@fluidframework/odsp-driver 0.52.1 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createFile.js +5 -4
- package/dist/createFile.js.map +1 -1
- package/dist/epochTracker.d.ts +2 -1
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +50 -21
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +15 -14
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.js +3 -3
- package/dist/getFileLink.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts +3 -3
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +7 -4
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +2 -0
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.d.ts +1 -1
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +13 -25
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +29 -26
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +4 -3
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspError.d.ts.map +1 -1
- package/dist/odspError.js +3 -1
- package/dist/odspError.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts +1 -1
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +7 -20
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +31 -22
- package/dist/odspUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/vroom.d.ts.map +1 -1
- package/dist/vroom.js +4 -1
- package/dist/vroom.js.map +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +3 -3
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/createFile.d.ts.map +1 -1
- package/lib/createFile.js +6 -5
- package/lib/createFile.js.map +1 -1
- package/lib/epochTracker.d.ts +2 -1
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +50 -21
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +15 -14
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/getFileLink.js +4 -4
- package/lib/getFileLink.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts +3 -3
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js +7 -4
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +2 -0
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentService.d.ts +1 -1
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +15 -27
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +31 -28
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +5 -4
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspError.d.ts.map +1 -1
- package/lib/odspError.js +3 -1
- package/lib/odspError.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts +1 -1
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +8 -21
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +33 -24
- package/lib/odspUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/vroom.d.ts.map +1 -1
- package/lib/vroom.js +4 -1
- package/lib/vroom.js.map +1 -1
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/zipItDataRepresentationUtils.js +3 -3
- package/lib/zipItDataRepresentationUtils.js.map +1 -1
- package/package.json +8 -8
- package/src/createFile.ts +13 -9
- package/src/epochTracker.ts +50 -20
- package/src/fetchSnapshot.ts +15 -8
- package/src/getFileLink.ts +10 -4
- package/src/odspDeltaStorageService.ts +10 -3
- package/src/odspDocumentDeltaConnection.ts +2 -0
- package/src/odspDocumentService.ts +27 -29
- package/src/odspDocumentStorageManager.ts +48 -28
- package/src/odspDriverUrlResolverForShareLink.ts +8 -3
- package/src/odspError.ts +5 -1
- package/src/odspSummaryUploadManager.ts +7 -22
- package/src/odspUtils.ts +43 -34
- package/src/packageVersion.ts +1 -1
- package/src/vroom.ts +6 -1
- package/src/zipItDataRepresentationUtils.ts +4 -7
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { assert, delay, } from "@fluidframework/common-utils";
|
|
6
6
|
import { PerformanceEvent, } from "@fluidframework/telemetry-utils";
|
|
7
|
-
import { LoaderCachingPolicy, } from "@fluidframework/driver-definitions";
|
|
8
|
-
import { RateLimiter } from "@fluidframework/driver-utils";
|
|
9
|
-
import { throwOdspNetworkError } from "@fluidframework/odsp-doclib-utils";
|
|
7
|
+
import { LoaderCachingPolicy, DriverErrorType, } from "@fluidframework/driver-definitions";
|
|
8
|
+
import { RateLimiter, NonRetryableError } from "@fluidframework/driver-utils";
|
|
10
9
|
import { OdspErrorType, } from "@fluidframework/odsp-driver-definitions";
|
|
11
10
|
import { downloadSnapshot, fetchSnapshot, fetchSnapshotWithRedeem } from "./fetchSnapshot";
|
|
12
11
|
import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
|
|
@@ -218,9 +217,6 @@ export class OdspDocumentStorageService {
|
|
|
218
217
|
});
|
|
219
218
|
this.blobCache.setBlob(blobId, blob);
|
|
220
219
|
}
|
|
221
|
-
if (!this.attributesBlobHandles.has(blobId)) {
|
|
222
|
-
return blob;
|
|
223
|
-
}
|
|
224
220
|
return blob;
|
|
225
221
|
}
|
|
226
222
|
async readBlob(blobId) {
|
|
@@ -299,39 +295,46 @@ export class OdspDocumentStorageService {
|
|
|
299
295
|
const hostSnapshotOptions = this.hostPolicy.snapshotOptions;
|
|
300
296
|
const odspSnapshotCacheValue = await PerformanceEvent.timedExecAsync(this.logger, { eventName: "ObtainSnapshot" }, async (event) => {
|
|
301
297
|
const props = {};
|
|
302
|
-
let
|
|
298
|
+
let retrievedSnapshot;
|
|
299
|
+
// Here's the logic to grab the persistent cache snapshot implemented by the host
|
|
300
|
+
// Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions
|
|
303
301
|
const cachedSnapshotP = this.epochTracker.get(createCacheSnapshotKey(this.odspResolvedUrl))
|
|
304
|
-
.then((snapshotCachedEntry) => {
|
|
302
|
+
.then(async (snapshotCachedEntry) => {
|
|
305
303
|
var _a;
|
|
306
304
|
if (snapshotCachedEntry !== undefined) {
|
|
307
305
|
// If the cached entry does not contain the entry time, then assign it a default of 30 days old.
|
|
306
|
+
const age = Date.now() - ((_a = snapshotCachedEntry.cacheEntryTime) !== null && _a !== void 0 ? _a : (Date.now() - 30 * 24 * 60 * 60 * 1000));
|
|
307
|
+
// Record the cache age
|
|
308
308
|
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
309
|
-
props["cacheEntryAge"] =
|
|
309
|
+
props["cacheEntryAge"] = age;
|
|
310
310
|
}
|
|
311
311
|
return snapshotCachedEntry;
|
|
312
312
|
});
|
|
313
|
+
// Based on the concurrentSnapshotFetch policy:
|
|
314
|
+
// Either retrieve both the network and cache snapshots concurrently and pick the first to return,
|
|
315
|
+
// or grab the cache value and then the network value if the cache value returns undefined.
|
|
313
316
|
let method;
|
|
314
317
|
if (this.hostPolicy.concurrentSnapshotFetch && !this.hostPolicy.summarizerClient) {
|
|
315
|
-
const
|
|
318
|
+
const networkSnapshotP = this.fetchSnapshot(hostSnapshotOptions);
|
|
316
319
|
// Ensure that failures on both paths are ignored initially.
|
|
317
320
|
// I.e. if cache fails for some reason, we will proceed with network result.
|
|
318
321
|
// And vice versa - if (for example) client is offline and network request fails first, we
|
|
319
322
|
// do want to attempt to succeed with cached data!
|
|
320
323
|
const promiseRaceWinner = await promiseRaceWithWinner([
|
|
321
324
|
cachedSnapshotP.catch(() => undefined),
|
|
322
|
-
|
|
325
|
+
networkSnapshotP.catch(() => undefined),
|
|
323
326
|
]);
|
|
324
|
-
|
|
327
|
+
retrievedSnapshot = promiseRaceWinner.value;
|
|
325
328
|
method = promiseRaceWinner.index === 0 ? "cache" : "network";
|
|
326
|
-
if (
|
|
329
|
+
if (retrievedSnapshot === undefined) {
|
|
327
330
|
// if network failed -> wait for cache ( then return network failure)
|
|
328
331
|
// If cache returned empty or failed -> wait for network (success of failure)
|
|
329
332
|
if (promiseRaceWinner.index === 1) {
|
|
330
|
-
|
|
333
|
+
retrievedSnapshot = await cachedSnapshotP;
|
|
331
334
|
method = "cache";
|
|
332
335
|
}
|
|
333
|
-
if (
|
|
334
|
-
|
|
336
|
+
if (retrievedSnapshot === undefined) {
|
|
337
|
+
retrievedSnapshot = await networkSnapshotP;
|
|
335
338
|
method = "network";
|
|
336
339
|
}
|
|
337
340
|
}
|
|
@@ -339,10 +342,10 @@ export class OdspDocumentStorageService {
|
|
|
339
342
|
else {
|
|
340
343
|
// Note: There's a race condition here - another caller may come past the undefined check
|
|
341
344
|
// while the first caller is awaiting later async code in this block.
|
|
342
|
-
|
|
343
|
-
method =
|
|
344
|
-
if (
|
|
345
|
-
|
|
345
|
+
retrievedSnapshot = await cachedSnapshotP;
|
|
346
|
+
method = retrievedSnapshot !== undefined ? "cache" : "network";
|
|
347
|
+
if (retrievedSnapshot === undefined) {
|
|
348
|
+
retrievedSnapshot = await this.fetchSnapshot(hostSnapshotOptions);
|
|
346
349
|
}
|
|
347
350
|
}
|
|
348
351
|
if (method === "network") {
|
|
@@ -350,9 +353,9 @@ export class OdspDocumentStorageService {
|
|
|
350
353
|
props["cacheEntryAge"] = undefined;
|
|
351
354
|
}
|
|
352
355
|
event.end(Object.assign(Object.assign({}, props), { method }));
|
|
353
|
-
return
|
|
354
|
-
}
|
|
355
|
-
// Successful call,
|
|
356
|
+
return retrievedSnapshot;
|
|
357
|
+
});
|
|
358
|
+
// Successful call, make network calls only
|
|
356
359
|
this.firstVersionCall = false;
|
|
357
360
|
this._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;
|
|
358
361
|
const { snapshotTree, blobs, ops } = odspSnapshotCacheValue;
|
|
@@ -379,10 +382,10 @@ export class OdspDocumentStorageService {
|
|
|
379
382
|
}, async () => this.epochTracker.fetchAndParseAsJSON(url, { headers }, "versions"));
|
|
380
383
|
const versionsResponse = response.content;
|
|
381
384
|
if (!versionsResponse) {
|
|
382
|
-
|
|
385
|
+
throw new NonRetryableError("getVersionsReturnedNoResponse", "No response from /versions endpoint", DriverErrorType.genericNetworkError);
|
|
383
386
|
}
|
|
384
387
|
if (!Array.isArray(versionsResponse.value)) {
|
|
385
|
-
|
|
388
|
+
throw new NonRetryableError("getVersionsReturnedNonArrayResponse", "Incorrect response from /versions endpoint", DriverErrorType.genericNetworkError);
|
|
386
389
|
}
|
|
387
390
|
return versionsResponse.value.map((version) => {
|
|
388
391
|
// Parse the date from the message
|
|
@@ -493,17 +496,17 @@ export class OdspDocumentStorageService {
|
|
|
493
496
|
}
|
|
494
497
|
checkSnapshotUrl() {
|
|
495
498
|
if (!this.snapshotUrl) {
|
|
496
|
-
|
|
499
|
+
throw new NonRetryableError("noSnapshotUrlProvided", "Method failed because no snapshot url was available", DriverErrorType.genericError);
|
|
497
500
|
}
|
|
498
501
|
}
|
|
499
502
|
checkAttachmentPOSTUrl() {
|
|
500
503
|
if (!this.attachmentPOSTUrl) {
|
|
501
|
-
|
|
504
|
+
throw new NonRetryableError("noAttachmentPOSTUrlProvided", "Method failed because no attachment POST url was available", DriverErrorType.genericError);
|
|
502
505
|
}
|
|
503
506
|
}
|
|
504
507
|
checkAttachmentGETUrl() {
|
|
505
508
|
if (!this.attachmentGETUrl) {
|
|
506
|
-
|
|
509
|
+
throw new NonRetryableError("noAttachmentGETUrlWasProvided", "Method failed because no attachment GET url was available", DriverErrorType.genericError);
|
|
507
510
|
}
|
|
508
511
|
}
|
|
509
512
|
async readTree(id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentStorageManager.js","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,MAAM,EACN,KAAK,GACR,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACH,gBAAgB,GACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAGH,mBAAmB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAGH,aAAa,GAEhB,MAAM,yCAAyC,CAAC;AAOjD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EACH,sBAAsB,EACtB,2BAA2B,GAE9B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,w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AK,QAAQ,EAAE;YACxC,uCAAuC;YACvC,wBAAwB,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;SACpE;aAAM;YACH,wBAAwB,GAAG,gBAAgB,CAAC;SAC/C;QAED,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,CAAC,wBAAwB,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;SAC5C;QAED,IAAI,CAAC,mBAAmB,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QAED,IAAI,wBAAwB,CAAC,KAAK,EAAE;YAChC,MAAM,cAAc,GAAG,wBAAwB,CAAC,KAAK,CAAC,UAAU,CAAC;YACjE,IAAI,cAAc,EAAE;gBAChB,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;aAClD;SACJ;QACD,OAAO,IAAI,CAAC,iCAAiC,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,CAAC;IACjG,CAAC;IAEO,iCAAiC,CACrC,mBAAsC,EACtC,wBAA2C;QAE3C,MAAM,mBAAmB,GAAsB;YAC3C,KAAK,oBACE,mBAAmB,CAAC,KAAK,CAC/B;YACD,OAAO,oBACA,mBAAmB,CAAC,OAAO,CACjC;YACD,KAAK,kCACE,mBAAmB,CAAC,KAAK;gBAC5B,sCAAsC;gBACtC,yDAAyD;gBACzD,WAAW,EAAE,wBAAwB,GACxC;SACJ,CAAC;QAEF,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n assert,\n delay,\n} from \"@fluidframework/common-utils\";\nimport {\n PerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport {\n ISummaryContext,\n IDocumentStorageService,\n LoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { RateLimiter } from \"@fluidframework/driver-utils\";\nimport { throwOdspNetworkError } from \"@fluidframework/odsp-doclib-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n IDocumentStorageGetVersionsResponse,\n HostStoragePolicyInternal,\n IVersionedValueWithEpoch,\n ISnapshotCachedEntry,\n} from \"./contracts\";\nimport { downloadSnapshot, fetchSnapshot, fetchSnapshotWithRedeem } from \"./fetchSnapshot\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { IOdspCache } from \"./odspCache\";\nimport {\n createCacheSnapshotKey,\n getWithRetryForTokenRefresh,\n ISnapshotContents,\n} from \"./odspUtils\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OdspSummaryUploadManager } from \"./odspSummaryUploadManager\";\nimport { FlushResult } from \"./odspDocumentDeltaConnection\";\n\n/* eslint-disable max-len */\n\n// An implementation of Promise.race that gives you the winner of the promise race\nasync function promiseRaceWithWinner<T>(promises: Promise<T>[]): Promise<{ index: number, value: T }> {\n return new Promise((resolve, reject) => {\n promises.forEach((p, index) => {\n p.then((v) => resolve({ index, value: v })).catch(reject);\n });\n });\n}\n\nclass BlobCache {\n // Save the timeout so we can cancel and reschedule it as needed\n private blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n // If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n // This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n // too many calls to setTimeout/clearTimeout.\n private deferBlobCacheClear: boolean = false;\n\n private readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n // Tracks all blob IDs evicted from cache\n private readonly blobsEvicted: Set<string> = new Set();\n\n // Initial time-out to purge data from cache\n // If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n // requests to storage, which brings down perf and may trip protection limits causing 429s\n private blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n // SPO does not keep old snapshots around for long, so we are running chances of not\n // being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n // even if blob read by runtime, it could be read again in the future)\n // So for now, purging is disabled.\n private readonly purgeEnabled = false;\n\n public get value() {\n return this._blobCache;\n }\n\n public addBlobs(blobs: Map<string, ArrayBuffer>) {\n blobs.forEach((value, blobId) => {\n this._blobCache.set(blobId, value);\n });\n // Reset the timer on cache set\n this.scheduleClearBlobsCache();\n }\n\n /**\n * Schedule a timer for clearing the blob cache or defer the current one.\n */\n private scheduleClearBlobsCache() {\n if (this.blobCacheTimeout !== undefined) {\n // If we already have an outstanding timer, just signal that we should defer the clear\n this.deferBlobCacheClear = true;\n } else if (this.purgeEnabled) {\n // If we don't have an outstanding timer, set a timer\n // When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n const clearCacheOrDefer = () => {\n this.blobCacheTimeout = undefined;\n if (this.deferBlobCacheClear) {\n this.deferBlobCacheClear = false;\n this.scheduleClearBlobsCache();\n } else {\n // NOTE: Slightly better algorithm here would be to purge either only big blobs,\n // or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n // Purging is optimizing memory footprint. But count controls potential number of storage requests\n // We want to optimize both - memory footprint and number of future requests to storage.\n // Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n // control when blobs will be used.\n this._blobCache.forEach((_, blobId) => this.blobsEvicted.add(blobId));\n this._blobCache.clear();\n }\n };\n this.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n // any future storage reads that get into the cache should be cleared from cache rather quickly -\n // there is not much value in keeping them longer\n this.blobCacheTimeoutDuration = 10 * 1000;\n }\n }\n\n public getBlob(blobId: string) {\n // Reset the timer on attempted cache read\n this.scheduleClearBlobsCache();\n const blobContent = this._blobCache.get(blobId);\n const evicted = this.blobsEvicted.has(blobId);\n return { blobContent, evicted };\n }\n\n public setBlob(blobId: string, blob: ArrayBuffer) {\n // This API is called as result of cache miss and reading blob from storage.\n // Runtime never reads same blob twice.\n // The only reason we may get read request for same blob is blob de-duping in summaries.\n // Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n // Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n // blobs are de-duped.\n const size = blob.byteLength;\n if (size < 256 * 1024) {\n // Reset the timer on cache set\n this.scheduleClearBlobsCache();\n return this._blobCache.set(blobId, blob);\n } else {\n // we evicted it here by not caching.\n this.blobsEvicted.add(blobId);\n }\n }\n}\n\nexport class OdspDocumentStorageService implements IDocumentStorageService {\n readonly policies = {\n // By default, ODSP tells the container not to prefetch/cache.\n caching: LoaderCachingPolicy.NoCaching,\n\n // ODSP storage works better if it has less number of blobs / edges\n // Runtime creating many small blobs results in sub-optimal perf.\n // 2K seems like the sweat spot:\n // The smaller the number, less blobs we aggregate. Most storages are very likely to have notion\n // of minimal \"cluster\" size, so having small blobs is wasteful\n // At the same time increasing the limit ensure that more blobs with user content are aggregated,\n // reducing possibility for de-duping of same blobs (i.e. .attributes rolled into aggregate blob\n // are not reused across data stores, or even within data store, resulting in duplication of content)\n // Note that duplication of content should not have significant impact for bytes over wire as\n // compression of http payload mostly takes care of it, but it does impact storage size and in-memory sizes.\n minBlobSize: 2048,\n };\n\n private readonly commitCache: Map<string, api.ISnapshotTree> = new Map();\n\n private readonly attributesBlobHandles: Set<string> = new Set();\n\n private readonly odspSummaryUploadManager: OdspSummaryUploadManager;\n private _ops: api.ISequencedDocumentMessage[] | undefined;\n\n private firstVersionCall = true;\n private _snapshotSequenceNumber: number | undefined;\n\n private readonly documentId: string;\n private readonly snapshotUrl: string | undefined;\n private readonly attachmentPOSTUrl: string | undefined;\n private readonly attachmentGETUrl: string | undefined;\n // Driver specified limits for snapshot size and time.\n /**\n * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to\n * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large\n * snapshot size and timeout limits so that such failures are unlikely to occur.\n */\n private readonly maxSnapshotSizeLimit = 500000000; // 500 MB\n private readonly maxSnapshotFetchTimeout = 120000; // 2 min\n\n // limits the amount of parallel \"attachment\" blob uploads\n private readonly createBlobRateLimiter = new RateLimiter(1);\n\n private readonly blobCache = new BlobCache();\n\n public set ops(ops: api.ISequencedDocumentMessage[] | undefined) {\n assert(this._ops === undefined, 0x0a5 /* \"Trying to set ops when they are already set!\" */);\n this._ops = ops;\n }\n\n public get ops(): api.ISequencedDocumentMessage[] | undefined {\n return this._ops;\n }\n\n public get snapshotSequenceNumber() {\n return this._snapshotSequenceNumber;\n }\n\n constructor(\n private readonly odspResolvedUrl: IOdspResolvedUrl,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly logger: ITelemetryLogger,\n private readonly fetchFullSnapshot: boolean,\n private readonly cache: IOdspCache,\n private readonly hostPolicy: HostStoragePolicyInternal,\n private readonly epochTracker: EpochTracker,\n private readonly flushCallback: () => Promise<FlushResult>,\n ) {\n this.documentId = this.odspResolvedUrl.hashedDocumentId;\n this.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;\n this.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;\n this.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;\n this.odspSummaryUploadManager = new OdspSummaryUploadManager(this.snapshotUrl, getStorageToken, logger, epochTracker);\n }\n\n public get repositoryUrl(): string {\n return \"\";\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse> {\n this.checkAttachmentPOSTUrl();\n\n const response = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"CreateBlob\");\n const { url, headers } = getUrlAndHeadersWithAuth(`${this.attachmentPOSTUrl}/content`, storageToken);\n headers[\"Content-Type\"] = \"application/octet-stream\";\n\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"createBlob\",\n size: file.byteLength,\n waitQueueLength: this.createBlobRateLimiter.waitQueueLength,\n },\n async (event) => {\n const res = await this.createBlobRateLimiter.schedule(async () =>\n this.epochTracker.fetchAndParseAsJSON<api.ICreateBlobResponse>(\n url,\n {\n body: file,\n headers,\n method: \"POST\",\n },\n \"createBlob\",\n ));\n event.end({\n blobId: res.content.id,\n ...res.commonSpoHeaders,\n });\n return res;\n },\n );\n });\n\n return response.content;\n }\n\n private async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n const { blobContent, evicted } = this.blobCache.getBlob(blobId);\n let blob = blobContent;\n\n if (blob === undefined) {\n this.checkAttachmentGETUrl();\n\n blob = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"GetBlob\");\n const unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;\n const { url, headers } = getUrlAndHeadersWithAuth(unAuthedUrl, storageToken);\n\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"readDataBlob\",\n blobId,\n evicted,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n },\n async (event) => {\n const res = await this.epochTracker.fetchArray(url, { headers }, \"blob\");\n event.end({\n waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n ...res.commonSpoHeaders,\n attempts: options.refresh ? 2 : 1,\n });\n const cacheControl = res.headers.get(\"cache-control\");\n if (cacheControl === undefined || !(cacheControl.includes(\"private\") || cacheControl.includes(\"public\"))) {\n this.logger.sendErrorEvent({\n eventName: \"NonCacheableBlob\",\n cacheControl,\n blobId,\n ...res.commonSpoHeaders,\n });\n }\n return res.content;\n },\n );\n });\n this.blobCache.setBlob(blobId, blob);\n }\n\n if (!this.attributesBlobHandles.has(blobId)) {\n return blob;\n }\n return blob;\n }\n\n public async readBlob(blobId: string): Promise<ArrayBufferLike> {\n return this.readBlobCore(blobId);\n }\n\n public async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n if (!this.snapshotUrl) {\n return null;\n }\n\n let id: string;\n if (!version || !version.id) {\n const versions = await this.getVersions(null, 1);\n if (!versions || versions.length === 0) {\n return null;\n }\n id = versions[0].id;\n } else {\n id = version.id;\n }\n\n const snapshotTree = await this.readTree(id);\n if (!snapshotTree) {\n return null;\n }\n // Decode commit paths\n const commits = {};\n\n for (const key of Object.keys(snapshotTree.commits)) {\n commits[decodeURIComponent(key)] = snapshotTree.commits[key];\n }\n\n let finalTree: api.ISnapshotTree;\n // For container loaded from detach new summary, we will not have a commit for \".app\" in downloaded summary as the client uploaded both\n // \".app\" and \".protocol\" trees by itself. For other summaries, we will have \".app\" as commit because client previously only uploaded the\n // app summary.\n if (commits && commits[\".app\"]) {\n // The latest snapshot is a summary\n // attempt to read .protocol from commits for backwards compat\n finalTree = await this.readSummaryTree(commits[\".protocol\"] || snapshotTree.trees[\".protocol\"], commits[\".app\"] as string);\n } else {\n if (snapshotTree.blobs) {\n const attributesBlob = snapshotTree.blobs.attributes;\n if (attributesBlob) {\n this.attributesBlobHandles.add(attributesBlob);\n }\n }\n\n snapshotTree.commits = commits;\n\n // When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n // So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n const appTree = snapshotTree.trees[\".app\"];\n const protocolTree = snapshotTree.trees[\".protocol\"];\n finalTree = this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);\n }\n return finalTree;\n }\n\n public async getVersions(blobid: string | null, count: number): Promise<api.IVersion[]> {\n // Regular load workflow uses blobId === documentID to indicate \"latest\".\n if (blobid !== this.documentId && blobid) {\n // FluidFetch & FluidDebugger tools use empty sting to query for versions\n // In such case we need to make a call against SPO to give full picture to the tool.\n // Otherwise, each commit calls getVersions but odsp doesn't have a history for each commit\n // return the blobid as is\n return [\n {\n id: blobid,\n treeId: undefined!,\n },\n ];\n }\n\n // Can't really make a call if we do not have URL\n if (!this.snapshotUrl) {\n return [];\n }\n\n // If count is one, we can use the trees/latest API, which returns the latest version and trees in a single request for better performance\n // Do it only once - we might get more here due to summarizer - it needs only container tree, not full snapshot.\n if (this.firstVersionCall && count === 1 && (blobid === null || blobid === this.documentId)) {\n const hostSnapshotOptions = this.hostPolicy.snapshotOptions;\n const odspSnapshotCacheValue: ISnapshotContents = await PerformanceEvent.timedExecAsync(\n this.logger,\n { eventName: \"ObtainSnapshot\" },\n async (event: PerformanceEvent) => {\n const props = {};\n let cachedSnapshot: ISnapshotContents | undefined;\n const cachedSnapshotP: Promise<ISnapshotContents | undefined> =\n this.epochTracker.get(createCacheSnapshotKey(this.odspResolvedUrl))\n .then((snapshotCachedEntry: ISnapshotCachedEntry) => {\n if (snapshotCachedEntry !== undefined) {\n // If the cached entry does not contain the entry time, then assign it a default of 30 days old.\n // eslint-disable-next-line @typescript-eslint/dot-notation\n props[\"cacheEntryAge\"] = Date.now() - (snapshotCachedEntry.cacheEntryTime ??\n (Date.now() - 30 * 24 * 60 * 60 * 1000));\n }\n return snapshotCachedEntry;\n });\n\n let method: string;\n if (this.hostPolicy.concurrentSnapshotFetch && !this.hostPolicy.summarizerClient) {\n const snapshotP = this.fetchSnapshot(hostSnapshotOptions);\n\n // Ensure that failures on both paths are ignored initially.\n // I.e. if cache fails for some reason, we will proceed with network result.\n // And vice versa - if (for example) client is offline and network request fails first, we\n // do want to attempt to succeed with cached data!\n const promiseRaceWinner = await promiseRaceWithWinner([\n cachedSnapshotP.catch(() => undefined),\n snapshotP.catch(() => undefined),\n ]);\n cachedSnapshot = promiseRaceWinner.value;\n method = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n if (cachedSnapshot === undefined) {\n // if network failed -> wait for cache ( then return network failure)\n // If cache returned empty or failed -> wait for network (success of failure)\n if (promiseRaceWinner.index === 1) {\n cachedSnapshot = await cachedSnapshotP;\n method = \"cache\";\n }\n if (cachedSnapshot === undefined) {\n cachedSnapshot = await snapshotP;\n method = \"network\";\n }\n }\n } else {\n // Note: There's a race condition here - another caller may come past the undefined check\n // while the first caller is awaiting later async code in this block.\n\n cachedSnapshot = await cachedSnapshotP;\n\n method = cachedSnapshot !== undefined ? \"cache\" : \"network\";\n\n if (cachedSnapshot === undefined) {\n cachedSnapshot = await this.fetchSnapshot(hostSnapshotOptions);\n }\n }\n if (method === \"network\") {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n props[\"cacheEntryAge\"] = undefined;\n }\n event.end({ ...props, method });\n return cachedSnapshot;\n },\n {end: true, cancel: \"error\"},\n );\n\n // Successful call, redirect future calls to getVersion only!\n this.firstVersionCall = false;\n\n this._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n const { snapshotTree, blobs, ops } = odspSnapshotCacheValue;\n // id should be undefined in case of just ops in snapshot.\n let id: string | undefined;\n if (snapshotTree) {\n id = snapshotTree.id;\n assert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n this.setRootTree(id, snapshotTree);\n }\n if (blobs) {\n this.initBlobsCache(blobs);\n }\n\n this.ops = ops;\n return id ? [{ id, treeId: undefined! }] : [];\n }\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"GetVersions\");\n const { url, headers } = getUrlAndHeadersWithAuth(`${this.snapshotUrl}/versions?count=${count}`, storageToken);\n\n // Fetch the latest snapshot versions for the document\n const response = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"getVersions\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => this.epochTracker.fetchAndParseAsJSON<IDocumentStorageGetVersionsResponse>(url, { headers }, \"versions\"),\n );\n const versionsResponse = response.content;\n if (!versionsResponse) {\n throwOdspNetworkError(\"getVersionsReturnedNoResponse\", 400);\n }\n if (!Array.isArray(versionsResponse.value)) {\n throwOdspNetworkError(\"getVersionsReturnedNonArrayResponse\", 400);\n }\n return versionsResponse.value.map((version) => {\n // Parse the date from the message\n let date: string | undefined;\n for (const rec of version.message.split(\"\\n\")) {\n const index = rec.indexOf(\":\");\n if (index !== -1 && rec.substr(0, index) === \"Date\") {\n date = rec.substr(index + 1).trim();\n break;\n }\n }\n return {\n date,\n id: version.id,\n treeId: undefined!,\n };\n });\n });\n }\n\n private async fetchSnapshot(hostSnapshotOptions: ISnapshotOptions | undefined) {\n return this.fetchSnapshotCore(hostSnapshotOptions).catch((error) => {\n // Issue #5895:\n // If we are offline, this error is retryable. But that means that RetriableDocumentStorageService\n // will run in circles calling getSnapshotTree, which would result in OdspDocumentStorageService class\n // going getVersions / individual blob download path. This path is very slow, and will not work with\n // delay-loaded data stores and ODSP storage deleting old snapshots and blobs.\n if (typeof error === \"object\" && error !== null) {\n error.canRetry = false;\n }\n throw error;\n });\n }\n\n private async fetchSnapshotCore(hostSnapshotOptions: ISnapshotOptions | undefined) {\n const snapshotOptions: ISnapshotOptions = {\n mds: this.maxSnapshotSizeLimit,\n ...hostSnapshotOptions,\n timeout: hostSnapshotOptions?.timeout ? Math.min(hostSnapshotOptions.timeout, this.maxSnapshotFetchTimeout) : this.maxSnapshotFetchTimeout,\n };\n\n // No limit on size of snapshot or time to fetch, as otherwise we fail all clients to summarize\n if (this.hostPolicy.summarizerClient) {\n snapshotOptions.mds = undefined;\n snapshotOptions.timeout = undefined;\n }\n\n const snapshotDownloader = async (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n options: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => {\n return downloadSnapshot(\n finalOdspResolvedUrl,\n storageToken,\n this.logger,\n options,\n this.hostPolicy.fetchBinarySnapshotFormat,\n controller,\n this.epochTracker,\n );\n };\n const putInCache = async (valueWithEpoch: IVersionedValueWithEpoch) => {\n return this.cache.persistedCache.put(\n createCacheSnapshotKey(this.odspResolvedUrl),\n // Epoch tracker will add the epoch and version to the value here. So just send value to cache.\n valueWithEpoch.value,\n );\n };\n const removeEntries = async () => this.cache.persistedCache.removeEntries();\n try {\n const odspSnapshot = await fetchSnapshotWithRedeem(\n this.odspResolvedUrl,\n this.getStorageToken,\n snapshotOptions,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback);\n return odspSnapshot;\n } catch (error) {\n const errorType = error.errorType;\n // If the snapshot size is too big and the host specified the size limitation(specified in hostSnapshotOptions), then don't try to fetch the snapshot again.\n if ((errorType === OdspErrorType.snapshotTooBig && hostSnapshotOptions?.mds !== undefined) && (this.hostPolicy.summarizerClient !== true)) {\n throw error;\n }\n // If the first snapshot request was with blobs and we either timed out or the size was too big, then try to fetch without blobs.\n if ((errorType === OdspErrorType.snapshotTooBig || errorType === OdspErrorType.fetchTimeout) && snapshotOptions.blobs) {\n this.logger.sendErrorEvent({\n eventName: \"TreeLatest_SecondCall\",\n errorType,\n });\n const snapshotOptionsWithoutBlobs: ISnapshotOptions = { ...snapshotOptions, blobs: 0, mds: undefined, timeout: undefined };\n const odspSnapshot = await fetchSnapshotWithRedeem(\n this.odspResolvedUrl,\n this.getStorageToken,\n snapshotOptionsWithoutBlobs,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback);\n return odspSnapshot;\n }\n throw error;\n }\n }\n\n public async write(tree: api.ITree, parents: string[], message: string): Promise<api.IVersion> {\n this.checkSnapshotUrl();\n\n throw new Error(\"Not supported\");\n }\n\n public async uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string> {\n this.checkSnapshotUrl();\n\n // Enable flushing only if we have single commit summary and this is not the initial summary for an empty file\n if (\".protocol\" in summary.tree && context.ackHandle !== undefined) {\n let retry = 0;\n for (;;) {\n const result = await this.flushCallback();\n const seq = result.lastPersistedSequenceNumber;\n if (seq !== undefined && seq >= context.referenceSequenceNumber) {\n break;\n }\n\n retry++;\n if (retry > 3) {\n this.logger.sendErrorEvent({\n eventName: \"FlushFailure\",\n ...result,\n retry,\n referenceSequenceNumber: context.referenceSequenceNumber,\n });\n break;\n }\n\n this.logger.sendPerformanceEvent({\n eventName: \"FlushExtraCall\",\n ...result,\n retry,\n referenceSequenceNumber: context.referenceSequenceNumber,\n });\n\n await delay(1000 * (result.retryAfter ?? 1));\n }\n }\n\n const id = await PerformanceEvent.timedExecAsync(this.logger,\n { eventName: \"uploadSummaryWithContext\" },\n async () => this.odspSummaryUploadManager.writeSummaryTree(summary, context));\n return id;\n }\n\n public async downloadSummary(commit: api.ISummaryHandle): Promise<api.ISummaryTree> {\n throw new Error(\"Not implemented yet\");\n }\n\n private setRootTree(id: string, tree: api.ISnapshotTree) {\n this.commitCache.set(id, tree);\n }\n\n private initBlobsCache(blobs: Map<string, ArrayBuffer>) {\n this.blobCache.addBlobs(blobs);\n }\n\n private checkSnapshotUrl() {\n if (!this.snapshotUrl) {\n throwOdspNetworkError(\"methodNotSupportedBecauseNoSnapshotUrlWasProvided\", 400);\n }\n }\n\n private checkAttachmentPOSTUrl() {\n if (!this.attachmentPOSTUrl) {\n throwOdspNetworkError(\"methodNotSupportedBecauseNoAttachmentPOSTUrlWasProvided\", 400);\n }\n }\n\n private checkAttachmentGETUrl() {\n if (!this.attachmentGETUrl) {\n throwOdspNetworkError(\"methodNotSupportedBecauseNoAttachmentGETUrlWasProvided\", 400);\n }\n }\n\n private async readTree(id: string): Promise<api.ISnapshotTree | null> {\n if (!this.snapshotUrl) {\n return null;\n }\n let tree = this.commitCache.get(id);\n if (!tree) {\n tree = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"ReadCommit\");\n const snapshotDownloader = async (url: string, fetchOptions: {[index: string]: any}) => {\n return this.epochTracker.fetchAndParseAsJSON(\n url,\n fetchOptions,\n \"snapshotTree\",\n );\n };\n const snapshot = await fetchSnapshot(this.snapshotUrl!, storageToken, id, this.fetchFullSnapshot, this.logger, snapshotDownloader);\n let treeId = \"\";\n if (snapshot.snapshotTree) {\n assert(snapshot.snapshotTree.id !== undefined, 0x222 /* \"Root tree should contain the id!!\" */);\n treeId = snapshot.snapshotTree.id;\n this.setRootTree(treeId, snapshot.snapshotTree);\n }\n if (snapshot.blobs) {\n this.initBlobsCache(snapshot.blobs);\n }\n // If the version id doesn't match with the id of the tree, then use the id of first tree which in that case\n // will be the actual id of tree to be fetched.\n return this.commitCache.get(id) ?? this.commitCache.get(treeId);\n });\n }\n\n if (!tree) {\n return null;\n }\n\n return tree;\n }\n\n /**\n * Reads a summary tree\n * @param protocolTreeOrId - Protocol snapshot tree or id of the protocol tree\n * @param appTreeId - Id of the app tree\n */\n private async readSummaryTree(protocolTreeOrId: api.ISnapshotTree | string, appTreeId: string): Promise<api.ISnapshotTree> {\n // Load the app and protocol trees and return them\n let hierarchicalProtocolTree: api.ISnapshotTree | null;\n if (typeof (protocolTreeOrId) === \"string\") {\n // Backwards compat for older summaries\n hierarchicalProtocolTree = await this.readTree(protocolTreeOrId);\n } else {\n hierarchicalProtocolTree = protocolTreeOrId;\n }\n\n const hierarchicalAppTree = await this.readTree(appTreeId);\n if (!hierarchicalProtocolTree) {\n throw new Error(\"Invalid protocol tree\");\n }\n\n if (!hierarchicalAppTree) {\n throw new Error(\"Invalid app tree\");\n }\n\n if (hierarchicalProtocolTree.blobs) {\n const attributesBlob = hierarchicalProtocolTree.blobs.attributes;\n if (attributesBlob) {\n this.attributesBlobHandles.add(attributesBlob);\n }\n }\n return this.combineProtocolAndAppSnapshotTree(hierarchicalAppTree, hierarchicalProtocolTree);\n }\n\n private combineProtocolAndAppSnapshotTree(\n hierarchicalAppTree: api.ISnapshotTree,\n hierarchicalProtocolTree: api.ISnapshotTree,\n ) {\n const summarySnapshotTree: api.ISnapshotTree = {\n blobs: {\n ...hierarchicalAppTree.blobs,\n },\n commits: {\n ...hierarchicalAppTree.commits,\n },\n trees: {\n ...hierarchicalAppTree.trees,\n // the app tree could have a .protocol\n // in that case we want to server protocol to override it\n \".protocol\": hierarchicalProtocolTree,\n },\n };\n\n return summarySnapshotTree;\n }\n}\n\n/* eslint-enable max-len */\n"]}
|
|
1
|
+
{"version":3,"file":"odspDocumentStorageManager.js","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,MAAM,EACN,KAAK,GACR,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACH,gBAAgB,GACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAGH,mBAAmB,EACnB,eAAe,GAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAGH,aAAa,GAEhB,MAAM,yCAAyC,CAAC;AAOjD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EACH,sBAAsB,EACtB,2BAA2B,GAE9B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,4BAA4B;AAE5B,kFAAkF;AAClF,KAAK,UAAU,qBAAqB,CAAI,QAAsB;IAC1D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAC1B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,SAAS;IAAf;QAGI,kGAAkG;QAClG,gHAAgH;QAChH,6CAA6C;QACrC,wBAAmB,GAAY,KAAK,CAAC;QAE5B,eAA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E;YACtB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;QAED,IAAI,wBAAwB,CAAC,KAAK,EAAE;YAChC,MAAM,cAAc,GAAG,wBAAwB,CAAC,KAAK,CAAC,UAAU,CAAC;YACjE,IAAI,cAAc,EAAE;gBAChB,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;aAClD;SACJ;QACD,OAAO,IAAI,CAAC,iCAAiC,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,CAAC;IACjG,CAAC;IAEO,iCAAiC,CACrC,mBAAsC,EACtC,wBAA2C;QAE3C,MAAM,mBAAmB,GAAsB;YAC3C,KAAK,oBACE,mBAAmB,CAAC,KAAK,CAC/B;YACD,OAAO,oBACA,mBAAmB,CAAC,OAAO,CACjC;YACD,KAAK,kCACE,mBAAmB,CAAC,KAAK;gBAC5B,sCAAsC;gBACtC,yDAAyD;gBACzD,WAAW,EAAE,wBAAwB,GACxC;SACJ,CAAC;QAEF,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n assert,\n delay,\n} from \"@fluidframework/common-utils\";\nimport {\n PerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport {\n ISummaryContext,\n IDocumentStorageService,\n LoaderCachingPolicy,\n DriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport { RateLimiter, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n IDocumentStorageGetVersionsResponse,\n HostStoragePolicyInternal,\n IVersionedValueWithEpoch,\n ISnapshotCachedEntry,\n} from \"./contracts\";\nimport { downloadSnapshot, fetchSnapshot, fetchSnapshotWithRedeem } from \"./fetchSnapshot\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { IOdspCache } from \"./odspCache\";\nimport {\n createCacheSnapshotKey,\n getWithRetryForTokenRefresh,\n ISnapshotContents,\n} from \"./odspUtils\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OdspSummaryUploadManager } from \"./odspSummaryUploadManager\";\nimport { FlushResult } from \"./odspDocumentDeltaConnection\";\n\n/* eslint-disable max-len */\n\n// An implementation of Promise.race that gives you the winner of the promise race\nasync function promiseRaceWithWinner<T>(promises: Promise<T>[]): Promise<{ index: number, value: T }> {\n return new Promise((resolve, reject) => {\n promises.forEach((p, index) => {\n p.then((v) => resolve({ index, value: v })).catch(reject);\n });\n });\n}\n\nclass BlobCache {\n // Save the timeout so we can cancel and reschedule it as needed\n private blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n // If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n // This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n // too many calls to setTimeout/clearTimeout.\n private deferBlobCacheClear: boolean = false;\n\n private readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n // Tracks all blob IDs evicted from cache\n private readonly blobsEvicted: Set<string> = new Set();\n\n // Initial time-out to purge data from cache\n // If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n // requests to storage, which brings down perf and may trip protection limits causing 429s\n private blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n // SPO does not keep old snapshots around for long, so we are running chances of not\n // being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n // even if blob read by runtime, it could be read again in the future)\n // So for now, purging is disabled.\n private readonly purgeEnabled = false;\n\n public get value() {\n return this._blobCache;\n }\n\n public addBlobs(blobs: Map<string, ArrayBuffer>) {\n blobs.forEach((value, blobId) => {\n this._blobCache.set(blobId, value);\n });\n // Reset the timer on cache set\n this.scheduleClearBlobsCache();\n }\n\n /**\n * Schedule a timer for clearing the blob cache or defer the current one.\n */\n private scheduleClearBlobsCache() {\n if (this.blobCacheTimeout !== undefined) {\n // If we already have an outstanding timer, just signal that we should defer the clear\n this.deferBlobCacheClear = true;\n } else if (this.purgeEnabled) {\n // If we don't have an outstanding timer, set a timer\n // When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n const clearCacheOrDefer = () => {\n this.blobCacheTimeout = undefined;\n if (this.deferBlobCacheClear) {\n this.deferBlobCacheClear = false;\n this.scheduleClearBlobsCache();\n } else {\n // NOTE: Slightly better algorithm here would be to purge either only big blobs,\n // or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n // Purging is optimizing memory footprint. But count controls potential number of storage requests\n // We want to optimize both - memory footprint and number of future requests to storage.\n // Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n // control when blobs will be used.\n this._blobCache.forEach((_, blobId) => this.blobsEvicted.add(blobId));\n this._blobCache.clear();\n }\n };\n this.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n // any future storage reads that get into the cache should be cleared from cache rather quickly -\n // there is not much value in keeping them longer\n this.blobCacheTimeoutDuration = 10 * 1000;\n }\n }\n\n public getBlob(blobId: string) {\n // Reset the timer on attempted cache read\n this.scheduleClearBlobsCache();\n const blobContent = this._blobCache.get(blobId);\n const evicted = this.blobsEvicted.has(blobId);\n return { blobContent, evicted };\n }\n\n public setBlob(blobId: string, blob: ArrayBuffer) {\n // This API is called as result of cache miss and reading blob from storage.\n // Runtime never reads same blob twice.\n // The only reason we may get read request for same blob is blob de-duping in summaries.\n // Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n // Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n // blobs are de-duped.\n const size = blob.byteLength;\n if (size < 256 * 1024) {\n // Reset the timer on cache set\n this.scheduleClearBlobsCache();\n return this._blobCache.set(blobId, blob);\n } else {\n // we evicted it here by not caching.\n this.blobsEvicted.add(blobId);\n }\n }\n}\n\nexport class OdspDocumentStorageService implements IDocumentStorageService {\n readonly policies = {\n // By default, ODSP tells the container not to prefetch/cache.\n caching: LoaderCachingPolicy.NoCaching,\n\n // ODSP storage works better if it has less number of blobs / edges\n // Runtime creating many small blobs results in sub-optimal perf.\n // 2K seems like the sweat spot:\n // The smaller the number, less blobs we aggregate. Most storages are very likely to have notion\n // of minimal \"cluster\" size, so having small blobs is wasteful\n // At the same time increasing the limit ensure that more blobs with user content are aggregated,\n // reducing possibility for de-duping of same blobs (i.e. .attributes rolled into aggregate blob\n // are not reused across data stores, or even within data store, resulting in duplication of content)\n // Note that duplication of content should not have significant impact for bytes over wire as\n // compression of http payload mostly takes care of it, but it does impact storage size and in-memory sizes.\n minBlobSize: 2048,\n };\n\n private readonly commitCache: Map<string, api.ISnapshotTree> = new Map();\n\n private readonly attributesBlobHandles: Set<string> = new Set();\n\n private readonly odspSummaryUploadManager: OdspSummaryUploadManager;\n private _ops: api.ISequencedDocumentMessage[] | undefined;\n\n private firstVersionCall = true;\n private _snapshotSequenceNumber: number | undefined;\n\n private readonly documentId: string;\n private readonly snapshotUrl: string | undefined;\n private readonly attachmentPOSTUrl: string | undefined;\n private readonly attachmentGETUrl: string | undefined;\n // Driver specified limits for snapshot size and time.\n /**\n * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to\n * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large\n * snapshot size and timeout limits so that such failures are unlikely to occur.\n */\n private readonly maxSnapshotSizeLimit = 500000000; // 500 MB\n private readonly maxSnapshotFetchTimeout = 120000; // 2 min\n\n // limits the amount of parallel \"attachment\" blob uploads\n private readonly createBlobRateLimiter = new RateLimiter(1);\n\n private readonly blobCache = new BlobCache();\n\n public set ops(ops: api.ISequencedDocumentMessage[] | undefined) {\n assert(this._ops === undefined, 0x0a5 /* \"Trying to set ops when they are already set!\" */);\n this._ops = ops;\n }\n\n public get ops(): api.ISequencedDocumentMessage[] | undefined {\n return this._ops;\n }\n\n public get snapshotSequenceNumber() {\n return this._snapshotSequenceNumber;\n }\n\n constructor(\n private readonly odspResolvedUrl: IOdspResolvedUrl,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly logger: ITelemetryLogger,\n private readonly fetchFullSnapshot: boolean,\n private readonly cache: IOdspCache,\n private readonly hostPolicy: HostStoragePolicyInternal,\n private readonly epochTracker: EpochTracker,\n private readonly flushCallback: () => Promise<FlushResult>,\n ) {\n this.documentId = this.odspResolvedUrl.hashedDocumentId;\n this.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;\n this.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;\n this.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;\n this.odspSummaryUploadManager = new OdspSummaryUploadManager(this.snapshotUrl, getStorageToken, logger, epochTracker);\n }\n\n public get repositoryUrl(): string {\n return \"\";\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse> {\n this.checkAttachmentPOSTUrl();\n\n const response = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"CreateBlob\");\n const { url, headers } = getUrlAndHeadersWithAuth(`${this.attachmentPOSTUrl}/content`, storageToken);\n headers[\"Content-Type\"] = \"application/octet-stream\";\n\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"createBlob\",\n size: file.byteLength,\n waitQueueLength: this.createBlobRateLimiter.waitQueueLength,\n },\n async (event) => {\n const res = await this.createBlobRateLimiter.schedule(async () =>\n this.epochTracker.fetchAndParseAsJSON<api.ICreateBlobResponse>(\n url,\n {\n body: file,\n headers,\n method: \"POST\",\n },\n \"createBlob\",\n ));\n event.end({\n blobId: res.content.id,\n ...res.commonSpoHeaders,\n });\n return res;\n },\n );\n });\n\n return response.content;\n }\n\n private async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n const { blobContent, evicted } = this.blobCache.getBlob(blobId);\n let blob = blobContent;\n\n if (blob === undefined) {\n this.checkAttachmentGETUrl();\n\n blob = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"GetBlob\");\n const unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;\n const { url, headers } = getUrlAndHeadersWithAuth(unAuthedUrl, storageToken);\n\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"readDataBlob\",\n blobId,\n evicted,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n },\n async (event) => {\n const res = await this.epochTracker.fetchArray(url, { headers }, \"blob\");\n event.end({\n waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n ...res.commonSpoHeaders,\n attempts: options.refresh ? 2 : 1,\n });\n const cacheControl = res.headers.get(\"cache-control\");\n if (cacheControl === undefined || !(cacheControl.includes(\"private\") || cacheControl.includes(\"public\"))) {\n this.logger.sendErrorEvent({\n eventName: \"NonCacheableBlob\",\n cacheControl,\n blobId,\n ...res.commonSpoHeaders,\n });\n }\n return res.content;\n },\n );\n });\n this.blobCache.setBlob(blobId, blob);\n }\n\n return blob;\n }\n\n public async readBlob(blobId: string): Promise<ArrayBufferLike> {\n return this.readBlobCore(blobId);\n }\n\n public async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n if (!this.snapshotUrl) {\n return null;\n }\n\n let id: string;\n if (!version || !version.id) {\n const versions = await this.getVersions(null, 1);\n if (!versions || versions.length === 0) {\n return null;\n }\n id = versions[0].id;\n } else {\n id = version.id;\n }\n\n const snapshotTree = await this.readTree(id);\n if (!snapshotTree) {\n return null;\n }\n // Decode commit paths\n const commits = {};\n\n for (const key of Object.keys(snapshotTree.commits)) {\n commits[decodeURIComponent(key)] = snapshotTree.commits[key];\n }\n\n let finalTree: api.ISnapshotTree;\n // For container loaded from detach new summary, we will not have a commit for \".app\" in downloaded summary as the client uploaded both\n // \".app\" and \".protocol\" trees by itself. For other summaries, we will have \".app\" as commit because client previously only uploaded the\n // app summary.\n if (commits && commits[\".app\"]) {\n // The latest snapshot is a summary\n // attempt to read .protocol from commits for backwards compat\n finalTree = await this.readSummaryTree(commits[\".protocol\"] || snapshotTree.trees[\".protocol\"], commits[\".app\"] as string);\n } else {\n if (snapshotTree.blobs) {\n const attributesBlob = snapshotTree.blobs.attributes;\n if (attributesBlob) {\n this.attributesBlobHandles.add(attributesBlob);\n }\n }\n\n snapshotTree.commits = commits;\n\n // When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n // So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n const appTree = snapshotTree.trees[\".app\"];\n const protocolTree = snapshotTree.trees[\".protocol\"];\n finalTree = this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);\n }\n return finalTree;\n }\n\n public async getVersions(blobid: string | null, count: number): Promise<api.IVersion[]> {\n // Regular load workflow uses blobId === documentID to indicate \"latest\".\n if (blobid !== this.documentId && blobid) {\n // FluidFetch & FluidDebugger tools use empty sting to query for versions\n // In such case we need to make a call against SPO to give full picture to the tool.\n // Otherwise, each commit calls getVersions but odsp doesn't have a history for each commit\n // return the blobid as is\n return [\n {\n id: blobid,\n treeId: undefined!,\n },\n ];\n }\n\n // Can't really make a call if we do not have URL\n if (!this.snapshotUrl) {\n return [];\n }\n\n // If count is one, we can use the trees/latest API, which returns the latest version and trees in a single request for better performance\n // Do it only once - we might get more here due to summarizer - it needs only container tree, not full snapshot.\n if (this.firstVersionCall && count === 1 && (blobid === null || blobid === this.documentId)) {\n const hostSnapshotOptions = this.hostPolicy.snapshotOptions;\n const odspSnapshotCacheValue: ISnapshotContents = await PerformanceEvent.timedExecAsync(\n this.logger,\n { eventName: \"ObtainSnapshot\" },\n async (event: PerformanceEvent) => {\n const props = {};\n let retrievedSnapshot: ISnapshotContents | undefined;\n // Here's the logic to grab the persistent cache snapshot implemented by the host\n // Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions\n const cachedSnapshotP: Promise<ISnapshotContents | undefined> =\n this.epochTracker.get(createCacheSnapshotKey(this.odspResolvedUrl))\n .then(async (snapshotCachedEntry: ISnapshotCachedEntry) => {\n if (snapshotCachedEntry !== undefined) {\n // If the cached entry does not contain the entry time, then assign it a default of 30 days old.\n const age = Date.now() - (snapshotCachedEntry.cacheEntryTime ??\n (Date.now() - 30 * 24 * 60 * 60 * 1000));\n\n // Record the cache age\n // eslint-disable-next-line @typescript-eslint/dot-notation\n props[\"cacheEntryAge\"] = age;\n }\n\n return snapshotCachedEntry;\n });\n\n // Based on the concurrentSnapshotFetch policy:\n // Either retrieve both the network and cache snapshots concurrently and pick the first to return,\n // or grab the cache value and then the network value if the cache value returns undefined.\n let method: string;\n if (this.hostPolicy.concurrentSnapshotFetch && !this.hostPolicy.summarizerClient) {\n const networkSnapshotP = this.fetchSnapshot(hostSnapshotOptions);\n\n // Ensure that failures on both paths are ignored initially.\n // I.e. if cache fails for some reason, we will proceed with network result.\n // And vice versa - if (for example) client is offline and network request fails first, we\n // do want to attempt to succeed with cached data!\n const promiseRaceWinner = await promiseRaceWithWinner([\n cachedSnapshotP.catch(() => undefined),\n networkSnapshotP.catch(() => undefined),\n ]);\n retrievedSnapshot = promiseRaceWinner.value;\n method = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n if (retrievedSnapshot === undefined) {\n // if network failed -> wait for cache ( then return network failure)\n // If cache returned empty or failed -> wait for network (success of failure)\n if (promiseRaceWinner.index === 1) {\n retrievedSnapshot = await cachedSnapshotP;\n method = \"cache\";\n }\n if (retrievedSnapshot === undefined) {\n retrievedSnapshot = await networkSnapshotP;\n method = \"network\";\n }\n }\n } else {\n // Note: There's a race condition here - another caller may come past the undefined check\n // while the first caller is awaiting later async code in this block.\n\n retrievedSnapshot = await cachedSnapshotP;\n\n method = retrievedSnapshot !== undefined ? \"cache\" : \"network\";\n\n if (retrievedSnapshot === undefined) {\n retrievedSnapshot = await this.fetchSnapshot(hostSnapshotOptions);\n }\n }\n if (method === \"network\") {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n props[\"cacheEntryAge\"] = undefined;\n }\n event.end({ ...props, method });\n return retrievedSnapshot;\n },\n );\n\n // Successful call, make network calls only\n this.firstVersionCall = false;\n\n this._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n const { snapshotTree, blobs, ops } = odspSnapshotCacheValue;\n // id should be undefined in case of just ops in snapshot.\n let id: string | undefined;\n if (snapshotTree) {\n id = snapshotTree.id;\n assert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n this.setRootTree(id, snapshotTree);\n }\n if (blobs) {\n this.initBlobsCache(blobs);\n }\n\n this.ops = ops;\n return id ? [{ id, treeId: undefined! }] : [];\n }\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"GetVersions\");\n const { url, headers } = getUrlAndHeadersWithAuth(`${this.snapshotUrl}/versions?count=${count}`, storageToken);\n\n // Fetch the latest snapshot versions for the document\n const response = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"getVersions\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => this.epochTracker.fetchAndParseAsJSON<IDocumentStorageGetVersionsResponse>(url, { headers }, \"versions\"),\n );\n const versionsResponse = response.content;\n if (!versionsResponse) {\n throw new NonRetryableError(\n \"getVersionsReturnedNoResponse\",\n \"No response from /versions endpoint\",\n DriverErrorType.genericNetworkError);\n }\n if (!Array.isArray(versionsResponse.value)) {\n throw new NonRetryableError(\n \"getVersionsReturnedNonArrayResponse\",\n \"Incorrect response from /versions endpoint\",\n DriverErrorType.genericNetworkError);\n }\n return versionsResponse.value.map((version) => {\n // Parse the date from the message\n let date: string | undefined;\n for (const rec of version.message.split(\"\\n\")) {\n const index = rec.indexOf(\":\");\n if (index !== -1 && rec.substr(0, index) === \"Date\") {\n date = rec.substr(index + 1).trim();\n break;\n }\n }\n return {\n date,\n id: version.id,\n treeId: undefined!,\n };\n });\n });\n }\n\n private async fetchSnapshot(hostSnapshotOptions: ISnapshotOptions | undefined) {\n return this.fetchSnapshotCore(hostSnapshotOptions).catch((error) => {\n // Issue #5895:\n // If we are offline, this error is retryable. But that means that RetriableDocumentStorageService\n // will run in circles calling getSnapshotTree, which would result in OdspDocumentStorageService class\n // going getVersions / individual blob download path. This path is very slow, and will not work with\n // delay-loaded data stores and ODSP storage deleting old snapshots and blobs.\n if (typeof error === \"object\" && error !== null) {\n error.canRetry = false;\n }\n throw error;\n });\n }\n\n private async fetchSnapshotCore(hostSnapshotOptions: ISnapshotOptions | undefined) {\n const snapshotOptions: ISnapshotOptions = {\n mds: this.maxSnapshotSizeLimit,\n ...hostSnapshotOptions,\n timeout: hostSnapshotOptions?.timeout ? Math.min(hostSnapshotOptions.timeout, this.maxSnapshotFetchTimeout) : this.maxSnapshotFetchTimeout,\n };\n\n // No limit on size of snapshot or time to fetch, as otherwise we fail all clients to summarize\n if (this.hostPolicy.summarizerClient) {\n snapshotOptions.mds = undefined;\n snapshotOptions.timeout = undefined;\n }\n\n const snapshotDownloader = async (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n options: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => {\n return downloadSnapshot(\n finalOdspResolvedUrl,\n storageToken,\n this.logger,\n options,\n this.hostPolicy.fetchBinarySnapshotFormat,\n controller,\n this.epochTracker,\n );\n };\n const putInCache = async (valueWithEpoch: IVersionedValueWithEpoch) => {\n return this.cache.persistedCache.put(\n createCacheSnapshotKey(this.odspResolvedUrl),\n // Epoch tracker will add the epoch and version to the value here. So just send value to cache.\n valueWithEpoch.value,\n );\n };\n const removeEntries = async () => this.cache.persistedCache.removeEntries();\n try {\n const odspSnapshot = await fetchSnapshotWithRedeem(\n this.odspResolvedUrl,\n this.getStorageToken,\n snapshotOptions,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback);\n return odspSnapshot;\n } catch (error) {\n const errorType = error.errorType;\n // If the snapshot size is too big and the host specified the size limitation(specified in hostSnapshotOptions), then don't try to fetch the snapshot again.\n if ((errorType === OdspErrorType.snapshotTooBig && hostSnapshotOptions?.mds !== undefined) && (this.hostPolicy.summarizerClient !== true)) {\n throw error;\n }\n // If the first snapshot request was with blobs and we either timed out or the size was too big, then try to fetch without blobs.\n if ((errorType === OdspErrorType.snapshotTooBig || errorType === OdspErrorType.fetchTimeout) && snapshotOptions.blobs) {\n this.logger.sendErrorEvent({\n eventName: \"TreeLatest_SecondCall\",\n errorType,\n });\n const snapshotOptionsWithoutBlobs: ISnapshotOptions = { ...snapshotOptions, blobs: 0, mds: undefined, timeout: undefined };\n const odspSnapshot = await fetchSnapshotWithRedeem(\n this.odspResolvedUrl,\n this.getStorageToken,\n snapshotOptionsWithoutBlobs,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback);\n return odspSnapshot;\n }\n throw error;\n }\n }\n\n public async write(tree: api.ITree, parents: string[], message: string): Promise<api.IVersion> {\n this.checkSnapshotUrl();\n\n throw new Error(\"Not supported\");\n }\n\n public async uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string> {\n this.checkSnapshotUrl();\n\n // Enable flushing only if we have single commit summary and this is not the initial summary for an empty file\n if (\".protocol\" in summary.tree && context.ackHandle !== undefined) {\n let retry = 0;\n for (;;) {\n const result = await this.flushCallback();\n const seq = result.lastPersistedSequenceNumber;\n if (seq !== undefined && seq >= context.referenceSequenceNumber) {\n break;\n }\n\n retry++;\n if (retry > 3) {\n this.logger.sendErrorEvent({\n eventName: \"FlushFailure\",\n ...result,\n retry,\n referenceSequenceNumber: context.referenceSequenceNumber,\n });\n break;\n }\n\n this.logger.sendPerformanceEvent({\n eventName: \"FlushExtraCall\",\n ...result,\n retry,\n referenceSequenceNumber: context.referenceSequenceNumber,\n });\n\n await delay(1000 * (result.retryAfter ?? 1));\n }\n }\n\n const id = await PerformanceEvent.timedExecAsync(this.logger,\n { eventName: \"uploadSummaryWithContext\" },\n async () => this.odspSummaryUploadManager.writeSummaryTree(summary, context));\n return id;\n }\n\n public async downloadSummary(commit: api.ISummaryHandle): Promise<api.ISummaryTree> {\n throw new Error(\"Not implemented yet\");\n }\n\n private setRootTree(id: string, tree: api.ISnapshotTree) {\n this.commitCache.set(id, tree);\n }\n\n private initBlobsCache(blobs: Map<string, ArrayBuffer>) {\n this.blobCache.addBlobs(blobs);\n }\n\n private checkSnapshotUrl() {\n if (!this.snapshotUrl) {\n throw new NonRetryableError(\n \"noSnapshotUrlProvided\",\n \"Method failed because no snapshot url was available\",\n DriverErrorType.genericError);\n }\n }\n\n private checkAttachmentPOSTUrl() {\n if (!this.attachmentPOSTUrl) {\n throw new NonRetryableError(\n \"noAttachmentPOSTUrlProvided\",\n \"Method failed because no attachment POST url was available\",\n DriverErrorType.genericError);\n }\n }\n\n private checkAttachmentGETUrl() {\n if (!this.attachmentGETUrl) {\n throw new NonRetryableError(\n \"noAttachmentGETUrlWasProvided\",\n \"Method failed because no attachment GET url was available\",\n DriverErrorType.genericError);\n }\n }\n\n private async readTree(id: string): Promise<api.ISnapshotTree | null> {\n if (!this.snapshotUrl) {\n return null;\n }\n let tree = this.commitCache.get(id);\n if (!tree) {\n tree = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"ReadCommit\");\n const snapshotDownloader = async (url: string, fetchOptions: {[index: string]: any}) => {\n return this.epochTracker.fetchAndParseAsJSON(\n url,\n fetchOptions,\n \"snapshotTree\",\n );\n };\n const snapshot = await fetchSnapshot(this.snapshotUrl!, storageToken, id, this.fetchFullSnapshot, this.logger, snapshotDownloader);\n let treeId = \"\";\n if (snapshot.snapshotTree) {\n assert(snapshot.snapshotTree.id !== undefined, 0x222 /* \"Root tree should contain the id!!\" */);\n treeId = snapshot.snapshotTree.id;\n this.setRootTree(treeId, snapshot.snapshotTree);\n }\n if (snapshot.blobs) {\n this.initBlobsCache(snapshot.blobs);\n }\n // If the version id doesn't match with the id of the tree, then use the id of first tree which in that case\n // will be the actual id of tree to be fetched.\n return this.commitCache.get(id) ?? this.commitCache.get(treeId);\n });\n }\n\n if (!tree) {\n return null;\n }\n\n return tree;\n }\n\n /**\n * Reads a summary tree\n * @param protocolTreeOrId - Protocol snapshot tree or id of the protocol tree\n * @param appTreeId - Id of the app tree\n */\n private async readSummaryTree(protocolTreeOrId: api.ISnapshotTree | string, appTreeId: string): Promise<api.ISnapshotTree> {\n // Load the app and protocol trees and return them\n let hierarchicalProtocolTree: api.ISnapshotTree | null;\n if (typeof (protocolTreeOrId) === \"string\") {\n // Backwards compat for older summaries\n hierarchicalProtocolTree = await this.readTree(protocolTreeOrId);\n } else {\n hierarchicalProtocolTree = protocolTreeOrId;\n }\n\n const hierarchicalAppTree = await this.readTree(appTreeId);\n if (!hierarchicalProtocolTree) {\n throw new Error(\"Invalid protocol tree\");\n }\n\n if (!hierarchicalAppTree) {\n throw new Error(\"Invalid app tree\");\n }\n\n if (hierarchicalProtocolTree.blobs) {\n const attributesBlob = hierarchicalProtocolTree.blobs.attributes;\n if (attributesBlob) {\n this.attributesBlobHandles.add(attributesBlob);\n }\n }\n return this.combineProtocolAndAppSnapshotTree(hierarchicalAppTree, hierarchicalProtocolTree);\n }\n\n private combineProtocolAndAppSnapshotTree(\n hierarchicalAppTree: api.ISnapshotTree,\n hierarchicalProtocolTree: api.ISnapshotTree,\n ) {\n const summarySnapshotTree: api.ISnapshotTree = {\n blobs: {\n ...hierarchicalAppTree.blobs,\n },\n commits: {\n ...hierarchicalAppTree.commits,\n },\n trees: {\n ...hierarchicalAppTree.trees,\n // the app tree could have a .protocol\n // in that case we want to server protocol to override it\n \".protocol\": hierarchicalProtocolTree,\n },\n };\n\n return summarySnapshotTree;\n }\n}\n\n/* eslint-enable max-len */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDriverUrlResolverForShareLink.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAkB,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAoB,MAAM,oCAAoC,CAAC;AAG5F,OAAO,EACH,gBAAgB,EAChB,YAAY,EAEZ,6BAA6B,EAC7B,YAAY,
|
|
1
|
+
{"version":3,"file":"odspDriverUrlResolverForShareLink.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAkB,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAoB,MAAM,oCAAoC,CAAC;AAG5F,OAAO,EACH,gBAAgB,EAChB,YAAY,EAEZ,6BAA6B,EAC7B,YAAY,EAEf,MAAM,yCAAyC,CAAC;AAOjD,OAAO,EAAE,yBAAyB,EAAqB,MAAM,mBAAmB,CAAC;AAMjF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC1D;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED;;;;GAIG;AACH,qBAAa,iCAAkC,YAAW,YAAY;IAkB9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAjB7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAsC;IACvE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAoC;IAE1E;;;;;;;;;OASG;gBAEC,qBAAqB,CAAC,EAAE,qBAAqB,GAAG,SAAS,EACzD,MAAM,CAAC,EAAE,oBAAoB,EACZ,OAAO,CAAC,oBAAQ;IAWrC;;;OAGG;IACI,mBAAmB,CAAC,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAyBrF,OAAO,CAAC,MAAM;IAId;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgClE,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,0BAA0B;YAqBpB,mBAAmB;IA8BjC;;;;;OAKG;IACU,cAAc,CACvB,WAAW,EAAE,YAAY,EACzB,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,iBAAiB,GAChC,OAAO,CAAC,MAAM,CAAC;IAwBlB;;OAEG;WACW,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB;IAQtF;;OAEG;WACW,cAAc,CAAC,OAAO,EAAE,yBAAyB;CAGlE"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { PromiseCache } from "@fluidframework/common-utils";
|
|
6
6
|
import { isFluidPackage } from "@fluidframework/core-interfaces";
|
|
7
|
-
import {
|
|
7
|
+
import { NonRetryableError } from "@fluidframework/driver-utils";
|
|
8
8
|
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
9
|
-
import { isTokenFromCache, } from "@fluidframework/odsp-driver-definitions";
|
|
9
|
+
import { isTokenFromCache, OdspErrorType, } from "@fluidframework/odsp-driver-definitions";
|
|
10
10
|
import { getLocatorFromOdspUrl, storeLocatorInOdspUrl, encodeOdspFluidDataStoreLocator, locatorQueryParamName, } from "./odspFluidFileLink";
|
|
11
11
|
import { SharingLinkHeader } from "./contractsPublic";
|
|
12
12
|
import { createOdspUrl } from "./createOdspUrl";
|
|
@@ -86,7 +86,8 @@ export class OdspDriverUrlResolverForShareLink {
|
|
|
86
86
|
// We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId
|
|
87
87
|
// when redeeming the share link during the redeem fallback for trees latest call becomes greater than
|
|
88
88
|
// the eligible length.
|
|
89
|
-
odspResolvedUrl.
|
|
89
|
+
odspResolvedUrl.sharingLinkToRedeem = this.removeNavParam(request.url);
|
|
90
|
+
odspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo || {}, { sharingLinkToRedeem: odspResolvedUrl.sharingLinkToRedeem });
|
|
90
91
|
}
|
|
91
92
|
if (odspResolvedUrl.itemId) {
|
|
92
93
|
// Kick start the sharing link request if we don't have it already as a performance optimization.
|
|
@@ -106,7 +107,7 @@ export class OdspDriverUrlResolverForShareLink {
|
|
|
106
107
|
return async (options) => {
|
|
107
108
|
return PerformanceEvent.timedExecAsync(logger, { eventName: "GetSharingLinkToken" }, async (event) => tokenFetcher(options).then((tokenResponse) => {
|
|
108
109
|
if (tokenResponse === null) {
|
|
109
|
-
|
|
110
|
+
throw new NonRetryableError("shareLinkTokenIsNull", "Token callback returned null", OdspErrorType.fetchTokenError);
|
|
110
111
|
}
|
|
111
112
|
event.end({ fromCache: isTokenFromCache(tokenResponse) });
|
|
112
113
|
return tokenResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAA+B,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAG9F,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAGH,gBAAgB,GAGnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACH,qBAAqB,EACrB,qBA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AC,OAAkC;QAC3D,OAAO,+BAA+B,CAAC,OAAO,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 { PromiseCache } from \"@fluidframework/common-utils\";\nimport { IFluidCodeDetails, IRequest, isFluidPackage } from \"@fluidframework/core-interfaces\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { fetchTokenErrorCode, throwOdspNetworkError } from \"@fluidframework/odsp-doclib-utils\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspResolvedUrl,\n IdentityType,\n isTokenFromCache,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n getLocatorFromOdspUrl,\n storeLocatorInOdspUrl,\n encodeOdspFluidDataStoreLocator,\n locatorQueryParamName,\n} from \"./odspFluidFileLink\";\nimport { OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport { getOdspResolvedUrl, createOdspLogger } from \"./odspUtils\";\nimport { getFileLink } from \"./getFileLink\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n */\nexport interface ShareLinkFetcherProps {\n /**\n * Callback method that is used to fetch access token necessary to call API that produces share link\n */\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>;\n /**\n * Identity type determining the shape of share link as it differs for Enterprise and Consumer users.\n */\n identityType: IdentityType;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.\n * This resolver also handles share links and try to generate one for the use by the app.\n */\nexport class OdspDriverUrlResolverForShareLink implements IUrlResolver {\n private readonly logger: ITelemetryLogger;\n private readonly sharingLinkCache = new PromiseCache<string, string>();\n private readonly shareLinkFetcherProps: ShareLinkFetcherProps | undefined;\n\n /**\n * Creates url resolver instance\n * @param shareLinkFetcherProps - properties used when fetching share link.\n * Can be set as 'undefined' for cases where share link is not needed. Currently, only\n * getAbsoluteUrl() method requires share link.\n * @param logger - logger object that is used as telemetry sink\n * @param appName - application name hint that is encoded with url produced by getAbsoluteUrl() method.\n * This hint is used by link handling logic which determines which app to redirect to when user\n * navigates directly to the link.\n */\n public constructor(\n shareLinkFetcherProps?: ShareLinkFetcherProps | undefined,\n logger?: ITelemetryBaseLogger,\n private readonly appName?: string,\n ) {\n this.logger = createOdspLogger(logger);\n if (shareLinkFetcherProps) {\n this.shareLinkFetcherProps = {\n ...shareLinkFetcherProps,\n tokenFetcher: this.toInstrumentedTokenFetcher(this.logger, shareLinkFetcherProps.tokenFetcher),\n };\n }\n }\n\n /**\n * Takes an already generated data store url (from requestUrl) and appends a path to the\n * existing data store information.\n */\n public appendDataStorePath(requestUrl: URL, pathToAppend: string): string | undefined {\n const fluidInfo = getLocatorFromOdspUrl(requestUrl);\n\n if (!fluidInfo) {\n return undefined;\n }\n\n const parsingUrl = new URL(fluidInfo.dataStorePath, `${requestUrl.protocol}//${requestUrl.hostname}`);\n // Determine if the caller is passing a query parameter or path since processing will be different.\n if (pathToAppend.startsWith(\"/?\") || pathToAppend.startsWith(\"?\")) {\n const queryParams = new URLSearchParams(pathToAppend);\n queryParams.forEach((value: string, key: string) => {\n parsingUrl.searchParams.append(key, value);\n });\n fluidInfo.dataStorePath = `${parsingUrl.pathname}${parsingUrl.search}`;\n } else {\n fluidInfo.dataStorePath = `${parsingUrl.pathname}${\n parsingUrl.pathname.endsWith(\"/\") || pathToAppend.startsWith(\"/\") ? \"\" : \"/\"\n }${pathToAppend}/${parsingUrl.search}`;\n }\n storeLocatorInOdspUrl(requestUrl, fluidInfo);\n\n return requestUrl.href;\n }\n\n private getKey(resolvedUrl: IOdspResolvedUrl): string {\n return `${resolvedUrl.siteUrl},${resolvedUrl.driveId},${resolvedUrl.itemId}`;\n }\n\n /**\n * Resolves request URL into driver details\n */\n public async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n const requestToBeResolved = { headers: request.headers, url: request.url };\n const isSharingLinkToRedeem = requestToBeResolved.headers?.[SharingLinkHeader.isSharingLinkToRedeem];\n try {\n const url = new URL(request.url);\n\n const odspFluidInfo = getLocatorFromOdspUrl(url);\n if (odspFluidInfo) {\n requestToBeResolved.url = createOdspUrl(odspFluidInfo);\n }\n } catch {\n // If the locator throws some error, then try to resolve the request as it is.\n }\n\n const odspResolvedUrl = await new OdspDriverUrlResolver().resolve(requestToBeResolved);\n\n if (isSharingLinkToRedeem) {\n // We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId\n // when redeeming the share link during the redeem fallback for trees latest call becomes greater than\n // the eligible length.\n odspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo || {},\n {sharingLinkToRedeem: this.removeNavParam(request.url)});\n }\n if (odspResolvedUrl.itemId) {\n // Kick start the sharing link request if we don't have it already as a performance optimization.\n // For detached create new, we don't have an item id yet and therefore cannot generate a share link\n this.getShareLinkPromise(odspResolvedUrl).catch(() => {});\n }\n return odspResolvedUrl;\n }\n\n private removeNavParam(link: string): string {\n const url = new URL(link);\n const params = new URLSearchParams(url.search);\n params.delete(locatorQueryParamName);\n url.search = params.toString();\n return url.href;\n }\n\n private toInstrumentedTokenFetcher(\n logger: ITelemetryLogger,\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n ): TokenFetcher<OdspResourceTokenFetchOptions> {\n return async (options: OdspResourceTokenFetchOptions) => {\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"GetSharingLinkToken\" },\n async (event) => tokenFetcher(options).then((tokenResponse) => {\n if (tokenResponse === null) {\n throwOdspNetworkError(\"shareLinkTokenIsNull\", fetchTokenErrorCode);\n }\n event.end({ fromCache: isTokenFromCache(tokenResponse) });\n return tokenResponse;\n }));\n };\n }\n\n private async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise<string> {\n if (this.shareLinkFetcherProps === undefined) {\n throw new Error(\"Failed to get share link because share link fetcher props are missing\");\n }\n\n if (!(resolvedUrl.siteUrl && resolvedUrl.driveId && resolvedUrl.itemId)) {\n throw new Error(\"Failed to get share link because necessary information is missing \" +\n \"(e.g. siteUrl, driveId or itemId)\");\n }\n\n const key = this.getKey(resolvedUrl);\n const cachedLinkPromise = this.sharingLinkCache.get(key);\n if (cachedLinkPromise) {\n return cachedLinkPromise;\n }\n const newLinkPromise = getFileLink(\n this.shareLinkFetcherProps.tokenFetcher,\n resolvedUrl,\n this.shareLinkFetcherProps.identityType,\n this.logger,\n ).catch((error) => {\n // This should imply that error is a non-retriable error.\n this.logger.sendErrorEvent({ eventName: \"FluidFileUrlError\" }, error);\n this.sharingLinkCache.remove(key);\n throw error;\n });\n this.sharingLinkCache.add(key, async () => newLinkPromise);\n return newLinkPromise;\n }\n\n /**\n * Requests a driver + data store storage URL. Note that this method requires share link to be fetched\n * and it will throw in case share link fetcher props were not specified when instance was created.\n * @param resolvedUrl - The driver resolved URL\n * @param request - The relative data store path URL. For requesting a driver URL, this value should always be '/'\n */\n public async getAbsoluteUrl(\n resolvedUrl: IResolvedUrl,\n dataStorePath: string,\n codeDetails?: IFluidCodeDetails,\n ): Promise<string> {\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n const shareLink = await this.getShareLinkPromise(odspResolvedUrl);\n\n const shareLinkUrl = new URL(shareLink);\n\n const containerPackageName =\n isFluidPackage(codeDetails?.package) ? codeDetails?.package.name : codeDetails?.package ??\n odspResolvedUrl.codeHint?.containerPackageName;\n\n storeLocatorInOdspUrl(shareLinkUrl, {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n dataStorePath,\n appName: this.appName,\n containerPackageName,\n fileVersion: odspResolvedUrl.fileVersion,\n });\n\n return shareLinkUrl.href;\n }\n\n /**\n * Crafts a supported document/driver URL\n */\n public static createDocumentUrl(baseUrl: string, driverInfo: OdspFluidDataStoreLocator) {\n const url = new URL(baseUrl);\n\n storeLocatorInOdspUrl(url, driverInfo);\n\n return url.href;\n }\n\n /**\n * Crafts a supported data store nav param\n */\n public static createNavParam(locator: OdspFluidDataStoreLocator) {\n return encodeOdspFluidDataStoreLocator(locator);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAA+B,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAG9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAGH,gBAAgB,EAGhB,aAAa,GAChB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA6B,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgB5C;;;;GAIG;AACH,MAAM,OAAO,iCAAiC;IAK1C;;;;;;;;;OASG;IACH,YACI,qBAAyD,EACzD,MAA6B,EACZ,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAhBpB,qBAAgB,GAAG,IAAI,YAAY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GACtB,cAAc,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,IAAI,CAAC,CAAC,OAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,yCACvF,eAAe,CAAC,QAAQ,0CAAE,oBAAoB,CAAC;QAEnD,qBAAqB,CAAC,YAAY,EAAE;YAChC,OAAO,EAAE,eAAe,CAAC,OAAO;YAChC,OAAO,EAAE,eAAe,CAAC,OAAO;YAChC,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,aAAa;YACb,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,oBAAoB;YACpB,WAAW,EAAE,eAAe,CAAC,WAAW;SAC3C,CAAC,CAAC;QAEH,OAAO,YAAY,CAAC,IAAI,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,iBAAiB,CAAC,OAAe,EAAE,UAAqC;QAClF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAE7B,qBAAqB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,cAAc,CAAC,OAAkC;QAC3D,OAAO,+BAA+B,CAAC,OAAO,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 { PromiseCache } from \"@fluidframework/common-utils\";\nimport { IFluidCodeDetails, IRequest, isFluidPackage } from \"@fluidframework/core-interfaces\";\nimport { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspResolvedUrl,\n IdentityType,\n isTokenFromCache,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n OdspErrorType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n getLocatorFromOdspUrl,\n storeLocatorInOdspUrl,\n encodeOdspFluidDataStoreLocator,\n locatorQueryParamName,\n} from \"./odspFluidFileLink\";\nimport { OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport { getOdspResolvedUrl, createOdspLogger } from \"./odspUtils\";\nimport { getFileLink } from \"./getFileLink\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n */\nexport interface ShareLinkFetcherProps {\n /**\n * Callback method that is used to fetch access token necessary to call API that produces share link\n */\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>;\n /**\n * Identity type determining the shape of share link as it differs for Enterprise and Consumer users.\n */\n identityType: IdentityType;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.\n * This resolver also handles share links and try to generate one for the use by the app.\n */\nexport class OdspDriverUrlResolverForShareLink implements IUrlResolver {\n private readonly logger: ITelemetryLogger;\n private readonly sharingLinkCache = new PromiseCache<string, string>();\n private readonly shareLinkFetcherProps: ShareLinkFetcherProps | undefined;\n\n /**\n * Creates url resolver instance\n * @param shareLinkFetcherProps - properties used when fetching share link.\n * Can be set as 'undefined' for cases where share link is not needed. Currently, only\n * getAbsoluteUrl() method requires share link.\n * @param logger - logger object that is used as telemetry sink\n * @param appName - application name hint that is encoded with url produced by getAbsoluteUrl() method.\n * This hint is used by link handling logic which determines which app to redirect to when user\n * navigates directly to the link.\n */\n public constructor(\n shareLinkFetcherProps?: ShareLinkFetcherProps | undefined,\n logger?: ITelemetryBaseLogger,\n private readonly appName?: string,\n ) {\n this.logger = createOdspLogger(logger);\n if (shareLinkFetcherProps) {\n this.shareLinkFetcherProps = {\n ...shareLinkFetcherProps,\n tokenFetcher: this.toInstrumentedTokenFetcher(this.logger, shareLinkFetcherProps.tokenFetcher),\n };\n }\n }\n\n /**\n * Takes an already generated data store url (from requestUrl) and appends a path to the\n * existing data store information.\n */\n public appendDataStorePath(requestUrl: URL, pathToAppend: string): string | undefined {\n const fluidInfo = getLocatorFromOdspUrl(requestUrl);\n\n if (!fluidInfo) {\n return undefined;\n }\n\n const parsingUrl = new URL(fluidInfo.dataStorePath, `${requestUrl.protocol}//${requestUrl.hostname}`);\n // Determine if the caller is passing a query parameter or path since processing will be different.\n if (pathToAppend.startsWith(\"/?\") || pathToAppend.startsWith(\"?\")) {\n const queryParams = new URLSearchParams(pathToAppend);\n queryParams.forEach((value: string, key: string) => {\n parsingUrl.searchParams.append(key, value);\n });\n fluidInfo.dataStorePath = `${parsingUrl.pathname}${parsingUrl.search}`;\n } else {\n fluidInfo.dataStorePath = `${parsingUrl.pathname}${\n parsingUrl.pathname.endsWith(\"/\") || pathToAppend.startsWith(\"/\") ? \"\" : \"/\"\n }${pathToAppend}/${parsingUrl.search}`;\n }\n storeLocatorInOdspUrl(requestUrl, fluidInfo);\n\n return requestUrl.href;\n }\n\n private getKey(resolvedUrl: IOdspResolvedUrl): string {\n return `${resolvedUrl.siteUrl},${resolvedUrl.driveId},${resolvedUrl.itemId}`;\n }\n\n /**\n * Resolves request URL into driver details\n */\n public async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n const requestToBeResolved = { headers: request.headers, url: request.url };\n const isSharingLinkToRedeem = requestToBeResolved.headers?.[SharingLinkHeader.isSharingLinkToRedeem];\n try {\n const url = new URL(request.url);\n\n const odspFluidInfo = getLocatorFromOdspUrl(url);\n if (odspFluidInfo) {\n requestToBeResolved.url = createOdspUrl(odspFluidInfo);\n }\n } catch {\n // If the locator throws some error, then try to resolve the request as it is.\n }\n\n const odspResolvedUrl = await new OdspDriverUrlResolver().resolve(requestToBeResolved);\n\n if (isSharingLinkToRedeem) {\n // We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId\n // when redeeming the share link during the redeem fallback for trees latest call becomes greater than\n // the eligible length.\n odspResolvedUrl.sharingLinkToRedeem = this.removeNavParam(request.url);\n odspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo || {},\n {sharingLinkToRedeem: odspResolvedUrl.sharingLinkToRedeem});\n }\n if (odspResolvedUrl.itemId) {\n // Kick start the sharing link request if we don't have it already as a performance optimization.\n // For detached create new, we don't have an item id yet and therefore cannot generate a share link\n this.getShareLinkPromise(odspResolvedUrl).catch(() => {});\n }\n return odspResolvedUrl;\n }\n\n private removeNavParam(link: string): string {\n const url = new URL(link);\n const params = new URLSearchParams(url.search);\n params.delete(locatorQueryParamName);\n url.search = params.toString();\n return url.href;\n }\n\n private toInstrumentedTokenFetcher(\n logger: ITelemetryLogger,\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n ): TokenFetcher<OdspResourceTokenFetchOptions> {\n return async (options: OdspResourceTokenFetchOptions) => {\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"GetSharingLinkToken\" },\n async (event) => tokenFetcher(options).then((tokenResponse) => {\n if (tokenResponse === null) {\n throw new NonRetryableError(\n \"shareLinkTokenIsNull\",\n \"Token callback returned null\",\n OdspErrorType.fetchTokenError);\n }\n event.end({ fromCache: isTokenFromCache(tokenResponse) });\n return tokenResponse;\n }));\n };\n }\n\n private async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise<string> {\n if (this.shareLinkFetcherProps === undefined) {\n throw new Error(\"Failed to get share link because share link fetcher props are missing\");\n }\n\n if (!(resolvedUrl.siteUrl && resolvedUrl.driveId && resolvedUrl.itemId)) {\n throw new Error(\"Failed to get share link because necessary information is missing \" +\n \"(e.g. siteUrl, driveId or itemId)\");\n }\n\n const key = this.getKey(resolvedUrl);\n const cachedLinkPromise = this.sharingLinkCache.get(key);\n if (cachedLinkPromise) {\n return cachedLinkPromise;\n }\n const newLinkPromise = getFileLink(\n this.shareLinkFetcherProps.tokenFetcher,\n resolvedUrl,\n this.shareLinkFetcherProps.identityType,\n this.logger,\n ).catch((error) => {\n // This should imply that error is a non-retriable error.\n this.logger.sendErrorEvent({ eventName: \"FluidFileUrlError\" }, error);\n this.sharingLinkCache.remove(key);\n throw error;\n });\n this.sharingLinkCache.add(key, async () => newLinkPromise);\n return newLinkPromise;\n }\n\n /**\n * Requests a driver + data store storage URL. Note that this method requires share link to be fetched\n * and it will throw in case share link fetcher props were not specified when instance was created.\n * @param resolvedUrl - The driver resolved URL\n * @param request - The relative data store path URL. For requesting a driver URL, this value should always be '/'\n */\n public async getAbsoluteUrl(\n resolvedUrl: IResolvedUrl,\n dataStorePath: string,\n codeDetails?: IFluidCodeDetails,\n ): Promise<string> {\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n const shareLink = await this.getShareLinkPromise(odspResolvedUrl);\n\n const shareLinkUrl = new URL(shareLink);\n\n const containerPackageName =\n isFluidPackage(codeDetails?.package) ? codeDetails?.package.name : codeDetails?.package ??\n odspResolvedUrl.codeHint?.containerPackageName;\n\n storeLocatorInOdspUrl(shareLinkUrl, {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n dataStorePath,\n appName: this.appName,\n containerPackageName,\n fileVersion: odspResolvedUrl.fileVersion,\n });\n\n return shareLinkUrl.href;\n }\n\n /**\n * Crafts a supported document/driver URL\n */\n public static createDocumentUrl(baseUrl: string, driverInfo: OdspFluidDataStoreLocator) {\n const url = new URL(baseUrl);\n\n storeLocatorInOdspUrl(url, driverInfo);\n\n return url.href;\n }\n\n /**\n * Crafts a supported data store nav param\n */\n public static createNavParam(locator: OdspFluidDataStoreLocator) {\n return encodeOdspFluidDataStoreLocator(locator);\n }\n}\n"]}
|
package/lib/odspError.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspError.d.ts","sourceRoot":"","sources":["../src/odspError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"odspError.d.ts","sourceRoot":"","sources":["../src/odspError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,k6BAWxF"}
|
package/lib/odspError.js
CHANGED
|
@@ -8,6 +8,8 @@ import { createOdspNetworkError } from "@fluidframework/odsp-doclib-utils";
|
|
|
8
8
|
*/
|
|
9
9
|
export function errorObjectFromSocketError(socketError, handler) {
|
|
10
10
|
const message = `OdspSocketError (${handler}): ${socketError.message}`;
|
|
11
|
-
|
|
11
|
+
const error = createOdspNetworkError(`odspSocketError [${handler}]`, message, socketError.code, socketError.retryAfter);
|
|
12
|
+
error.addTelemetryProperties({ odspError: true, relayServiceError: true });
|
|
13
|
+
return error;
|
|
12
14
|
}
|
|
13
15
|
//# sourceMappingURL=odspError.js.map
|
package/lib/odspError.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspError.js","sourceRoot":"","sources":["../src/odspError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAG3E;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAA6B,EAAE,OAAe;IACrF,MAAM,OAAO,GAAG,oBAAoB,OAAO,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IACvE,
|
|
1
|
+
{"version":3,"file":"odspError.js","sourceRoot":"","sources":["../src/odspError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAG3E;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAA6B,EAAE,OAAe;IACrF,MAAM,OAAO,GAAG,oBAAoB,OAAO,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IACvE,MAAM,KAAK,GAAG,sBAAsB,CAChC,oBAAoB,OAAO,GAAG,EAC9B,OAAO,EACP,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5B,KAAK,CAAC,sBAAsB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IAE3E,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createOdspNetworkError } from \"@fluidframework/odsp-doclib-utils\";\nimport { IOdspSocketError } from \"./contracts\";\n\n/**\n * Returns network error based on error object from ODSP socket (IOdspSocketError)\n */\nexport function errorObjectFromSocketError(socketError: IOdspSocketError, handler: string) {\n const message = `OdspSocketError (${handler}): ${socketError.message}`;\n const error = createOdspNetworkError(\n `odspSocketError [${handler}]`,\n message,\n socketError.code,\n socketError.retryAfter);\n\n error.addTelemetryProperties({ odspError: true, relayServiceError: true });\n\n return error;\n}\n"]}
|
|
@@ -14,9 +14,9 @@ import { EpochTracker } from "./epochTracker";
|
|
|
14
14
|
export declare class OdspSummaryUploadManager {
|
|
15
15
|
private readonly snapshotUrl;
|
|
16
16
|
private readonly getStorageToken;
|
|
17
|
-
private readonly logger;
|
|
18
17
|
private readonly epochTracker;
|
|
19
18
|
private lastSummaryProposalHandle;
|
|
19
|
+
private readonly mc;
|
|
20
20
|
constructor(snapshotUrl: string, getStorageToken: InstrumentedStorageTokenFetcher, logger: ITelemetryLogger, epochTracker: EpochTracker);
|
|
21
21
|
writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
22
22
|
private writeSummaryTreeCore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspSummaryUploadManager.d.ts","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAU1F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"odspSummaryUploadManager.d.ts","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAU1F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM9C;;;GAGG;AACH,qBAAa,wBAAwB;IAM7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAEhC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAPjC,OAAO,CAAC,yBAAyB,CAAqB;IACtD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;gBAGlB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,+BAA+B,EACjE,MAAM,EAAE,gBAAgB,EACP,YAAY,EAAE,YAAY;IAKlC,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,eAAe;YAmBhE,oBAAoB;IAuDlC;;;;;;;;OAQG;YACW,4BAA4B;CAuG7C"}
|