@fluidframework/tree 2.93.0 → 2.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/INCREMENTAL_SUMMARY.md +89 -0
- package/README.md +6 -0
- package/api-report/tree.alpha.api.md +3 -0
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +25 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js +71 -18
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +1 -2
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js +0 -1
- package/dist/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts +10 -2
- package/dist/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.js +15 -1
- package/dist/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +6 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +25 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -0
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +76 -22
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +9 -0
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/docs/user-facing/isolated-declarations.md +147 -0
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +25 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js +72 -19
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts +1 -2
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js +0 -1
- package/lib/feature-libraries/chunked-forest/codec/format/formatGeneric.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts +10 -2
- package/lib/feature-libraries/chunked-forest/codec/format/versions.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format/versions.js +13 -0
- package/lib/feature-libraries/chunked-forest/codec/format/versions.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +6 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +26 -2
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +19 -0
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +76 -22
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +9 -0
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/package.json +24 -24
- package/src/feature-libraries/chunked-forest/basicChunk.ts +76 -20
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +2 -2
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +2 -1
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +3 -2
- package/src/feature-libraries/chunked-forest/codec/format/formatGeneric.ts +0 -1
- package/src/feature-libraries/chunked-forest/codec/format/index.ts +1 -0
- package/src/feature-libraries/chunked-forest/codec/format/versions.ts +15 -0
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +32 -2
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +116 -31
- package/src/packageVersion.ts +1 -1
- package/src/simple-tree/api/schemaFactoryAlpha.ts +34 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incrementalSummaryBuilder.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAE7D,2EAAiE;AAGjE,qEAA4E;AAC5E,uEAAwE;AAIxE,kDAM6B;AAS7B,6DAA6D;AAkF7D;;GAEG;AACH,IAAY,gCAgBX;AAhBD,WAAY,gCAAgC;IAC3C;;;;OAIG;IACH,qGAAW,CAAA;IACX;;;;;;;OAOG;IACH,mGAAU,CAAA;AACX,CAAC,EAhBW,gCAAgC,gDAAhC,gCAAgC,QAgB3C;AAED,4CAA4C;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,2CAA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AC;QAED,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,sBAAsB,CAC5B,WAA6B,EAC7B,YAAyD;QAEzD,MAAM,mBAAmB,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,WAAW,EAAE,CAAC,CAAC;QACvE,IAAA,iBAAM,EAAC,mBAAmB,KAAK,SAAS,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC3F,MAAM,KAAK,GAAG,YAAY,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;QAEhE,8EAA8E;QAC9E,gFAAgF;QAChF,sFAAsF;QACtF,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,mGAAmG;QACnG,mGAAmG;QACnG,yCAAyC;QACzC,IAAA,yBAAc,EAAC,IAAI,CAAC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,EAAE,KAAK,EAAE;YAClF,WAAW;YACX,WAAW,EAAE,mBAAmB,CAAC,WAAW;SAC5C,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAzUD,0EAyUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport type { ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport type { IExperimentalIncrementalSummaryContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { ITreeCursorSynchronous } from \"../../core/index.js\";\nimport type { SummaryElementStringifier } from \"../../shared-tree-core/index.js\";\nimport {\n\tbrand,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n\ttype JsonCompatible,\n\ttype NestedMap,\n} from \"../../util/index.js\";\nimport type {\n\tChunkReferenceId,\n\tEncodedFieldBatchV2,\n\tIncrementalEncoderDecoder,\n\tIncrementalEncodingPolicy,\n\tTreeChunk,\n} from \"../chunked-forest/index.js\";\n\nimport { summaryContentBlobKey } from \"./summaryFormatV3.js\";\n\n/**\n * The properties of a chunk tracked during the loading process.\n * These are used to identify a chunk when it is decoded and recreate the tracking state\n * as it was when the summary that the client is loading from was generated.\n *\n * An encoded chunk, paired with a location it can be reused / reloaded from.\n * @remarks\n * This identifies a location in a specific summary where `encodedContents` was loaded from.\n *\n * When summarizing, Fluid always ensures the summary that the summary client is allowed to reuse content from\n * is the one it loaded from, so tracking this on load is sufficient for now:\n * there is no need to track the equivalent data when summarizing.\n */\ninterface ChunkLoadProperties {\n\t/**\n\t * The encoded contents of the chunk.\n\t */\n\treadonly encodedContents: EncodedFieldBatchV2;\n\t/**\n\t * The path for this chunk's contents in the summary tree relative to the forest's summary tree.\n\t * This path is used to generate a summary handle for the chunk if it doesn't change between summaries.\n\t */\n\treadonly summaryPath: string;\n}\n\n/**\n * The properties of a chunk that is tracked for every summary.\n * If a chunk doesn't change between summaries,\n * these properties will be used to generate a summary handle for the chunk.\n */\ninterface ChunkSummaryProperties {\n\t/**\n\t * The reference ID of the chunk which uniquely identifies it under its parent's summary tree.\n\t * The summary for this chunk will be stored against this reference ID as key in the summary tree.\n\t */\n\treadonly referenceId: ChunkReferenceId;\n\t/**\n\t * The path for this chunk's summary in the summary tree relative to the forest's summary tree.\n\t * This path is used to generate a summary handle for the chunk if it doesn't change between summaries.\n\t */\n\treadonly summaryPath: string;\n}\n\n/**\n * The properties of a summary being tracked.\n */\ninterface TrackedSummaryProperties {\n\t/**\n\t * The sequence number of the summary in progress.\n\t */\n\treadonly summarySequenceNumber: number;\n\t/**\n\t * The base path for the latest summary that was successful.\n\t * This is used to generate summary handles.\n\t */\n\treadonly latestSummaryBasePath: string;\n\t/**\n\t * Whether the summary being tracked is a full tree summary.\n\t * If true, the summary will not contain any summary handles. All chunks must be summarized in full.\n\t */\n\treadonly fullTree: boolean;\n\t/**\n\t * Represents the path of a chunk in the summary tree relative to the forest's summary tree.\n\t * Each item in the array is the {@link ChunkReferenceId} of a chunk in the summary tree starting\n\t * from the chunk under forest summary tree.\n\t * When a chunk is summarized, this array will be used to generate the path for the chunk's summary in the\n\t * summary tree.\n\t */\n\treadonly chunkSummaryPath: ChunkReferenceId[];\n\t/**\n\t * The parent summary builder to use to build the incremental summary tree.\n\t * When a chunk is being summarized, it will add its summary to this builder against its reference ID.\n\t */\n\tparentSummaryBuilder: SummaryTreeBuilder;\n\t/**\n\t * Serializes content (including {@link (IFluidHandle:interface)}s) for adding to a summary blob.\n\t */\n\tstringify: SummaryElementStringifier;\n}\n\n/**\n * The behavior of the forest's incremental summary - whether the summary should be a single blob or incremental.\n */\nexport enum ForestIncrementalSummaryBehavior {\n\t/**\n\t * The forest can encode chunks incrementally, i.e., chunks that support incremental encoding will be encoded\n\t * separately - they will be added to a separate tree.\n\t * The incremental summary format is described in {@link ForestIncrementalSummaryBuilder}.\n\t */\n\tIncremental,\n\t/**\n\t * The forest should encode all of it's data in a single summary blob.\n\t * @remarks\n\t * The format of the summary will be the same as the old format (pre-incremental summaries) and is fully\n\t * backwards compatible with the old format. The summary will basically look like an incremental summary\n\t * with no incremental fields - it will only contain the \"ForestTree\" blob in the summary format described\n\t * in {@link ForestIncrementalSummaryBuilder}.\n\t */\n\tSingleBlob,\n}\n\n/* eslint-disable jsdoc/check-indentation */\n/**\n * Tracks and builds the incremental summary tree for a forest where chunks that support incremental encoding are\n * stored in a separate tree in the summary under its {@link ChunkReferenceId}.\n * The summary tree for a chunk is self-sufficient and can be independently loaded and used to reconstruct the\n * chunk's contents without any additional context from its parent.\n *\n * An example summary tree with incremental summary:\n * Forest\n * ├── contents\n * ├── 0\n * | ├── contents\n * | ├── 1\n * | | ├── contents\n * | | ├── 2\n * | | | ├── contents\n * | ├── 3 - \".../Forest/ForestTree/0/1/3\"\n * ├── 4\n * | ├── contents\n * | ├── ...\n * ├── 5 - \"/.../Forest/ForestTree/5\"\n * - Forest is a summary tree node added by the shared tree and contains the following:\n * - The inline portion of the top-level forest content is stored in a summary blob called \"contents\".\n * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.\n * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.\n * - For each chunk, the structure of the summary tree is the same as the Forest. It contains the following:\n * - The inline portion of the chunk content is stored in a blob called \"contents\".\n * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.\n * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.\n * - Chunks that do not change between summaries are summarized as handles in the summary tree.\n *\n * TODO: AB#46752\n * Add strong types for the summary structure to document it better. It will help make it super clear what the actual\n * format is in a way that can easily be linked to, documented and inspected.\n */\n/* eslint-enable jsdoc/check-indentation */\nexport class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecoder {\n\t/**\n\t * The next reference ID to use for a chunk.\n\t */\n\tprivate nextReferenceId: ChunkReferenceId = brand(0);\n\n\t/**\n\t * For a given summary sequence number, keeps track of a chunk's properties that will be used to generate\n\t * a summary handle for the chunk if it does not change between summaries.\n\t */\n\tprivate readonly chunkTrackingPropertiesMap: NestedMap<\n\t\tnumber,\n\t\tTreeChunk,\n\t\tChunkSummaryProperties\n\t> = new Map();\n\n\t/**\n\t * True when encoding a summary, false otherwise.\n\t * @remarks\n\t * Exposed for testing purposes.\n\t */\n\tpublic get isSummarizing(): boolean {\n\t\treturn this.trackedSummaryProperties !== undefined;\n\t}\n\t/**\n\t * The sequence number of the latest summary that was successful.\n\t */\n\tprivate latestSummarySequenceNumber: number = -1;\n\n\t/**\n\t * The current state of the summary being \"tracked\".\n\t * @remarks\n\t * A summary being \"tracked\" means that a summary is being encoded.\n\t * This is undefined if no summary is currently being encoded.\n\t *\n\t * @privateRemarks\n\t * This has nothing to do which how content from a summary being loaded is tracked (thats written all in chunkTrackingPropertiesMap).\n\t * \"Tracked\" should probably be renamed to \"encoded\" or \"summarizing\" or something like that to avoid confusion.\n\t * Perhaps a better way to clarify this would be to not store this property on this object at all, and have it\n\t * only exist within the scope of the summary encoding (use an encoding specific object to accumulate any stat necessary during encode).\n\t */\n\tprivate trackedSummaryProperties: TrackedSummaryProperties | undefined;\n\n\t/**\n\t * A map of chunk reference IDs to their encoded contents. This is typically used during the loading of the\n\t * forest to retrieve the contents of the chunks that were summarized incrementally.\n\t */\n\t/**\n\t * A map of chunk reference IDs to their {@link ChunkLoadProperties}.\n\t * This is used during the loading of the forest to track each chunk that is retrieved and decoded.\n\t */\n\tprivate readonly loadedChunksMap: Map<string, ChunkLoadProperties> = new Map();\n\n\tpublic constructor(\n\t\tprivate readonly enableIncrementalSummary: boolean,\n\t\tprivate readonly getChunkAtCursor: (cursor: ITreeCursorSynchronous) => TreeChunk[],\n\t\tpublic readonly shouldEncodeIncrementally: IncrementalEncodingPolicy,\n\t\tprivate readonly initialSequenceNumber: number,\n\t) {}\n\n\t/**\n\t * Must be called when the forest is loaded to download the encoded contents of incremental chunks.\n\t * @param services - The channel storage service to use to access the snapshot tree and download the\n\t * contents of the chunks.\n\t * @param readAndParse - A function that reads and parses a blob from the storage service.\n\t */\n\tpublic async load(args: {\n\t\tservices: IChannelStorageService;\n\t\treadAndParseChunk: (chunkBlobPath: string) => Promise<JsonCompatible<IFluidHandle>>;\n\t}): Promise<void> {\n\t\tconst forestTree = args.services.getSnapshotTree?.();\n\t\t// Snapshot tree should be available when loading forest's contents. However, it is an optional function\n\t\t// and may not be implemented by the storage service.\n\t\tif (forestTree === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Downloads the contents of incremental chunks in the given snapshot tree. Also, recursively downloads\n\t\t// the contents of incremental chunks in any sub-trees.\n\t\tconst downloadChunkContentsInTree = async (\n\t\t\tsnapshotTree: ISnapshotTree,\n\t\t\tparentTreeKey: string,\n\t\t): Promise<void> => {\n\t\t\t// All trees in the snapshot tree are for incremental chunks. The key is the chunk's reference ID\n\t\t\t// and the value is the snapshot tree for the chunk.\n\t\t\tfor (const [chunkReferenceId, chunkSnapshotTree] of Object.entries(snapshotTree.trees)) {\n\t\t\t\tconst chunkSubTreePath = `${parentTreeKey}${chunkReferenceId}`;\n\t\t\t\tconst chunkContentsPath = `${chunkSubTreePath}/${summaryContentBlobKey}`;\n\t\t\t\tif (!(await args.services.contains(chunkContentsPath))) {\n\t\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\t`SharedTree: Cannot find contents for incremental chunk ${chunkContentsPath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst chunkContents = (await args.readAndParseChunk(\n\t\t\t\t\tchunkContentsPath,\n\t\t\t\t)) as EncodedFieldBatchV2; // TODO: this should use a codec to validate the data instead of just type casting.\n\t\t\t\tthis.loadedChunksMap.set(chunkReferenceId, {\n\t\t\t\t\tencodedContents: chunkContents,\n\t\t\t\t\tsummaryPath: chunkSubTreePath,\n\t\t\t\t});\n\n\t\t\t\tconst chunkReferenceIdNumber = Number(chunkReferenceId);\n\t\t\t\tthis.nextReferenceId = brand(\n\t\t\t\t\tMath.max(this.nextReferenceId, chunkReferenceIdNumber + 1),\n\t\t\t\t);\n\n\t\t\t\t// Recursively download the contents of chunks in this chunk's sub tree.\n\t\t\t\tawait downloadChunkContentsInTree(chunkSnapshotTree, `${chunkSubTreePath}/`);\n\t\t\t}\n\t\t};\n\t\tawait downloadChunkContentsInTree(forestTree, \"\");\n\t}\n\n\t/**\n\t * Asserts that a summary is currently being tracked and that the tracked summary properties are defined.\n\t * @returns The properties of the tracked summary.\n\t */\n\tprivate requireTrackingSummary(): TrackedSummaryProperties {\n\t\tassert(this.trackedSummaryProperties !== undefined, 0xc22 /* Not tracking a summary */);\n\t\treturn this.trackedSummaryProperties;\n\t}\n\n\t/**\n\t * Must be called when starting a new forest summary to track it.\n\t * @param fullTree - Whether the summary is a full tree summary. If true, the summary will not contain\n\t * any summary handles. All chunks must be summarized in full.\n\t * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers\n\t * for the current and latest summaries.\n\t * @param stringify - Serializes content (including {@link (IFluidHandle:interface)}s) for adding to a summary blob.\n\t * @returns the behavior of the forest's incremental summary.\n\t */\n\tpublic startSummary(args: {\n\t\tfullTree: boolean;\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tstringify: SummaryElementStringifier;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): ForestIncrementalSummaryBehavior {\n\t\tassert(\n\t\t\tthis.trackedSummaryProperties === undefined,\n\t\t\t0xc24 /* Already tracking a summary */,\n\t\t);\n\n\t\tconst { fullTree, incrementalSummaryContext, stringify, builder } = args;\n\t\t// If there is no incremental summary context, do not summarize incrementally. This happens in two scenarios:\n\t\t// 1. When summarizing a detached container, i.e., the first ever summary.\n\t\t// 2. When running GC, the default behavior is to call summarize on DDS without incrementalSummaryContext.\n\t\tif (!this.enableIncrementalSummary || incrementalSummaryContext === undefined) {\n\t\t\treturn ForestIncrementalSummaryBehavior.SingleBlob;\n\t\t}\n\n\t\tthis.latestSummarySequenceNumber = incrementalSummaryContext.latestSummarySequenceNumber;\n\t\tthis.trackedSummaryProperties = {\n\t\t\tsummarySequenceNumber: incrementalSummaryContext.summarySequenceNumber,\n\t\t\tlatestSummaryBasePath: incrementalSummaryContext.summaryPath,\n\t\t\tchunkSummaryPath: [],\n\t\t\tparentSummaryBuilder: builder,\n\t\t\tfullTree,\n\t\t\tstringify,\n\t\t};\n\t\treturn ForestIncrementalSummaryBehavior.Incremental;\n\t}\n\n\t/**\n\t * {@link IncrementalEncoder.encodeIncrementalField}\n\t * @remarks Returns an empty array if the field has no content.\n\t */\n\tpublic encodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatchV2,\n\t): ChunkReferenceId[] {\n\t\t// Validate that a summary is currently being tracked and that the tracked summary properties are defined.\n\t\tconst trackedSummaryProperties = this.requireTrackingSummary();\n\n\t\tconst chunkReferenceIds: ChunkReferenceId[] = [];\n\t\tconst chunks = this.getChunkAtCursor(cursor);\n\t\tfor (const chunk of chunks) {\n\t\t\tlet chunkProperties: ChunkSummaryProperties;\n\n\t\t\t// Try and get the properties of the chunk from the latest successful summary.\n\t\t\t// If it exists and the summary is not a full tree, use the properties to generate a summary handle.\n\t\t\t// If it does not exist, encode the chunk and generate new properties for it.\n\t\t\tconst previousChunkProperties = tryGetFromNestedMap(\n\t\t\t\tthis.chunkTrackingPropertiesMap,\n\t\t\t\tthis.latestSummarySequenceNumber,\n\t\t\t\tchunk,\n\t\t\t);\n\t\t\tif (previousChunkProperties !== undefined && !trackedSummaryProperties.fullTree) {\n\t\t\t\tchunkProperties = previousChunkProperties;\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder.addHandle(\n\t\t\t\t\t`${chunkProperties.referenceId}`,\n\t\t\t\t\tSummaryType.Tree,\n\t\t\t\t\t`${trackedSummaryProperties.latestSummaryBasePath}/${chunkProperties.summaryPath}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Generate a new reference ID for the chunk.\n\t\t\t\tconst newReferenceId: ChunkReferenceId = brand(this.nextReferenceId++);\n\n\t\t\t\t// Add the reference ID of this chunk to the chunk summary path and use the path as the summary path\n\t\t\t\t// for the chunk in its summary properties.\n\t\t\t\t// This is done before encoding the chunk so that the summary path is updated correctly when encoding\n\t\t\t\t// any incremental chunks that are under this chunk.\n\t\t\t\ttrackedSummaryProperties.chunkSummaryPath.push(newReferenceId);\n\n\t\t\t\tchunkProperties = {\n\t\t\t\t\treferenceId: newReferenceId,\n\t\t\t\t\tsummaryPath: trackedSummaryProperties.chunkSummaryPath.join(\"/\"),\n\t\t\t\t};\n\n\t\t\t\tconst parentSummaryBuilder = trackedSummaryProperties.parentSummaryBuilder;\n\t\t\t\t// Create a new summary builder for this chunk to build its summary tree which will be stored in the\n\t\t\t\t// parent's summary tree under its reference ID.\n\t\t\t\t// Before encoding the chunk, set the parent summary builder to this chunk's summary builder so that\n\t\t\t\t// any incremental chunks in the subtree of this chunk will use that as their parent summary builder.\n\t\t\t\tconst chunkSummaryBuilder = new SummaryTreeBuilder();\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder = chunkSummaryBuilder;\n\t\t\t\tchunkSummaryBuilder.addBlob(\n\t\t\t\t\tsummaryContentBlobKey,\n\t\t\t\t\ttrackedSummaryProperties.stringify(chunkEncoder(chunk)),\n\t\t\t\t);\n\n\t\t\t\t// Add this chunk's summary tree to the parent's summary tree. The summary tree contains its encoded\n\t\t\t\t// contents and the summary trees of any incremental chunks under it.\n\t\t\t\tparentSummaryBuilder.addWithStats(\n\t\t\t\t\t`${newReferenceId}`,\n\t\t\t\t\tchunkSummaryBuilder.getSummaryTree(),\n\t\t\t\t);\n\n\t\t\t\t// Restore the parent summary builder and chunk summary path.\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder = parentSummaryBuilder;\n\t\t\t\ttrackedSummaryProperties.chunkSummaryPath.pop();\n\t\t\t}\n\n\t\t\tsetInNestedMap(\n\t\t\t\tthis.chunkTrackingPropertiesMap,\n\t\t\t\ttrackedSummaryProperties.summarySequenceNumber,\n\t\t\t\tchunk,\n\t\t\t\tchunkProperties,\n\t\t\t);\n\t\t\tchunkReferenceIds.push(chunkProperties.referenceId);\n\t\t}\n\t\treturn chunkReferenceIds;\n\t}\n\n\t/**\n\t * Must be called after summary generation is complete to finish tracking the summary.\n\t * It clears any tracking state and deletes the tracking properties for summaries that are older than the\n\t * latest successful summary.\n\t * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers.\n\t * If this is undefined, the summary tree will only contain a summary blob for `forestSummaryRootContent`.\n\t * @param forestSummaryRootContent - The stringified ForestCodec output of top-level Forest content.\n\t * @param forestSummaryRootContentKey - The key to use for the blob containing `forestSummaryRootContent`.\n\t * @param builder - The summary tree builder to use to add the forest's contents. Note that if tracking an incremental\n\t * summary, this builder will be the same as the one tracked in `trackedSummaryProperties`.\n\t * @returns the Forest's summary tree.\n\t */\n\tpublic completeSummary(args: {\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tforestSummaryRootContent: string;\n\t\tforestSummaryRootContentKey: string;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst {\n\t\t\tincrementalSummaryContext,\n\t\t\tforestSummaryRootContent,\n\t\t\tforestSummaryRootContentKey,\n\t\t\tbuilder,\n\t\t} = args;\n\t\tif (!this.enableIncrementalSummary || incrementalSummaryContext === undefined) {\n\t\t\tbuilder.addBlob(forestSummaryRootContentKey, forestSummaryRootContent);\n\t\t\treturn;\n\t\t}\n\n\t\tconst trackedSummaryProperties = this.requireTrackingSummary();\n\n\t\tbuilder.addBlob(forestSummaryRootContentKey, forestSummaryRootContent);\n\n\t\t// Copy over the entries from the latest summary to the current summary.\n\t\t// In the current summary, there can be fields that haven't changed since the latest summary and the chunks\n\t\t// in these fields and in any of its children weren't encoded. So, we need get the entries for these chunks\n\t\t// to be able to incrementally summarize them in the next summary.\n\t\tconst latestSummaryTrackingMap = this.chunkTrackingPropertiesMap.get(\n\t\t\tthis.latestSummarySequenceNumber,\n\t\t);\n\t\tconst currentSummaryTrackingMap = this.chunkTrackingPropertiesMap.get(\n\t\t\ttrackedSummaryProperties.summarySequenceNumber,\n\t\t);\n\t\tif (latestSummaryTrackingMap !== undefined && currentSummaryTrackingMap !== undefined) {\n\t\t\tfor (const [chunk, chunkProperties] of latestSummaryTrackingMap.entries()) {\n\t\t\t\tif (!currentSummaryTrackingMap.has(chunk)) {\n\t\t\t\t\tcurrentSummaryTrackingMap.set(chunk, chunkProperties);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Delete tracking for summaries that are older than the latest successful summary because they will\n\t\t// never be referenced again for generating summary handles.\n\t\tfor (const sequenceNumber of this.chunkTrackingPropertiesMap.keys()) {\n\t\t\tif (sequenceNumber < this.latestSummarySequenceNumber) {\n\t\t\t\tthis.chunkTrackingPropertiesMap.delete(sequenceNumber);\n\t\t\t}\n\t\t}\n\n\t\tthis.trackedSummaryProperties = undefined;\n\t}\n\n\t/**\n\t * {@link IncrementalEncoder.decodeIncrementalChunk}\n\t */\n\tpublic decodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatchV2) => TreeChunk,\n\t): TreeChunk {\n\t\tconst ChunkLoadProperties = this.loadedChunksMap.get(`${referenceId}`);\n\t\tassert(ChunkLoadProperties !== undefined, 0xc86 /* Encoded incremental chunk not found */);\n\t\tconst chunk = chunkDecoder(ChunkLoadProperties.encodedContents);\n\n\t\t// Account for the reference about to be added in `chunkTrackingPropertiesMap`\n\t\t// to ensure that no other users of this chunk think they have unique ownership.\n\t\t// This prevents prevent whoever this chunk is returned to from modifying it in-place.\n\t\tchunk.referenceAdded();\n\t\t// Track the decoded chunk. This will recreate the tracking state when the summary that this client\n\t\t// is loaded from was generated. This is needed to ensure that incremental summaries work correctly\n\t\t// when a new client starts to summarize.\n\t\tsetInNestedMap(this.chunkTrackingPropertiesMap, this.initialSequenceNumber, chunk, {\n\t\t\treferenceId,\n\t\t\tsummaryPath: ChunkLoadProperties.summaryPath,\n\t\t});\n\t\treturn chunk;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"incrementalSummaryBuilder.js","sourceRoot":"","sources":["../../../src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAE7D,2EAAiE;AAGjE,qEAA4E;AAC5E,uEAAwE;AAIxE,kDAM6B;AAS7B,6DAA6D;AAqG7D;;GAEG;AACH,IAAY,gCAgBX;AAhBD,WAAY,gCAAgC;IAC3C;;;;OAIG;IACH,qGAAW,CAAA;IACX;;;;;;;OAOG;IACH,mGAAU,CAAA;AACX,CAAC,EAhBW,gCAAgC,gDAAhC,gCAAgC,QAgB3C;AAED,4CAA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,KAAK,CAAC,EAAE,CAAC;oBAC3C,yBAAyB,CAAC,GAAG,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;gBACvD,CAAC;YACF,CAAC;QACF,CAAC;QAED,oGAAoG;QACpG,4DAA4D;QAC5D,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,0BAA0B,CAAC,IAAI,EAAE,EAAE,CAAC;YACrE,IAAI,cAAc,GAAG,IAAI,CAAC,2BAA2B,EAAE,CAAC;gBACvD,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YACxD,CAAC;QACF,CAAC;QAED,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,sBAAsB,CAC5B,WAA6B,EAC7B,YAAyD;QAEzD,MAAM,mBAAmB,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,WAAW,EAAE,CAAC,CAAC;QACvE,IAAA,iBAAM,EAAC,mBAAmB,KAAK,SAAS,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC3F,MAAM,KAAK,GAAG,YAAY,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;QAEhE,8EAA8E;QAC9E,gFAAgF;QAChF,sFAAsF;QACtF,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,mGAAmG;QACnG,mGAAmG;QACnG,yCAAyC;QACzC,IAAA,yBAAc,EAAC,IAAI,CAAC,0BAA0B,EAAE,IAAI,CAAC,qBAAqB,EAAE,KAAK,EAAE;YAClF,WAAW;YACX,iBAAiB,EAAE,mBAAmB,CAAC,iBAAiB;SACxD,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AA3YD,0EA2YC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport type { ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport type { IExperimentalIncrementalSummaryContext } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { ITreeCursorSynchronous } from \"../../core/index.js\";\nimport type { SummaryElementStringifier } from \"../../shared-tree-core/index.js\";\nimport {\n\tbrand,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n\ttype JsonCompatible,\n\ttype NestedMap,\n} from \"../../util/index.js\";\nimport type {\n\tChunkReferenceId,\n\tEncodedFieldBatchV2,\n\tIncrementalEncoderDecoder,\n\tIncrementalEncodingPolicy,\n\tTreeChunk,\n} from \"../chunked-forest/index.js\";\n\nimport { summaryContentBlobKey } from \"./summaryFormatV3.js\";\n\n/**\n * The properties of a chunk tracked during the loading process.\n * These are used to identify a chunk when it is decoded and recreate the tracking state\n * as it was when the summary that the client is loading from was generated.\n *\n * An encoded chunk, paired with a location it can be reused / reloaded from.\n * @remarks\n * This identifies a location in a specific summary where `encodedContents` was loaded from.\n *\n * When summarizing, Fluid always ensures the summary that the summary client is allowed to reuse content from\n * is the one it loaded from, so tracking this on load is sufficient for now:\n * there is no need to track the equivalent data when summarizing.\n */\ninterface ChunkLoadProperties {\n\t/**\n\t * The encoded contents of the chunk.\n\t */\n\treadonly encodedContents: EncodedFieldBatchV2;\n\t/**\n\t * The reference ID of this chunk's parent in the summary tree, or `undefined` if this chunk is\n\t * at the top level (directly under the forest summary tree).\n\t * Stored here so that {@link ForestIncrementalSummaryBuilder.decodeIncrementalChunk} can\n\t * reconstruct the correct {@link ChunkSummaryProperties} without re-parsing a path string.\n\t */\n\treadonly parentReferenceId: ChunkReferenceId | undefined;\n}\n\n/**\n * The properties of a chunk that is tracked for every summary.\n * If a chunk doesn't change between summaries,\n * these properties will be used to generate a summary handle for the chunk.\n */\ninterface ChunkSummaryProperties {\n\t/**\n\t * The reference ID of the chunk which uniquely identifies it under its parent's summary tree.\n\t * The summary for this chunk will be stored against this reference ID as key in the summary tree.\n\t */\n\treadonly referenceId: ChunkReferenceId;\n\t/**\n\t * The reference ID of this chunk's parent in the summary tree, or `undefined` if this chunk\n\t * is at the top level (has no incremental parent).\n\t *\n\t * @remarks\n\t * Storing only the immediate parent (rather than the full path string) keeps every chunk's\n\t * tracking entry correct even when an ancestor is re-encoded and receives a new reference ID.\n\t * The full summary path is computed on demand by {@link ForestIncrementalSummaryBuilder.computeHandlePathInLatestSummary}\n\t * by walking up the parent chain through {@link TrackedSummaryProperties.latestSummaryRefIdMap}.\n\t *\n\t * If a parent chunk is encoded as a handle in the current summary its reference ID is unchanged,\n\t * so its children's `parentReferenceId` values copied forward by `completeSummary` remain valid\n\t * without any additional update.\n\t */\n\treadonly parentReferenceId: ChunkReferenceId | undefined;\n}\n\n/**\n * The properties of a summary being tracked.\n */\ninterface TrackedSummaryProperties {\n\t/**\n\t * The sequence number of the summary in progress.\n\t */\n\treadonly summarySequenceNumber: number;\n\t/**\n\t * The base path for the latest summary that was successful.\n\t * This is used to generate summary handles.\n\t */\n\treadonly latestSummaryBasePath: string;\n\t/**\n\t * Whether the summary being tracked is a full tree summary.\n\t * If true, the summary will not contain any summary handles. All chunks must be summarized in full.\n\t */\n\treadonly fullTree: boolean;\n\t/**\n\t * Represents the path of a chunk in the summary tree relative to the forest's summary tree.\n\t * Each item in the array is the {@link ChunkReferenceId} of a chunk in the summary tree starting\n\t * from the chunk under forest summary tree.\n\t * When a chunk is summarized, this array will be used to generate the path for the chunk's summary in the\n\t * summary tree.\n\t */\n\treadonly chunkSummaryPath: ChunkReferenceId[];\n\t/**\n\t * The parent summary builder to use to build the incremental summary tree.\n\t * When a chunk is being summarized, it will add its summary to this builder against its reference ID.\n\t */\n\tparentSummaryBuilder: SummaryTreeBuilder;\n\t/**\n\t * Serializes content (including {@link (IFluidHandle:interface)}s) for adding to a summary blob.\n\t */\n\tstringify: SummaryElementStringifier;\n\t/**\n\t * Reverse lookup map for the latest summary: maps each chunk's {@link ChunkReferenceId} to its\n\t * {@link ChunkSummaryProperties}.\n\t * Used by {@link ForestIncrementalSummaryBuilder.computeHandlePathInLatestSummary} to traverse\n\t * the parent chain when generating handle paths.\n\t */\n\treadonly latestSummaryRefIdMap: Map<ChunkReferenceId, ChunkSummaryProperties>;\n}\n\n/**\n * The behavior of the forest's incremental summary - whether the summary should be a single blob or incremental.\n */\nexport enum ForestIncrementalSummaryBehavior {\n\t/**\n\t * The forest can encode chunks incrementally, i.e., chunks that support incremental encoding will be encoded\n\t * separately - they will be added to a separate tree.\n\t * The incremental summary format is described in {@link ForestIncrementalSummaryBuilder}.\n\t */\n\tIncremental,\n\t/**\n\t * The forest should encode all of it's data in a single summary blob.\n\t * @remarks\n\t * The format of the summary will be the same as the old format (pre-incremental summaries) and is fully\n\t * backwards compatible with the old format. The summary will basically look like an incremental summary\n\t * with no incremental fields - it will only contain the \"ForestTree\" blob in the summary format described\n\t * in {@link ForestIncrementalSummaryBuilder}.\n\t */\n\tSingleBlob,\n}\n\n/* eslint-disable jsdoc/check-indentation */\n/**\n * Tracks and builds the incremental summary tree for a forest where chunks that support incremental encoding are\n * stored in a separate tree in the summary under its {@link ChunkReferenceId}.\n * The summary tree for a chunk is self-sufficient and can be independently loaded and used to reconstruct the\n * chunk's contents without any additional context from its parent.\n *\n * An example summary tree with incremental summary:\n * Forest\n * ├── contents\n * ├── 0\n * | ├── contents\n * | ├── 1\n * | | ├── contents\n * | | ├── 2\n * | | | ├── contents\n * | ├── 3 - \".../Forest/ForestTree/0/1/3\"\n * ├── 4\n * | ├── contents\n * | ├── ...\n * ├── 5 - \"/.../Forest/ForestTree/5\"\n * - Forest is a summary tree node added by the shared tree and contains the following:\n * - The inline portion of the top-level forest content is stored in a summary blob called \"contents\".\n * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.\n * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.\n * - For each chunk, the structure of the summary tree is the same as the Forest. It contains the following:\n * - The inline portion of the chunk content is stored in a blob called \"contents\".\n * It also contains the {@link ChunkReferenceId}s of the incremental chunks under it.\n * - The summary for each incremental chunk under it is stored against its {@link ChunkReferenceId}.\n * - Chunks that do not change between summaries are summarized as handles in the summary tree.\n *\n * TODO: AB#46752\n * Add strong types for the summary structure to document it better. It will help make it super clear what the actual\n * format is in a way that can easily be linked to, documented and inspected.\n */\n/* eslint-enable jsdoc/check-indentation */\nexport class ForestIncrementalSummaryBuilder implements IncrementalEncoderDecoder {\n\t/**\n\t * The next reference ID to use for a chunk.\n\t */\n\tprivate nextReferenceId: ChunkReferenceId = brand(0);\n\n\t/**\n\t * For a given summary sequence number, keeps track of a chunk's properties that will be used to generate\n\t * a summary handle for the chunk if it does not change between summaries.\n\t *\n\t * @remarks\n\t * `chunk` (the TreeChunk object) is used as the map key by object identity.\n\t * This assumes each chunk appears at exactly one position in the forest — an invariant that holds because every\n\t * node in a tree has a single parent.\n\t * If the forest ever introduced structural sharing (two positions backed by the same TreeChunk object),\n\t * a second call here would silently overwrite the first entry, causing the first position's handle to point\n\t * to the second position's parent in subsequent summaries. In theory, this should be fine from summary perspective\n\t * because the chunk contents are the same. But, it could lead to confusing handle paths in the summary tree and\n\t * may lead to other unexpected behavior. Adequate tests should be added if structural sharing is introduced.\n\t */\n\tprivate readonly chunkTrackingPropertiesMap: NestedMap<\n\t\tnumber,\n\t\tTreeChunk,\n\t\tChunkSummaryProperties\n\t> = new Map();\n\n\t/**\n\t * True when encoding a summary, false otherwise.\n\t * @remarks\n\t * Exposed for testing purposes.\n\t */\n\tpublic get isSummarizing(): boolean {\n\t\treturn this.trackedSummaryProperties !== undefined;\n\t}\n\t/**\n\t * The sequence number of the latest summary that was successful.\n\t */\n\tprivate latestSummarySequenceNumber: number = -1;\n\n\t/**\n\t * The current state of the summary being \"tracked\".\n\t * @remarks\n\t * A summary being \"tracked\" means that a summary is being encoded.\n\t * This is undefined if no summary is currently being encoded.\n\t *\n\t * @privateRemarks\n\t * This has nothing to do which how content from a summary being loaded is tracked (thats written all in chunkTrackingPropertiesMap).\n\t * \"Tracked\" should probably be renamed to \"encoded\" or \"summarizing\" or something like that to avoid confusion.\n\t * Perhaps a better way to clarify this would be to not store this property on this object at all, and have it\n\t * only exist within the scope of the summary encoding (use an encoding specific object to accumulate any stat necessary during encode).\n\t */\n\tprivate trackedSummaryProperties: TrackedSummaryProperties | undefined;\n\n\t/**\n\t * A map of chunk reference IDs to their encoded contents. This is typically used during the loading of the\n\t * forest to retrieve the contents of the chunks that were summarized incrementally.\n\t */\n\t/**\n\t * A map of chunk reference IDs to their {@link ChunkLoadProperties}.\n\t * This is used during the loading of the forest to track each chunk that is retrieved and decoded.\n\t */\n\tprivate readonly loadedChunksMap: Map<string, ChunkLoadProperties> = new Map();\n\n\tpublic constructor(\n\t\tprivate readonly enableIncrementalSummary: boolean,\n\t\tprivate readonly getChunkAtCursor: (cursor: ITreeCursorSynchronous) => TreeChunk[],\n\t\tpublic readonly shouldEncodeIncrementally: IncrementalEncodingPolicy,\n\t\tprivate readonly initialSequenceNumber: number,\n\t) {}\n\n\t/**\n\t * Must be called when the forest is loaded to download the encoded contents of incremental chunks.\n\t * @param services - The channel storage service to use to access the snapshot tree and download the\n\t * contents of the chunks.\n\t * @param readAndParse - A function that reads and parses a blob from the storage service.\n\t */\n\tpublic async load(args: {\n\t\tservices: IChannelStorageService;\n\t\treadAndParseChunk: (chunkBlobPath: string) => Promise<JsonCompatible<IFluidHandle>>;\n\t}): Promise<void> {\n\t\tconst forestTree = args.services.getSnapshotTree?.();\n\t\t// Snapshot tree should be available when loading forest's contents. However, it is an optional function\n\t\t// and may not be implemented by the storage service.\n\t\tif (forestTree === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Downloads the contents of incremental chunks in the given snapshot tree. Also, recursively downloads\n\t\t// the contents of incremental chunks in any sub-trees.\n\t\tconst downloadChunkContentsInTree = async (\n\t\t\tsnapshotTree: ISnapshotTree,\n\t\t\tparentPathSegments: string[],\n\t\t\tparentReferenceId: ChunkReferenceId | undefined,\n\t\t): Promise<void> => {\n\t\t\t// All trees in the snapshot tree are for incremental chunks. The key is the chunk's reference ID\n\t\t\t// and the value is the snapshot tree for the chunk.\n\t\t\tfor (const [chunkReferenceId, chunkSnapshotTree] of Object.entries(snapshotTree.trees)) {\n\t\t\t\tconst chunkSubTreeSegments = [...parentPathSegments, chunkReferenceId];\n\t\t\t\tconst chunkSubTreePath = chunkSubTreeSegments.join(\"/\");\n\t\t\t\tconst chunkContentsPath = `${chunkSubTreePath}/${summaryContentBlobKey}`;\n\t\t\t\tif (!(await args.services.contains(chunkContentsPath))) {\n\t\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\t`SharedTree: Cannot find contents for incremental chunk ${chunkContentsPath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst chunkContents = (await args.readAndParseChunk(\n\t\t\t\t\tchunkContentsPath,\n\t\t\t\t)) as EncodedFieldBatchV2; // TODO: this should use a codec to validate the data instead of just type casting.\n\t\t\t\tthis.loadedChunksMap.set(chunkReferenceId, {\n\t\t\t\t\tencodedContents: chunkContents,\n\t\t\t\t\tparentReferenceId,\n\t\t\t\t});\n\n\t\t\t\tconst chunkReferenceIdNumber = Number(chunkReferenceId);\n\t\t\t\tthis.nextReferenceId = brand(\n\t\t\t\t\tMath.max(this.nextReferenceId, chunkReferenceIdNumber + 1),\n\t\t\t\t);\n\n\t\t\t\t// Recursively download the contents of chunks in this chunk's sub tree.\n\t\t\t\tawait downloadChunkContentsInTree(\n\t\t\t\t\tchunkSnapshotTree,\n\t\t\t\t\tchunkSubTreeSegments,\n\t\t\t\t\tbrand(chunkReferenceIdNumber),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\t// parentReferenceId is undefined for the root of the forest tree.\n\t\tawait downloadChunkContentsInTree(forestTree, [], undefined /* parentReferenceId */);\n\t}\n\n\t/**\n\t * Asserts that a summary is currently being tracked and that the tracked summary properties are defined.\n\t * @returns The properties of the tracked summary.\n\t */\n\tprivate requireTrackingSummary(): TrackedSummaryProperties {\n\t\tassert(this.trackedSummaryProperties !== undefined, 0xc22 /* Not tracking a summary */);\n\t\treturn this.trackedSummaryProperties;\n\t}\n\n\t/**\n\t * Must be called when starting a new forest summary to track it.\n\t * @param fullTree - Whether the summary is a full tree summary. If true, the summary will not contain\n\t * any summary handles. All chunks must be summarized in full.\n\t * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers\n\t * for the current and latest summaries.\n\t * @param stringify - Serializes content (including {@link (IFluidHandle:interface)}s) for adding to a summary blob.\n\t * @returns the behavior of the forest's incremental summary.\n\t */\n\tpublic startSummary(args: {\n\t\tfullTree: boolean;\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tstringify: SummaryElementStringifier;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): ForestIncrementalSummaryBehavior {\n\t\tassert(\n\t\t\tthis.trackedSummaryProperties === undefined,\n\t\t\t0xc24 /* Already tracking a summary */,\n\t\t);\n\n\t\tconst { fullTree, incrementalSummaryContext, stringify, builder } = args;\n\t\t// If there is no incremental summary context, do not summarize incrementally. This happens in two scenarios:\n\t\t// 1. When summarizing a detached container, i.e., the first ever summary.\n\t\t// 2. When running GC, the default behavior is to call summarize on DDS without incrementalSummaryContext.\n\t\tif (!this.enableIncrementalSummary || incrementalSummaryContext === undefined) {\n\t\t\treturn ForestIncrementalSummaryBehavior.SingleBlob;\n\t\t}\n\n\t\tthis.latestSummarySequenceNumber = incrementalSummaryContext.latestSummarySequenceNumber;\n\n\t\t// Build a reverse lookup map (referenceId → properties) for the latest summary so that\n\t\t// computeHandlePathInLatestSummary can traverse the parent chain without iterating the whole map.\n\t\tconst latestSummaryRefIdMap: Map<ChunkReferenceId, ChunkSummaryProperties> = new Map();\n\t\tconst latestTracking = this.chunkTrackingPropertiesMap.get(\n\t\t\tthis.latestSummarySequenceNumber,\n\t\t);\n\t\tif (latestTracking !== undefined) {\n\t\t\tfor (const properties of latestTracking.values()) {\n\t\t\t\tlatestSummaryRefIdMap.set(properties.referenceId, properties);\n\t\t\t}\n\t\t}\n\n\t\tthis.trackedSummaryProperties = {\n\t\t\tsummarySequenceNumber: incrementalSummaryContext.summarySequenceNumber,\n\t\t\tlatestSummaryBasePath: incrementalSummaryContext.summaryPath,\n\t\t\tchunkSummaryPath: [],\n\t\t\tparentSummaryBuilder: builder,\n\t\t\tfullTree,\n\t\t\tstringify,\n\t\t\tlatestSummaryRefIdMap,\n\t\t};\n\t\treturn ForestIncrementalSummaryBehavior.Incremental;\n\t}\n\n\t/**\n\t * Computes a chunk's path in the latest summary by traversing up the parent chain via\n\t * {@link latestSummaryRefIdMap}.\n\t *\n\t * Each {@link ChunkSummaryProperties.parentReferenceId} points to the chunk's parent as it\n\t * appeared in the summary where the entry was last written. Walking up the chain from the\n\t * chunk to the root produces the full path that can be used in a summary handle path.\n\t */\n\tprivate computeHandlePathInLatestSummary(chunkProperties: ChunkSummaryProperties): string {\n\t\tconst { latestSummaryRefIdMap } = this.requireTrackingSummary();\n\t\tconst pathSegments: string[] = [];\n\t\tlet current: ChunkSummaryProperties | undefined = chunkProperties;\n\t\twhile (current !== undefined) {\n\t\t\tpathSegments.push(`${current.referenceId}`);\n\t\t\tif (current.parentReferenceId === undefined) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcurrent = latestSummaryRefIdMap.get(current.parentReferenceId);\n\t\t\tassert(\n\t\t\t\tcurrent !== undefined,\n\t\t\t\t0xcf7 /* Parent chunk not found in latest summary tracking */,\n\t\t\t);\n\t\t}\n\t\t// Segments are collected leaf-to-root and then reversed. The alternative would be to use unshift\n\t\t// instead of push and reverse. However, using push and reverse is O(n) whereas using unshift would be O(n²).\n\t\treturn pathSegments.reverse().join(\"/\");\n\t}\n\n\t/**\n\t * {@link IncrementalEncoder.encodeIncrementalField}\n\t * @remarks Returns an empty array if the field has no content.\n\t */\n\tpublic encodeIncrementalField(\n\t\tcursor: ITreeCursorSynchronous,\n\t\tchunkEncoder: (chunk: TreeChunk) => EncodedFieldBatchV2,\n\t): ChunkReferenceId[] {\n\t\t// Validate that a summary is currently being tracked and that the tracked summary properties are defined.\n\t\tconst trackedSummaryProperties = this.requireTrackingSummary();\n\n\t\tconst chunkReferenceIds: ChunkReferenceId[] = [];\n\t\tconst chunks = this.getChunkAtCursor(cursor);\n\t\tfor (const chunk of chunks) {\n\t\t\t// Try and get the properties of the chunk from the latest successful summary.\n\t\t\t// If it exists and the summary is not a full tree, use the properties to generate a summary handle.\n\t\t\t// If it does not exist, encode the chunk and generate new properties for it.\n\t\t\tconst previousChunkProperties = tryGetFromNestedMap(\n\t\t\t\tthis.chunkTrackingPropertiesMap,\n\t\t\t\tthis.latestSummarySequenceNumber,\n\t\t\t\tchunk,\n\t\t\t);\n\t\t\tlet chunkReferenceId: ChunkReferenceId;\n\t\t\tif (previousChunkProperties !== undefined && !trackedSummaryProperties.fullTree) {\n\t\t\t\tchunkReferenceId = previousChunkProperties.referenceId;\n\t\t\t\t// Compute this chunk's path in the latest summary by traversing the parent chain.\n\t\t\t\t// Using parentReferenceId traversal (rather than a stored path string) ensures the\n\t\t\t\t// path is correct even when an ancestor was re-encoded in a prior summary and\n\t\t\t\t// received a new referenceId — the stored summaryPath would have been stale in\n\t\t\t\t// that case.\n\t\t\t\tconst handlePath = this.computeHandlePathInLatestSummary(previousChunkProperties);\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder.addHandle(\n\t\t\t\t\t`${chunkReferenceId}`,\n\t\t\t\t\tSummaryType.Tree,\n\t\t\t\t\t`${trackedSummaryProperties.latestSummaryBasePath}/${handlePath}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Generate a new reference ID for the chunk.\n\t\t\t\tconst newReferenceId: ChunkReferenceId = brand(this.nextReferenceId++);\n\t\t\t\tchunkReferenceId = newReferenceId;\n\n\t\t\t\t// Add the reference ID of this chunk to the chunk summary path before encoding so\n\t\t\t\t// that any incremental chunks in the subtree use the correct parent path.\n\t\t\t\ttrackedSummaryProperties.chunkSummaryPath.push(newReferenceId);\n\n\t\t\t\tconst parentSummaryBuilder = trackedSummaryProperties.parentSummaryBuilder;\n\t\t\t\t// Create a new summary builder for this chunk to build its summary tree which will be stored in the\n\t\t\t\t// parent's summary tree under its reference ID.\n\t\t\t\t// Before encoding the chunk, set the parent summary builder to this chunk's summary builder so that\n\t\t\t\t// any incremental chunks in the subtree of this chunk will use that as their parent summary builder.\n\t\t\t\tconst chunkSummaryBuilder = new SummaryTreeBuilder();\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder = chunkSummaryBuilder;\n\t\t\t\tchunkSummaryBuilder.addBlob(\n\t\t\t\t\tsummaryContentBlobKey,\n\t\t\t\t\ttrackedSummaryProperties.stringify(chunkEncoder(chunk)),\n\t\t\t\t);\n\n\t\t\t\t// Add this chunk's summary tree to the parent's summary tree. The summary tree contains its encoded\n\t\t\t\t// contents and the summary trees of any incremental chunks under it.\n\t\t\t\tparentSummaryBuilder.addWithStats(\n\t\t\t\t\t`${newReferenceId}`,\n\t\t\t\t\tchunkSummaryBuilder.getSummaryTree(),\n\t\t\t\t);\n\n\t\t\t\t// Restore the parent summary builder and chunk summary path.\n\t\t\t\ttrackedSummaryProperties.parentSummaryBuilder = parentSummaryBuilder;\n\t\t\t\ttrackedSummaryProperties.chunkSummaryPath.pop();\n\t\t\t}\n\n\t\t\t// Get the parent reference ID from the current chunk summary path.\n\t\t\t// For the root of the forest tree, the parent reference ID is undefined.\n\t\t\t// For all other chunks, the parent reference ID is the last element in the current chunk summary path.\n\t\t\tconst chunkSummaryPathLength = trackedSummaryProperties.chunkSummaryPath.length;\n\t\t\tconst parentReferenceId: ChunkReferenceId | undefined =\n\t\t\t\tchunkSummaryPathLength > 0\n\t\t\t\t\t? trackedSummaryProperties.chunkSummaryPath[chunkSummaryPathLength - 1]\n\t\t\t\t\t: undefined;\n\t\t\tsetInNestedMap(\n\t\t\t\tthis.chunkTrackingPropertiesMap,\n\t\t\t\ttrackedSummaryProperties.summarySequenceNumber,\n\t\t\t\tchunk,\n\t\t\t\t{ referenceId: chunkReferenceId, parentReferenceId },\n\t\t\t);\n\t\t\tchunkReferenceIds.push(chunkReferenceId);\n\t\t}\n\t\treturn chunkReferenceIds;\n\t}\n\n\t/**\n\t * Must be called after summary generation is complete to finish tracking the summary.\n\t * It clears any tracking state and deletes the tracking properties for summaries that are older than the\n\t * latest successful summary.\n\t * @param incrementalSummaryContext - The context for the incremental summary that contains the sequence numbers.\n\t * If this is undefined, the summary tree will only contain a summary blob for `forestSummaryRootContent`.\n\t * @param forestSummaryRootContent - The stringified ForestCodec output of top-level Forest content.\n\t * @param forestSummaryRootContentKey - The key to use for the blob containing `forestSummaryRootContent`.\n\t * @param builder - The summary tree builder to use to add the forest's contents. Note that if tracking an incremental\n\t * summary, this builder will be the same as the one tracked in `trackedSummaryProperties`.\n\t * @returns the Forest's summary tree.\n\t */\n\tpublic completeSummary(args: {\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined;\n\t\tforestSummaryRootContent: string;\n\t\tforestSummaryRootContentKey: string;\n\t\tbuilder: SummaryTreeBuilder;\n\t}): void {\n\t\tconst {\n\t\t\tincrementalSummaryContext,\n\t\t\tforestSummaryRootContent,\n\t\t\tforestSummaryRootContentKey,\n\t\t\tbuilder,\n\t\t} = args;\n\t\tif (!this.enableIncrementalSummary || incrementalSummaryContext === undefined) {\n\t\t\tbuilder.addBlob(forestSummaryRootContentKey, forestSummaryRootContent);\n\t\t\treturn;\n\t\t}\n\n\t\tconst trackedSummaryProperties = this.requireTrackingSummary();\n\n\t\tbuilder.addBlob(forestSummaryRootContentKey, forestSummaryRootContent);\n\n\t\t// Copy over the entries from the latest summary to the current summary.\n\t\t// In the current summary, there can be fields that haven't changed since the latest summary and the chunks\n\t\t// in these fields and in any of its children weren't encoded. So, we need get the entries for these chunks\n\t\t// to be able to incrementally summarize them in the next summary.\n\t\tconst latestSummaryTrackingMap = this.chunkTrackingPropertiesMap.get(\n\t\t\tthis.latestSummarySequenceNumber,\n\t\t);\n\t\tconst currentSummaryTrackingMap = this.chunkTrackingPropertiesMap.get(\n\t\t\ttrackedSummaryProperties.summarySequenceNumber,\n\t\t);\n\t\tif (latestSummaryTrackingMap !== undefined && currentSummaryTrackingMap !== undefined) {\n\t\t\tfor (const [chunk, chunkProperties] of latestSummaryTrackingMap.entries()) {\n\t\t\t\tif (!currentSummaryTrackingMap.has(chunk)) {\n\t\t\t\t\tcurrentSummaryTrackingMap.set(chunk, chunkProperties);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Delete tracking for summaries that are older than the latest successful summary because they will\n\t\t// never be referenced again for generating summary handles.\n\t\tfor (const sequenceNumber of this.chunkTrackingPropertiesMap.keys()) {\n\t\t\tif (sequenceNumber < this.latestSummarySequenceNumber) {\n\t\t\t\tthis.chunkTrackingPropertiesMap.delete(sequenceNumber);\n\t\t\t}\n\t\t}\n\n\t\tthis.trackedSummaryProperties = undefined;\n\t}\n\n\t/**\n\t * {@link IncrementalEncoder.decodeIncrementalChunk}\n\t */\n\tpublic decodeIncrementalChunk(\n\t\treferenceId: ChunkReferenceId,\n\t\tchunkDecoder: (encoded: EncodedFieldBatchV2) => TreeChunk,\n\t): TreeChunk {\n\t\tconst chunkLoadProperties = this.loadedChunksMap.get(`${referenceId}`);\n\t\tassert(chunkLoadProperties !== undefined, 0xc86 /* Encoded incremental chunk not found */);\n\t\tconst chunk = chunkDecoder(chunkLoadProperties.encodedContents);\n\n\t\t// Account for the reference about to be added in `chunkTrackingPropertiesMap`\n\t\t// to ensure that no other users of this chunk think they have unique ownership.\n\t\t// This prevents prevent whoever this chunk is returned to from modifying it in-place.\n\t\tchunk.referenceAdded();\n\t\t// Track the decoded chunk. This will recreate the tracking state when the summary that this client\n\t\t// is loaded from was generated. This is needed to ensure that incremental summaries work correctly\n\t\t// when a new client starts to summarize.\n\t\tsetInNestedMap(this.chunkTrackingPropertiesMap, this.initialSequenceNumber, chunk, {\n\t\t\treferenceId,\n\t\t\tparentReferenceId: chunkLoadProperties.parentReferenceId,\n\t\t});\n\t\treturn chunk;\n\t}\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,YAAY,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/tree";
|
|
11
|
-
exports.pkgVersion = "2.
|
|
11
|
+
exports.pkgVersion = "2.100.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.100.0\";\n"]}
|
|
@@ -223,7 +223,7 @@ export declare class TreeCheckout implements ITreeCheckout {
|
|
|
223
223
|
/** True if and only if this checkout is for a branch which is persisted and shared with other clients. */
|
|
224
224
|
isSharedBranch: boolean, changeFamily: ChangeFamily<SharedTreeEditBuilder, SharedTreeChange>, storedSchema: TreeStoredSchemaRepository, forest: IEditableForest, mintRevisionTag: () => RevisionTag, revisionTagCodec: RevisionTagCodec, idCompressor: IIdCompressor, _removedRoots?: DetachedFieldIndex,
|
|
225
225
|
/** Optional logger for telemetry. */
|
|
226
|
-
logger?:
|
|
226
|
+
logger?: import("@fluidframework/telemetry-utils/internal").TelemetryLoggerExt | undefined, breaker?: Breakable, disposeForksAfterTransaction?: boolean);
|
|
227
227
|
/**
|
|
228
228
|
* Pushes a new label node for a transaction nesting level.
|
|
229
229
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeCheckout.d.ts","sourceRoot":"","sources":["../../src/shared-tree/treeCheckout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,+BAA+B,CAAC;AAE9E,OAAO,EAEN,KAAK,mBAAmB,EACxB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAGjB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAEjB,KAAK,W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,OAAO,CAAC,mBAAmB;IAkB3B;;;;;;;;OAQG;IACI,aAAa,CACnB,MAAM,EAAE,WAAW,CAAC,gBAAgB,CAAC,EACrC,EAAE,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,GACjD,OAAO;IAWV,iGAAiG;IACjG,OAAO,CAAC,cAAc;IActB;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAOsD;IAE/E,oBAAoB,IAAI,IAAI;IAS5B,kBAAkB,IAAI;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KAChB;IAIM,MAAM,CACZ,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,EACtC,OAAO,EAAE,SAAS,YAAY,CAAC,gBAAgB,CAAC,EAAE,GAChD,gBAAgB,EAAE;IAuCrB,IAAW,UAAU,IAAI,gBAAgB,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAEjF;CAGD"}
|
|
@@ -89,7 +89,7 @@ export interface SchemaStaticsAlpha {
|
|
|
89
89
|
* The migration path is:
|
|
90
90
|
*
|
|
91
91
|
* 1. Start with `sf.required(T)` — all clients require the field.
|
|
92
|
-
* 2. Deploy `sf.stagedOptional(T)` — new clients can read documents where the field is present or absent, but the stored schema stays Required (so old clients are unaffected).
|
|
92
|
+
* 2. Deploy `sf.stagedOptional(T)` — new clients can read documents where the field is present or absent, but the stored schema stays Required (so old clients are unaffected). Setting the field to `undefined` is rejected because the stored schema still declares the field as required.
|
|
93
93
|
* 3. Deploy `sf.optional(T)` once all clients support the staged optional field — the stored schema becomes Optional and the field can be cleared.
|
|
94
94
|
*
|
|
95
95
|
* Analogous to {@link SchemaStaticsBeta.staged} for allowed types, but for field optionality.
|
|
@@ -101,6 +101,14 @@ export interface SchemaStaticsAlpha {
|
|
|
101
101
|
* See {@link FieldSchemaMetadata.custom}.
|
|
102
102
|
*/
|
|
103
103
|
readonly stagedOptional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider" | "stagedOptionalUpgrade">) => FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
|
|
104
|
+
/**
|
|
105
|
+
* {@link SchemaStaticsAlpha.stagedOptional} except tweaked to work better for recursive types.
|
|
106
|
+
* Use with {@link ValidateRecursiveSchema} for improved type safety.
|
|
107
|
+
* @remarks
|
|
108
|
+
* This version of {@link SchemaStaticsAlpha.stagedOptional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
|
|
109
|
+
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
110
|
+
*/
|
|
111
|
+
readonly stagedOptionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "defaultProvider" | "stagedOptionalUpgrade">) => FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
|
|
104
112
|
/**
|
|
105
113
|
* {@link SchemaStaticsAlpha.withDefault} except tweaked to work better for recursive types.
|
|
106
114
|
* Use with {@link ValidateRecursiveSchema} for improved type safety.
|
|
@@ -218,6 +226,14 @@ export declare class SchemaFactoryAlpha<out TScope extends string | undefined =
|
|
|
218
226
|
* {@inheritdoc SchemaStaticsAlpha.stagedOptional}
|
|
219
227
|
*/
|
|
220
228
|
static readonly stagedOptional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "stagedOptionalUpgrade" | "defaultProvider"> | undefined) => FieldSchemaAlpha<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
|
|
229
|
+
/**
|
|
230
|
+
* {@inheritdoc SchemaStaticsAlpha.stagedOptionalRecursive}
|
|
231
|
+
*/
|
|
232
|
+
readonly stagedOptionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "stagedOptionalUpgrade" | "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
|
|
233
|
+
/**
|
|
234
|
+
* {@inheritdoc SchemaStaticsAlpha.stagedOptionalRecursive}
|
|
235
|
+
*/
|
|
236
|
+
static readonly stagedOptionalRecursive: <const T extends System_Unsafe.ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<FieldPropsAlpha<TCustomMetadata>, "stagedOptionalUpgrade" | "defaultProvider"> | undefined) => FieldSchemaAlphaUnsafe<FieldKind.Optional, T, TCustomMetadata, FieldPropsAlpha<TCustomMetadata>>;
|
|
221
237
|
/**
|
|
222
238
|
* Define a {@link TreeNodeSchema} for a {@link TreeMapNodeAlpha}.
|
|
223
239
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaFactoryAlpha.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EAIb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACN,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,SAAS,EACT,KAAK,mBAAmB,EACxB,KAAK,oCAAoC,EACzC,KAAK,WAAW,EAGhB,KAAK,eAAe,EACpB,MAAM,mBA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
};
|
|
60
61
|
/**
|
|
61
62
|
* {@link SchemaFactory} with additional alpha APIs.
|
|
@@ -101,6 +102,10 @@ class SchemaFactoryAlpha extends schemaFactoryBeta_js_1.SchemaFactoryBeta {
|
|
|
101
102
|
* {@inheritdoc SchemaStaticsAlpha.stagedOptional}
|
|
102
103
|
*/
|
|
103
104
|
this.stagedOptional = schemaStaticsAlpha.stagedOptional;
|
|
105
|
+
/**
|
|
106
|
+
* {@inheritdoc SchemaStaticsAlpha.stagedOptionalRecursive}
|
|
107
|
+
*/
|
|
108
|
+
this.stagedOptionalRecursive = schemaStaticsAlpha.stagedOptionalRecursive;
|
|
104
109
|
}
|
|
105
110
|
/**
|
|
106
111
|
* Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.
|
|
@@ -262,4 +267,8 @@ SchemaFactoryAlpha.withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursiv
|
|
|
262
267
|
* {@inheritdoc SchemaStaticsAlpha.stagedOptional}
|
|
263
268
|
*/
|
|
264
269
|
SchemaFactoryAlpha.stagedOptional = schemaStaticsAlpha.stagedOptional;
|
|
270
|
+
/**
|
|
271
|
+
* {@inheritdoc SchemaStaticsAlpha.stagedOptionalRecursive}
|
|
272
|
+
*/
|
|
273
|
+
SchemaFactoryAlpha.stagedOptionalRecursive = schemaStaticsAlpha.stagedOptionalRecursive;
|
|
265
274
|
//# sourceMappingURL=schemaFactoryAlpha.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+CAQ0B;AAC1B,qGAAqG;AACrG,gHAAgH;AAChH,sDAW2B;AAE3B,qDAWgC;AAGhC,gGAA8F;AAE9F,yDAM4B;AAC5B,iEAA2D;AAC3D,yDAAmD;AACnD,+CAAyC;AA2JzC,MAAM,WAAW,GAAG,CAKnB,WAAsD,EACtD,YAA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AG,IAAA,uBAAY,EAAC;YACjC,UAAU,EAAE,IAAA,yBAAM,EAAsB,IAAI,EAAE,IAAI,CAAC;YACnD,IAAI,EAAE,YAAwC;YAC9C,YAAY,EAAE,IAAI;YAClB,iFAAiF;YACjF,8GAA8G;YAC9G,uBAAuB,EAAE,KAAK;YAC9B,WAAW,EAAE,OAAO;SACpB,CAAC,CAAC;QAEH,OAAO,YAgBN,CAAC;IACH,CAAC;IAED;;OAEG;IACI,kBAAkB,CAGvB,IAAO;QACR,OAAO,IAAI,kBAAkB,CAAC,IAAA,yBAAM,EAAmB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACrE,CAAC;;AAzZF,gDA0ZC;AAtRA;;GAEG;AAC6B,yBAAM,GAAG,gCAAa,CAAC,MAAM,AAAvB,CAAwB;AAE9D;;GAEG;AAC6B,2BAAQ,GAAG,gCAAa,CAAC,QAAQ,AAAzB,CAA0B;AAElE;;GAEG;AAC6B,2BAAQ,GAAG,gCAAa,CAAC,QAAQ,AAAzB,CAA0B;AAElE;;GAEG;AAC6B,oCAAiB,GAAG,gCAAa,CAAC,iBAAiB,AAAlC,CAAmC;AAEpF;;GAEG;AAC6B,oCAAiB,GAAG,gCAAa,CAAC,iBAAiB,AAAlC,CAAmC;AAEpF;;GAEG;AACoB,6BAAU,GAAG,gCAAa,CAAC,UAAU,AAA3B,CAA4B;AAgC7D;;GAEG;AACoB,8BAAW,GAAG,kBAAkB,CAAC,WAAW,AAAjC,CAAkC;AAOpE;;GAEG;AACoB,uCAAoB,GAAG,kBAAkB,CAAC,oBAAoB,AAA1C,CAA2C;AAOtF;;GAEG;AACoB,iCAAc,GAAG,kBAAkB,CAAC,cAAc,AAApC,CAAqC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport {\n\ttype NodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype ImplicitAllowedTypes,\n\ttype WithType,\n\tnormalizeAllowedTypes,\n\tisTreeNode,\n\tcreateSchemaUpgrade,\n} from \"../core/index.js\";\n// These imports prevent a large number of type references in the API reports from showing up as *_2.\n/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\nimport {\n\ttype FieldProps,\n\ttype FieldSchemaAlpha,\n\ttype FieldPropsAlpha,\n\tFieldKind,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tgetDefaultProvider,\n\tcreateFieldSchema,\n\ttype DefaultProvider,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport {\n\ttype ArrayNodeCustomizableSchema,\n\ttype ArrayNodeCustomizableSchemaAlpha,\n\tarraySchema,\n\ttype MapNodeCustomizableSchema,\n\tmapSchema,\n\ttype ObjectNodeSchema,\n\ttype ObjectNodeSchemaWorkaround,\n\tobjectSchema,\n\ttype RecordNodeCustomizableSchema,\n\trecordSchema,\n} from \"../node-kinds/index.js\";\nimport type { SchemaType, SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport type { SimpleLeafNodeSchema } from \"../simpleSchema.js\";\nimport { unhydratedFlexTreeFromInsertableNode } from \"../unhydratedFlexTreeFromInsertable.js\";\n\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tscoped,\n\ttype NodeSchemaOptionsAlpha,\n\ttype ObjectSchemaOptionsAlpha,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport { SchemaFactoryBeta } from \"./schemaFactoryBeta.js\";\nimport { schemaStatics } from \"./schemaStatics.js\";\nimport { TreeBeta } from \"./treeBeta.js\";\nimport type {\n\tArrayNodeCustomizableSchemaUnsafe,\n\tFieldSchemaAlphaUnsafe,\n\tInsertableObjectFromSchemaRecordAlphaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n\tUnenforced,\n} from \"./typesUnsafe.js\";\n/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\n\n/**\n * A provider for values in tree nodes.\n *\n * @remarks\n * This type represents two ways to provide node values:\n *\n * 1. **A value**: Provide any value directly (number, string, object, array, etc.). When a value is provided,\n * the data is copied for each use to ensure independence between instances. The value must be of an allowed type for the field.\n *\n * 2. **A generator function**: A function that returns a value. The function is called each time a default is needed,\n * allowing for dynamic defaults or explicit control over value creation. The return value must be of an allowed type for the field.\n *\n * Values should be preferred over generator functions when possible, as they are simpler and more efficient.\n * Generator functions should be used when the default value needs to be dynamic or when it is not possible to provide a value directly.\n *\n * @example\n * ```typescript\n * // Provide a value directly\n * factory.withDefault(factory.required(factory.string), \"default\")\n * factory.withDefault(factory.optional(Person), new Person({ name: \"Guest\" }))\n *\n * // Use a generator function\n * factory.withDefault(factory.required(factory.string), () => crypto.randomUUID())\n * factory.withDefault(factory.optional(Person), () => new Person({ name: \"Guest\" }))\n * ```\n *\n * @alpha @sealed\n */\nexport type NodeProvider<T> = T | (() => T);\n\n/**\n * Stateless APIs exposed via {@link SchemaFactoryBeta} as both instance properties and as statics.\n * @see {@link SchemaStatics} for why this is useful.\n * @system @sealed @alpha\n */\nexport interface SchemaStaticsAlpha {\n\t/**\n\t * Creates a field schema with a default value. Fields with defaults (whether required or optional) are recognized by the type system as optional in constructors,\n\t * allowing them to be omitted when creating new nodes.\n\t *\n\t * @param fieldSchema - The field schema to add a default to (e.g., `factory.required(factory.string)` or `factory.optional(factory.number)`)\n\t * @param defaultValue - A {@link NodeProvider} specifying the default value.\n\t *\n\t * @example\n\t * ```typescript\n\t * const MySchema = factory.objectAlpha(\"MyObject\", {\n\t * // Provide values directly\n\t * name: factory.withDefault(factory.required(factory.string), \"untitled\"),\n\t * count: factory.withDefault(factory.required(factory.number), 0),\n\t * metadata: factory.withDefault(factory.optional(Metadata), new Metadata({ version: 1 })),\n\t *\n\t * // Use generator functions for dynamic values\n\t * timestamp: factory.withDefault(factory.required(factory.number), () => Date.now()),\n\t * id: factory.withDefault(factory.required(factory.string), () => crypto.randomUUID()),\n\t * });\n\t *\n\t * const obj1 = new MySchema({}); // All defaults applied\n\t * const obj2 = new MySchema({ name: \"custom\" }); // name=\"custom\", other defaults applied\n\t * ```\n\t *\n\t * @privateRemarks\n\t * This function wraps an existing field schema and adds a default value provider to it.\n\t * The default value will be used when constructing nodes if the field is not explicitly provided or set to `undefined`.\n\t *\n\t * Defaults are evaluated eagerly during node construction, unlike identifier defaults which require context.\n\t */\n\treadonly withDefault: <\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>(\n\t\tfieldSchema: FieldSchema<Kind, Types, TCustomMetadata>,\n\t\tdefaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>,\n\t) => FieldSchemaAlpha<\n\t\tKind,\n\t\tTypes,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n\t>;\n\t/**\n\t * Creates a field schema that is Optional in the view but behaves as Required in the stored schema\n\t * during the rollout period of an optional-field migration.\n\t *\n\t * @remarks\n\t * Use this to incrementally migrate a required field to optional without a coordinated deployment.\n\t * The migration path is:\n\t *\n\t * 1. Start with `sf.required(T)` — all clients require the field.\n\t * 2. Deploy `sf.stagedOptional(T)` — new clients can read documents where the field is present or absent, but the stored schema stays Required (so old clients are unaffected). Writing `undefined` is blocked at runtime.\n\t * 3. Deploy `sf.optional(T)` once all clients support the staged optional field — the stored schema becomes Optional and the field can be cleared.\n\t *\n\t * Analogous to {@link SchemaStaticsBeta.staged} for allowed types, but for field optionality.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\treadonly stagedOptional: <\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<\n\t\t\tFieldPropsAlpha<TCustomMetadata>,\n\t\t\t\"defaultProvider\" | \"stagedOptionalUpgrade\"\n\t\t>,\n\t) => FieldSchemaAlpha<\n\t\tFieldKind.Optional,\n\t\tT,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata>\n\t>;\n\n\t/**\n\t * {@link SchemaStaticsAlpha.withDefault} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStaticsAlpha.withDefault} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\twithDefaultRecursive: <\n\t\tKind extends FieldKind,\n\t\tTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tTCustomMetadata = unknown,\n\t>(\n\t\tfieldSchema: System_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata>,\n\t\tdefaultValue: Unenforced<\n\t\t\tNodeProvider<\n\t\t\t\tSystem_Unsafe.InsertableTreeFieldFromImplicitFieldUnsafe<\n\t\t\t\t\tSystem_Unsafe.FieldSchemaUnsafe<Kind, Types>\n\t\t\t\t>\n\t\t\t>\n\t\t>,\n\t) => FieldSchemaAlphaUnsafe<\n\t\tKind,\n\t\tTypes,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n\t>;\n}\n\nconst withDefault = <\n\tKind extends FieldKind,\n\tTypes extends ImplicitAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tfieldSchema: FieldSchema<Kind, Types, TCustomMetadata>,\n\tdefaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>,\n): FieldSchemaAlpha<\n\tKind,\n\tTypes,\n\tTCustomMetadata,\n\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n> => {\n\tconst typedFieldSchema = fieldSchema as FieldSchemaAlpha<Kind, Types, TCustomMetadata>;\n\n\t// create the default provider function, it is called eagerly during node construction\n\tconst defaultProvider = getDefaultProvider(() => {\n\t\t// Resolve the value: if it's a function, call it; otherwise use it directly\n\t\tlet insertableValue =\n\t\t\ttypeof defaultValue === \"function\" ? (defaultValue as () => unknown)() : defaultValue;\n\n\t\t// If the value is an already-constructed TreeNode (e.g., from a generator function that\n\t\t// returns the same instance repeatedly), clone it to ensure each use gets a fresh instance.\n\t\t// This prevents multi-parenting errors.\n\t\tif (isTreeNode(insertableValue)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tinsertableValue = TreeBeta.clone(insertableValue as any);\n\t\t}\n\n\t\t// For optional fields with an undefined default, return an empty array (no value).\n\t\tif (insertableValue === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Convert the insertable value to an unhydrated flex tree.\n\t\t// For insertable data, this creates a fresh tree structure.\n\t\tconst allowedTypeSet = normalizeAllowedTypes(typedFieldSchema.allowedTypes).evaluateSet();\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\treturn [unhydratedFlexTreeFromInsertableNode(insertableValue as any, allowedTypeSet)];\n\t});\n\n\t// create a new field schema with the default provider\n\tconst propsWithDefault = {\n\t\t...typedFieldSchema.props,\n\t\tdefaultProvider,\n\t};\n\n\treturn createFieldSchema(\n\t\ttypedFieldSchema.kind,\n\t\ttypedFieldSchema.allowedTypes,\n\t\tpropsWithDefault,\n\t);\n};\n\nconst stagedOptional = <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\tt: T,\n\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\" | \"stagedOptionalUpgrade\">,\n): FieldSchemaAlpha<\n\tFieldKind.Optional,\n\tT,\n\tTCustomMetadata,\n\tFieldPropsAlpha<TCustomMetadata>\n> => {\n\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\tdefaultProvider: getDefaultProvider(() => []),\n\t\t...props,\n\t\tstagedOptionalUpgrade: createSchemaUpgrade(),\n\t});\n};\n\nconst schemaStaticsAlpha: SchemaStaticsAlpha = {\n\twithDefault,\n\n\twithDefaultRecursive: withDefault as SchemaStaticsAlpha[\"withDefaultRecursive\"],\n\n\tstagedOptional,\n};\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n * When building schema, when `options` is not provided, `TCustomMetadata` is inferred as `unknown`.\n * If desired, this could be made to infer `undefined` instead by adding overloads for everything,\n * but currently it is not worth the maintenance overhead as there is no use case which this is known to be helpful for.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactoryBeta<TScope, TName> {\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic objectAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): ObjectNodeSchemaWorkaround<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn objectSchema(scoped<TScope, TName, Name>(this, name), fields, true, {\n\t\t\t...defaultSchemaFactoryObjectOptions,\n\t\t\t...options,\n\t\t});\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * Alpha version of {@link SchemaFactory.objectRecursive} that supports field defaults via {@link SchemaStaticsAlpha.withDefaultRecursive}.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * Use this instead of {@link SchemaFactory.objectRecursive} when fields use {@link SchemaStaticsAlpha.withDefaultRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic objectRecursiveAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordAlphaUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> &\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordAlphaUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic static override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic readonly withDefault = schemaStaticsAlpha.withDefault;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic static readonly withDefault = schemaStaticsAlpha.withDefault;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic readonly withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic static readonly withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.stagedOptional}\n\t */\n\tpublic readonly stagedOptional = schemaStaticsAlpha.stagedOptional;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.stagedOptional}\n\t */\n\tpublic static readonly stagedOptional = schemaStaticsAlpha.stagedOptional;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNodeAlpha}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchemaAlpha<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tT,\n\t\ttrue,\n\t\tTCustomMetadata\n\t> {\n\t\treturn arraySchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions ?? {},\n\t\t) as unknown as ArrayNodeCustomizableSchemaAlpha<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\ttrue,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@link SchemaFactory.arrayRecursive} but with support for some alpha features.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.recordAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic recordAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable: true,\n\t\t\timplicitlyConstructable: true,\n\t\t\tnodeOptions: options,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryBeta.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\tconst RecordSchema = recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes as T & ImplicitAllowedTypes,\n\t\t\tcustomizable: true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\timplicitlyConstructable: false,\n\t\t\tnodeOptions: options,\n\t\t});\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactoryBeta.scopedFactory}\n\t */\n\tpublic scopedFactoryAlpha<\n\t\tconst T extends TName,\n\t\tTNameInner extends number | string = string,\n\t>(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(scoped<TScope, TName, T>(this, name));\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+CAQ0B;AAC1B,q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C,oBAAoB,AAA1C,CAA2C;AAOtF;;GAEG;AACoB,iCAAc,GAAG,kBAAkB,CAAC,cAAc,AAApC,CAAqC;AAO1E;;GAEG;AACoB,0CAAuB,GAAG,kBAAkB,CAAC,uBAAuB,AAA7C,CAA8C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport {\n\ttype NodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype ImplicitAllowedTypes,\n\ttype WithType,\n\tnormalizeAllowedTypes,\n\tisTreeNode,\n\tcreateSchemaUpgrade,\n} from \"../core/index.js\";\n// These imports prevent a large number of type references in the API reports from showing up as *_2.\n/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\nimport {\n\ttype FieldProps,\n\ttype FieldSchemaAlpha,\n\ttype FieldPropsAlpha,\n\tFieldKind,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tgetDefaultProvider,\n\tcreateFieldSchema,\n\ttype DefaultProvider,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport {\n\ttype ArrayNodeCustomizableSchema,\n\ttype ArrayNodeCustomizableSchemaAlpha,\n\tarraySchema,\n\ttype MapNodeCustomizableSchema,\n\tmapSchema,\n\ttype ObjectNodeSchema,\n\ttype ObjectNodeSchemaWorkaround,\n\tobjectSchema,\n\ttype RecordNodeCustomizableSchema,\n\trecordSchema,\n} from \"../node-kinds/index.js\";\nimport type { SchemaType, SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport type { SimpleLeafNodeSchema } from \"../simpleSchema.js\";\nimport { unhydratedFlexTreeFromInsertableNode } from \"../unhydratedFlexTreeFromInsertable.js\";\n\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tscoped,\n\ttype NodeSchemaOptionsAlpha,\n\ttype ObjectSchemaOptionsAlpha,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport { SchemaFactoryBeta } from \"./schemaFactoryBeta.js\";\nimport { schemaStatics } from \"./schemaStatics.js\";\nimport { TreeBeta } from \"./treeBeta.js\";\nimport type {\n\tArrayNodeCustomizableSchemaUnsafe,\n\tFieldSchemaAlphaUnsafe,\n\tInsertableObjectFromSchemaRecordAlphaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n\tUnenforced,\n} from \"./typesUnsafe.js\";\n/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\n\n/**\n * A provider for values in tree nodes.\n *\n * @remarks\n * This type represents two ways to provide node values:\n *\n * 1. **A value**: Provide any value directly (number, string, object, array, etc.). When a value is provided,\n * the data is copied for each use to ensure independence between instances. The value must be of an allowed type for the field.\n *\n * 2. **A generator function**: A function that returns a value. The function is called each time a default is needed,\n * allowing for dynamic defaults or explicit control over value creation. The return value must be of an allowed type for the field.\n *\n * Values should be preferred over generator functions when possible, as they are simpler and more efficient.\n * Generator functions should be used when the default value needs to be dynamic or when it is not possible to provide a value directly.\n *\n * @example\n * ```typescript\n * // Provide a value directly\n * factory.withDefault(factory.required(factory.string), \"default\")\n * factory.withDefault(factory.optional(Person), new Person({ name: \"Guest\" }))\n *\n * // Use a generator function\n * factory.withDefault(factory.required(factory.string), () => crypto.randomUUID())\n * factory.withDefault(factory.optional(Person), () => new Person({ name: \"Guest\" }))\n * ```\n *\n * @alpha @sealed\n */\nexport type NodeProvider<T> = T | (() => T);\n\n/**\n * Stateless APIs exposed via {@link SchemaFactoryBeta} as both instance properties and as statics.\n * @see {@link SchemaStatics} for why this is useful.\n * @system @sealed @alpha\n */\nexport interface SchemaStaticsAlpha {\n\t/**\n\t * Creates a field schema with a default value. Fields with defaults (whether required or optional) are recognized by the type system as optional in constructors,\n\t * allowing them to be omitted when creating new nodes.\n\t *\n\t * @param fieldSchema - The field schema to add a default to (e.g., `factory.required(factory.string)` or `factory.optional(factory.number)`)\n\t * @param defaultValue - A {@link NodeProvider} specifying the default value.\n\t *\n\t * @example\n\t * ```typescript\n\t * const MySchema = factory.objectAlpha(\"MyObject\", {\n\t * // Provide values directly\n\t * name: factory.withDefault(factory.required(factory.string), \"untitled\"),\n\t * count: factory.withDefault(factory.required(factory.number), 0),\n\t * metadata: factory.withDefault(factory.optional(Metadata), new Metadata({ version: 1 })),\n\t *\n\t * // Use generator functions for dynamic values\n\t * timestamp: factory.withDefault(factory.required(factory.number), () => Date.now()),\n\t * id: factory.withDefault(factory.required(factory.string), () => crypto.randomUUID()),\n\t * });\n\t *\n\t * const obj1 = new MySchema({}); // All defaults applied\n\t * const obj2 = new MySchema({ name: \"custom\" }); // name=\"custom\", other defaults applied\n\t * ```\n\t *\n\t * @privateRemarks\n\t * This function wraps an existing field schema and adds a default value provider to it.\n\t * The default value will be used when constructing nodes if the field is not explicitly provided or set to `undefined`.\n\t *\n\t * Defaults are evaluated eagerly during node construction, unlike identifier defaults which require context.\n\t */\n\treadonly withDefault: <\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>(\n\t\tfieldSchema: FieldSchema<Kind, Types, TCustomMetadata>,\n\t\tdefaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>,\n\t) => FieldSchemaAlpha<\n\t\tKind,\n\t\tTypes,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n\t>;\n\t/**\n\t * Creates a field schema that is Optional in the view but behaves as Required in the stored schema\n\t * during the rollout period of an optional-field migration.\n\t *\n\t * @remarks\n\t * Use this to incrementally migrate a required field to optional without a coordinated deployment.\n\t * The migration path is:\n\t *\n\t * 1. Start with `sf.required(T)` — all clients require the field.\n\t * 2. Deploy `sf.stagedOptional(T)` — new clients can read documents where the field is present or absent, but the stored schema stays Required (so old clients are unaffected). Setting the field to `undefined` is rejected because the stored schema still declares the field as required.\n\t * 3. Deploy `sf.optional(T)` once all clients support the staged optional field — the stored schema becomes Optional and the field can be cleared.\n\t *\n\t * Analogous to {@link SchemaStaticsBeta.staged} for allowed types, but for field optionality.\n\t *\n\t * @param t - The types allowed under the field.\n\t * @param props - Optional properties to associate with the field.\n\t *\n\t * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n\t * See {@link FieldSchemaMetadata.custom}.\n\t */\n\treadonly stagedOptional: <\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<\n\t\t\tFieldPropsAlpha<TCustomMetadata>,\n\t\t\t\"defaultProvider\" | \"stagedOptionalUpgrade\"\n\t\t>,\n\t) => FieldSchemaAlpha<\n\t\tFieldKind.Optional,\n\t\tT,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata>\n\t>;\n\t/**\n\t * {@link SchemaStaticsAlpha.stagedOptional} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStaticsAlpha.stagedOptional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\treadonly stagedOptionalRecursive: <\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tt: T,\n\t\tprops?: Omit<\n\t\t\tFieldPropsAlpha<TCustomMetadata>,\n\t\t\t\"defaultProvider\" | \"stagedOptionalUpgrade\"\n\t\t>,\n\t) => FieldSchemaAlphaUnsafe<\n\t\tFieldKind.Optional,\n\t\tT,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata>\n\t>;\n\n\t/**\n\t * {@link SchemaStaticsAlpha.withDefault} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStaticsAlpha.withDefault} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\twithDefaultRecursive: <\n\t\tKind extends FieldKind,\n\t\tTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tTCustomMetadata = unknown,\n\t>(\n\t\tfieldSchema: System_Unsafe.FieldSchemaUnsafe<Kind, Types, TCustomMetadata>,\n\t\tdefaultValue: Unenforced<\n\t\t\tNodeProvider<\n\t\t\t\tSystem_Unsafe.InsertableTreeFieldFromImplicitFieldUnsafe<\n\t\t\t\t\tSystem_Unsafe.FieldSchemaUnsafe<Kind, Types>\n\t\t\t\t>\n\t\t\t>\n\t\t>,\n\t) => FieldSchemaAlphaUnsafe<\n\t\tKind,\n\t\tTypes,\n\t\tTCustomMetadata,\n\t\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n\t>;\n}\n\nconst withDefault = <\n\tKind extends FieldKind,\n\tTypes extends ImplicitAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tfieldSchema: FieldSchema<Kind, Types, TCustomMetadata>,\n\tdefaultValue: NodeProvider<InsertableTreeFieldFromImplicitField<FieldSchema<Kind, Types>>>,\n): FieldSchemaAlpha<\n\tKind,\n\tTypes,\n\tTCustomMetadata,\n\tFieldPropsAlpha<TCustomMetadata> & { defaultProvider: DefaultProvider }\n> => {\n\tconst typedFieldSchema = fieldSchema as FieldSchemaAlpha<Kind, Types, TCustomMetadata>;\n\n\t// create the default provider function, it is called eagerly during node construction\n\tconst defaultProvider = getDefaultProvider(() => {\n\t\t// Resolve the value: if it's a function, call it; otherwise use it directly\n\t\tlet insertableValue =\n\t\t\ttypeof defaultValue === \"function\" ? (defaultValue as () => unknown)() : defaultValue;\n\n\t\t// If the value is an already-constructed TreeNode (e.g., from a generator function that\n\t\t// returns the same instance repeatedly), clone it to ensure each use gets a fresh instance.\n\t\t// This prevents multi-parenting errors.\n\t\tif (isTreeNode(insertableValue)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tinsertableValue = TreeBeta.clone(insertableValue as any);\n\t\t}\n\n\t\t// For optional fields with an undefined default, return an empty array (no value).\n\t\tif (insertableValue === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Convert the insertable value to an unhydrated flex tree.\n\t\t// For insertable data, this creates a fresh tree structure.\n\t\tconst allowedTypeSet = normalizeAllowedTypes(typedFieldSchema.allowedTypes).evaluateSet();\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\treturn [unhydratedFlexTreeFromInsertableNode(insertableValue as any, allowedTypeSet)];\n\t});\n\n\t// create a new field schema with the default provider\n\tconst propsWithDefault = {\n\t\t...typedFieldSchema.props,\n\t\tdefaultProvider,\n\t};\n\n\treturn createFieldSchema(\n\t\ttypedFieldSchema.kind,\n\t\ttypedFieldSchema.allowedTypes,\n\t\tpropsWithDefault,\n\t);\n};\n\nconst stagedOptional = <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(\n\tt: T,\n\tprops?: Omit<FieldPropsAlpha<TCustomMetadata>, \"defaultProvider\" | \"stagedOptionalUpgrade\">,\n): FieldSchemaAlpha<\n\tFieldKind.Optional,\n\tT,\n\tTCustomMetadata,\n\tFieldPropsAlpha<TCustomMetadata>\n> => {\n\treturn createFieldSchema(FieldKind.Optional, t, {\n\t\tdefaultProvider: getDefaultProvider(() => []),\n\t\t...props,\n\t\tstagedOptionalUpgrade: createSchemaUpgrade(),\n\t});\n};\n\nconst schemaStaticsAlpha: SchemaStaticsAlpha = {\n\twithDefault,\n\twithDefaultRecursive: withDefault as SchemaStaticsAlpha[\"withDefaultRecursive\"],\n\tstagedOptional,\n\tstagedOptionalRecursive: stagedOptional as SchemaStaticsAlpha[\"stagedOptionalRecursive\"],\n};\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n * When building schema, when `options` is not provided, `TCustomMetadata` is inferred as `unknown`.\n * If desired, this could be made to infer `undefined` instead by adding overloads for everything,\n * but currently it is not worth the maintenance overhead as there is no use case which this is known to be helpful for.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactoryBeta<TScope, TName> {\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic objectAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): ObjectNodeSchemaWorkaround<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn objectSchema(scoped<TScope, TName, Name>(this, name), fields, true, {\n\t\t\t...defaultSchemaFactoryObjectOptions,\n\t\t\t...options,\n\t\t});\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * Alpha version of {@link SchemaFactory.objectRecursive} that supports field defaults via {@link SchemaStaticsAlpha.withDefaultRecursive}.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * Use this instead of {@link SchemaFactory.objectRecursive} when fields use {@link SchemaStaticsAlpha.withDefaultRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tpublic objectRecursiveAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordAlphaUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<SchemaType.View, TCustomMetadata> &\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.objectAlpha(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordAlphaUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic static override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.leaves}\n\t */\n\tpublic override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.requiredRecursive}\n\t */\n\tpublic override readonly requiredRecursive = schemaStatics.requiredRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic readonly withDefault = schemaStaticsAlpha.withDefault;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic static readonly withDefault = schemaStaticsAlpha.withDefault;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic readonly withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.withDefault}\n\t */\n\tpublic static readonly withDefaultRecursive = schemaStaticsAlpha.withDefaultRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.stagedOptional}\n\t */\n\tpublic readonly stagedOptional = schemaStaticsAlpha.stagedOptional;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.stagedOptional}\n\t */\n\tpublic static readonly stagedOptional = schemaStaticsAlpha.stagedOptional;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.stagedOptionalRecursive}\n\t */\n\tpublic readonly stagedOptionalRecursive = schemaStaticsAlpha.stagedOptionalRecursive;\n\n\t/**\n\t * {@inheritdoc SchemaStaticsAlpha.stagedOptionalRecursive}\n\t */\n\tpublic static readonly stagedOptionalRecursive = schemaStaticsAlpha.stagedOptionalRecursive;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNodeAlpha}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchemaAlpha<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tT,\n\t\ttrue,\n\t\tTCustomMetadata\n\t> {\n\t\treturn arraySchema(\n\t\t\tscoped<TScope, TName, Name>(this, name),\n\t\t\tallowedTypes,\n\t\t\ttrue,\n\t\t\ttrue,\n\t\t\toptions ?? {},\n\t\t) as unknown as ArrayNodeCustomizableSchemaAlpha<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\ttrue,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@link SchemaFactory.arrayRecursive} but with support for some alpha features.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.recordAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic recordAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptionsAlpha<TCustomMetadata>,\n\t): RecordNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable: true,\n\t\t\timplicitlyConstructable: true,\n\t\t\tnodeOptions: options,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryBeta.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptionsAlpha<TCustomMetadata>) {\n\t\tconst RecordSchema = recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes as T & ImplicitAllowedTypes,\n\t\t\tcustomizable: true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\timplicitlyConstructable: false,\n\t\t\tnodeOptions: options,\n\t\t});\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactoryBeta.scopedFactory}\n\t */\n\tpublic scopedFactoryAlpha<\n\t\tconst T extends TName,\n\t\tTNameInner extends number | string = string,\n\t>(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(scoped<TScope, TName, T>(this, name));\n\t}\n}\n"]}
|