@fluidframework/odsp-driver 1.2.7 → 2.0.0-dev.1.3.0.96595
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/.mocharc.js +12 -0
- package/README.md +19 -0
- package/dist/ReadBufferUtils.d.ts.map +1 -1
- package/dist/ReadBufferUtils.js +1 -0
- package/dist/ReadBufferUtils.js.map +1 -1
- package/dist/WriteBufferUtils.d.ts +3 -5
- package/dist/WriteBufferUtils.d.ts.map +1 -1
- package/dist/WriteBufferUtils.js +59 -55
- package/dist/WriteBufferUtils.js.map +1 -1
- package/dist/compactSnapshotParser.d.ts +2 -2
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +91 -34
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.d.ts +1 -2
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/compactSnapshotWriter.js +17 -14
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/contracts.d.ts +1 -18
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/createFile.d.ts +1 -1
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createFile.js +53 -16
- package/dist/createFile.js.map +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +0 -1
- package/dist/createNewUtils.js.map +1 -1
- package/dist/createOdspCreateContainerRequest.d.ts +4 -3
- package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/dist/createOdspCreateContainerRequest.js +6 -3
- package/dist/createOdspCreateContainerRequest.js.map +1 -1
- package/dist/epochTracker.d.ts +1 -0
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +24 -5
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts +1 -2
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +22 -27
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.d.ts +3 -6
- package/dist/getFileLink.d.ts.map +1 -1
- package/dist/getFileLink.js +22 -33
- package/dist/getFileLink.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js +1 -2
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts +3 -2
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +9 -12
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +3 -6
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.d.ts +1 -0
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +12 -6
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +29 -6
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +4 -4
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +82 -64
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/dist/odspDocumentStorageServiceBase.js +4 -2
- package/dist/odspDocumentStorageServiceBase.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +4 -4
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspFluidFileLink.js +1 -1
- package/dist/odspFluidFileLink.js.map +1 -1
- package/dist/odspLocationRedirection.d.ts +14 -0
- package/dist/odspLocationRedirection.d.ts.map +1 -0
- package/dist/odspLocationRedirection.js +24 -0
- package/dist/odspLocationRedirection.js.map +1 -0
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/odspSnapshotParser.js +1 -2
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts +6 -3
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +14 -17
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUrlHelper.js +2 -1
- package/dist/odspUrlHelper.js.map +1 -1
- package/dist/odspUtils.d.ts +11 -2
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +32 -5
- package/dist/odspUtils.js.map +1 -1
- package/dist/opsCaching.d.ts.map +1 -1
- package/dist/opsCaching.js +3 -2
- package/dist/opsCaching.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/prefetchLatestSnapshot.d.ts +6 -4
- package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.js +6 -4
- package/dist/prefetchLatestSnapshot.js.map +1 -1
- package/dist/retryUtils.d.ts.map +1 -1
- package/dist/retryUtils.js +8 -4
- package/dist/retryUtils.js.map +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts +30 -18
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +170 -76
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/ReadBufferUtils.d.ts.map +1 -1
- package/lib/ReadBufferUtils.js +1 -0
- package/lib/ReadBufferUtils.js.map +1 -1
- package/lib/WriteBufferUtils.d.ts +3 -5
- package/lib/WriteBufferUtils.d.ts.map +1 -1
- package/lib/WriteBufferUtils.js +61 -57
- package/lib/WriteBufferUtils.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts +2 -2
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +92 -35
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/compactSnapshotWriter.d.ts +1 -2
- package/lib/compactSnapshotWriter.d.ts.map +1 -1
- package/lib/compactSnapshotWriter.js +18 -15
- package/lib/compactSnapshotWriter.js.map +1 -1
- package/lib/contracts.d.ts +1 -18
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/createFile.d.ts +1 -1
- package/lib/createFile.d.ts.map +1 -1
- package/lib/createFile.js +54 -17
- package/lib/createFile.js.map +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +0 -1
- package/lib/createNewUtils.js.map +1 -1
- package/lib/createOdspCreateContainerRequest.d.ts +4 -3
- package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/lib/createOdspCreateContainerRequest.js +6 -3
- package/lib/createOdspCreateContainerRequest.js.map +1 -1
- package/lib/epochTracker.d.ts +1 -0
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +26 -7
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts +1 -2
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +22 -27
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/getFileLink.d.ts +3 -6
- package/lib/getFileLink.d.ts.map +1 -1
- package/lib/getFileLink.js +24 -35
- package/lib/getFileLink.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js +1 -2
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts +3 -2
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js +9 -12
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +3 -6
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentService.d.ts +1 -0
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +14 -8
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +29 -6
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +4 -4
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +83 -65
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/lib/odspDocumentStorageServiceBase.js +4 -2
- package/lib/odspDocumentStorageServiceBase.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +4 -4
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspFluidFileLink.js +1 -1
- package/lib/odspFluidFileLink.js.map +1 -1
- package/lib/odspLocationRedirection.d.ts +14 -0
- package/lib/odspLocationRedirection.d.ts.map +1 -0
- package/lib/odspLocationRedirection.js +20 -0
- package/lib/odspLocationRedirection.js.map +1 -0
- package/lib/odspSnapshotParser.d.ts.map +1 -1
- package/lib/odspSnapshotParser.js +1 -2
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts +6 -3
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +14 -17
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/odspUrlHelper.js +2 -1
- package/lib/odspUrlHelper.js.map +1 -1
- package/lib/odspUtils.d.ts +11 -2
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +31 -5
- package/lib/odspUtils.js.map +1 -1
- package/lib/opsCaching.d.ts.map +1 -1
- package/lib/opsCaching.js +3 -2
- package/lib/opsCaching.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/prefetchLatestSnapshot.d.ts +6 -4
- package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
- package/lib/prefetchLatestSnapshot.js +6 -4
- package/lib/prefetchLatestSnapshot.js.map +1 -1
- package/lib/retryUtils.d.ts.map +1 -1
- package/lib/retryUtils.js +9 -5
- package/lib/retryUtils.js.map +1 -1
- package/lib/zipItDataRepresentationUtils.d.ts +30 -18
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/zipItDataRepresentationUtils.js +166 -75
- package/lib/zipItDataRepresentationUtils.js.map +1 -1
- package/package.json +33 -20
- package/src/ReadBufferUtils.ts +1 -0
- package/src/WriteBufferUtils.ts +67 -58
- package/src/compactSnapshotParser.ts +102 -40
- package/src/compactSnapshotWriter.ts +25 -17
- package/src/contracts.ts +2 -14
- package/src/createFile.ts +75 -15
- package/src/createNewUtils.ts +2 -4
- package/src/createOdspCreateContainerRequest.ts +7 -4
- package/src/epochTracker.ts +47 -7
- package/src/fetchSnapshot.ts +35 -31
- package/src/getFileLink.ts +26 -39
- package/src/index.ts +1 -3
- package/src/localOdspDriver/localOdspDocumentStorageManager.ts +2 -2
- package/src/odspDeltaStorageService.ts +8 -9
- package/src/odspDocumentDeltaConnection.ts +3 -5
- package/src/odspDocumentService.ts +16 -13
- package/src/odspDocumentServiceFactoryCore.ts +40 -4
- package/src/odspDocumentStorageManager.ts +64 -50
- package/src/odspDocumentStorageServiceBase.ts +4 -2
- package/src/odspDriverUrlResolverForShareLink.ts +2 -5
- package/src/odspFluidFileLink.ts +1 -1
- package/src/odspLocationRedirection.ts +23 -0
- package/src/odspSnapshotParser.ts +3 -4
- package/src/odspSummaryUploadManager.ts +10 -11
- package/src/odspUrlHelper.ts +1 -1
- package/src/odspUtils.ts +40 -7
- package/src/opsCaching.ts +3 -2
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +6 -4
- package/src/retryUtils.ts +8 -5
- package/src/zipItDataRepresentationUtils.ts +198 -75
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { PerformanceEvent, } from "@fluidframework/telemetry-utils";
|
|
6
6
|
import { getDocAttributesFromProtocolSummary, ensureFluidResolvedUrl, } from "@fluidframework/driver-utils";
|
|
7
|
+
import { SharingLinkScope, SharingLinkRole, ShareLinkTypes, } from "@fluidframework/odsp-driver-definitions";
|
|
7
8
|
import { v4 as uuid } from "uuid";
|
|
8
9
|
import { LocalPersistentCache, NonPersistentCache, } from "./odspCache";
|
|
9
10
|
import { createOdspCacheAndTracker, } from "./epochTracker";
|
|
@@ -46,7 +47,6 @@ export class OdspDocumentServiceFactoryCore {
|
|
|
46
47
|
this.hostPolicy.sessionOptions = Object.assign({ forceAccessTokenViaAuthorizationHeader: true }, this.hostPolicy.sessionOptions);
|
|
47
48
|
}
|
|
48
49
|
async createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer) {
|
|
49
|
-
var _a, _b;
|
|
50
50
|
ensureFluidResolvedUrl(createNewResolvedUrl);
|
|
51
51
|
let odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);
|
|
52
52
|
const resolvedUrlData = {
|
|
@@ -67,15 +67,13 @@ export class OdspDocumentServiceFactoryCore {
|
|
|
67
67
|
throw new Error("Seq number in detached ODSP container should be 0");
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
const createShareLinkParam = getSharingLinkParams(this.hostPolicy, searchParams);
|
|
70
71
|
const newFileInfo = {
|
|
71
72
|
driveId: odspResolvedUrl.driveId,
|
|
72
73
|
siteUrl: odspResolvedUrl.siteUrl,
|
|
73
74
|
filePath,
|
|
74
75
|
filename: odspResolvedUrl.fileName,
|
|
75
|
-
|
|
76
|
-
// so that share link creation with create file can be enabled
|
|
77
|
-
createLinkType: this.hostPolicy.enableShareLinkWithCreate ?
|
|
78
|
-
(_b = (_a = odspResolvedUrl.shareLinkInfo) === null || _a === void 0 ? void 0 : _a.createLink) === null || _b === void 0 ? void 0 : _b.type : undefined,
|
|
76
|
+
createLinkType: createShareLinkParam,
|
|
79
77
|
};
|
|
80
78
|
const odspLogger = createOdspLogger(logger);
|
|
81
79
|
const fileEntry = { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId };
|
|
@@ -83,9 +81,12 @@ export class OdspDocumentServiceFactoryCore {
|
|
|
83
81
|
return PerformanceEvent.timedExecAsync(odspLogger, {
|
|
84
82
|
eventName: "CreateNew",
|
|
85
83
|
isWithSummaryUpload: true,
|
|
84
|
+
createShareLinkParam: JSON.stringify(createShareLinkParam),
|
|
85
|
+
enableShareLinkWithCreate: this.hostPolicy.enableShareLinkWithCreate,
|
|
86
|
+
enableSingleRequestForShareLinkWithCreate: this.hostPolicy.enableSingleRequestForShareLinkWithCreate,
|
|
86
87
|
}, async (event) => {
|
|
87
88
|
var _a, _b;
|
|
88
|
-
odspResolvedUrl = await createNewFluidFile(toInstrumentedOdspTokenFetcher(odspLogger, resolvedUrlData, this.getStorageToken, true /* throwOnNullToken */), newFileInfo, odspLogger, createNewSummary, cacheAndTracker.epochTracker, fileEntry, (_a = this.hostPolicy.cacheCreateNewSummary) !== null && _a !== void 0 ? _a : true, !!((_b = this.hostPolicy.sessionOptions) === null || _b === void 0 ? void 0 : _b.forceAccessTokenViaAuthorizationHeader), odspResolvedUrl.isClpCompliantApp);
|
|
89
|
+
odspResolvedUrl = await createNewFluidFile(toInstrumentedOdspTokenFetcher(odspLogger, resolvedUrlData, this.getStorageToken, true /* throwOnNullToken */), newFileInfo, odspLogger, createNewSummary, cacheAndTracker.epochTracker, fileEntry, (_a = this.hostPolicy.cacheCreateNewSummary) !== null && _a !== void 0 ? _a : true, !!((_b = this.hostPolicy.sessionOptions) === null || _b === void 0 ? void 0 : _b.forceAccessTokenViaAuthorizationHeader), odspResolvedUrl.isClpCompliantApp, this.hostPolicy.enableSingleRequestForShareLinkWithCreate, this.hostPolicy.enableShareLinkWithCreate);
|
|
89
90
|
const docService = this.createDocumentServiceCore(odspResolvedUrl, odspLogger, cacheAndTracker, clientIsSummarizer);
|
|
90
91
|
event.end({
|
|
91
92
|
docId: odspResolvedUrl.hashedDocumentId,
|
|
@@ -111,4 +112,26 @@ export class OdspDocumentServiceFactoryCore {
|
|
|
111
112
|
return OdspDocumentService.create(resolvedUrl, storageTokenFetcher, webSocketTokenFetcher, odspLogger, this.getSocketIOClient, cacheAndTracker.cache, this.hostPolicy, cacheAndTracker.epochTracker, this.socketReferenceKeyPrefix, clientIsSummarizer);
|
|
112
113
|
}
|
|
113
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Extract the sharing link kind from the resolved URL's query paramerters
|
|
117
|
+
*/
|
|
118
|
+
function getSharingLinkParams(hostPolicy, searchParams) {
|
|
119
|
+
// extract request parameters for creation of sharing link (if provided) if the feature is enabled
|
|
120
|
+
let createShareLinkParam;
|
|
121
|
+
if (hostPolicy.enableSingleRequestForShareLinkWithCreate) {
|
|
122
|
+
const createLinkScope = searchParams.get("createLinkScope");
|
|
123
|
+
const createLinkRole = searchParams.get("createLinkRole");
|
|
124
|
+
if (createLinkScope && SharingLinkScope[createLinkScope]) {
|
|
125
|
+
createShareLinkParam = Object.assign({ scope: SharingLinkScope[createLinkScope] }, (createLinkRole && SharingLinkRole[createLinkRole] ?
|
|
126
|
+
{ role: SharingLinkRole[createLinkRole] } : {}));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else if (hostPolicy.enableShareLinkWithCreate) {
|
|
130
|
+
const createLinkType = searchParams.get("createLinkType");
|
|
131
|
+
if (createLinkType && ShareLinkTypes[createLinkType]) {
|
|
132
|
+
createShareLinkParam = ShareLinkTypes[createLinkType || ""];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return createShareLinkParam;
|
|
136
|
+
}
|
|
114
137
|
//# sourceMappingURL=odspDocumentServiceFactoryCore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAEH,gBAAgB,GACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,mCAAmC,EACnC,sBAAsB,GACzB,MAAM,8BAA8B,CAAC;AAWtC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EACH,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,yBAAyB,GAE5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAgB,kBAAkB,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,OAAO,8BAA8B;IAyFvC;;;;;;;;;OASG;IACH,YACqB,eAA4D,EAC5D,iBAA0E,EAC1E,iBAA6D,EACpE,iBAAkC,IAAI,oBAAoB,EAAE,EACrD,aAAgC,EAAE;;QAJlC,oBAAe,GAAf,eAAe,CAA6C;QAC5D,sBAAiB,GAAjB,iBAAiB,CAAyD;QAC1E,sBAAiB,GAAjB,iBAAiB,CAA4C;QACpE,mBAAc,GAAd,cAAc,CAA8C;QACrD,eAAU,GAAV,UAAU,CAAwB;Q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I,CAAC,sBAAsB,CAC9B,CAAC;QAEF,MAAM,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,KAAK,SAAS;YAC9D,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,KAAK,EAAE,OAA0B,EAAE,EAAE,CAAC,8BAA8B,CAClE,UAAU,EACV,eAAe,EACf,IAAI,CAAC,iBAAkB,EACvB,KAAK,CAAC,sBAAsB,CAC/B,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;QAEpC,OAAO,mBAAmB,CAAC,MAAM,CAC7B,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,IAAI,CAAC,iBAAiB,EACtB,eAAe,CAAC,KAAK,EACrB,IAAI,CAAC,UAAU,EACf,eAAe,CAAC,YAAY,EAC5B,IAAI,CAAC,wBAAwB,EAC7B,kBAAkB,CACrB,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport {\n IDocumentService,\n IDocumentServiceFactory,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport {\n TelemetryLogger,\n PerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n getDocAttributesFromProtocolSummary,\n ensureFluidResolvedUrl,\n} from \"@fluidframework/driver-utils\";\nimport {\n TokenFetchOptions,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n IPersistedCache,\n HostStoragePolicy,\n IFileEntry,\n IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport type { io as SocketIOClientStatic } from \"socket.io-client\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n LocalPersistentCache,\n NonPersistentCache,\n} from \"./odspCache\";\nimport {\n createOdspCacheAndTracker,\n ICacheAndTracker,\n} from \"./epochTracker\";\nimport { OdspDocumentService } from \"./odspDocumentService\";\nimport { INewFileInfo, getOdspResolvedUrl, createOdspLogger, toInstrumentedOdspTokenFetcher } from \"./odspUtils\";\nimport { createNewFluidFile } from \"./createFile\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n *\n * This constructor should be used by environments that support dynamic imports and that wish\n * to leverage code splitting as a means to keep bundles as small as possible.\n */\nexport class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {\n public readonly protocolName = \"fluid-odsp:\";\n\n private readonly nonPersistentCache = new NonPersistentCache();\n private readonly socketReferenceKeyPrefix?: string;\n\n public async createContainer(\n createNewSummary: ISummaryTree | undefined,\n createNewResolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(createNewResolvedUrl);\n\n let odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const [, queryString] = odspResolvedUrl.url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n const filePath = searchParams.get(\"path\");\n if (filePath === undefined || filePath === null) {\n throw new Error(\"File path should be provided!!\");\n }\n\n const protocolSummary = createNewSummary?.tree[\".protocol\"];\n if (protocolSummary) {\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary as ISummaryTree);\n if (documentAttributes?.sequenceNumber !== 0) {\n throw new Error(\"Seq number in detached ODSP container should be 0\");\n }\n }\n\n const newFileInfo: INewFileInfo = {\n driveId: odspResolvedUrl.driveId,\n siteUrl: odspResolvedUrl.siteUrl,\n filePath,\n filename: odspResolvedUrl.fileName,\n // set createLinkType to undefined if enableShareLinkWithCreate is set to false,\n // so that share link creation with create file can be enabled\n createLinkType: this.hostPolicy.enableShareLinkWithCreate ?\n odspResolvedUrl.shareLinkInfo?.createLink?.type : undefined,\n };\n\n const odspLogger = createOdspLogger(logger);\n\n const fileEntry: IFileEntry = { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId };\n const cacheAndTracker = createOdspCacheAndTracker(\n this.persistedCache,\n this.nonPersistentCache,\n fileEntry,\n odspLogger,\n clientIsSummarizer);\n\n return PerformanceEvent.timedExecAsync(\n odspLogger,\n {\n eventName: \"CreateNew\",\n isWithSummaryUpload: true,\n },\n async (event) => {\n odspResolvedUrl = await createNewFluidFile(\n toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getStorageToken,\n true /* throwOnNullToken */,\n ),\n newFileInfo,\n odspLogger,\n createNewSummary,\n cacheAndTracker.epochTracker,\n fileEntry,\n this.hostPolicy.cacheCreateNewSummary ?? true,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n odspResolvedUrl.isClpCompliantApp,\n );\n const docService = this.createDocumentServiceCore(odspResolvedUrl, odspLogger,\n cacheAndTracker, clientIsSummarizer);\n event.end({\n docId: odspResolvedUrl.hashedDocumentId,\n });\n return docService;\n });\n }\n\n /**\n * @param getStorageToken - function that can provide the storage token for a given site. This is\n * is also referred to as the \"Vroom\" token in SPO.\n * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n * response payload.\n * @param storageFetchWrapper - if not provided FetchWrapper will be used\n * @param deltasFetchWrapper - if not provided FetchWrapper will be used\n * @param persistedCache - PersistedCache provided by host for use in this session.\n */\n constructor(\n private readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n private readonly getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n private readonly getSocketIOClient: () => Promise<typeof SocketIOClientStatic>,\n protected persistedCache: IPersistedCache = new LocalPersistentCache(),\n private readonly hostPolicy: HostStoragePolicy = {},\n ) {\n if (this.hostPolicy.isolateSocketCache === true) {\n // create the key to separate the socket reuse cache\n this.socketReferenceKeyPrefix = uuid();\n }\n // Set enableRedeemFallback by default as true.\n this.hostPolicy.enableRedeemFallback = this.hostPolicy.enableRedeemFallback ?? true;\n this.hostPolicy.sessionOptions = {\n forceAccessTokenViaAuthorizationHeader: true,\n ...this.hostPolicy.sessionOptions,\n };\n }\n\n public async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n return this.createDocumentServiceCore(resolvedUrl, createOdspLogger(logger), undefined, clientIsSummarizer);\n }\n\n protected async createDocumentServiceCore(\n resolvedUrl: IResolvedUrl,\n odspLogger: TelemetryLogger,\n cacheAndTrackerArg?: ICacheAndTracker,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const cacheAndTracker = cacheAndTrackerArg ?? createOdspCacheAndTracker(\n this.persistedCache,\n this.nonPersistentCache,\n { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },\n odspLogger,\n clientIsSummarizer);\n\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getStorageToken,\n true /* throwOnNullToken */,\n );\n\n const webSocketTokenFetcher = this.getWebsocketToken === undefined\n ? undefined\n : async (options: TokenFetchOptions) => toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getWebsocketToken!,\n false /* throwOnNullToken */,\n )(options, \"GetWebsocketToken\");\n\n return OdspDocumentService.create(\n resolvedUrl,\n storageTokenFetcher,\n webSocketTokenFetcher,\n odspLogger,\n this.getSocketIOClient,\n cacheAndTracker.cache,\n this.hostPolicy,\n cacheAndTracker.epochTracker,\n this.socketReferenceKeyPrefix,\n clientIsSummarizer,\n );\n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cAAc,CAAC,EAAE;YAClD,oBAAoB,GAAG,cAAc,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;SAC/D;KACJ;IACD,OAAO,oBAAoB,CAAC;AAChC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport {\n IDocumentService,\n IDocumentServiceFactory,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport {\n TelemetryLogger,\n PerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n getDocAttributesFromProtocolSummary,\n ensureFluidResolvedUrl,\n} from \"@fluidframework/driver-utils\";\nimport {\n TokenFetchOptions,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n IPersistedCache,\n HostStoragePolicy,\n IFileEntry,\n IOdspUrlParts,\n SharingLinkScope,\n SharingLinkRole,\n ShareLinkTypes,\n ISharingLinkKind,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport type { io as SocketIOClientStatic } from \"socket.io-client\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n LocalPersistentCache,\n NonPersistentCache,\n} from \"./odspCache\";\nimport {\n createOdspCacheAndTracker,\n ICacheAndTracker,\n} from \"./epochTracker\";\nimport { OdspDocumentService } from \"./odspDocumentService\";\nimport { INewFileInfo, getOdspResolvedUrl, createOdspLogger, toInstrumentedOdspTokenFetcher } from \"./odspUtils\";\nimport { createNewFluidFile } from \"./createFile\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n *\n * This constructor should be used by environments that support dynamic imports and that wish\n * to leverage code splitting as a means to keep bundles as small as possible.\n */\nexport class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {\n public readonly protocolName = \"fluid-odsp:\";\n\n private readonly nonPersistentCache = new NonPersistentCache();\n private readonly socketReferenceKeyPrefix?: string;\n\n public async createContainer(\n createNewSummary: ISummaryTree | undefined,\n createNewResolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(createNewResolvedUrl);\n\n let odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const [, queryString] = odspResolvedUrl.url.split(\"?\");\n\n const searchParams = new URLSearchParams(queryString);\n const filePath = searchParams.get(\"path\");\n if (filePath === undefined || filePath === null) {\n throw new Error(\"File path should be provided!!\");\n }\n\n const protocolSummary = createNewSummary?.tree[\".protocol\"];\n if (protocolSummary) {\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary as ISummaryTree);\n if (documentAttributes?.sequenceNumber !== 0) {\n throw new Error(\"Seq number in detached ODSP container should be 0\");\n }\n }\n\n const createShareLinkParam = getSharingLinkParams(this.hostPolicy, searchParams);\n const newFileInfo: INewFileInfo = {\n driveId: odspResolvedUrl.driveId,\n siteUrl: odspResolvedUrl.siteUrl,\n filePath,\n filename: odspResolvedUrl.fileName,\n createLinkType: createShareLinkParam,\n };\n\n const odspLogger = createOdspLogger(logger);\n\n const fileEntry: IFileEntry = { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId };\n const cacheAndTracker = createOdspCacheAndTracker(\n this.persistedCache,\n this.nonPersistentCache,\n fileEntry,\n odspLogger,\n clientIsSummarizer);\n\n return PerformanceEvent.timedExecAsync(\n odspLogger,\n {\n eventName: \"CreateNew\",\n isWithSummaryUpload: true,\n createShareLinkParam: JSON.stringify(createShareLinkParam),\n enableShareLinkWithCreate: this.hostPolicy.enableShareLinkWithCreate,\n enableSingleRequestForShareLinkWithCreate:\n this.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n },\n async (event) => {\n odspResolvedUrl = await createNewFluidFile(\n toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getStorageToken,\n true /* throwOnNullToken */,\n ),\n newFileInfo,\n odspLogger,\n createNewSummary,\n cacheAndTracker.epochTracker,\n fileEntry,\n this.hostPolicy.cacheCreateNewSummary ?? true,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n odspResolvedUrl.isClpCompliantApp,\n this.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n this.hostPolicy.enableShareLinkWithCreate,\n );\n const docService = this.createDocumentServiceCore(odspResolvedUrl, odspLogger,\n cacheAndTracker, clientIsSummarizer);\n event.end({\n docId: odspResolvedUrl.hashedDocumentId,\n });\n return docService;\n });\n }\n\n /**\n * @param getStorageToken - function that can provide the storage token for a given site. This is\n * is also referred to as the \"Vroom\" token in SPO.\n * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n * response payload.\n * @param storageFetchWrapper - if not provided FetchWrapper will be used\n * @param deltasFetchWrapper - if not provided FetchWrapper will be used\n * @param persistedCache - PersistedCache provided by host for use in this session.\n */\n constructor(\n private readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n private readonly getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n private readonly getSocketIOClient: () => Promise<typeof SocketIOClientStatic>,\n protected persistedCache: IPersistedCache = new LocalPersistentCache(),\n private readonly hostPolicy: HostStoragePolicy = {},\n ) {\n if (this.hostPolicy.isolateSocketCache === true) {\n // create the key to separate the socket reuse cache\n this.socketReferenceKeyPrefix = uuid();\n }\n // Set enableRedeemFallback by default as true.\n this.hostPolicy.enableRedeemFallback = this.hostPolicy.enableRedeemFallback ?? true;\n this.hostPolicy.sessionOptions = {\n forceAccessTokenViaAuthorizationHeader: true,\n ...this.hostPolicy.sessionOptions,\n };\n }\n\n public async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n return this.createDocumentServiceCore(resolvedUrl, createOdspLogger(logger), undefined, clientIsSummarizer);\n }\n\n protected async createDocumentServiceCore(\n resolvedUrl: IResolvedUrl,\n odspLogger: TelemetryLogger,\n cacheAndTrackerArg?: ICacheAndTracker,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const cacheAndTracker = cacheAndTrackerArg ?? createOdspCacheAndTracker(\n this.persistedCache,\n this.nonPersistentCache,\n { resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },\n odspLogger,\n clientIsSummarizer);\n\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getStorageToken,\n true /* throwOnNullToken */,\n );\n\n const webSocketTokenFetcher = this.getWebsocketToken === undefined\n ? undefined\n : async (options: TokenFetchOptions) => toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n this.getWebsocketToken!,\n false /* throwOnNullToken */,\n )(options, \"GetWebsocketToken\");\n\n return OdspDocumentService.create(\n resolvedUrl,\n storageTokenFetcher,\n webSocketTokenFetcher,\n odspLogger,\n this.getSocketIOClient,\n cacheAndTracker.cache,\n this.hostPolicy,\n cacheAndTracker.epochTracker,\n this.socketReferenceKeyPrefix,\n clientIsSummarizer,\n );\n }\n}\n\n/**\n * Extract the sharing link kind from the resolved URL's query paramerters\n */\nfunction getSharingLinkParams(\n hostPolicy: HostStoragePolicy,\n searchParams: URLSearchParams,\n): ShareLinkTypes | ISharingLinkKind | undefined {\n // extract request parameters for creation of sharing link (if provided) if the feature is enabled\n let createShareLinkParam: ShareLinkTypes | ISharingLinkKind | undefined;\n if (hostPolicy.enableSingleRequestForShareLinkWithCreate) {\n const createLinkScope = searchParams.get(\"createLinkScope\");\n const createLinkRole = searchParams.get(\"createLinkRole\");\n if (createLinkScope && SharingLinkScope[createLinkScope]) {\n createShareLinkParam = {\n scope: SharingLinkScope[createLinkScope],\n ...(createLinkRole && SharingLinkRole[createLinkRole] ?\n { role: SharingLinkRole[createLinkRole] } : {}),\n };\n }\n } else if (hostPolicy.enableShareLinkWithCreate) {\n const createLinkType = searchParams.get(\"createLinkType\");\n if (createLinkType && ShareLinkTypes[createLinkType]) {\n createShareLinkParam = ShareLinkTypes[createLinkType || \"\"];\n }\n }\n return createShareLinkParam;\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
6
|
import * as api from "@fluidframework/protocol-definitions";
|
|
7
|
-
import { ISummaryContext } from "@fluidframework/driver-definitions";
|
|
7
|
+
import { ISummaryContext, FetchSource } from "@fluidframework/driver-definitions";
|
|
8
8
|
import { IOdspResolvedUrl, InstrumentedStorageTokenFetcher } from "@fluidframework/odsp-driver-definitions";
|
|
9
9
|
import { HostStoragePolicyInternal } from "./contracts";
|
|
10
10
|
import { SnapshotFormatSupportType } from "./fetchSnapshot";
|
|
@@ -17,11 +17,11 @@ export declare class OdspDocumentStorageService extends OdspDocumentStorageServi
|
|
|
17
17
|
private readonly odspResolvedUrl;
|
|
18
18
|
private readonly getStorageToken;
|
|
19
19
|
private readonly logger;
|
|
20
|
-
private readonly fetchFullSnapshot;
|
|
21
20
|
private readonly cache;
|
|
22
21
|
private readonly hostPolicy;
|
|
23
22
|
private readonly epochTracker;
|
|
24
23
|
private readonly flushCallback;
|
|
24
|
+
private readonly relayServiceTenantAndSessionId;
|
|
25
25
|
private readonly snapshotFormatFetchType?;
|
|
26
26
|
private readonly odspSummaryUploadManager;
|
|
27
27
|
private firstVersionCall;
|
|
@@ -37,11 +37,11 @@ export declare class OdspDocumentStorageService extends OdspDocumentStorageServi
|
|
|
37
37
|
private readonly maxSnapshotSizeLimit;
|
|
38
38
|
private readonly maxSnapshotFetchTimeout;
|
|
39
39
|
private readonly createBlobRateLimiter;
|
|
40
|
-
constructor(odspResolvedUrl: IOdspResolvedUrl, getStorageToken: InstrumentedStorageTokenFetcher, logger: ITelemetryLogger,
|
|
40
|
+
constructor(odspResolvedUrl: IOdspResolvedUrl, getStorageToken: InstrumentedStorageTokenFetcher, logger: ITelemetryLogger, cache: IOdspCache, hostPolicy: HostStoragePolicyInternal, epochTracker: EpochTracker, flushCallback: () => Promise<FlushResult>, relayServiceTenantAndSessionId: () => string, snapshotFormatFetchType?: SnapshotFormatSupportType | undefined);
|
|
41
41
|
createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
|
|
42
42
|
protected fetchBlobFromStorage(blobId: string, evicted: boolean): Promise<ArrayBuffer>;
|
|
43
43
|
getSnapshotTree(version?: api.IVersion, scenarioName?: string): Promise<api.ISnapshotTree | null>;
|
|
44
|
-
getVersions(blobid: string | null, count: number, scenarioName?: string): Promise<api.IVersion[]>;
|
|
44
|
+
getVersions(blobid: string | null, count: number, scenarioName?: string, fetchSource?: FetchSource): Promise<api.IVersion[]>;
|
|
45
45
|
private fetchSnapshot;
|
|
46
46
|
private fetchSnapshotCore;
|
|
47
47
|
uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAQtE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EACH,eAAe,
|
|
1
|
+
{"version":3,"file":"odspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAA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,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,SAAS,CAAC;CAkCnH"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { assert, delay, } from "@fluidframework/common-utils";
|
|
6
6
|
import { PerformanceEvent, } from "@fluidframework/telemetry-utils";
|
|
7
|
-
import { DriverErrorType, } from "@fluidframework/driver-definitions";
|
|
7
|
+
import { DriverErrorType, FetchSource, } from "@fluidframework/driver-definitions";
|
|
8
8
|
import { RateLimiter, NonRetryableError } from "@fluidframework/driver-utils";
|
|
9
9
|
import { OdspErrorType, } from "@fluidframework/odsp-driver-definitions";
|
|
10
10
|
import { downloadSnapshot, fetchSnapshot, fetchSnapshotWithRedeem } from "./fetchSnapshot";
|
|
@@ -24,17 +24,17 @@ async function promiseRaceWithWinner(promises) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
27
|
-
constructor(odspResolvedUrl, getStorageToken, logger,
|
|
27
|
+
constructor(odspResolvedUrl, getStorageToken, logger, cache, hostPolicy, epochTracker, flushCallback, relayServiceTenantAndSessionId, snapshotFormatFetchType) {
|
|
28
28
|
var _a;
|
|
29
29
|
super();
|
|
30
30
|
this.odspResolvedUrl = odspResolvedUrl;
|
|
31
31
|
this.getStorageToken = getStorageToken;
|
|
32
32
|
this.logger = logger;
|
|
33
|
-
this.fetchFullSnapshot = fetchFullSnapshot;
|
|
34
33
|
this.cache = cache;
|
|
35
34
|
this.hostPolicy = hostPolicy;
|
|
36
35
|
this.epochTracker = epochTracker;
|
|
37
36
|
this.flushCallback = flushCallback;
|
|
37
|
+
this.relayServiceTenantAndSessionId = relayServiceTenantAndSessionId;
|
|
38
38
|
this.snapshotFormatFetchType = snapshotFormatFetchType;
|
|
39
39
|
this.firstVersionCall = true;
|
|
40
40
|
// Driver specified limits for snapshot size and time.
|
|
@@ -51,7 +51,7 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
51
51
|
this.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;
|
|
52
52
|
this.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;
|
|
53
53
|
this.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;
|
|
54
|
-
this.odspSummaryUploadManager = new OdspSummaryUploadManager(this.snapshotUrl, getStorageToken, logger, epochTracker, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
|
|
54
|
+
this.odspSummaryUploadManager = new OdspSummaryUploadManager(this.snapshotUrl, getStorageToken, logger, epochTracker, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader), this.relayServiceTenantAndSessionId);
|
|
55
55
|
}
|
|
56
56
|
async createBlob(file) {
|
|
57
57
|
this.checkAttachmentPOSTUrl();
|
|
@@ -109,7 +109,7 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
109
109
|
}
|
|
110
110
|
return super.getSnapshotTree(version, scenarioName);
|
|
111
111
|
}
|
|
112
|
-
async getVersions(blobid, count, scenarioName) {
|
|
112
|
+
async getVersions(blobid, count, scenarioName, fetchSource) {
|
|
113
113
|
// Regular load workflow uses blobId === documentID to indicate "latest".
|
|
114
114
|
if (blobid !== this.documentId && blobid) {
|
|
115
115
|
// FluidFetch & FluidDebugger tools use empty sting to query for versions
|
|
@@ -128,85 +128,103 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
128
128
|
return [];
|
|
129
129
|
}
|
|
130
130
|
// 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
|
|
131
|
-
|
|
132
|
-
if (this.firstVersionCall && count === 1 && (blobid === null || blobid === this.documentId)) {
|
|
131
|
+
if (count === 1 && (blobid === null || blobid === this.documentId)) {
|
|
133
132
|
const hostSnapshotOptions = this.hostPolicy.snapshotOptions;
|
|
134
|
-
const odspSnapshotCacheValue = await PerformanceEvent.timedExecAsync(this.logger, { eventName: "ObtainSnapshot" }, async (event) => {
|
|
133
|
+
const odspSnapshotCacheValue = await PerformanceEvent.timedExecAsync(this.logger, { eventName: "ObtainSnapshot", fetchSource }, async (event) => {
|
|
135
134
|
const props = {};
|
|
136
135
|
let retrievedSnapshot;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
136
|
+
let method;
|
|
137
|
+
if (fetchSource === FetchSource.noCache) {
|
|
138
|
+
retrievedSnapshot = await this.fetchSnapshot(hostSnapshotOptions, scenarioName);
|
|
139
|
+
method = "networkOnly";
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// Here's the logic to grab the persistent cache snapshot implemented by the host
|
|
143
|
+
// Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions
|
|
144
|
+
const cachedSnapshotP = this.epochTracker.get(createCacheSnapshotKey(this.odspResolvedUrl))
|
|
145
|
+
.then(async (snapshotCachedEntry) => {
|
|
146
|
+
var _a;
|
|
147
|
+
if (snapshotCachedEntry !== undefined) {
|
|
148
|
+
// If the cached entry does not contain the entry time, then assign it a default of 30 days old.
|
|
149
|
+
const age = Date.now() - ((_a = snapshotCachedEntry.cacheEntryTime) !== null && _a !== void 0 ? _a : (Date.now() - 30 * 24 * 60 * 60 * 1000));
|
|
150
|
+
// In order to decrease the number of times we have to execute a snapshot refresh,
|
|
151
|
+
// if this is the summarizer and we have a cache entry but it is past the defaultSummarizerCacheExpiryTimeout,
|
|
152
|
+
// force the network retrieval instead as there might be a more recent snapshot available.
|
|
153
|
+
// See: https://github.com/microsoft/FluidFramework/issues/8995 for additional information.
|
|
154
|
+
if (this.hostPolicy.summarizerClient) {
|
|
155
|
+
if (age > defaultSummarizerCacheExpiryTimeout) {
|
|
156
|
+
props.cacheSummarizerExpired = true;
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
props.cacheSummarizerExpired = false;
|
|
161
|
+
}
|
|
153
162
|
}
|
|
154
|
-
|
|
155
|
-
|
|
163
|
+
// Record the cache age
|
|
164
|
+
props.cacheEntryAge = age;
|
|
165
|
+
}
|
|
166
|
+
return snapshotCachedEntry;
|
|
167
|
+
});
|
|
168
|
+
// Based on the concurrentSnapshotFetch policy:
|
|
169
|
+
// Either retrieve both the network and cache snapshots concurrently and pick the first to return,
|
|
170
|
+
// or grab the cache value and then the network value if the cache value returns undefined.
|
|
171
|
+
// For summarizer which could call this during refreshing of summary parent, always use the cache
|
|
172
|
+
// first. Also for other clients, if it is not critical path which is determined by firstVersionCall,
|
|
173
|
+
// then also check the cache first.
|
|
174
|
+
if (this.firstVersionCall && this.hostPolicy.concurrentSnapshotFetch && !this.hostPolicy.summarizerClient) {
|
|
175
|
+
const networkSnapshotP = this.fetchSnapshot(hostSnapshotOptions, scenarioName);
|
|
176
|
+
// Ensure that failures on both paths are ignored initially.
|
|
177
|
+
// I.e. if cache fails for some reason, we will proceed with network result.
|
|
178
|
+
// And vice versa - if (for example) client is offline and network request fails first, we
|
|
179
|
+
// do want to attempt to succeed with cached data!
|
|
180
|
+
const promiseRaceWinner = await promiseRaceWithWinner([
|
|
181
|
+
cachedSnapshotP.catch(() => undefined),
|
|
182
|
+
networkSnapshotP.catch(() => undefined),
|
|
183
|
+
]);
|
|
184
|
+
retrievedSnapshot = promiseRaceWinner.value;
|
|
185
|
+
method = promiseRaceWinner.index === 0 ? "cache" : "network";
|
|
186
|
+
if (retrievedSnapshot === undefined) {
|
|
187
|
+
// if network failed -> wait for cache ( then return network failure)
|
|
188
|
+
// If cache returned empty or failed -> wait for network (success of failure)
|
|
189
|
+
if (promiseRaceWinner.index === 1) {
|
|
190
|
+
retrievedSnapshot = await cachedSnapshotP;
|
|
191
|
+
method = "cache";
|
|
192
|
+
}
|
|
193
|
+
if (retrievedSnapshot === undefined) {
|
|
194
|
+
retrievedSnapshot = await networkSnapshotP;
|
|
195
|
+
method = "network";
|
|
156
196
|
}
|
|
157
197
|
}
|
|
158
|
-
// Record the cache age
|
|
159
|
-
props.cacheEntryAge = age;
|
|
160
198
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
let method;
|
|
167
|
-
if (this.hostPolicy.concurrentSnapshotFetch && !this.hostPolicy.summarizerClient) {
|
|
168
|
-
const networkSnapshotP = this.fetchSnapshot(hostSnapshotOptions, scenarioName);
|
|
169
|
-
// Ensure that failures on both paths are ignored initially.
|
|
170
|
-
// I.e. if cache fails for some reason, we will proceed with network result.
|
|
171
|
-
// And vice versa - if (for example) client is offline and network request fails first, we
|
|
172
|
-
// do want to attempt to succeed with cached data!
|
|
173
|
-
const promiseRaceWinner = await promiseRaceWithWinner([
|
|
174
|
-
cachedSnapshotP.catch(() => undefined),
|
|
175
|
-
networkSnapshotP.catch(() => undefined),
|
|
176
|
-
]);
|
|
177
|
-
retrievedSnapshot = promiseRaceWinner.value;
|
|
178
|
-
method = promiseRaceWinner.index === 0 ? "cache" : "network";
|
|
179
|
-
if (retrievedSnapshot === undefined) {
|
|
180
|
-
// if network failed -> wait for cache ( then return network failure)
|
|
181
|
-
// If cache returned empty or failed -> wait for network (success of failure)
|
|
182
|
-
if (promiseRaceWinner.index === 1) {
|
|
183
|
-
retrievedSnapshot = await cachedSnapshotP;
|
|
199
|
+
else {
|
|
200
|
+
// Note: There's a race condition here - another caller may come past the undefined check
|
|
201
|
+
// while the first caller is awaiting later async code in this block.
|
|
202
|
+
retrievedSnapshot = await cachedSnapshotP;
|
|
203
|
+
if (retrievedSnapshot !== undefined) {
|
|
184
204
|
method = "cache";
|
|
185
205
|
}
|
|
186
|
-
|
|
187
|
-
retrievedSnapshot = await networkSnapshotP;
|
|
206
|
+
else {
|
|
188
207
|
method = "network";
|
|
208
|
+
const options = Object.assign({}, hostSnapshotOptions);
|
|
209
|
+
// Don't fetch the blobs/deltas if it is not the first call. By default server will add
|
|
210
|
+
// blobs and deltas to the response.
|
|
211
|
+
if (!this.firstVersionCall) {
|
|
212
|
+
options.blobs = 0;
|
|
213
|
+
options.deltas = 0;
|
|
214
|
+
}
|
|
215
|
+
retrievedSnapshot = await this.fetchSnapshot(options, scenarioName);
|
|
189
216
|
}
|
|
190
217
|
}
|
|
191
218
|
}
|
|
192
|
-
else {
|
|
193
|
-
// Note: There's a race condition here - another caller may come past the undefined check
|
|
194
|
-
// while the first caller is awaiting later async code in this block.
|
|
195
|
-
retrievedSnapshot = await cachedSnapshotP;
|
|
196
|
-
method = retrievedSnapshot !== undefined ? "cache" : "network";
|
|
197
|
-
if (retrievedSnapshot === undefined) {
|
|
198
|
-
retrievedSnapshot = await this.fetchSnapshot(hostSnapshotOptions, scenarioName);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
219
|
if (method === "network") {
|
|
202
220
|
props.cacheEntryAge = undefined;
|
|
203
221
|
}
|
|
204
222
|
event.end(Object.assign(Object.assign({}, props), { method }));
|
|
205
223
|
return retrievedSnapshot;
|
|
206
224
|
});
|
|
207
|
-
//
|
|
225
|
+
// Don't override ops which were fetched during initial load, since we could still need them.
|
|
226
|
+
const id = this.initializeFromSnapshot(odspSnapshotCacheValue, this.firstVersionCall);
|
|
208
227
|
this.firstVersionCall = false;
|
|
209
|
-
const id = this.initializeFromSnapshot(odspSnapshotCacheValue);
|
|
210
228
|
return id ? [{ id, treeId: undefined }] : [];
|
|
211
229
|
}
|
|
212
230
|
return getWithRetryForTokenRefresh(async (options) => {
|
|
@@ -332,7 +350,7 @@ export class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
|
332
350
|
const snapshotDownloader = async (url, fetchOptions) => {
|
|
333
351
|
return this.epochTracker.fetchAndParseAsJSON(url, fetchOptions, "snapshotTree", undefined, scenarioName);
|
|
334
352
|
};
|
|
335
|
-
const snapshot = await fetchSnapshot(this.snapshotUrl, storageToken, id,
|
|
353
|
+
const snapshot = await fetchSnapshot(this.snapshotUrl, storageToken, id, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader), this.logger, snapshotDownloader);
|
|
336
354
|
let treeId = "";
|
|
337
355
|
if (snapshot.snapshotTree) {
|
|
338
356
|
assert(snapshot.snapshotTree.id !== undefined, 0x222 /* "Root tree should contain the id!!" */);
|