From fba24a86bf7f748e448e09302fbfa89513d08715 Mon Sep 17 00:00:00 2001 From: "Craig Macomber (Microsoft)" <42876482+CraigMacomber@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:46:18 -0700 Subject: [PATCH] tree: Misc cleanup from after flex-tree schema removal (#22718) ## Description This does some cleanups enabled by the removal of the tree schema. --- .../.dependency-cruiser-known-violations.json | 14 ------- .../dds/tree/src/feature-libraries/index.ts | 10 ----- .../feature-libraries/typed-schema/README.md | 6 --- .../feature-libraries/typed-schema/index.ts | 16 -------- .../typed-schema/typedTreeSchema.ts | 14 ------- packages/dds/tree/src/index.ts | 4 +- packages/dds/tree/src/internalTypes.ts | 2 +- .../dds/tree/src/simple-tree/api/index.ts | 18 +++++++++ .../tree/src/simple-tree/api/schemaFactory.ts | 10 ++--- .../simple-tree/api/schemaFactoryRecursive.ts | 3 +- .../tree/src/simple-tree/api/treeNodeApi.ts | 11 ++---- .../src/simple-tree/{ => api}/typesUnsafe.ts | 20 +++++++--- .../dds/tree/src/simple-tree/arrayNode.ts | 2 +- .../TreeNodeBinding.md} | 0 .../dds/tree/src/simple-tree/core/index.ts | 1 + .../src/simple-tree/core/treeNodeKernel.ts | 13 +++++++ .../typed-schema => simple-tree}/flexList.ts | 0 packages/dds/tree/src/simple-tree/index.ts | 37 +++++++++---------- packages/dds/tree/src/simple-tree/mapNode.ts | 2 +- .../dds/tree/src/simple-tree/objectNode.ts | 2 +- .../dds/tree/src/simple-tree/proxyBinding.ts | 20 ---------- .../dds/tree/src/simple-tree/schemaTypes.ts | 8 +--- .../dds/tree/src/simple-tree/toFlexSchema.ts | 4 +- .../dds/tree/src/simple-tree/treeNodeValid.ts | 3 +- .../shared-tree/fuzz/fuzzEditGenerators.ts | 4 +- .../test/shared-tree/fuzz/fuzzEditReducers.ts | 3 +- .../src/test/shared-tree/treeCheckout.spec.ts | 4 +- .../api/schemaFactoryRecursive.spec.ts | 4 +- .../flexList.spec.ts | 4 +- .../src/test/simple-tree/typesUnsafe.spec.ts | 2 +- 30 files changed, 92 insertions(+), 149 deletions(-) delete mode 100644 packages/dds/tree/src/feature-libraries/typed-schema/README.md delete mode 100644 packages/dds/tree/src/feature-libraries/typed-schema/index.ts delete mode 100644 packages/dds/tree/src/feature-libraries/typed-schema/typedTreeSchema.ts rename packages/dds/tree/src/simple-tree/{ => api}/typesUnsafe.ts (92%) rename packages/dds/tree/src/simple-tree/{ProxyBinding.md => core/TreeNodeBinding.md} (100%) rename packages/dds/tree/src/{feature-libraries/typed-schema => simple-tree}/flexList.ts (100%) delete mode 100644 packages/dds/tree/src/simple-tree/proxyBinding.ts rename packages/dds/tree/src/test/{feature-libraries/typedSchema => simple-tree}/flexList.spec.ts (90%) diff --git a/packages/dds/tree/.dependency-cruiser-known-violations.json b/packages/dds/tree/.dependency-cruiser-known-violations.json index de2f815dfbe2..5b62380cf5be 100644 --- a/packages/dds/tree/.dependency-cruiser-known-violations.json +++ b/packages/dds/tree/.dependency-cruiser-known-violations.json @@ -11,19 +11,5 @@ "src/feature-libraries/flex-tree/lazyNode.ts", "src/feature-libraries/flex-tree/lazyField.ts" ] - }, - { - "type": "cycle", - "from": "src/feature-libraries/flex-tree/lazyField.ts", - "to": "src/feature-libraries/flex-tree/unboxed.ts", - "rule": { - "severity": "error", - "name": "no-circular" - }, - "cycle": [ - "src/feature-libraries/flex-tree/unboxed.ts", - "src/feature-libraries/flex-tree/lazyNode.ts", - "src/feature-libraries/flex-tree/lazyField.ts" - ] } ] \ No newline at end of file diff --git a/packages/dds/tree/src/feature-libraries/index.ts b/packages/dds/tree/src/feature-libraries/index.ts index 6fe8d3de9823..1d6b4ff96922 100644 --- a/packages/dds/tree/src/feature-libraries/index.ts +++ b/packages/dds/tree/src/feature-libraries/index.ts @@ -79,16 +79,6 @@ export { isNeverTree, } from "./modular-schema/index.js"; -export { - type Unenforced, - markEager, - type LazyItem, - type FlexListToUnion, - type ExtractItemType, - isLazy, - type FlexList, -} from "./typed-schema/index.js"; - export { mapRootChanges } from "./deltaUtils.js"; export { diff --git a/packages/dds/tree/src/feature-libraries/typed-schema/README.md b/packages/dds/tree/src/feature-libraries/typed-schema/README.md deleted file mode 100644 index b6373a3655b8..000000000000 --- a/packages/dds/tree/src/feature-libraries/typed-schema/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Typed Schema - -Schema building API which captures type information in both runtime data and TypeScript types. - -TODO: -The portion of this that is not dependent on specific field kinds should be separated from the part that does depend on specific field kinds. diff --git a/packages/dds/tree/src/feature-libraries/typed-schema/index.ts b/packages/dds/tree/src/feature-libraries/typed-schema/index.ts deleted file mode 100644 index bbc5c6c632fd..000000000000 --- a/packages/dds/tree/src/feature-libraries/typed-schema/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation and contributors. All rights reserved. - * Licensed under the MIT License. - */ - -export { type Unenforced } from "./typedTreeSchema.js"; - -export { - type FlexList, - markEager, - type LazyItem, - isLazy, - type FlexListToUnion, - type ExtractItemType, - normalizeFlexListEager, -} from "./flexList.js"; diff --git a/packages/dds/tree/src/feature-libraries/typed-schema/typedTreeSchema.ts b/packages/dds/tree/src/feature-libraries/typed-schema/typedTreeSchema.ts deleted file mode 100644 index e38c4d90360f..000000000000 --- a/packages/dds/tree/src/feature-libraries/typed-schema/typedTreeSchema.ts +++ /dev/null @@ -1,14 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation and contributors. All rights reserved. - * Licensed under the MIT License. - */ - -/** - * A placeholder to use in {@link https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-constraints | extends constraints} when using the real type breaks compilation of some recursive types due to {@link https://github.com/microsoft/TypeScript/issues/55758 | a design limitation of TypeScript}. - * - * These extends constraints only serve as documentation: - * to avoid breaking compilation, this type has to not actually enforce anything, and thus is just `unknown`. - * Therefore the type safety is the responsibility of the user of the API. - * @public - */ -export type Unenforced<_DesiredExtendsConstraint> = unknown; diff --git a/packages/dds/tree/src/index.ts b/packages/dds/tree/src/index.ts index e85c2e26c301..bb30dbfa54c6 100644 --- a/packages/dds/tree/src/index.ts +++ b/packages/dds/tree/src/index.ts @@ -40,9 +40,7 @@ export { } from "./events/index.js"; export { - type LazyItem, TreeStatus, - type Unenforced, TreeCompressionStrategy, } from "./feature-libraries/index.js"; @@ -150,6 +148,8 @@ export { type JsonSchemaType, type JsonLeafSchemaType, getJsonSchema, + type LazyItem, + type Unenforced, } from "./simple-tree/index.js"; export { SharedTree, diff --git a/packages/dds/tree/src/internalTypes.ts b/packages/dds/tree/src/internalTypes.ts index e20a52238ed0..9d322ff3b802 100644 --- a/packages/dds/tree/src/internalTypes.ts +++ b/packages/dds/tree/src/internalTypes.ts @@ -34,6 +34,6 @@ export type { NodeFromSchemaUnsafe, ReadonlyMapInlined, } from "./simple-tree/index.js"; -export type { FlexList, FlexListToUnion, ExtractItemType } from "./feature-libraries/index.js"; +export type { FlexList, FlexListToUnion, ExtractItemType } from "./simple-tree/index.js"; export type { TreeApi } from "./shared-tree/index.js"; diff --git a/packages/dds/tree/src/simple-tree/api/index.ts b/packages/dds/tree/src/simple-tree/api/index.ts index 9669e922b111..a8a91e24e638 100644 --- a/packages/dds/tree/src/simple-tree/api/index.ts +++ b/packages/dds/tree/src/simple-tree/api/index.ts @@ -46,6 +46,24 @@ export { export { getJsonSchema } from "./getJsonSchema.js"; export { getSimpleSchema } from "./getSimpleSchema.js"; export { ViewSchema } from "./view.js"; +export type { + Unenforced, + FieldHasDefaultUnsafe, + ObjectFromSchemaRecordUnsafe, + TreeObjectNodeUnsafe, + TreeFieldFromImplicitFieldUnsafe, + TreeNodeFromImplicitAllowedTypesUnsafe, + FieldSchemaUnsafe, + InsertableTreeNodeFromImplicitAllowedTypesUnsafe, + TreeArrayNodeUnsafe, + TreeMapNodeUnsafe, + InsertableObjectFromSchemaRecordUnsafe, + InsertableTreeFieldFromImplicitFieldUnsafe, + InsertableTypedNodeUnsafe, + NodeBuilderDataUnsafe, + NodeFromSchemaUnsafe, + ReadonlyMapInlined, +} from "./typesUnsafe.js"; export { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from "./treeApiBeta.js"; diff --git a/packages/dds/tree/src/simple-tree/api/schemaFactory.ts b/packages/dds/tree/src/simple-tree/api/schemaFactory.ts index cee408e0b81f..459140a943e0 100644 --- a/packages/dds/tree/src/simple-tree/api/schemaFactory.ts +++ b/packages/dds/tree/src/simple-tree/api/schemaFactory.ts @@ -12,11 +12,7 @@ import { UsageError } from "@fluidframework/telemetry-utils/internal"; import { isFluidHandle } from "@fluidframework/runtime-utils/internal"; import type { TreeValue } from "../../core/index.js"; -import { - type NodeKeyManager, - type Unenforced, - isLazy, -} from "../../feature-libraries/index.js"; +import type { NodeKeyManager } from "../../feature-libraries/index.js"; import { type RestrictiveStringRecord, getOrCreate, @@ -73,9 +69,11 @@ import type { TreeArrayNodeUnsafe, TreeMapNodeUnsafe, TreeObjectNodeUnsafe, -} from "../typesUnsafe.js"; + Unenforced, +} from "./typesUnsafe.js"; import { createFieldSchemaUnsafe } from "./schemaFactoryRecursive.js"; import { TreeNodeValid } from "../treeNodeValid.js"; +import { isLazy } from "../flexList.js"; /** * Gets the leaf domain schema compatible with a given {@link TreeValue}. */ diff --git a/packages/dds/tree/src/simple-tree/api/schemaFactoryRecursive.ts b/packages/dds/tree/src/simple-tree/api/schemaFactoryRecursive.ts index a4322fb2c61a..204d1b2452de 100644 --- a/packages/dds/tree/src/simple-tree/api/schemaFactoryRecursive.ts +++ b/packages/dds/tree/src/simple-tree/api/schemaFactoryRecursive.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. */ -import type { Unenforced } from "../../feature-libraries/index.js"; import type { RestrictiveStringRecord } from "../../util/index.js"; import type { InsertableObjectFromSchemaRecord } from "../objectNode.js"; @@ -22,7 +21,7 @@ import type { WithType, TreeNode, } from "../core/index.js"; -import type { FieldSchemaUnsafe } from "../typesUnsafe.js"; +import type { FieldSchemaUnsafe, Unenforced } from "./typesUnsafe.js"; export function createFieldSchemaUnsafe< Kind extends FieldKind, diff --git a/packages/dds/tree/src/simple-tree/api/treeNodeApi.ts b/packages/dds/tree/src/simple-tree/api/treeNodeApi.ts index 9bb0faa586d5..3154ed67d8e0 100644 --- a/packages/dds/tree/src/simple-tree/api/treeNodeApi.ts +++ b/packages/dds/tree/src/simple-tree/api/treeNodeApi.ts @@ -6,15 +6,8 @@ import { assert, oob } from "@fluidframework/core-utils/internal"; import { EmptyKey, rootFieldKey } from "../../core/index.js"; -import { - type LazyItem, - type TreeStatus, - isLazy, - isTreeValue, - FieldKinds, -} from "../../feature-libraries/index.js"; +import { type TreeStatus, isTreeValue, FieldKinds } from "../../feature-libraries/index.js"; import { fail, extractFromOpaque, isReadonlyArray } from "../../util/index.js"; -import { getOrCreateInnerNode } from "../proxyBinding.js"; import { type TreeLeafValue, type ImplicitFieldSchema, @@ -43,8 +36,10 @@ import { getOrCreateNodeFromInnerNode, UnhydratedFlexTreeNode, typeSchemaSymbol, + getOrCreateInnerNode, } from "../core/index.js"; import { isObjectNodeSchema } from "../objectNodeTypes.js"; +import { isLazy, type LazyItem } from "../flexList.js"; /** * Provides various functions for analyzing {@link TreeNode}s. diff --git a/packages/dds/tree/src/simple-tree/typesUnsafe.ts b/packages/dds/tree/src/simple-tree/api/typesUnsafe.ts similarity index 92% rename from packages/dds/tree/src/simple-tree/typesUnsafe.ts rename to packages/dds/tree/src/simple-tree/api/typesUnsafe.ts index 4104b19b0967..f7506b229292 100644 --- a/packages/dds/tree/src/simple-tree/typesUnsafe.ts +++ b/packages/dds/tree/src/simple-tree/api/typesUnsafe.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. */ -import type { FlexListToUnion, Unenforced } from "../feature-libraries/index.js"; -import type { RestrictiveStringRecord, _InlineTrick } from "../util/index.js"; +import type { RestrictiveStringRecord, _InlineTrick } from "../../util/index.js"; import type { AllowedTypes, @@ -15,15 +14,16 @@ import type { ImplicitFieldSchema, NodeFromSchema, TreeNodeFromImplicitAllowedTypes, -} from "./schemaTypes.js"; +} from "../schemaTypes.js"; import type { NodeKind, TreeNodeSchema, WithType, TreeNode, Unhydrated, -} from "./core/index.js"; -import type { TreeArrayNodeBase, TreeArrayNode } from "./arrayNode.js"; +} from "../core/index.js"; +import type { TreeArrayNodeBase, TreeArrayNode } from "../arrayNode.js"; +import type { FlexListToUnion } from "../flexList.js"; /* * TODO: @@ -37,6 +37,16 @@ import type { TreeArrayNodeBase, TreeArrayNode } from "./arrayNode.js"; */ /* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * A placeholder to use in {@link https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-constraints | extends constraints} when using the real type breaks compilation of some recursive types due to {@link https://github.com/microsoft/TypeScript/issues/55758 | a design limitation of TypeScript}. + * + * These extends constraints only serve as documentation: + * to avoid breaking compilation, this type has to not actually enforce anything, and thus is just `unknown`. + * Therefore the type safety is the responsibility of the user of the API. + * @public + */ +export type Unenforced<_DesiredExtendsConstraint> = unknown; + /** * {@link Unenforced} version of `ObjectFromSchemaRecord`. * @remarks diff --git a/packages/dds/tree/src/simple-tree/arrayNode.ts b/packages/dds/tree/src/simple-tree/arrayNode.ts index 9f930a6d9dcc..318c26e9834d 100644 --- a/packages/dds/tree/src/simple-tree/arrayNode.ts +++ b/packages/dds/tree/src/simple-tree/arrayNode.ts @@ -14,7 +14,6 @@ import { isFlexTreeNode, } from "../feature-libraries/index.js"; import { prepareContentForHydration } from "./proxies.js"; -import { getOrCreateInnerNode } from "./proxyBinding.js"; import { normalizeAllowedTypes, type ImplicitAllowedTypes, @@ -34,6 +33,7 @@ import { getOrCreateNodeFromInnerNode, type TreeNodeSchemaBoth, getSimpleNodeSchemaFromInnerNode, + getOrCreateInnerNode, } from "./core/index.js"; import { type InsertableContent, mapTreeFromNodeData } from "./toMapTree.js"; import { fail } from "../util/index.js"; diff --git a/packages/dds/tree/src/simple-tree/ProxyBinding.md b/packages/dds/tree/src/simple-tree/core/TreeNodeBinding.md similarity index 100% rename from packages/dds/tree/src/simple-tree/ProxyBinding.md rename to packages/dds/tree/src/simple-tree/core/TreeNodeBinding.md diff --git a/packages/dds/tree/src/simple-tree/core/index.ts b/packages/dds/tree/src/simple-tree/core/index.ts index f4701ae4541a..ca50e3699ca0 100644 --- a/packages/dds/tree/src/simple-tree/core/index.ts +++ b/packages/dds/tree/src/simple-tree/core/index.ts @@ -11,6 +11,7 @@ export { type InnerNode, tryDisposeTreeNode, tryGetTreeNodeFromMapNode, + getOrCreateInnerNode, } from "./treeNodeKernel.js"; export { type WithType, typeNameSymbol, typeSchemaSymbol } from "./withType.js"; export { diff --git a/packages/dds/tree/src/simple-tree/core/treeNodeKernel.ts b/packages/dds/tree/src/simple-tree/core/treeNodeKernel.ts index 42b5d1366040..ef0a6b6f8cf3 100644 --- a/packages/dds/tree/src/simple-tree/core/treeNodeKernel.ts +++ b/packages/dds/tree/src/simple-tree/core/treeNodeKernel.ts @@ -430,3 +430,16 @@ export function getTreeNodeSchemaFromHydratedFlexNode(flexNode: FlexTreeNode): T return context.schema.get(flexNode.schema) ?? fail("Missing schema"); } + +/** + * Retrieves the flex node associated with the given target via {@link setInnerNode}. + * @remarks + * For {@link Unhydrated} nodes, this returns the MapTreeNode. + * + * For hydrated nodes it returns a FlexTreeNode backed by the forest. + * Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode. + */ +export function getOrCreateInnerNode(treeNode: TreeNode, allowFreed = false): InnerNode { + const kernel = getKernel(treeNode); + return kernel.getOrCreateInnerNode(allowFreed); +} diff --git a/packages/dds/tree/src/feature-libraries/typed-schema/flexList.ts b/packages/dds/tree/src/simple-tree/flexList.ts similarity index 100% rename from packages/dds/tree/src/feature-libraries/typed-schema/flexList.ts rename to packages/dds/tree/src/simple-tree/flexList.ts diff --git a/packages/dds/tree/src/simple-tree/index.ts b/packages/dds/tree/src/simple-tree/index.ts index 2566befc949d..dc4f0dcfb38d 100644 --- a/packages/dds/tree/src/simple-tree/index.ts +++ b/packages/dds/tree/src/simple-tree/index.ts @@ -22,6 +22,7 @@ export { tryDisposeTreeNode, HydratedContext, SimpleContextSlot, + getOrCreateInnerNode, } from "./core/index.js"; export { type ITree, @@ -68,6 +69,22 @@ export { getJsonSchema, getSimpleSchema, ViewSchema, + type Unenforced, + type FieldHasDefaultUnsafe, + type ObjectFromSchemaRecordUnsafe, + type TreeObjectNodeUnsafe, + type TreeFieldFromImplicitFieldUnsafe, + type TreeNodeFromImplicitAllowedTypesUnsafe, + type FieldSchemaUnsafe, + type InsertableTreeNodeFromImplicitAllowedTypesUnsafe, + type TreeArrayNodeUnsafe, + type TreeMapNodeUnsafe, + type InsertableObjectFromSchemaRecordUnsafe, + type InsertableTreeFieldFromImplicitFieldUnsafe, + type InsertableTypedNodeUnsafe, + type NodeBuilderDataUnsafe, + type NodeFromSchemaUnsafe, + type ReadonlyMapInlined, } from "./api/index.js"; export { type NodeFromSchema, @@ -90,29 +107,10 @@ export { type ApplyKind, type FieldSchemaMetadata, } from "./schemaTypes.js"; -export { getOrCreateInnerNode } from "./proxyBinding.js"; -export type { - FieldHasDefaultUnsafe, - ObjectFromSchemaRecordUnsafe, - TreeObjectNodeUnsafe, - TreeFieldFromImplicitFieldUnsafe, - TreeNodeFromImplicitAllowedTypesUnsafe, - FieldSchemaUnsafe, - InsertableTreeNodeFromImplicitAllowedTypesUnsafe, - TreeArrayNodeUnsafe, - TreeMapNodeUnsafe, - InsertableObjectFromSchemaRecordUnsafe, - InsertableTreeFieldFromImplicitFieldUnsafe, - InsertableTypedNodeUnsafe, - NodeBuilderDataUnsafe, - NodeFromSchemaUnsafe, - ReadonlyMapInlined, -} from "./typesUnsafe.js"; export { getTreeNodeForField, prepareContentForHydration, } from "./proxies.js"; - export { TreeArrayNode, IterableTreeArrayContent, @@ -135,3 +133,4 @@ export { handleSchema, nullSchema, } from "./leafNodeSchema.js"; +export type { LazyItem, FlexList, FlexListToUnion, ExtractItemType } from "./flexList.js"; diff --git a/packages/dds/tree/src/simple-tree/mapNode.ts b/packages/dds/tree/src/simple-tree/mapNode.ts index 094a2eb12ef3..1c5935a4a386 100644 --- a/packages/dds/tree/src/simple-tree/mapNode.ts +++ b/packages/dds/tree/src/simple-tree/mapNode.ts @@ -11,7 +11,6 @@ import { getSchemaAndPolicy, } from "../feature-libraries/index.js"; import { getTreeNodeForField, prepareContentForHydration } from "./proxies.js"; -import { getOrCreateInnerNode } from "./proxyBinding.js"; import { createFieldSchema, FieldKind, @@ -33,6 +32,7 @@ import { typeSchemaSymbol, type Context, UnhydratedFlexTreeNode, + getOrCreateInnerNode, } from "./core/index.js"; import { mapTreeFromNodeData, diff --git a/packages/dds/tree/src/simple-tree/objectNode.ts b/packages/dds/tree/src/simple-tree/objectNode.ts index 8f0993fd9895..b17847ee5626 100644 --- a/packages/dds/tree/src/simple-tree/objectNode.ts +++ b/packages/dds/tree/src/simple-tree/objectNode.ts @@ -16,7 +16,6 @@ import { getSchemaAndPolicy, } from "../feature-libraries/index.js"; import { getTreeNodeForField, prepareContentForHydration } from "./proxies.js"; -import { getOrCreateInnerNode } from "./proxyBinding.js"; import { type ImplicitFieldSchema, getStoredKey, @@ -39,6 +38,7 @@ import { type TreeNode, type Context, UnhydratedFlexTreeNode, + getOrCreateInnerNode, } from "./core/index.js"; import { mapTreeFromNodeData, type InsertableContent } from "./toMapTree.js"; import { type RestrictiveStringRecord, fail, type FlattenKeys } from "../util/index.js"; diff --git a/packages/dds/tree/src/simple-tree/proxyBinding.ts b/packages/dds/tree/src/simple-tree/proxyBinding.ts deleted file mode 100644 index 1a1386b4fe07..000000000000 --- a/packages/dds/tree/src/simple-tree/proxyBinding.ts +++ /dev/null @@ -1,20 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation and contributors. All rights reserved. - * Licensed under the MIT License. - */ - -import type { InnerNode, TreeNode } from "./core/index.js"; -import { getKernel } from "./core/index.js"; - -/** - * Retrieves the flex node associated with the given target via {@link setInnerNode}. - * @remarks - * For {@link Unhydrated} nodes, this returns the MapTreeNode. - * - * For hydrated nodes it returns a FlexTreeNode backed by the forest. - * Note that for "marinated" nodes, this FlexTreeNode exists and returns it: it does not return the MapTreeNode which is the current InnerNode. - */ -export function getOrCreateInnerNode(treeNode: TreeNode, allowFreed = false): InnerNode { - const kernel = getKernel(treeNode); - return kernel.getOrCreateInnerNode(allowFreed); -} diff --git a/packages/dds/tree/src/simple-tree/schemaTypes.ts b/packages/dds/tree/src/simple-tree/schemaTypes.ts index 32596d4d43f4..73dc2db36990 100644 --- a/packages/dds/tree/src/simple-tree/schemaTypes.ts +++ b/packages/dds/tree/src/simple-tree/schemaTypes.ts @@ -7,12 +7,7 @@ import type { ErasedType, IFluidHandle } from "@fluidframework/core-interfaces"; import { Lazy } from "@fluidframework/core-utils/internal"; import { UsageError } from "@fluidframework/telemetry-utils/internal"; -import { - type LazyItem, - type NodeKeyManager, - isLazy, - type FlexListToUnion, -} from "../feature-libraries/index.js"; +import type { NodeKeyManager } from "../feature-libraries/index.js"; import { type MakeNominal, brand, isReadonlyArray } from "../util/index.js"; import type { Unhydrated, @@ -22,6 +17,7 @@ import type { } from "./core/index.js"; import type { FieldKey } from "../core/index.js"; import type { InsertableContent } from "./toMapTree.js"; +import { isLazy, type FlexListToUnion, type LazyItem } from "./flexList.js"; /** * Returns true if the given schema is a {@link TreeNodeSchemaClass}, or otherwise false if it is a {@link TreeNodeSchemaNonClass}. diff --git a/packages/dds/tree/src/simple-tree/toFlexSchema.ts b/packages/dds/tree/src/simple-tree/toFlexSchema.ts index d4116a6d1283..ae5b614d050d 100644 --- a/packages/dds/tree/src/simple-tree/toFlexSchema.ts +++ b/packages/dds/tree/src/simple-tree/toFlexSchema.ts @@ -20,9 +20,6 @@ import { type TreeTypeSet, } from "../core/index.js"; import { FieldKinds, type FlexFieldKind } from "../feature-libraries/index.js"; -// TODO: once flex schema is gone, this code can move into simple-tree -// eslint-disable-next-line import/no-internal-modules -import { normalizeFlexListEager } from "../feature-libraries/typed-schema/index.js"; import { brand, fail, isReadonlyArray } from "../util/index.js"; import { NodeKind, type TreeNodeSchema } from "./core/index.js"; import { @@ -34,6 +31,7 @@ import { import { walkFieldSchema } from "./walkFieldSchema.js"; import { LeafNodeSchema } from "./leafNodeSchema.js"; import { isObjectNodeSchema } from "./objectNodeTypes.js"; +import { normalizeFlexListEager } from "./flexList.js"; /** * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}. diff --git a/packages/dds/tree/src/simple-tree/treeNodeValid.ts b/packages/dds/tree/src/simple-tree/treeNodeValid.ts index 53415d517aba..6fe4d665276d 100644 --- a/packages/dds/tree/src/simple-tree/treeNodeValid.ts +++ b/packages/dds/tree/src/simple-tree/treeNodeValid.ts @@ -18,11 +18,12 @@ import { type Context, type UnhydratedFlexTreeNode, } from "./core/index.js"; -import { type FlexTreeNode, isFlexTreeNode, markEager } from "../feature-libraries/index.js"; +import { type FlexTreeNode, isFlexTreeNode } from "../feature-libraries/index.js"; import { UsageError } from "@fluidframework/telemetry-utils/internal"; import { fail } from "../util/index.js"; import { getSimpleNodeSchemaFromInnerNode } from "./core/index.js"; +import { markEager } from "./flexList.js"; /** * Class which all {@link TreeNode}s must extend. diff --git a/packages/dds/tree/src/test/shared-tree/fuzz/fuzzEditGenerators.ts b/packages/dds/tree/src/test/shared-tree/fuzz/fuzzEditGenerators.ts index 1512dc39a566..332a54b95e42 100644 --- a/packages/dds/tree/src/test/shared-tree/fuzz/fuzzEditGenerators.ts +++ b/packages/dds/tree/src/test/shared-tree/fuzz/fuzzEditGenerators.ts @@ -62,9 +62,7 @@ import { } from "./operationTypes.js"; // eslint-disable-next-line import/no-internal-modules import type { SchematizingSimpleTreeView } from "../../../shared-tree/schematizingTreeView.js"; - -// eslint-disable-next-line import/no-internal-modules -import { getOrCreateInnerNode } from "../../../simple-tree/proxyBinding.js"; +import { getOrCreateInnerNode } from "../../../simple-tree/index.js"; import { SchemaFactory, TreeViewConfiguration, diff --git a/packages/dds/tree/src/test/shared-tree/fuzz/fuzzEditReducers.ts b/packages/dds/tree/src/test/shared-tree/fuzz/fuzzEditReducers.ts index c8dd94e08dee..36b852d5c456 100644 --- a/packages/dds/tree/src/test/shared-tree/fuzz/fuzzEditReducers.ts +++ b/packages/dds/tree/src/test/shared-tree/fuzz/fuzzEditReducers.ts @@ -52,8 +52,7 @@ import { type GUIDNodeValue, } from "./operationTypes.js"; -// eslint-disable-next-line import/no-internal-modules -import { getOrCreateInnerNode } from "../../../simple-tree/proxyBinding.js"; +import { getOrCreateInnerNode } from "../../../simple-tree/index.js"; // eslint-disable-next-line import/no-internal-modules import { isObjectNodeSchema } from "../../../simple-tree/objectNodeTypes.js"; import { diff --git a/packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts b/packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts index fe38d27e95b4..695e01b146b7 100644 --- a/packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts +++ b/packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts @@ -45,10 +45,8 @@ import { type InsertableTreeFieldFromImplicitField, } from "../../index.js"; // eslint-disable-next-line import/no-internal-modules -import { getOrCreateInnerNode } from "../../simple-tree/proxyBinding.js"; -// eslint-disable-next-line import/no-internal-modules import { SchematizingSimpleTreeView } from "../../shared-tree/schematizingTreeView.js"; -import { toStoredSchema } from "../../simple-tree/index.js"; +import { getOrCreateInnerNode, toStoredSchema } from "../../simple-tree/index.js"; // eslint-disable-next-line import/no-internal-modules import { stringSchema } from "../../simple-tree/leafNodeSchema.js"; diff --git a/packages/dds/tree/src/test/simple-tree/api/schemaFactoryRecursive.spec.ts b/packages/dds/tree/src/test/simple-tree/api/schemaFactoryRecursive.spec.ts index 698e6327ac47..275dec3a8889 100644 --- a/packages/dds/tree/src/test/simple-tree/api/schemaFactoryRecursive.spec.ts +++ b/packages/dds/tree/src/test/simple-tree/api/schemaFactoryRecursive.spec.ts @@ -10,7 +10,6 @@ import { strict as assert } from "node:assert"; import { createIdCompressor } from "@fluidframework/id-compressor/internal"; import { MockFluidDataStoreRuntime } from "@fluidframework/test-runtime-utils/internal"; -import type { FlexListToUnion } from "../../../feature-libraries/index.js"; import { type FieldSchema, type InsertableTreeNodeFromImplicitAllowedTypes, @@ -21,6 +20,7 @@ import { SchemaFactory, type InternalTreeNode, type ApplyKind, + type FlexListToUnion, } from "../../../simple-tree/index.js"; import type { ValidateRecursiveSchema, @@ -33,7 +33,7 @@ import type { TreeFieldFromImplicitFieldUnsafe, TreeNodeFromImplicitAllowedTypesUnsafe, // eslint-disable-next-line import/no-internal-modules -} from "../../../simple-tree/typesUnsafe.js"; +} from "../../../simple-tree/api/typesUnsafe.js"; import { TreeFactory } from "../../../treeFactory.js"; import type { areSafelyAssignable, diff --git a/packages/dds/tree/src/test/feature-libraries/typedSchema/flexList.spec.ts b/packages/dds/tree/src/test/simple-tree/flexList.spec.ts similarity index 90% rename from packages/dds/tree/src/test/feature-libraries/typedSchema/flexList.spec.ts rename to packages/dds/tree/src/test/simple-tree/flexList.spec.ts index ce291e837270..2afb9f3e9eea 100644 --- a/packages/dds/tree/src/test/feature-libraries/typedSchema/flexList.spec.ts +++ b/packages/dds/tree/src/test/simple-tree/flexList.spec.ts @@ -13,8 +13,8 @@ import { normalizeFlexListEager, // Allow importing from this specific file which is being tested: /* eslint-disable-next-line import/no-internal-modules */ -} from "../../../feature-libraries/typed-schema/flexList.js"; -import type { areSafelyAssignable, requireTrue } from "../../../util/index.js"; +} from "../../simple-tree/flexList.js"; +import type { areSafelyAssignable, requireTrue } from "../../util/index.js"; // Test FlexListToUnion { diff --git a/packages/dds/tree/src/test/simple-tree/typesUnsafe.spec.ts b/packages/dds/tree/src/test/simple-tree/typesUnsafe.spec.ts index 0b5c05026c43..82f2817bd224 100644 --- a/packages/dds/tree/src/test/simple-tree/typesUnsafe.spec.ts +++ b/packages/dds/tree/src/test/simple-tree/typesUnsafe.spec.ts @@ -4,7 +4,7 @@ */ // eslint-disable-next-line import/no-internal-modules -import type { ReadonlyMapInlined } from "../../simple-tree/typesUnsafe.js"; +import type { ReadonlyMapInlined } from "../../simple-tree/api/typesUnsafe.js"; // eslint-disable-next-line import/no-internal-modules import type { numberSchema } from "../../simple-tree/leafNodeSchema.js"; import type { areSafelyAssignable, requireTrue } from "../../util/index.js";