@fluidframework/driver-utils 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/.eslintrc.js +17 -19
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/blobAggregationStorage.d.ts +15 -2
  5. package/dist/blobAggregationStorage.d.ts.map +1 -1
  6. package/dist/blobAggregationStorage.js +22 -13
  7. package/dist/blobAggregationStorage.js.map +1 -1
  8. package/dist/blobCacheStorageService.d.ts.map +1 -1
  9. package/dist/blobCacheStorageService.js.map +1 -1
  10. package/dist/buildSnapshotTree.d.ts.map +1 -1
  11. package/dist/buildSnapshotTree.js.map +1 -1
  12. package/dist/documentStorageServiceProxy.d.ts.map +1 -1
  13. package/dist/documentStorageServiceProxy.js.map +1 -1
  14. package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
  15. package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
  16. package/dist/error.d.ts.map +1 -1
  17. package/dist/error.js.map +1 -1
  18. package/dist/fluidResolvedUrl.d.ts.map +1 -1
  19. package/dist/fluidResolvedUrl.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/insecureUrlResolver.d.ts.map +1 -1
  24. package/dist/insecureUrlResolver.js +2 -1
  25. package/dist/insecureUrlResolver.js.map +1 -1
  26. package/dist/mapWithExpiration.d.ts.map +1 -1
  27. package/dist/mapWithExpiration.js +5 -3
  28. package/dist/mapWithExpiration.js.map +1 -1
  29. package/dist/messageRecognition.d.ts.map +1 -1
  30. package/dist/messageRecognition.js.map +1 -1
  31. package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
  32. package/dist/multiDocumentServiceFactory.js.map +1 -1
  33. package/dist/multiUrlResolver.d.ts.map +1 -1
  34. package/dist/multiUrlResolver.js.map +1 -1
  35. package/dist/network.d.ts +1 -1
  36. package/dist/network.d.ts.map +1 -1
  37. package/dist/network.js +4 -3
  38. package/dist/network.js.map +1 -1
  39. package/dist/networkUtils.d.ts.map +1 -1
  40. package/dist/networkUtils.js +2 -3
  41. package/dist/networkUtils.js.map +1 -1
  42. package/dist/packageVersion.d.ts +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/parallelRequests.d.ts.map +1 -1
  46. package/dist/parallelRequests.js +19 -9
  47. package/dist/parallelRequests.js.map +1 -1
  48. package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
  49. package/dist/prefetchDocumentStorageService.js.map +1 -1
  50. package/dist/rateLimiter.d.ts.map +1 -1
  51. package/dist/rateLimiter.js.map +1 -1
  52. package/dist/readAndParse.d.ts.map +1 -1
  53. package/dist/readAndParse.js.map +1 -1
  54. package/dist/runWithRetry.d.ts.map +1 -1
  55. package/dist/runWithRetry.js.map +1 -1
  56. package/dist/summaryForCreateNew.d.ts.map +1 -1
  57. package/dist/summaryForCreateNew.js.map +1 -1
  58. package/dist/treeConversions.d.ts.map +1 -1
  59. package/dist/treeConversions.js +1 -4
  60. package/dist/treeConversions.js.map +1 -1
  61. package/dist/treeUtils.d.ts +10 -10
  62. package/dist/treeUtils.d.ts.map +1 -1
  63. package/dist/treeUtils.js +10 -10
  64. package/dist/treeUtils.js.map +1 -1
  65. package/lib/blobAggregationStorage.d.ts +15 -2
  66. package/lib/blobAggregationStorage.d.ts.map +1 -1
  67. package/lib/blobAggregationStorage.js +22 -13
  68. package/lib/blobAggregationStorage.js.map +1 -1
  69. package/lib/blobCacheStorageService.d.ts.map +1 -1
  70. package/lib/blobCacheStorageService.js.map +1 -1
  71. package/lib/buildSnapshotTree.d.ts.map +1 -1
  72. package/lib/buildSnapshotTree.js.map +1 -1
  73. package/lib/documentStorageServiceProxy.d.ts.map +1 -1
  74. package/lib/documentStorageServiceProxy.js.map +1 -1
  75. package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
  76. package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
  77. package/lib/error.d.ts.map +1 -1
  78. package/lib/error.js.map +1 -1
  79. package/lib/fluidResolvedUrl.d.ts.map +1 -1
  80. package/lib/fluidResolvedUrl.js.map +1 -1
  81. package/lib/index.d.ts +1 -1
  82. package/lib/index.d.ts.map +1 -1
  83. package/lib/index.js +1 -1
  84. package/lib/index.js.map +1 -1
  85. package/lib/insecureUrlResolver.d.ts.map +1 -1
  86. package/lib/insecureUrlResolver.js +2 -1
  87. package/lib/insecureUrlResolver.js.map +1 -1
  88. package/lib/mapWithExpiration.d.ts.map +1 -1
  89. package/lib/mapWithExpiration.js +5 -3
  90. package/lib/mapWithExpiration.js.map +1 -1
  91. package/lib/messageRecognition.d.ts.map +1 -1
  92. package/lib/messageRecognition.js +1 -1
  93. package/lib/messageRecognition.js.map +1 -1
  94. package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
  95. package/lib/multiDocumentServiceFactory.js.map +1 -1
  96. package/lib/multiUrlResolver.d.ts.map +1 -1
  97. package/lib/multiUrlResolver.js.map +1 -1
  98. package/lib/network.d.ts +1 -1
  99. package/lib/network.d.ts.map +1 -1
  100. package/lib/network.js +4 -3
  101. package/lib/network.js.map +1 -1
  102. package/lib/networkUtils.d.ts.map +1 -1
  103. package/lib/networkUtils.js +2 -3
  104. package/lib/networkUtils.js.map +1 -1
  105. package/lib/packageVersion.d.ts +1 -1
  106. package/lib/packageVersion.js +1 -1
  107. package/lib/packageVersion.js.map +1 -1
  108. package/lib/parallelRequests.d.ts.map +1 -1
  109. package/lib/parallelRequests.js +19 -9
  110. package/lib/parallelRequests.js.map +1 -1
  111. package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
  112. package/lib/prefetchDocumentStorageService.js.map +1 -1
  113. package/lib/rateLimiter.d.ts.map +1 -1
  114. package/lib/rateLimiter.js.map +1 -1
  115. package/lib/readAndParse.d.ts.map +1 -1
  116. package/lib/readAndParse.js.map +1 -1
  117. package/lib/runWithRetry.d.ts.map +1 -1
  118. package/lib/runWithRetry.js.map +1 -1
  119. package/lib/summaryForCreateNew.d.ts.map +1 -1
  120. package/lib/summaryForCreateNew.js.map +1 -1
  121. package/lib/treeConversions.d.ts.map +1 -1
  122. package/lib/treeConversions.js +4 -7
  123. package/lib/treeConversions.js.map +1 -1
  124. package/lib/treeUtils.d.ts +10 -10
  125. package/lib/treeUtils.d.ts.map +1 -1
  126. package/lib/treeUtils.js +11 -11
  127. package/lib/treeUtils.js.map +1 -1
  128. package/package.json +43 -64
  129. package/prettier.config.cjs +1 -1
  130. package/src/blobAggregationStorage.ts +380 -324
  131. package/src/blobCacheStorageService.ts +20 -17
  132. package/src/buildSnapshotTree.ts +54 -51
  133. package/src/documentStorageServiceProxy.ts +49 -43
  134. package/src/emptyDocumentDeltaStorageService.ts +11 -10
  135. package/src/error.ts +5 -7
  136. package/src/fluidResolvedUrl.ts +9 -6
  137. package/src/index.ts +5 -1
  138. package/src/insecureUrlResolver.ts +127 -116
  139. package/src/mapWithExpiration.ts +111 -104
  140. package/src/messageRecognition.ts +25 -19
  141. package/src/multiDocumentServiceFactory.ts +73 -62
  142. package/src/multiUrlResolver.ts +26 -29
  143. package/src/network.ts +114 -112
  144. package/src/networkUtils.ts +37 -34
  145. package/src/packageVersion.ts +1 -1
  146. package/src/parallelRequests.ts +571 -509
  147. package/src/prefetchDocumentStorageService.ts +76 -74
  148. package/src/rateLimiter.ts +29 -29
  149. package/src/readAndParse.ts +7 -4
  150. package/src/runWithRetry.ts +105 -94
  151. package/src/summaryForCreateNew.ts +27 -24
  152. package/src/treeConversions.ts +48 -70
  153. package/src/treeUtils.ts +70 -74
  154. package/tsconfig.esnext.json +6 -6
  155. package/tsconfig.json +8 -12
@@ -8,9 +8,10 @@ import { loggerToMonitoringContext } from "@fluidframework/telemetry-utils";
8
8
  /*
9
9
  * Work around for bufferToString having a bug - it can't consume IsoBuffer!
10
10
  * To be removed once bufferToString is fixed!
11
- */
11
+ */
12
12
  function bufferToString2(blob, encoding) {
13
- if (blob instanceof Uint8Array) { // IsoBuffer does not have ctor, so it's not in proto chain :(
13
+ if (blob instanceof Uint8Array) {
14
+ // IsoBuffer does not have ctor, so it's not in proto chain :(
14
15
  return Uint8ArrayToString(blob, encoding);
15
16
  }
16
17
  return bufferToString(blob, encoding);
@@ -36,9 +37,11 @@ class BlobAggregator {
36
37
  return JSON.parse(data);
37
38
  }
38
39
  }
39
- /*
40
+ /**
40
41
  * Base class that deals with unpacking snapshots (in place) containing aggregated blobs
41
42
  * It relies on abstract methods for reads and storing unpacked blobs.
43
+ *
44
+ * @deprecated This class was introduced experimentally and is no longer used.
42
45
  */
43
46
  export class SnapshotExtractor {
44
47
  constructor() {
@@ -109,10 +112,12 @@ class SnapshotExtractorInPlace extends SnapshotExtractor {
109
112
  tree.blobs[id] = fromUtf8ToBase64(content);
110
113
  }
111
114
  }
112
- /*
115
+ /**
113
116
  * Snapshot packer and extractor.
114
117
  * When summary is written it will find and aggregate small blobs into bigger blobs
115
118
  * When snapshot is read, it will unpack aggregated blobs and provide them transparently to caller.
119
+ *
120
+ * @deprecated This class was introduced experimentally and is no longer used.
116
121
  */
117
122
  export class BlobAggregationStorage extends SnapshotExtractor {
118
123
  constructor(storage, logger, allowPacking, packingLevel, blobCutOffSize) {
@@ -164,9 +169,11 @@ export class BlobAggregationStorage extends SnapshotExtractor {
164
169
  throw error;
165
170
  });
166
171
  }
167
- get repositoryUrl() { return this.storage.repositoryUrl; }
168
- async getVersions(versionId, count) {
169
- return this.storage.getVersions(versionId, count);
172
+ get repositoryUrl() {
173
+ return this.storage.repositoryUrl;
174
+ }
175
+ async getVersions(versionId, count, scenarioName, fetchSource) {
176
+ return this.storage.getVersions(versionId, count, scenarioName, fetchSource);
170
177
  }
171
178
  async downloadSummary(handle) {
172
179
  throw new Error("NYI");
@@ -207,12 +214,12 @@ export class BlobAggregationStorage extends SnapshotExtractor {
207
214
  // - data store either reuses previous summary, or generates full summary, i.e. there is no partial (some DDS)
208
215
  // summary produced by data stores.
209
216
  // These simplifications allow us not to touch handles, as they are self-contained (either do not use aggregated
210
- // blob Or contain aggregated blob that stays relevant for that sub-tree)
217
+ // blob or contain aggregated blob that stays relevant for that sub-tree)
211
218
  // Note:
212
- // From perf perspective, it makes sense to place aggregated blobs one level up in the tree not to create extra
219
+ // From perf perspective, it makes sense to place aggregated blobs one level up in the tree to not create extra
213
220
  // tree nodes (i.e. have shallow tree with less edges). But that creates problems with reusability of trees at
214
221
  // incremental summary time - we would need to understand handles and parse them. In current design we can skip
215
- // that step because if data store is reused, the hole sub-tree is reused included aggregated blob embedded into it
222
+ // that step because if data store is reused, the whole sub-tree is reused including aggregated blob embedded into it
216
223
  // and that means we can do nothing and be correct!
217
224
  async compressSmallBlobs(summary, path = "", level = 0, aggregatorArg) {
218
225
  if (this.blobCutOffSize === undefined || this.blobCutOffSize < 0) {
@@ -240,17 +247,19 @@ export class BlobAggregationStorage extends SnapshotExtractor {
240
247
  case SummaryType.Tree:
241
248
  // If client created empty tree, keep it as is
242
249
  // Also do not package search blobs - they are part of storage contract
243
- if (obj.tree !== {} && key !== "__search") {
250
+ if (Object.keys(obj).length !== 0 && key !== "__search") {
244
251
  const tree = await this.compressSmallBlobs(obj, newPath, level + 1, aggregator);
245
252
  newSummary.tree[key] = tree;
246
- if (tree.tree === {}) {
253
+ if (Object.keys(obj).length === 0) {
247
254
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
248
255
  delete newSummary.tree[key];
249
256
  }
250
257
  }
251
258
  break;
252
259
  case SummaryType.Blob:
253
- if (aggregator && typeof obj.content == "string" && obj.content.length < this.blobCutOffSize) {
260
+ if (aggregator &&
261
+ typeof obj.content == "string" &&
262
+ obj.content.length < this.blobCutOffSize) {
254
263
  aggregator.addBlob(newPath, obj.content);
255
264
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
256
265
  delete newSummary.tree[key];
@@ -1 +1 @@
1
- {"version":3,"file":"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gBACD,KAAK,WAAW,CAAC,UAAU;oBACvB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,oCAAoC,CAAC,CAAC;oBACjF,MAAM;gBACV;oBACI,eAAe,CAAC,GAAG,EAAE,iBAAkB,GAAW,CAAC,IAAI,EAAE,CAAC,CAAC;aAClE;SACJ;QAED,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,SAAS,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACvG,IAAI,cAAc,EAAE;YAChB,yFAAyF;YACzF,4FAA4F;YAC5F,qGAAqG;YACrG,iEAAiE;YACjE,+CAA+C;YAC/C,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAC5D,MAAM,OAAO,GAAG,UAAU,CAAC,wBAAwB,EAAE,CAAC;YACtD,IAAI,OAAO,KAAK,SAAS,EAAE;gBACvB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG;oBACvC,IAAI,EAAE,WAAW,CAAC,IAAI;oBACtB,OAAO;iBACV,CAAC;aACL;SACJ;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAES,eAAe,CAAC,EAAU;QAChC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAChD,CAAC;;AAjOD,6FAA6F;AAC7F,8BAA8B;AAC9B,uGAAuG;AACvG,yGAAyG;AACzG,4FAA4F;AAC5F,qGAAqG;AACrG,oGAAoG;AACpG,mCAAmC;AACnC,yGAAyG;AACzG,mFAAmF;AACnE,6CAAsB,GAAG,IAAI,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IDocumentStorageService,\n IDocumentStorageServicePolicies,\n ISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n SummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n assert,\n bufferToString,\n stringToBuffer,\n unreachableCase,\n fromUtf8ToBase64,\n Uint8ArrayToString,\n } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils\";\n\n/*\n * Work around for bufferToString having a bug - it can't consume IsoBuffer!\n * To be removed once bufferToString is fixed!\n*/\nfunction bufferToString2(blob: ArrayBufferLike, encoding: \"utf-8\" | \"base64\"): string {\n if (blob instanceof Uint8Array) { // IsoBuffer does not have ctor, so it's not in proto chain :(\n return Uint8ArrayToString(blob, encoding);\n }\n return bufferToString(blob, encoding);\n}\n\n /**\n * Class responsible for aggregating smaller blobs into one and unpacking it later on.\n */\nclass BlobAggregator {\n private readonly content: [string, string][] = [];\n\n public addBlob(key: string, content: string) {\n this.content.push([key, content]);\n }\n\n public getAggregatedBlobContent() {\n if (this.content.length === 0) {\n return undefined;\n }\n return JSON.stringify(this.content);\n }\n\n static load(input: ArrayBufferLike) {\n const data = bufferToString2(input, \"utf-8\");\n return JSON.parse(data) as [string, string][];\n }\n}\n\n/*\n * Base class that deals with unpacking snapshots (in place) containing aggregated blobs\n * It relies on abstract methods for reads and storing unpacked blobs.\n */\nexport abstract class SnapshotExtractor {\n protected readonly aggregatedBlobName = \"__big\";\n protected readonly virtualIdPrefix = \"__\";\n\n // counter for generation of virtual storage IDs\n protected virtualIdCounter = 0;\n protected getNextVirtualId() {\n return `${this.virtualIdPrefix}${++this.virtualIdCounter}`;\n }\n\n abstract getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike>;\n abstract setBlob(id: string, tree: ISnapshotTree, content: string);\n\n public async unpackSnapshotCore(snapshot: ISnapshotTree, level = 0): Promise<void> {\n for (const key of Object.keys(snapshot.trees)) {\n const obj = snapshot.trees[key];\n await this.unpackSnapshotCore(obj, level + 1);\n }\n\n // For future proof, we will support multiple aggregated blobs with any name\n // that starts with this.aggregatedBlobName\n for (const key of Object.keys(snapshot.blobs)) {\n if (!key.startsWith(this.aggregatedBlobName)) { continue; }\n const blobId = snapshot.blobs[key];\n if (blobId !== undefined) {\n const blob = await this.getBlob(blobId, snapshot);\n for (const [path, value] of BlobAggregator.load(blob)) {\n const id = this.getNextVirtualId();\n this.setBlob(id, snapshot, value);\n const pathSplit = path.split(\"/\");\n let subTree = snapshot;\n for (const subPath of pathSplit.slice(0, pathSplit.length - 1)) {\n if (subTree.trees[subPath] === undefined) {\n subTree.trees[subPath] = { blobs: {}, trees: {} };\n }\n subTree = subTree.trees[subPath];\n }\n const blobName = pathSplit[pathSplit.length - 1];\n assert(subTree.blobs[blobName] === undefined, 0x0f6 /* \"real blob ID exists\" */);\n subTree.blobs[blobName] = id;\n }\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete snapshot.blobs[this.aggregatedBlobName];\n }\n }\n }\n}\n\n/*\n * Snapshot extractor class that works in place, i.e. patches snapshot that has\n * blob content in ISnapshotTree.blobs itself, not in storage.\n * As result, it implements reading and writing of blobs to/from snapshot itself.\n * It follows existing pattern that mixes concerns - ISnapshotTree.blobs is used for two\n * purposes:\n * 1. map path name to blob ID\n * 2. map blob ID to blob content\n * #2 is what storage (IDocumentStorageService) is for, but in places where we do not have it\n * (like loading serialized earlier draft content), blob content is put directly into snapshot.\n * Ideally this should be fixed by using BlobCacheStorageService or something similar and\n * fixing existing flows to allow switching of storage.\n */\nclass SnapshotExtractorInPlace extends SnapshotExtractor {\n public async getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike> {\n const blob = tree.blobs[id];\n assert(blob !== undefined, 0x0f7 /* \"aggregate blob missing\" */);\n return stringToBuffer(blob, \"base64\");\n }\n\n public setBlob(id: string, tree: ISnapshotTree, content: string) {\n assert(tree.blobs[id] === undefined, 0x0f8 /* \"blob from aggregate blob exists on its own\" */);\n tree.blobs[id] = fromUtf8ToBase64(content);\n }\n}\n\n/*\n * Snapshot packer and extractor.\n * When summary is written it will find and aggregate small blobs into bigger blobs\n * When snapshot is read, it will unpack aggregated blobs and provide them transparently to caller.\n */\nexport class BlobAggregationStorage extends SnapshotExtractor implements IDocumentStorageService {\n // Tells data store if it can use incremental summary (i.e. reuse DDSes from previous summary\n // when only one DDS changed).\n // The answer has to be know long before we enable actual packing. The reason for the is the following:\n // A the moment when we enable packing, we should assume that all clients out there wil already have bits\n // that can unpack properly (i.e. enough time passed since we deployed bits that can unpack)\n // But we can still have clients where some of them already pack, and some do not. If one summary was\n // using packing, then it relies on non-incremental summaries going forward, even if next client who\n // produced summary is not packing!\n // This can have slight improvement by enabling it per file (based on \"did summary we loaded from contain\n // aggregated blobs\"), but that's harder to make reliable, so going for simplicity.\n static readonly fullDataStoreSummaries = true;\n\n protected loadedFromSummary = false;\n\n protected virtualBlobs = new Map<string, ArrayBufferLike>();\n\n static wrap(\n storage: IDocumentStorageService,\n logger: ITelemetryLogger,\n allowPacking?: boolean,\n packingLevel = 2,\n ) {\n if (storage instanceof BlobAggregationStorage) {\n return storage;\n }\n const mc = loggerToMonitoringContext(logger);\n const realAllowPackaging = mc.config.getBoolean(\"FluidAggregateBlobs\") ?? allowPacking ?? false;\n\n // Always create BlobAggregationStorage even if storage is not asking for packing.\n // This is mostly to avoid cases where future changes in policy would result in inability to\n // load old files that were created with aggregation on.\n const minBlobSize = storage.policies?.minBlobSize;\n return new BlobAggregationStorage(storage, logger, realAllowPackaging, packingLevel, minBlobSize);\n }\n\n static async unpackSnapshot(snapshot: ISnapshotTree) {\n const converter = new SnapshotExtractorInPlace();\n await converter.unpackSnapshotCore(snapshot);\n }\n\n public get policies(): IDocumentStorageServicePolicies | undefined {\n const policies = this.storage.policies;\n if (policies) {\n return { ...policies, minBlobSize: undefined };\n }\n }\n\n public async unpackSnapshot(snapshot: ISnapshotTree) {\n // SummarizerNodeWithGC.refreshLatestSummary can call it when this.loadedFromSummary === false\n // (I assumed after file was created)\n // assert(!this.loadedFromSummary, \"unpack without summary\");\n\n this.loadedFromSummary = true;\n await this.unpackSnapshotCore(snapshot);\n }\n\n protected constructor(\n private readonly storage: IDocumentStorageService,\n private readonly logger: ITelemetryLogger,\n private readonly allowPacking: boolean,\n private readonly packingLevel: number,\n private readonly blobCutOffSize?: number) {\n super();\n }\n\n public setBlob(id: string, tree: ISnapshotTree, content: string) {\n this.virtualBlobs.set(id, stringToBuffer(content, \"utf-8\"));\n }\n\n public async getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike> {\n return this.readBlob(id).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"BlobDedupNoAggregateBlob\" }, error);\n throw error;\n });\n }\n\n public get repositoryUrl() { return this.storage.repositoryUrl; }\n public async getVersions(versionId: string | null, count: number) {\n return this.storage.getVersions(versionId, count);\n }\n\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n throw new Error(\"NYI\");\n }\n\n // for now we are not optimizing these blobs, with assumption that this API is used only\n // for big blobs (images)\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n return this.storage.createBlob(file);\n }\n\n public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n const tree = await this.storage.getSnapshotTree(version);\n if (tree) {\n await this.unpackSnapshot(tree);\n }\n return tree;\n }\n\n public async readBlob(id: string): Promise<ArrayBufferLike> {\n if (this.isRealStorageId(id)) {\n return this.storage.readBlob(id);\n }\n // We support only reading blobs from the summary we loaded from.\n // This may need to be extended to any general summary in the future as runtime usage pattern\n // of storage changes (for example, data stores start to load from recent summary, not from original\n // summary whole container loaded from)\n\n // are there other ways we can get here? createFile is one flow, but we should not be reading blobs\n // in such flow\n assert(this.loadedFromSummary, 0x0f9 /* \"never read summary\" */);\n const blob = this.virtualBlobs.get(id);\n assert(blob !== undefined, 0x0fa /* \"virtual blob not found\" */);\n return blob;\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n const summaryNew = this.allowPacking ? await this.compressSmallBlobs(summary) : summary;\n return this.storage.uploadSummaryWithContext(summaryNew, context);\n }\n\n // For simplification, we assume that\n // - blob aggregation is done at data store level only for now\n // - data store either reuses previous summary, or generates full summary, i.e. there is no partial (some DDS)\n // summary produced by data stores.\n // These simplifications allow us not to touch handles, as they are self-contained (either do not use aggregated\n // blob Or contain aggregated blob that stays relevant for that sub-tree)\n // Note:\n // From perf perspective, it makes sense to place aggregated blobs one level up in the tree not to create extra\n // tree nodes (i.e. have shallow tree with less edges). But that creates problems with reusability of trees at\n // incremental summary time - we would need to understand handles and parse them. In current design we can skip\n // that step because if data store is reused, the hole sub-tree is reused included aggregated blob embedded into it\n // and that means we can do nothing and be correct!\n private async compressSmallBlobs(\n summary: ISummaryTree,\n path = \"\",\n level = 0,\n aggregatorArg?: BlobAggregator): Promise<ISummaryTree> {\n if (this.blobCutOffSize === undefined || this.blobCutOffSize < 0) {\n return summary;\n }\n\n let shouldCompress: boolean = false;\n\n let aggregator = aggregatorArg;\n // checking if this is a dataStore tree, since we only pack at data store level\n if (Object.keys(summary.tree).includes(\".component\")) {\n assert(aggregator === undefined, 0x0fb /* \"logic err with aggregator\" */);\n assert(level === this.packingLevel, 0x23b /* \"we are not packing at the right level\" */);\n aggregator = new BlobAggregator();\n shouldCompress = true;\n } else {\n assert(level !== this.packingLevel, 0x23c /* \"we are not packing at the right level\" */);\n }\n\n const newSummary: ISummaryTree = { ...summary };\n newSummary.tree = { ...newSummary.tree };\n for (const key of Object.keys(summary.tree)) {\n const obj = summary.tree[key];\n // Get path relative to root of data store (where we do aggregation)\n const newPath = shouldCompress ? key : `${path}/${key}`;\n switch (obj.type) {\n case SummaryType.Tree:\n // If client created empty tree, keep it as is\n // Also do not package search blobs - they are part of storage contract\n if (obj.tree !== {} && key !== \"__search\") {\n const tree = await this.compressSmallBlobs(obj, newPath, level + 1, aggregator);\n newSummary.tree[key] = tree;\n if (tree.tree === {}) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete newSummary.tree[key];\n }\n }\n break;\n case SummaryType.Blob:\n if (aggregator && typeof obj.content == \"string\" && obj.content.length < this.blobCutOffSize) {\n aggregator.addBlob(newPath, obj.content);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete newSummary.tree[key];\n }\n break;\n case SummaryType.Handle: {\n // Would be nice to:\n // Trees: expand the tree\n // Blobs: parse handle and ensure it points to real blob, not virtual blob.\n // We can avoid it for now given data store is the granularity of incremental summaries.\n let handlePath = obj.handle;\n if (handlePath.startsWith(\"/\")) {\n handlePath = handlePath.substr(1);\n }\n // Ensure only whole data stores can be reused, no reusing at deeper level!\n assert(level === 0, 0x0fc /* \"tree reuse at lower level\" */);\n assert(!handlePath.includes(\"/\"),\n 0x0fd /* \"data stores are writing incremental summaries!\" */);\n break;\n }\n case SummaryType.Attachment:\n assert(this.isRealStorageId(obj.id), 0x0fe /* \"attachment is aggregate blob\" */);\n break;\n default:\n unreachableCase(obj, `Unknown type: ${(obj as any).type}`);\n }\n }\n\n assert(newSummary.tree[this.aggregatedBlobName] === undefined, 0x0ff /* \"duplicate aggregate blob\" */);\n if (shouldCompress) {\n // Note: It would be great to add code here to unpack aggregate blob back to normal blobs\n // If only one blob made it into aggregate. Currently that does not happen as we always have\n // at least one .component blob and at least one DDS that has .attributes blob, so it's not an issue.\n // But it's possible that in future that would be great addition!\n // Good news - it's backward compatible change.\n assert(aggregator !== undefined, 0x100 /* \"logic error\" */);\n const content = aggregator.getAggregatedBlobContent();\n if (content !== undefined) {\n newSummary.tree[this.aggregatedBlobName] = {\n type: SummaryType.Blob,\n content,\n };\n }\n }\n return newSummary;\n }\n\n protected isRealStorageId(id: string): boolean {\n return !id.startsWith(this.virtualIdPrefix);\n }\n}\n"]}
1
+ {"version":3,"file":"blobAggregationStorage.js","sourceRoot":"","sources":["../src/blobAggregationStorage.ts"],"names":[],"mappings":"AAAA;;;GA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ACN;gBACD,KAAK,WAAW,CAAC,UAAU;oBAC1B,MAAM,CACL,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,EAC5B,KAAK,CAAC,oCAAoC,CAC1C,CAAC;oBACF,MAAM;gBACP;oBACC,eAAe,CAAC,GAAG,EAAE,iBAAkB,GAAW,CAAC,IAAI,EAAE,CAAC,CAAC;aAC5D;SACD;QAED,MAAM,CACL,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,SAAS,EACtD,KAAK,CAAC,gCAAgC,CACtC,CAAC;QACF,IAAI,cAAc,EAAE;YACnB,yFAAyF;YACzF,4FAA4F;YAC5F,qGAAqG;YACrG,iEAAiE;YACjE,+CAA+C;YAC/C,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAC5D,MAAM,OAAO,GAAG,UAAU,CAAC,wBAAwB,EAAE,CAAC;YACtD,IAAI,OAAO,KAAK,SAAS,EAAE;gBAC1B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG;oBAC1C,IAAI,EAAE,WAAW,CAAC,IAAI;oBACtB,OAAO;iBACP,CAAC;aACF;SACD;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;IAES,eAAe,CAAC,EAAU;QACnC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC7C,CAAC;;AA3QD,6FAA6F;AAC7F,8BAA8B;AAC9B,uGAAuG;AACvG,yGAAyG;AACzG,4FAA4F;AAC5F,qGAAqG;AACrG,oGAAoG;AACpG,mCAAmC;AACnC,yGAAyG;AACzG,mFAAmF;AACnE,6CAAsB,GAAG,IAAI,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tassert,\n\tbufferToString,\n\tstringToBuffer,\n\tunreachableCase,\n\tfromUtf8ToBase64,\n\tUint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils\";\n\n/*\n * Work around for bufferToString having a bug - it can't consume IsoBuffer!\n * To be removed once bufferToString is fixed!\n */\nfunction bufferToString2(blob: ArrayBufferLike, encoding: \"utf-8\" | \"base64\"): string {\n\tif (blob instanceof Uint8Array) {\n\t\t// IsoBuffer does not have ctor, so it's not in proto chain :(\n\t\treturn Uint8ArrayToString(blob, encoding);\n\t}\n\treturn bufferToString(blob, encoding);\n}\n\n/**\n * Class responsible for aggregating smaller blobs into one and unpacking it later on.\n */\nclass BlobAggregator {\n\tprivate readonly content: [string, string][] = [];\n\n\tpublic addBlob(key: string, content: string) {\n\t\tthis.content.push([key, content]);\n\t}\n\n\tpublic getAggregatedBlobContent() {\n\t\tif (this.content.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn JSON.stringify(this.content);\n\t}\n\n\tstatic load(input: ArrayBufferLike) {\n\t\tconst data = bufferToString2(input, \"utf-8\");\n\t\treturn JSON.parse(data) as [string, string][];\n\t}\n}\n\n/**\n * Base class that deals with unpacking snapshots (in place) containing aggregated blobs\n * It relies on abstract methods for reads and storing unpacked blobs.\n *\n * @deprecated This class was introduced experimentally and is no longer used.\n */\nexport abstract class SnapshotExtractor {\n\tprotected readonly aggregatedBlobName = \"__big\";\n\tprotected readonly virtualIdPrefix = \"__\";\n\n\t// counter for generation of virtual storage IDs\n\tprotected virtualIdCounter = 0;\n\tprotected getNextVirtualId() {\n\t\treturn `${this.virtualIdPrefix}${++this.virtualIdCounter}`;\n\t}\n\n\tabstract getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike>;\n\tabstract setBlob(id: string, tree: ISnapshotTree, content: string);\n\n\tpublic async unpackSnapshotCore(snapshot: ISnapshotTree, level = 0): Promise<void> {\n\t\tfor (const key of Object.keys(snapshot.trees)) {\n\t\t\tconst obj = snapshot.trees[key];\n\t\t\tawait this.unpackSnapshotCore(obj, level + 1);\n\t\t}\n\n\t\t// For future proof, we will support multiple aggregated blobs with any name\n\t\t// that starts with this.aggregatedBlobName\n\t\tfor (const key of Object.keys(snapshot.blobs)) {\n\t\t\tif (!key.startsWith(this.aggregatedBlobName)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst blobId = snapshot.blobs[key];\n\t\t\tif (blobId !== undefined) {\n\t\t\t\tconst blob = await this.getBlob(blobId, snapshot);\n\t\t\t\tfor (const [path, value] of BlobAggregator.load(blob)) {\n\t\t\t\t\tconst id = this.getNextVirtualId();\n\t\t\t\t\tthis.setBlob(id, snapshot, value);\n\t\t\t\t\tconst pathSplit = path.split(\"/\");\n\t\t\t\t\tlet subTree = snapshot;\n\t\t\t\t\tfor (const subPath of pathSplit.slice(0, pathSplit.length - 1)) {\n\t\t\t\t\t\tif (subTree.trees[subPath] === undefined) {\n\t\t\t\t\t\t\tsubTree.trees[subPath] = { blobs: {}, trees: {} };\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsubTree = subTree.trees[subPath];\n\t\t\t\t\t}\n\t\t\t\t\tconst blobName = pathSplit[pathSplit.length - 1];\n\t\t\t\t\tassert(\n\t\t\t\t\t\tsubTree.blobs[blobName] === undefined,\n\t\t\t\t\t\t0x0f6 /* \"real blob ID exists\" */,\n\t\t\t\t\t);\n\t\t\t\t\tsubTree.blobs[blobName] = id;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete snapshot.blobs[this.aggregatedBlobName];\n\t\t\t}\n\t\t}\n\t}\n}\n\n/*\n * Snapshot extractor class that works in place, i.e. patches snapshot that has\n * blob content in ISnapshotTree.blobs itself, not in storage.\n * As result, it implements reading and writing of blobs to/from snapshot itself.\n * It follows existing pattern that mixes concerns - ISnapshotTree.blobs is used for two\n * purposes:\n * 1. map path name to blob ID\n * 2. map blob ID to blob content\n * #2 is what storage (IDocumentStorageService) is for, but in places where we do not have it\n * (like loading serialized earlier draft content), blob content is put directly into snapshot.\n * Ideally this should be fixed by using BlobCacheStorageService or something similar and\n * fixing existing flows to allow switching of storage.\n */\nclass SnapshotExtractorInPlace extends SnapshotExtractor {\n\tpublic async getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike> {\n\t\tconst blob = tree.blobs[id];\n\t\tassert(blob !== undefined, 0x0f7 /* \"aggregate blob missing\" */);\n\t\treturn stringToBuffer(blob, \"base64\");\n\t}\n\n\tpublic setBlob(id: string, tree: ISnapshotTree, content: string) {\n\t\tassert(\n\t\t\ttree.blobs[id] === undefined,\n\t\t\t0x0f8 /* \"blob from aggregate blob exists on its own\" */,\n\t\t);\n\t\ttree.blobs[id] = fromUtf8ToBase64(content);\n\t}\n}\n\n/**\n * Snapshot packer and extractor.\n * When summary is written it will find and aggregate small blobs into bigger blobs\n * When snapshot is read, it will unpack aggregated blobs and provide them transparently to caller.\n *\n * @deprecated This class was introduced experimentally and is no longer used.\n */\nexport class BlobAggregationStorage extends SnapshotExtractor implements IDocumentStorageService {\n\t// Tells data store if it can use incremental summary (i.e. reuse DDSes from previous summary\n\t// when only one DDS changed).\n\t// The answer has to be know long before we enable actual packing. The reason for the is the following:\n\t// A the moment when we enable packing, we should assume that all clients out there wil already have bits\n\t// that can unpack properly (i.e. enough time passed since we deployed bits that can unpack)\n\t// But we can still have clients where some of them already pack, and some do not. If one summary was\n\t// using packing, then it relies on non-incremental summaries going forward, even if next client who\n\t// produced summary is not packing!\n\t// This can have slight improvement by enabling it per file (based on \"did summary we loaded from contain\n\t// aggregated blobs\"), but that's harder to make reliable, so going for simplicity.\n\tstatic readonly fullDataStoreSummaries = true;\n\n\tprotected loadedFromSummary = false;\n\n\tprotected virtualBlobs = new Map<string, ArrayBufferLike>();\n\n\tstatic wrap(\n\t\tstorage: IDocumentStorageService,\n\t\tlogger: ITelemetryLogger,\n\t\tallowPacking?: boolean,\n\t\tpackingLevel = 2,\n\t) {\n\t\tif (storage instanceof BlobAggregationStorage) {\n\t\t\treturn storage;\n\t\t}\n\t\tconst mc = loggerToMonitoringContext(logger);\n\t\tconst realAllowPackaging =\n\t\t\tmc.config.getBoolean(\"FluidAggregateBlobs\") ?? allowPacking ?? false;\n\n\t\t// Always create BlobAggregationStorage even if storage is not asking for packing.\n\t\t// This is mostly to avoid cases where future changes in policy would result in inability to\n\t\t// load old files that were created with aggregation on.\n\t\tconst minBlobSize = storage.policies?.minBlobSize;\n\t\treturn new BlobAggregationStorage(\n\t\t\tstorage,\n\t\t\tlogger,\n\t\t\trealAllowPackaging,\n\t\t\tpackingLevel,\n\t\t\tminBlobSize,\n\t\t);\n\t}\n\n\tstatic async unpackSnapshot(snapshot: ISnapshotTree) {\n\t\tconst converter = new SnapshotExtractorInPlace();\n\t\tawait converter.unpackSnapshotCore(snapshot);\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tconst policies = this.storage.policies;\n\t\tif (policies) {\n\t\t\treturn { ...policies, minBlobSize: undefined };\n\t\t}\n\t}\n\n\tpublic async unpackSnapshot(snapshot: ISnapshotTree) {\n\t\t// SummarizerNodeWithGC.refreshLatestSummary can call it when this.loadedFromSummary === false\n\t\t// (I assumed after file was created)\n\t\t// assert(!this.loadedFromSummary, \"unpack without summary\");\n\n\t\tthis.loadedFromSummary = true;\n\t\tawait this.unpackSnapshotCore(snapshot);\n\t}\n\n\tprotected constructor(\n\t\tprivate readonly storage: IDocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t\tprivate readonly allowPacking: boolean,\n\t\tprivate readonly packingLevel: number,\n\t\tprivate readonly blobCutOffSize?: number,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic setBlob(id: string, tree: ISnapshotTree, content: string) {\n\t\tthis.virtualBlobs.set(id, stringToBuffer(content, \"utf-8\"));\n\t}\n\n\tpublic async getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike> {\n\t\treturn this.readBlob(id).catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"BlobDedupNoAggregateBlob\" }, error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tpublic get repositoryUrl() {\n\t\treturn this.storage.repositoryUrl;\n\t}\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t) {\n\t\treturn this.storage.getVersions(versionId, count, scenarioName, fetchSource);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NYI\");\n\t}\n\n\t// for now we are not optimizing these blobs, with assumption that this API is used only\n\t// for big blobs (images)\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.storage.createBlob(file);\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst tree = await this.storage.getSnapshotTree(version);\n\t\tif (tree) {\n\t\t\tawait this.unpackSnapshot(tree);\n\t\t}\n\t\treturn tree;\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tif (this.isRealStorageId(id)) {\n\t\t\treturn this.storage.readBlob(id);\n\t\t}\n\t\t// We support only reading blobs from the summary we loaded from.\n\t\t// This may need to be extended to any general summary in the future as runtime usage pattern\n\t\t// of storage changes (for example, data stores start to load from recent summary, not from original\n\t\t// summary whole container loaded from)\n\n\t\t// are there other ways we can get here? createFile is one flow, but we should not be reading blobs\n\t\t// in such flow\n\t\tassert(this.loadedFromSummary, 0x0f9 /* \"never read summary\" */);\n\t\tconst blob = this.virtualBlobs.get(id);\n\t\tassert(blob !== undefined, 0x0fa /* \"virtual blob not found\" */);\n\t\treturn blob;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryNew = this.allowPacking ? await this.compressSmallBlobs(summary) : summary;\n\t\treturn this.storage.uploadSummaryWithContext(summaryNew, context);\n\t}\n\n\t// For simplification, we assume that\n\t// - blob aggregation is done at data store level only for now\n\t// - data store either reuses previous summary, or generates full summary, i.e. there is no partial (some DDS)\n\t// summary produced by data stores.\n\t// These simplifications allow us not to touch handles, as they are self-contained (either do not use aggregated\n\t// blob or contain aggregated blob that stays relevant for that sub-tree)\n\t// Note:\n\t// From perf perspective, it makes sense to place aggregated blobs one level up in the tree to not create extra\n\t// tree nodes (i.e. have shallow tree with less edges). But that creates problems with reusability of trees at\n\t// incremental summary time - we would need to understand handles and parse them. In current design we can skip\n\t// that step because if data store is reused, the whole sub-tree is reused including aggregated blob embedded into it\n\t// and that means we can do nothing and be correct!\n\tprivate async compressSmallBlobs(\n\t\tsummary: ISummaryTree,\n\t\tpath = \"\",\n\t\tlevel = 0,\n\t\taggregatorArg?: BlobAggregator,\n\t): Promise<ISummaryTree> {\n\t\tif (this.blobCutOffSize === undefined || this.blobCutOffSize < 0) {\n\t\t\treturn summary;\n\t\t}\n\n\t\tlet shouldCompress: boolean = false;\n\n\t\tlet aggregator = aggregatorArg;\n\t\t// checking if this is a dataStore tree, since we only pack at data store level\n\t\tif (Object.keys(summary.tree).includes(\".component\")) {\n\t\t\tassert(aggregator === undefined, 0x0fb /* \"logic err with aggregator\" */);\n\t\t\tassert(\n\t\t\t\tlevel === this.packingLevel,\n\t\t\t\t0x23b /* \"we are not packing at the right level\" */,\n\t\t\t);\n\t\t\taggregator = new BlobAggregator();\n\t\t\tshouldCompress = true;\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tlevel !== this.packingLevel,\n\t\t\t\t0x23c /* \"we are not packing at the right level\" */,\n\t\t\t);\n\t\t}\n\n\t\tconst newSummary: ISummaryTree = { ...summary };\n\t\tnewSummary.tree = { ...newSummary.tree };\n\t\tfor (const key of Object.keys(summary.tree)) {\n\t\t\tconst obj = summary.tree[key];\n\t\t\t// Get path relative to root of data store (where we do aggregation)\n\t\t\tconst newPath = shouldCompress ? key : `${path}/${key}`;\n\t\t\tswitch (obj.type) {\n\t\t\t\tcase SummaryType.Tree:\n\t\t\t\t\t// If client created empty tree, keep it as is\n\t\t\t\t\t// Also do not package search blobs - they are part of storage contract\n\t\t\t\t\tif (Object.keys(obj).length !== 0 && key !== \"__search\") {\n\t\t\t\t\t\tconst tree = await this.compressSmallBlobs(\n\t\t\t\t\t\t\tobj,\n\t\t\t\t\t\t\tnewPath,\n\t\t\t\t\t\t\tlevel + 1,\n\t\t\t\t\t\t\taggregator,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tnewSummary.tree[key] = tree;\n\t\t\t\t\t\tif (Object.keys(obj).length === 0) {\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\t\t\t\tdelete newSummary.tree[key];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase SummaryType.Blob:\n\t\t\t\t\tif (\n\t\t\t\t\t\taggregator &&\n\t\t\t\t\t\ttypeof obj.content == \"string\" &&\n\t\t\t\t\t\tobj.content.length < this.blobCutOffSize\n\t\t\t\t\t) {\n\t\t\t\t\t\taggregator.addBlob(newPath, obj.content);\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\t\t\tdelete newSummary.tree[key];\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase SummaryType.Handle: {\n\t\t\t\t\t// Would be nice to:\n\t\t\t\t\t// Trees: expand the tree\n\t\t\t\t\t// Blobs: parse handle and ensure it points to real blob, not virtual blob.\n\t\t\t\t\t// We can avoid it for now given data store is the granularity of incremental summaries.\n\t\t\t\t\tlet handlePath = obj.handle;\n\t\t\t\t\tif (handlePath.startsWith(\"/\")) {\n\t\t\t\t\t\thandlePath = handlePath.substr(1);\n\t\t\t\t\t}\n\t\t\t\t\t// Ensure only whole data stores can be reused, no reusing at deeper level!\n\t\t\t\t\tassert(level === 0, 0x0fc /* \"tree reuse at lower level\" */);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!handlePath.includes(\"/\"),\n\t\t\t\t\t\t0x0fd /* \"data stores are writing incremental summaries!\" */,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SummaryType.Attachment:\n\t\t\t\t\tassert(\n\t\t\t\t\t\tthis.isRealStorageId(obj.id),\n\t\t\t\t\t\t0x0fe /* \"attachment is aggregate blob\" */,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(obj, `Unknown type: ${(obj as any).type}`);\n\t\t\t}\n\t\t}\n\n\t\tassert(\n\t\t\tnewSummary.tree[this.aggregatedBlobName] === undefined,\n\t\t\t0x0ff /* \"duplicate aggregate blob\" */,\n\t\t);\n\t\tif (shouldCompress) {\n\t\t\t// Note: It would be great to add code here to unpack aggregate blob back to normal blobs\n\t\t\t// If only one blob made it into aggregate. Currently that does not happen as we always have\n\t\t\t// at least one .component blob and at least one DDS that has .attributes blob, so it's not an issue.\n\t\t\t// But it's possible that in future that would be great addition!\n\t\t\t// Good news - it's backward compatible change.\n\t\t\tassert(aggregator !== undefined, 0x100 /* \"logic error\" */);\n\t\t\tconst content = aggregator.getAggregatedBlobContent();\n\t\t\tif (content !== undefined) {\n\t\t\t\tnewSummary.tree[this.aggregatedBlobName] = {\n\t\t\t\t\ttype: SummaryType.Blob,\n\t\t\t\t\tcontent,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn newSummary;\n\t}\n\n\tprotected isRealStorageId(id: string): boolean {\n\t\treturn !id.startsWith(this.virtualIdPrefix);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"blobCacheStorageService.d.ts","sourceRoot":"","sources":["../src/blobCacheStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AAC9G,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,2BAA2B;IAGhE,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADtB,sBAAsB,EAAE,uBAAuB,EAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC;IAKxD,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAEjE;IAEY,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAQ9D"}
1
+ {"version":3,"file":"blobCacheStorageService.d.ts","sourceRoot":"","sources":["../src/blobCacheStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,uBAAuB,EACvB,+BAA+B,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,2BAA2B;IAGtE,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADtB,sBAAsB,EAAE,uBAAuB,EAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC;IAKrD,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAEjE;IAEY,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAQ3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"blobCacheStorageService.js","sourceRoot":"","sources":["../src/blobCacheStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,2BAA2B;IACpE,YACI,sBAA+C,EAC9B,KAAmC;QAEpD,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAFb,UAAK,GAAL,KAAK,CAA8B;IAGxD,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,IAAI,KAAK,SAAS,EAAE;YACpB,OAAO,IAAI,CAAC;SACf;QAED,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentStorageService, IDocumentStorageServicePolicies } from \"@fluidframework/driver-definitions\";\nimport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\n\n/**\n * IDocumentStorageService adapter with pre-cached blobs.\n */\nexport class BlobCacheStorageService extends DocumentStorageServiceProxy {\n constructor(\n internalStorageService: IDocumentStorageService,\n private readonly blobs: Map<string, ArrayBufferLike>,\n ) {\n super(internalStorageService);\n }\n\n public get policies(): IDocumentStorageServicePolicies | undefined {\n return this.internalStorageService.policies;\n }\n\n public async readBlob(id: string): Promise<ArrayBufferLike> {\n const blob = this.blobs.get(id);\n if (blob !== undefined) {\n return blob;\n }\n\n return this.internalStorageService.readBlob(id);\n }\n}\n"]}
1
+ {"version":3,"file":"blobCacheStorageService.js","sourceRoot":"","sources":["../src/blobCacheStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,2BAA2B;IACvE,YACC,sBAA+C,EAC9B,KAAmC;QAEpD,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAFb,UAAK,GAAL,KAAK,CAA8B;IAGrD,CAAC;IAED,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,IAAI,KAAK,SAAS,EAAE;YACvB,OAAO,IAAI,CAAC;SACZ;QAED,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\n\n/**\n * IDocumentStorageService adapter with pre-cached blobs.\n */\nexport class BlobCacheStorageService extends DocumentStorageServiceProxy {\n\tconstructor(\n\t\tinternalStorageService: IDocumentStorageService,\n\t\tprivate readonly blobs: Map<string, ArrayBufferLike>,\n\t) {\n\t\tsuper(internalStorageService);\n\t}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.internalStorageService.policies;\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\tconst blob = this.blobs.get(id);\n\t\tif (blob !== undefined) {\n\t\t\treturn blob;\n\t\t}\n\n\t\treturn this.internalStorageService.readBlob(id);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"buildSnapshotTree.d.ts","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEH,aAAa,EACb,UAAU,EAEb,MAAM,sCAAsC,CAAC;AAiE9C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC7B,OAAO,EAAE,UAAU,EAAE,EACrB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GACtC,aAAa,CAGf"}
1
+ {"version":3,"file":"buildSnapshotTree.d.ts","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,aAAa,EACb,UAAU,EAEV,MAAM,sCAAsC,CAAC;AAoE9C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,UAAU,EAAE,EACrB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GACnC,aAAa,CAGf"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildSnapshotTree.js","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EACH,QAAQ,EAGR,SAAS,GACZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,SAAS,WAAW,CAChB,IAAY,EACZ,WAAyB,EACzB,OAAqC;IAErC,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE;QACjC,MAAM,OAAO,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAE3C,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE;YACnC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC;YAC7B,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,QAA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CAAC;IAC/C,OAAO;QACH,GAAG,EAAE,EAAE;QACP,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,EAAE;KACV,CAAC;AACN,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC7B,OAAqB,EACrB,OAAqC;IAErC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, stringToBuffer } from \"@fluidframework/common-utils\";\nimport * as git from \"@fluidframework/gitresources\";\nimport {\n FileMode,\n ISnapshotTree,\n ITreeEntry,\n TreeEntry,\n} from \"@fluidframework/protocol-definitions\";\nimport { buildHierarchy } from \"@fluidframework/protocol-base\";\nimport { v4 as uuid } from \"uuid\";\n\nfunction flattenCore(\n path: string,\n treeEntries: ITreeEntry[],\n blobMap: Map<string, ArrayBufferLike>,\n): git.ITreeEntry[] {\n const entries: git.ITreeEntry[] = [];\n for (const treeEntry of treeEntries) {\n const subPath = `${path}${treeEntry.path}`;\n\n if (treeEntry.type === TreeEntry.Blob) {\n const blob = treeEntry.value;\n const buffer = stringToBuffer(blob.contents, blob.encoding);\n const id = uuid();\n blobMap.set(id, buffer);\n\n const entry: git.ITreeEntry = {\n mode: FileMode[treeEntry.mode],\n path: subPath,\n sha: id,\n size: 0,\n type: \"blob\",\n url: \"\",\n };\n entries.push(entry);\n } else if (treeEntry.type === TreeEntry.Tree) {\n assert(treeEntry.type === TreeEntry.Tree, 0x101 /* \"Unexpected tree entry type on flatten!\" */);\n const t = treeEntry.value;\n const entry: git.ITreeEntry = {\n mode: FileMode[treeEntry.mode],\n path: subPath,\n sha: \"\",\n size: -1,\n type: \"tree\",\n url: \"\",\n };\n entries.push(entry);\n\n const subTreeEntries = flattenCore(`${subPath}/`, t.entries, blobMap);\n entries.push(...subTreeEntries);\n }\n }\n\n return entries;\n}\n\n/**\n * Create a flatten view of an array of ITreeEntry\n *\n * @param tree - an array of ITreeEntry to flatten\n * @param blobMap - a map of blob's sha1 to content\n * @returns A flatten with of the ITreeEntry\n */\nfunction flatten(tree: ITreeEntry[], blobMap: Map<string, ArrayBufferLike>): git.ITree {\n const entries = flattenCore(\"\", tree, blobMap);\n return {\n sha: \"\",\n tree: entries,\n url: \"\",\n };\n}\n\n/**\n * Build a tree hierarchy base on an array of ITreeEntry\n *\n * @param entries - an array of ITreeEntry to flatten\n * @param blobMap - a map of blob's sha1 to content that gets filled with content from entries\n * NOTE: blobMap's validity is contingent on the returned promise's resolution\n * @returns the hierarchical tree\n */\nexport function buildSnapshotTree(\n entries: ITreeEntry[],\n blobMap: Map<string, ArrayBufferLike>,\n): ISnapshotTree {\n const flattened = flatten(entries, blobMap);\n return buildHierarchy(flattened);\n}\n"]}
1
+ {"version":3,"file":"buildSnapshotTree.js","sourceRoot":"","sources":["../src/buildSnapshotTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EACN,QAAQ,EAGR,SAAS,GACT,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,SAAS,WAAW,CACnB,IAAY,EACZ,WAAyB,EACzB,OAAqC;IAErC,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE;QACpC,MAAM,OAAO,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAE3C,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE;YACtC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC;YAC7B,MAAM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,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,OAAO;QACN,GAAG,EAAE,EAAE;QACP,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,EAAE;KACP,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAChC,OAAqB,EACrB,OAAqC;IAErC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, stringToBuffer } from \"@fluidframework/common-utils\";\nimport * as git from \"@fluidframework/gitresources\";\nimport {\n\tFileMode,\n\tISnapshotTree,\n\tITreeEntry,\n\tTreeEntry,\n} from \"@fluidframework/protocol-definitions\";\nimport { buildHierarchy } from \"@fluidframework/protocol-base\";\nimport { v4 as uuid } from \"uuid\";\n\nfunction flattenCore(\n\tpath: string,\n\ttreeEntries: ITreeEntry[],\n\tblobMap: Map<string, ArrayBufferLike>,\n): git.ITreeEntry[] {\n\tconst entries: git.ITreeEntry[] = [];\n\tfor (const treeEntry of treeEntries) {\n\t\tconst subPath = `${path}${treeEntry.path}`;\n\n\t\tif (treeEntry.type === TreeEntry.Blob) {\n\t\t\tconst blob = treeEntry.value;\n\t\t\tconst buffer = stringToBuffer(blob.contents, blob.encoding);\n\t\t\tconst id = uuid();\n\t\t\tblobMap.set(id, buffer);\n\n\t\t\tconst entry: git.ITreeEntry = {\n\t\t\t\tmode: FileMode[treeEntry.mode],\n\t\t\t\tpath: subPath,\n\t\t\t\tsha: id,\n\t\t\t\tsize: 0,\n\t\t\t\ttype: \"blob\",\n\t\t\t\turl: \"\",\n\t\t\t};\n\t\t\tentries.push(entry);\n\t\t} else if (treeEntry.type === TreeEntry.Tree) {\n\t\t\tassert(\n\t\t\t\ttreeEntry.type === TreeEntry.Tree,\n\t\t\t\t0x101 /* \"Unexpected tree entry type on flatten!\" */,\n\t\t\t);\n\t\t\tconst t = treeEntry.value;\n\t\t\tconst entry: git.ITreeEntry = {\n\t\t\t\tmode: FileMode[treeEntry.mode],\n\t\t\t\tpath: subPath,\n\t\t\t\tsha: \"\",\n\t\t\t\tsize: -1,\n\t\t\t\ttype: \"tree\",\n\t\t\t\turl: \"\",\n\t\t\t};\n\t\t\tentries.push(entry);\n\n\t\t\tconst subTreeEntries = flattenCore(`${subPath}/`, t.entries, blobMap);\n\t\t\tentries.push(...subTreeEntries);\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Create a flatten view of an array of ITreeEntry\n *\n * @param tree - an array of ITreeEntry to flatten\n * @param blobMap - a map of blob's sha1 to content\n * @returns A flatten with of the ITreeEntry\n */\nfunction flatten(tree: ITreeEntry[], blobMap: Map<string, ArrayBufferLike>): git.ITree {\n\tconst entries = flattenCore(\"\", tree, blobMap);\n\treturn {\n\t\tsha: \"\",\n\t\ttree: entries,\n\t\turl: \"\",\n\t};\n}\n\n/**\n * Build a tree hierarchy base on an array of ITreeEntry\n *\n * @param entries - an array of ITreeEntry to flatten\n * @param blobMap - a map of blob's sha1 to content that gets filled with content from entries\n * NOTE: blobMap's validity is contingent on the returned promise's resolution\n * @returns the hierarchical tree\n */\nexport function buildSnapshotTree(\n\tentries: ITreeEntry[],\n\tblobMap: Map<string, ArrayBufferLike>,\n): ISnapshotTree {\n\tconst flattened = flatten(entries, blobMap);\n\treturn buildHierarchy(flattened);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"documentStorageServiceProxy.d.ts","sourceRoot":"","sources":["../src/documentStorageServiceProxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,WAAW,EACX,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,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O,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAClE,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IACrD,CAAC;IAIM,KAAK,CAAC,eAAe,CAAC,OAAkB,EAAE,YAAqB;QAClE,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC;IAEM,KAAK,CAAC,WAAW,CACpB,SAAwB,EACxB,KAAa,EACb,YAAqB,EACrB,WAAyB;QAEzB,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAChG,CAAC;IAEM,KAAK,CAAC,wBAAwB,CAAC,OAAqB,EAAE,OAAwB;QACjF,OAAO,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAC/C,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QACzC,OAAO,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAAc;QAChC,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n FetchSource,\n IDocumentStorageService,\n IDocumentStorageServicePolicies,\n ISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n} from \"@fluidframework/protocol-definitions\";\n\nexport class DocumentStorageServiceProxy implements IDocumentStorageService {\n private _policies: IDocumentStorageServicePolicies | undefined;\n\n public set policies(policies: IDocumentStorageServicePolicies | undefined) {\n this._policies = policies;\n }\n\n public get policies() {\n return this._policies ?? this.internalStorageService.policies;\n }\n\n public get repositoryUrl(): string {\n return this.internalStorageService.repositoryUrl;\n }\n\n constructor(protected readonly internalStorageService: IDocumentStorageService) { }\n\n public async getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null> {\n return this.internalStorageService.getSnapshotTree(version, scenarioName);\n }\n\n public async getVersions(\n versionId: string | null,\n count: number,\n scenarioName?: string,\n fetchSource?: FetchSource,\n ): Promise<IVersion[]> {\n return this.internalStorageService.getVersions(versionId, count, scenarioName, fetchSource);\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n return this.internalStorageService.uploadSummaryWithContext(summary, context);\n }\n\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n return this.internalStorageService.downloadSummary(handle);\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n return this.internalStorageService.createBlob(file);\n }\n\n public async readBlob(blobId: string): Promise<ArrayBufferLike> {\n return this.internalStorageService.readBlob(blobId);\n }\n}\n"]}
1
+ {"version":3,"file":"documentStorageServiceProxy.js","sourceRoot":"","sources":["../src/documentStorageServiceProxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,MAAM,OAAO,2BAA2B;IAevC,YAA+B,sBAA+C;QAA/C,2BAAsB,GAAtB,sBAAsB,CAAyB;IAAG,CAAC;IAZlF,IAAW,QAAQ,CAAC,QAAqD;QACxE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAW,QAAQ;;QAClB,OAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC/D,CAAC;IAED,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IAClD,CAAC;IAIM,KAAK,CAAC,eAAe,CAC3B,OAAkB,EAClB,YAAqB;QAErB,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC3E,CAAC;IAEM,KAAK,CAAC,WAAW,CACvB,SAAwB,EACxB,KAAa,EACb,YAAqB,EACrB,WAAyB;QAEzB,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC7F,CAAC;IAEM,KAAK,CAAC,wBAAwB,CACpC,OAAqB,EACrB,OAAwB;QAExB,OAAO,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,OAAO,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAAc;QACnC,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\n\nexport class DocumentStorageServiceProxy implements IDocumentStorageService {\n\tprivate _policies: IDocumentStorageServicePolicies | undefined;\n\n\tpublic set policies(policies: IDocumentStorageServicePolicies | undefined) {\n\t\tthis._policies = policies;\n\t}\n\n\tpublic get policies() {\n\t\treturn this._policies ?? this.internalStorageService.policies;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this.internalStorageService.repositoryUrl;\n\t}\n\n\tconstructor(protected readonly internalStorageService: IDocumentStorageService) {}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.internalStorageService.getSnapshotTree(version, scenarioName);\n\t}\n\n\tpublic async getVersions(\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.internalStorageService.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.internalStorageService.uploadSummaryWithContext(summary, context);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.internalStorageService.downloadSummary(handle);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.internalStorageService.createBlob(file);\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.internalStorageService.readBlob(blobId);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"emptyDocumentDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/emptyDocumentDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF;;GAEG;AACH,qBAAa,gCAAiC,YAAW,4BAA4B;IAC1E,aAAa,CAAC,IAAI,EAAE,MAAM,EAC7B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,YAAY,CAAC,EAAE,WAAW,EAC1B,WAAW,CAAC,EAAE,OAAO,EACrB,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,yBAAyB,EAAE,CAAC;CAK1C"}
1
+ {"version":3,"file":"emptyDocumentDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/emptyDocumentDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF;;GAEG;AACH,qBAAa,gCAAiC,YAAW,4BAA4B;IAC7E,aAAa,CACnB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,YAAY,CAAC,EAAE,WAAW,EAC1B,WAAW,CAAC,EAAE,OAAO,EACrB,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,yBAAyB,EAAE,CAAC;CAKvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"emptyDocumentDeltaStorageService.js","sourceRoot":"","sources":["../src/emptyDocumentDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,gCAAgC;IAClC,aAAa,CAAC,IAAY,EAC7B,GAAuB,EACvB,YAA0B,EAC1B,WAAqB,EACrB,YAAqB;QAErB,MAAM,KAAK,GAAG,IAAI,KAAK,EAA+B,CAAC;QACvD,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { Queue } from \"./parallelRequests\";\n\n/**\n * Implementation of IDocumentDeltaStorageService that will always return an empty message queue when fetching messages\n */\nexport class EmptyDocumentDeltaStorageService implements IDocumentDeltaStorageService {\n public fetchMessages(from: number,\n _to: number | undefined,\n _abortSignal?: AbortSignal,\n _cachedOnly?: boolean,\n _fetchReason?: string,\n ): IStream<ISequencedDocumentMessage[]> {\n const queue = new Queue<ISequencedDocumentMessage[]>();\n queue.pushDone();\n return queue;\n }\n}\n"]}
1
+ {"version":3,"file":"emptyDocumentDeltaStorageService.js","sourceRoot":"","sources":["../src/emptyDocumentDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,gCAAgC;IACrC,aAAa,CACnB,IAAY,EACZ,GAAuB,EACvB,YAA0B,EAC1B,WAAqB,EACrB,YAAqB;QAErB,MAAM,KAAK,GAAG,IAAI,KAAK,EAA+B,CAAC;QACvD,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { Queue } from \"./parallelRequests\";\n\n/**\n * Implementation of IDocumentDeltaStorageService that will always return an empty message queue when fetching messages\n */\nexport class EmptyDocumentDeltaStorageService implements IDocumentDeltaStorageService {\n\tpublic fetchMessages(\n\t\tfrom: number,\n\t\t_to: number | undefined,\n\t\t_abortSignal?: AbortSignal,\n\t\t_cachedOnly?: boolean,\n\t\t_fetchReason?: string,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\tconst queue = new Queue<ISequencedDocumentMessage[]>();\n\t\tqueue.pushDone();\n\t\treturn queue;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEhF,0FAA0F;AAC1F,qBAAa,UAAW,SAAQ,YAAa,YAAW,gBAAgB,EAAE,eAAe;IACrF,QAAQ,CAAC,SAAS,8BAA8B;IAChD,QAAQ,CAAC,QAAQ,SAAS;gBAGtB,OAAO,EAAE,MAAM;CAItB"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEhF,0FAA0F;AAC1F,qBAAa,UAAW,SAAQ,YAAa,YAAW,gBAAgB,EAAE,eAAe;IACxF,QAAQ,CAAC,SAAS,8BAA8B;IAChD,QAAQ,CAAC,QAAQ,SAAS;gBAEd,OAAO,EAAE,MAAM;CAG3B"}
package/lib/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAoB,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAmB,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEhF,0FAA0F;AAC1F,MAAM,OAAO,UAAW,SAAQ,YAAY;IAIxC,YACI,OAAe;QAEf,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QANhC,cAAS,GAAG,eAAe,CAAC,UAAU,CAAC;QACvC,aAAQ,GAAG,KAAK,CAAC;IAM1B,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DriverErrorType, IDriverErrorBase } from \"@fluidframework/driver-definitions\";\nimport { IFluidErrorBase, LoggingError } from \"@fluidframework/telemetry-utils\";\n\n/** Error indicating an API is being used improperly resulting in an invalid operation. */\nexport class UsageError extends LoggingError implements IDriverErrorBase, IFluidErrorBase {\n readonly errorType = DriverErrorType.usageError;\n readonly canRetry = false;\n\n constructor(\n message: string,\n ) {\n super(message, { usageError: true });\n }\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAoB,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAmB,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEhF,0FAA0F;AAC1F,MAAM,OAAO,UAAW,SAAQ,YAAY;IAI3C,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAJ7B,cAAS,GAAG,eAAe,CAAC,UAAU,CAAC;QACvC,aAAQ,GAAG,KAAK,CAAC;IAI1B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DriverErrorType, IDriverErrorBase } from \"@fluidframework/driver-definitions\";\nimport { IFluidErrorBase, LoggingError } from \"@fluidframework/telemetry-utils\";\n\n/** Error indicating an API is being used improperly resulting in an invalid operation. */\nexport class UsageError extends LoggingError implements IDriverErrorBase, IFluidErrorBase {\n\treadonly errorType = DriverErrorType.usageError;\n\treadonly canRetry = false;\n\n\tconstructor(message: string) {\n\t\tsuper(message, { usageError: true });\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fluidResolvedUrl.d.ts","sourceRoot":"","sources":["../src/fluidResolvedUrl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAErF,eAAO,MAAM,kBAAkB,aAChB,YAAY,GAAG,SAAS,kCAA8D,CAAC;AAEtG,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC,QAAQ,IAAI,iBAAiB,CAIhH"}
1
+ {"version":3,"file":"fluidResolvedUrl.d.ts","sourceRoot":"","sources":["../src/fluidResolvedUrl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAErF,eAAO,MAAM,kBAAkB,aACpB,YAAY,GAAG,SAAS,kCAC2B,CAAC;AAE/D,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,YAAY,GAAG,SAAS,GAChC,OAAO,CAAC,QAAQ,IAAI,iBAAiB,CAIvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fluidResolvedUrl.js","sourceRoot":"","sources":["../src/fluidResolvedUrl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,CAAC,MAAM,kBAAkB,GAC3B,CAAC,QAAkC,EAAiC,EAAE,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,OAAO,CAAC;AAEtG,MAAM,UAAU,sBAAsB,CAAC,QAAkC;IACrE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,CAAC,CAAC;KAC3E;AACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl, IFluidResolvedUrl } from \"@fluidframework/driver-definitions\";\n\nexport const isFluidResolvedUrl =\n (resolved: IResolvedUrl | undefined): resolved is IFluidResolvedUrl => resolved?.type === \"fluid\";\n\nexport function ensureFluidResolvedUrl(resolved: IResolvedUrl | undefined): asserts resolved is IFluidResolvedUrl {\n if (!isFluidResolvedUrl(resolved)) {\n throw new Error(`resolved is not a Fluid url. Type: ${resolved?.type}`);\n }\n}\n"]}
1
+ {"version":3,"file":"fluidResolvedUrl.js","sourceRoot":"","sources":["../src/fluidResolvedUrl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CACjC,QAAkC,EACF,EAAE,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,OAAO,CAAC;AAE/D,MAAM,UAAU,sBAAsB,CACrC,QAAkC;IAElC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,CAAC,CAAC;KACxE;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl, IFluidResolvedUrl } from \"@fluidframework/driver-definitions\";\n\nexport const isFluidResolvedUrl = (\n\tresolved: IResolvedUrl | undefined,\n): resolved is IFluidResolvedUrl => resolved?.type === \"fluid\";\n\nexport function ensureFluidResolvedUrl(\n\tresolved: IResolvedUrl | undefined,\n): asserts resolved is IFluidResolvedUrl {\n\tif (!isFluidResolvedUrl(resolved)) {\n\t\tthrow new Error(`resolved is not a Fluid url. Type: ${resolved?.type}`);\n\t}\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -23,5 +23,5 @@ export { readAndParse } from "./readAndParse";
23
23
  export { IProgress, runWithRetry } from "./runWithRetry";
24
24
  export { combineAppAndProtocolSummary, getDocAttributesFromProtocolSummary, getQuorumValuesFromProtocolSummary, } from "./summaryForCreateNew";
25
25
  export { convertSummaryTreeToSnapshotITree } from "./treeConversions";
26
- export { convertSnapshotAndBlobsToSummaryTree, ISummaryTreeAssemblerProps, SummaryTreeAssembler } from "./treeUtils";
26
+ export { convertSnapshotAndBlobsToSummaryTree, ISummaryTreeAssemblerProps, SummaryTreeAssembler, } from "./treeUtils";
27
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACN,uBAAuB,EACvB,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,mCAAmC,EACnC,yBAAyB,EACzB,uBAAuB,EACvB,m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AAC"}
package/lib/index.js CHANGED
@@ -23,5 +23,5 @@ export { readAndParse } from "./readAndParse";
23
23
  export { runWithRetry } from "./runWithRetry";
24
24
  export { combineAppAndProtocolSummary, getDocAttributesFromProtocolSummary, getQuorumValuesFromProtocolSummary, } from "./summaryForCreateNew";
25
25
  export { convertSummaryTreeToSnapshotITree } from "./treeConversions";
26
- export { convertSnapshotAndBlobsToSummaryTree, SummaryTreeAssembler } from "./treeUtils";
26
+ export { convertSnapshotAndBlobsToSummaryTree, SummaryTreeAssembler, } from "./treeUtils";
27
27
  //# sourceMappingURL=index.js.map
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,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACN,uBAAuB,EACvB,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,mCAAmC,EAEnC,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAE7B,QAAQ,EACR,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,eAAe,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,cAAc,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAa,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACN,4BAA4B,EAC5B,mCAAmC,EACnC,kCAAkC,GAClC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAA8B,oBAAoB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { BlobAggregationStorage, SnapshotExtractor } from \"./blobAggregationStorage\";\nexport { BlobCacheStorageService } from \"./blobCacheStorageService\";\nexport { buildSnapshotTree } from \"./buildSnapshotTree\";\nexport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\nexport { EmptyDocumentDeltaStorageService } from \"./emptyDocumentDeltaStorageService\";\nexport { UsageError } from \"./error\";\nexport { ensureFluidResolvedUrl, isFluidResolvedUrl } from \"./fluidResolvedUrl\";\nexport { InsecureUrlResolver } from \"./insecureUrlResolver\";\nexport { MapWithExpiration } from \"./mapWithExpiration\";\nexport {\n\tcanBeCoalescedByService,\n\tisRuntimeMessage,\n\tisUnpackedRuntimeMessage,\n\tMessageType2,\n} from \"./messageRecognition\";\nexport { MultiDocumentServiceFactory } from \"./multiDocumentServiceFactory\";\nexport { configurableUrlResolver, MultiUrlResolver } from \"./multiUrlResolver\";\nexport {\n\tAuthorizationError,\n\tcanRetryOnError,\n\tcreateGenericNetworkError,\n\tcreateWriteError,\n\tDeltaStreamConnectionForbiddenError,\n\tDriverErrorTelemetryProps,\n\tFluidInvalidSchemaError,\n\tGenericNetworkError,\n\tgetRetryDelayFromError,\n\tgetRetryDelaySecondsFromError,\n\tIAnyDriverError,\n\tisOnline,\n\tLocationRedirectionError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tThrottlingError,\n} from \"./network\";\nexport { logNetworkFailure, waitForConnectedState } from \"./networkUtils\";\nexport {\n\temptyMessageStream,\n\tParallelRequests,\n\tQueue,\n\trequestOps,\n\tstreamFromMessages,\n\tstreamObserver,\n} from \"./parallelRequests\";\nexport { PrefetchDocumentStorageService } from \"./prefetchDocumentStorageService\";\nexport { RateLimiter } from \"./rateLimiter\";\nexport { readAndParse } from \"./readAndParse\";\nexport { IProgress, runWithRetry } from \"./runWithRetry\";\nexport {\n\tcombineAppAndProtocolSummary,\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n} from \"./summaryForCreateNew\";\nexport { convertSummaryTreeToSnapshotITree } from \"./treeConversions\";\nexport { convertSnapshotAndBlobsToSummaryTree, ISummaryTreeAssemblerProps, SummaryTreeAssembler } from \"./treeUtils\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE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C;AACzD,OAAO,EACN,4BAA4B,EAC5B,mCAAmC,EACnC,kCAAkC,GAClC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACN,oCAAoC,EAEpC,oBAAoB,GACpB,MAAM,aAAa,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { BlobAggregationStorage, SnapshotExtractor } from \"./blobAggregationStorage\";\nexport { BlobCacheStorageService } from \"./blobCacheStorageService\";\nexport { buildSnapshotTree } from \"./buildSnapshotTree\";\nexport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\nexport { EmptyDocumentDeltaStorageService } from \"./emptyDocumentDeltaStorageService\";\nexport { UsageError } from \"./error\";\nexport { ensureFluidResolvedUrl, isFluidResolvedUrl } from \"./fluidResolvedUrl\";\nexport { InsecureUrlResolver } from \"./insecureUrlResolver\";\nexport { MapWithExpiration } from \"./mapWithExpiration\";\nexport {\n\tcanBeCoalescedByService,\n\tisRuntimeMessage,\n\tisUnpackedRuntimeMessage,\n\tMessageType2,\n} from \"./messageRecognition\";\nexport { MultiDocumentServiceFactory } from \"./multiDocumentServiceFactory\";\nexport { configurableUrlResolver, MultiUrlResolver } from \"./multiUrlResolver\";\nexport {\n\tAuthorizationError,\n\tcanRetryOnError,\n\tcreateGenericNetworkError,\n\tcreateWriteError,\n\tDeltaStreamConnectionForbiddenError,\n\tDriverErrorTelemetryProps,\n\tFluidInvalidSchemaError,\n\tGenericNetworkError,\n\tgetRetryDelayFromError,\n\tgetRetryDelaySecondsFromError,\n\tIAnyDriverError,\n\tisOnline,\n\tLocationRedirectionError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tThrottlingError,\n} from \"./network\";\nexport { logNetworkFailure, waitForConnectedState } from \"./networkUtils\";\nexport {\n\temptyMessageStream,\n\tParallelRequests,\n\tQueue,\n\trequestOps,\n\tstreamFromMessages,\n\tstreamObserver,\n} from \"./parallelRequests\";\nexport { PrefetchDocumentStorageService } from \"./prefetchDocumentStorageService\";\nexport { RateLimiter } from \"./rateLimiter\";\nexport { readAndParse } from \"./readAndParse\";\nexport { IProgress, runWithRetry } from \"./runWithRetry\";\nexport {\n\tcombineAppAndProtocolSummary,\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n} from \"./summaryForCreateNew\";\nexport { convertSummaryTreeToSnapshotITree } from \"./treeConversions\";\nexport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tISummaryTreeAssemblerProps,\n\tSummaryTreeAssembler,\n} from \"./treeUtils\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"insecureUrlResolver.d.ts","sourceRoot":"","sources":["../src/insecureUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAEH,YAAY,EACZ,YAAY,EAEf,MAAM,oCAAoC,CAAC;AAG5C;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAoB,YAAW,YAAY;IAIhD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IARlC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4C;gBAG7C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,aAAa,GAAE,OAAe;IAGtC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IA2C1E,OAAO,CAAC,aAAa;IA2CR,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBrF,sBAAsB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ;CAU7D"}
1
+ {"version":3,"file":"insecureUrlResolver.d.ts","sourceRoot":"","sources":["../src/insecureUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAEN,YAAY,EACZ,YAAY,EAEZ,MAAM,oCAAoC,CAAC;AAG5C;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAoB,YAAW,YAAY;IAItD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAR/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4C;gBAGhD,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,aAAa,GAAE,OAAe;IAGnC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IA+C1E,OAAO,CAAC,aAAa;IAiDR,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBrF,sBAAsB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ;CAU1D"}
@@ -93,7 +93,8 @@ export class InsecureUrlResolver {
93
93
  }
94
94
  const encodedDocId = encodeURIComponent(documentId);
95
95
  const relativePath = !documentRelativePath || documentRelativePath.startsWith("/")
96
- ? documentRelativePath : `/${documentRelativePath}`;
96
+ ? documentRelativePath
97
+ : `/${documentRelativePath}`;
97
98
  const documentUrl = `fluid://${host}/${encodedTenantId}/${encodedDocId}${relativePath}${queryParams}`;
98
99
  const deltaStorageUrl = `${this.ordererUrl}/deltas/${encodedTenantId}/${encodedDocId}`;
99
100
  const storageUrl = `${this.storageUrl}/repos/${encodedTenantId}`;
@@ -1 +1 @@
1
- {"version":3,"file":"insecureUrlResolver.js","sourceRoot":"","sources":["../src/insecureUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAIH,YAAY,GACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,mBAAmB;IAG5B,YACqB,OAAe,EACf,UAAkB,EAClB,UAAkB,EAClB,QAAgB,EAChB,MAAc,EACd,gBAAyB,KAAK;QAL9B,YAAO,GAAP,OAAO,CAAQ;QACf,eAAU,GAAV,UAAU,CAAQ;QAClB,eAAU,GAAV,UAAU,CAAQ;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,kBAAa,GAAb,aAAa,CAAiB;QARlC,UAAK,GAAG,IAAI,GAAG,EAAiC,CAAC;IAS9D,CAAC;IAEE,KAAK,CAAC,OAAO,CAAC,OAAiB;;QAClC,yEAAyE;QACzE,IAAI,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,SAAS,CAAC,EAAE;YAC3C,MAAM,CAAC,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/C,MAAM,YAAY,GAAG,IAAI,eA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AAI,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAAC,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC;IAClE,CAAC;IAEM,sBAAsB,CAAC,QAAiB;QAC3C,MAAM,gBAAgB,GAAa;YAC/B,yEAAyE;YACzE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,aAAa,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;YACrE,OAAO,EAAE;gBACL,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI;aACjC;SACJ,CAAC;QACF,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n IFluidResolvedUrl,\n IResolvedUrl,\n IUrlResolver,\n DriverHeader,\n} from \"@fluidframework/driver-definitions\";\nimport Axios from \"axios\";\n\n/**\n * As the name implies this is not secure and should not be used in production. It simply makes the example easier\n * to get up and running.\n *\n * In our example we run a simple web server via webpack-dev-server. This defines a URL format of the form\n * http://localhost:8080/<documentId>/<path>.\n *\n * We then need to map that to a Fluid based URL. These are of the form\n * fluid://orderingUrl/<tenantId>/<documentId>/<path>.\n *\n * The tenantId/documentId pair defines the 'full' document ID the service makes use of. The path is then an optional\n * part of the URL that the document interprets and maps to a data store. It's exactly similar to how a web service\n * works or a router inside of a single page app framework.\n */\nexport class InsecureUrlResolver implements IUrlResolver {\n private readonly cache = new Map<string, Promise<IResolvedUrl>>();\n\n constructor(\n private readonly hostUrl: string,\n private readonly ordererUrl: string,\n private readonly storageUrl: string,\n private readonly tenantId: string,\n private readonly bearer: string,\n private readonly isForNodeTest: boolean = false,\n ) { }\n\n public async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (request.headers?.[DriverHeader.createNew]) {\n const [, queryString] = request.url.split(\"?\");\n const searchParams = new URLSearchParams(queryString);\n const fileName = searchParams.get(\"fileName\");\n return this.resolveHelper(fileName);\n }\n const parsedUrl = new URL(request.url);\n // If hosts match then we use the local tenant information. Otherwise we make a REST call out to the hosting\n // service using our bearer token.\n if (this.isForNodeTest) {\n const [, documentId, tmpRelativePath] = parsedUrl.pathname.substr(1).split(\"/\");\n const relativePath = tmpRelativePath === undefined ? \"\" : tmpRelativePath;\n return this.resolveHelper(documentId, relativePath, parsedUrl.search);\n } else if (parsedUrl.host === window.location.host) {\n const fullPath = parsedUrl.pathname.substr(1);\n const documentId = fullPath.split(\"/\")[0];\n const documentRelativePath = fullPath.slice(documentId.length);\n return this.resolveHelper(documentId, documentRelativePath);\n } else {\n const maybeResolvedUrl = this.cache.get(request.url);\n if (maybeResolvedUrl) {\n return maybeResolvedUrl;\n }\n\n const headers = {\n Authorization: `Bearer ${this.bearer}`,\n };\n const resolvedP = Axios.post<IResolvedUrl>(\n `${this.hostUrl}/api/v1/load`,\n {\n url: request.url,\n },\n {\n headers,\n });\n this.cache.set(request.url, resolvedP.then((resolved) => resolved.data));\n\n return this.cache.get(request.url);\n }\n }\n\n private resolveHelper(documentId: string | null, documentRelativePath: string = \"\", queryParams: string = \"\") {\n const encodedTenantId = encodeURIComponent(this.tenantId);\n const host = new URL(this.ordererUrl).host;\n // when the document ID is not provided we need to resolve a special create new document URL.\n // the actual container ID will be generated by the driver.\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (!documentId) {\n const createNewResponse: IFluidResolvedUrl = {\n endpoints: {\n deltaStorageUrl: `${this.ordererUrl}/deltas/${encodedTenantId}/new`,\n ordererUrl: this.ordererUrl,\n storageUrl: `${this.storageUrl}/repos/${encodedTenantId}`,\n },\n // document ID is ignored by the driver for new container requests\n id: \"\",\n tokens: {},\n type: \"fluid\",\n url: `fluid://${host}/${encodedTenantId}/new`,\n };\n return createNewResponse;\n }\n const encodedDocId = encodeURIComponent(documentId);\n const relativePath = !documentRelativePath || documentRelativePath.startsWith(\"/\")\n ? documentRelativePath : `/${documentRelativePath}`;\n const documentUrl = `fluid://${host}/${encodedTenantId}/${encodedDocId}${relativePath}${queryParams}`;\n\n const deltaStorageUrl = `${this.ordererUrl}/deltas/${encodedTenantId}/${encodedDocId}`;\n const storageUrl = `${this.storageUrl}/repos/${encodedTenantId}`;\n\n const response: IFluidResolvedUrl = {\n endpoints: {\n deltaStorageUrl,\n ordererUrl: this.ordererUrl,\n storageUrl,\n },\n id: documentId,\n tokens: {},\n type: \"fluid\",\n url: documentUrl,\n };\n return response;\n }\n\n public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n const fluidResolvedUrl = resolvedUrl as IFluidResolvedUrl;\n\n const parsedUrl = parse(fluidResolvedUrl.url);\n const [, , documentId] = parsedUrl.pathname?.split(\"/\") ?? [];\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n assert(!!documentId, 0x273 /* \"Invalid document id from parsed URL\" */);\n\n let url = relativeUrl;\n if (url.startsWith(\"/\")) {\n url = url.substr(1);\n }\n\n return `${this.hostUrl}/${encodeURIComponent(\n this.tenantId)}/${encodeURIComponent(documentId)}/${url}`;\n }\n\n public createCreateNewRequest(fileName?: string): IRequest {\n const createNewRequest: IRequest = {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n url: fileName ? `${this.hostUrl}?fileName=${fileName}` : this.hostUrl,\n headers: {\n [DriverHeader.createNew]: true,\n },\n };\n return createNewRequest;\n }\n}\n"]}
1
+ {"version":3,"file":"insecureUrlResolver.js","sourceRoot":"","sources":["../src/insecureUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAIN,YAAY,GACZ,M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EAAE;YACV,IAAI,EAAE,OAAO;YACb,GAAG,EAAE,WAAW;SAChB,CAAC;QACF,OAAO,QAAQ,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,WAAyB,EAAE,WAAmB;;QACzE,MAAM,gBAAgB,GAAG,WAAgC,CAAC;QAE1D,MAAM,SAAS,GAAG,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,CAAC,EAAE,AAAD,EAAG,UAAU,CAAC,GAAG,MAAA,MAAA,SAAS,CAAC,QAAQ,0CAAE,KAAK,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;QAC9D,yEAAyE;QACzE,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAExE,IAAI,GAAG,GAAG,WAAW,CAAC;QACtB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACxB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACpB;QAED,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,kBAAkB,CAChF,UAAU,CACV,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;IAEM,sBAAsB,CAAC,QAAiB;QAC9C,MAAM,gBAAgB,GAAa;YAClC,yEAAyE;YACzE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,aAAa,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;YACrE,OAAO,EAAE;gBACR,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI;aAC9B;SACD,CAAC;QACF,OAAO,gBAAgB,CAAC;IACzB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidResolvedUrl,\n\tIResolvedUrl,\n\tIUrlResolver,\n\tDriverHeader,\n} from \"@fluidframework/driver-definitions\";\nimport Axios from \"axios\";\n\n/**\n * As the name implies this is not secure and should not be used in production. It simply makes the example easier\n * to get up and running.\n *\n * In our example we run a simple web server via webpack-dev-server. This defines a URL format of the form\n * http://localhost:8080/<documentId>/<path>.\n *\n * We then need to map that to a Fluid based URL. These are of the form\n * fluid://orderingUrl/<tenantId>/<documentId>/<path>.\n *\n * The tenantId/documentId pair defines the 'full' document ID the service makes use of. The path is then an optional\n * part of the URL that the document interprets and maps to a data store. It's exactly similar to how a web service\n * works or a router inside of a single page app framework.\n */\nexport class InsecureUrlResolver implements IUrlResolver {\n\tprivate readonly cache = new Map<string, Promise<IResolvedUrl>>();\n\n\tconstructor(\n\t\tprivate readonly hostUrl: string,\n\t\tprivate readonly ordererUrl: string,\n\t\tprivate readonly storageUrl: string,\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly bearer: string,\n\t\tprivate readonly isForNodeTest: boolean = false,\n\t) {}\n\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\tif (request.headers?.[DriverHeader.createNew]) {\n\t\t\tconst [, queryString] = request.url.split(\"?\");\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst fileName = searchParams.get(\"fileName\");\n\t\t\treturn this.resolveHelper(fileName);\n\t\t}\n\t\tconst parsedUrl = new URL(request.url);\n\t\t// If hosts match then we use the local tenant information. Otherwise we make a REST call out to the hosting\n\t\t// service using our bearer token.\n\t\tif (this.isForNodeTest) {\n\t\t\tconst [, documentId, tmpRelativePath] = parsedUrl.pathname.substr(1).split(\"/\");\n\t\t\tconst relativePath = tmpRelativePath === undefined ? \"\" : tmpRelativePath;\n\t\t\treturn this.resolveHelper(documentId, relativePath, parsedUrl.search);\n\t\t} else if (parsedUrl.host === window.location.host) {\n\t\t\tconst fullPath = parsedUrl.pathname.substr(1);\n\t\t\tconst documentId = fullPath.split(\"/\")[0];\n\t\t\tconst documentRelativePath = fullPath.slice(documentId.length);\n\t\t\treturn this.resolveHelper(documentId, documentRelativePath);\n\t\t} else {\n\t\t\tconst maybeResolvedUrl = this.cache.get(request.url);\n\t\t\tif (maybeResolvedUrl) {\n\t\t\t\treturn maybeResolvedUrl;\n\t\t\t}\n\n\t\t\tconst headers = {\n\t\t\t\tAuthorization: `Bearer ${this.bearer}`,\n\t\t\t};\n\t\t\tconst resolvedP = Axios.post<IResolvedUrl>(\n\t\t\t\t`${this.hostUrl}/api/v1/load`,\n\t\t\t\t{\n\t\t\t\t\turl: request.url,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\theaders,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.cache.set(\n\t\t\t\trequest.url,\n\t\t\t\tresolvedP.then((resolved) => resolved.data),\n\t\t\t);\n\n\t\t\treturn this.cache.get(request.url);\n\t\t}\n\t}\n\n\tprivate resolveHelper(\n\t\tdocumentId: string | null,\n\t\tdocumentRelativePath: string = \"\",\n\t\tqueryParams: string = \"\",\n\t) {\n\t\tconst encodedTenantId = encodeURIComponent(this.tenantId);\n\t\tconst host = new URL(this.ordererUrl).host;\n\t\t// when the document ID is not provided we need to resolve a special create new document URL.\n\t\t// the actual container ID will be generated by the driver.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\tif (!documentId) {\n\t\t\tconst createNewResponse: IFluidResolvedUrl = {\n\t\t\t\tendpoints: {\n\t\t\t\t\tdeltaStorageUrl: `${this.ordererUrl}/deltas/${encodedTenantId}/new`,\n\t\t\t\t\tordererUrl: this.ordererUrl,\n\t\t\t\t\tstorageUrl: `${this.storageUrl}/repos/${encodedTenantId}`,\n\t\t\t\t},\n\t\t\t\t// document ID is ignored by the driver for new container requests\n\t\t\t\tid: \"\",\n\t\t\t\ttokens: {},\n\t\t\t\ttype: \"fluid\",\n\t\t\t\turl: `fluid://${host}/${encodedTenantId}/new`,\n\t\t\t};\n\t\t\treturn createNewResponse;\n\t\t}\n\t\tconst encodedDocId = encodeURIComponent(documentId);\n\t\tconst relativePath =\n\t\t\t!documentRelativePath || documentRelativePath.startsWith(\"/\")\n\t\t\t\t? documentRelativePath\n\t\t\t\t: `/${documentRelativePath}`;\n\t\tconst documentUrl = `fluid://${host}/${encodedTenantId}/${encodedDocId}${relativePath}${queryParams}`;\n\n\t\tconst deltaStorageUrl = `${this.ordererUrl}/deltas/${encodedTenantId}/${encodedDocId}`;\n\t\tconst storageUrl = `${this.storageUrl}/repos/${encodedTenantId}`;\n\n\t\tconst response: IFluidResolvedUrl = {\n\t\t\tendpoints: {\n\t\t\t\tdeltaStorageUrl,\n\t\t\t\tordererUrl: this.ordererUrl,\n\t\t\t\tstorageUrl,\n\t\t\t},\n\t\t\tid: documentId,\n\t\t\ttokens: {},\n\t\t\ttype: \"fluid\",\n\t\t\turl: documentUrl,\n\t\t};\n\t\treturn response;\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tconst fluidResolvedUrl = resolvedUrl as IFluidResolvedUrl;\n\n\t\tconst parsedUrl = parse(fluidResolvedUrl.url);\n\t\tconst [, , documentId] = parsedUrl.pathname?.split(\"/\") ?? [];\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\tassert(!!documentId, 0x273 /* \"Invalid document id from parsed URL\" */);\n\n\t\tlet url = relativeUrl;\n\t\tif (url.startsWith(\"/\")) {\n\t\t\turl = url.substr(1);\n\t\t}\n\n\t\treturn `${this.hostUrl}/${encodeURIComponent(this.tenantId)}/${encodeURIComponent(\n\t\t\tdocumentId,\n\t\t)}/${url}`;\n\t}\n\n\tpublic createCreateNewRequest(fileName?: string): IRequest {\n\t\tconst createNewRequest: IRequest = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\turl: fileName ? `${this.hostUrl}?fileName=${fileName}` : this.hostUrl,\n\t\t\theaders: {\n\t\t\t\t[DriverHeader.createNew]: true,\n\t\t\t},\n\t\t};\n\t\treturn createNewRequest;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mapWithExpiration.d.ts","sourceRoot":"","sources":["../src/mapWithExpiration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,qBAAa,iBAAiB,CAAC,IAAI,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,CAAE,SAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC;IAK1E,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAJ7B,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA2B;gBAGzC,QAAQ,EAAE,MAAM;IAKrC,OAAO,CAAC,OAAO;IAIf;;;OAGG;IACH,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,mBAAmB;IAK3B,IAAI,IAAI,IAAI,MAAM,CAGjB;IAED,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO;IAKvB,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS;IAKlC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAMnC,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO;IAK1B,KAAK,IAAI,IAAI;IAKb,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI;IAgBpG,OAAO,IAAI,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAI3C,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC;IAI9B,MAAM,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M,CAAC;IAIlC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAKrD,OAAO;CAIP"}
@@ -15,7 +15,7 @@ export class MapWithExpiration extends Map {
15
15
  this.lastRefreshedTimes = new Map();
16
16
  }
17
17
  refresh(key) {
18
- this.lastRefreshedTimes.set(key, (new Date()).valueOf());
18
+ this.lastRefreshedTimes.set(key, new Date().valueOf());
19
19
  }
20
20
  /**
21
21
  * Returns true if the key is present and expired, false if it's not expired, and undefined if it's not found
@@ -27,7 +27,7 @@ export class MapWithExpiration extends Map {
27
27
  if (refreshTime === undefined) {
28
28
  return undefined;
29
29
  }
30
- const expired = (new Date()).valueOf() - refreshTime >= this.expiryMs;
30
+ const expired = new Date().valueOf() - refreshTime >= this.expiryMs;
31
31
  if (expired && cleanUp) {
32
32
  this.delete(key);
33
33
  }
@@ -73,7 +73,9 @@ export class MapWithExpiration extends Map {
73
73
  }
74
74
  });
75
75
  // Clean up keys we know are expired now that we're done iterating
76
- expiredKeys.forEach((key) => { this.delete(key); });
76
+ expiredKeys.forEach((key) => {
77
+ this.delete(key);
78
+ });
77
79
  }
78
80
  entries() {
79
81
  this.clearExpiredEntries();
@@ -1 +1 @@
1
- {"version":3,"file":"mapWithExpiration.js","sourceRoot":"","sources":["../src/mapWithExpiration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD;;;GAGG;AACH,MAAM,OAAO,iBAA4C,SAAQ,GAAiB;IAI9E,YACqB,QAAgB;QAEjC,KAAK,EAAE,CAAC;QAFS,aAAQ,GAAR,QAAQ,CAAQ;QAJrC,2EAA2E;QAC1D,uBAAkB,GAAG,IAAI,GAAG,EAAgB,CAAC;IAM9D,CAAC;IAEO,OAAO,CAAC,GAAS;QACrB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,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IAC1B,CAAC;IACD,CAAC,MAAM,CAAC,QAAQ,CAAC;QACb,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACpC,CAAC;IAED,OAAO;QACH,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\n\n/**\n * An extension of Map that expires (deletes) entries after a period of inactivity.\n * The policy is based on the last time a key was written to.\n */\nexport class MapWithExpiration<TKey = any, TValue = any> extends Map<TKey, TValue> {\n /** Timestamps (as epoch ms numbers) of when each key was last refreshed */\n private readonly lastRefreshedTimes = new Map<TKey, number>();\n\n constructor(\n private readonly expiryMs: number,\n ) {\n super();\n }\n\n private refresh(key: TKey): void {\n this.lastRefreshedTimes.set(key, (new Date()).valueOf());\n }\n\n /**\n * Returns true if the key is present and expired, false if it's not expired, and undefined if it's not found\n * If cleanUp is passed as true, then delete any expired entry before returning.\n */\n private checkExpiry(key: TKey, cleanUp: boolean = false): boolean | undefined {\n const refreshTime = this.lastRefreshedTimes.get(key);\n assert((refreshTime !== undefined) === super.has(key), 0x50c /* freshness map out of sync */);\n\n if (refreshTime === undefined) {\n return undefined;\n }\n const expired = (new Date()).valueOf() - refreshTime >= this.expiryMs;\n if (expired && cleanUp) {\n this.delete(key);\n }\n return expired;\n }\n\n private clearExpiredEntries() {\n // forEach clears out any expired entries\n this.forEach(() => {});\n }\n\n get size(): number {\n this.clearExpiredEntries();\n return super.size;\n }\n\n has(key: TKey): boolean {\n this.checkExpiry(key, true /* cleanUp */);\n return super.has(key);\n }\n\n get(key: TKey): TValue | undefined {\n this.checkExpiry(key, true /* cleanUp */);\n return super.get(key);\n }\n\n set(key: TKey, value: TValue): this {\n // Sliding window expiration policy (on write)\n this.refresh(key);\n return super.set(key, value);\n }\n\n delete(key: TKey): boolean {\n this.lastRefreshedTimes.delete(key);\n return super.delete(key);\n }\n\n clear(): void {\n this.lastRefreshedTimes.clear();\n super.clear();\n }\n\n forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: any): void {\n const expiredKeys: TKey[] = [];\n super.forEach((v, k, m) => {\n if (this.checkExpiry(k) === true) {\n expiredKeys.push(k);\n } else {\n callbackfn.bind(thisArg)(v, k, m);\n }\n },\n // Note we don't pass thisArg here, since we bind it directly to callbackFn and don't need it otherwise\n );\n\n // Clean up keys we know are expired now that we're done iterating\n expiredKeys.forEach((key: TKey) => { this.delete(key); });\n }\n\n entries(): IterableIterator<[TKey, TValue]> {\n this.clearExpiredEntries();\n return super.entries();\n }\n keys(): IterableIterator<TKey> {\n this.clearExpiredEntries();\n return super.keys();\n }\n values(): IterableIterator<TValue> {\n this.clearExpiredEntries();\n return super.values();\n }\n [Symbol.iterator](): IterableIterator<[TKey, TValue]> {\n this.clearExpiredEntries();\n return super[Symbol.iterator]();\n }\n\n valueOf() {\n this.clearExpiredEntries();\n return super.valueOf();\n }\n}\n"]}
1
+ {"version":3,"file":"mapWithExpiration.js","sourceRoot":"","sources":["../src/mapWithExpiration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD;;;GAGG;AACH,MAAM,OAAO,iBAA4C,SAAQ,GAAiB;IAIjF,YAA6B,QAAgB;QAC5C,KAAK,EAAE,CAAC;QADoB,aAAQ,GAAR,QAAQ,CAAQ;QAH7C,2EAA2E;QAC1D,uBAAkB,GAAG,IAAI,GAAG,EAAgB,CAAC;IAI9D,CAAC;IAEO,OAAO,CAAC,GAAS;QACxB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;IAC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B,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACjC,CAAC;IAED,OAAO;QACN,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\n\n/**\n * An extension of Map that expires (deletes) entries after a period of inactivity.\n * The policy is based on the last time a key was written to.\n */\nexport class MapWithExpiration<TKey = any, TValue = any> extends Map<TKey, TValue> {\n\t/** Timestamps (as epoch ms numbers) of when each key was last refreshed */\n\tprivate readonly lastRefreshedTimes = new Map<TKey, number>();\n\n\tconstructor(private readonly expiryMs: number) {\n\t\tsuper();\n\t}\n\n\tprivate refresh(key: TKey): void {\n\t\tthis.lastRefreshedTimes.set(key, new Date().valueOf());\n\t}\n\n\t/**\n\t * Returns true if the key is present and expired, false if it's not expired, and undefined if it's not found\n\t * If cleanUp is passed as true, then delete any expired entry before returning.\n\t */\n\tprivate checkExpiry(key: TKey, cleanUp: boolean = false): boolean | undefined {\n\t\tconst refreshTime = this.lastRefreshedTimes.get(key);\n\t\tassert(\n\t\t\t(refreshTime !== undefined) === super.has(key),\n\t\t\t0x50c /* freshness map out of sync */,\n\t\t);\n\n\t\tif (refreshTime === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst expired = new Date().valueOf() - refreshTime >= this.expiryMs;\n\t\tif (expired && cleanUp) {\n\t\t\tthis.delete(key);\n\t\t}\n\t\treturn expired;\n\t}\n\n\tprivate clearExpiredEntries() {\n\t\t// forEach clears out any expired entries\n\t\tthis.forEach(() => {});\n\t}\n\n\tget size(): number {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.size;\n\t}\n\n\thas(key: TKey): boolean {\n\t\tthis.checkExpiry(key, true /* cleanUp */);\n\t\treturn super.has(key);\n\t}\n\n\tget(key: TKey): TValue | undefined {\n\t\tthis.checkExpiry(key, true /* cleanUp */);\n\t\treturn super.get(key);\n\t}\n\n\tset(key: TKey, value: TValue): this {\n\t\t// Sliding window expiration policy (on write)\n\t\tthis.refresh(key);\n\t\treturn super.set(key, value);\n\t}\n\n\tdelete(key: TKey): boolean {\n\t\tthis.lastRefreshedTimes.delete(key);\n\t\treturn super.delete(key);\n\t}\n\n\tclear(): void {\n\t\tthis.lastRefreshedTimes.clear();\n\t\tsuper.clear();\n\t}\n\n\tforEach(\n\t\tcallbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void,\n\t\tthisArg?: any,\n\t): void {\n\t\tconst expiredKeys: TKey[] = [];\n\t\tsuper.forEach(\n\t\t\t(v, k, m) => {\n\t\t\t\tif (this.checkExpiry(k) === true) {\n\t\t\t\t\texpiredKeys.push(k);\n\t\t\t\t} else {\n\t\t\t\t\tcallbackfn.bind(thisArg)(v, k, m);\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Note we don't pass thisArg here, since we bind it directly to callbackFn and don't need it otherwise\n\t\t);\n\n\t\t// Clean up keys we know are expired now that we're done iterating\n\t\texpiredKeys.forEach((key: TKey) => {\n\t\t\tthis.delete(key);\n\t\t});\n\t}\n\n\tentries(): IterableIterator<[TKey, TValue]> {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.entries();\n\t}\n\tkeys(): IterableIterator<TKey> {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.keys();\n\t}\n\tvalues(): IterableIterator<TValue> {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.values();\n\t}\n\t[Symbol.iterator](): IterableIterator<[TKey, TValue]> {\n\t\tthis.clearExpiredEntries();\n\t\treturn super[Symbol.iterator]();\n\t}\n\n\tvalueOf() {\n\t\tthis.clearExpiredEntries();\n\t\treturn super.valueOf();\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"messageRecognition.d.ts","sourceRoot":"","sources":["../src/messageRecognition.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAEhH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;CAAE,GAAG,OAAO,CAEpE;AAYD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAKpF;AAID,oBAAY,YAAY;IACpB,MAAM,WAAW;CACpB;AAGD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,yBAAyB,GAAG,gBAAgB,GAAG,OAAO,CAItG"}
1
+ {"version":3,"file":"messageRecognition.d.ts","sourceRoot":"","sources":["../src/messageRecognition.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,gBAAgB,EAChB,yBAAyB,EAEzB,MAAM,sCAAsC,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAEnE;AAYD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAKpF;AAID,oBAAY,YAAY;IACvB,MAAM,WAAW;CACjB;AAGD,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,yBAAyB,GAAG,gBAAgB,GACnD,OAAO,CAIT"}
@@ -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 { MessageType } from "@fluidframework/protocol-definitions";
5
+ import { MessageType, } from "@fluidframework/protocol-definitions";
6
6
  /**
7
7
  * Tells if message was sent by container runtime
8
8
  * @privateRemarks ADO #1385: To be moved to container-definitions