@fluid-experimental/tree 1.1.0 → 1.2.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/dist/Common.d.ts +12 -6
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js +14 -8
- package/dist/Common.js.map +1 -1
- package/dist/SharedTree.d.ts +12 -1
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +61 -11
- package/dist/SharedTree.js.map +1 -1
- package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
- package/dist/id-compressor/IdCompressor.js +7 -11
- package/dist/id-compressor/IdCompressor.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/lib/Common.d.ts +12 -6
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +14 -8
- package/lib/Common.js.map +1 -1
- package/lib/SharedTree.d.ts +12 -1
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +61 -11
- package/lib/SharedTree.js.map +1 -1
- package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
- package/lib/id-compressor/IdCompressor.js +7 -11
- package/lib/id-compressor/IdCompressor.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/test/IdCompressor.tests.js +2 -1
- package/lib/test/IdCompressor.tests.js.map +1 -1
- package/lib/test/fuzz/Generators.d.ts.map +1 -1
- package/lib/test/fuzz/Generators.js +20 -10
- package/lib/test/fuzz/Generators.js.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
- package/lib/test/fuzz/SharedTreeFuzzTests.js +55 -20
- package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
- package/lib/test/fuzz/Types.d.ts +14 -4
- package/lib/test/fuzz/Types.d.ts.map +1 -1
- package/lib/test/fuzz/Types.js.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
- package/lib/test/utilities/PendingLocalStateTests.js +199 -56
- package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
- package/lib/test/utilities/TestUtilities.d.ts +12 -1
- package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
- package/lib/test/utilities/TestUtilities.js +12 -2
- package/lib/test/utilities/TestUtilities.js.map +1 -1
- package/package.json +17 -17
- package/src/Common.ts +14 -8
- package/src/SharedTree.ts +90 -12
- package/src/id-compressor/IdCompressor.ts +9 -11
- package/src/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestUtilities.js","sourceRoot":"","sources":["../../../src/test/utilities/TestUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,EAAa,MAAM,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EACN,2BAA2B,EAC3B,yBAAyB,EACzB,WAAW,GACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAGN,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,GACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAenE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAoB,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO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H,MAAM,UAAU,iBAAiB,CAChC,uBAAoD;IAEpD,MAAM,GAAG,GAAS,EAAE,CAAC;IACrB,MAAM,YAAY,GAAG,uBAAuB,CAAC,WAAW,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACvF,uBAAuB,CAAC,WAAW,GAAG,CAAC,OAA2C,EAAE,EAAE;QACrF,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAC7B,GAAG,CAAC,IAAI,CAAC,QAAc,CAAC,CAAC;QACzB,YAAY,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,aAAyB;IAC7D,MAAM,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC;IACvC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,YAAY,EAAE,IAAI,mBAAmB,EAAE,CAAC,CAAC;IACzF,MAAM,YAAY,GAAG,MAAM,iBAAiB,CAAC,cAAc,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;IAC7F,OAAO,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC;AAChD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { resolve } from 'path';\nimport { v5 as uuidv5 } from 'uuid';\nimport { expect } from 'chai';\nimport { SummaryCollection, DefaultSummaryConfiguration } from '@fluidframework/container-runtime';\nimport { Container, Loader, waitContainerToCatchUp } from '@fluidframework/container-loader';\nimport { requestFluidObject } from '@fluidframework/runtime-utils';\nimport {\n\tMockContainerRuntimeFactory,\n\tMockFluidDataStoreRuntime,\n\tMockStorage,\n} from '@fluidframework/test-runtime-utils';\nimport {\n\tChannelFactoryRegistry,\n\tITestFluidObject,\n\tTestObjectProvider,\n\tTestContainerRuntimeFactory,\n\tTestFluidObjectFactory,\n\tcreateAndAttachContainer,\n} from '@fluidframework/test-utils';\nimport { LocalServerTestDriver } from '@fluidframework/test-drivers';\nimport { ITelemetryBaseLogger } from '@fluidframework/common-definitions';\nimport { TelemetryNullLogger } from '@fluidframework/common-utils';\nimport type { IContainer, IHostLoader } from '@fluidframework/container-definitions';\nimport type { IFluidCodeDetails, IFluidHandle, IRequestHeader } from '@fluidframework/core-interfaces';\nimport { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport { IContainerRuntimeBase } from '@fluidframework/runtime-definitions';\nimport { IRequest } from '@fluidframework/core-interfaces';\nimport {\n\tAttributionId,\n\tDetachedSequenceId,\n\tEditId,\n\tNodeId,\n\tOpSpaceNodeId,\n\tSessionId,\n\tStableNodeId,\n} from '../../Identifiers';\nimport { assert, fail, identity, ReplaceRecursive } from '../../Common';\nimport { IdCompressor } from '../../id-compressor';\nimport { createSessionId } from '../../id-compressor/NumericUuid';\nimport { getChangeNodeFromViewNode } from '../../SerializationUtilities';\nimport { initialTree } from '../../InitialTree';\nimport {\n\tChangeInternal,\n\tEdit,\n\tNodeData,\n\tPayload,\n\treservedIdCount,\n\tSharedTreeOp,\n\tSharedTreeOp_0_0_2,\n\tWriteFormat,\n} from '../../persisted-types';\nimport { TraitLocation, TreeView } from '../../TreeView';\nimport { SharedTreeDiagnosticEvent } from '../../EventTypes';\nimport { getNodeId, getNodeIdContext, NodeIdContext, NodeIdConverter, NodeIdNormalizer } from '../../NodeIdUtilities';\nimport { newEdit, setTrait } from '../../EditUtilities';\nimport { SharedTree, SharedTreeFactory } from '../../SharedTree';\nimport { BuildNode, Change, StablePlace } from '../../ChangeTypes';\nimport { convertEditIds } from '../../IdConversion';\nimport { OrderedEditSet } from '../../EditLog';\nimport { buildLeaf, RefreshingTestTree, SimpleTestTree, TestTree } from './TestNode';\n\n/** Objects returned by setUpTestSharedTree */\nexport interface SharedTreeTestingComponents {\n\t/** The MockFluidDataStoreRuntime used to created the SharedTree. */\n\tcomponentRuntime: MockFluidDataStoreRuntime;\n\t/**\n\t * The MockContainerRuntimeFactory created if one was not provided in the options.\n\t * Only connected to the SharedTree if the localMode option was set to false.\n\t * */\n\tcontainerRuntimeFactory: MockContainerRuntimeFactory;\n\t/** The SharedTree created and set up. */\n\ttree: SharedTree;\n}\n\n/** Options used to customize setUpTestSharedTree */\nexport interface SharedTreeTestingOptions {\n\t/**\n\t * Id for the SharedTree to be created.\n\t * If two SharedTrees have the same id and the same containerRuntimeFactory,\n\t * they will collaborate (send edits to each other)\n\t */\n\tid?: string;\n\t/** Node to initialize the SharedTree with. */\n\tinitialTree?: BuildNode;\n\t/** If false, a MockContainerRuntimeFactory connected to the SharedTree will be returned. */\n\tlocalMode?: boolean;\n\t/**\n\t * MockContainerRuntimeFactory to connect the SharedTree to. A new one will not be created if one is provided.\n\t * If localMode is set to true, it will not be connected to the created SharedTree.\n\t * */\n\tcontainerRuntimeFactory?: MockContainerRuntimeFactory;\n\t/** Iff true, do not `fail` on invalid edits */\n\tallowInvalid?: boolean;\n\t/** Iff true, do not `fail` on malformed edits */\n\tallowMalformed?: boolean;\n\t/** Unless set to true, a SharedTree error causes the test to fail */\n\tnoFailOnError?: boolean;\n\t/**\n\t * If not set, full history will be preserved.\n\t */\n\tsummarizeHistory?: boolean;\n\t/**\n\t * If not set, summaries will be written in format 0.1.1.\n\t */\n\twriteFormat?: WriteFormat;\n\t/**\n\t * Optional attribution ID to give to the new tree\n\t */\n\tattributionId?: AttributionId;\n\t/**\n\t * If set, uses the given id as the edit id for tree setup. Only has an effect if initialTree is also set.\n\t */\n\tsetupEditId?: EditId;\n\n\t/**\n\t * Telemetry logger injected into the SharedTree.\n\t */\n\tlogger?: ITelemetryBaseLogger;\n}\n\nexport const testTraitLabel = SimpleTestTree.traitLabel;\nexport function testTrait(view: TreeView): TraitLocation {\n\treturn {\n\t\tlabel: testTraitLabel,\n\t\tparent: view.root,\n\t};\n}\n\n/** Sets up and returns an object of components useful for testing SharedTree. */\nexport function setUpTestSharedTree(\n\toptions: SharedTreeTestingOptions = { localMode: true }\n): SharedTreeTestingComponents {\n\tconst {\n\t\tid,\n\t\tinitialTree,\n\t\tlocalMode,\n\t\tcontainerRuntimeFactory,\n\t\tsetupEditId,\n\t\tsummarizeHistory,\n\t\twriteFormat,\n\t\tattributionId,\n\t} = options;\n\tlet componentRuntime: MockFluidDataStoreRuntime;\n\tif (options.logger) {\n\t\tconst proxyHandler: ProxyHandler<MockFluidDataStoreRuntime> = {\n\t\t\tget: (target, prop, receiver) => {\n\t\t\t\tif (prop === 'logger' && options.logger) {\n\t\t\t\t\treturn options.logger;\n\t\t\t\t}\n\t\t\t\treturn target[prop as keyof MockFluidDataStoreRuntime];\n\t\t\t},\n\t\t};\n\t\tcomponentRuntime = new Proxy(new MockFluidDataStoreRuntime(), proxyHandler);\n\t} else {\n\t\tcomponentRuntime = new MockFluidDataStoreRuntime();\n\t}\n\n\t// Enable expensiveValidation\n\tlet factory: SharedTreeFactory;\n\tif (writeFormat === WriteFormat.v0_0_2) {\n\t\tfactory = SharedTree.getFactory(writeFormat, { summarizeHistory: summarizeHistory ?? true });\n\t} else {\n\t\tconst options = {\n\t\t\tsummarizeHistory: summarizeHistory ?? true ? { uploadEditChunks: true } : false,\n\t\t\tattributionId,\n\t\t};\n\t\tfactory = SharedTree.getFactory(writeFormat ?? WriteFormat.v0_1_1, options);\n\t}\n\tconst tree = factory.create(componentRuntime, id === undefined ? 'testSharedTree' : id);\n\n\tif (options.allowInvalid === undefined || !options.allowInvalid) {\n\t\ttree.on(SharedTreeDiagnosticEvent.DroppedInvalidEdit, () => fail('unexpected invalid edit'));\n\t}\n\n\tif (options.allowMalformed === undefined || !options.allowMalformed) {\n\t\ttree.on(SharedTreeDiagnosticEvent.DroppedMalformedEdit, () => fail('unexpected malformed edit'));\n\t}\n\n\tif (options.noFailOnError === undefined || !options.noFailOnError) {\n\t\t// any errors thrown by a SharedObject event listener will be caught and\n\t\t// reemitted on this event. For testing purposes, rethrow so that it\n\t\t// actually causes the test to fail.\n\t\ttree.on('error', (error) => {\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tconst newContainerRuntimeFactory = containerRuntimeFactory || new MockContainerRuntimeFactory();\n\n\tif (localMode === true) {\n\t\tcomponentRuntime.local = true;\n\t} else {\n\t\tconst containerRuntime = newContainerRuntimeFactory.createContainerRuntime(componentRuntime);\n\t\tconst services = {\n\t\t\tdeltaConnection: containerRuntime.createDeltaConnection(),\n\t\t\tobjectStorage: new MockStorage(undefined),\n\t\t};\n\t\ttree.connect(services);\n\t}\n\n\tif (initialTree !== undefined) {\n\t\tsetTestTree(tree, initialTree, setupEditId);\n\t}\n\n\treturn {\n\t\tcomponentRuntime,\n\t\tcontainerRuntimeFactory: newContainerRuntimeFactory,\n\t\ttree,\n\t};\n}\n\nconst TestDataStoreType = '@fluid-example/test-dataStore';\n\n/** Objects returned by setUpLocalServerTestSharedTree */\nexport interface LocalServerSharedTreeTestingComponents {\n\t/** The testObjectProvider created if one was not set in the options. */\n\ttestObjectProvider: TestObjectProvider;\n\t/** The SharedTree created and set up. */\n\ttree: SharedTree;\n\t/** The container created and set up. */\n\tcontainer: Container;\n\t/** Handles to any blobs uploaded via `blobs` */\n\tuploadedBlobs: IFluidHandle<ArrayBufferLike>[];\n}\n\n/** Options used to customize setUpLocalServerTestSharedTree */\nexport interface LocalServerSharedTreeTestingOptions {\n\t/** Contents of blobs that should be uploaded to the runtime upon creation. Handles to these blobs will be returned. */\n\tblobs?: ArrayBufferLike[];\n\t/** Headers to include on the container load request. */\n\theaders?: IRequestHeader;\n\t/**\n\t * Id for the SharedTree to be created.\n\t * If two SharedTrees have the same id and the same testObjectProvider,\n\t * they will collaborate (send edits to each other)\n\t */\n\tid?: string;\n\t/** Node to initialize the SharedTree with. */\n\tinitialTree?: BuildNode;\n\t/** If set, uses the provider to create the container and create the SharedTree. */\n\ttestObjectProvider?: TestObjectProvider;\n\t/**\n\t * If not set, full history will be preserved.\n\t */\n\tsummarizeHistory?: boolean;\n\t/**\n\t * If not set, summaries will be written in format 0.0.2.\n\t */\n\twriteFormat?: WriteFormat;\n\t/**\n\t * Optional attribution ID to give to the new tree\n\t */\n\tattributionId?: AttributionId;\n\t/**\n\t * If not set, will upload edit chunks when they are full.\n\t */\n\tuploadEditChunks?: boolean;\n\t/**\n\t * If set, uses the given id as the edit id for tree setup. Only has an effect if initialTree is also set.\n\t */\n\tsetupEditId?: EditId;\n}\n\nconst testObjectProviders: TestObjectProvider[] = [];\nafterEach(() => {\n\tfor (const provider of testObjectProviders) {\n\t\tprovider.reset();\n\t}\n\ttestObjectProviders.length = 0;\n});\n\n/**\n * Sets up and returns an object of components useful for testing SharedTree with a local server.\n * Required for tests that involve the uploadBlob API.\n *\n * Any TestObjectProvider created by this function will be reset after the test completes (via afterEach) hook.\n */\nexport async function setUpLocalServerTestSharedTree(\n\toptions: LocalServerSharedTreeTestingOptions\n): Promise<LocalServerSharedTreeTestingComponents> {\n\tconst {\n\t\tblobs,\n\t\theaders,\n\t\tid,\n\t\tinitialTree,\n\t\ttestObjectProvider,\n\t\tsetupEditId,\n\t\tsummarizeHistory,\n\t\twriteFormat,\n\t\tuploadEditChunks,\n\t\tattributionId,\n\t} = options;\n\n\tconst treeId = id ?? 'test';\n\tlet factory: SharedTreeFactory;\n\tif (writeFormat === WriteFormat.v0_0_2) {\n\t\tfactory = SharedTree.getFactory(writeFormat, { summarizeHistory: summarizeHistory ?? true });\n\t} else {\n\t\tconst options = {\n\t\t\tsummarizeHistory: summarizeHistory ?? true ? { uploadEditChunks: uploadEditChunks ?? true } : false,\n\t\t\tattributionId,\n\t\t};\n\t\tfactory = SharedTree.getFactory(writeFormat ?? WriteFormat.v0_1_1, options);\n\t}\n\tconst registry: ChannelFactoryRegistry = [[treeId, factory]];\n\tconst innerRequestHandler = async (request: IRequest, runtime: IContainerRuntimeBase) =>\n\t\truntime.IFluidHandleContext.resolveHandle(request);\n\n\tconst runtimeFactory = () =>\n\t\tnew TestContainerRuntimeFactory(\n\t\t\tTestDataStoreType,\n\t\t\tnew TestFluidObjectFactory(registry),\n\t\t\t{\n\t\t\t\tenableOfflineLoad: true,\n\t\t\t\tsummaryOptions: {\n\t\t\t\t\tsummaryConfigOverrides: {\n\t\t\t\t\t\t...DefaultSummaryConfiguration,\n\t\t\t\t\t\t...{\n\t\t\t\t\t\t\tidleTime: 1000, // Current default idleTime is 15000 which will cause some SharedTree tests to timeout.\n\t\t\t\t\t\t\tmaxTime: 1000 * 12,\n\t\t\t\t\t\t\tinitialSummarizerDelayMs: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t[innerRequestHandler]\n\t\t);\n\n\tconst defaultCodeDetails: IFluidCodeDetails = {\n\t\tpackage: 'defaultTestPackage',\n\t\tconfig: {},\n\t};\n\n\tfunction makeTestLoader(provider: TestObjectProvider): IHostLoader {\n\t\tconst fluidEntryPoint = runtimeFactory();\n\t\treturn provider.createLoader([[defaultCodeDetails, fluidEntryPoint]], {\n\t\t\toptions: { maxClientLeaveWaitTime: 1000 },\n\t\t});\n\t}\n\n\tlet provider: TestObjectProvider;\n\tlet container: Container;\n\n\tif (testObjectProvider !== undefined) {\n\t\tprovider = testObjectProvider;\n\t\tconst driver = new LocalServerTestDriver();\n\t\tconst loader = makeTestLoader(provider);\n\t\t// Once ILoaderOptions is specificable, this should use `provider.loadTestContainer` instead.\n\t\tcontainer = (await loader.resolve({ url: await driver.createContainerUrl(treeId), headers })) as Container;\n\t\tawait waitContainerToCatchUp(container);\n\t} else {\n\t\tconst driver = new LocalServerTestDriver();\n\t\tprovider = new TestObjectProvider(Loader, driver, runtimeFactory);\n\t\ttestObjectProviders.push(provider);\n\t\t// Once ILoaderOptions is specificable, this should use `provider.makeTestContainer` instead.\n\t\tconst loader = makeTestLoader(provider);\n\t\tcontainer = (await createAndAttachContainer(\n\t\t\tdefaultCodeDetails,\n\t\t\tloader,\n\t\t\tdriver.createCreateNewRequest(treeId)\n\t\t)) as Container;\n\t}\n\n\tconst dataObject = await requestFluidObject<ITestFluidObject>(container, '/');\n\n\tconst uploadedBlobs =\n\t\tblobs === undefined ? [] : await Promise.all(blobs.map(async (blob) => dataObject.context.uploadBlob(blob)));\n\tconst tree = await dataObject.getSharedObject<SharedTree>(treeId);\n\n\tif (initialTree !== undefined && testObjectProvider === undefined) {\n\t\tsetTestTree(tree, initialTree, setupEditId);\n\t}\n\n\treturn { container, tree, testObjectProvider: provider, uploadedBlobs };\n}\n\n/** Sets testTrait to contain `node`. */\nfunction setTestTree(tree: SharedTree, node: BuildNode, overrideId?: EditId): EditId {\n\tconst trait = testTrait(tree.currentView);\n\tif (overrideId === undefined) {\n\t\treturn tree.applyEdit(...setTrait(trait, node)).id;\n\t} else {\n\t\tconst changes = setTrait(trait, node).map((c) => tree.internalizeChange(c));\n\t\treturn tree.applyEditInternal({ changes, id: overrideId }).id;\n\t}\n}\n\n/**\n * Creates a list of edits with stable IDs that can be processed by a SharedTree.\n * @returns the list of created edits\n */\nexport function createStableEdits(\n\tnumberOfEdits: number,\n\tidContext: NodeIdContext = makeNodeIdContext(),\n\tpayload: (i: number) => Payload = identity\n): Edit<ChangeInternal>[] {\n\tif (numberOfEdits === 0) {\n\t\treturn [];\n\t}\n\n\tconst uuidNamespace = '44864298-500e-4cf8-9f44-a249e5b3a286';\n\tconst nodeId = idContext.generateNodeId('ae6b24eb-6fa8-42cc-abd2-48f250b7798f');\n\tconst node = buildLeaf(nodeId);\n\tconst insertEmptyNode = newEdit([\n\t\tChangeInternal.build([node], 0 as DetachedSequenceId),\n\t\tChangeInternal.insert(\n\t\t\t0 as DetachedSequenceId,\n\t\t\tStablePlace.atEndOf({ label: testTraitLabel, parent: idContext.convertToNodeId(initialTree.identifier) })\n\t\t),\n\t]);\n\n\tconst edits: Edit<ChangeInternal>[] = [{ ...insertEmptyNode, id: uuidv5('test', uuidNamespace) as EditId }];\n\n\t// Every subsequent edit is a set payload\n\tfor (let i = 1; i < numberOfEdits; i++) {\n\t\tconst edit = newEdit([ChangeInternal.setPayload(nodeId, payload(i))]);\n\t\tedits.push({ ...edit, id: uuidv5(i.toString(), uuidNamespace) as EditId });\n\t}\n\n\treturn edits;\n}\n\n/** Asserts that changes to SharedTree in editor() function do not cause any observable state change */\nexport function assertNoDelta(tree: SharedTree, editor: () => void) {\n\tconst viewA = tree.currentView;\n\teditor();\n\tconst viewB = tree.currentView;\n\tconst delta = viewA.delta(viewB);\n\texpect(delta).deep.equals({\n\t\tchanged: [],\n\t\tadded: [],\n\t\tremoved: [],\n\t});\n}\n\n/**\n * Used to test error throwing in async functions.\n */\nexport async function asyncFunctionThrowsCorrectly(\n\tasyncFunction: () => Promise<unknown>,\n\texpectedError: string\n): Promise<boolean> {\n\tlet errorMessage: string | undefined;\n\n\ttry {\n\t\tawait asyncFunction();\n\t} catch (error) {\n\t\terrorMessage = (error as Error).message;\n\t}\n\n\treturn errorMessage === expectedError;\n}\n\n/*\n * Returns true if two nodes have equivalent data, otherwise false.\n * Does not compare children or payloads.\n * @param nodes - two or more nodes to compare\n */\nexport function areNodesEquivalent(...nodes: NodeData<unknown>[]): boolean {\n\tif (nodes.length < 2) {\n\t\tfail('Too few nodes to compare');\n\t}\n\n\tfor (let i = 1; i < nodes.length; i++) {\n\t\tif (nodes[i].definition !== nodes[0].definition) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (nodes[i].identifier !== nodes[0].identifier) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n// This accounts for this file being executed after compilation. If many tests want to leverage resources, we should unify\n// resource path logic to a single place.\nexport const testDocumentsPathBase = resolve(__dirname, '../../../src/test/documents/');\n\nexport const versionComparator = (versionA: string, versionB: string): number => {\n\tconst versionASplit = versionA.split('.');\n\tconst versionBSplit = versionB.split('.');\n\n\tassert(\n\t\tversionASplit.length === versionBSplit.length && versionASplit.length === 3,\n\t\t'Version numbers should follow semantic versioning.'\n\t);\n\n\tfor (let i = 0; i < 3; ++i) {\n\t\tconst numberA = parseInt(versionASplit[i], 10);\n\t\tconst numberB = parseInt(versionBSplit[i], 10);\n\n\t\tif (numberA > numberB) {\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (numberA < numberB) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\treturn 0;\n};\n\n/**\n * Create a {@link SimpleTestTree} from the given {@link SharedTree} or {@link IdCompressor}\n */\nexport function setUpTestTree(idSource?: IdCompressor | SharedTree, expensiveValidation = false): TestTree {\n\tconst source = idSource ?? new IdCompressor(createSessionId(), reservedIdCount);\n\tif (source instanceof SharedTree) {\n\t\tassert(source.edits.length === 0, 'tree must be a new SharedTree');\n\t\tconst getNormalizer = () => getIdNormalizerFromSharedTree(source);\n\t\tconst contextWrapper = {\n\t\t\tnormalizeToOpSpace: (id: NodeId) => getNormalizer().normalizeToOpSpace(id),\n\t\t\tnormalizeToSessionSpace: (id: OpSpaceNodeId, sessionId: SessionId) =>\n\t\t\t\tgetNormalizer().normalizeToSessionSpace(id, sessionId),\n\t\t\tget localSessionId() {\n\t\t\t\treturn getNormalizer().localSessionId;\n\t\t\t},\n\t\t};\n\t\tconst simpleTestTree = new SimpleTestTree(source, contextWrapper, expensiveValidation);\n\t\tsetTestTree(source, simpleTestTree);\n\t\treturn simpleTestTree;\n\t}\n\n\tconst context = makeNodeIdContext(source);\n\treturn new SimpleTestTree(context, context, expensiveValidation);\n}\n\n/**\n * Gets an id normalizer from the provided shared-tree. This is\n */\nexport function getIdNormalizerFromSharedTree(sharedTree: SharedTree): NodeIdNormalizer<OpSpaceNodeId> {\n\treturn (\n\t\t((sharedTree as any).idNormalizer as NodeIdNormalizer<OpSpaceNodeId>) ??\n\t\tfail('Failed to find SharedTree normalizer')\n\t);\n}\n\n/**\n * Create a {@link SimpleTestTree} before each test\n */\nexport function refreshTestTree(\n\tidSourceFactory?: (() => IdCompressor) | (() => SharedTree),\n\tfn?: (testTree: TestTree) => void,\n\texpensiveValidation = false\n): TestTree {\n\tconst factory = idSourceFactory ?? (() => new IdCompressor(createSessionId(), reservedIdCount));\n\treturn new RefreshingTestTree(() => {\n\t\treturn setUpTestTree(factory(), expensiveValidation);\n\t}, fn);\n}\n\nexport function makeNodeIdContext(idCompressor?: IdCompressor): NodeIdContext & NodeIdNormalizer<OpSpaceNodeId> {\n\tconst compressor = idCompressor ?? new IdCompressor(createSessionId(), reservedIdCount);\n\treturn getNodeIdContext(compressor);\n}\n\n/**\n * Applies an arbitrary edit to the given SharedTree which leaves the tree in the same state that it was before the edit.\n * This is useful for test scenarios that want to apply edits but don't care what they do.\n */\nexport function applyNoop(tree: SharedTree): Edit<unknown> {\n\treturn tree.applyEdit(...noopEdit(tree.currentView));\n}\n\n/**\n * Creates an arbitrary edit which leaves a tree in the same state that it was before the edit.\n * This is useful for test scenarios that want to create edits but don't care what they do.\n */\nexport function noopEdit(view: TreeView): Change[] {\n\tconst traitLocation = testTrait(view);\n\tconst trait = view.getTrait(traitLocation);\n\t// Set the test trait to the same thing that it already was\n\treturn setTrait(\n\t\ttraitLocation,\n\t\ttrait.map((id) => getChangeNodeFromViewNode(view, id))\n\t);\n}\n\n/** Translate an ID in one context to an ID in another */\nexport function translateId(id: NodeId | NodeData<NodeId>, from: NodeIdConverter, to: NodeIdConverter): NodeId {\n\treturn to.convertToNodeId(from.convertToStableNodeId(getNodeId(id)));\n}\n\nexport function normalizeId(tree: SharedTree, id: NodeId): OpSpaceNodeId {\n\tconst normalizer = getIdNormalizerFromSharedTree(tree);\n\treturn normalizer.normalizeToOpSpace(id);\n}\n\nexport function normalizeIds(tree: SharedTree, ...ids: NodeId[]): OpSpaceNodeId[] {\n\tconst normalizer = getIdNormalizerFromSharedTree(tree);\n\treturn ids.map((id) => normalizer.normalizeToOpSpace(id));\n}\n\nexport function idsAreEqual(treeA: SharedTree, idsA: NodeId[], treeB: SharedTree, idsB: NodeId[]): boolean {\n\tif (idsA.length !== idsB.length) {\n\t\treturn false;\n\t}\n\tconst contextA = getIdNormalizerFromSharedTree(treeA);\n\tconst contextB = getIdNormalizerFromSharedTree(treeB);\n\tfor (let i = 0; i < idsA.length; i++) {\n\t\tif (contextA.normalizeToOpSpace(idsA[i]) !== contextB.normalizeToOpSpace(idsB[i])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nexport function normalizeEdit(\n\ttree: SharedTree,\n\tedit: Edit<ChangeInternal>\n): Edit<ReplaceRecursive<ChangeInternal, NodeId, OpSpaceNodeId>> {\n\tconst context = getIdNormalizerFromSharedTree(tree);\n\treturn convertEditIds(edit, (id) => context.normalizeToOpSpace(id));\n}\n\nexport function stabilizeEdit(\n\ttree: SharedTree,\n\tedit: Edit<ChangeInternal>\n): Edit<ReplaceRecursive<ChangeInternal, NodeId, StableNodeId>> {\n\treturn convertEditIds(edit, (id) => tree.convertToStableNodeId(id));\n}\n\nexport function getEditLogInternal(tree: SharedTree): OrderedEditSet<ChangeInternal> {\n\treturn tree.edits as unknown as OrderedEditSet<ChangeInternal>;\n}\n\n/**\n * Spies on all future ops submitted to `containerRuntimeFactory`. When ops are submitted, they will be `push`ed into the\n * returned array.\n */\nexport function spyOnSubmittedOps<Op extends SharedTreeOp | SharedTreeOp_0_0_2>(\n\tcontainerRuntimeFactory: MockContainerRuntimeFactory\n): Op[] {\n\tconst ops: Op[] = [];\n\tconst originalPush = containerRuntimeFactory.pushMessage.bind(containerRuntimeFactory);\n\tcontainerRuntimeFactory.pushMessage = (message: Partial<ISequencedDocumentMessage>) => {\n\t\tconst { contents } = message;\n\t\tops.push(contents as Op);\n\t\toriginalPush(message);\n\t};\n\treturn ops;\n}\n\n/**\n * Waits for summarization to occur, and returns a version that can be passed into newly loaded containers\n * to ensure they load this summary version. Use the `LoaderHeader.version` header.\n */\nexport async function waitForSummary(mainContainer: IContainer): Promise<string> {\n\tconst { deltaManager } = mainContainer;\n\tconst summaryCollection = new SummaryCollection(deltaManager, new TelemetryNullLogger());\n\tconst ackedSummary = await summaryCollection.waitSummaryAck(deltaManager.lastSequenceNumber);\n\treturn ackedSummary.summaryAck.cont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,YAAY,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,aAAyB;IAC7D,MAAM,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC;IACvC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,YAAY,EAAE,IAAI,mBAAmB,EAAE,CAAC,CAAC;IACzF,MAAM,YAAY,GAAG,MAAM,iBAAiB,CAAC,cAAc,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;IAC7F,OAAO,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACzC,QAA6B,EAC7B,SAAqB,EACrB,MAAqB;IAErB,MAAM,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACpC,MAAM,QAAQ,CAAC,sBAAsB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACjE,MAAM,YAAY,GAAG,MAAM,EAAE,CAAC;IAC9B,MAAM,iBAAiB,GAAG,SAAS,CAAC,4BAA4B,EAAE,CAAC;IACnE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { resolve } from 'path';\nimport { v5 as uuidv5 } from 'uuid';\nimport { expect } from 'chai';\nimport { SummaryCollection, DefaultSummaryConfiguration } from '@fluidframework/container-runtime';\nimport { Container, Loader, waitContainerToCatchUp } from '@fluidframework/container-loader';\nimport { requestFluidObject } from '@fluidframework/runtime-utils';\nimport {\n\tMockContainerRuntimeFactory,\n\tMockFluidDataStoreRuntime,\n\tMockStorage,\n} from '@fluidframework/test-runtime-utils';\nimport {\n\tChannelFactoryRegistry,\n\tITestFluidObject,\n\tTestObjectProvider,\n\tTestContainerRuntimeFactory,\n\tTestFluidObjectFactory,\n\tcreateAndAttachContainer,\n\tITestObjectProvider,\n} from '@fluidframework/test-utils';\nimport { LocalServerTestDriver } from '@fluidframework/test-drivers';\nimport { ITelemetryBaseLogger } from '@fluidframework/common-definitions';\nimport { TelemetryNullLogger } from '@fluidframework/common-utils';\nimport type { IContainer, IHostLoader } from '@fluidframework/container-definitions';\nimport type { IFluidCodeDetails, IFluidHandle, IRequestHeader } from '@fluidframework/core-interfaces';\nimport { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport { IContainerRuntimeBase } from '@fluidframework/runtime-definitions';\nimport { IRequest } from '@fluidframework/core-interfaces';\nimport {\n\tAttributionId,\n\tDetachedSequenceId,\n\tEditId,\n\tNodeId,\n\tOpSpaceNodeId,\n\tSessionId,\n\tStableNodeId,\n} from '../../Identifiers';\nimport { assert, fail, identity, ReplaceRecursive } from '../../Common';\nimport { IdCompressor } from '../../id-compressor';\nimport { createSessionId } from '../../id-compressor/NumericUuid';\nimport { getChangeNodeFromViewNode } from '../../SerializationUtilities';\nimport { initialTree } from '../../InitialTree';\nimport {\n\tChangeInternal,\n\tEdit,\n\tNodeData,\n\tPayload,\n\treservedIdCount,\n\tSharedTreeOp,\n\tSharedTreeOp_0_0_2,\n\tWriteFormat,\n} from '../../persisted-types';\nimport { TraitLocation, TreeView } from '../../TreeView';\nimport { SharedTreeDiagnosticEvent } from '../../EventTypes';\nimport { getNodeId, getNodeIdContext, NodeIdContext, NodeIdConverter, NodeIdNormalizer } from '../../NodeIdUtilities';\nimport { newEdit, setTrait } from '../../EditUtilities';\nimport { SharedTree, SharedTreeFactory } from '../../SharedTree';\nimport { BuildNode, Change, StablePlace } from '../../ChangeTypes';\nimport { convertEditIds } from '../../IdConversion';\nimport { OrderedEditSet } from '../../EditLog';\nimport { buildLeaf, RefreshingTestTree, SimpleTestTree, TestTree } from './TestNode';\n\n/** Objects returned by setUpTestSharedTree */\nexport interface SharedTreeTestingComponents {\n\t/** The MockFluidDataStoreRuntime used to created the SharedTree. */\n\tcomponentRuntime: MockFluidDataStoreRuntime;\n\t/**\n\t * The MockContainerRuntimeFactory created if one was not provided in the options.\n\t * Only connected to the SharedTree if the localMode option was set to false.\n\t * */\n\tcontainerRuntimeFactory: MockContainerRuntimeFactory;\n\t/** The SharedTree created and set up. */\n\ttree: SharedTree;\n}\n\n/** Options used to customize setUpTestSharedTree */\nexport interface SharedTreeTestingOptions {\n\t/**\n\t * Id for the SharedTree to be created.\n\t * If two SharedTrees have the same id and the same containerRuntimeFactory,\n\t * they will collaborate (send edits to each other)\n\t */\n\tid?: string;\n\t/** Node to initialize the SharedTree with. */\n\tinitialTree?: BuildNode;\n\t/** If false, a MockContainerRuntimeFactory connected to the SharedTree will be returned. */\n\tlocalMode?: boolean;\n\t/**\n\t * MockContainerRuntimeFactory to connect the SharedTree to. A new one will not be created if one is provided.\n\t * If localMode is set to true, it will not be connected to the created SharedTree.\n\t * */\n\tcontainerRuntimeFactory?: MockContainerRuntimeFactory;\n\t/** Iff true, do not `fail` on invalid edits */\n\tallowInvalid?: boolean;\n\t/** Iff true, do not `fail` on malformed edits */\n\tallowMalformed?: boolean;\n\t/** Unless set to true, a SharedTree error causes the test to fail */\n\tnoFailOnError?: boolean;\n\t/**\n\t * If not set, full history will be preserved.\n\t */\n\tsummarizeHistory?: boolean;\n\t/**\n\t * If not set, summaries will be written in format 0.1.1.\n\t */\n\twriteFormat?: WriteFormat;\n\t/**\n\t * Optional attribution ID to give to the new tree\n\t */\n\tattributionId?: AttributionId;\n\t/**\n\t * If set, uses the given id as the edit id for tree setup. Only has an effect if initialTree is also set.\n\t */\n\tsetupEditId?: EditId;\n\n\t/**\n\t * Telemetry logger injected into the SharedTree.\n\t */\n\tlogger?: ITelemetryBaseLogger;\n}\n\nexport const testTraitLabel = SimpleTestTree.traitLabel;\nexport function testTrait(view: TreeView): TraitLocation {\n\treturn {\n\t\tlabel: testTraitLabel,\n\t\tparent: view.root,\n\t};\n}\n\n/** Sets up and returns an object of components useful for testing SharedTree. */\nexport function setUpTestSharedTree(\n\toptions: SharedTreeTestingOptions = { localMode: true }\n): SharedTreeTestingComponents {\n\tconst {\n\t\tid,\n\t\tinitialTree,\n\t\tlocalMode,\n\t\tcontainerRuntimeFactory,\n\t\tsetupEditId,\n\t\tsummarizeHistory,\n\t\twriteFormat,\n\t\tattributionId,\n\t} = options;\n\tlet componentRuntime: MockFluidDataStoreRuntime;\n\tif (options.logger) {\n\t\tconst proxyHandler: ProxyHandler<MockFluidDataStoreRuntime> = {\n\t\t\tget: (target, prop, receiver) => {\n\t\t\t\tif (prop === 'logger' && options.logger) {\n\t\t\t\t\treturn options.logger;\n\t\t\t\t}\n\t\t\t\treturn target[prop as keyof MockFluidDataStoreRuntime];\n\t\t\t},\n\t\t};\n\t\tcomponentRuntime = new Proxy(new MockFluidDataStoreRuntime(), proxyHandler);\n\t} else {\n\t\tcomponentRuntime = new MockFluidDataStoreRuntime();\n\t}\n\n\t// Enable expensiveValidation\n\tlet factory: SharedTreeFactory;\n\tif (writeFormat === WriteFormat.v0_0_2) {\n\t\tfactory = SharedTree.getFactory(writeFormat, { summarizeHistory: summarizeHistory ?? true });\n\t} else {\n\t\tconst options = {\n\t\t\tsummarizeHistory: summarizeHistory ?? true ? { uploadEditChunks: true } : false,\n\t\t\tattributionId,\n\t\t};\n\t\tfactory = SharedTree.getFactory(writeFormat ?? WriteFormat.v0_1_1, options);\n\t}\n\tconst tree = factory.create(componentRuntime, id === undefined ? 'testSharedTree' : id);\n\n\tif (options.allowInvalid === undefined || !options.allowInvalid) {\n\t\ttree.on(SharedTreeDiagnosticEvent.DroppedInvalidEdit, () => fail('unexpected invalid edit'));\n\t}\n\n\tif (options.allowMalformed === undefined || !options.allowMalformed) {\n\t\ttree.on(SharedTreeDiagnosticEvent.DroppedMalformedEdit, () => fail('unexpected malformed edit'));\n\t}\n\n\tif (options.noFailOnError === undefined || !options.noFailOnError) {\n\t\t// any errors thrown by a SharedObject event listener will be caught and\n\t\t// reemitted on this event. For testing purposes, rethrow so that it\n\t\t// actually causes the test to fail.\n\t\ttree.on('error', (error) => {\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tconst newContainerRuntimeFactory = containerRuntimeFactory || new MockContainerRuntimeFactory();\n\n\tif (localMode === true) {\n\t\tcomponentRuntime.local = true;\n\t} else {\n\t\tconst containerRuntime = newContainerRuntimeFactory.createContainerRuntime(componentRuntime);\n\t\tconst services = {\n\t\t\tdeltaConnection: containerRuntime.createDeltaConnection(),\n\t\t\tobjectStorage: new MockStorage(undefined),\n\t\t};\n\t\ttree.connect(services);\n\t}\n\n\tif (initialTree !== undefined) {\n\t\tsetTestTree(tree, initialTree, setupEditId);\n\t}\n\n\treturn {\n\t\tcomponentRuntime,\n\t\tcontainerRuntimeFactory: newContainerRuntimeFactory,\n\t\ttree,\n\t};\n}\n\nconst TestDataStoreType = '@fluid-example/test-dataStore';\n\n/** Objects returned by setUpLocalServerTestSharedTree */\nexport interface LocalServerSharedTreeTestingComponents {\n\t/** The testObjectProvider created if one was not set in the options. */\n\ttestObjectProvider: TestObjectProvider;\n\t/** The SharedTree created and set up. */\n\ttree: SharedTree;\n\t/** The container created and set up. */\n\tcontainer: Container;\n\t/** Handles to any blobs uploaded via `blobs` */\n\tuploadedBlobs: IFluidHandle<ArrayBufferLike>[];\n}\n\n/** Options used to customize setUpLocalServerTestSharedTree */\nexport interface LocalServerSharedTreeTestingOptions {\n\t/** Contents of blobs that should be uploaded to the runtime upon creation. Handles to these blobs will be returned. */\n\tblobs?: ArrayBufferLike[];\n\t/** Headers to include on the container load request. */\n\theaders?: IRequestHeader;\n\t/**\n\t * Id for the SharedTree to be created.\n\t * If two SharedTrees have the same id and the same testObjectProvider,\n\t * they will collaborate (send edits to each other)\n\t */\n\tid?: string;\n\t/** Node to initialize the SharedTree with. */\n\tinitialTree?: BuildNode;\n\t/** If set, uses the provider to create the container and create the SharedTree. */\n\ttestObjectProvider?: TestObjectProvider;\n\t/**\n\t * If not set, full history will be preserved.\n\t */\n\tsummarizeHistory?: boolean;\n\t/**\n\t * If not set, summaries will be written in format 0.0.2.\n\t */\n\twriteFormat?: WriteFormat;\n\t/**\n\t * Optional attribution ID to give to the new tree\n\t */\n\tattributionId?: AttributionId;\n\t/**\n\t * If not set, will upload edit chunks when they are full.\n\t */\n\tuploadEditChunks?: boolean;\n\t/**\n\t * If set, uses the given id as the edit id for tree setup. Only has an effect if initialTree is also set.\n\t */\n\tsetupEditId?: EditId;\n\t/**\n\t * If set, will be passed to the container on load\n\t */\n\tpendingLocalState?: string;\n}\n\nconst testObjectProviders: TestObjectProvider[] = [];\nafterEach(() => {\n\tfor (const provider of testObjectProviders) {\n\t\tprovider.reset();\n\t}\n\ttestObjectProviders.length = 0;\n});\n\n/**\n * Sets up and returns an object of components useful for testing SharedTree with a local server.\n * Required for tests that involve the uploadBlob API.\n *\n * Any TestObjectProvider created by this function will be reset after the test completes (via afterEach) hook.\n */\nexport async function setUpLocalServerTestSharedTree(\n\toptions: LocalServerSharedTreeTestingOptions\n): Promise<LocalServerSharedTreeTestingComponents> {\n\tconst {\n\t\tblobs,\n\t\theaders,\n\t\tid,\n\t\tinitialTree,\n\t\ttestObjectProvider,\n\t\tsetupEditId,\n\t\tsummarizeHistory,\n\t\twriteFormat,\n\t\tuploadEditChunks,\n\t\tattributionId,\n\t\tpendingLocalState,\n\t} = options;\n\n\tconst treeId = id ?? 'test';\n\tlet factory: SharedTreeFactory;\n\tif (writeFormat === WriteFormat.v0_0_2) {\n\t\tfactory = SharedTree.getFactory(writeFormat, { summarizeHistory: summarizeHistory ?? true });\n\t} else {\n\t\tconst options = {\n\t\t\tsummarizeHistory: summarizeHistory ?? true ? { uploadEditChunks: uploadEditChunks ?? true } : false,\n\t\t\tattributionId,\n\t\t};\n\t\tfactory = SharedTree.getFactory(writeFormat ?? WriteFormat.v0_1_1, options);\n\t}\n\tconst registry: ChannelFactoryRegistry = [[treeId, factory]];\n\tconst innerRequestHandler = async (request: IRequest, runtime: IContainerRuntimeBase) =>\n\t\truntime.IFluidHandleContext.resolveHandle(request);\n\n\tconst runtimeFactory = () =>\n\t\tnew TestContainerRuntimeFactory(\n\t\t\tTestDataStoreType,\n\t\t\tnew TestFluidObjectFactory(registry),\n\t\t\t{\n\t\t\t\tenableOfflineLoad: true,\n\t\t\t\tsummaryOptions: {\n\t\t\t\t\tsummaryConfigOverrides: {\n\t\t\t\t\t\t...DefaultSummaryConfiguration,\n\t\t\t\t\t\t...{\n\t\t\t\t\t\t\tidleTime: 1000, // Current default idleTime is 15000 which will cause some SharedTree tests to timeout.\n\t\t\t\t\t\t\tmaxTime: 1000 * 12,\n\t\t\t\t\t\t\tinitialSummarizerDelayMs: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t[innerRequestHandler]\n\t\t);\n\n\tconst defaultCodeDetails: IFluidCodeDetails = {\n\t\tpackage: 'defaultTestPackage',\n\t\tconfig: {},\n\t};\n\n\tfunction makeTestLoader(provider: TestObjectProvider): IHostLoader {\n\t\tconst fluidEntryPoint = runtimeFactory();\n\t\treturn provider.createLoader([[defaultCodeDetails, fluidEntryPoint]], {\n\t\t\toptions: { maxClientLeaveWaitTime: 1000 },\n\t\t});\n\t}\n\n\tlet provider: TestObjectProvider;\n\tlet container: Container;\n\n\tif (testObjectProvider !== undefined) {\n\t\tprovider = testObjectProvider;\n\t\tconst driver = new LocalServerTestDriver();\n\t\tconst loader = makeTestLoader(provider);\n\t\t// Once ILoaderOptions is specificable, this should use `provider.loadTestContainer` instead.\n\t\tcontainer = (await loader.resolve(\n\t\t\t{ url: await driver.createContainerUrl(treeId), headers },\n\t\t\tpendingLocalState\n\t\t)) as Container;\n\t\tawait waitContainerToCatchUp(container);\n\t} else {\n\t\tconst driver = new LocalServerTestDriver();\n\t\tprovider = new TestObjectProvider(Loader, driver, runtimeFactory);\n\t\ttestObjectProviders.push(provider);\n\t\t// Once ILoaderOptions is specificable, this should use `provider.makeTestContainer` instead.\n\t\tconst loader = makeTestLoader(provider);\n\t\tcontainer = (await createAndAttachContainer(\n\t\t\tdefaultCodeDetails,\n\t\t\tloader,\n\t\t\tdriver.createCreateNewRequest(treeId)\n\t\t)) as Container;\n\t}\n\n\tconst dataObject = await requestFluidObject<ITestFluidObject>(container, '/');\n\n\tconst uploadedBlobs =\n\t\tblobs === undefined ? [] : await Promise.all(blobs.map(async (blob) => dataObject.context.uploadBlob(blob)));\n\tconst tree = await dataObject.getSharedObject<SharedTree>(treeId);\n\n\tif (initialTree !== undefined && testObjectProvider === undefined) {\n\t\tsetTestTree(tree, initialTree, setupEditId);\n\t}\n\n\treturn { container, tree, testObjectProvider: provider, uploadedBlobs };\n}\n\n/** Sets testTrait to contain `node`. */\nfunction setTestTree(tree: SharedTree, node: BuildNode, overrideId?: EditId): EditId {\n\tconst trait = testTrait(tree.currentView);\n\tif (overrideId === undefined) {\n\t\treturn tree.applyEdit(...setTrait(trait, node)).id;\n\t} else {\n\t\tconst changes = setTrait(trait, node).map((c) => tree.internalizeChange(c));\n\t\treturn tree.applyEditInternal({ changes, id: overrideId }).id;\n\t}\n}\n\n/**\n * Creates a list of edits with stable IDs that can be processed by a SharedTree.\n * @returns the list of created edits\n */\nexport function createStableEdits(\n\tnumberOfEdits: number,\n\tidContext: NodeIdContext = makeNodeIdContext(),\n\tpayload: (i: number) => Payload = identity\n): Edit<ChangeInternal>[] {\n\tif (numberOfEdits === 0) {\n\t\treturn [];\n\t}\n\n\tconst uuidNamespace = '44864298-500e-4cf8-9f44-a249e5b3a286';\n\tconst nodeId = idContext.generateNodeId('ae6b24eb-6fa8-42cc-abd2-48f250b7798f');\n\tconst node = buildLeaf(nodeId);\n\tconst insertEmptyNode = newEdit([\n\t\tChangeInternal.build([node], 0 as DetachedSequenceId),\n\t\tChangeInternal.insert(\n\t\t\t0 as DetachedSequenceId,\n\t\t\tStablePlace.atEndOf({ label: testTraitLabel, parent: idContext.convertToNodeId(initialTree.identifier) })\n\t\t),\n\t]);\n\n\tconst edits: Edit<ChangeInternal>[] = [{ ...insertEmptyNode, id: uuidv5('test', uuidNamespace) as EditId }];\n\n\t// Every subsequent edit is a set payload\n\tfor (let i = 1; i < numberOfEdits; i++) {\n\t\tconst edit = newEdit([ChangeInternal.setPayload(nodeId, payload(i))]);\n\t\tedits.push({ ...edit, id: uuidv5(i.toString(), uuidNamespace) as EditId });\n\t}\n\n\treturn edits;\n}\n\n/** Asserts that changes to SharedTree in editor() function do not cause any observable state change */\nexport function assertNoDelta(tree: SharedTree, editor: () => void) {\n\tconst viewA = tree.currentView;\n\teditor();\n\tconst viewB = tree.currentView;\n\tconst delta = viewA.delta(viewB);\n\texpect(delta).deep.equals({\n\t\tchanged: [],\n\t\tadded: [],\n\t\tremoved: [],\n\t});\n}\n\n/**\n * Used to test error throwing in async functions.\n */\nexport async function asyncFunctionThrowsCorrectly(\n\tasyncFunction: () => Promise<unknown>,\n\texpectedError: string\n): Promise<boolean> {\n\tlet errorMessage: string | undefined;\n\n\ttry {\n\t\tawait asyncFunction();\n\t} catch (error) {\n\t\terrorMessage = (error as Error).message;\n\t}\n\n\treturn errorMessage === expectedError;\n}\n\n/*\n * Returns true if two nodes have equivalent data, otherwise false.\n * Does not compare children or payloads.\n * @param nodes - two or more nodes to compare\n */\nexport function areNodesEquivalent(...nodes: NodeData<unknown>[]): boolean {\n\tif (nodes.length < 2) {\n\t\tfail('Too few nodes to compare');\n\t}\n\n\tfor (let i = 1; i < nodes.length; i++) {\n\t\tif (nodes[i].definition !== nodes[0].definition) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (nodes[i].identifier !== nodes[0].identifier) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n// This accounts for this file being executed after compilation. If many tests want to leverage resources, we should unify\n// resource path logic to a single place.\nexport const testDocumentsPathBase = resolve(__dirname, '../../../src/test/documents/');\n\nexport const versionComparator = (versionA: string, versionB: string): number => {\n\tconst versionASplit = versionA.split('.');\n\tconst versionBSplit = versionB.split('.');\n\n\tassert(\n\t\tversionASplit.length === versionBSplit.length && versionASplit.length === 3,\n\t\t'Version numbers should follow semantic versioning.'\n\t);\n\n\tfor (let i = 0; i < 3; ++i) {\n\t\tconst numberA = parseInt(versionASplit[i], 10);\n\t\tconst numberB = parseInt(versionBSplit[i], 10);\n\n\t\tif (numberA > numberB) {\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (numberA < numberB) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\treturn 0;\n};\n\n/**\n * Create a {@link SimpleTestTree} from the given {@link SharedTree} or {@link IdCompressor}\n */\nexport function setUpTestTree(idSource?: IdCompressor | SharedTree, expensiveValidation = false): TestTree {\n\tconst source = idSource ?? new IdCompressor(createSessionId(), reservedIdCount);\n\tif (source instanceof SharedTree) {\n\t\tassert(source.edits.length === 0, 'tree must be a new SharedTree');\n\t\tconst getNormalizer = () => getIdNormalizerFromSharedTree(source);\n\t\tconst contextWrapper = {\n\t\t\tnormalizeToOpSpace: (id: NodeId) => getNormalizer().normalizeToOpSpace(id),\n\t\t\tnormalizeToSessionSpace: (id: OpSpaceNodeId, sessionId: SessionId) =>\n\t\t\t\tgetNormalizer().normalizeToSessionSpace(id, sessionId),\n\t\t\tget localSessionId() {\n\t\t\t\treturn getNormalizer().localSessionId;\n\t\t\t},\n\t\t};\n\t\tconst simpleTestTree = new SimpleTestTree(source, contextWrapper, expensiveValidation);\n\t\tsetTestTree(source, simpleTestTree);\n\t\treturn simpleTestTree;\n\t}\n\n\tconst context = makeNodeIdContext(source);\n\treturn new SimpleTestTree(context, context, expensiveValidation);\n}\n\n/**\n * Gets an id normalizer from the provided shared-tree. This is\n */\nexport function getIdNormalizerFromSharedTree(sharedTree: SharedTree): NodeIdNormalizer<OpSpaceNodeId> {\n\treturn (\n\t\t((sharedTree as any).idNormalizer as NodeIdNormalizer<OpSpaceNodeId>) ??\n\t\tfail('Failed to find SharedTree normalizer')\n\t);\n}\n\n/**\n * Create a {@link SimpleTestTree} before each test\n */\nexport function refreshTestTree(\n\tidSourceFactory?: (() => IdCompressor) | (() => SharedTree),\n\tfn?: (testTree: TestTree) => void,\n\texpensiveValidation = false\n): TestTree {\n\tconst factory = idSourceFactory ?? (() => new IdCompressor(createSessionId(), reservedIdCount));\n\treturn new RefreshingTestTree(() => {\n\t\treturn setUpTestTree(factory(), expensiveValidation);\n\t}, fn);\n}\n\nexport function makeNodeIdContext(idCompressor?: IdCompressor): NodeIdContext & NodeIdNormalizer<OpSpaceNodeId> {\n\tconst compressor = idCompressor ?? new IdCompressor(createSessionId(), reservedIdCount);\n\treturn getNodeIdContext(compressor);\n}\n\n/**\n * Applies an arbitrary edit to the given SharedTree which leaves the tree in the same state that it was before the edit.\n * This is useful for test scenarios that want to apply edits but don't care what they do.\n */\nexport function applyNoop(tree: SharedTree): Edit<unknown> {\n\treturn tree.applyEdit(...noopEdit(tree.currentView));\n}\n\n/**\n * Creates an arbitrary edit which leaves a tree in the same state that it was before the edit.\n * This is useful for test scenarios that want to create edits but don't care what they do.\n */\nexport function noopEdit(view: TreeView): Change[] {\n\tconst traitLocation = testTrait(view);\n\tconst trait = view.getTrait(traitLocation);\n\t// Set the test trait to the same thing that it already was\n\treturn setTrait(\n\t\ttraitLocation,\n\t\ttrait.map((id) => getChangeNodeFromViewNode(view, id))\n\t);\n}\n\n/** Translate an ID in one context to an ID in another */\nexport function translateId(id: NodeId | NodeData<NodeId>, from: NodeIdConverter, to: NodeIdConverter): NodeId {\n\treturn to.convertToNodeId(from.convertToStableNodeId(getNodeId(id)));\n}\n\nexport function normalizeId(tree: SharedTree, id: NodeId): OpSpaceNodeId {\n\tconst normalizer = getIdNormalizerFromSharedTree(tree);\n\treturn normalizer.normalizeToOpSpace(id);\n}\n\nexport function normalizeIds(tree: SharedTree, ...ids: NodeId[]): OpSpaceNodeId[] {\n\tconst normalizer = getIdNormalizerFromSharedTree(tree);\n\treturn ids.map((id) => normalizer.normalizeToOpSpace(id));\n}\n\nexport function idsAreEqual(treeA: SharedTree, idsA: NodeId[], treeB: SharedTree, idsB: NodeId[]): boolean {\n\tif (idsA.length !== idsB.length) {\n\t\treturn false;\n\t}\n\tconst contextA = getIdNormalizerFromSharedTree(treeA);\n\tconst contextB = getIdNormalizerFromSharedTree(treeB);\n\tfor (let i = 0; i < idsA.length; i++) {\n\t\tif (contextA.normalizeToOpSpace(idsA[i]) !== contextB.normalizeToOpSpace(idsB[i])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nexport function normalizeEdit(\n\ttree: SharedTree,\n\tedit: Edit<ChangeInternal>\n): Edit<ReplaceRecursive<ChangeInternal, NodeId, OpSpaceNodeId>> {\n\tconst context = getIdNormalizerFromSharedTree(tree);\n\treturn convertEditIds(edit, (id) => context.normalizeToOpSpace(id));\n}\n\nexport function stabilizeEdit(\n\ttree: SharedTree,\n\tedit: Edit<ChangeInternal>\n): Edit<ReplaceRecursive<ChangeInternal, NodeId, StableNodeId>> {\n\treturn convertEditIds(edit, (id) => tree.convertToStableNodeId(id));\n}\n\nexport function getEditLogInternal(tree: SharedTree): OrderedEditSet<ChangeInternal> {\n\treturn tree.edits as unknown as OrderedEditSet<ChangeInternal>;\n}\n\n/**\n * Spies on all future ops submitted to `containerRuntimeFactory`. When ops are submitted, they will be `push`ed into the\n * returned array.\n */\nexport function spyOnSubmittedOps<Op extends SharedTreeOp | SharedTreeOp_0_0_2>(\n\tcontainerRuntimeFactory: MockContainerRuntimeFactory\n): Op[] {\n\tconst ops: Op[] = [];\n\tconst originalPush = containerRuntimeFactory.pushMessage.bind(containerRuntimeFactory);\n\tcontainerRuntimeFactory.pushMessage = (message: Partial<ISequencedDocumentMessage>) => {\n\t\tconst { contents } = message;\n\t\tops.push(contents as Op);\n\t\toriginalPush(message);\n\t};\n\treturn ops;\n}\n\n/**\n * Waits for summarization to occur, and returns a version that can be passed into newly loaded containers\n * to ensure they load this summary version. Use the `LoaderHeader.version` header.\n */\nexport async function waitForSummary(mainContainer: IContainer): Promise<string> {\n\tconst { deltaManager } = mainContainer;\n\tconst summaryCollection = new SummaryCollection(deltaManager, new TelemetryNullLogger());\n\tconst ackedSummary = await summaryCollection.waitSummaryAck(deltaManager.lastSequenceNumber);\n\treturn ackedSummary.summaryAck.contents.handle;\n}\n\n/**\n * Runs an action while the given container has been paused\n */\nexport async function withContainerOffline<TReturn>(\n\tprovider: ITestObjectProvider,\n\tcontainer: IContainer,\n\taction: () => TReturn\n): Promise<{ actionReturn: TReturn; pendingLocalState: string }> {\n\tawait provider.ensureSynchronized();\n\tawait provider.opProcessingController.pauseProcessing(container);\n\tconst actionReturn = action();\n\tconst pendingLocalState = container.closeAndGetPendingLocalState();\n\treturn { actionReturn, pendingLocalState };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/tree",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
40
40
|
"@fluidframework/common-utils": "^0.32.1",
|
|
41
|
-
"@fluidframework/container-definitions": "^1.
|
|
42
|
-
"@fluidframework/core-interfaces": "^1.
|
|
43
|
-
"@fluidframework/datastore-definitions": "^1.
|
|
41
|
+
"@fluidframework/container-definitions": "^1.2.0",
|
|
42
|
+
"@fluidframework/core-interfaces": "^1.2.0",
|
|
43
|
+
"@fluidframework/datastore-definitions": "^1.2.0",
|
|
44
44
|
"@fluidframework/protocol-definitions": "^0.1028.2000",
|
|
45
|
-
"@fluidframework/runtime-definitions": "^1.
|
|
46
|
-
"@fluidframework/shared-object-base": "^1.
|
|
47
|
-
"@fluidframework/telemetry-utils": "^1.
|
|
45
|
+
"@fluidframework/runtime-definitions": "^1.2.0",
|
|
46
|
+
"@fluidframework/shared-object-base": "^1.2.0",
|
|
47
|
+
"@fluidframework/telemetry-utils": "^1.2.0",
|
|
48
48
|
"buffer": "^6.0.3",
|
|
49
49
|
"denque": "^1.5.1",
|
|
50
50
|
"lru-cache": "^6.0.0",
|
|
@@ -52,19 +52,19 @@
|
|
|
52
52
|
"uuid": "^8.3.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@fluid-internal/stochastic-test-utils": "^1.
|
|
55
|
+
"@fluid-internal/stochastic-test-utils": "^1.2.0",
|
|
56
56
|
"@fluid-tools/benchmark": "^0.40.0",
|
|
57
57
|
"@fluidframework/build-common": "^0.24.0",
|
|
58
|
-
"@fluidframework/container-loader": "^1.
|
|
59
|
-
"@fluidframework/container-runtime": "^1.
|
|
58
|
+
"@fluidframework/container-loader": "^1.2.0",
|
|
59
|
+
"@fluidframework/container-runtime": "^1.2.0",
|
|
60
60
|
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
61
|
-
"@fluidframework/mocha-test-setup": "^1.
|
|
62
|
-
"@fluidframework/runtime-utils": "^1.
|
|
63
|
-
"@fluidframework/test-driver-definitions": "^1.
|
|
64
|
-
"@fluidframework/test-drivers": "^1.
|
|
65
|
-
"@fluidframework/test-runtime-utils": "^1.
|
|
66
|
-
"@fluidframework/test-utils": "^1.
|
|
67
|
-
"@fluidframework/undo-redo": "^1.
|
|
61
|
+
"@fluidframework/mocha-test-setup": "^1.2.0",
|
|
62
|
+
"@fluidframework/runtime-utils": "^1.2.0",
|
|
63
|
+
"@fluidframework/test-driver-definitions": "^1.2.0",
|
|
64
|
+
"@fluidframework/test-drivers": "^1.2.0",
|
|
65
|
+
"@fluidframework/test-runtime-utils": "^1.2.0",
|
|
66
|
+
"@fluidframework/test-utils": "^1.2.0",
|
|
67
|
+
"@fluidframework/undo-redo": "^1.2.0",
|
|
68
68
|
"@microsoft/api-extractor": "^7.22.2",
|
|
69
69
|
"@rushstack/eslint-config": "^2.5.1",
|
|
70
70
|
"@types/lru-cache": "^5.1.0",
|
package/src/Common.ts
CHANGED
|
@@ -105,16 +105,21 @@ export function fail(message: string = defaultFailMessage, containsPII = false):
|
|
|
105
105
|
* Asserts a value is not undefined, and returns the value.
|
|
106
106
|
* Use when violations are logic errors in the program.
|
|
107
107
|
*
|
|
108
|
+
* @remarks
|
|
108
109
|
* When practical, prefer the pattern `x ?? fail('message')` over `assertNotUndefined(x, 'message')`.
|
|
109
|
-
* Using `?? fail` allows for message formatting without incurring the cost of formatting the message
|
|
110
|
-
*
|
|
111
|
-
*
|
|
110
|
+
* Using `?? fail` allows for message formatting without incurring the cost of formatting the message
|
|
111
|
+
* in the non failing case.
|
|
112
|
+
*
|
|
113
|
+
* Example:
|
|
114
|
+
* ```typescript
|
|
112
115
|
* x ?? fail(`x should exist for ${y}`)
|
|
113
116
|
* ```
|
|
114
|
-
*
|
|
117
|
+
*
|
|
118
|
+
* Additionally the `?? fail` avoids an extra call/stack frame in the non failing case.
|
|
115
119
|
*
|
|
116
120
|
* Another pattern to prefer over `assertNotUndefined(x, 'message')` is `assert(x !== undefined)`.
|
|
117
|
-
* This pattern is preferred because it is more general (same approach works with typeof, instance of,
|
|
121
|
+
* This pattern is preferred because it is more general (same approach works with typeof, instance of,
|
|
122
|
+
* comparison to other values etc.).
|
|
118
123
|
*
|
|
119
124
|
* @param value - Value to assert against is non undefined.
|
|
120
125
|
* @param message - Message to be printed if assertion fails.
|
|
@@ -148,8 +153,9 @@ export function assign<T, K extends keyof never, V>(object: T, property: K, valu
|
|
|
148
153
|
/**
|
|
149
154
|
* Redefine a property to have the given value. This is simply a type-safe wrapper around
|
|
150
155
|
* `Object.defineProperty`, but it is useful for caching public getters on first read.
|
|
156
|
+
*
|
|
151
157
|
* @example
|
|
152
|
-
* ```
|
|
158
|
+
* ```typescript
|
|
153
159
|
* // `randomOnce()` will return a random number, but always the same random number.
|
|
154
160
|
* {
|
|
155
161
|
* get randomOnce(): number {
|
|
@@ -378,7 +384,8 @@ export function setPropertyIfDefined<TDst, P extends keyof TDst>(
|
|
|
378
384
|
}
|
|
379
385
|
|
|
380
386
|
/**
|
|
381
|
-
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
382
389
|
* function (thing: ObjectWithMaybeFoo) {
|
|
383
390
|
* const x: MyActualType = {
|
|
384
391
|
* bar: 3
|
|
@@ -388,7 +395,6 @@ export function setPropertyIfDefined<TDst, P extends keyof TDst>(
|
|
|
388
395
|
* copyPropertyIfDefined(thing, x, 'foo');
|
|
389
396
|
* }
|
|
390
397
|
* ```
|
|
391
|
-
* @returns
|
|
392
398
|
*/
|
|
393
399
|
|
|
394
400
|
function breakOnDifference(): { break: boolean } {
|
package/src/SharedTree.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
OpSpaceNodeId,
|
|
36
36
|
isDetachedSequenceId,
|
|
37
37
|
AttributionId,
|
|
38
|
+
SessionId,
|
|
38
39
|
} from './Identifiers';
|
|
39
40
|
import { initialTree } from './InitialTree';
|
|
40
41
|
import {
|
|
@@ -344,6 +345,18 @@ export type SequencedEditAppliedHandler = (args: SequencedEditAppliedEventArgume
|
|
|
344
345
|
|
|
345
346
|
const sharedTreeTelemetryProperties: ITelemetryLoggerPropertyBags = { all: { isSharedTreeEvent: true } };
|
|
346
347
|
|
|
348
|
+
/**
|
|
349
|
+
* Contains information resulting from processing stashed shared tree ops
|
|
350
|
+
* @public
|
|
351
|
+
*/
|
|
352
|
+
export interface StashedLocalOpMetadata {
|
|
353
|
+
/** A modified version of the edit in an edit op that should be resubmitted rather than the original edit */
|
|
354
|
+
transformedEdit?: Edit<ChangeInternal>;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** The SessionId of the temporary IdCompressor that records stashed ops */
|
|
358
|
+
const stashedSessionId = '8477b8d5-cf6c-4673-8345-8f076a8f9bc6' as SessionId;
|
|
359
|
+
|
|
347
360
|
/**
|
|
348
361
|
* A [distributed tree](../Readme.md).
|
|
349
362
|
* @public
|
|
@@ -416,6 +429,8 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
|
|
|
416
429
|
normalizeToOpSpace: (id) => this.idCompressor.normalizeToOpSpace(id) as OpSpaceNodeId,
|
|
417
430
|
normalizeToSessionSpace: (id, sessionId) => this.idCompressor.normalizeToSessionSpace(id, sessionId) as NodeId,
|
|
418
431
|
};
|
|
432
|
+
/** Temporarily created to apply stashed ops from a previous session */
|
|
433
|
+
private stashedIdCompressor?: IdCompressor | null;
|
|
419
434
|
|
|
420
435
|
// The initial tree's definition isn't included in any op by default but it should still be interned. Including it here ensures that.
|
|
421
436
|
private interner: MutableStringInterner = new MutableStringInterner([initialTree.definition]);
|
|
@@ -1549,20 +1564,21 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
|
|
|
1549
1564
|
*
|
|
1550
1565
|
* @param content - op to apply locally.
|
|
1551
1566
|
*/
|
|
1552
|
-
protected applyStashedOp(op: unknown):
|
|
1567
|
+
protected applyStashedOp(op: unknown): StashedLocalOpMetadata {
|
|
1568
|
+
// In some scenarios, edit ops need to have their edits transformed before application and resubmission. The transformation
|
|
1569
|
+
// occurs in this method, and the result is passed to `resubmitCore` via the return value of this function.
|
|
1553
1570
|
const sharedTreeOp = op as SharedTreeOp | SharedTreeOp_0_0_2;
|
|
1554
1571
|
switch (sharedTreeOp.type) {
|
|
1555
1572
|
case SharedTreeOpType.Edit: {
|
|
1573
|
+
let stashedEdit: Edit<ChangeInternal> | undefined;
|
|
1556
1574
|
switch (this.writeFormat) {
|
|
1557
1575
|
case WriteFormat.v0_0_2:
|
|
1558
1576
|
switch (sharedTreeOp.version) {
|
|
1559
1577
|
case WriteFormat.v0_0_2: {
|
|
1560
|
-
|
|
1561
|
-
this.applyEditLocally(edit, undefined);
|
|
1578
|
+
stashedEdit = this.parseSequencedEdit(sharedTreeOp);
|
|
1562
1579
|
break;
|
|
1563
1580
|
}
|
|
1564
1581
|
case WriteFormat.v0_1_1:
|
|
1565
|
-
// TODO:#74390: Implement
|
|
1566
1582
|
fail('Received stashed op 0.1.1 before upgrade');
|
|
1567
1583
|
default:
|
|
1568
1584
|
fail('Unknown version');
|
|
@@ -1570,30 +1586,92 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
|
|
|
1570
1586
|
break;
|
|
1571
1587
|
case WriteFormat.v0_1_1:
|
|
1572
1588
|
switch (sharedTreeOp.version) {
|
|
1573
|
-
case WriteFormat.v0_0_2:
|
|
1574
|
-
//
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1589
|
+
case WriteFormat.v0_0_2: {
|
|
1590
|
+
// Use the IDs from the stashed ops as overrides for the equivalent new ops
|
|
1591
|
+
stashedEdit = convertEditIds(sharedTreeOp.edit, (id) => this.generateNodeId(id));
|
|
1592
|
+
break;
|
|
1593
|
+
}
|
|
1594
|
+
case WriteFormat.v0_1_1: {
|
|
1595
|
+
assert(this.stashedIdCompressor !== null, 'Stashed op applied after expected window');
|
|
1596
|
+
if (this.stashedIdCompressor === undefined) {
|
|
1597
|
+
// Use a temporary compressor that will help translate the stashed ops
|
|
1598
|
+
this.stashedIdCompressor = IdCompressor.deserialize(
|
|
1599
|
+
this.idCompressor.serialize(false),
|
|
1600
|
+
stashedSessionId,
|
|
1601
|
+
sharedTreeOp.idRange.attributionId
|
|
1602
|
+
);
|
|
1603
|
+
// Once all stashed ops have been applied, clear the temporary state
|
|
1604
|
+
this.runtime.on('connected', () => {
|
|
1605
|
+
this.stashedIdCompressor = null;
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
// Pretend (from the perspective of the temporary compressor) that the stashed ops have been sequenced
|
|
1609
|
+
this.stashedIdCompressor.finalizeCreationRange(sharedTreeOp.idRange);
|
|
1610
|
+
const stashedIdContext = getNodeIdContext(this.stashedIdCompressor);
|
|
1611
|
+
// Use a normalizer to translate all node IDs in the stashed ops
|
|
1612
|
+
const normalizer: NodeIdNormalizer<OpSpaceNodeId> = {
|
|
1613
|
+
localSessionId: this.idCompressor.localSessionId,
|
|
1614
|
+
normalizeToSessionSpace: (id, _sessionId) => {
|
|
1615
|
+
// Interpret the IDs from the stashed ops as stable IDs, and use those as overrides for the equivalent new ops
|
|
1616
|
+
const sessionSpaceId = stashedIdContext.normalizeToSessionSpace(
|
|
1617
|
+
id,
|
|
1618
|
+
sharedTreeOp.idRange.sessionId
|
|
1619
|
+
);
|
|
1620
|
+
return this.generateNodeId(
|
|
1621
|
+
stashedIdContext.convertToStableNodeId(sessionSpaceId)
|
|
1622
|
+
);
|
|
1623
|
+
},
|
|
1624
|
+
normalizeToOpSpace: (id) => this.idNormalizer.normalizeToOpSpace(id),
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1627
|
+
stashedEdit = this.encoder_0_1_1.decodeEditOp(
|
|
1628
|
+
sharedTreeOp,
|
|
1629
|
+
this.encodeSemiSerializedEdit.bind(this),
|
|
1630
|
+
normalizer,
|
|
1631
|
+
this.interner
|
|
1632
|
+
);
|
|
1633
|
+
break;
|
|
1634
|
+
}
|
|
1579
1635
|
default:
|
|
1580
1636
|
fail('Unknown version');
|
|
1581
1637
|
}
|
|
1638
|
+
break;
|
|
1582
1639
|
default:
|
|
1583
1640
|
fail('Unknown version');
|
|
1584
1641
|
}
|
|
1585
|
-
|
|
1642
|
+
this.applyEditLocally(stashedEdit, undefined);
|
|
1643
|
+
return { transformedEdit: stashedEdit };
|
|
1586
1644
|
}
|
|
1587
1645
|
// Handle and update ops are only acknowledged by the client that generated them upon sequencing--no local changes necessary.
|
|
1588
1646
|
case SharedTreeOpType.Handle:
|
|
1589
1647
|
case SharedTreeOpType.Update:
|
|
1590
1648
|
case SharedTreeOpType.NoOp:
|
|
1591
|
-
|
|
1649
|
+
return {};
|
|
1592
1650
|
default:
|
|
1593
1651
|
fail('Unrecognized op');
|
|
1594
1652
|
}
|
|
1595
1653
|
}
|
|
1596
1654
|
|
|
1655
|
+
protected reSubmitCore(op: unknown, localOpMetadata?: StashedLocalOpMetadata): void {
|
|
1656
|
+
const sharedTreeOp = op as SharedTreeOp | SharedTreeOp_0_0_2;
|
|
1657
|
+
switch (sharedTreeOp.type) {
|
|
1658
|
+
case SharedTreeOpType.Edit:
|
|
1659
|
+
if (compareSummaryFormatVersions(sharedTreeOp.version, this.writeFormat) > 0) {
|
|
1660
|
+
fail('Attempted to resubmit op of version newer than current version');
|
|
1661
|
+
} else if (localOpMetadata?.transformedEdit !== undefined) {
|
|
1662
|
+
// Optimization: stashed 0.0.2 ops require no transformation in 0.0.2; don't re-encode
|
|
1663
|
+
if (this.writeFormat !== WriteFormat.v0_0_2 || sharedTreeOp.version !== WriteFormat.v0_0_2) {
|
|
1664
|
+
this.submitEditOp(localOpMetadata.transformedEdit);
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
break;
|
|
1669
|
+
default:
|
|
1670
|
+
break;
|
|
1671
|
+
}
|
|
1672
|
+
super.reSubmitCore(sharedTreeOp, localOpMetadata);
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1597
1675
|
private changeWriteFormat(newFormat: WriteFormat): void {
|
|
1598
1676
|
this.writeFormat = newFormat;
|
|
1599
1677
|
this.emit(SharedTreeDiagnosticEvent.WriteVersionChanged, newFormat);
|
|
@@ -889,16 +889,14 @@ export class IdCompressor {
|
|
|
889
889
|
numericOverride = numericUuidFromStableId(stableOverride);
|
|
890
890
|
const delta = getPositiveDelta(numericOverride, cluster.baseUuid, cluster.capacity - 1);
|
|
891
891
|
if (delta !== undefined) {
|
|
892
|
-
if (isFinalOverride) {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
return this.normalizeToSessionSpace(
|
|
897
|
-
(compressionMapping.clusterBase + delta) as FinalCompressedId
|
|
898
|
-
);
|
|
899
|
-
} else {
|
|
900
|
-
IdCompressor.failWithCollidingOverride(inversionKey);
|
|
892
|
+
if (!isFinalOverride) {
|
|
893
|
+
if (delta >= cluster.count) {
|
|
894
|
+
// TODO:#283: Properly implement unification
|
|
895
|
+
return undefined;
|
|
901
896
|
}
|
|
897
|
+
return this.normalizeToSessionSpace(
|
|
898
|
+
(compressionMapping.clusterBase + delta) as FinalCompressedId
|
|
899
|
+
);
|
|
902
900
|
}
|
|
903
901
|
}
|
|
904
902
|
}
|
|
@@ -987,7 +985,7 @@ export class IdCompressor {
|
|
|
987
985
|
|
|
988
986
|
if (overrideInversionKey !== undefined) {
|
|
989
987
|
const registeredLocal = sessionIdNormalizer.addLocalId();
|
|
990
|
-
assert(registeredLocal === newLocalId, '
|
|
988
|
+
assert(registeredLocal === newLocalId, 'Session ID Normalizer produced unexpected local ID');
|
|
991
989
|
if (eagerFinalId !== undefined) {
|
|
992
990
|
sessionIdNormalizer.addFinalIds(eagerFinalId, eagerFinalId, cluster ?? fail());
|
|
993
991
|
}
|
|
@@ -1000,7 +998,7 @@ export class IdCompressor {
|
|
|
1000
998
|
return eagerFinalId;
|
|
1001
999
|
} else {
|
|
1002
1000
|
const registeredLocal = sessionIdNormalizer.addLocalId();
|
|
1003
|
-
assert(registeredLocal === newLocalId, '
|
|
1001
|
+
assert(registeredLocal === newLocalId, 'Session ID Normalizer produced unexpected local ID');
|
|
1004
1002
|
}
|
|
1005
1003
|
|
|
1006
1004
|
return newLocalId;
|