@fluidframework/odsp-driver 0.58.2002 → 0.59.1000
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/compactSnapshotParser.d.ts +1 -0
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +8 -7
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/createNewUtils.js +0 -1
- package/dist/createNewUtils.js.map +1 -1
- package/dist/epochTracker.d.ts +12 -0
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +18 -22
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts +11 -0
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +53 -68
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/odspDocumentService.d.ts +2 -1
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +14 -7
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +2 -2
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +6 -6
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +0 -6
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +9 -58
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDriverUrlResolver.d.ts +2 -6
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/odspDriverUrlResolver.js +15 -10
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -6
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +12 -9
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/odspSnapshotParser.js +1 -5
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +9 -6
- package/dist/odspSummaryUploadManager.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/lib/compactSnapshotParser.d.ts +1 -0
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +7 -6
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/createNewUtils.js +0 -1
- package/lib/createNewUtils.js.map +1 -1
- package/lib/epochTracker.d.ts +12 -0
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +19 -23
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts +11 -0
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +55 -70
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/odspDocumentService.d.ts +2 -1
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +14 -7
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts +2 -2
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +6 -6
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +0 -6
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +9 -58
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDriverUrlResolver.d.ts +2 -6
- package/lib/odspDriverUrlResolver.d.ts.map +1 -1
- package/lib/odspDriverUrlResolver.js +14 -9
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -6
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +10 -7
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspSnapshotParser.d.ts.map +1 -1
- package/lib/odspSnapshotParser.js +1 -5
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +9 -6
- package/lib/odspSummaryUploadManager.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/package.json +19 -14
- package/src/compactSnapshotParser.ts +14 -12
- package/src/createNewUtils.ts +0 -1
- package/src/epochTracker.ts +34 -25
- package/src/fetchSnapshot.ts +57 -89
- package/src/odspDocumentService.ts +8 -5
- package/src/odspDocumentServiceFactoryCore.ts +7 -2
- package/src/odspDocumentStorageManager.ts +10 -64
- package/src/odspDriverUrlResolver.ts +18 -9
- package/src/odspDriverUrlResolverForShareLink.ts +11 -8
- package/src/odspSnapshotParser.ts +1 -4
- package/src/odspSummaryUploadManager.ts +7 -6
- package/src/packageVersion.ts +1 -1
|
@@ -64,12 +64,6 @@ export declare class OdspDocumentStorageService implements IDocumentStorageServi
|
|
|
64
64
|
private checkAttachmentPOSTUrl;
|
|
65
65
|
private checkAttachmentGETUrl;
|
|
66
66
|
private readTree;
|
|
67
|
-
/**
|
|
68
|
-
* Reads a summary tree
|
|
69
|
-
* @param protocolTreeOrId - Protocol snapshot tree or id of the protocol tree
|
|
70
|
-
* @param appTreeId - Id of the app tree
|
|
71
|
-
*/
|
|
72
|
-
private readSummaryTree;
|
|
73
67
|
private combineProtocolAndAppSnapshotTree;
|
|
74
68
|
}
|
|
75
69
|
//# sourceMappingURL=odspDocumentStorageManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;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AAC,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAInF,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,qBAAqB;YASf,QAAQ;IA8CtB,OAAO,CAAC,iCAAiC;CAkB5C"}
|
|
@@ -250,35 +250,17 @@ class OdspDocumentStorageService {
|
|
|
250
250
|
if (!snapshotTree) {
|
|
251
251
|
return null;
|
|
252
252
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
let finalTree;
|
|
259
|
-
// For container loaded from detach new summary, we will not have a commit for ".app" in downloaded summary as the client uploaded both
|
|
260
|
-
// ".app" and ".protocol" trees by itself. For other summaries, we will have ".app" as commit because client previously only uploaded the
|
|
261
|
-
// app summary.
|
|
262
|
-
if (commits && commits[".app"]) {
|
|
263
|
-
// The latest snapshot is a summary
|
|
264
|
-
// attempt to read .protocol from commits for backwards compat
|
|
265
|
-
finalTree = await this.readSummaryTree(commits[".protocol"] || snapshotTree.trees[".protocol"], commits[".app"]);
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
if (snapshotTree.blobs) {
|
|
269
|
-
const attributesBlob = snapshotTree.blobs.attributes;
|
|
270
|
-
if (attributesBlob) {
|
|
271
|
-
this.attributesBlobHandles.add(attributesBlob);
|
|
272
|
-
}
|
|
253
|
+
if (snapshotTree.blobs) {
|
|
254
|
+
const attributesBlob = snapshotTree.blobs.attributes;
|
|
255
|
+
if (attributesBlob) {
|
|
256
|
+
this.attributesBlobHandles.add(attributesBlob);
|
|
273
257
|
}
|
|
274
|
-
snapshotTree.commits = commits;
|
|
275
|
-
// When we upload the container snapshot, we upload appTree in ".app" and protocol tree in ".protocol"
|
|
276
|
-
// So when we request the snapshot we get ".app" as tree and not as commit node as in the case just above.
|
|
277
|
-
const appTree = snapshotTree.trees[".app"];
|
|
278
|
-
const protocolTree = snapshotTree.trees[".protocol"];
|
|
279
|
-
finalTree = this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);
|
|
280
258
|
}
|
|
281
|
-
|
|
259
|
+
// When we upload the container snapshot, we upload appTree in ".app" and protocol tree in ".protocol"
|
|
260
|
+
// So when we request the snapshot we get ".app" as tree and not as commit node as in the case just above.
|
|
261
|
+
const appTree = snapshotTree.trees[".app"];
|
|
262
|
+
const protocolTree = snapshotTree.trees[".protocol"];
|
|
263
|
+
return this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);
|
|
282
264
|
}
|
|
283
265
|
async getVersions(blobid, count) {
|
|
284
266
|
// Regular load workflow uses blobId === documentID to indicate "latest".
|
|
@@ -552,40 +534,9 @@ class OdspDocumentStorageService {
|
|
|
552
534
|
}
|
|
553
535
|
return tree;
|
|
554
536
|
}
|
|
555
|
-
/**
|
|
556
|
-
* Reads a summary tree
|
|
557
|
-
* @param protocolTreeOrId - Protocol snapshot tree or id of the protocol tree
|
|
558
|
-
* @param appTreeId - Id of the app tree
|
|
559
|
-
*/
|
|
560
|
-
async readSummaryTree(protocolTreeOrId, appTreeId) {
|
|
561
|
-
// Load the app and protocol trees and return them
|
|
562
|
-
let hierarchicalProtocolTree;
|
|
563
|
-
if (typeof (protocolTreeOrId) === "string") {
|
|
564
|
-
// Backwards compat for older summaries
|
|
565
|
-
hierarchicalProtocolTree = await this.readTree(protocolTreeOrId);
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
hierarchicalProtocolTree = protocolTreeOrId;
|
|
569
|
-
}
|
|
570
|
-
const hierarchicalAppTree = await this.readTree(appTreeId);
|
|
571
|
-
if (!hierarchicalProtocolTree) {
|
|
572
|
-
throw new Error("Invalid protocol tree");
|
|
573
|
-
}
|
|
574
|
-
if (!hierarchicalAppTree) {
|
|
575
|
-
throw new Error("Invalid app tree");
|
|
576
|
-
}
|
|
577
|
-
if (hierarchicalProtocolTree.blobs) {
|
|
578
|
-
const attributesBlob = hierarchicalProtocolTree.blobs.attributes;
|
|
579
|
-
if (attributesBlob) {
|
|
580
|
-
this.attributesBlobHandles.add(attributesBlob);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
return this.combineProtocolAndAppSnapshotTree(hierarchicalAppTree, hierarchicalProtocolTree);
|
|
584
|
-
}
|
|
585
537
|
combineProtocolAndAppSnapshotTree(hierarchicalAppTree, hierarchicalProtocolTree) {
|
|
586
538
|
const summarySnapshotTree = {
|
|
587
539
|
blobs: Object.assign({}, hierarchicalAppTree.blobs),
|
|
588
|
-
commits: Object.assign({}, hierarchicalAppTree.commits),
|
|
589
540
|
trees: Object.assign(Object.assign({}, hierarchicalAppTree.trees), {
|
|
590
541
|
// the app tree could have a .protocol
|
|
591
542
|
// in that case we want to server protocol to override it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentStorageManager.js","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAGsC;AACtC,qEAEyC;AAEzC,2EAK4C;AAC5C,+DAA8E;AAC9E,qFAKiD;AAOjD,mDAA2F;AAC3F,yEAAsE;AAEtE,2CAIqB;AACrB,iDAA2E;AAC3E,yEAAsE;AAEtE,qDAA+D;AAE/D,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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SACJ,CAAC;QAEF,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AA5qBD,gEA4qBC;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 { defaultCacheExpiryTimeoutMs, EpochTracker } from \"./epochTracker\";\nimport { OdspSummaryUploadManager } from \"./odspSummaryUploadManager\";\nimport { FlushResult } from \"./odspDocumentDeltaConnection\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\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 maximumCacheDurationMs: defaultCacheExpiryTimeoutMs,\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(\n this.snapshotUrl,\n getStorageToken,\n logger,\n epochTracker,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\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(\n `${this.attachmentPOSTUrl}/content`,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\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.propsToLog,\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(\n unAuthedUrl,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\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.propsToLog,\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.propsToLog,\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(\n `${this.snapshotUrl}/versions?count=${count}`,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\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 \"No response from /versions endpoint\",\n DriverErrorType.genericNetworkError,\n { driverVersion });\n }\n if (!Array.isArray(versionsResponse.value)) {\n throw new NonRetryableError(\n \"Incorrect response from /versions endpoint, expected an array\",\n DriverErrorType.genericNetworkError,\n { driverVersion });\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.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback,\n );\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.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback,\n );\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 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 \"Method failed because no snapshot url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private checkAttachmentPOSTUrl() {\n if (!this.attachmentPOSTUrl) {\n throw new NonRetryableError(\n \"Method failed because no attachment POST url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private checkAttachmentGETUrl() {\n if (!this.attachmentGETUrl) {\n throw new NonRetryableError(\n \"Method failed because no attachment GET url was available\",\n DriverErrorType.genericError,\n { driverVersion });\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(\n this.snapshotUrl!,\n storageToken,\n id,\n this.fetchFullSnapshot,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n );\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,+DAGsC;AACtC,qEAEyC;AAEzC,2EAK4C;AAC5C,+DAA8E;AAC9E,qFAKiD;AAOjD,mDAA2F;AAC3F,yEAAsE;AAEtE,2CAIqB;AACrB,iDAA2E;AAC3E,yEAAsE;AA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YAC3C,KAAK,oBACE,mBAAmB,CAAC,KAAK,CAC/B;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;AAtnBD,gEAsnBC;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 { defaultCacheExpiryTimeoutMs, EpochTracker } from \"./epochTracker\";\nimport { OdspSummaryUploadManager } from \"./odspSummaryUploadManager\";\nimport { FlushResult } from \"./odspDocumentDeltaConnection\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\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 maximumCacheDurationMs: defaultCacheExpiryTimeoutMs,\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(\n this.snapshotUrl,\n getStorageToken,\n logger,\n epochTracker,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\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(\n `${this.attachmentPOSTUrl}/content`,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\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.propsToLog,\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(\n unAuthedUrl,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\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.propsToLog,\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.propsToLog,\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\n if (snapshotTree.blobs) {\n const attributesBlob = snapshotTree.blobs.attributes;\n if (attributesBlob) {\n this.attributesBlobHandles.add(attributesBlob);\n }\n }\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\n return this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);\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(\n `${this.snapshotUrl}/versions?count=${count}`,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\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 \"No response from /versions endpoint\",\n DriverErrorType.genericNetworkError,\n { driverVersion });\n }\n if (!Array.isArray(versionsResponse.value)) {\n throw new NonRetryableError(\n \"Incorrect response from /versions endpoint, expected an array\",\n DriverErrorType.genericNetworkError,\n { driverVersion });\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.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback,\n );\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.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback,\n );\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 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 \"Method failed because no snapshot url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private checkAttachmentPOSTUrl() {\n if (!this.attachmentPOSTUrl) {\n throw new NonRetryableError(\n \"Method failed because no attachment POST url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private checkAttachmentGETUrl() {\n if (!this.attachmentGETUrl) {\n throw new NonRetryableError(\n \"Method failed because no attachment GET url was available\",\n DriverErrorType.genericError,\n { driverVersion });\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(\n this.snapshotUrl!,\n storageToken,\n id,\n this.fetchFullSnapshot,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n );\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 private combineProtocolAndAppSnapshotTree(\n hierarchicalAppTree: api.ISnapshotTree,\n hierarchicalProtocolTree: api.ISnapshotTree,\n ) {\n const summarySnapshotTree: api.ISnapshotTree = {\n blobs: {\n ...hierarchicalAppTree.blobs,\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,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { IFluidCodeDetails, IRequest } from "@fluidframework/core-interfaces";
|
|
1
|
+
import { IRequest } from "@fluidframework/core-interfaces";
|
|
6
2
|
import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
3
|
import { IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions";
|
|
8
4
|
/**
|
|
@@ -12,6 +8,6 @@ import { IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions";
|
|
|
12
8
|
export declare class OdspDriverUrlResolver implements IUrlResolver {
|
|
13
9
|
constructor();
|
|
14
10
|
resolve(request: IRequest): Promise<IOdspResolvedUrl>;
|
|
15
|
-
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string, packageInfoSource?: IContainerPackageInfo
|
|
11
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string, packageInfoSource?: IContainerPackageInfo): Promise<string>;
|
|
16
12
|
}
|
|
17
13
|
//# sourceMappingURL=odspDriverUrlResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDriverUrlResolver.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"odspDriverUrlResolver.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAGH,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAqC,MAAM,yCAAyC,CAAC;AA+C9G;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,YAAY;;IAGzC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA6FrD,cAAc,CACvB,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,qBAAqB,GAC1C,OAAO,CAAC,MAAM,CAAC;CA4BrB"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OdspDriverUrlResolver = void 0;
|
|
2
4
|
/*!
|
|
3
5
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
6
|
* Licensed under the MIT License.
|
|
5
7
|
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.OdspDriverUrlResolver = void 0;
|
|
8
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
-
const core_interfaces_1 = require("@fluidframework/core-interfaces");
|
|
10
9
|
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
11
10
|
const odsp_driver_definitions_1 = require("@fluidframework/odsp-driver-definitions");
|
|
11
|
+
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
12
12
|
const createOdspUrl_1 = require("./createOdspUrl");
|
|
13
13
|
const odspUrlHelper_1 = require("./odspUrlHelper");
|
|
14
14
|
const odspUtils_1 = require("./odspUtils");
|
|
15
15
|
const odspPublicUtils_1 = require("./odspPublicUtils");
|
|
16
16
|
const contractsPublic_1 = require("./contractsPublic");
|
|
17
|
+
const packageVersion_1 = require("./packageVersion");
|
|
17
18
|
function getUrlBase(siteUrl, driveId, itemId, fileVersion) {
|
|
18
19
|
const siteOrigin = new URL(siteUrl).origin;
|
|
19
20
|
const version = fileVersion ? `versions/${fileVersion}/` : "";
|
|
@@ -62,7 +63,7 @@ class OdspDriverUrlResolver {
|
|
|
62
63
|
const packageName = searchParams.get("containerPackageName");
|
|
63
64
|
const createLinkType = searchParams.get("createLinkType");
|
|
64
65
|
if (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {
|
|
65
|
-
throw new
|
|
66
|
+
throw new driver_utils_1.NonRetryableError("Proper new file params should be there!!", driver_definitions_1.DriverErrorType.genericError, { driverVersion: packageVersion_1.pkgVersion });
|
|
66
67
|
}
|
|
67
68
|
let shareLinkInfo;
|
|
68
69
|
if (createLinkType && createLinkType in odsp_driver_definitions_1.ShareLinkTypes) {
|
|
@@ -137,24 +138,28 @@ class OdspDriverUrlResolver {
|
|
|
137
138
|
};
|
|
138
139
|
}
|
|
139
140
|
async getAbsoluteUrl(resolvedUrl, relativeUrl, packageInfoSource) {
|
|
140
|
-
var _a;
|
|
141
|
+
var _a, _b, _c, _d;
|
|
141
142
|
let dataStorePath = relativeUrl;
|
|
142
143
|
if (dataStorePath.startsWith("/")) {
|
|
143
144
|
dataStorePath = dataStorePath.substr(1);
|
|
144
145
|
}
|
|
145
146
|
const odspResolvedUrl = odspUtils_1.getOdspResolvedUrl(resolvedUrl);
|
|
146
|
-
// back-compat:
|
|
147
|
+
// back-compat: GitHub #9653
|
|
148
|
+
const isFluidPackage = (pkg) => typeof pkg === "object"
|
|
149
|
+
&& typeof (pkg === null || pkg === void 0 ? void 0 : pkg.name) === "string"
|
|
150
|
+
&& typeof (pkg === null || pkg === void 0 ? void 0 : pkg.fluid) === "object";
|
|
147
151
|
let containerPackageName;
|
|
148
152
|
if (packageInfoSource && "name" in packageInfoSource) {
|
|
149
153
|
containerPackageName = packageInfoSource.name;
|
|
154
|
+
// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails
|
|
150
155
|
}
|
|
151
|
-
else if (
|
|
152
|
-
containerPackageName = packageInfoSource === null ||
|
|
156
|
+
else if (isFluidPackage((_a = packageInfoSource) === null || _a === void 0 ? void 0 : _a.package)) {
|
|
157
|
+
containerPackageName = (_b = packageInfoSource) === null || _b === void 0 ? void 0 : _b.package.name;
|
|
153
158
|
}
|
|
154
159
|
else {
|
|
155
|
-
containerPackageName = packageInfoSource === null ||
|
|
160
|
+
containerPackageName = (_c = packageInfoSource) === null || _c === void 0 ? void 0 : _c.package;
|
|
156
161
|
}
|
|
157
|
-
containerPackageName = containerPackageName !== null && containerPackageName !== void 0 ? containerPackageName : (
|
|
162
|
+
containerPackageName = containerPackageName !== null && containerPackageName !== void 0 ? containerPackageName : (_d = odspResolvedUrl.codeHint) === null || _d === void 0 ? void 0 : _d.containerPackageName;
|
|
158
163
|
return createOdspUrl_1.createOdspUrl(Object.assign(Object.assign({}, odspResolvedUrl), { containerPackageName,
|
|
159
164
|
dataStorePath }));
|
|
160
165
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDriverUrlResolver.js","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,qEAA8F;AAC9F,2EAK4C;AAC5C,qFAA8G;AAC9G,mDAAgD;AAChD,mDAA6C;AAC7C,2CAAiD;AACjD,uDAAwD;AACxD,uDAA0D;AAE1D,SAAS,UAAU,CAAC,OAAe,EAAE,OAAe,EAAE,MAAc,EAAE,WAAoB;IACtF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,YAAY,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,OAAO,GAAG,0BAAU,CAAC,UAAU,CAAC,WAAW,OAAO,UAAU,MAAM,IAAI,OAAO,EAAE,CAAC;AACpF,CAAC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,OAAe,EAAE,MAAc,EAAE,WAAoB;IAC1F,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAClE,OAAO,GAAG,OAAO,oBAAoB,CAAC;AAC1C,CA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right (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IFluidCodeDetails, IRequest, isFluidPackage } from \"@fluidframework/core-interfaces\";\nimport {\n DriverHeader,\n IContainerPackageInfo,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl, ShareLinkTypes, ShareLinkInfoType } from \"@fluidframework/odsp-driver-definitions\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { getOdspResolvedUrl } from \"./odspUtils\";\nimport { getHashedDocumentId } from \"./odspPublicUtils\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\n\nfunction getUrlBase(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const siteOrigin = new URL(siteUrl).origin;\n const version = fileVersion ? `versions/${fileVersion}/` : \"\";\n return `${getApiRoot(siteOrigin)}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n if (str.startsWith(\"/\")) {\n return str.substr(1);\n }\n\n return str;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n constructor() { }\n\n public async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n if (request.headers && request.headers[DriverHeader.createNew]) {\n const [siteURL, queryString] = request.url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n const fileName = request.headers[DriverHeader.createNew].fileName;\n const driveID = searchParams.get(\"driveId\");\n const filePath = searchParams.get(\"path\");\n const packageName = searchParams.get(\"containerPackageName\");\n const createLinkType = searchParams.get(\"createLinkType\");\n if (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n throw new Error(\"Proper new file params should be there!!\");\n }\n let shareLinkInfo: ShareLinkInfoType | undefined;\n if(createLinkType && createLinkType in ShareLinkTypes) {\n shareLinkInfo = {\n createLink: {\n type: ShareLinkTypes[createLinkType],\n },\n };\n }\n return {\n endpoints: {\n snapshotStorageUrl: \"\",\n attachmentGETStorageUrl: \"\",\n attachmentPOSTStorageUrl: \"\",\n deltaStorageUrl: \"\",\n },\n tokens: {},\n type: \"fluid\",\n odspResolvedUrl: true,\n id: \"odspCreateNew\",\n url: `fluid-odsp://${siteURL}?${queryString}&version=null`,\n siteUrl: siteURL,\n hashedDocumentId: \"\",\n driveId: driveID,\n itemId: \"\",\n fileName,\n summarizer: false,\n codeHint: {\n containerPackageName: packageName ? packageName : undefined,\n },\n fileVersion: undefined,\n shareLinkInfo,\n isClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n };\n }\n const { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } = decodeOdspUrl(request.url);\n const hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n assert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n let documentUrl = `fluid-odsp://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(path)}`;\n\n if (request.url.length > 0) {\n // In case of any additional parameters add them back to the url\n const requestURL = new URL(request.url);\n const searchParams = requestURL.search;\n if (searchParams) {\n documentUrl += searchParams;\n }\n }\n\n const summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\n return {\n type: \"fluid\",\n odspResolvedUrl: true,\n endpoints: {\n snapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n attachmentPOSTStorageUrl: getAttachmentPOSTUrl(siteUrl, driveId, itemId, fileVersion),\n attachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n deltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n },\n id: hashedDocumentId,\n tokens: {},\n url: documentUrl,\n hashedDocumentId,\n siteUrl,\n driveId,\n itemId,\n fileName: \"\",\n summarizer,\n codeHint: {\n containerPackageName,\n },\n fileVersion,\n isClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n };\n }\n\n public async getAbsoluteUrl(\n resolvedUrl: IResolvedUrl,\n relativeUrl: string,\n packageInfoSource?: IContainerPackageInfo | IFluidCodeDetails,\n ): Promise<string> {\n let dataStorePath = relativeUrl;\n if (dataStorePath.startsWith(\"/\")) {\n dataStorePath = dataStorePath.substr(1);\n }\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n // back-compat: IFluidCodeDetails usage to be removed in 0.58.0\n let containerPackageName;\n if (packageInfoSource && \"name\" in packageInfoSource) {\n containerPackageName = packageInfoSource.name;\n } else if (isFluidPackage(packageInfoSource?.package)) {\n containerPackageName = packageInfoSource?.package.name;\n } else {\n containerPackageName = packageInfoSource?.package;\n }\n containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n return createOdspUrl({\n ... odspResolvedUrl,\n containerPackageName,\n dataStorePath,\n });\n }\n}\n\nfunction decodeOdspUrl(url: string): {\n siteUrl: string;\n driveId: string;\n itemId: string;\n path: string;\n containerPackageName?: string;\n fileVersion?: string;\n} {\n const [siteUrl, queryString] = url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n\n const driveId = searchParams.get(\"driveId\");\n const itemId = searchParams.get(\"itemId\");\n const path = searchParams.get(\"path\");\n const containerPackageName = searchParams.get(\"containerPackageName\");\n const fileVersion = searchParams.get(\"fileVersion\");\n\n if (driveId === null) {\n throw new Error(\"ODSP URL did not contain a drive id\");\n }\n\n if (itemId === null) {\n throw new Error(\"ODSP Url did not contain an item id\");\n }\n\n if (path === null) {\n throw new Error(\"ODSP Url did not contain a path\");\n }\n\n return {\n siteUrl,\n driveId: decodeURIComponent(driveId),\n itemId: decodeURIComponent(itemId),\n path: decodeURIComponent(path),\n containerPackageName: containerPackageName ? decodeURIComponent(containerPackageName) : undefined,\n fileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDriverUrlResolver.js","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAAsD;AAEtD,2EAM4C;AAC5C,qFAA8G;AAC9G,+DAAiE;AACjE,mDAAgD;AAChD,mDAA6C;AAC7C,2CAAiD;AACjD,uDAAwD;AACxD,uDAA0D;AAC1D,qDAA8C;AAE9C,SAAS,UAAU,CAAC,OAAe,EAAE,OAAe,EAAE,MAAc,EAAE,WAAoB;IACtF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,YAAY,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,OAAO,GAAG,0BAAU,CAAC,UAAU,CAAC,WAAW,OAAO,UAAU,MAAM,IAAI,OAAO,EAAE,CAAC;AACpF,CAAC;AAED,SAAS,cAAc,CAAC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CAAC,CAAC;KACtD;IAED,OAAO;QACH,OAAO;QACP,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;QACpC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;QAClC,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC;QAC9B,oBAAoB,EAAE,oBAAoB,CAAC,CAAC,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,SAAS;QACjG,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACzE,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n DriverErrorType,\n DriverHeader,\n IContainerPackageInfo,\n IResolvedUrl,\n IUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl, ShareLinkTypes, ShareLinkInfoType } from \"@fluidframework/odsp-driver-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { getOdspResolvedUrl } from \"./odspUtils\";\nimport { getHashedDocumentId } from \"./odspPublicUtils\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\nimport { pkgVersion } from \"./packageVersion\";\n\nfunction getUrlBase(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const siteOrigin = new URL(siteUrl).origin;\n const version = fileVersion ? `versions/${fileVersion}/` : \"\";\n return `${getApiRoot(siteOrigin)}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(siteUrl: string, driveId: string, itemId: string, fileVersion?: string) {\n const urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n return `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n if (str.startsWith(\"/\")) {\n return str.substr(1);\n }\n\n return str;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n constructor() { }\n\n public async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n if (request.headers && request.headers[DriverHeader.createNew]) {\n const [siteURL, queryString] = request.url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n const fileName = request.headers[DriverHeader.createNew].fileName;\n const driveID = searchParams.get(\"driveId\");\n const filePath = searchParams.get(\"path\");\n const packageName = searchParams.get(\"containerPackageName\");\n const createLinkType = searchParams.get(\"createLinkType\");\n if (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n throw new NonRetryableError(\n \"Proper new file params should be there!!\",\n DriverErrorType.genericError,\n { driverVersion: pkgVersion });\n }\n let shareLinkInfo: ShareLinkInfoType | undefined;\n if(createLinkType && createLinkType in ShareLinkTypes) {\n shareLinkInfo = {\n createLink: {\n type: ShareLinkTypes[createLinkType],\n },\n };\n }\n return {\n endpoints: {\n snapshotStorageUrl: \"\",\n attachmentGETStorageUrl: \"\",\n attachmentPOSTStorageUrl: \"\",\n deltaStorageUrl: \"\",\n },\n tokens: {},\n type: \"fluid\",\n odspResolvedUrl: true,\n id: \"odspCreateNew\",\n url: `fluid-odsp://${siteURL}?${queryString}&version=null`,\n siteUrl: siteURL,\n hashedDocumentId: \"\",\n driveId: driveID,\n itemId: \"\",\n fileName,\n summarizer: false,\n codeHint: {\n containerPackageName: packageName ? packageName : undefined,\n },\n fileVersion: undefined,\n shareLinkInfo,\n isClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n };\n }\n const { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } = decodeOdspUrl(request.url);\n const hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n assert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n let documentUrl = `fluid-odsp://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(path)}`;\n\n if (request.url.length > 0) {\n // In case of any additional parameters add them back to the url\n const requestURL = new URL(request.url);\n const searchParams = requestURL.search;\n if (searchParams) {\n documentUrl += searchParams;\n }\n }\n\n const summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\n return {\n type: \"fluid\",\n odspResolvedUrl: true,\n endpoints: {\n snapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n attachmentPOSTStorageUrl: getAttachmentPOSTUrl(siteUrl, driveId, itemId, fileVersion),\n attachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n deltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n },\n id: hashedDocumentId,\n tokens: {},\n url: documentUrl,\n hashedDocumentId,\n siteUrl,\n driveId,\n itemId,\n fileName: \"\",\n summarizer,\n codeHint: {\n containerPackageName,\n },\n fileVersion,\n isClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n };\n }\n\n public async getAbsoluteUrl(\n resolvedUrl: IResolvedUrl,\n relativeUrl: string,\n packageInfoSource?: IContainerPackageInfo,\n ): Promise<string> {\n let dataStorePath = relativeUrl;\n if (dataStorePath.startsWith(\"/\")) {\n dataStorePath = dataStorePath.substr(1);\n }\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n // back-compat: GitHub #9653\n const isFluidPackage = (pkg: any) =>\n typeof pkg === \"object\"\n && typeof pkg?.name === \"string\"\n && typeof pkg?.fluid === \"object\";\n let containerPackageName;\n if (packageInfoSource && \"name\" in packageInfoSource) {\n containerPackageName = packageInfoSource.name;\n // packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n } else if (isFluidPackage((packageInfoSource as any)?.package)) {\n containerPackageName = (packageInfoSource as any)?.package.name;\n } else {\n containerPackageName = (packageInfoSource as any)?.package;\n }\n containerPackageName = containerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n return createOdspUrl({\n ... odspResolvedUrl,\n containerPackageName,\n dataStorePath,\n });\n }\n}\n\nfunction decodeOdspUrl(url: string): {\n siteUrl: string;\n driveId: string;\n itemId: string;\n path: string;\n containerPackageName?: string;\n fileVersion?: string;\n} {\n const [siteUrl, queryString] = url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n\n const driveId = searchParams.get(\"driveId\");\n const itemId = searchParams.get(\"itemId\");\n const path = searchParams.get(\"path\");\n const containerPackageName = searchParams.get(\"containerPackageName\");\n const fileVersion = searchParams.get(\"fileVersion\");\n\n if (driveId === null) {\n throw new Error(\"ODSP URL did not contain a drive id\");\n }\n\n if (itemId === null) {\n throw new Error(\"ODSP Url did not contain an item id\");\n }\n\n if (path === null) {\n throw new Error(\"ODSP Url did not contain a path\");\n }\n\n return {\n siteUrl,\n driveId: decodeURIComponent(driveId),\n itemId: decodeURIComponent(itemId),\n path: decodeURIComponent(path),\n containerPackageName: containerPackageName ? decodeURIComponent(containerPackageName) : undefined,\n fileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n };\n}\n"]}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { IFluidCodeDetails, IRequest } from "@fluidframework/core-interfaces";
|
|
1
|
+
import { IRequest } from "@fluidframework/core-interfaces";
|
|
6
2
|
import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
7
3
|
import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
8
4
|
import { IOdspResolvedUrl, IdentityType, OdspResourceTokenFetchOptions, TokenFetcher } from "@fluidframework/odsp-driver-definitions";
|
|
@@ -59,7 +55,7 @@ export declare class OdspDriverUrlResolverForShareLink implements IUrlResolver {
|
|
|
59
55
|
* @param resolvedUrl - The driver resolved URL
|
|
60
56
|
* @param request - The relative data store path URL. For requesting a driver URL, this value should always be '/'
|
|
61
57
|
*/
|
|
62
|
-
getAbsoluteUrl(resolvedUrl: IResolvedUrl, dataStorePath: string, packageInfoSource?: IContainerPackageInfo
|
|
58
|
+
getAbsoluteUrl(resolvedUrl: IResolvedUrl, dataStorePath: string, packageInfoSource?: IContainerPackageInfo): Promise<string>;
|
|
63
59
|
/**
|
|
64
60
|
* Crafts a supported document/driver URL
|
|
65
61
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDriverUrlResolverForShareLink.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"odspDriverUrlResolverForShareLink.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EACH,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAo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