@fluidframework/container-loader 2.63.0-359962 → 2.70.0-360374

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 (73) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-report/container-loader.legacy.alpha.api.md +28 -0
  3. package/dist/container.d.ts.map +1 -1
  4. package/dist/container.js +10 -6
  5. package/dist/container.js.map +1 -1
  6. package/dist/containerStorageAdapter.d.ts +6 -12
  7. package/dist/containerStorageAdapter.d.ts.map +1 -1
  8. package/dist/containerStorageAdapter.js +8 -13
  9. package/dist/containerStorageAdapter.js.map +1 -1
  10. package/dist/createAndLoadContainerUtils.d.ts +13 -0
  11. package/dist/createAndLoadContainerUtils.d.ts.map +1 -1
  12. package/dist/createAndLoadContainerUtils.js +117 -1
  13. package/dist/createAndLoadContainerUtils.js.map +1 -1
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/legacyAlpha.d.ts +6 -1
  19. package/dist/packageVersion.d.ts +1 -1
  20. package/dist/packageVersion.js +1 -1
  21. package/dist/packageVersion.js.map +1 -1
  22. package/dist/serializedStateManager.d.ts +2 -2
  23. package/dist/serializedStateManager.d.ts.map +1 -1
  24. package/dist/serializedStateManager.js +2 -1
  25. package/dist/serializedStateManager.js.map +1 -1
  26. package/dist/summarizerResultTypes.d.ts +96 -0
  27. package/dist/summarizerResultTypes.d.ts.map +1 -0
  28. package/dist/summarizerResultTypes.js +9 -0
  29. package/dist/summarizerResultTypes.js.map +1 -0
  30. package/dist/utils.d.ts +1 -2
  31. package/dist/utils.d.ts.map +1 -1
  32. package/dist/utils.js +12 -11
  33. package/dist/utils.js.map +1 -1
  34. package/lib/container.d.ts.map +1 -1
  35. package/lib/container.js +11 -7
  36. package/lib/container.js.map +1 -1
  37. package/lib/containerStorageAdapter.d.ts +6 -12
  38. package/lib/containerStorageAdapter.d.ts.map +1 -1
  39. package/lib/containerStorageAdapter.js +9 -14
  40. package/lib/containerStorageAdapter.js.map +1 -1
  41. package/lib/createAndLoadContainerUtils.d.ts +13 -0
  42. package/lib/createAndLoadContainerUtils.d.ts.map +1 -1
  43. package/lib/createAndLoadContainerUtils.js +115 -0
  44. package/lib/createAndLoadContainerUtils.js.map +1 -1
  45. package/lib/index.d.ts +2 -1
  46. package/lib/index.d.ts.map +1 -1
  47. package/lib/index.js +1 -1
  48. package/lib/index.js.map +1 -1
  49. package/lib/legacyAlpha.d.ts +6 -1
  50. package/lib/packageVersion.d.ts +1 -1
  51. package/lib/packageVersion.js +1 -1
  52. package/lib/packageVersion.js.map +1 -1
  53. package/lib/serializedStateManager.d.ts +2 -2
  54. package/lib/serializedStateManager.d.ts.map +1 -1
  55. package/lib/serializedStateManager.js +2 -1
  56. package/lib/serializedStateManager.js.map +1 -1
  57. package/lib/summarizerResultTypes.d.ts +96 -0
  58. package/lib/summarizerResultTypes.d.ts.map +1 -0
  59. package/lib/summarizerResultTypes.js +6 -0
  60. package/lib/summarizerResultTypes.js.map +1 -0
  61. package/lib/utils.d.ts +1 -2
  62. package/lib/utils.d.ts.map +1 -1
  63. package/lib/utils.js +12 -11
  64. package/lib/utils.js.map +1 -1
  65. package/package.json +11 -11
  66. package/src/container.ts +13 -11
  67. package/src/containerStorageAdapter.ts +9 -12
  68. package/src/createAndLoadContainerUtils.ts +174 -0
  69. package/src/index.ts +7 -0
  70. package/src/packageVersion.ts +1 -1
  71. package/src/serializedStateManager.ts +6 -3
  72. package/src/summarizerResultTypes.ts +115 -0
  73. package/src/utils.ts +15 -14
@@ -22,10 +22,6 @@ export interface ISerializableBlobContents {
22
22
  */
23
23
  export declare class ContainerStorageAdapter implements ISerializedStateManagerDocumentStorageService, IContainerStorageService, IDisposable {
24
24
  private readonly logger;
25
- /**
26
- * ArrayBufferLikes or utf8 encoded strings, containing blobs from a snapshot
27
- */
28
- private readonly blobContents;
29
25
  private loadingGroupIdSnapshotsFromPendingState;
30
26
  private readonly addProtocolSummaryIfMissing;
31
27
  private readonly enableSummarizeProtocolTree;
@@ -40,6 +36,10 @@ export declare class ContainerStorageAdapter implements ISerializedStateManagerD
40
36
  * Any loading group id (virtualized) snapshot download from storage will be stored here.
41
37
  */
42
38
  get loadedGroupIdSnapshots(): Record<string, ISnapshot>;
39
+ /**
40
+ * ArrayBufferLikes containing blobs from a snapshot
41
+ */
42
+ private readonly blobContents;
43
43
  /**
44
44
  * An adapter that ensures we're using detachedBlobStorage up until we connect to a real service, and then
45
45
  * after connecting to a real service augments it with retry and combined summary tree enforcement.
@@ -50,17 +50,11 @@ export declare class ContainerStorageAdapter implements ISerializedStateManagerD
50
50
  * upload, and fix it up with a protocol tree if needed
51
51
  * @param enableSummarizeProtocolTree - Enable uploading a protocol summary. Note: preference is given to service policy's "summarizeProtocolTree" before this value.
52
52
  */
53
- constructor(detachedBlobStorage: MemoryDetachedBlobStorage | undefined, logger: ITelemetryLoggerExt,
54
- /**
55
- * ArrayBufferLikes or utf8 encoded strings, containing blobs from a snapshot
56
- */
57
- blobContents: {
58
- [id: string]: ArrayBufferLike | string;
59
- }, loadingGroupIdSnapshotsFromPendingState: Record<string, SerializedSnapshotInfo> | undefined, addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree, enableSummarizeProtocolTree: boolean | undefined);
53
+ constructor(detachedBlobStorage: MemoryDetachedBlobStorage | undefined, logger: ITelemetryLoggerExt, loadingGroupIdSnapshotsFromPendingState: Record<string, SerializedSnapshotInfo> | undefined, addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree, enableSummarizeProtocolTree: boolean | undefined);
60
54
  disposed: boolean;
61
55
  dispose(error?: Error): void;
62
56
  connectToService(service: IDocumentService): void;
63
- loadSnapshotFromSnapshotBlobs(snapshotBlobs: ISerializableBlobContents): void;
57
+ cacheSnapshotBlobs(snapshotBlobs: Map<string, ArrayBuffer>): void;
64
58
  clearPendingState(): void;
65
59
  get policies(): IDocumentStorageServicePolicies | undefined;
66
60
  get maximumCacheDurationMs(): IDocumentStorageServicePolicies["maximumCacheDurationMs"];
@@ -1 +1 @@
1
- {"version":3,"file":"containerStorageAdapter.d.ts","sourceRoot":"","sources":["../src/containerStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,6BAA6B,EAC7B,wBAAwB,EACxB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,KAAK,EACX,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,+BAA+B,EAC/B,SAAS,EACT,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAEpF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGxE,OAAO,KAAK,EACX,6CAA6C,EAC7C,sBAAsB,EACtB,MAAM,6BAA6B,CAAC;AAGrC;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACzC,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,qBAAa,uBACZ,YACC,6CAA6C,EAC7C,wBAAwB,EACxB,WAAW;IAgCX,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,uCAAuC;IAG/C,OAAO,CAAC,QAAQ,CAAC,2BAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,2BAA2B;IAvC7C,OAAO,CAAC,eAAe,CAAiD;IAExE,OAAO,CAAC,sBAAsB,CAAsB;IACpD;;OAEG;IACH,IAAW,qBAAqB,IA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QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GAGnB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAInB,WAAW,CAAC,oBAAoB,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,CAAC;IAwC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAQ9C,WAAW,CAGvB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIT,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAIL,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI5E;;;;;OAKG;IACU,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CAG3E;AA6DD;;GAEG;AACH,wBAAsB,uBAAuB,CAC5C,QAAQ,EAAE,SAAS,GAAG,aAAa,EACnC,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,GAChD,OAAO,CAAC,yBAAyB,CAAC,CAYpC;AAqCD;;GAEG;AACH,wBAAgB,uCAAuC,CACtD,QAAQ,EAAE,6BAA6B,GACrC,yBAAyB,CAI3B"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { bufferToString, stringToBuffer } from "@fluid-internal/client-utils";
5
+ import { bufferToString } from "@fluid-internal/client-utils";
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
7
  import { isInstanceOfISnapshot, UsageError } from "@fluidframework/driver-utils/internal";
8
8
  import { ProtocolTreeStorageService } from "./protocolTreeDocumentStorageService.js";
@@ -35,17 +35,16 @@ export class ContainerStorageAdapter {
35
35
  * upload, and fix it up with a protocol tree if needed
36
36
  * @param enableSummarizeProtocolTree - Enable uploading a protocol summary. Note: preference is given to service policy's "summarizeProtocolTree" before this value.
37
37
  */
38
- constructor(detachedBlobStorage, logger,
39
- /**
40
- * ArrayBufferLikes or utf8 encoded strings, containing blobs from a snapshot
41
- */
42
- blobContents = {}, loadingGroupIdSnapshotsFromPendingState, addProtocolSummaryIfMissing, enableSummarizeProtocolTree) {
38
+ constructor(detachedBlobStorage, logger, loadingGroupIdSnapshotsFromPendingState, addProtocolSummaryIfMissing, enableSummarizeProtocolTree) {
43
39
  this.logger = logger;
44
- this.blobContents = blobContents;
45
40
  this.loadingGroupIdSnapshotsFromPendingState = loadingGroupIdSnapshotsFromPendingState;
46
41
  this.addProtocolSummaryIfMissing = addProtocolSummaryIfMissing;
47
42
  this.enableSummarizeProtocolTree = enableSummarizeProtocolTree;
48
43
  this._loadedGroupIdSnapshots = {};
44
+ /**
45
+ * ArrayBufferLikes containing blobs from a snapshot
46
+ */
47
+ this.blobContents = {};
49
48
  this.disposed = false;
50
49
  this._storageService = new BlobOnlyStorage(detachedBlobStorage, logger);
51
50
  }
@@ -82,9 +81,9 @@ export class ContainerStorageAdapter {
82
81
  return this._summarizeProtocolTree;
83
82
  });
84
83
  }
85
- loadSnapshotFromSnapshotBlobs(snapshotBlobs) {
86
- for (const [id, value] of Object.entries(snapshotBlobs)) {
87
- this.blobContents[id] = value;
84
+ cacheSnapshotBlobs(snapshotBlobs) {
85
+ for (const [id, value] of snapshotBlobs.entries()) {
86
+ this.blobContents[id] ??= value;
88
87
  }
89
88
  }
90
89
  clearPendingState() {
@@ -140,10 +139,6 @@ export class ContainerStorageAdapter {
140
139
  async readBlob(id) {
141
140
  const maybeBlob = this.blobContents[id];
142
141
  if (maybeBlob !== undefined) {
143
- if (typeof maybeBlob === "string") {
144
- const blob = stringToBuffer(maybeBlob, "utf8");
145
- return blob;
146
- }
147
142
  return maybeBlob;
148
143
  }
149
144
  return this._storageService.readBlob(id);
@@ -1 +1 @@
1
- {"version":3,"file":"containerStorageAdapter.js","sourceRoot":"","sources":["../src/containerStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9E,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAc7D,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAI1F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAKvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAU3D;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IASnC;;OAEG;IACH,IAAW,qBAAqB;QAC/B,OAAO,IAAI,CAAC,sBAAsB,KAAK,IAAI,CAAC;IAC7C,CAAC;IAGD;;OAEG;IACH,IAAW,sBAAsB;QAChC,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACrC,CAAC;IAED;;;;;;;;;OASG;IACH,YACC,mBAA0D,EACzC,MAA2B;IAC5C;;OAEG;IACc,eAA2D,EAAE,EACtE,uCAEI,EACK,2BAAwE,EACxE,2BAAgD;QAThD,WAAM,GAAN,MAAM,CAAqB;QAI3B,iBAAY,GAAZ,YAAY,CAAiD;QACtE,4CAAuC,GAAvC,uCAAuC,CAEnC;QACK,gCAA2B,GAA3B,2BAA2B,CAA6C;QACxE,gCAA2B,GAA3B,2BAA2B,CAAqB;QA7B1D,4BAAuB,GAA8B,EAAE,CAAC;QAkChE,aAAQ,GAAY,KAAK,CAAC;QAHzB,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IACzE,CAAC;IAGD,OAAO,CAAC,KAAa;QACpB,IAAI,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC,KA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ACtC,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC9E,oDAAoD;IACpD,KAAK,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport type {\n\tISnapshotTreeWithBlobContents,\n\tIContainerStorageService,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tFetchSource,\n\tIDocumentService,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { isInstanceOfISnapshot, UsageError } from \"@fluidframework/driver-utils/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { MemoryDetachedBlobStorage } from \"./memoryBlobStorage.js\";\nimport { ProtocolTreeStorageService } from \"./protocolTreeDocumentStorageService.js\";\nimport { RetriableDocumentStorageService } from \"./retriableDocumentStorageService.js\";\nimport type {\n\tISerializedStateManagerDocumentStorageService,\n\tSerializedSnapshotInfo,\n} from \"./serializedStateManager.js\";\nimport { convertSnapshotInfoToSnapshot } from \"./utils.js\";\n\n/**\n * Stringified blobs from a summary/snapshot tree.\n * @internal\n */\nexport interface ISerializableBlobContents {\n\t[id: string]: string;\n}\n\n/**\n * This class wraps the actual storage and make sure no wrong apis are called according to\n * container attach state.\n */\nexport class ContainerStorageAdapter\n\timplements\n\t\tISerializedStateManagerDocumentStorageService,\n\t\tIContainerStorageService,\n\t\tIDisposable\n{\n\tprivate _storageService: IDocumentStorageService & Partial<IDisposable>;\n\n\tprivate _summarizeProtocolTree: boolean | undefined;\n\t/**\n\t * Whether the adapter will enforce sending combined summary trees.\n\t */\n\tpublic get summarizeProtocolTree(): boolean {\n\t\treturn this._summarizeProtocolTree === true;\n\t}\n\n\tprivate _loadedGroupIdSnapshots: Record<string, ISnapshot> = {};\n\t/**\n\t * Any loading group id (virtualized) snapshot download from storage will be stored here.\n\t */\n\tpublic get loadedGroupIdSnapshots(): Record<string, ISnapshot> {\n\t\treturn this._loadedGroupIdSnapshots;\n\t}\n\n\t/**\n\t * An adapter that ensures we're using detachedBlobStorage up until we connect to a real service, and then\n\t * after connecting to a real service augments it with retry and combined summary tree enforcement.\n\t * @param detachedBlobStorage - The detached blob storage to use up until we connect to a real service\n\t * @param logger - Telemetry logger\n\t * @param loadingGroupIdSnapshotsFromPendingState - in offline mode, any loading group snapshots we've downloaded from the service that were stored in the pending state\n\t * @param addProtocolSummaryIfMissing - a callback to permit the container to inspect the summary we're about to\n\t * upload, and fix it up with a protocol tree if needed\n\t * @param enableSummarizeProtocolTree - Enable uploading a protocol summary. Note: preference is given to service policy's \"summarizeProtocolTree\" before this value.\n\t */\n\tpublic constructor(\n\t\tdetachedBlobStorage: MemoryDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\t/**\n\t\t * ArrayBufferLikes or utf8 encoded strings, containing blobs from a snapshot\n\t\t */\n\t\tprivate readonly blobContents: { [id: string]: ArrayBufferLike | string } = {},\n\t\tprivate loadingGroupIdSnapshotsFromPendingState:\n\t\t\t| Record<string, SerializedSnapshotInfo>\n\t\t\t| undefined,\n\t\tprivate readonly addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree,\n\t\tprivate readonly enableSummarizeProtocolTree: boolean | undefined,\n\t) {\n\t\tthis._storageService = new BlobOnlyStorage(detachedBlobStorage, logger);\n\t}\n\n\tdisposed: boolean = false;\n\tdispose(error?: Error): void {\n\t\tthis._storageService?.dispose?.(error);\n\t\tthis.disposed = true;\n\t}\n\n\tpublic connectToService(service: IDocumentService): void {\n\t\tif (!(this._storageService instanceof BlobOnlyStorage)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst storageServiceP = service.connectToStorage();\n\t\tconst retriableStorage = (this._storageService = new RetriableDocumentStorageService(\n\t\t\tstorageServiceP,\n\t\t\tthis.logger,\n\t\t));\n\n\t\t// A storage service wrapper which intercept calls to uploadSummaryWithContext and ensure they include\n\t\t// the protocol summary, provided single-commit summary is enabled.\n\t\tthis._storageService = new ProtocolTreeStorageService(\n\t\t\tretriableStorage,\n\t\t\t(...props) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"summarizeProtocolTreeEnabled\" });\n\t\t\t\treturn this.addProtocolSummaryIfMissing(...props);\n\t\t\t},\n\t\t\t// A callback to ensure we fetch the most updated value of service.policies.summarizeProtocolTree, which could be set\n\t\t\t// based on the response received from the service after connection is established.\n\t\t\t() => {\n\t\t\t\t// Determine whether or not container should upload the protocol summary along with the summary.\n\t\t\t\t// This is determined based on what value is set for serve policy's summariProtocolTree value or the enableSummarizeProtocolTree\n\t\t\t\t// retrievd from the loader options or monitoring context config.\n\t\t\t\tconst shouldSummarizeProtocolTree =\n\t\t\t\t\tservice.policies?.summarizeProtocolTree ?? this.enableSummarizeProtocolTree ?? false;\n\n\t\t\t\tif (this._summarizeProtocolTree !== shouldSummarizeProtocolTree) {\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"isSummarizeProtocolTreeEnabled\",\n\t\t\t\t\t\tdetails: { value: shouldSummarizeProtocolTree },\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis._summarizeProtocolTree = shouldSummarizeProtocolTree;\n\t\t\t\treturn this._summarizeProtocolTree;\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic loadSnapshotFromSnapshotBlobs(snapshotBlobs: ISerializableBlobContents): void {\n\t\tfor (const [id, value] of Object.entries(snapshotBlobs)) {\n\t\t\tthis.blobContents[id] = value;\n\t\t}\n\t}\n\n\tpublic clearPendingState(): void {\n\t\tthis.loadingGroupIdSnapshotsFromPendingState = undefined;\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\t// back-compat 0.40 containerRuntime requests policies even in detached container if storage is present\n\t\t// and storage is always present in >=0.41.\n\t\ttry {\n\t\t\treturn this._storageService.policies;\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic get maximumCacheDurationMs(): IDocumentStorageServicePolicies[\"maximumCacheDurationMs\"] {\n\t\treturn this.policies?.maximumCacheDurationMs;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// API called below uses null\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this._storageService.getSnapshotTree(version, scenarioName);\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet snapshot: ISnapshot;\n\t\tif (\n\t\t\tthis.loadingGroupIdSnapshotsFromPendingState !== undefined &&\n\t\t\tsnapshotFetchOptions?.loadingGroupIds !== undefined\n\t\t) {\n\t\t\tconst localSnapshot =\n\t\t\t\tthis.loadingGroupIdSnapshotsFromPendingState[snapshotFetchOptions.loadingGroupIds[0]];\n\t\t\tassert(localSnapshot !== undefined, 0x970 /* Local snapshot must be present */);\n\t\t\tsnapshot = convertSnapshotInfoToSnapshot(localSnapshot);\n\t\t} else {\n\t\t\tif (this._storageService.getSnapshot === undefined) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"getSnapshot api should exist in internal storage in ContainerStorageAdapter\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tsnapshot = await this._storageService.getSnapshot(snapshotFetchOptions);\n\t\t}\n\n\t\t// Track the latest snapshot for each loading group id\n\t\tconst loadingGroupIds = snapshotFetchOptions?.loadingGroupIds;\n\t\tassert(\n\t\t\tsnapshot.sequenceNumber !== undefined,\n\t\t\t0x971 /* Snapshot must have sequence number */,\n\t\t);\n\t\tif (loadingGroupIds !== undefined) {\n\t\t\tfor (const loadingGroupId of loadingGroupIds) {\n\t\t\t\t// Do we actually want to update the stored snapshot?\n\t\t\t\t// What if the incoming snapshot is way newer than the stored snapshot?\n\t\t\t\t// We only want to update the stored snapshot if the incoming snapshot is newer (stored sequence number < incoming sequence number)\n\t\t\t\tconst storedSeqNum =\n\t\t\t\t\tthis._loadedGroupIdSnapshots[loadingGroupId]?.sequenceNumber ?? -1;\n\t\t\t\tif (storedSeqNum < snapshot.sequenceNumber) {\n\t\t\t\t\tthis._loadedGroupIdSnapshots[loadingGroupId] = snapshot;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn snapshot;\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst maybeBlob = this.blobContents[id];\n\t\tif (maybeBlob !== undefined) {\n\t\t\tif (typeof maybeBlob === \"string\") {\n\t\t\t\tconst blob = stringToBuffer(maybeBlob, \"utf8\");\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t\treturn maybeBlob;\n\t\t}\n\t\treturn this._storageService.readBlob(id);\n\t}\n\n\tpublic async getVersions(\n\t\t// API used below uses null\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this._storageService.getVersions(versionId, count, scenarioName, fetchSource);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this._storageService.uploadSummaryWithContext(summary, context);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this._storageService.createBlob(file);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.downloadSummary}.\n\t *\n\t * @deprecated - This API is deprecated and will be removed in a future release. No replacement is planned as\n\t * it is unused in the Runtime and below layers.\n\t */\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this._storageService.downloadSummary(handle);\n\t}\n}\n\n/**\n * Storage which only supports createBlob() and readBlob(). This is used with IDetachedBlobStorage to support\n * blobs in detached containers.\n */\nclass BlobOnlyStorage implements IDocumentStorageService {\n\tconstructor(\n\t\tprivate readonly detachedStorage: MemoryDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tpublic async createBlob(content: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.verifyStorage().createBlob(content);\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.verifyStorage().readBlob(blobId);\n\t}\n\n\tprivate verifyStorage(): MemoryDetachedBlobStorage {\n\t\tif (this.detachedStorage === undefined) {\n\t\t\tthrow new UsageError(\"Real storage calls not allowed in Unattached container\");\n\t\t}\n\t\treturn this.detachedStorage;\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.notCalled();\n\t}\n\n\t/* eslint-disable @typescript-eslint/unbound-method */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic getSnapshotTree: () => Promise<ISnapshotTree | null> = this.notCalled;\n\tpublic getSnapshot: () => Promise<ISnapshot> = this.notCalled;\n\tpublic getVersions: () => Promise<IVersion[]> = this.notCalled;\n\tpublic write: () => Promise<IVersion> = this.notCalled;\n\tpublic uploadSummaryWithContext: () => Promise<string> = this.notCalled;\n\tpublic downloadSummary: () => Promise<ISummaryTree> = this.notCalled;\n\t/* eslint-enable @typescript-eslint/unbound-method */\n\n\tprivate notCalled(): never {\n\t\tthis.verifyStorage();\n\t\ttry {\n\t\t\t// some browsers may not populate stack unless exception is thrown\n\t\t\tthrow new Error(\"BlobOnlyStorage not implemented method used\");\n\t\t} catch (error) {\n\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"BlobOnlyStorageWrongCall\" }, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\n// runtime will write a tree to the summary containing \"attachment\" type entries\n// which reference attachment blobs by ID, along with a blob containing the blob redirect table.\n// However, some drivers do not support the \"attachment\" type and will convert them to \"blob\" type\n// entries. We want to avoid saving these to reduce the size of stashed change blobs, but we\n// need to make sure the blob redirect table is saved.\nconst blobsTreeName = \".blobs\";\nconst redirectTableBlobName = \".redirectTable\";\n\n/**\n * Get blob contents of a snapshot tree from storage (or, ideally, cache)\n */\nexport async function getBlobContentsFromTree(\n\tsnapshot: ISnapshot | ISnapshotTree,\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n): Promise<ISerializableBlobContents> {\n\tconst blobs = {};\n\tif (isInstanceOfISnapshot(snapshot)) {\n\t\tconst blobContents = snapshot.blobContents;\n\t\tfor (const [id, content] of blobContents.entries()) {\n\t\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\t\tblobs[id] = bufferToString(content, \"utf8\");\n\t\t}\n\t} else {\n\t\tawait getBlobContentsFromTreeCore(snapshot, blobs, storage);\n\t}\n\treturn blobs;\n}\n\nasync function getBlobContentsFromTreeCore(\n\ttree: ISnapshotTree,\n\tblobs: ISerializableBlobContents,\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n\troot = true,\n): Promise<unknown[]> {\n\tconst treePs: Promise<unknown>[] = [];\n\tfor (const [key, subTree] of Object.entries(tree.trees)) {\n\t\tif (root && key === blobsTreeName) {\n\t\t\ttreePs.push(getBlobManagerTreeFromTree(subTree, blobs, storage));\n\t\t} else {\n\t\t\ttreePs.push(getBlobContentsFromTreeCore(subTree, blobs, storage, false));\n\t\t}\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = await storage.readBlob(id);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n\treturn Promise.all(treePs);\n}\n\n// save redirect table from .blobs tree but nothing else\nasync function getBlobManagerTreeFromTree(\n\ttree: ISnapshotTree,\n\tblobs: ISerializableBlobContents,\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n): Promise<void> {\n\tconst id = tree.blobs[redirectTableBlobName];\n\tassert(id !== undefined, 0x9ce /* id is undefined in getBlobManagerTreeFromTree */);\n\tconst blob = await storage.readBlob(id);\n\t// ArrayBufferLike will not survive JSON.stringify()\n\tblobs[id] = bufferToString(blob, \"utf8\");\n}\n\n/**\n * Extract blob contents from a snapshot tree with blob contents\n */\nexport function getBlobContentsFromTreeWithBlobContents(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISerializableBlobContents {\n\tconst blobs = {};\n\tgetBlobContentsFromTreeWithBlobContentsCore(snapshot, blobs);\n\treturn blobs;\n}\n\nfunction getBlobContentsFromTreeWithBlobContentsCore(\n\ttree: ISnapshotTreeWithBlobContents,\n\tblobs: ISerializableBlobContents,\n\troot = true,\n): void {\n\tfor (const [key, subTree] of Object.entries(tree.trees)) {\n\t\tif (root && key === blobsTreeName) {\n\t\t\tgetBlobManagerTreeFromTreeWithBlobContents(subTree, blobs);\n\t\t} else {\n\t\t\tgetBlobContentsFromTreeWithBlobContentsCore(subTree, blobs, false);\n\t\t}\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = tree.blobsContents?.[id];\n\t\tassert(blob !== undefined, 0x2ec /* \"Blob must be present in blobsContents\" */);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n}\n\n// save redirect table from .blobs tree but nothing else\nfunction getBlobManagerTreeFromTreeWithBlobContents(\n\ttree: ISnapshotTreeWithBlobContents,\n\tblobs: ISerializableBlobContents,\n): void {\n\tconst id = tree.blobs[redirectTableBlobName];\n\tassert(\n\t\tid !== undefined,\n\t\t0x9cf /* id is undefined in getBlobManagerTreeFromTreeWithBlobContents */,\n\t);\n\tconst blob = tree.blobsContents?.[id];\n\tassert(blob !== undefined, 0x70f /* Blob must be present in blobsContents */);\n\t// ArrayBufferLike will not survive JSON.stringify()\n\tblobs[id] = bufferToString(blob, \"utf8\");\n}\n"]}
1
+ {"version":3,"file":"containerStorageAdapter.js","sourceRoot":"","sources":["../src/containerStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAc7D,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAI1F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAKvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAU3D;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IASnC;;OAEG;IACH,IAAW,qBAAqB;QAC/B,OAAO,IAAI,CAAC,sBAAsB,KAAK,IAAI,CAAC;IAC7C,CAAC;IAGD;;OAEG;IACH,IAAW,sBAAsB;QAChC,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACrC,CAAC;IAOD;;;;;;;;;OASG;IACH,YACC,mBAA0D,EACzC,MAA2B,EACpC,uCAEI,EACK,2BAAwE,EACxE,2BAAgD;QALhD,WAAM,GAAN,MAAM,CAAqB;QACpC,4CAAuC,GAAvC,uCAAuC,CAEnC;QACK,gCAA2B,GAA3B,2BAA2B,CAA6C;QACxE,gCAA2B,GAA3B,2BAA2B,CAAqB;QA9B1D,4BAAuB,GAA8B,EAAE,CAAC;QAQhE;;WAEG;QACc,iBAAY,GAAsC,EAAE,CAAC;QAwBtE,aAAQ,GAAY,KAAK,CAAC;QAHzB,IAAI,CAAC,eAAe,GAAG,IAAI,eA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E,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC9E,oDAAoD;IACpD,KAAK,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport type {\n\tISnapshotTreeWithBlobContents,\n\tIContainerStorageService,\n} from \"@fluidframework/container-definitions/internal\";\nimport type { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tFetchSource,\n\tIDocumentService,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { isInstanceOfISnapshot, UsageError } from \"@fluidframework/driver-utils/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { MemoryDetachedBlobStorage } from \"./memoryBlobStorage.js\";\nimport { ProtocolTreeStorageService } from \"./protocolTreeDocumentStorageService.js\";\nimport { RetriableDocumentStorageService } from \"./retriableDocumentStorageService.js\";\nimport type {\n\tISerializedStateManagerDocumentStorageService,\n\tSerializedSnapshotInfo,\n} from \"./serializedStateManager.js\";\nimport { convertSnapshotInfoToSnapshot } from \"./utils.js\";\n\n/**\n * Stringified blobs from a summary/snapshot tree.\n * @internal\n */\nexport interface ISerializableBlobContents {\n\t[id: string]: string;\n}\n\n/**\n * This class wraps the actual storage and make sure no wrong apis are called according to\n * container attach state.\n */\nexport class ContainerStorageAdapter\n\timplements\n\t\tISerializedStateManagerDocumentStorageService,\n\t\tIContainerStorageService,\n\t\tIDisposable\n{\n\tprivate _storageService: IDocumentStorageService & Partial<IDisposable>;\n\n\tprivate _summarizeProtocolTree: boolean | undefined;\n\t/**\n\t * Whether the adapter will enforce sending combined summary trees.\n\t */\n\tpublic get summarizeProtocolTree(): boolean {\n\t\treturn this._summarizeProtocolTree === true;\n\t}\n\n\tprivate _loadedGroupIdSnapshots: Record<string, ISnapshot> = {};\n\t/**\n\t * Any loading group id (virtualized) snapshot download from storage will be stored here.\n\t */\n\tpublic get loadedGroupIdSnapshots(): Record<string, ISnapshot> {\n\t\treturn this._loadedGroupIdSnapshots;\n\t}\n\n\t/**\n\t * ArrayBufferLikes containing blobs from a snapshot\n\t */\n\tprivate readonly blobContents: { [id: string]: ArrayBufferLike } = {};\n\n\t/**\n\t * An adapter that ensures we're using detachedBlobStorage up until we connect to a real service, and then\n\t * after connecting to a real service augments it with retry and combined summary tree enforcement.\n\t * @param detachedBlobStorage - The detached blob storage to use up until we connect to a real service\n\t * @param logger - Telemetry logger\n\t * @param loadingGroupIdSnapshotsFromPendingState - in offline mode, any loading group snapshots we've downloaded from the service that were stored in the pending state\n\t * @param addProtocolSummaryIfMissing - a callback to permit the container to inspect the summary we're about to\n\t * upload, and fix it up with a protocol tree if needed\n\t * @param enableSummarizeProtocolTree - Enable uploading a protocol summary. Note: preference is given to service policy's \"summarizeProtocolTree\" before this value.\n\t */\n\tpublic constructor(\n\t\tdetachedBlobStorage: MemoryDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate loadingGroupIdSnapshotsFromPendingState:\n\t\t\t| Record<string, SerializedSnapshotInfo>\n\t\t\t| undefined,\n\t\tprivate readonly addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree,\n\t\tprivate readonly enableSummarizeProtocolTree: boolean | undefined,\n\t) {\n\t\tthis._storageService = new BlobOnlyStorage(detachedBlobStorage, logger);\n\t}\n\n\tdisposed: boolean = false;\n\tdispose(error?: Error): void {\n\t\tthis._storageService?.dispose?.(error);\n\t\tthis.disposed = true;\n\t}\n\n\tpublic connectToService(service: IDocumentService): void {\n\t\tif (!(this._storageService instanceof BlobOnlyStorage)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst storageServiceP = service.connectToStorage();\n\t\tconst retriableStorage = (this._storageService = new RetriableDocumentStorageService(\n\t\t\tstorageServiceP,\n\t\t\tthis.logger,\n\t\t));\n\n\t\t// A storage service wrapper which intercept calls to uploadSummaryWithContext and ensure they include\n\t\t// the protocol summary, provided single-commit summary is enabled.\n\t\tthis._storageService = new ProtocolTreeStorageService(\n\t\t\tretriableStorage,\n\t\t\t(...props) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"summarizeProtocolTreeEnabled\" });\n\t\t\t\treturn this.addProtocolSummaryIfMissing(...props);\n\t\t\t},\n\t\t\t// A callback to ensure we fetch the most updated value of service.policies.summarizeProtocolTree, which could be set\n\t\t\t// based on the response received from the service after connection is established.\n\t\t\t() => {\n\t\t\t\t// Determine whether or not container should upload the protocol summary along with the summary.\n\t\t\t\t// This is determined based on what value is set for serve policy's summariProtocolTree value or the enableSummarizeProtocolTree\n\t\t\t\t// retrievd from the loader options or monitoring context config.\n\t\t\t\tconst shouldSummarizeProtocolTree =\n\t\t\t\t\tservice.policies?.summarizeProtocolTree ?? this.enableSummarizeProtocolTree ?? false;\n\n\t\t\t\tif (this._summarizeProtocolTree !== shouldSummarizeProtocolTree) {\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"isSummarizeProtocolTreeEnabled\",\n\t\t\t\t\t\tdetails: { value: shouldSummarizeProtocolTree },\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis._summarizeProtocolTree = shouldSummarizeProtocolTree;\n\t\t\t\treturn this._summarizeProtocolTree;\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic cacheSnapshotBlobs(snapshotBlobs: Map<string, ArrayBuffer>): void {\n\t\tfor (const [id, value] of snapshotBlobs.entries()) {\n\t\t\tthis.blobContents[id] ??= value;\n\t\t}\n\t}\n\n\tpublic clearPendingState(): void {\n\t\tthis.loadingGroupIdSnapshotsFromPendingState = undefined;\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\t// back-compat 0.40 containerRuntime requests policies even in detached container if storage is present\n\t\t// and storage is always present in >=0.41.\n\t\ttry {\n\t\t\treturn this._storageService.policies;\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tpublic get maximumCacheDurationMs(): IDocumentStorageServicePolicies[\"maximumCacheDurationMs\"] {\n\t\treturn this.policies?.maximumCacheDurationMs;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// API called below uses null\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this._storageService.getSnapshotTree(version, scenarioName);\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet snapshot: ISnapshot;\n\t\tif (\n\t\t\tthis.loadingGroupIdSnapshotsFromPendingState !== undefined &&\n\t\t\tsnapshotFetchOptions?.loadingGroupIds !== undefined\n\t\t) {\n\t\t\tconst localSnapshot =\n\t\t\t\tthis.loadingGroupIdSnapshotsFromPendingState[snapshotFetchOptions.loadingGroupIds[0]];\n\t\t\tassert(localSnapshot !== undefined, 0x970 /* Local snapshot must be present */);\n\t\t\tsnapshot = convertSnapshotInfoToSnapshot(localSnapshot);\n\t\t} else {\n\t\t\tif (this._storageService.getSnapshot === undefined) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"getSnapshot api should exist in internal storage in ContainerStorageAdapter\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tsnapshot = await this._storageService.getSnapshot(snapshotFetchOptions);\n\t\t}\n\n\t\t// Track the latest snapshot for each loading group id\n\t\tconst loadingGroupIds = snapshotFetchOptions?.loadingGroupIds;\n\t\tassert(\n\t\t\tsnapshot.sequenceNumber !== undefined,\n\t\t\t0x971 /* Snapshot must have sequence number */,\n\t\t);\n\t\tif (loadingGroupIds !== undefined) {\n\t\t\tfor (const loadingGroupId of loadingGroupIds) {\n\t\t\t\t// Do we actually want to update the stored snapshot?\n\t\t\t\t// What if the incoming snapshot is way newer than the stored snapshot?\n\t\t\t\t// We only want to update the stored snapshot if the incoming snapshot is newer (stored sequence number < incoming sequence number)\n\t\t\t\tconst storedSeqNum =\n\t\t\t\t\tthis._loadedGroupIdSnapshots[loadingGroupId]?.sequenceNumber ?? -1;\n\t\t\t\tif (storedSeqNum < snapshot.sequenceNumber) {\n\t\t\t\t\tthis._loadedGroupIdSnapshots[loadingGroupId] = snapshot;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn snapshot;\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst maybeBlob = this.blobContents[id];\n\t\tif (maybeBlob !== undefined) {\n\t\t\treturn maybeBlob;\n\t\t}\n\t\treturn this._storageService.readBlob(id);\n\t}\n\n\tpublic async getVersions(\n\t\t// API used below uses null\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this._storageService.getVersions(versionId, count, scenarioName, fetchSource);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\treturn this._storageService.uploadSummaryWithContext(summary, context);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this._storageService.createBlob(file);\n\t}\n\n\t/**\n\t * {@link IRuntimeStorageService.downloadSummary}.\n\t *\n\t * @deprecated - This API is deprecated and will be removed in a future release. No replacement is planned as\n\t * it is unused in the Runtime and below layers.\n\t */\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this._storageService.downloadSummary(handle);\n\t}\n}\n\n/**\n * Storage which only supports createBlob() and readBlob(). This is used with IDetachedBlobStorage to support\n * blobs in detached containers.\n */\nclass BlobOnlyStorage implements IDocumentStorageService {\n\tconstructor(\n\t\tprivate readonly detachedStorage: MemoryDetachedBlobStorage | undefined,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tpublic async createBlob(content: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.verifyStorage().createBlob(content);\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.verifyStorage().readBlob(blobId);\n\t}\n\n\tprivate verifyStorage(): MemoryDetachedBlobStorage {\n\t\tif (this.detachedStorage === undefined) {\n\t\t\tthrow new UsageError(\"Real storage calls not allowed in Unattached container\");\n\t\t}\n\t\treturn this.detachedStorage;\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.notCalled();\n\t}\n\n\t/* eslint-disable @typescript-eslint/unbound-method */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic getSnapshotTree: () => Promise<ISnapshotTree | null> = this.notCalled;\n\tpublic getSnapshot: () => Promise<ISnapshot> = this.notCalled;\n\tpublic getVersions: () => Promise<IVersion[]> = this.notCalled;\n\tpublic write: () => Promise<IVersion> = this.notCalled;\n\tpublic uploadSummaryWithContext: () => Promise<string> = this.notCalled;\n\tpublic downloadSummary: () => Promise<ISummaryTree> = this.notCalled;\n\t/* eslint-enable @typescript-eslint/unbound-method */\n\n\tprivate notCalled(): never {\n\t\tthis.verifyStorage();\n\t\ttry {\n\t\t\t// some browsers may not populate stack unless exception is thrown\n\t\t\tthrow new Error(\"BlobOnlyStorage not implemented method used\");\n\t\t} catch (error) {\n\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"BlobOnlyStorageWrongCall\" }, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\n// runtime will write a tree to the summary containing \"attachment\" type entries\n// which reference attachment blobs by ID, along with a blob containing the blob redirect table.\n// However, some drivers do not support the \"attachment\" type and will convert them to \"blob\" type\n// entries. We want to avoid saving these to reduce the size of stashed change blobs, but we\n// need to make sure the blob redirect table is saved.\nconst blobsTreeName = \".blobs\";\nconst redirectTableBlobName = \".redirectTable\";\n\n/**\n * Get blob contents of a snapshot tree from storage (or, ideally, cache)\n */\nexport async function getBlobContentsFromTree(\n\tsnapshot: ISnapshot | ISnapshotTree,\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n): Promise<ISerializableBlobContents> {\n\tconst blobs = {};\n\tif (isInstanceOfISnapshot(snapshot)) {\n\t\tconst blobContents = snapshot.blobContents;\n\t\tfor (const [id, content] of blobContents.entries()) {\n\t\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\t\tblobs[id] = bufferToString(content, \"utf8\");\n\t\t}\n\t} else {\n\t\tawait getBlobContentsFromTreeCore(snapshot, blobs, storage);\n\t}\n\treturn blobs;\n}\n\nasync function getBlobContentsFromTreeCore(\n\ttree: ISnapshotTree,\n\tblobs: ISerializableBlobContents,\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n\troot = true,\n): Promise<unknown[]> {\n\tconst treePs: Promise<unknown>[] = [];\n\tfor (const [key, subTree] of Object.entries(tree.trees)) {\n\t\tif (root && key === blobsTreeName) {\n\t\t\ttreePs.push(getBlobManagerTreeFromTree(subTree, blobs, storage));\n\t\t} else {\n\t\t\ttreePs.push(getBlobContentsFromTreeCore(subTree, blobs, storage, false));\n\t\t}\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = await storage.readBlob(id);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n\treturn Promise.all(treePs);\n}\n\n// save redirect table from .blobs tree but nothing else\nasync function getBlobManagerTreeFromTree(\n\ttree: ISnapshotTree,\n\tblobs: ISerializableBlobContents,\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n): Promise<void> {\n\tconst id = tree.blobs[redirectTableBlobName];\n\tassert(id !== undefined, 0x9ce /* id is undefined in getBlobManagerTreeFromTree */);\n\tconst blob = await storage.readBlob(id);\n\t// ArrayBufferLike will not survive JSON.stringify()\n\tblobs[id] = bufferToString(blob, \"utf8\");\n}\n\n/**\n * Extract blob contents from a snapshot tree with blob contents\n */\nexport function getBlobContentsFromTreeWithBlobContents(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISerializableBlobContents {\n\tconst blobs = {};\n\tgetBlobContentsFromTreeWithBlobContentsCore(snapshot, blobs);\n\treturn blobs;\n}\n\nfunction getBlobContentsFromTreeWithBlobContentsCore(\n\ttree: ISnapshotTreeWithBlobContents,\n\tblobs: ISerializableBlobContents,\n\troot = true,\n): void {\n\tfor (const [key, subTree] of Object.entries(tree.trees)) {\n\t\tif (root && key === blobsTreeName) {\n\t\t\tgetBlobManagerTreeFromTreeWithBlobContents(subTree, blobs);\n\t\t} else {\n\t\t\tgetBlobContentsFromTreeWithBlobContentsCore(subTree, blobs, false);\n\t\t}\n\t}\n\tfor (const id of Object.values(tree.blobs)) {\n\t\tconst blob = tree.blobsContents?.[id];\n\t\tassert(blob !== undefined, 0x2ec /* \"Blob must be present in blobsContents\" */);\n\t\t// ArrayBufferLike will not survive JSON.stringify()\n\t\tblobs[id] = bufferToString(blob, \"utf8\");\n\t}\n}\n\n// save redirect table from .blobs tree but nothing else\nfunction getBlobManagerTreeFromTreeWithBlobContents(\n\ttree: ISnapshotTreeWithBlobContents,\n\tblobs: ISerializableBlobContents,\n): void {\n\tconst id = tree.blobs[redirectTableBlobName];\n\tassert(\n\t\tid !== undefined,\n\t\t0x9cf /* id is undefined in getBlobManagerTreeFromTreeWithBlobContents */,\n\t);\n\tconst blob = tree.blobsContents?.[id];\n\tassert(blob !== undefined, 0x70f /* Blob must be present in blobsContents */);\n\t// ArrayBufferLike will not survive JSON.stringify()\n\tblobs[id] = bufferToString(blob, \"utf8\");\n}\n"]}
@@ -7,6 +7,7 @@ import type { FluidObject, IConfigProviderBase, IRequest, ITelemetryBaseLogger }
7
7
  import type { IClientDetails } from "@fluidframework/driver-definitions";
8
8
  import type { IDocumentServiceFactory, IUrlResolver } from "@fluidframework/driver-definitions/internal";
9
9
  import type { ProtocolHandlerBuilder } from "./protocol.js";
10
+ import type { LoadSummarizerSummaryResult } from "./summarizerResultTypes.js";
10
11
  /**
11
12
  * Properties necessary for creating and loading a container.
12
13
  * @legacy @beta
@@ -75,6 +76,11 @@ export interface ILoadExistingContainerProps extends ICreateAndLoadContainerProp
75
76
  */
76
77
  readonly pendingLocalState?: string | undefined;
77
78
  }
79
+ /**
80
+ * Props used to load summarizer container.
81
+ * @legacy @alpha
82
+ */
83
+ export type ILoadSummarizerContainerProps = Omit<ILoadExistingContainerProps, "pendingLocalState">;
78
84
  /**
79
85
  * Props used to create a detached container.
80
86
  * @legacy @beta
@@ -131,4 +137,11 @@ export interface ILoadFrozenContainerFromPendingStateProps extends ILoadExisting
131
137
  * @legacy @alpha
132
138
  */
133
139
  export declare function loadFrozenContainerFromPendingState(props: ILoadFrozenContainerFromPendingStateProps): Promise<IContainer>;
140
+ /**
141
+ * Loads a summarizer container with the required headers, triggers an on-demand summary, and then closes it.
142
+ * Returns success/failure and an optional error for host-side handling.
143
+ *
144
+ * @legacy @alpha
145
+ */
146
+ export declare function loadSummarizerContainerAndMakeSummary(loadSummarizerContainerProps: ILoadSummarizerContainerProps): Promise<LoadSummarizerSummaryResult>;
134
147
  //# sourceMappingURL=createAndLoadContainerUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createAndLoadContainerUtils.d.ts","sourceRoot":"","sources":["../src/createAndLoadContainerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACX,WAAW,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,WAAW,6BAA8B,SAAQ,4BAA4B;IAClF;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAiC,SAAQ,4BAA4B;IACrF;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CACjC;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC5C,4BAA4B,EAAE,6BAA6B,GACzD,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC/C,+BAA+B,EAAE,gCAAgC,GAC/D,OAAO,CAAC,UAAU,CAAC,CASrB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAC1C,0BAA0B,EAAE,2BAA2B,GACrD,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED;;;GAGG;AACH,MAAM,WAAW,yCAChB,SAAQ,2BAA2B;IACnC;;OAEG;IACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAsB,mCAAmC,CACxD,KAAK,EAAE,yCAAyC,GAC9C,OAAO,CAAC,UAAU,CAAC,CAKrB"}
1
+ {"version":3,"file":"createAndLoadContainerUtils.d.ts","sourceRoot":"","sources":["../src/createAndLoadContainerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EACX,WAAW,EACX,mBAAmB,EACnB,QAAQ,EACR,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EACX,uBAAuB,EACvB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAiBrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5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;;;GAGG;AACH,MAAM,WAAW,gCAAiC,SAAQ,4BAA4B;IACrF;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CACjC;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC5C,4BAA4B,EAAE,6BAA6B,GACzD,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC/C,+BAA+B,EAAE,gCAAgC,GAC/D,OAAO,CAAC,UAAU,CAAC,CASrB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAC1C,0BAA0B,EAAE,2BAA2B,GACrD,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED;;;GAGG;AACH,MAAM,WAAW,yCAChB,SAAQ,2BAA2B;IACnC;;OAEG;IACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAsB,mCAAmC,CACxD,KAAK,EAAE,yCAAyC,GAC9C,OAAO,CAAC,UAAU,CAAC,CAKrB;AAED;;;;;GAKG;AACH,wBAAsB,qCAAqC,CAC1D,4BAA4B,EAAE,6BAA6B,GACzD,OAAO,CAAC,2BAA2B,CAAC,CAwHtC"}
@@ -2,8 +2,14 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { LoaderHeader } from "@fluidframework/container-definitions/internal";
6
+ import { DriverHeader } from "@fluidframework/driver-definitions/internal";
7
+ import { GenericError, normalizeError, createChildMonitoringContext, mixinMonitoringContext, sessionStorageConfigProvider, PerformanceEvent, isFluidError, } from "@fluidframework/telemetry-utils/internal";
8
+ import { v4 as uuid } from "uuid";
9
+ import { DebugLogger } from "./debugLogger.js";
5
10
  import { createFrozenDocumentServiceFactory } from "./frozenServices.js";
6
11
  import { Loader } from "./loader.js";
12
+ import { pkgVersion } from "./packageVersion.js";
7
13
  /**
8
14
  * Creates a new container using the specified code details but in an unattached state. While unattached, all
9
15
  * updates will only be local until the user explicitly attaches the container to a service provider.
@@ -50,4 +56,113 @@ export async function loadFrozenContainerFromPendingState(props) {
50
56
  documentServiceFactory: createFrozenDocumentServiceFactory(props.documentServiceFactory),
51
57
  });
52
58
  }
59
+ /**
60
+ * Loads a summarizer container with the required headers, triggers an on-demand summary, and then closes it.
61
+ * Returns success/failure and an optional error for host-side handling.
62
+ *
63
+ * @legacy @alpha
64
+ */
65
+ export async function loadSummarizerContainerAndMakeSummary(loadSummarizerContainerProps) {
66
+ const { logger, configProvider, request: originalRequest } = loadSummarizerContainerProps;
67
+ const telemetryProps = {
68
+ loaderId: uuid(),
69
+ loaderVersion: pkgVersion,
70
+ };
71
+ const subMc = mixinMonitoringContext(DebugLogger.mixinDebugLogger("fluid:telemetry", logger, {
72
+ all: telemetryProps,
73
+ }), sessionStorageConfigProvider.value, configProvider);
74
+ const mc = createChildMonitoringContext({
75
+ logger: subMc.logger,
76
+ namespace: "SummarizerOnDemand",
77
+ });
78
+ return PerformanceEvent.timedExecAsync(mc.logger, { eventName: "SummarizerOnDemandSummary" }, async (event) => {
79
+ const baseHeaders = originalRequest.headers;
80
+ const request = {
81
+ ...originalRequest,
82
+ headers: {
83
+ ...baseHeaders,
84
+ [LoaderHeader.cache]: false,
85
+ [LoaderHeader.clientDetails]: {
86
+ capabilities: { interactive: false },
87
+ type: "summarizer",
88
+ },
89
+ [DriverHeader.summarizingClient]: true,
90
+ [LoaderHeader.reconnect]: false,
91
+ },
92
+ };
93
+ const container = await loadExistingContainer({
94
+ ...loadSummarizerContainerProps,
95
+ request,
96
+ });
97
+ let summarySubmitted;
98
+ let summaryOpBroadcasted;
99
+ try {
100
+ if (container.getEntryPoint === undefined) {
101
+ throw new GenericError("container.getEntryPoint() is undefined");
102
+ }
103
+ const fluidObject = (await container.getEntryPoint());
104
+ const summarizer = fluidObject?.ISummarizer;
105
+ if (summarizer === undefined) {
106
+ throw new GenericError("Summarizer entry point not available");
107
+ }
108
+ // Host controlled feature gate for fullTree
109
+ // Default value will be false
110
+ const fullTreeGate = mc.config.getBoolean("Fluid.Summarizer.FullTree.OnDemand") === true;
111
+ const summarizeResults = summarizer.summarizeOnDemand({
112
+ reason: "summaryOnRequest",
113
+ retryOnFailure: true,
114
+ fullTree: fullTreeGate,
115
+ });
116
+ [summarySubmitted, summaryOpBroadcasted] = await Promise.all([
117
+ summarizeResults.summarySubmitted,
118
+ summarizeResults.summaryOpBroadcasted,
119
+ ]);
120
+ const summaryResults = {
121
+ summarySubmitted: summarySubmitted.success,
122
+ summaryInfo: summarySubmitted.success
123
+ ? {
124
+ stage: summarySubmitted.data.stage,
125
+ handle: summaryOpBroadcasted.success
126
+ ? summaryOpBroadcasted.data.summarizeOp.contents.handle
127
+ : undefined,
128
+ }
129
+ : {},
130
+ summaryOpBroadcasted: summaryOpBroadcasted.success,
131
+ };
132
+ if (summarySubmitted.success && summaryOpBroadcasted.success) {
133
+ event.end({
134
+ success: true,
135
+ summarySubmitted: true,
136
+ summaryOpBroadcasted: true,
137
+ });
138
+ return {
139
+ success: true,
140
+ summaryResults,
141
+ };
142
+ }
143
+ const failureError = summarySubmitted.success === false
144
+ ? summarySubmitted.error
145
+ : summaryOpBroadcasted.success === false
146
+ ? summaryOpBroadcasted.error
147
+ : new GenericError("On demand summary failed");
148
+ event.end({
149
+ success: false,
150
+ summarySubmitted: summarySubmitted.success,
151
+ summaryOpBroadcasted: summaryOpBroadcasted.success,
152
+ });
153
+ return {
154
+ success: false,
155
+ error: failureError,
156
+ };
157
+ }
158
+ catch (error) {
159
+ event.cancel({ success: false }, error);
160
+ const caughtError = isFluidError(error) ? error : normalizeError(error);
161
+ return { success: false, error: caughtError };
162
+ }
163
+ finally {
164
+ container.dispose();
165
+ }
166
+ }, { start: true, end: true, cancel: "generic" });
167
+ }
53
168
  //# sourceMappingURL=createAndLoadContainerUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createAndLoadContainerUtils.js","sourceRoot":"","sources":["../src/createAndLoadContainerUt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microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIContainer,\n\tICodeDetailsLoader,\n\tIFluidCodeDetails,\n\tIContainerPolicies,\n} from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IClientDetails } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentServiceFactory,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { createFrozenDocumentServiceFactory } from \"./frozenServices.js\";\nimport { Loader } from \"./loader.js\";\nimport type { ProtocolHandlerBuilder } from \"./protocol.js\";\n\n/**\n * Properties necessary for creating and loading a container.\n * @legacy @beta\n */\nexport interface ICreateAndLoadContainerProps {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options/policies used by various layers\n\t * to control features\n\t */\n\treadonly options?: IContainerPolicies | undefined;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope?: FluidObject | undefined;\n\n\t/**\n\t * The logger that all telemetry should be pushed to.\n\t */\n\treadonly logger?: ITelemetryBaseLogger | undefined;\n\n\t/**\n\t * The configuration provider which may be used to control features.\n\t */\n\treadonly configProvider?: IConfigProviderBase | undefined;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder | undefined;\n\n\t/**\n\t * Disables the Container from reconnecting if false, allows reconnect otherwise.\n\t */\n\treadonly allowReconnect?: boolean | undefined;\n\n\t/**\n\t * Client details provided in the override will be merged over the default client.\n\t */\n\treadonly clientDetailsOverride?: IClientDetails | undefined;\n}\n\n/**\n * Props used to load a container.\n * @legacy @beta\n */\nexport interface ILoadExistingContainerProps extends ICreateAndLoadContainerProps {\n\t/**\n\t * The request to resolve the container.\n\t */\n\treadonly request: IRequest;\n\n\t/**\n\t * Pending local state to be applied to the container.\n\t */\n\treadonly pendingLocalState?: string | undefined;\n}\n\n/**\n * Props used to create a detached container.\n * @legacy @beta\n */\nexport interface ICreateDetachedContainerProps extends ICreateAndLoadContainerProps {\n\t/**\n\t * The code details for the container to be created.\n\t */\n\treadonly codeDetails: IFluidCodeDetails;\n}\n\n/**\n * Props used to rehydrate a detached container.\n * @legacy @beta\n */\nexport interface IRehydrateDetachedContainerProps extends ICreateAndLoadContainerProps {\n\t/**\n\t * The serialized state returned by calling serialize on another container\n\t */\n\treadonly serializedState: string;\n}\n\n/**\n * Creates a new container using the specified code details but in an unattached state. While unattached, all\n * updates will only be local until the user explicitly attaches the container to a service provider.\n * @param createDetachedContainerProps - Services and properties necessary for creating detached container.\n * @legacy @beta\n */\nexport async function createDetachedContainer(\n\tcreateDetachedContainerProps: ICreateDetachedContainerProps,\n): Promise<IContainer> {\n\tconst loader = new Loader(createDetachedContainerProps);\n\treturn loader.createDetachedContainer(createDetachedContainerProps.codeDetails, {\n\t\tcanReconnect: createDetachedContainerProps.allowReconnect,\n\t\tclientDetailsOverride: createDetachedContainerProps.clientDetailsOverride,\n\t});\n}\n\n/**\n * Creates a new container using the specified snapshot but in an unattached state. While unattached, all\n * updates will only be local until the user explicitly attaches the container to a service provider.\n * @param rehydrateDetachedContainerProps - Services and properties necessary for rehydrating detached container from a previously serialized container's state.\n * @legacy @beta\n */\nexport async function rehydrateDetachedContainer(\n\trehydrateDetachedContainerProps: IRehydrateDetachedContainerProps,\n): Promise<IContainer> {\n\tconst loader = new Loader(rehydrateDetachedContainerProps);\n\treturn loader.rehydrateDetachedContainerFromSnapshot(\n\t\trehydrateDetachedContainerProps.serializedState,\n\t\t{\n\t\t\tcanReconnect: rehydrateDetachedContainerProps.allowReconnect,\n\t\t\tclientDetailsOverride: rehydrateDetachedContainerProps.clientDetailsOverride,\n\t\t},\n\t);\n}\n\n/**\n * Loads a container with an existing snapshot from the service.\n * @param loadExistingContainerProps - Services and properties necessary for loading an existing container.\n * @legacy @beta\n */\nexport async function loadExistingContainer(\n\tloadExistingContainerProps: ILoadExistingContainerProps,\n): Promise<IContainer> {\n\tconst loader = new Loader(loadExistingContainerProps);\n\treturn loader.resolve(\n\t\tloadExistingContainerProps.request,\n\t\tloadExistingContainerProps.pendingLocalState,\n\t);\n}\n\n/**\n * Properties required to load a frozen container from pending state.\n * @legacy @alpha\n */\nexport interface ILoadFrozenContainerFromPendingStateProps\n\textends ILoadExistingContainerProps {\n\t/**\n\t * Pending local state to be applied to the container.\n\t */\n\treadonly pendingLocalState: string;\n}\n\n/**\n * Loads a frozen container from pending local state.\n * @param props - Properties required to load a frozen container from pending state.\n * @legacy @alpha\n */\nexport async function loadFrozenContainerFromPendingState(\n\tprops: ILoadFrozenContainerFromPendingStateProps,\n): Promise<IContainer> {\n\treturn loadExistingContainer({\n\t\t...props,\n\t\tdocumentServiceFactory: createFrozenDocumentServiceFactory(props.documentServiceFactory),\n\t});\n}\n"]}
1
+ {"version":3,"file":"createAndLoadContainerUtils.js","sourceRoot":"","sources":["../src/createAndLoadContainerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAY9E,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EACN,YAAY,EACZ,cAAc,EACd,4BAA4B,EAC5B,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,YAAY,GACZ,MAAM,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;IACF,CAAC,EACD,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAC7C,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIContainer,\n\tICodeDetailsLoader,\n\tIFluidCodeDetails,\n\tIContainerPolicies,\n} from \"@fluidframework/container-definitions/internal\";\nimport { LoaderHeader } from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIConfigProviderBase,\n\tIRequest,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport type { IClientDetails } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentServiceFactory,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tGenericError,\n\tnormalizeError,\n\tcreateChildMonitoringContext,\n\tmixinMonitoringContext,\n\tsessionStorageConfigProvider,\n\tPerformanceEvent,\n\tisFluidError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { DebugLogger } from \"./debugLogger.js\";\nimport { createFrozenDocumentServiceFactory } from \"./frozenServices.js\";\nimport { Loader } from \"./loader.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\nimport type { ProtocolHandlerBuilder } from \"./protocol.js\";\nimport type {\n\tLoadSummarizerSummaryResult,\n\tOnDemandSummaryResults,\n\tSummarizeOnDemandResults,\n} from \"./summarizerResultTypes.js\";\n\ninterface OnDemandSummarizeResultsPromises {\n\treadonly summarySubmitted: Promise<SummarizeOnDemandResults[\"summarySubmitted\"]>;\n\treadonly summaryOpBroadcasted: Promise<SummarizeOnDemandResults[\"summaryOpBroadcasted\"]>;\n}\n\ninterface OnDemandSummarizeOptions {\n\treadonly reason?: string;\n\treadonly retryOnFailure?: boolean;\n\treadonly fullTree?: boolean;\n}\n\ninterface SummarizerLike {\n\treadonly ISummarizer?: SummarizerLike;\n\tsummarizeOnDemand(options: OnDemandSummarizeOptions): OnDemandSummarizeResultsPromises;\n}\n\n/**\n * Properties necessary for creating and loading a container.\n * @legacy @beta\n */\nexport interface ICreateAndLoadContainerProps {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options/policies used by various layers\n\t * to control features\n\t */\n\treadonly options?: IContainerPolicies | undefined;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope?: FluidObject | undefined;\n\n\t/**\n\t * The logger that all telemetry should be pushed to.\n\t */\n\treadonly logger?: ITelemetryBaseLogger | undefined;\n\n\t/**\n\t * The configuration provider which may be used to control features.\n\t */\n\treadonly configProvider?: IConfigProviderBase | undefined;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder | undefined;\n\n\t/**\n\t * Disables the Container from reconnecting if false, allows reconnect otherwise.\n\t */\n\treadonly allowReconnect?: boolean | undefined;\n\n\t/**\n\t * Client details provided in the override will be merged over the default client.\n\t */\n\treadonly clientDetailsOverride?: IClientDetails | undefined;\n}\n\n/**\n * Props used to load a container.\n * @legacy @beta\n */\nexport interface ILoadExistingContainerProps extends ICreateAndLoadContainerProps {\n\t/**\n\t * The request to resolve the container.\n\t */\n\treadonly request: IRequest;\n\n\t/**\n\t * Pending local state to be applied to the container.\n\t */\n\treadonly pendingLocalState?: string | undefined;\n}\n\n/**\n * Props used to load summarizer container.\n * @legacy @alpha\n */\nexport type ILoadSummarizerContainerProps = Omit<\n\tILoadExistingContainerProps,\n\t\"pendingLocalState\"\n>;\n\n/**\n * Props used to create a detached container.\n * @legacy @beta\n */\nexport interface ICreateDetachedContainerProps extends ICreateAndLoadContainerProps {\n\t/**\n\t * The code details for the container to be created.\n\t */\n\treadonly codeDetails: IFluidCodeDetails;\n}\n\n/**\n * Props used to rehydrate a detached container.\n * @legacy @beta\n */\nexport interface IRehydrateDetachedContainerProps extends ICreateAndLoadContainerProps {\n\t/**\n\t * The serialized state returned by calling serialize on another container\n\t */\n\treadonly serializedState: string;\n}\n\n/**\n * Creates a new container using the specified code details but in an unattached state. While unattached, all\n * updates will only be local until the user explicitly attaches the container to a service provider.\n * @param createDetachedContainerProps - Services and properties necessary for creating detached container.\n * @legacy @beta\n */\nexport async function createDetachedContainer(\n\tcreateDetachedContainerProps: ICreateDetachedContainerProps,\n): Promise<IContainer> {\n\tconst loader = new Loader(createDetachedContainerProps);\n\treturn loader.createDetachedContainer(createDetachedContainerProps.codeDetails, {\n\t\tcanReconnect: createDetachedContainerProps.allowReconnect,\n\t\tclientDetailsOverride: createDetachedContainerProps.clientDetailsOverride,\n\t});\n}\n\n/**\n * Creates a new container using the specified snapshot but in an unattached state. While unattached, all\n * updates will only be local until the user explicitly attaches the container to a service provider.\n * @param rehydrateDetachedContainerProps - Services and properties necessary for rehydrating detached container from a previously serialized container's state.\n * @legacy @beta\n */\nexport async function rehydrateDetachedContainer(\n\trehydrateDetachedContainerProps: IRehydrateDetachedContainerProps,\n): Promise<IContainer> {\n\tconst loader = new Loader(rehydrateDetachedContainerProps);\n\treturn loader.rehydrateDetachedContainerFromSnapshot(\n\t\trehydrateDetachedContainerProps.serializedState,\n\t\t{\n\t\t\tcanReconnect: rehydrateDetachedContainerProps.allowReconnect,\n\t\t\tclientDetailsOverride: rehydrateDetachedContainerProps.clientDetailsOverride,\n\t\t},\n\t);\n}\n\n/**\n * Loads a container with an existing snapshot from the service.\n * @param loadExistingContainerProps - Services and properties necessary for loading an existing container.\n * @legacy @beta\n */\nexport async function loadExistingContainer(\n\tloadExistingContainerProps: ILoadExistingContainerProps,\n): Promise<IContainer> {\n\tconst loader = new Loader(loadExistingContainerProps);\n\treturn loader.resolve(\n\t\tloadExistingContainerProps.request,\n\t\tloadExistingContainerProps.pendingLocalState,\n\t);\n}\n\n/**\n * Properties required to load a frozen container from pending state.\n * @legacy @alpha\n */\nexport interface ILoadFrozenContainerFromPendingStateProps\n\textends ILoadExistingContainerProps {\n\t/**\n\t * Pending local state to be applied to the container.\n\t */\n\treadonly pendingLocalState: string;\n}\n\n/**\n * Loads a frozen container from pending local state.\n * @param props - Properties required to load a frozen container from pending state.\n * @legacy @alpha\n */\nexport async function loadFrozenContainerFromPendingState(\n\tprops: ILoadFrozenContainerFromPendingStateProps,\n): Promise<IContainer> {\n\treturn loadExistingContainer({\n\t\t...props,\n\t\tdocumentServiceFactory: createFrozenDocumentServiceFactory(props.documentServiceFactory),\n\t});\n}\n\n/**\n * Loads a summarizer container with the required headers, triggers an on-demand summary, and then closes it.\n * Returns success/failure and an optional error for host-side handling.\n *\n * @legacy @alpha\n */\nexport async function loadSummarizerContainerAndMakeSummary(\n\tloadSummarizerContainerProps: ILoadSummarizerContainerProps,\n): Promise<LoadSummarizerSummaryResult> {\n\tconst { logger, configProvider, request: originalRequest } = loadSummarizerContainerProps;\n\tconst telemetryProps = {\n\t\tloaderId: uuid(),\n\t\tloaderVersion: pkgVersion,\n\t};\n\n\tconst subMc = mixinMonitoringContext(\n\t\tDebugLogger.mixinDebugLogger(\"fluid:telemetry\", logger, {\n\t\t\tall: telemetryProps,\n\t\t}),\n\t\tsessionStorageConfigProvider.value,\n\t\tconfigProvider,\n\t);\n\tconst mc = createChildMonitoringContext({\n\t\tlogger: subMc.logger,\n\t\tnamespace: \"SummarizerOnDemand\",\n\t});\n\treturn PerformanceEvent.timedExecAsync(\n\t\tmc.logger,\n\t\t{ eventName: \"SummarizerOnDemandSummary\" },\n\t\tasync (event) => {\n\t\t\tconst baseHeaders = originalRequest.headers;\n\t\t\tconst request = {\n\t\t\t\t...originalRequest,\n\t\t\t\theaders: {\n\t\t\t\t\t...baseHeaders,\n\t\t\t\t\t[LoaderHeader.cache]: false,\n\t\t\t\t\t[LoaderHeader.clientDetails]: {\n\t\t\t\t\t\tcapabilities: { interactive: false },\n\t\t\t\t\t\ttype: \"summarizer\",\n\t\t\t\t\t},\n\t\t\t\t\t[DriverHeader.summarizingClient]: true,\n\t\t\t\t\t[LoaderHeader.reconnect]: false,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst container = await loadExistingContainer({\n\t\t\t\t...loadSummarizerContainerProps,\n\t\t\t\trequest,\n\t\t\t});\n\n\t\t\tlet summarySubmitted: SummarizeOnDemandResults[\"summarySubmitted\"];\n\t\t\tlet summaryOpBroadcasted: SummarizeOnDemandResults[\"summaryOpBroadcasted\"];\n\t\t\ttry {\n\t\t\t\tif (container.getEntryPoint === undefined) {\n\t\t\t\t\tthrow new GenericError(\"container.getEntryPoint() is undefined\");\n\t\t\t\t}\n\t\t\t\tconst fluidObject = (await container.getEntryPoint()) as FluidObject<SummarizerLike>;\n\t\t\t\tconst summarizer = fluidObject?.ISummarizer;\n\t\t\t\tif (summarizer === undefined) {\n\t\t\t\t\tthrow new GenericError(\"Summarizer entry point not available\");\n\t\t\t\t}\n\t\t\t\t// Host controlled feature gate for fullTree\n\t\t\t\t// Default value will be false\n\t\t\t\tconst fullTreeGate =\n\t\t\t\t\tmc.config.getBoolean(\"Fluid.Summarizer.FullTree.OnDemand\") === true;\n\n\t\t\t\tconst summarizeResults: OnDemandSummarizeResultsPromises =\n\t\t\t\t\tsummarizer.summarizeOnDemand({\n\t\t\t\t\t\treason: \"summaryOnRequest\",\n\t\t\t\t\t\tretryOnFailure: true,\n\t\t\t\t\t\tfullTree: fullTreeGate,\n\t\t\t\t\t});\n\t\t\t\t[summarySubmitted, summaryOpBroadcasted] = await Promise.all([\n\t\t\t\t\tsummarizeResults.summarySubmitted,\n\t\t\t\t\tsummarizeResults.summaryOpBroadcasted,\n\t\t\t\t]);\n\n\t\t\t\tconst summaryResults: OnDemandSummaryResults = {\n\t\t\t\t\tsummarySubmitted: summarySubmitted.success,\n\t\t\t\t\tsummaryInfo: summarySubmitted.success\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tstage: summarySubmitted.data.stage,\n\t\t\t\t\t\t\t\thandle: summaryOpBroadcasted.success\n\t\t\t\t\t\t\t\t\t? summaryOpBroadcasted.data.summarizeOp.contents.handle\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {},\n\t\t\t\t\tsummaryOpBroadcasted: summaryOpBroadcasted.success,\n\t\t\t\t};\n\n\t\t\t\tif (summarySubmitted.success && summaryOpBroadcasted.success) {\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tsummarySubmitted: true,\n\t\t\t\t\t\tsummaryOpBroadcasted: true,\n\t\t\t\t\t});\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tsummaryResults,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst failureError =\n\t\t\t\t\tsummarySubmitted.success === false\n\t\t\t\t\t\t? summarySubmitted.error\n\t\t\t\t\t\t: summaryOpBroadcasted.success === false\n\t\t\t\t\t\t\t? summaryOpBroadcasted.error\n\t\t\t\t\t\t\t: new GenericError(\"On demand summary failed\");\n\n\t\t\t\tevent.end({\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tsummarySubmitted: summarySubmitted.success,\n\t\t\t\t\tsummaryOpBroadcasted: summaryOpBroadcasted.success,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: failureError,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tevent.cancel({ success: false }, error);\n\t\t\t\tconst caughtError = isFluidError(error) ? error : normalizeError(error);\n\t\t\t\treturn { success: false, error: caughtError };\n\t\t\t} finally {\n\t\t\t\tcontainer.dispose();\n\t\t\t}\n\t\t},\n\t\t{ start: true, end: true, cancel: \"generic\" },\n\t);\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -5,7 +5,8 @@
5
5
  export { ConnectionState } from "./connectionState.js";
6
6
  export { type ContainerAlpha, waitContainerToCatchUp, asLegacyAlpha } from "./container.js";
7
7
  export { createFrozenDocumentServiceFactory } from "./frozenServices.js";
8
- export { createDetachedContainer, loadExistingContainer, rehydrateDetachedContainer, loadFrozenContainerFromPendingState, type ICreateAndLoadContainerProps, type ICreateDetachedContainerProps, type ILoadExistingContainerProps, type IRehydrateDetachedContainerProps, type ILoadFrozenContainerFromPendingStateProps, } from "./createAndLoadContainerUtils.js";
8
+ export { createDetachedContainer, loadExistingContainer, rehydrateDetachedContainer, loadFrozenContainerFromPendingState, loadSummarizerContainerAndMakeSummary, type ICreateAndLoadContainerProps, type ICreateDetachedContainerProps, type ILoadExistingContainerProps, type ILoadSummarizerContainerProps, type IRehydrateDetachedContainerProps, type ILoadFrozenContainerFromPendingStateProps, } from "./createAndLoadContainerUtils.js";
9
+ export type { LoadSummarizerSummaryResult, OnDemandSummaryResults, SummaryStage, } from "./summarizerResultTypes.js";
9
10
  export { type ICodeDetailsLoader, type IFluidModuleWithDetails, type ILoaderProps, type ILoaderServices, Loader, } from "./loader.js";
10
11
  export { driverSupportRequirementsForLoader, loaderCoreCompatDetails, runtimeSupportRequirementsForLoader, loaderCompatDetailsForRuntime, } from "./loaderLayerCompatState.js";
11
12
  export { loadContainerPaused } from "./loadPaused.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,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0B,EAC1B,mCAAmC,EACnC,qCAAqC,EACrC,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAChC,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EACrC,KAAK,yCAAyC,GAC9C,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EACX,2BAA2B,EAC3B,sBAAsB,EACtB,YAAY,GACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,MAAM,GACN,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,kCAAkC,EAClC,uBAAuB,EACvB,mCAAmC,EACnC,6BAA6B,GAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACN,0BAA0B,EAC1B,sCAAsC,GACtC,MAAM,2CAA2C,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EACN,6BAA6B,EAC7B,KAAK,UAAU,GACf,MAAM,YAAY,CAAC;AACpB,YAAY,EACX,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,qBAAqB,CAAC"}
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  export { ConnectionState } from "./connectionState.js";
6
6
  export { waitContainerToCatchUp, asLegacyAlpha } from "./container.js";
7
7
  export { createFrozenDocumentServiceFactory } from "./frozenServices.js";
8
- export { createDetachedContainer, loadExistingContainer, rehydrateDetachedContainer, loadFrozenContainerFromPendingState, } from "./createAndLoadContainerUtils.js";
8
+ export { createDetachedContainer, loadExistingContainer, rehydrateDetachedContainer, loadFrozenContainerFromPendingState, loadSummarizerContainerAndMakeSummary, } from "./createAndLoadContainerUtils.js";
9
9
  export { Loader, } from "./loader.js";
10
10
  export { driverSupportRequirementsForLoader, loaderCoreCompatDetails, runtimeSupportRequirementsForLoader, loaderCompatDetailsForRuntime, } from "./loaderLayerCompatState.js";
11
11
  export { loadContainerPaused } from "./loadPaused.js";
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAuB,sBAAsB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,mCAAmC,GAMnC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAKN,MAAM,GACN,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,kCAAkC,EAClC,uBAAuB,EACvB,mCAAmC,EACnC,6BAA6B,GAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACN,0BAA0B,EAC1B,sCAAsC,GACtC,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EACN,6BAA6B,GAE7B,MAAM,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConnectionState } from \"./connectionState.js\";\nexport { type ContainerAlpha, waitContainerToCatchUp, asLegacyAlpha } from \"./container.js\";\nexport { createFrozenDocumentServiceFactory } from \"./frozenServices.js\";\nexport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\trehydrateDetachedContainer,\n\tloadFrozenContainerFromPendingState,\n\ttype ICreateAndLoadContainerProps,\n\ttype ICreateDetachedContainerProps,\n\ttype ILoadExistingContainerProps,\n\ttype IRehydrateDetachedContainerProps,\n\ttype ILoadFrozenContainerFromPendingStateProps,\n} from \"./createAndLoadContainerUtils.js\";\nexport {\n\ttype ICodeDetailsLoader,\n\ttype IFluidModuleWithDetails,\n\ttype ILoaderProps,\n\ttype ILoaderServices,\n\tLoader,\n} from \"./loader.js\";\nexport {\n\tdriverSupportRequirementsForLoader,\n\tloaderCoreCompatDetails,\n\truntimeSupportRequirementsForLoader,\n\tloaderCompatDetailsForRuntime,\n} from \"./loaderLayerCompatState.js\";\nexport { loadContainerPaused } from \"./loadPaused.js\";\nexport {\n\tisLocationRedirectionError,\n\tresolveWithLocationRedirectionHandling,\n} from \"./location-redirection-utilities/index.js\";\nexport type { IProtocolHandler, ProtocolHandlerBuilder } from \"./protocol.js\";\nexport {\n\ttryParseCompatibleResolvedUrl,\n\ttype IParsedUrl,\n} from \"./utils.js\";\nexport type {\n\tIBaseProtocolHandler,\n\tIScribeProtocolState,\n\tIQuorumSnapshot,\n\tQuorumClientsSnapshot,\n\tQuorumProposalsSnapshot,\n} from \"./protocol/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAuB,sBAAsB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,mCAAmC,EACnC,qCAAqC,GAOrC,MAAM,kCAAkC,CAAC;AAM1C,OAAO,EAKN,MAAM,GACN,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,kCAAkC,EAClC,uBAAuB,EACvB,mCAAmC,EACnC,6BAA6B,GAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACN,0BAA0B,EAC1B,sCAAsC,GACtC,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EACN,6BAA6B,GAE7B,MAAM,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ConnectionState } from \"./connectionState.js\";\nexport { type ContainerAlpha, waitContainerToCatchUp, asLegacyAlpha } from \"./container.js\";\nexport { createFrozenDocumentServiceFactory } from \"./frozenServices.js\";\nexport {\n\tcreateDetachedContainer,\n\tloadExistingContainer,\n\trehydrateDetachedContainer,\n\tloadFrozenContainerFromPendingState,\n\tloadSummarizerContainerAndMakeSummary,\n\ttype ICreateAndLoadContainerProps,\n\ttype ICreateDetachedContainerProps,\n\ttype ILoadExistingContainerProps,\n\ttype ILoadSummarizerContainerProps,\n\ttype IRehydrateDetachedContainerProps,\n\ttype ILoadFrozenContainerFromPendingStateProps,\n} from \"./createAndLoadContainerUtils.js\";\nexport type {\n\tLoadSummarizerSummaryResult,\n\tOnDemandSummaryResults,\n\tSummaryStage,\n} from \"./summarizerResultTypes.js\";\nexport {\n\ttype ICodeDetailsLoader,\n\ttype IFluidModuleWithDetails,\n\ttype ILoaderProps,\n\ttype ILoaderServices,\n\tLoader,\n} from \"./loader.js\";\nexport {\n\tdriverSupportRequirementsForLoader,\n\tloaderCoreCompatDetails,\n\truntimeSupportRequirementsForLoader,\n\tloaderCompatDetailsForRuntime,\n} from \"./loaderLayerCompatState.js\";\nexport { loadContainerPaused } from \"./loadPaused.js\";\nexport {\n\tisLocationRedirectionError,\n\tresolveWithLocationRedirectionHandling,\n} from \"./location-redirection-utilities/index.js\";\nexport type { IProtocolHandler, ProtocolHandlerBuilder } from \"./protocol.js\";\nexport {\n\ttryParseCompatibleResolvedUrl,\n\ttype IParsedUrl,\n} from \"./utils.js\";\nexport type {\n\tIBaseProtocolHandler,\n\tIScribeProtocolState,\n\tIQuorumSnapshot,\n\tQuorumClientsSnapshot,\n\tQuorumProposalsSnapshot,\n} from \"./protocol/index.js\";\n"]}
@@ -42,8 +42,13 @@ export {
42
42
  // #region @legacyAlpha APIs
43
43
  ContainerAlpha,
44
44
  ILoadFrozenContainerFromPendingStateProps,
45
+ ILoadSummarizerContainerProps,
46
+ LoadSummarizerSummaryResult,
47
+ OnDemandSummaryResults,
48
+ SummaryStage,
45
49
  asLegacyAlpha,
46
50
  createFrozenDocumentServiceFactory,
47
- loadFrozenContainerFromPendingState
51
+ loadFrozenContainerFromPendingState,
52
+ loadSummarizerContainerAndMakeSummary
48
53
  // #endregion
49
54
  } from "./index.js";
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/container-loader";
8
- export declare const pkgVersion = "2.63.0-359962";
8
+ export declare const pkgVersion = "2.70.0-360374";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/container-loader";
8
- export const pkgVersion = "2.63.0-359962";
8
+ export const pkgVersion = "2.70.0-360374";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.63.0-359962\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-loader\";\nexport const pkgVersion = \"2.70.0-360374\";\n"]}
@@ -7,7 +7,7 @@ import type { IEventProvider, IEvent, ITelemetryBaseLogger } from "@fluidframewo
7
7
  import type { IDisposable } from "@fluidframework/core-interfaces/internal";
8
8
  import { type IDocumentStorageService, type IResolvedUrl, type ISnapshot, type IDocumentAttributes, type ISnapshotTree, type IVersion, type ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
9
9
  import { type MonitoringContext } from "@fluidframework/telemetry-utils/internal";
10
- import { type ISerializableBlobContents } from "./containerStorageAdapter.js";
10
+ import { type ContainerStorageAdapter, type ISerializableBlobContents } from "./containerStorageAdapter.js";
11
11
  /**
12
12
  * This is very similar to {@link @fluidframework/protocol-definitions/internal#ISnapshot}, but the difference is
13
13
  * that the blobs of ISnapshot are of type ArrayBufferLike, while the blobs of this interface are serializable because
@@ -95,7 +95,7 @@ interface ISnapshotInfo {
95
95
  snapshotFetchedTime?: number | undefined;
96
96
  snapshot: ISnapshot | ISnapshotTree;
97
97
  }
98
- export type ISerializedStateManagerDocumentStorageService = Pick<IDocumentStorageService, "getSnapshot" | "getSnapshotTree" | "getVersions" | "readBlob"> & {
98
+ export type ISerializedStateManagerDocumentStorageService = Pick<ContainerStorageAdapter, "getSnapshot" | "getSnapshotTree" | "getVersions" | "readBlob" | "cacheSnapshotBlobs"> & {
99
99
  loadedGroupIdSnapshots: Record<string, ISnapshot>;
100
100
  };
101
101
  interface ISerializerEvent extends IEvent {
@@ -1 +1 @@
1
- {"version":3,"file":"serializedStateManager.d.ts","sourceRoot":"","sources":["../src/serializedStateMan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AAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAC,CAwBvE"}
@@ -145,11 +145,12 @@ export class SerializedStateManager {
145
145
  }
146
146
  else {
147
147
  const { baseSnapshot, snapshotBlobs, savedOps } = pendingLocalState;
148
- const attributes = await getDocumentAttributes(this.storageAdapter, baseSnapshot);
149
148
  const blobContents = new Map();
150
149
  for (const [id, value] of Object.entries(snapshotBlobs)) {
151
150
  blobContents.set(id, stringToBuffer(value, "utf8"));
152
151
  }
152
+ this.storageAdapter.cacheSnapshotBlobs(blobContents);
153
+ const attributes = await getDocumentAttributes(this.storageAdapter, baseSnapshot);
153
154
  const snapshot = {
154
155
  sequenceNumber: attributes.sequenceNumber,
155
156
  snapshotTree: baseSnapshot,