@fluidframework/container-runtime 2.0.0-dev-rc.5.0.0.271045 → 2.0.0-dev-rc.5.0.0.271717

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 (173) hide show
  1. package/container-runtime.test-files.tar +0 -0
  2. package/dist/batchTracker.js +1 -5
  3. package/dist/batchTracker.js.map +1 -1
  4. package/dist/blobManager.js +14 -39
  5. package/dist/blobManager.js.map +1 -1
  6. package/dist/channelCollection.js +10 -23
  7. package/dist/channelCollection.js.map +1 -1
  8. package/dist/connectionTelemetry.js +14 -32
  9. package/dist/connectionTelemetry.js.map +1 -1
  10. package/dist/containerHandleContext.js +0 -4
  11. package/dist/containerHandleContext.js.map +1 -1
  12. package/dist/containerRuntime.js +26 -138
  13. package/dist/containerRuntime.js.map +1 -1
  14. package/dist/dataStore.js +1 -9
  15. package/dist/dataStore.js.map +1 -1
  16. package/dist/dataStoreContext.js +99 -141
  17. package/dist/dataStoreContext.js.map +1 -1
  18. package/dist/dataStoreContexts.js +28 -29
  19. package/dist/dataStoreContexts.js.map +1 -1
  20. package/dist/dataStoreRegistry.js +0 -1
  21. package/dist/dataStoreRegistry.js.map +1 -1
  22. package/dist/deltaManagerProxies.js +28 -33
  23. package/dist/deltaManagerProxies.js.map +1 -1
  24. package/dist/deltaScheduler.js +9 -13
  25. package/dist/deltaScheduler.js.map +1 -1
  26. package/dist/error.js +1 -2
  27. package/dist/error.js.map +1 -1
  28. package/dist/gc/garbageCollection.js +15 -37
  29. package/dist/gc/garbageCollection.js.map +1 -1
  30. package/dist/gc/gcSummaryStateTracker.js +14 -19
  31. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  32. package/dist/gc/gcTelemetry.js +5 -12
  33. package/dist/gc/gcTelemetry.js.map +1 -1
  34. package/dist/gc/gcUnreferencedStateTracker.js +1 -12
  35. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  36. package/dist/opLifecycle/batchManager.js +3 -5
  37. package/dist/opLifecycle/batchManager.js.map +1 -1
  38. package/dist/opLifecycle/opCompressor.js +0 -1
  39. package/dist/opLifecycle/opCompressor.js.map +1 -1
  40. package/dist/opLifecycle/opDecompressor.js +4 -6
  41. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  42. package/dist/opLifecycle/opGroupingManager.js +1 -3
  43. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  44. package/dist/opLifecycle/opSplitter.js +0 -6
  45. package/dist/opLifecycle/opSplitter.js.map +1 -1
  46. package/dist/opLifecycle/outbox.js +10 -15
  47. package/dist/opLifecycle/outbox.js.map +1 -1
  48. package/dist/opLifecycle/remoteMessageProcessor.js +0 -3
  49. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  50. package/dist/packageVersion.d.ts +1 -1
  51. package/dist/packageVersion.js +1 -1
  52. package/dist/packageVersion.js.map +1 -1
  53. package/dist/pendingStateManager.js +14 -20
  54. package/dist/pendingStateManager.js.map +1 -1
  55. package/dist/scheduleManager.js +4 -15
  56. package/dist/scheduleManager.js.map +1 -1
  57. package/dist/storageServiceWithAttachBlobs.js +0 -1
  58. package/dist/storageServiceWithAttachBlobs.js.map +1 -1
  59. package/dist/summary/documentSchema.js +1 -17
  60. package/dist/summary/documentSchema.js.map +1 -1
  61. package/dist/summary/orderedClientElection.js +11 -19
  62. package/dist/summary/orderedClientElection.js.map +1 -1
  63. package/dist/summary/runWhileConnectedCoordinator.js +2 -4
  64. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  65. package/dist/summary/runningSummarizer.js +38 -56
  66. package/dist/summary/runningSummarizer.js.map +1 -1
  67. package/dist/summary/summarizer.js +8 -17
  68. package/dist/summary/summarizer.js.map +1 -1
  69. package/dist/summary/summarizerClientElection.js +7 -18
  70. package/dist/summary/summarizerClientElection.js.map +1 -1
  71. package/dist/summary/summarizerHeuristics.js +25 -30
  72. package/dist/summary/summarizerHeuristics.js.map +1 -1
  73. package/dist/summary/summarizerNode/summarizerNode.js +3 -12
  74. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  75. package/dist/summary/summarizerNode/summarizerNodeUtils.js +0 -2
  76. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  77. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +6 -20
  78. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  79. package/dist/summary/summaryCollection.js +11 -23
  80. package/dist/summary/summaryCollection.js.map +1 -1
  81. package/dist/summary/summaryGenerator.js +5 -12
  82. package/dist/summary/summaryGenerator.js.map +1 -1
  83. package/dist/summary/summaryManager.js +48 -58
  84. package/dist/summary/summaryManager.js.map +1 -1
  85. package/dist/throttler.js +1 -4
  86. package/dist/throttler.js.map +1 -1
  87. package/lib/batchTracker.js +1 -5
  88. package/lib/batchTracker.js.map +1 -1
  89. package/lib/blobManager.js +14 -39
  90. package/lib/blobManager.js.map +1 -1
  91. package/lib/channelCollection.js +10 -23
  92. package/lib/channelCollection.js.map +1 -1
  93. package/lib/connectionTelemetry.js +14 -32
  94. package/lib/connectionTelemetry.js.map +1 -1
  95. package/lib/containerHandleContext.js +0 -4
  96. package/lib/containerHandleContext.js.map +1 -1
  97. package/lib/containerRuntime.js +26 -138
  98. package/lib/containerRuntime.js.map +1 -1
  99. package/lib/dataStore.js +1 -9
  100. package/lib/dataStore.js.map +1 -1
  101. package/lib/dataStoreContext.js +99 -141
  102. package/lib/dataStoreContext.js.map +1 -1
  103. package/lib/dataStoreContexts.js +28 -29
  104. package/lib/dataStoreContexts.js.map +1 -1
  105. package/lib/dataStoreRegistry.js +0 -1
  106. package/lib/dataStoreRegistry.js.map +1 -1
  107. package/lib/deltaManagerProxies.js +28 -33
  108. package/lib/deltaManagerProxies.js.map +1 -1
  109. package/lib/deltaScheduler.js +9 -13
  110. package/lib/deltaScheduler.js.map +1 -1
  111. package/lib/error.js +1 -2
  112. package/lib/error.js.map +1 -1
  113. package/lib/gc/garbageCollection.js +15 -37
  114. package/lib/gc/garbageCollection.js.map +1 -1
  115. package/lib/gc/gcSummaryStateTracker.js +14 -19
  116. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  117. package/lib/gc/gcTelemetry.js +5 -12
  118. package/lib/gc/gcTelemetry.js.map +1 -1
  119. package/lib/gc/gcUnreferencedStateTracker.js +1 -12
  120. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
  121. package/lib/opLifecycle/batchManager.js +3 -5
  122. package/lib/opLifecycle/batchManager.js.map +1 -1
  123. package/lib/opLifecycle/opCompressor.js +0 -1
  124. package/lib/opLifecycle/opCompressor.js.map +1 -1
  125. package/lib/opLifecycle/opDecompressor.js +4 -6
  126. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  127. package/lib/opLifecycle/opGroupingManager.js +1 -3
  128. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  129. package/lib/opLifecycle/opSplitter.js +0 -6
  130. package/lib/opLifecycle/opSplitter.js.map +1 -1
  131. package/lib/opLifecycle/outbox.js +10 -15
  132. package/lib/opLifecycle/outbox.js.map +1 -1
  133. package/lib/opLifecycle/remoteMessageProcessor.js +0 -3
  134. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  135. package/lib/packageVersion.d.ts +1 -1
  136. package/lib/packageVersion.js +1 -1
  137. package/lib/packageVersion.js.map +1 -1
  138. package/lib/pendingStateManager.js +14 -20
  139. package/lib/pendingStateManager.js.map +1 -1
  140. package/lib/scheduleManager.js +4 -15
  141. package/lib/scheduleManager.js.map +1 -1
  142. package/lib/storageServiceWithAttachBlobs.js +0 -1
  143. package/lib/storageServiceWithAttachBlobs.js.map +1 -1
  144. package/lib/summary/documentSchema.js +1 -17
  145. package/lib/summary/documentSchema.js.map +1 -1
  146. package/lib/summary/orderedClientElection.js +11 -19
  147. package/lib/summary/orderedClientElection.js.map +1 -1
  148. package/lib/summary/runWhileConnectedCoordinator.js +2 -4
  149. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  150. package/lib/summary/runningSummarizer.js +38 -56
  151. package/lib/summary/runningSummarizer.js.map +1 -1
  152. package/lib/summary/summarizer.js +8 -17
  153. package/lib/summary/summarizer.js.map +1 -1
  154. package/lib/summary/summarizerClientElection.js +7 -18
  155. package/lib/summary/summarizerClientElection.js.map +1 -1
  156. package/lib/summary/summarizerHeuristics.js +25 -30
  157. package/lib/summary/summarizerHeuristics.js.map +1 -1
  158. package/lib/summary/summarizerNode/summarizerNode.js +3 -12
  159. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  160. package/lib/summary/summarizerNode/summarizerNodeUtils.js +0 -2
  161. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  162. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +6 -20
  163. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  164. package/lib/summary/summaryCollection.js +11 -23
  165. package/lib/summary/summaryCollection.js.map +1 -1
  166. package/lib/summary/summaryGenerator.js +5 -12
  167. package/lib/summary/summaryGenerator.js.map +1 -1
  168. package/lib/summary/summaryManager.js +48 -58
  169. package/lib/summary/summaryManager.js.map +1 -1
  170. package/lib/throttler.js +1 -4
  171. package/lib/throttler.js.map +1 -1
  172. package/package.json +17 -17
  173. package/src/packageVersion.ts +1 -1
package/lib/dataStore.js CHANGED
@@ -24,15 +24,6 @@ var AliasState;
24
24
  AliasState["None"] = "None";
25
25
  })(AliasState || (AliasState = {}));
26
26
  class DataStore {
27
- fluidDataStoreChannel;
28
- internalId;
29
- channelCollection;
30
- logger;
31
- parentContext;
32
- aliasState = AliasState.None;
33
- alias;
34
- pendingAliases;
35
- aliasResult;
36
27
  /**
37
28
  * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.trySetAlias}
38
29
  */
@@ -124,6 +115,7 @@ class DataStore {
124
115
  this.channelCollection = channelCollection;
125
116
  this.logger = logger;
126
117
  this.parentContext = parentContext;
118
+ this.aliasState = AliasState.None;
127
119
  this.pendingAliases = channelCollection.pendingAliases;
128
120
  }
129
121
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ACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tAliasResult,\n\tIDataStore,\n\tIFluidDataStoreChannel,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tTelemetryDataTag,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ChannelCollection } from \"./channelCollection.js\";\nimport { ContainerMessageType } from \"./messageTypes.js\";\n\n/**\n * Interface for an op to be used for assigning an\n * alias to a datastore\n */\nexport interface IDataStoreAliasMessage {\n\t/** The internal id of the datastore */\n\treadonly internalId: string;\n\t/** The alias name to be assigned to the datastore */\n\treadonly alias: string;\n}\n\n/**\n * Type guard that returns true if the given alias message is actually an instance of\n * a class which implements {@link IDataStoreAliasMessage}\n * @param maybeDataStoreAliasMessage - message object to be validated\n * @returns True if the {@link IDataStoreAliasMessage} is fully implemented, false otherwise\n */\nexport const isDataStoreAliasMessage = (\n\tmaybeDataStoreAliasMessage: any,\n): maybeDataStoreAliasMessage is IDataStoreAliasMessage => {\n\treturn (\n\t\ttypeof maybeDataStoreAliasMessage?.internalId === \"string\" &&\n\t\ttypeof maybeDataStoreAliasMessage?.alias === \"string\"\n\t);\n};\n\nexport const channelToDataStore = (\n\tfluidDataStoreChannel: IFluidDataStoreChannel,\n\tinternalId: string,\n\tchannelCollection: ChannelCollection,\n\tlogger: ITelemetryLoggerExt,\n): IDataStore => new DataStore(fluidDataStoreChannel, internalId, channelCollection, logger);\n\nenum AliasState {\n\tAliased = \"Aliased\",\n\tAliasing = \"Aliasing\",\n\tNone = \"None\",\n}\n\nclass DataStore implements IDataStore {\n\tprivate aliasState: AliasState = AliasState.None;\n\tprivate alias: string | undefined;\n\tprivate readonly pendingAliases: Map<string, Promise<AliasResult>>;\n\tprivate aliasResult: Promise<AliasResult> | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.trySetAlias}\n\t */\n\tasync trySetAlias(alias: string): Promise<AliasResult> {\n\t\tif (alias.includes(\"/\")) {\n\t\t\tthrow new UsageError(`The alias cannot contain slashes: '${alias}'`);\n\t\t}\n\n\t\tswitch (this.aliasState) {\n\t\t\t// If we're already aliasing, check if it's for the same value and return\n\t\t\t// the stored promise, otherwise return 'AlreadyAliased'\n\t\t\tcase AliasState.Aliasing:\n\t\t\t\tassert(\n\t\t\t\t\tthis.aliasResult !== undefined,\n\t\t\t\t\t0x316 /* There should be a cached promise of in-progress aliasing */,\n\t\t\t\t);\n\t\t\t\tawait this.aliasResult;\n\t\t\t\treturn this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n\t\t\t// If this datastore is already aliased, return true only if this\n\t\t\t// is a repeated call for the same alias\n\t\t\tcase AliasState.Aliased:\n\t\t\t\treturn this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n\t\t\tcase AliasState.None: {\n\t\t\t\tconst existingAlias = this.pendingAliases.get(alias);\n\t\t\t\tif (existingAlias !== undefined) {\n\t\t\t\t\t// There is already another datastore which will be aliased\n\t\t\t\t\t// to the same name\n\t\t\t\t\treturn \"Conflict\";\n\t\t\t\t}\n\n\t\t\t\t// There is no current or past alias operation for this datastore,\n\t\t\t\t// or for this alias, so it is safe to continue execution\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(this.aliasState);\n\t\t}\n\n\t\tthis.aliasState = AliasState.Aliasing;\n\t\tthis.aliasResult = this.trySetAliasInternal(alias);\n\t\tthis.pendingAliases.set(alias, this.aliasResult);\n\t\treturn this.aliasResult;\n\t}\n\n\tasync trySetAliasInternal(alias: string): Promise<AliasResult> {\n\t\tconst message: IDataStoreAliasMessage = {\n\t\t\tinternalId: this.internalId,\n\t\t\talias,\n\t\t};\n\t\tthis.fluidDataStoreChannel.makeVisibleAndAttachGraph();\n\n\t\tif (this.parentContext.attachState === AttachState.Detached) {\n\t\t\tconst localResult = this.channelCollection.processAliasMessageCore(\n\t\t\t\tthis.internalId,\n\t\t\t\talias,\n\t\t\t);\n\t\t\t// Explicitly lock-out future attempts of aliasing,\n\t\t\t// regardless of result\n\t\t\tthis.aliasState = AliasState.Aliased;\n\t\t\treturn localResult ? \"Success\" : \"Conflict\";\n\t\t}\n\n\t\tconst aliased = await this.ackBasedPromise<boolean>((resolve) => {\n\t\t\tthis.parentContext.submitMessage(ContainerMessageType.Alias, message, resolve);\n\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"AliasingException\",\n\t\t\t\t\t\talias: {\n\t\t\t\t\t\t\tvalue: alias,\n\t\t\t\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinternalId: {\n\t\t\t\t\t\t\tvalue: this.internalId,\n\t\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn false;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tthis.pendingAliases.delete(alias);\n\t\t\t});\n\n\t\tif (!aliased) {\n\t\t\tthis.aliasState = AliasState.None;\n\t\t\tthis.aliasResult = undefined;\n\t\t\treturn \"Conflict\";\n\t\t}\n\n\t\tthis.alias = alias;\n\t\tthis.aliasState = AliasState.Aliased;\n\t\treturn \"Success\";\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.entryPoint}\n\t */\n\tget entryPoint(): IFluidHandleInternal<FluidObject> {\n\t\treturn this.fluidDataStoreChannel.entryPoint;\n\t}\n\n\tconstructor(\n\t\tprivate readonly fluidDataStoreChannel: IFluidDataStoreChannel,\n\t\tprivate readonly internalId: string,\n\t\tprivate readonly channelCollection: ChannelCollection,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly parentContext = channelCollection.parentContext,\n\t) {\n\t\tthis.pendingAliases = channelCollection.pendingAliases;\n\t}\n\n\tprivate async ackBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: any) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"ContainerRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.parentContext.containerRuntime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.parentContext.containerRuntime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\tthis.parentContext.containerRuntime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"dataStore.js","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAGpE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAM9E,OAAO,EAEN,gBAAgB,EAChB,UAAU,GACV,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAazD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACtC,0BAA+B,EACwB,EAAE;IACzD,OAAO,CACN,OAAO,0BAA0B,EAAE,UAAU,KAAK,QAAQ;QAC1D,OAAO,0BAA0B,EAAE,KAAK,K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AGS;QAET,IAAI,oBAAgC,CAAC;QACrC,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzC,oBAAoB,GAAG,GAAG,EAAE,CAC3B,MAAM,CACL,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAC/E,CAAC;YAEH,IAAI,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;gBAClD,oBAAoB,EAAE,CAAC;gBACvB,OAAO;YACR,CAAC;YAED,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACf,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tAliasResult,\n\tIDataStore,\n\tIFluidDataStoreChannel,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tTelemetryDataTag,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ChannelCollection } from \"./channelCollection.js\";\nimport { ContainerMessageType } from \"./messageTypes.js\";\n\n/**\n * Interface for an op to be used for assigning an\n * alias to a datastore\n */\nexport interface IDataStoreAliasMessage {\n\t/** The internal id of the datastore */\n\treadonly internalId: string;\n\t/** The alias name to be assigned to the datastore */\n\treadonly alias: string;\n}\n\n/**\n * Type guard that returns true if the given alias message is actually an instance of\n * a class which implements {@link IDataStoreAliasMessage}\n * @param maybeDataStoreAliasMessage - message object to be validated\n * @returns True if the {@link IDataStoreAliasMessage} is fully implemented, false otherwise\n */\nexport const isDataStoreAliasMessage = (\n\tmaybeDataStoreAliasMessage: any,\n): maybeDataStoreAliasMessage is IDataStoreAliasMessage => {\n\treturn (\n\t\ttypeof maybeDataStoreAliasMessage?.internalId === \"string\" &&\n\t\ttypeof maybeDataStoreAliasMessage?.alias === \"string\"\n\t);\n};\n\nexport const channelToDataStore = (\n\tfluidDataStoreChannel: IFluidDataStoreChannel,\n\tinternalId: string,\n\tchannelCollection: ChannelCollection,\n\tlogger: ITelemetryLoggerExt,\n): IDataStore => new DataStore(fluidDataStoreChannel, internalId, channelCollection, logger);\n\nenum AliasState {\n\tAliased = \"Aliased\",\n\tAliasing = \"Aliasing\",\n\tNone = \"None\",\n}\n\nclass DataStore implements IDataStore {\n\tprivate aliasState: AliasState = AliasState.None;\n\tprivate alias: string | undefined;\n\tprivate readonly pendingAliases: Map<string, Promise<AliasResult>>;\n\tprivate aliasResult: Promise<AliasResult> | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.trySetAlias}\n\t */\n\tasync trySetAlias(alias: string): Promise<AliasResult> {\n\t\tif (alias.includes(\"/\")) {\n\t\t\tthrow new UsageError(`The alias cannot contain slashes: '${alias}'`);\n\t\t}\n\n\t\tswitch (this.aliasState) {\n\t\t\t// If we're already aliasing, check if it's for the same value and return\n\t\t\t// the stored promise, otherwise return 'AlreadyAliased'\n\t\t\tcase AliasState.Aliasing:\n\t\t\t\tassert(\n\t\t\t\t\tthis.aliasResult !== undefined,\n\t\t\t\t\t0x316 /* There should be a cached promise of in-progress aliasing */,\n\t\t\t\t);\n\t\t\t\tawait this.aliasResult;\n\t\t\t\treturn this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n\t\t\t// If this datastore is already aliased, return true only if this\n\t\t\t// is a repeated call for the same alias\n\t\t\tcase AliasState.Aliased:\n\t\t\t\treturn this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n\t\t\tcase AliasState.None: {\n\t\t\t\tconst existingAlias = this.pendingAliases.get(alias);\n\t\t\t\tif (existingAlias !== undefined) {\n\t\t\t\t\t// There is already another datastore which will be aliased\n\t\t\t\t\t// to the same name\n\t\t\t\t\treturn \"Conflict\";\n\t\t\t\t}\n\n\t\t\t\t// There is no current or past alias operation for this datastore,\n\t\t\t\t// or for this alias, so it is safe to continue execution\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(this.aliasState);\n\t\t}\n\n\t\tthis.aliasState = AliasState.Aliasing;\n\t\tthis.aliasResult = this.trySetAliasInternal(alias);\n\t\tthis.pendingAliases.set(alias, this.aliasResult);\n\t\treturn this.aliasResult;\n\t}\n\n\tasync trySetAliasInternal(alias: string): Promise<AliasResult> {\n\t\tconst message: IDataStoreAliasMessage = {\n\t\t\tinternalId: this.internalId,\n\t\t\talias,\n\t\t};\n\t\tthis.fluidDataStoreChannel.makeVisibleAndAttachGraph();\n\n\t\tif (this.parentContext.attachState === AttachState.Detached) {\n\t\t\tconst localResult = this.channelCollection.processAliasMessageCore(\n\t\t\t\tthis.internalId,\n\t\t\t\talias,\n\t\t\t);\n\t\t\t// Explicitly lock-out future attempts of aliasing,\n\t\t\t// regardless of result\n\t\t\tthis.aliasState = AliasState.Aliased;\n\t\t\treturn localResult ? \"Success\" : \"Conflict\";\n\t\t}\n\n\t\tconst aliased = await this.ackBasedPromise<boolean>((resolve) => {\n\t\t\tthis.parentContext.submitMessage(ContainerMessageType.Alias, message, resolve);\n\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"AliasingException\",\n\t\t\t\t\t\talias: {\n\t\t\t\t\t\t\tvalue: alias,\n\t\t\t\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinternalId: {\n\t\t\t\t\t\t\tvalue: this.internalId,\n\t\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn false;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tthis.pendingAliases.delete(alias);\n\t\t\t});\n\n\t\tif (!aliased) {\n\t\t\tthis.aliasState = AliasState.None;\n\t\t\tthis.aliasResult = undefined;\n\t\t\treturn \"Conflict\";\n\t\t}\n\n\t\tthis.alias = alias;\n\t\tthis.aliasState = AliasState.Aliased;\n\t\treturn \"Success\";\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.entryPoint}\n\t */\n\tget entryPoint(): IFluidHandleInternal<FluidObject> {\n\t\treturn this.fluidDataStoreChannel.entryPoint;\n\t}\n\n\tconstructor(\n\t\tprivate readonly fluidDataStoreChannel: IFluidDataStoreChannel,\n\t\tprivate readonly internalId: string,\n\t\tprivate readonly channelCollection: ChannelCollection,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly parentContext = channelCollection.parentContext,\n\t) {\n\t\tthis.pendingAliases = channelCollection.pendingAliases;\n\t}\n\n\tprivate async ackBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: any) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"ContainerRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.parentContext.containerRuntime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.parentContext.containerRuntime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\tthis.parentContext.containerRuntime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n}\n"]}
@@ -28,9 +28,6 @@ export function createAttributesBlob(pkg, isRootDataStore) {
28
28
  * @internal
29
29
  */
30
30
  export class FluidDataStoreContext extends TypedEventEmitter {
31
- existing;
32
- isLocalDataStore;
33
- makeLocallyVisibleFn;
34
31
  get packagePath() {
35
32
  assert(this.pkg !== undefined, 0x139 /* "Undefined package path" */);
36
33
  return this.pkg;
@@ -72,30 +69,18 @@ export class FluidDataStoreContext extends TypedEventEmitter {
72
69
  get idCompressor() {
73
70
  return this.parentContext.idCompressor;
74
71
  }
75
- _disposed = false;
76
72
  get disposed() {
77
73
  return this._disposed;
78
74
  }
79
- /**
80
- * A Tombstoned object has been unreferenced long enough that GC knows it won't be referenced again.
81
- * Tombstoned objects are eventually deleted by GC.
82
- */
83
- _tombstoned = false;
84
75
  get tombstoned() {
85
76
  return this._tombstoned;
86
77
  }
87
- /** If true, throw an error when a tombstone data store is used. */
88
- gcThrowOnTombstoneUsage;
89
- gcTombstoneEnforcementAllowed;
90
- /** If true, this means that this data store context and its children have been removed from the runtime */
91
- deleted = false;
92
78
  get attachState() {
93
79
  return this._attachState;
94
80
  }
95
81
  get IFluidDataStoreRegistry() {
96
82
  return this.registry;
97
83
  }
98
- baseSnapshotSequenceNumber;
99
84
  /**
100
85
  * A datastore is considered as root if it
101
86
  * 1. is root in memory - see isInMemoryRoot
@@ -125,41 +110,23 @@ export class FluidDataStoreContext extends TypedEventEmitter {
125
110
  isInMemoryRoot() {
126
111
  return this._isInMemoryRoot;
127
112
  }
128
- registry;
129
- detachedRuntimeCreation = false;
130
- channel;
131
- loaded = false;
132
- pending = [];
133
- channelP;
134
- _baseSnapshot;
135
- _attachState;
136
- _isInMemoryRoot = false;
137
- summarizerNode;
138
- mc;
139
- thresholdOpsCounter;
140
- static pendingOpsCountThreshold = 1000;
141
- /**
142
- * If the summarizer makes local changes, a telemetry event is logged. This has the potential to be very noisy.
143
- * So, adding a count of how many telemetry events are logged per data store context. This can be
144
- * controlled via feature flags.
145
- */
146
- localChangesTelemetryCount;
147
- // The used routes of this node as per the last GC run. This is used to update the used routes of the channel
148
- // if it realizes after GC is run.
149
- lastUsedRoutes;
150
- id;
151
- _containerRuntime;
152
- parentContext;
153
- storage;
154
- scope;
155
- // Represents the group to which the data store belongs too.
156
- loadingGroupId;
157
- pkg;
158
113
  constructor(props, existing, isLocalDataStore, makeLocallyVisibleFn) {
159
114
  super();
160
115
  this.existing = existing;
161
116
  this.isLocalDataStore = isLocalDataStore;
162
117
  this.makeLocallyVisibleFn = makeLocallyVisibleFn;
118
+ this._disposed = false;
119
+ /**
120
+ * A Tombstoned object has been unreferenced long enough that GC knows it won't be referenced again.
121
+ * Tombstoned objects are eventually deleted by GC.
122
+ */
123
+ this._tombstoned = false;
124
+ /** If true, this means that this data store context and its children have been removed from the runtime */
125
+ this.deleted = false;
126
+ this.detachedRuntimeCreation = false;
127
+ this.loaded = false;
128
+ this.pending = [];
129
+ this._isInMemoryRoot = false;
163
130
  this._containerRuntime = props.parentContext.containerRuntime;
164
131
  this.parentContext = props.parentContext;
165
132
  this.id = props.id;
@@ -663,16 +630,68 @@ export class FluidDataStoreContext extends TypedEventEmitter {
663
630
  return this.parentContext.uploadBlob(blob, signal);
664
631
  }
665
632
  }
633
+ FluidDataStoreContext.pendingOpsCountThreshold = 1000;
666
634
  /** @internal */
667
635
  export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
668
- // Tells whether we need to fetch the snapshot before use. This is to support Data Virtualization.
669
- snapshotFetchRequired;
670
- runtime;
671
- blobContents;
672
636
  constructor(props) {
673
637
  super(props, true /* existing */, false /* isLocalDataStore */, () => {
674
638
  throw new Error("Already attached");
675
639
  });
640
+ this.initialSnapshotDetailsP = new LazyPromise(async () => {
641
+ // Sequence number of the snapshot.
642
+ let sequenceNumber;
643
+ // Check whether we need to fetch the snapshot first to load.
644
+ if (this.snapshotFetchRequired === undefined && this._baseSnapshot?.groupId !== undefined) {
645
+ assert(this.blobContents !== undefined, 0x97a /* Blob contents should be present to evaluate */);
646
+ assert(this._baseSnapshot !== undefined, 0x97b /* snapshotTree should be present to evaluate */);
647
+ this.snapshotFetchRequired = isSnapshotFetchRequiredForLoadingGroupId(this._baseSnapshot, this.blobContents);
648
+ }
649
+ if (this.snapshotFetchRequired) {
650
+ assert(this.loadingGroupId !== undefined, 0x8f5 /* groupId should be present to fetch snapshot */);
651
+ const snapshot = await this.runtime.getSnapshotForLoadingGroupId([this.loadingGroupId], [this.id]);
652
+ this._baseSnapshot = snapshot.snapshotTree;
653
+ sequenceNumber = snapshot.sequenceNumber;
654
+ this.snapshotFetchRequired = false;
655
+ }
656
+ let tree = this.baseSnapshot;
657
+ let isRootDataStore = true;
658
+ if (!!tree && tree.blobs[dataStoreAttributesBlobName] !== undefined) {
659
+ // Need to get through snapshot and use that to populate extraBlobs
660
+ // eslint-disable-next-line import/no-deprecated
661
+ const attributes = await readAndParse(this.storage, tree.blobs[dataStoreAttributesBlobName]);
662
+ let pkgFromSnapshot;
663
+ // Use the snapshotFormatVersion to determine how the pkg is encoded in the snapshot.
664
+ // For snapshotFormatVersion = "0.1" (1) or above, pkg is jsonified, otherwise it is just a string.
665
+ const formatVersion = getAttributesFormatVersion(attributes);
666
+ if (formatVersion < 1) {
667
+ pkgFromSnapshot =
668
+ attributes.pkg.startsWith('["') && attributes.pkg.endsWith('"]')
669
+ ? JSON.parse(attributes.pkg)
670
+ : [attributes.pkg];
671
+ }
672
+ else {
673
+ pkgFromSnapshot = JSON.parse(attributes.pkg);
674
+ }
675
+ this.pkg = pkgFromSnapshot;
676
+ /**
677
+ * If there is no isRootDataStore in the attributes blob, set it to true. This will ensure that
678
+ * data stores in older documents are not garbage collected incorrectly. This may lead to additional
679
+ * roots in the document but they won't break.
680
+ */
681
+ isRootDataStore = attributes.isRootDataStore ?? true;
682
+ if (hasIsolatedChannels(attributes)) {
683
+ tree = tree.trees[channelsTreeName];
684
+ assert(tree !== undefined, 0x1fe /* "isolated channels subtree should exist in remote datastore snapshot" */);
685
+ }
686
+ }
687
+ assert(this.pkg !== undefined, 0x8f6 /* The datastore context package should be defined */);
688
+ return {
689
+ pkg: this.pkg,
690
+ isRootDataStore,
691
+ snapshot: tree,
692
+ sequenceNumber,
693
+ };
694
+ });
676
695
  this.runtime = props.parentContext.containerRuntime;
677
696
  if (isInstanceOfISnapshot(props.snapshot)) {
678
697
  this.blobContents = props.snapshot.blobContents;
@@ -696,61 +715,6 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
696
715
  4. attach op for this data store is processed - setAttachState() is called.
697
716
  */
698
717
  setAttachState(attachState) { }
699
- initialSnapshotDetailsP = new LazyPromise(async () => {
700
- // Sequence number of the snapshot.
701
- let sequenceNumber;
702
- // Check whether we need to fetch the snapshot first to load.
703
- if (this.snapshotFetchRequired === undefined && this._baseSnapshot?.groupId !== undefined) {
704
- assert(this.blobContents !== undefined, 0x97a /* Blob contents should be present to evaluate */);
705
- assert(this._baseSnapshot !== undefined, 0x97b /* snapshotTree should be present to evaluate */);
706
- this.snapshotFetchRequired = isSnapshotFetchRequiredForLoadingGroupId(this._baseSnapshot, this.blobContents);
707
- }
708
- if (this.snapshotFetchRequired) {
709
- assert(this.loadingGroupId !== undefined, 0x8f5 /* groupId should be present to fetch snapshot */);
710
- const snapshot = await this.runtime.getSnapshotForLoadingGroupId([this.loadingGroupId], [this.id]);
711
- this._baseSnapshot = snapshot.snapshotTree;
712
- sequenceNumber = snapshot.sequenceNumber;
713
- this.snapshotFetchRequired = false;
714
- }
715
- let tree = this.baseSnapshot;
716
- let isRootDataStore = true;
717
- if (!!tree && tree.blobs[dataStoreAttributesBlobName] !== undefined) {
718
- // Need to get through snapshot and use that to populate extraBlobs
719
- // eslint-disable-next-line import/no-deprecated
720
- const attributes = await readAndParse(this.storage, tree.blobs[dataStoreAttributesBlobName]);
721
- let pkgFromSnapshot;
722
- // Use the snapshotFormatVersion to determine how the pkg is encoded in the snapshot.
723
- // For snapshotFormatVersion = "0.1" (1) or above, pkg is jsonified, otherwise it is just a string.
724
- const formatVersion = getAttributesFormatVersion(attributes);
725
- if (formatVersion < 1) {
726
- pkgFromSnapshot =
727
- attributes.pkg.startsWith('["') && attributes.pkg.endsWith('"]')
728
- ? JSON.parse(attributes.pkg)
729
- : [attributes.pkg];
730
- }
731
- else {
732
- pkgFromSnapshot = JSON.parse(attributes.pkg);
733
- }
734
- this.pkg = pkgFromSnapshot;
735
- /**
736
- * If there is no isRootDataStore in the attributes blob, set it to true. This will ensure that
737
- * data stores in older documents are not garbage collected incorrectly. This may lead to additional
738
- * roots in the document but they won't break.
739
- */
740
- isRootDataStore = attributes.isRootDataStore ?? true;
741
- if (hasIsolatedChannels(attributes)) {
742
- tree = tree.trees[channelsTreeName];
743
- assert(tree !== undefined, 0x1fe /* "isolated channels subtree should exist in remote datastore snapshot" */);
744
- }
745
- }
746
- assert(this.pkg !== undefined, 0x8f6 /* The datastore context package should be defined */);
747
- return {
748
- pkg: this.pkg,
749
- isRootDataStore,
750
- snapshot: tree,
751
- sequenceNumber,
752
- };
753
- });
754
718
  async getInitialSnapshotDetails() {
755
719
  return this.initialSnapshotDetailsP;
756
720
  }
@@ -772,13 +736,39 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
772
736
  * @internal
773
737
  */
774
738
  export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
775
- snapshotTree;
776
- /**
777
- * @deprecated 0.16 Issue #1635, #3631
778
- */
779
- createProps;
780
739
  constructor(props) {
781
740
  super(props, props.snapshotTree !== undefined /* existing */, true /* isLocalDataStore */, props.makeLocallyVisibleFn);
741
+ this.initialSnapshotDetailsP = new LazyPromise(async () => {
742
+ let snapshot = this.snapshotTree;
743
+ // eslint-disable-next-line import/no-deprecated
744
+ let attributes;
745
+ let isRootDataStore = false;
746
+ if (snapshot !== undefined) {
747
+ // Get the dataStore attributes.
748
+ // Note: storage can be undefined in special case while detached.
749
+ attributes = await getFluidDataStoreAttributes(this.storage, snapshot);
750
+ if (hasIsolatedChannels(attributes)) {
751
+ snapshot = snapshot.trees[channelsTreeName];
752
+ assert(snapshot !== undefined, 0x1ff /* "isolated channels subtree should exist in local datastore snapshot" */);
753
+ }
754
+ if (this.pkg === undefined) {
755
+ this.pkg = JSON.parse(attributes.pkg);
756
+ // If there is no isRootDataStore in the attributes blob, set it to true. This ensures that data
757
+ // stores in older documents are not garbage collected incorrectly. This may lead to additional
758
+ // roots in the document but they won't break.
759
+ if (attributes.isRootDataStore ?? true) {
760
+ isRootDataStore = true;
761
+ this.setInMemoryRoot();
762
+ }
763
+ }
764
+ }
765
+ assert(this.pkg !== undefined, 0x152 /* "pkg should be available in local data store" */);
766
+ return {
767
+ pkg: this.pkg,
768
+ isRootDataStore,
769
+ snapshot,
770
+ };
771
+ });
782
772
  // Summarizer client should not create local data stores.
783
773
  this.identifyLocalChangeInSummarizer("DataStoreCreatedInSummarizer");
784
774
  this.snapshotTree = props.snapshotTree;
@@ -848,37 +838,6 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
848
838
  assert(this.channel !== undefined, "There should be a channel when generating attach GC data");
849
839
  return this.channel.getAttachGCData(telemetryContext);
850
840
  }
851
- initialSnapshotDetailsP = new LazyPromise(async () => {
852
- let snapshot = this.snapshotTree;
853
- // eslint-disable-next-line import/no-deprecated
854
- let attributes;
855
- let isRootDataStore = false;
856
- if (snapshot !== undefined) {
857
- // Get the dataStore attributes.
858
- // Note: storage can be undefined in special case while detached.
859
- attributes = await getFluidDataStoreAttributes(this.storage, snapshot);
860
- if (hasIsolatedChannels(attributes)) {
861
- snapshot = snapshot.trees[channelsTreeName];
862
- assert(snapshot !== undefined, 0x1ff /* "isolated channels subtree should exist in local datastore snapshot" */);
863
- }
864
- if (this.pkg === undefined) {
865
- this.pkg = JSON.parse(attributes.pkg);
866
- // If there is no isRootDataStore in the attributes blob, set it to true. This ensures that data
867
- // stores in older documents are not garbage collected incorrectly. This may lead to additional
868
- // roots in the document but they won't break.
869
- if (attributes.isRootDataStore ?? true) {
870
- isRootDataStore = true;
871
- this.setInMemoryRoot();
872
- }
873
- }
874
- }
875
- assert(this.pkg !== undefined, 0x152 /* "pkg should be available in local data store" */);
876
- return {
877
- pkg: this.pkg,
878
- isRootDataStore,
879
- snapshot,
880
- };
881
- });
882
841
  async getInitialSnapshotDetails() {
883
842
  return this.initialSnapshotDetailsP;
884
843
  }
@@ -924,7 +883,6 @@ export class LocalDetachedFluidDataStoreContext extends LocalFluidDataStoreConte
924
883
  this.detachedRuntimeCreation = true;
925
884
  this.channelToDataStoreFn = props.channelToDataStoreFn;
926
885
  }
927
- channelToDataStoreFn;
928
886
  async attachRuntime(registry, dataStoreChannel) {
929
887
  assert(this.detachedRuntimeCreation, 0x154 /* "runtime creation is already attached" */);
930
888
  this.detachedRuntimeCreation = false;