@fluidframework/datastore 2.0.0-internal.7.3.0 → 2.0.0-internal.8.0.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/api-extractor-lint.json +13 -0
  3. package/api-extractor.json +9 -1
  4. package/api-report/datastore.api.md +7 -10
  5. package/dist/dataStoreRuntime.d.ts +14 -21
  6. package/dist/dataStoreRuntime.d.ts.map +1 -1
  7. package/dist/dataStoreRuntime.js +40 -28
  8. package/dist/dataStoreRuntime.js.map +1 -1
  9. package/dist/datastore-alpha.d.ts +257 -0
  10. package/dist/datastore-beta.d.ts +87 -0
  11. package/dist/datastore-public.d.ts +87 -0
  12. package/dist/datastore-untrimmed.d.ts +324 -0
  13. package/dist/fluidHandle.d.ts +1 -2
  14. package/dist/fluidHandle.d.ts.map +1 -1
  15. package/dist/fluidHandle.js +1 -2
  16. package/dist/fluidHandle.js.map +1 -1
  17. package/dist/localChannelContext.d.ts +2 -2
  18. package/dist/localChannelContext.d.ts.map +1 -1
  19. package/dist/localChannelContext.js +13 -17
  20. package/dist/localChannelContext.js.map +1 -1
  21. package/lib/dataStoreRuntime.d.ts +14 -21
  22. package/lib/dataStoreRuntime.d.ts.map +1 -1
  23. package/lib/dataStoreRuntime.js +40 -28
  24. package/lib/dataStoreRuntime.js.map +1 -1
  25. package/lib/datastore-alpha.d.ts +257 -0
  26. package/lib/datastore-beta.d.ts +87 -0
  27. package/lib/datastore-public.d.ts +87 -0
  28. package/lib/datastore-untrimmed.d.ts +324 -0
  29. package/lib/fluidHandle.d.ts +1 -2
  30. package/lib/fluidHandle.d.ts.map +1 -1
  31. package/lib/fluidHandle.js +1 -2
  32. package/lib/fluidHandle.js.map +1 -1
  33. package/lib/localChannelContext.d.ts +2 -2
  34. package/lib/localChannelContext.d.ts.map +1 -1
  35. package/lib/localChannelContext.js +13 -17
  36. package/lib/localChannelContext.js.map +1 -1
  37. package/package.json +43 -19
  38. package/src/dataStoreRuntime.ts +53 -48
  39. package/src/fluidHandle.ts +1 -2
  40. package/src/localChannelContext.ts +14 -21
@@ -1 +1 @@
1
- {"version":3,"file":"localChannelContext.js","sourceRoot":"","sources":["../src/localChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sDAAsD;AACtD,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,iCAAiC,CAAC;AAU3F,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAEN,6BAA6B,EAE7B,WAAW,EACX,+BAA+B,EAC/B,gBAAgB,EAChB,qBAAqB,GACrB,MAAM,kBAAkB,CAAC;AAG1B;;GAEG;AACH,MAAM,OAAgB,uBAAuB;IAG5C,YACoB,EAAU,EACV,OAA+B,EAC/B,QAAuC,EACzC,QAA2B,EACpC,QAAmB;QAJR,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAwB;QAC/B,aAAQ,GAAR,QAAQ,CAA+B;QACzC,aAAQ,GAAR,QAAQ,CAAmB;QACpC,aAAQ,GAAR,QAAQ,CAAW;QAPpB,oBAAe,GAAG,KAAK,CAAC;QACb,YAAO,GAAgC,EAAE,CAAC;QAQ5D,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACvF,CAAC;IAEM,KAAK,CAAC,UAAU;QACtB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;SACtD;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,IAAW,QA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P,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE;YACnB,OAAO,CAAC,EAAE,CAAC,CAAC;QACb,CAAC,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-internal-modules\nimport cloneDeep from \"lodash/cloneDeep\";\nimport { DataProcessingError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { IChannel, IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { assert, Lazy, LazyPromise } from \"@fluidframework/core-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tChannelServiceEndpoints,\n\tcreateChannelServiceEndpoints,\n\tIChannelContext,\n\tloadChannel,\n\tloadChannelFactoryAndAttributes,\n\tsummarizeChannel,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\n/**\n * Channel context for a locally created channel\n */\nexport abstract class LocalChannelContextBase implements IChannelContext {\n\tprivate globallyVisible = false;\n\tprotected readonly pending: ISequencedDocumentMessage[] = [];\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly runtime: IFluidDataStoreRuntime,\n\t\tprotected readonly services: Lazy<ChannelServiceEndpoints>,\n\t\tprivate readonly channelP: Promise<IChannel>,\n\t\tprivate _channel?: IChannel,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x30f /* Channel context ID cannot contain slashes */);\n\t}\n\n\tpublic async getChannel(): Promise<IChannel> {\n\t\tif (this._channel === undefined) {\n\t\t\treturn this.channelP.then((c) => (this._channel = c));\n\t\t}\n\t\treturn this.channelP;\n\t}\n\n\tpublic get isLoaded(): boolean {\n\t\treturn this._channel !== undefined;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet globallyVisible or loaded\n\t\tif (this.globallyVisible && this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.setConnectionState(connected);\n\t\t}\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d3 /* \"Local channel must be globally visible when processing op\" */,\n\t\t);\n\n\t\t// A local channel may not be loaded in case where we rehydrate the container from a snapshot because of\n\t\t// delay loading. So after the container is attached and some other client joins which start generating\n\t\t// ops for this channel. So not loaded local channel can still receive ops and we store them to process later.\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tlocal === false,\n\t\t\t\t0x189 /* \"Should always be remote because a local dds shouldn't generate ops before loading\" */,\n\t\t\t);\n\t\t\tthis.pending.push(message);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x18a /* \"Channel should be loaded to resubmit ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d4 /* \"Local channel must be globally visible when resubmitting op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2ee /* \"Channel should be loaded to rollback ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2ef /* \"Local channel must be globally visible when rolling back op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp() {\n\t\tthrow new Error(\"no stashed ops on local channel\");\n\t}\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\tconst channel = await this.getChannel();\n\t\treturn summarizeChannelAsync(channel, fullTree, trackState, telemetryContext);\n\t}\n\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummarizeResult {\n\t\tassert(\n\t\t\tthis._channel !== undefined,\n\t\t\t0x18d /* \"Channel should be loaded to take snapshot\" */,\n\t\t);\n\t\treturn summarizeChannel(\n\t\t\tthis._channel,\n\t\t\ttrue /* fullTree */,\n\t\t\tfalse /* trackState */,\n\t\t\ttelemetryContext,\n\t\t);\n\t}\n\n\tpublic makeVisible(): void {\n\t\tif (this.globallyVisible) {\n\t\t\tthrow new Error(\"Channel is already globally visible\");\n\t\t}\n\n\t\tif (this.isLoaded) {\n\t\t\tassert(!!this._channel, 0x192 /* \"Channel should be there if loaded!!\" */);\n\t\t\tthis._channel.connect(this.services.value);\n\t\t}\n\t\tthis.globallyVisible = true;\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document. This should be called only after\n\t * the context has loaded.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tconst channel = await this.getChannel();\n\t\treturn channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected.\n\t\t * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed\n\t\t * value. See - https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t}\n}\n\nexport class RehydratedLocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tconstructor(\n\t\tid: string,\n\t\tregistry: ISharedObjectRegistry,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly snapshotTree: ISnapshotTree,\n\t) {\n\t\tsuper(\n\t\t\tid,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\tconst blobMap: Map<string, ArrayBufferLike> = new Map<string, ArrayBufferLike>();\n\t\t\t\tconst clonedSnapshotTree = cloneDeep(this.snapshotTree);\n\t\t\t\t// 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.\n\t\t\t\t// This is for older snapshot which is generated by loader <=0.47 version which still contains\n\t\t\t\t// the contents within blobs. After a couple of revisions we can remove it.\n\t\t\t\tif (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {\n\t\t\t\t\tthis.sanitizeSnapshot(clonedSnapshotTree);\n\t\t\t\t}\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t\tclonedSnapshotTree,\n\t\t\t\t\tblobMap,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tnew LazyPromise<IChannel>(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { attributes, factory } = await loadChannelFactoryAndAttributes(\n\t\t\t\t\t\tdataStoreContext,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t);\n\t\t\t\t\tconst channel = await loadChannel(\n\t\t\t\t\t\truntime,\n\t\t\t\t\t\tattributes,\n\t\t\t\t\t\tfactory,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t);\n\t\t\t\t\t// Send all pending messages to the channel\n\t\t\t\t\tfor (const message of this.pending) {\n\t\t\t\t\t\tthis.services.value.deltaConnection.process(\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tundefined /* localOpMetadata */,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn channel;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tthrow DataProcessingError.wrapIfUnrecognized(\n\t\t\t\t\t\terr,\n\t\t\t\t\t\t\"rehydratedLocalChannelContextFailedToLoadChannel\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(id);\n\t\t};\n\t}\n\n\tprivate isSnapshotInOldFormatAndCollectBlobs(\n\t\tsnapshotTree: ISnapshotTree,\n\t\tblobMap: Map<string, ArrayBufferLike>,\n\t): boolean {\n\t\tlet sanitize = false;\n\t\tconst blobsContents: { [path: string]: ArrayBufferLike } = (snapshotTree as any)\n\t\t\t.blobsContents;\n\t\tObject.entries(blobsContents).forEach(([key, value]) => {\n\t\t\tblobMap.set(key, value);\n\t\t\tif (snapshotTree.blobs[key] !== undefined) {\n\t\t\t\tsanitize = true;\n\t\t\t}\n\t\t});\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tsanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);\n\t\t}\n\t\treturn sanitize;\n\t}\n\n\tprivate sanitizeSnapshot(snapshotTree: ISnapshotTree) {\n\t\tconst blobMapInitial = new Map(Object.entries(snapshotTree.blobs));\n\t\tfor (const [blobName, blobId] of blobMapInitial.entries()) {\n\t\t\tconst blobValue = blobMapInitial.get(blobId);\n\t\t\tif (blobValue === undefined) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete snapshotTree.blobs[blobName];\n\t\t\t}\n\t\t}\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tthis.sanitizeSnapshot(value);\n\t\t}\n\t}\n}\n\nexport class LocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tpublic readonly channel: IChannel;\n\tconstructor(\n\t\tid: string,\n\t\tregistry: ISharedObjectRegistry,\n\t\ttype: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t) {\n\t\tassert(type !== undefined, 0x209 /* \"Factory Type should be defined\" */);\n\t\tconst factory = registry.get(type);\n\t\tif (factory === undefined) {\n\t\t\tthrow new Error(`Channel Factory ${type} not registered`);\n\t\t}\n\t\tconst channel = factory.create(runtime, id);\n\t\tsuper(\n\t\t\tid,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tPromise.resolve(channel),\n\t\t\tchannel,\n\t\t);\n\t\tthis.channel = channel;\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(id);\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"localChannelContext.js","sourceRoot":"","sources":["../src/localChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sDAAsD;AACtD,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,iCAAiC,CAAC;AAU3F,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGvE,OAAO,EAEN,6BAA6B,EAE7B,WAAW,EACX,+BAA+B,EAC/B,gBAAgB,EAChB,qBAAqB,GACrB,MAAM,kBAAkB,CAAC;AAG1B;;GAEG;AACH,MAAM,OAAgB,uBAAuB;IAG5C,YACoB,EAAU,EACV,OAA+B,EAC/B,QAAuC,EACzC,QAA2B,EACpC,QAAmB;QAJR,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAwB;QAC/B,aAAQ,GAAR,QAAQ,CAA+B;QACzC,aAAQ,GAAR,QAAQ,CAAmB;QACpC,aAAQ,GAAR,QAAQ,CAAW;QAPpB,oBAAe,GAAG,KAAK,CAAC;QACb,YAAO,GAAgC,EAAE,CAAC;QAQ5D,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACvF,CAAC;IAEM,KAAK,CAAC,UAAU;QACtB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;SACtD;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,C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GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;QACnE,KAAK,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,cAAc,CAAC,OAAO,EAAE,EAAE;YAC1D,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC7C,IAAI,SAAS,KAAK,SAAS,EAAE;gBAC5B,gEAAgE;gBAChE,OAAO,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;aACpC;SACD;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YACtD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;SAC7B;IACF,CAAC;CACD;AAED,MAAM,OAAO,mBAAoB,SAAQ,uBAAuB;IAE/D,YACiB,OAAiB,EACjC,OAA+B,EAC/B,gBAAwC,EACxC,cAAuC,EACvC,MAA2B,EAC3B,QAA0D,EAC1D,OAAkC,EAClC,0BAA2F;QAE3F,KAAK,CACJ,OAAO,CAAC,EAAE,EACV,OAAO,EACP,IAAI,IAAI,CAAC,GAAG,EAAE;YACb,OAAO,6BAA6B,CACnC,gBAAgB,CAAC,SAAS,EAC1B,QAAQ,EACR,IAAI,CAAC,OAAO,EACZ,0BAA0B,EAC1B,cAAc,EACd,MAAM,CACN,CAAC;QACH,CAAC,CAAC,EACF,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EACxB,OAAO,CACP,CAAC;QAxBc,YAAO,GAAP,OAAO,CAAU;QAyBjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE;YACnB,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-internal-modules\nimport cloneDeep from \"lodash/cloneDeep\";\nimport { DataProcessingError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { IChannel, IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { assert, Lazy, LazyPromise } from \"@fluidframework/core-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions\";\nimport {\n\tChannelServiceEndpoints,\n\tcreateChannelServiceEndpoints,\n\tIChannelContext,\n\tloadChannel,\n\tloadChannelFactoryAndAttributes,\n\tsummarizeChannel,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\n/**\n * Channel context for a locally created channel\n */\nexport abstract class LocalChannelContextBase implements IChannelContext {\n\tprivate globallyVisible = false;\n\tprotected readonly pending: ISequencedDocumentMessage[] = [];\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly runtime: IFluidDataStoreRuntime,\n\t\tprotected readonly services: Lazy<ChannelServiceEndpoints>,\n\t\tprivate readonly channelP: Promise<IChannel>,\n\t\tprivate _channel?: IChannel,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x30f /* Channel context ID cannot contain slashes */);\n\t}\n\n\tpublic async getChannel(): Promise<IChannel> {\n\t\tif (this._channel === undefined) {\n\t\t\treturn this.channelP.then((c) => (this._channel = c));\n\t\t}\n\t\treturn this.channelP;\n\t}\n\n\tpublic get isLoaded(): boolean {\n\t\treturn this._channel !== undefined;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet globallyVisible or loaded\n\t\tif (this.globallyVisible && this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.setConnectionState(connected);\n\t\t}\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d3 /* \"Local channel must be globally visible when processing op\" */,\n\t\t);\n\n\t\t// A local channel may not be loaded in case where we rehydrate the container from a snapshot because of\n\t\t// delay loading. So after the container is attached and some other client joins which start generating\n\t\t// ops for this channel. So not loaded local channel can still receive ops and we store them to process later.\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tlocal === false,\n\t\t\t\t0x189 /* \"Should always be remote because a local dds shouldn't generate ops before loading\" */,\n\t\t\t);\n\t\t\tthis.pending.push(message);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x18a /* \"Channel should be loaded to resubmit ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d4 /* \"Local channel must be globally visible when resubmitting op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2ee /* \"Channel should be loaded to rollback ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2ef /* \"Local channel must be globally visible when rolling back op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp() {\n\t\tthrow new Error(\"no stashed ops on local channel\");\n\t}\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\tconst channel = await this.getChannel();\n\t\treturn summarizeChannelAsync(channel, fullTree, trackState, telemetryContext);\n\t}\n\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummarizeResult {\n\t\tassert(\n\t\t\tthis._channel !== undefined,\n\t\t\t0x18d /* \"Channel should be loaded to take snapshot\" */,\n\t\t);\n\t\treturn summarizeChannel(\n\t\t\tthis._channel,\n\t\t\ttrue /* fullTree */,\n\t\t\tfalse /* trackState */,\n\t\t\ttelemetryContext,\n\t\t);\n\t}\n\n\tpublic makeVisible(): void {\n\t\tif (this.globallyVisible) {\n\t\t\tthrow new Error(\"Channel is already globally visible\");\n\t\t}\n\n\t\tif (this.isLoaded) {\n\t\t\tassert(!!this._channel, 0x192 /* \"Channel should be there if loaded!!\" */);\n\t\t\tthis._channel.connect(this.services.value);\n\t\t}\n\t\tthis.globallyVisible = true;\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document. This should be called only after\n\t * the context has loaded.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tconst channel = await this.getChannel();\n\t\treturn channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected.\n\t\t * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed\n\t\t * value. See - https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t}\n}\n\nexport class RehydratedLocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tconstructor(\n\t\tid: string,\n\t\tregistry: ISharedObjectRegistry,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly snapshotTree: ISnapshotTree,\n\t) {\n\t\tsuper(\n\t\t\tid,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\tconst blobMap: Map<string, ArrayBufferLike> = new Map<string, ArrayBufferLike>();\n\t\t\t\tconst clonedSnapshotTree = cloneDeep(this.snapshotTree);\n\t\t\t\t// 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.\n\t\t\t\t// This is for older snapshot which is generated by loader <=0.47 version which still contains\n\t\t\t\t// the contents within blobs. After a couple of revisions we can remove it.\n\t\t\t\tif (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {\n\t\t\t\t\tthis.sanitizeSnapshot(clonedSnapshotTree);\n\t\t\t\t}\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t\tclonedSnapshotTree,\n\t\t\t\t\tblobMap,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tnew LazyPromise<IChannel>(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { attributes, factory } = await loadChannelFactoryAndAttributes(\n\t\t\t\t\t\tdataStoreContext,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t);\n\t\t\t\t\tconst channel = await loadChannel(\n\t\t\t\t\t\truntime,\n\t\t\t\t\t\tattributes,\n\t\t\t\t\t\tfactory,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t);\n\t\t\t\t\t// Send all pending messages to the channel\n\t\t\t\t\tfor (const message of this.pending) {\n\t\t\t\t\t\tthis.services.value.deltaConnection.process(\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tundefined /* localOpMetadata */,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn channel;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tthrow DataProcessingError.wrapIfUnrecognized(\n\t\t\t\t\t\terr,\n\t\t\t\t\t\t\"rehydratedLocalChannelContextFailedToLoadChannel\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(id);\n\t\t};\n\t}\n\n\tprivate isSnapshotInOldFormatAndCollectBlobs(\n\t\tsnapshotTree: ISnapshotTreeWithBlobContents,\n\t\tblobMap: Map<string, ArrayBufferLike>,\n\t): boolean {\n\t\tlet sanitize = false;\n\t\tconst blobsContents = snapshotTree.blobsContents;\n\t\tif (blobsContents !== undefined) {\n\t\t\tObject.entries(blobsContents).forEach(([key, value]) => {\n\t\t\t\tblobMap.set(key, value);\n\t\t\t\tif (snapshotTree.blobs[key] !== undefined) {\n\t\t\t\t\tsanitize = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tsanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);\n\t\t}\n\t\treturn sanitize;\n\t}\n\n\tprivate sanitizeSnapshot(snapshotTree: ISnapshotTree) {\n\t\tconst blobMapInitial = new Map(Object.entries(snapshotTree.blobs));\n\t\tfor (const [blobName, blobId] of blobMapInitial.entries()) {\n\t\t\tconst blobValue = blobMapInitial.get(blobId);\n\t\t\tif (blobValue === undefined) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete snapshotTree.blobs[blobName];\n\t\t\t}\n\t\t}\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tthis.sanitizeSnapshot(value);\n\t\t}\n\t}\n}\n\nexport class LocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tconstructor(\n\t\tpublic readonly channel: IChannel,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t) {\n\t\tsuper(\n\t\t\tchannel.id,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tPromise.resolve(channel),\n\t\t\tchannel,\n\t\t);\n\t\tthis.channel = channel;\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(channel.id);\n\t\t};\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/datastore",
3
- "version": "2.0.0-internal.7.3.0",
3
+ "version": "2.0.0-internal.8.0.0",
4
4
  "description": "Fluid data store implementation",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -35,33 +35,35 @@
35
35
  "temp-directory": "nyc/.nyc_output"
36
36
  },
37
37
  "dependencies": {
38
- "@fluid-internal/client-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
39
- "@fluidframework/container-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
40
- "@fluidframework/core-interfaces": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
41
- "@fluidframework/core-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
42
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
43
- "@fluidframework/driver-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
44
- "@fluidframework/driver-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
38
+ "@fluid-internal/client-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
39
+ "@fluidframework/container-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
40
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
41
+ "@fluidframework/core-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
42
+ "@fluidframework/datastore-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
43
+ "@fluidframework/driver-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
44
+ "@fluidframework/driver-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
45
45
  "@fluidframework/protocol-definitions": "^3.0.0",
46
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
47
- "@fluidframework/runtime-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
48
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
46
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
47
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
48
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
49
49
  "lodash": "^4.17.21",
50
50
  "uuid": "^9.0.0"
51
51
  },
52
52
  "devDependencies": {
53
+ "@arethetypeswrong/cli": "^0.13.3",
53
54
  "@fluid-tools/build-cli": "^0.28.0",
54
55
  "@fluidframework/build-common": "^2.0.3",
55
56
  "@fluidframework/build-tools": "^0.28.0",
56
57
  "@fluidframework/datastore-previous": "npm:@fluidframework/datastore@2.0.0-internal.7.2.0",
57
58
  "@fluidframework/eslint-config-fluid": "^3.1.0",
58
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
59
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.3.0 <2.0.0-internal.7.4.0",
59
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
60
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
60
61
  "@microsoft/api-extractor": "^7.38.3",
61
62
  "@types/mocha": "^9.1.1",
62
- "@types/node": "^16.18.38",
63
+ "@types/node": "^18.19.0",
63
64
  "@types/uuid": "^9.0.2",
64
65
  "c8": "^7.7.1",
66
+ "copyfiles": "^2.4.1",
65
67
  "cross-env": "^7.0.3",
66
68
  "eslint": "~8.50.0",
67
69
  "mocha": "^10.2.0",
@@ -72,25 +74,47 @@
72
74
  "rimraf": "^4.4.0",
73
75
  "typescript": "~5.1.6"
74
76
  },
77
+ "fluidBuild": {
78
+ "tasks": {
79
+ "build:docs": {
80
+ "dependsOn": [
81
+ "...",
82
+ "api-extractor:commonjs",
83
+ "api-extractor:esnext"
84
+ ],
85
+ "script": false
86
+ }
87
+ }
88
+ },
75
89
  "typeValidation": {
76
- "broken": {}
90
+ "broken": {
91
+ "ClassDeclaration_FluidDataStoreRuntime": {
92
+ "forwardCompat": false,
93
+ "backCompat": false
94
+ }
95
+ }
77
96
  },
78
97
  "scripts": {
98
+ "api": "fluid-build . --task api",
99
+ "api-extractor:commonjs": "api-extractor run --local",
100
+ "api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
79
101
  "build": "fluid-build . --task build",
80
102
  "build:commonjs": "fluid-build . --task commonjs",
81
103
  "build:compile": "fluid-build . --task compile",
82
- "build:docs": "api-extractor run --local",
104
+ "build:docs": "fluid-build . --task api",
83
105
  "build:esnext": "tsc --project ./tsconfig.esnext.json",
84
106
  "build:test": "tsc --project ./src/test/tsconfig.json",
107
+ "check:are-the-types-wrong": "attw --pack",
108
+ "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
85
109
  "ci:build:docs": "api-extractor run",
86
110
  "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
87
111
  "eslint": "eslint --format stylish src",
88
112
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
89
113
  "format": "npm run prettier:fix",
90
- "lint": "npm run prettier && npm run eslint",
114
+ "lint": "npm run prettier && npm run check:release-tags && npm run eslint",
91
115
  "lint:fix": "npm run prettier:fix && npm run eslint:fix",
92
- "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
93
- "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
116
+ "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
117
+ "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
94
118
  "test": "npm run test:mocha",
95
119
  "test:coverage": "c8 npm test",
96
120
  "test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test --exit -r node_modules/@fluidframework/mocha-test-setup",
@@ -82,7 +82,7 @@ import { RemoteChannelContext } from "./remoteChannelContext";
82
82
  import { FluidObjectHandle } from "./fluidHandle";
83
83
 
84
84
  /**
85
- * @public
85
+ * @alpha
86
86
  */
87
87
  export enum DataStoreMessageType {
88
88
  // Creates a new channel
@@ -91,7 +91,7 @@ export enum DataStoreMessageType {
91
91
  }
92
92
 
93
93
  /**
94
- * @public
94
+ * @alpha
95
95
  */
96
96
  export interface ISharedObjectRegistry {
97
97
  // TODO consider making this async. A consequence is that either the creation of a distributed data type
@@ -101,46 +101,17 @@ export interface ISharedObjectRegistry {
101
101
 
102
102
  /**
103
103
  * Base data store class
104
- *
105
- * @public
104
+ * @alpha
106
105
  */
107
106
  export class FluidDataStoreRuntime
108
107
  extends TypedEventEmitter<IFluidDataStoreRuntimeEvents>
109
108
  implements IFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext
110
109
  {
111
- /**
112
- * @deprecated Instantiate the class using its constructor instead.
113
- *
114
- * Loads the data store runtime
115
- * @param context - The data store context
116
- * @param sharedObjectRegistry - The registry of shared objects used by this data store
117
- * @param existing - If loading from an existing file.
118
- */
119
- public static load(
120
- context: IFluidDataStoreContext,
121
- sharedObjectRegistry: ISharedObjectRegistry,
122
- existing: boolean,
123
- ): FluidDataStoreRuntime {
124
- return new FluidDataStoreRuntime(
125
- context,
126
- sharedObjectRegistry,
127
- existing,
128
- async (dataStoreRuntime) => dataStoreRuntime.entryPoint,
129
- );
130
- }
131
-
132
110
  /**
133
111
  * {@inheritDoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.entryPoint}
134
112
  */
135
113
  public readonly entryPoint: IFluidHandle<FluidObject>;
136
114
 
137
- /**
138
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
139
- */
140
- public get IFluidRouter() {
141
- return this;
142
- }
143
-
144
115
  public get connected(): boolean {
145
116
  return this.dataStoreContext.connected;
146
117
  }
@@ -432,34 +403,70 @@ export class FluidDataStoreRuntime
432
403
  return context.getChannel();
433
404
  }
434
405
 
435
- public createChannel(id: string = uuid(), type: string): IChannel {
406
+ /**
407
+ * Api which allows caller to create the channel first and then add it to the runtime.
408
+ * The channel type should be present in the registry, otherwise the runtime would reject
409
+ * the channel. Also the runtime used to create the channel object should be same to which
410
+ * it is added.
411
+ * @param channel - channel which needs to be added to the runtime.
412
+ */
413
+ public addChannel(channel: IChannel): void {
414
+ const id = channel.id;
436
415
  if (id.includes("/")) {
437
416
  throw new UsageError(`Id cannot contain slashes: ${id}`);
438
417
  }
439
418
 
440
419
  this.verifyNotClosed();
441
420
 
421
+ assert(!this.contexts.has(id), 0x865 /* addChannel() with existing ID */);
422
+
423
+ const type = channel.attributes.type;
424
+ const factory = this.sharedObjectRegistry.get(channel.attributes.type);
425
+ if (factory === undefined) {
426
+ throw new Error(`Channel Factory ${type} not registered`);
427
+ }
428
+
429
+ this.createChannelContext(channel);
430
+ // Channels (DDS) should not be created in summarizer client.
431
+ this.identifyLocalChangeInSummarizer("DDSCreatedInSummarizer", id, type);
432
+ }
433
+
434
+ public createChannel(id: string = uuid(), type: string): IChannel {
435
+ if (id.includes("/")) {
436
+ throw new UsageError(`Id cannot contain slashes: ${id}`);
437
+ }
438
+
439
+ this.verifyNotClosed();
442
440
  assert(!this.contexts.has(id), 0x179 /* "createChannel() with existing ID" */);
443
- this.notBoundedChannelContextSet.add(id);
441
+
442
+ assert(type !== undefined, 0x209 /* "Factory Type should be defined" */);
443
+ const factory = this.sharedObjectRegistry.get(type);
444
+ if (factory === undefined) {
445
+ throw new Error(`Channel Factory ${type} not registered`);
446
+ }
447
+
448
+ const channel = factory.create(this, id);
449
+ this.createChannelContext(channel);
450
+ // Channels (DDS) should not be created in summarizer client.
451
+ this.identifyLocalChangeInSummarizer("DDSCreatedInSummarizer", id, type);
452
+ return channel;
453
+ }
454
+
455
+ private createChannelContext(channel: IChannel) {
456
+ this.notBoundedChannelContextSet.add(channel.id);
444
457
  const context = new LocalChannelContext(
445
- id,
446
- this.sharedObjectRegistry,
447
- type,
458
+ channel,
448
459
  this,
449
460
  this.dataStoreContext,
450
461
  this.dataStoreContext.storage,
451
462
  this.logger,
452
- (content, localOpMetadata) => this.submitChannelOp(id, content, localOpMetadata),
463
+ (content, localOpMetadata) =>
464
+ this.submitChannelOp(channel.id, content, localOpMetadata),
453
465
  (address: string) => this.setChannelDirty(address),
454
466
  (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) =>
455
467
  this.addedGCOutboundReference(srcHandle, outboundHandle),
456
468
  );
457
- this.contexts.set(id, context);
458
-
459
- // Channels (DDS) should not be created in summarizer client.
460
- this.identifyLocalChangeInSummarizer("DDSCreatedInSummarizer", id, type);
461
-
462
- return context.channel;
469
+ this.contexts.set(channel.id, context);
463
470
  }
464
471
 
465
472
  /**
@@ -1128,8 +1135,7 @@ export class FluidDataStoreRuntime
1128
1135
  * Request handler is only called when data store can't resolve request, i.e. for custom requests.
1129
1136
  * @param Base - base class, inherits from FluidDataStoreRuntime
1130
1137
  * @param requestHandler - request handler to mix in
1131
- *
1132
- * @public
1138
+ * @internal
1133
1139
  */
1134
1140
  export const mixinRequestHandler = (
1135
1141
  requestHandler: (request: IRequest, runtime: FluidDataStoreRuntime) => Promise<IResponse>,
@@ -1150,8 +1156,7 @@ export const mixinRequestHandler = (
1150
1156
  * @param handler - handler that returns info about blob to be added to summary.
1151
1157
  * Or undefined not to add anything to summary.
1152
1158
  * @param Base - base class, inherits from FluidDataStoreRuntime
1153
- *
1154
- * @public
1159
+ * @internal
1155
1160
  */
1156
1161
  export const mixinSummaryHandler = (
1157
1162
  handler: (
@@ -8,8 +8,7 @@ import { generateHandleContextPath } from "@fluidframework/runtime-utils";
8
8
 
9
9
  /**
10
10
  * Handle for a shared {@link @fluidframework/core-interfaces#FluidObject}.
11
- *
12
- * @public
11
+ * @internal
13
12
  */
14
13
  export class FluidObjectHandle<T extends FluidObject = FluidObject> implements IFluidHandle {
15
14
  private readonly pendingHandlesToMakeVisible: Set<IFluidHandle> = new Set();
@@ -17,6 +17,7 @@ import {
17
17
  } from "@fluidframework/runtime-definitions";
18
18
  import { assert, Lazy, LazyPromise } from "@fluidframework/core-utils";
19
19
  import { IFluidHandle } from "@fluidframework/core-interfaces";
20
+ import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions";
20
21
  import {
21
22
  ChannelServiceEndpoints,
22
23
  createChannelServiceEndpoints,
@@ -245,18 +246,19 @@ export class RehydratedLocalChannelContext extends LocalChannelContextBase {
245
246
  }
246
247
 
247
248
  private isSnapshotInOldFormatAndCollectBlobs(
248
- snapshotTree: ISnapshotTree,
249
+ snapshotTree: ISnapshotTreeWithBlobContents,
249
250
  blobMap: Map<string, ArrayBufferLike>,
250
251
  ): boolean {
251
252
  let sanitize = false;
252
- const blobsContents: { [path: string]: ArrayBufferLike } = (snapshotTree as any)
253
- .blobsContents;
254
- Object.entries(blobsContents).forEach(([key, value]) => {
255
- blobMap.set(key, value);
256
- if (snapshotTree.blobs[key] !== undefined) {
257
- sanitize = true;
258
- }
259
- });
253
+ const blobsContents = snapshotTree.blobsContents;
254
+ if (blobsContents !== undefined) {
255
+ Object.entries(blobsContents).forEach(([key, value]) => {
256
+ blobMap.set(key, value);
257
+ if (snapshotTree.blobs[key] !== undefined) {
258
+ sanitize = true;
259
+ }
260
+ });
261
+ }
260
262
  for (const value of Object.values(snapshotTree.trees)) {
261
263
  sanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);
262
264
  }
@@ -280,11 +282,8 @@ export class RehydratedLocalChannelContext extends LocalChannelContextBase {
280
282
 
281
283
  export class LocalChannelContext extends LocalChannelContextBase {
282
284
  private readonly dirtyFn: () => void;
283
- public readonly channel: IChannel;
284
285
  constructor(
285
- id: string,
286
- registry: ISharedObjectRegistry,
287
- type: string,
286
+ public readonly channel: IChannel,
288
287
  runtime: IFluidDataStoreRuntime,
289
288
  dataStoreContext: IFluidDataStoreContext,
290
289
  storageService: IDocumentStorageService,
@@ -293,14 +292,8 @@ export class LocalChannelContext extends LocalChannelContextBase {
293
292
  dirtyFn: (address: string) => void,
294
293
  addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,
295
294
  ) {
296
- assert(type !== undefined, 0x209 /* "Factory Type should be defined" */);
297
- const factory = registry.get(type);
298
- if (factory === undefined) {
299
- throw new Error(`Channel Factory ${type} not registered`);
300
- }
301
- const channel = factory.create(runtime, id);
302
295
  super(
303
- id,
296
+ channel.id,
304
297
  runtime,
305
298
  new Lazy(() => {
306
299
  return createChannelServiceEndpoints(
@@ -318,7 +311,7 @@ export class LocalChannelContext extends LocalChannelContextBase {
318
311
  this.channel = channel;
319
312
 
320
313
  this.dirtyFn = () => {
321
- dirtyFn(id);
314
+ dirtyFn(channel.id);
322
315
  };
323
316
  }
324
317
  }