From 9e61721c36eb1665c5add8a1e858c7983d08b542 Mon Sep 17 00:00:00 2001 From: daesunp <138815173+daesunp@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:36:53 -0800 Subject: [PATCH] move chunk.ts file to core/tree (#23173) ## Description Moves the `chunk.ts` to `core/tree` to separate some chunk interfaces and types from the `ChunkedForest`. --- packages/dds/tree/src/core/index.ts | 5 +++++ .../chunked-forest => core/tree}/chunk.ts | 8 ++++---- packages/dds/tree/src/core/tree/index.ts | 8 ++++++++ .../src/feature-libraries/chunked-forest/basicChunk.ts | 6 ++++-- .../src/feature-libraries/chunked-forest/chunkTree.ts | 3 ++- .../src/feature-libraries/chunked-forest/chunkedForest.ts | 3 ++- .../chunked-forest/codec/chunkCodecUtilities.ts | 3 +-- .../chunked-forest/codec/chunkDecoding.ts | 8 ++++++-- .../chunked-forest/codec/chunkDecodingGeneric.ts | 2 +- .../src/feature-libraries/chunked-forest/emptyChunk.ts | 6 ++++-- .../tree/src/feature-libraries/chunked-forest/index.ts | 2 +- .../src/feature-libraries/chunked-forest/sequenceChunk.ts | 2 +- .../src/feature-libraries/chunked-forest/uniformChunk.ts | 5 ++++- .../feature-libraries/chunked-forest/basicChunk.spec.ts | 5 +---- .../feature-libraries/chunked-forest/chunkTree.spec.ts | 3 +-- .../chunked-forest/codec/chunkDecodingGeneric.spec.ts | 2 +- 16 files changed, 46 insertions(+), 25 deletions(-) rename packages/dds/tree/src/{feature-libraries/chunked-forest => core/tree}/chunk.ts (96%) diff --git a/packages/dds/tree/src/core/index.ts b/packages/dds/tree/src/core/index.ts index fdb6435bf731..a14043ce84d0 100644 --- a/packages/dds/tree/src/core/index.ts +++ b/packages/dds/tree/src/core/index.ts @@ -99,6 +99,11 @@ export { type DeltaFieldChanges, type ExclusiveMapTree, deepCopyMapTree, + type TreeChunk, + dummyRoot, + cursorChunk, + tryGetChunk, + type ChunkedCursor, } from "./tree/index.js"; export { diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/chunk.ts b/packages/dds/tree/src/core/tree/chunk.ts similarity index 96% rename from packages/dds/tree/src/feature-libraries/chunked-forest/chunk.ts rename to packages/dds/tree/src/core/tree/chunk.ts index d7367d34ad81..61072ad361b0 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/chunk.ts +++ b/packages/dds/tree/src/core/tree/chunk.ts @@ -5,14 +5,14 @@ import { assert } from "@fluidframework/core-utils/internal"; +import type { ReferenceCounted } from "../../util/index.js"; +import type { FieldKey } from "../schema-stored/index.js"; +import { rootFieldKey } from "./types.js"; import { CursorLocationType, - type FieldKey, type ITreeCursor, type ITreeCursorSynchronous, - rootFieldKey, -} from "../../core/index.js"; -import type { ReferenceCounted } from "../../util/index.js"; +} from "./cursor.js"; /** * Contiguous part of the tree which get stored together in some data format. diff --git a/packages/dds/tree/src/core/tree/index.ts b/packages/dds/tree/src/core/tree/index.ts index efc4147a6ea0..edab69d49277 100644 --- a/packages/dds/tree/src/core/tree/index.ts +++ b/packages/dds/tree/src/core/tree/index.ts @@ -111,5 +111,13 @@ export { emptyDelta, } from "./deltaUtil.js"; +export { + type TreeChunk, + dummyRoot, + cursorChunk, + tryGetChunk, + type ChunkedCursor, +} from "./chunk.js"; + export { DetachedFieldIndex } from "./detachedFieldIndex.js"; export { type ForestRootId } from "./detachedFieldIndexTypes.js"; diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/basicChunk.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/basicChunk.ts index e613489d7e7f..afa37915cc50 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/basicChunk.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/basicChunk.ts @@ -15,12 +15,14 @@ import { type TreeValue, type UpPath, type Value, + type ChunkedCursor, + type TreeChunk, + cursorChunk, + dummyRoot, } from "../../core/index.js"; import { ReferenceCountedBase, fail } from "../../util/index.js"; import { SynchronousCursor, prefixPath } from "../treeCursorUtils.js"; -import { type ChunkedCursor, type TreeChunk, cursorChunk, dummyRoot } from "./chunk.js"; - /** * General purpose one node chunk. */ diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/chunkTree.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/chunkTree.ts index 521eea910817..9239a6c3d33a 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/chunkTree.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/chunkTree.ts @@ -21,12 +21,13 @@ import { mapCursorFields, Multiplicity, ValueSchema, + type TreeChunk, + tryGetChunk, } from "../../core/index.js"; import { fail, getOrCreate } from "../../util/index.js"; import type { FullSchemaPolicy } from "../modular-schema/index.js"; import { BasicChunk } from "./basicChunk.js"; -import { type TreeChunk, tryGetChunk } from "./chunk.js"; import { SequenceChunk } from "./sequenceChunk.js"; import { type FieldShape, TreeShape, UniformChunk } from "./uniformChunk.js"; import { isStableNodeKey } from "../node-key/index.js"; diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/chunkedForest.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/chunkedForest.ts index 1f741b3ce00c..739117f68e95 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/chunkedForest.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/chunkedForest.ts @@ -31,6 +31,8 @@ import { detachedFieldAsKey, mapCursorField, rootFieldKey, + type ChunkedCursor, + type TreeChunk, } from "../../core/index.js"; import { assertValidRange, @@ -42,7 +44,6 @@ import { } from "../../util/index.js"; import { BasicChunk, BasicChunkCursor, type SiblingsOrKey } from "./basicChunk.js"; -import type { ChunkedCursor, TreeChunk } from "./chunk.js"; import { type IChunker, basicChunkTree, chunkTree } from "./chunkTree.js"; import type { IIdCompressor } from "@fluidframework/id-compressor"; diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts index bb062a74f505..3f2ea33767d5 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkCodecUtilities.ts @@ -5,10 +5,9 @@ import { assert, oob } from "@fluidframework/core-utils/internal"; -import type { TreeValue } from "../../../core/index.js"; +import type { TreeValue, TreeChunk } from "../../../core/index.js"; import { assertValidIndex } from "../../../util/index.js"; import { type FluidSerializableReadOnly, assertAllowedValue } from "../../valueUtilities.js"; -import type { TreeChunk } from "../chunk.js"; /** * Utilities related to chunk encoding and decoding that do not depend on specific chunk types or formats. diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts index 190c6f3042b3..0a5c15c91b0e 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts @@ -6,10 +6,14 @@ import { assert, unreachableCase, oob } from "@fluidframework/core-utils/internal"; import { DiscriminatedUnionDispatcher } from "../../../codec/index.js"; -import type { FieldKey, TreeNodeSchemaIdentifier, Value } from "../../../core/index.js"; +import type { + FieldKey, + TreeNodeSchemaIdentifier, + Value, + TreeChunk, +} from "../../../core/index.js"; import { assertValidIndex } from "../../../util/index.js"; import { BasicChunk } from "../basicChunk.js"; -import type { TreeChunk } from "../chunk.js"; import { emptyChunk } from "../emptyChunk.js"; import { SequenceChunk } from "../sequenceChunk.js"; diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts index 2eda4e43f0e0..c1cf210602c5 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts @@ -7,7 +7,7 @@ import { assert } from "@fluidframework/core-utils/internal"; import type { DiscriminatedUnionDispatcher } from "../../../codec/index.js"; import type { BrandedType } from "../../../util/index.js"; -import type { TreeChunk } from "../chunk.js"; +import type { TreeChunk } from "../../../core/index.js"; import { type ChunkDecoder, diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/emptyChunk.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/emptyChunk.ts index 0ff74157094e..446f08ef8179 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/emptyChunk.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/emptyChunk.ts @@ -10,12 +10,14 @@ import { type FieldUpPath, type PathRootPrefix, type UpPath, + type ChunkedCursor, + type TreeChunk, + cursorChunk, + dummyRoot, } from "../../core/index.js"; import { fail } from "../../util/index.js"; import { prefixFieldPath } from "../treeCursorUtils.js"; -import { type ChunkedCursor, type TreeChunk, cursorChunk, dummyRoot } from "./chunk.js"; - /** * Chunk that is empty. * diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/index.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/index.ts index 9cd34fa827f9..65146004d157 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/index.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/index.ts @@ -4,7 +4,7 @@ */ export { uniformChunk, ChunkShape } from "./uniformChunk.js"; -export { type TreeChunk, dummyRoot } from "./chunk.js"; +export { type TreeChunk, dummyRoot } from "../../core/index.js"; export { chunkTree, defaultChunkPolicy, diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/sequenceChunk.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/sequenceChunk.ts index c72b2b163e97..75539f1a3f58 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/sequenceChunk.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/sequenceChunk.ts @@ -6,7 +6,7 @@ import { ReferenceCountedBase } from "../../util/index.js"; import { BasicChunkCursor } from "./basicChunk.js"; -import { type ChunkedCursor, type TreeChunk, dummyRoot } from "./chunk.js"; +import { type ChunkedCursor, type TreeChunk, dummyRoot } from "../../core/index.js"; /** * General purpose multi-node sequence chunk. diff --git a/packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts b/packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts index 01deb2dacd85..e5768f1a17f7 100644 --- a/packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts +++ b/packages/dds/tree/src/feature-libraries/chunked-forest/uniformChunk.ts @@ -14,11 +14,14 @@ import { type TreeValue, type UpPath, type Value, + type ChunkedCursor, + type TreeChunk, + cursorChunk, + dummyRoot, } from "../../core/index.js"; import { ReferenceCountedBase, fail, hasSome } from "../../util/index.js"; import { SynchronousCursor, prefixFieldPath, prefixPath } from "../treeCursorUtils.js"; -import { type ChunkedCursor, type TreeChunk, cursorChunk, dummyRoot } from "./chunk.js"; import type { SessionSpaceCompressedId, IIdCompressor } from "@fluidframework/id-compressor"; import { UsageError } from "@fluidframework/telemetry-utils/internal"; diff --git a/packages/dds/tree/src/test/feature-libraries/chunked-forest/basicChunk.spec.ts b/packages/dds/tree/src/test/feature-libraries/chunked-forest/basicChunk.spec.ts index ff7026f38efc..a3fc5cbf6124 100644 --- a/packages/dds/tree/src/test/feature-libraries/chunked-forest/basicChunk.spec.ts +++ b/packages/dds/tree/src/test/feature-libraries/chunked-forest/basicChunk.spec.ts @@ -10,13 +10,10 @@ import { type ITreeCursor, type ITreeCursorSynchronous, type JsonableTree, + type ChunkedCursor, } from "../../../core/index.js"; // eslint-disable-next-line import/no-internal-modules import { BasicChunk } from "../../../feature-libraries/chunked-forest/basicChunk.js"; -import type { - ChunkedCursor, - // eslint-disable-next-line import/no-internal-modules -} from "../../../feature-libraries/chunked-forest/chunk.js"; import { basicChunkTree, basicOnlyChunkPolicy, diff --git a/packages/dds/tree/src/test/feature-libraries/chunked-forest/chunkTree.spec.ts b/packages/dds/tree/src/test/feature-libraries/chunked-forest/chunkTree.spec.ts index 83c704eda246..d7943a4d176f 100644 --- a/packages/dds/tree/src/test/feature-libraries/chunked-forest/chunkTree.spec.ts +++ b/packages/dds/tree/src/test/feature-libraries/chunked-forest/chunkTree.spec.ts @@ -11,11 +11,10 @@ import { type FieldKey, type Value, mapCursorField, + tryGetChunk, } from "../../../core/index.js"; // eslint-disable-next-line import/no-internal-modules import { BasicChunk } from "../../../feature-libraries/chunked-forest/basicChunk.js"; -// eslint-disable-next-line import/no-internal-modules -import { tryGetChunk } from "../../../feature-libraries/chunked-forest/chunk.js"; import { type ChunkPolicy, type ShapeInfo, diff --git a/packages/dds/tree/src/test/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.spec.ts b/packages/dds/tree/src/test/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.spec.ts index f87916ab8790..00c915254338 100644 --- a/packages/dds/tree/src/test/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.spec.ts +++ b/packages/dds/tree/src/test/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.spec.ts @@ -9,7 +9,7 @@ import { type Static, Type } from "@sinclair/typebox"; import { DiscriminatedUnionDispatcher, unionOptions } from "../../../../codec/index.js"; // eslint-disable-next-line import/no-internal-modules -import type { ChunkedCursor } from "../../../../feature-libraries/chunked-forest/chunk.js"; +import type { ChunkedCursor } from "../../../../core/index.js"; import { type ChunkDecoder, type StreamCursor,