@fluidframework/odsp-driver 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkUrl.d.ts +1 -1
- package/dist/checkUrl.js +1 -1
- package/dist/checkUrl.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/contractsPublic.d.ts +1 -0
- package/dist/contractsPublic.d.ts.map +1 -1
- package/dist/contractsPublic.js.map +1 -1
- package/dist/getFileLink.js +0 -4
- package/dist/getFileLink.js.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentService.d.ts +26 -0
- package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentService.js +39 -0
- package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +24 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.js +45 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +27 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactory.d.ts +2 -1
- package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactory.js +7 -1
- package/dist/odspDocumentServiceFactory.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +3 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +5 -23
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +52 -245
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts +58 -0
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -0
- package/dist/odspDocumentStorageServiceBase.js +216 -0
- package/dist/odspDocumentStorageServiceBase.js.map +1 -0
- package/dist/odspDriverUrlResolver.js +1 -1
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts +8 -2
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +11 -3
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspFluidFileLink.d.ts.map +1 -1
- package/dist/odspFluidFileLink.js +27 -21
- package/dist/odspFluidFileLink.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/checkUrl.d.ts +1 -1
- package/lib/checkUrl.js +1 -1
- package/lib/checkUrl.js.map +1 -1
- package/lib/constants.d.ts +1 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +1 -1
- package/lib/constants.js.map +1 -1
- package/lib/contractsPublic.d.ts +1 -0
- package/lib/contractsPublic.d.ts.map +1 -1
- package/lib/contractsPublic.js.map +1 -1
- package/lib/getFileLink.js +0 -4
- package/lib/getFileLink.js.map +1 -1
- package/lib/localOdspDriver/localOdspDocumentService.d.ts +26 -0
- package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentService.js +35 -0
- package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts +24 -0
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.js +41 -0
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts +27 -0
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js +62 -0
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +1 -1
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactory.d.ts +2 -1
- package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactory.js +5 -0
- package/lib/odspDocumentServiceFactory.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts +3 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +5 -23
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +53 -246
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts +58 -0
- package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -0
- package/lib/odspDocumentStorageServiceBase.js +212 -0
- package/lib/odspDocumentStorageServiceBase.js.map +1 -0
- package/lib/odspDriverUrlResolver.js +1 -1
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts +8 -2
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +11 -3
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspFluidFileLink.d.ts.map +1 -1
- package/lib/odspFluidFileLink.js +27 -21
- package/lib/odspFluidFileLink.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 +17 -12
- package/src/checkUrl.ts +1 -1
- package/src/constants.ts +1 -1
- package/src/contractsPublic.ts +1 -0
- package/src/getFileLink.ts +0 -5
- package/src/localOdspDriver/localOdspDocumentService.ts +54 -0
- package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +67 -0
- package/src/localOdspDriver/localOdspDocumentStorageManager.ts +83 -0
- package/src/odspDeltaStorageService.ts +1 -1
- package/src/odspDocumentService.ts +5 -1
- package/src/odspDocumentServiceFactory.ts +7 -3
- package/src/odspDocumentServiceFactoryCore.ts +1 -1
- package/src/odspDocumentStorageManager.ts +81 -312
- package/src/odspDocumentStorageServiceBase.ts +268 -0
- package/src/odspDriverUrlResolver.ts +1 -1
- package/src/odspDriverUrlResolverForShareLink.ts +13 -1
- package/src/odspFluidFileLink.ts +26 -22
- package/src/packageVersion.ts +1 -1
package/dist/checkUrl.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { DriverPreCheckInfo } from "@fluidframework/driver-definitions";
|
|
6
6
|
/**
|
|
7
7
|
* A check that returns DriverPreCheckInfo if the URL format is likely supported by this driver.
|
|
8
|
-
* Note that returning information here is NOT a full
|
|
8
|
+
* Note that returning information here is NOT a full guarantee that resolve will ultimately be successful.
|
|
9
9
|
* Instead, this should be used as a lightweight check that can filter out easily detectable unsupported URLs
|
|
10
10
|
* before the entire Fluid loading process needs to be kicked off.
|
|
11
11
|
*/
|
package/dist/checkUrl.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.checkUrl = void 0;
|
|
|
8
8
|
const odspFluidFileLink_1 = require("./odspFluidFileLink");
|
|
9
9
|
/**
|
|
10
10
|
* A check that returns DriverPreCheckInfo if the URL format is likely supported by this driver.
|
|
11
|
-
* Note that returning information here is NOT a full
|
|
11
|
+
* Note that returning information here is NOT a full guarantee that resolve will ultimately be successful.
|
|
12
12
|
* Instead, this should be used as a lightweight check that can filter out easily detectable unsupported URLs
|
|
13
13
|
* before the entire Fluid loading process needs to be kicked off.
|
|
14
14
|
*/
|
package/dist/checkUrl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkUrl.js","sourceRoot":"","sources":["../src/checkUrl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAA4D;AAE5D;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,WAAgB;IACvC,MAAM,OAAO,GAAG,IAAA,yCAAqB,EAAC,WAAW,CAAC,CAAC;IAEnD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,UAA8B,CAAC;IACnC,IAAI;QACF,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE;YACpB,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC,MAAM,CAAC;SAC/C;KACF;IAAC,WAAM,GAAE;IAEV,OAAO;QACL,eAAe,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB;QAC9C,uEAAuE;QACvE,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;KAC3D,CAAC;AACJ,CAAC;AAnBD,4BAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DriverPreCheckInfo } from \"@fluidframework/driver-definitions\";\nimport { getLocatorFromOdspUrl } from \"./odspFluidFileLink\";\n\n/**\n * A check that returns DriverPreCheckInfo if the URL format is likely supported by this driver.\n * Note that returning information here is NOT a full
|
|
1
|
+
{"version":3,"file":"checkUrl.js","sourceRoot":"","sources":["../src/checkUrl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAA4D;AAE5D;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,WAAgB;IACvC,MAAM,OAAO,GAAG,IAAA,yCAAqB,EAAC,WAAW,CAAC,CAAC;IAEnD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,UAA8B,CAAC;IACnC,IAAI;QACF,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE;YACpB,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC,MAAM,CAAC;SAC/C;KACF;IAAC,WAAM,GAAE;IAEV,OAAO;QACL,eAAe,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB;QAC9C,uEAAuE;QACvE,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;KAC3D,CAAC;AACJ,CAAC;AAnBD,4BAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DriverPreCheckInfo } from \"@fluidframework/driver-definitions\";\nimport { getLocatorFromOdspUrl } from \"./odspFluidFileLink\";\n\n/**\n * A check that returns DriverPreCheckInfo if the URL format is likely supported by this driver.\n * Note that returning information here is NOT a full guarantee that resolve will ultimately be successful.\n * Instead, this should be used as a lightweight check that can filter out easily detectable unsupported URLs\n * before the entire Fluid loading process needs to be kicked off.\n */\nexport function checkUrl(documentUrl: URL): DriverPreCheckInfo | undefined {\n const locator = getLocatorFromOdspUrl(documentUrl);\n\n if (!locator) {\n return undefined;\n }\n\n let siteOrigin: string | undefined;\n try {\n if (locator?.siteUrl) {\n siteOrigin = new URL(locator?.siteUrl).origin;\n }\n } catch {}\n\n return {\n codeDetailsHint: locator?.containerPackageName,\n // Add the snapshot endpoint, which has the same domain as the site URL\n criticalBootDomains: siteOrigin ? [siteOrigin] : undefined,\n };\n}\n"]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export declare const OdcApiSiteOrigin = "https://
|
|
5
|
+
export declare const OdcApiSiteOrigin = "https://my.microsoftpersonalcontent.com";
|
|
6
6
|
export declare const OdcFileSiteOrigin = "https://1drv.ms";
|
|
7
7
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,gBAAgB,4CAA4C,CAAC;AAC1E,eAAO,MAAM,iBAAiB,oBAAoB,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.OdcFileSiteOrigin = exports.OdcApiSiteOrigin = void 0;
|
|
8
|
-
exports.OdcApiSiteOrigin = "https://
|
|
8
|
+
exports.OdcApiSiteOrigin = "https://my.microsoftpersonalcontent.com";
|
|
9
9
|
exports.OdcFileSiteOrigin = "https://1drv.ms";
|
|
10
10
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,gBAAgB,GAAG,yCAAyC,CAAC;AAC7D,QAAA,iBAAiB,GAAG,iBAAiB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const OdcApiSiteOrigin = \"https://my.microsoftpersonalcontent.com\";\nexport const OdcFileSiteOrigin = \"https://1drv.ms\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractsPublic.d.ts","sourceRoot":"","sources":["../src/contractsPublic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"contractsPublic.d.ts","sourceRoot":"","sources":["../src/contractsPublic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,oBAAY,iBAAiB;IAGzB,qBAAqB,0BAA0B;CAClD;AAED,MAAM,WAAW,kBAAkB;IAC/B,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACtD;AAED,oBAAY,qBAAqB;IAG7B,iBAAiB,wBAAwB;CAC5C;AAED,MAAM,WAAW,sBAAsB;IACnC,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACtD;AAED,OAAO,QAAQ,iCAAiC,CAAC;IAE7C,UAAiB,cAAe,SAAQ,OAAO,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC;KAAI;CAC3G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractsPublic.js","sourceRoot":"","sources":["../src/contractsPublic.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"contractsPublic.js","sourceRoot":"","sources":["../src/contractsPublic.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,yGAAyG;IACzG,sDAAsD;IACtD,oEAA+C,CAAA;AACnD,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAMD,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC7B,oGAAoG;IACpG,wGAAwG;IACxG,kEAAyC,CAAA;AAC7C,CAAC,EAJW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAIhC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions\";\n\nexport interface OdspFluidDataStoreLocator extends IOdspUrlParts {\n dataStorePath: string;\n appName?: string;\n containerPackageName?: string;\n fileVersion?: string;\n context?: string;\n}\n\nexport enum SharingLinkHeader {\n // Can be used in request made to resolver, to tell the resolver that the passed in URL is a sharing link\n // which can be redeemed at server to get permissions.\n isSharingLinkToRedeem = \"isSharingLinkToRedeem\",\n}\n\nexport interface ISharingLinkHeader {\n [SharingLinkHeader.isSharingLinkToRedeem]: boolean;\n}\n\nexport enum ClpCompliantAppHeader {\n // Can be used in request made to resolver, to tell the resolver that the host app is CLP compliant.\n // Odsp will not return Classified, labeled, or protected documents if the host app cannot support them.\n isClpCompliantApp = \"X-CLP-Compliant-App\",\n}\n\nexport interface IClpCompliantAppHeader {\n [ClpCompliantAppHeader.isClpCompliantApp]: boolean;\n}\n\ndeclare module \"@fluidframework/core-interfaces\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface IRequestHeader extends Partial<ISharingLinkHeader>, Partial<IClpCompliantAppHeader> { }\n}\n"]}
|
package/dist/getFileLink.js
CHANGED
|
@@ -68,10 +68,6 @@ async function getFileLink(getToken, odspUrlParts, identityType, logger) {
|
|
|
68
68
|
exports.getFileLink = getFileLink;
|
|
69
69
|
async function getFileLinkCore(getToken, odspUrlParts, identityType, logger) {
|
|
70
70
|
const fileItem = await getFileItemLite(getToken, odspUrlParts, logger, identityType === "Consumer");
|
|
71
|
-
// ODC canonical link does not require any additional processing
|
|
72
|
-
if (identityType === "Consumer") {
|
|
73
|
-
return fileItem.webUrl;
|
|
74
|
-
}
|
|
75
71
|
// ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder
|
|
76
72
|
return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "odspFileLink", requestName: "getSharingLink" }, async (event) => {
|
|
77
73
|
let attempts = 0;
|
package/dist/getFileLink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileLink.js","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA6D;AAC7D,+DAA0G;AAC1G,qEAAmE;AACnE,2EAAqE;AAOrE,yEAAsE;AACtE,2CAAuG;AACvG,qDAA+D;AAE/D,2GAA2G;AAC3G,MAAM,aAAa,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,WAAW,CAC7B,QAAqD,EACrD,YAA2B,EAC3B,YAA0B,EAC1B,MAAwB;IAExB,MAAM,QAAQ,GAAG,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,IAAI,YAAY,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n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, delay } from \"@fluidframework/common-utils\";\nimport { canRetryOnError, getRetryDelayFromError, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n IOdspUrlParts,\n OdspResourceTokenFetchOptions,\n IdentityType,\n TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { fetchHelper, getWithRetryForTokenRefresh, toInstrumentedOdspTokenFetcher } from \"./odspUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n// Store cached responses for the lifetime of web session as file link remains the same for given file item\nconst fileLinkCache = new Map<string, Promise<string>>();\n\n/**\n * Returns file link for a file with given drive and item ids.\n * Scope needed: files.readwrite.all.\n * This function keeps retrying if it gets a retriable error or wait for some delay if it gets a\n * throttling error. In future, we are thinking of app allowing to pass some cancel token, with which\n * we would be able to stop retrying.\n * @param getToken - used to fetch access tokens needed to execute operation\n * @param siteUrl - url of the site that contains the file\n * @param driveId - drive where file is stored\n * @param itemId - file id\n * @param identityType - type of client account\n * @param logger - used to log results of operation, including any error\n * @returns Promise which resolves to file link url when successful; otherwise, undefined.\n */\nexport async function getFileLink(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n identityType: IdentityType,\n logger: ITelemetryLogger,\n): Promise<string> {\n const cacheKey = `${odspUrlParts.siteUrl}_${odspUrlParts.driveId}_${odspUrlParts.itemId}`;\n const maybeFileLinkCacheEntry = fileLinkCache.get(cacheKey);\n if (maybeFileLinkCacheEntry !== undefined) {\n return maybeFileLinkCacheEntry;\n }\n\n const valueGenerator = async function() {\n let result: string | undefined;\n let success = false;\n let retryAfterMs = 1000;\n do {\n try {\n result = await getFileLinkCore(getToken, odspUrlParts, identityType, logger);\n success = true;\n } catch (err) {\n // If it is not retriable, then just throw\n if (!canRetryOnError(err)) {\n // Delete from the cache to permit retrying later.\n fileLinkCache.delete(cacheKey);\n throw err;\n }\n // If the error is throttling error, then wait for the specified time before retrying.\n // If the waitTime is not specified, then we start with retrying immediately to max of 8s.\n retryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);\n await delay(retryAfterMs);\n }\n } while (!success);\n\n // We are guaranteed to run the getFileLinkCore at least once with successful result (which must be a string)\n assert(result !== undefined, 0x292 /* \"Unexpected undefined result from getFileLinkCore\" */);\n return result;\n };\n const fileLink = valueGenerator();\n fileLinkCache.set(cacheKey, fileLink);\n return fileLink;\n}\n\nasync function getFileLinkCore(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n identityType: IdentityType,\n logger: ITelemetryLogger,\n): Promise<string> {\n const fileItem = await getFileItemLite(getToken, odspUrlParts, logger, identityType === \"Consumer\");\n\n // ODC canonical link does not require any additional processing\n if (identityType === \"Consumer\") {\n return fileItem.webUrl;\n }\n\n // ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"odspFileLink\", requestName: \"getSharingLink\" },\n async (event) => {\n let attempts = 0;\n let additionalProps;\n const fileLink = await getWithRetryForTokenRefresh(async (options) => {\n attempts++;\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n logger,\n odspUrlParts,\n getToken,\n true /* throwOnNullToken */,\n );\n const storageToken = await storageTokenFetcher(options, \"GetFileLinkCore\");\n assert(storageToken !== null,\n 0x2bb /* \"Instrumented token fetcher with throwOnNullToken = true should never return null\" */);\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${odspUrlParts.siteUrl}/_api/web/GetFileByServerRelativeUrl(@a1)/Linkingurl?@a1=${\n encodeURIComponent(`'${new URL(fileItem.webDavUrl).pathname}'`)\n }`,\n storageToken,\n false,\n );\n const requestInit = {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json;odata=verbose\",\n \"Accept\": \"application/json;odata=verbose\",\n ...headers,\n },\n };\n const response = await fetchHelper(url, requestInit);\n additionalProps = response.propsToLog;\n\n const sharingInfo = await response.content.json();\n const linkingUrl = sharingInfo?.d?.LinkingUrl;\n if (typeof linkingUrl !== \"string\") {\n // This will retry once in getWithRetryForTokenRefresh\n throw new NonRetryableError(\n \"Malformed GetSharingLink response\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n return linkingUrl;\n });\n event.end({ ...additionalProps, attempts });\n return fileLink;\n },\n );\n}\n\n/**\n * This represents a lite version of file item containing only the webUrl and webDavUrl properties\n */\ninterface FileItemLite {\n webUrl: string;\n webDavUrl: string;\n}\n\nconst isFileItemLite = (maybeFileItemLite: any): maybeFileItemLite is FileItemLite => {\n if (typeof maybeFileItemLite.webUrl !== \"string\" || typeof maybeFileItemLite.webDavUrl !== \"string\") {\n return false;\n }\n return true;\n};\n\nasync function getFileItemLite(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<FileItemLite> {\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"odspFileLink\", requestName: \"getFileItemLite\" },\n async (event) => {\n let attempts = 0;\n let additionalProps;\n const fileItem = await getWithRetryForTokenRefresh(async (options) => {\n attempts++;\n const { siteUrl, driveId, itemId } = odspUrlParts;\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n logger,\n odspUrlParts,\n getToken,\n true /* throwOnNullToken */,\n );\n const storageToken = await storageTokenFetcher(options, \"GetFileItemLite\");\n assert(storageToken !== null,\n 0x2bc /* \"Instrumented token fetcher with throwOnNullToken =true should never return null\" */);\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${siteUrl}/_api/v2.0/drives/${driveId}/items/${itemId}?select=webUrl,webDavUrl`,\n storageToken,\n forceAccessTokenViaAuthorizationHeader,\n );\n const requestInit = { method: \"GET\", headers };\n const response = await fetchHelper(url, requestInit);\n additionalProps = response.propsToLog;\n\n const responseJson = await response.content.json();\n if (!isFileItemLite(responseJson)) {\n // This will retry once in getWithRetryForTokenRefresh\n throw new NonRetryableError(\n \"Malformed getFileItemLite response\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n return responseJson;\n });\n event.end({ ...additionalProps, attempts });\n return fileItem;\n },\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getFileLink.js","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA6D;AAC7D,+DAA0G;AAC1G,qEAAmE;AACnE,2EAAqE;AAOrE,yEAAsE;AACtE,2CAAuG;AACvG,qDAA+D;AAE/D,2GAA2G;AAC3G,MAAM,aAAa,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,WAAW,CAC7B,QAAqD,EACrD,YAA2B,EAC3B,YAA0B,EAC1B,MAAwB;IAExB,MAAM,QAAQ,GAAG,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;IAC1F,MAAM,uBAAuB,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5D,IAAI,uBAAuB,KAAK,SAAS,EAAE;QACvC,OAAO,uBAAuB,CAAC;KAClC;IAED,MAAM,cAAc,GAAG,KAAK;;QACxB,IAAI,MAA0B,CAAC;QAC/B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,IAAI,YAAY,GAAG,IAAI,CAAC;QACxB,GAAG;YACC,IAAI;gBACA,MAAM,GAAG,MAAM,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;gBAC7E,OAAO,GAAG,IAAI,CAAC;aAClB;YAAC,OAAO,GAAG,EAAE;gB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AAK,EAAE,OAAO,EAAE,CAAC;YAC/C,MAAM,QAAQ,GAAG,MAAM,IAAA,uBAAW,EAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YACrD,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC;YAEtC,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACnD,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE;gBAC/B,sDAAsD;gBACtD,MAAM,IAAI,gCAAiB,CACvB,oCAAoC,EACpC,oCAAe,CAAC,uBAAuB,EACvC,EAAE,aAAa,EAAb,2BAAa,EAAE,CAAC,CAAC;aAC1B;YACD,OAAO,YAAY,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,GAAG,iCAAM,eAAe,KAAE,QAAQ,IAAG,CAAC;QAC5C,OAAO,QAAQ,CAAC;IACpB,CAAC,CACJ,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, delay } from \"@fluidframework/common-utils\";\nimport { canRetryOnError, getRetryDelayFromError, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n IOdspUrlParts,\n OdspResourceTokenFetchOptions,\n IdentityType,\n TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { fetchHelper, getWithRetryForTokenRefresh, toInstrumentedOdspTokenFetcher } from \"./odspUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n// Store cached responses for the lifetime of web session as file link remains the same for given file item\nconst fileLinkCache = new Map<string, Promise<string>>();\n\n/**\n * Returns file link for a file with given drive and item ids.\n * Scope needed: files.readwrite.all.\n * This function keeps retrying if it gets a retriable error or wait for some delay if it gets a\n * throttling error. In future, we are thinking of app allowing to pass some cancel token, with which\n * we would be able to stop retrying.\n * @param getToken - used to fetch access tokens needed to execute operation\n * @param siteUrl - url of the site that contains the file\n * @param driveId - drive where file is stored\n * @param itemId - file id\n * @param identityType - type of client account\n * @param logger - used to log results of operation, including any error\n * @returns Promise which resolves to file link url when successful; otherwise, undefined.\n */\nexport async function getFileLink(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n identityType: IdentityType,\n logger: ITelemetryLogger,\n): Promise<string> {\n const cacheKey = `${odspUrlParts.siteUrl}_${odspUrlParts.driveId}_${odspUrlParts.itemId}`;\n const maybeFileLinkCacheEntry = fileLinkCache.get(cacheKey);\n if (maybeFileLinkCacheEntry !== undefined) {\n return maybeFileLinkCacheEntry;\n }\n\n const valueGenerator = async function() {\n let result: string | undefined;\n let success = false;\n let retryAfterMs = 1000;\n do {\n try {\n result = await getFileLinkCore(getToken, odspUrlParts, identityType, logger);\n success = true;\n } catch (err) {\n // If it is not retriable, then just throw\n if (!canRetryOnError(err)) {\n // Delete from the cache to permit retrying later.\n fileLinkCache.delete(cacheKey);\n throw err;\n }\n // If the error is throttling error, then wait for the specified time before retrying.\n // If the waitTime is not specified, then we start with retrying immediately to max of 8s.\n retryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);\n await delay(retryAfterMs);\n }\n } while (!success);\n\n // We are guaranteed to run the getFileLinkCore at least once with successful result (which must be a string)\n assert(result !== undefined, 0x292 /* \"Unexpected undefined result from getFileLinkCore\" */);\n return result;\n };\n const fileLink = valueGenerator();\n fileLinkCache.set(cacheKey, fileLink);\n return fileLink;\n}\n\nasync function getFileLinkCore(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n identityType: IdentityType,\n logger: ITelemetryLogger,\n): Promise<string> {\n const fileItem = await getFileItemLite(getToken, odspUrlParts, logger, identityType === \"Consumer\");\n\n // ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"odspFileLink\", requestName: \"getSharingLink\" },\n async (event) => {\n let attempts = 0;\n let additionalProps;\n const fileLink = await getWithRetryForTokenRefresh(async (options) => {\n attempts++;\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n logger,\n odspUrlParts,\n getToken,\n true /* throwOnNullToken */,\n );\n const storageToken = await storageTokenFetcher(options, \"GetFileLinkCore\");\n assert(storageToken !== null,\n 0x2bb /* \"Instrumented token fetcher with throwOnNullToken = true should never return null\" */);\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${odspUrlParts.siteUrl}/_api/web/GetFileByServerRelativeUrl(@a1)/Linkingurl?@a1=${\n encodeURIComponent(`'${new URL(fileItem.webDavUrl).pathname}'`)\n }`,\n storageToken,\n false,\n );\n const requestInit = {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json;odata=verbose\",\n \"Accept\": \"application/json;odata=verbose\",\n ...headers,\n },\n };\n const response = await fetchHelper(url, requestInit);\n additionalProps = response.propsToLog;\n\n const sharingInfo = await response.content.json();\n const linkingUrl = sharingInfo?.d?.LinkingUrl;\n if (typeof linkingUrl !== \"string\") {\n // This will retry once in getWithRetryForTokenRefresh\n throw new NonRetryableError(\n \"Malformed GetSharingLink response\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n return linkingUrl;\n });\n event.end({ ...additionalProps, attempts });\n return fileLink;\n },\n );\n}\n\n/**\n * This represents a lite version of file item containing only the webUrl and webDavUrl properties\n */\ninterface FileItemLite {\n webUrl: string;\n webDavUrl: string;\n}\n\nconst isFileItemLite = (maybeFileItemLite: any): maybeFileItemLite is FileItemLite => {\n if (typeof maybeFileItemLite.webUrl !== \"string\" || typeof maybeFileItemLite.webDavUrl !== \"string\") {\n return false;\n }\n return true;\n};\n\nasync function getFileItemLite(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<FileItemLite> {\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"odspFileLink\", requestName: \"getFileItemLite\" },\n async (event) => {\n let attempts = 0;\n let additionalProps;\n const fileItem = await getWithRetryForTokenRefresh(async (options) => {\n attempts++;\n const { siteUrl, driveId, itemId } = odspUrlParts;\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n logger,\n odspUrlParts,\n getToken,\n true /* throwOnNullToken */,\n );\n const storageToken = await storageTokenFetcher(options, \"GetFileItemLite\");\n assert(storageToken !== null,\n 0x2bc /* \"Instrumented token fetcher with throwOnNullToken =true should never return null\" */);\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${siteUrl}/_api/v2.0/drives/${driveId}/items/${itemId}?select=webUrl,webDavUrl`,\n storageToken,\n forceAccessTokenViaAuthorizationHeader,\n );\n const requestInit = { method: \"GET\", headers };\n const response = await fetchHelper(url, requestInit);\n additionalProps = response.propsToLog;\n\n const responseJson = await response.content.json();\n if (!isFileItemLite(responseJson)) {\n // This will retry once in getWithRetryForTokenRefresh\n throw new NonRetryableError(\n \"Malformed getFileItemLite response\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n return responseJson;\n });\n event.end({ ...additionalProps, attempts });\n return fileItem;\n },\n );\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
|
+
import { IDocumentDeltaStorageService, IDocumentService, IDocumentStorageService, IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
7
|
+
import { IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions";
|
|
8
|
+
import { IClient } from "@fluidframework/protocol-definitions";
|
|
9
|
+
/**
|
|
10
|
+
* IDocumentService implementation that provides explicit snapshot to the document storage service.
|
|
11
|
+
*/
|
|
12
|
+
export declare class LocalOdspDocumentService implements IDocumentService {
|
|
13
|
+
private readonly odspResolvedUrl;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private readonly localSnapshot;
|
|
16
|
+
policies: {
|
|
17
|
+
storageOnly: boolean;
|
|
18
|
+
};
|
|
19
|
+
constructor(odspResolvedUrl: IOdspResolvedUrl, logger: ITelemetryLogger, localSnapshot: Uint8Array | string);
|
|
20
|
+
get resolvedUrl(): IResolvedUrl;
|
|
21
|
+
connectToStorage(): Promise<IDocumentStorageService>;
|
|
22
|
+
connectToDeltaStorage(): Promise<IDocumentDeltaStorageService>;
|
|
23
|
+
connectToDeltaStream(_client: IClient): never;
|
|
24
|
+
dispose(_error?: any): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=localOdspDocumentService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localOdspDocumentService.d.ts","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACH,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAG/D;;GAEG;AACH,qBAAa,wBAAyB,YAAW,gBAAgB;IAIzD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAL3B,QAAQ;;MAAyB;gBAGnB,eAAe,EAAE,gBAAgB,EACjC,MAAM,EAAE,gBAAgB,EACxB,aAAa,EAAE,UAAU,GAAG,MAAM;IAGvD,IAAW,WAAW,IAAI,YAAY,CAErC;IAEY,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAOpD,qBAAqB,IAAI,OAAO,CAAC,4BAA4B,CAAC;IAIpE,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK;IAM7C,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,IAAI;CAGrC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LocalOdspDocumentService = void 0;
|
|
8
|
+
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
9
|
+
const localOdspDocumentStorageManager_1 = require("./localOdspDocumentStorageManager");
|
|
10
|
+
/**
|
|
11
|
+
* IDocumentService implementation that provides explicit snapshot to the document storage service.
|
|
12
|
+
*/
|
|
13
|
+
class LocalOdspDocumentService {
|
|
14
|
+
constructor(odspResolvedUrl, logger, localSnapshot) {
|
|
15
|
+
this.odspResolvedUrl = odspResolvedUrl;
|
|
16
|
+
this.logger = logger;
|
|
17
|
+
this.localSnapshot = localSnapshot;
|
|
18
|
+
this.policies = { storageOnly: true };
|
|
19
|
+
}
|
|
20
|
+
get resolvedUrl() {
|
|
21
|
+
return this.odspResolvedUrl;
|
|
22
|
+
}
|
|
23
|
+
async connectToStorage() {
|
|
24
|
+
return new localOdspDocumentStorageManager_1.LocalOdspDocumentStorageService(this.logger, this.localSnapshot);
|
|
25
|
+
}
|
|
26
|
+
async connectToDeltaStorage() {
|
|
27
|
+
return new driver_utils_1.EmptyDocumentDeltaStorageService();
|
|
28
|
+
}
|
|
29
|
+
connectToDeltaStream(_client) {
|
|
30
|
+
const toThrow = new driver_utils_1.UsageError("\"connectToDeltaStream\" is not supported by LocalOdspDocumentService");
|
|
31
|
+
this.logger.sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
|
|
32
|
+
throw toThrow;
|
|
33
|
+
}
|
|
34
|
+
dispose(_error) {
|
|
35
|
+
// Do nothing
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.LocalOdspDocumentService = LocalOdspDocumentService;
|
|
39
|
+
//# sourceMappingURL=localOdspDocumentService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localOdspDocumentService.js","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,+DAA4F;AAG5F,uFAAoF;AAEpF;;GAEG;AACH,MAAa,wBAAwB;IAGjC,YACqB,eAAiC,EACjC,MAAwB,EACxB,aAAkC;QAFlC,oBAAe,GAAf,eAAe,CAAkB;QACjC,WAAM,GAAN,MAAM,CAAkB;QACxB,kBAAa,GAAb,aAAa,CAAqB;QALhD,aAAQ,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAMpC,CAAC;IAEL,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAEM,KAAK,CAAC,gBAAgB;QACzB,OAAO,IAAI,iEAA+B,CACtC,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,aAAa,CACrB,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAC9B,OAAO,IAAI,+CAAgC,EAAE,CAAC;IAClD,CAAC;IAEM,oBAAoB,CAAC,OAAgB;QACxC,MAAM,OAAO,GAAG,IAAI,yBAAU,CAAC,uEAAuE,CAAC,CAAC;QACxG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,OAAO,CAAC;IAClB,CAAC;IAEM,OAAO,CAAC,MAAY;QACvB,aAAa;IACjB,CAAC;CACJ;AAjCD,4DAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IDocumentDeltaStorageService,\n IDocumentService,\n IDocumentStorageService,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { UsageError, EmptyDocumentDeltaStorageService } from \"@fluidframework/driver-utils\";\nimport { IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { LocalOdspDocumentStorageService } from \"./localOdspDocumentStorageManager\";\n\n/**\n * IDocumentService implementation that provides explicit snapshot to the document storage service.\n */\nexport class LocalOdspDocumentService implements IDocumentService {\n public policies = { storageOnly: true };\n\n constructor(\n private readonly odspResolvedUrl: IOdspResolvedUrl,\n private readonly logger: ITelemetryLogger,\n private readonly localSnapshot: Uint8Array | string,\n ) { }\n\n public get resolvedUrl(): IResolvedUrl {\n return this.odspResolvedUrl;\n }\n\n public async connectToStorage(): Promise<IDocumentStorageService> {\n return new LocalOdspDocumentStorageService(\n this.logger,\n this.localSnapshot,\n );\n }\n\n public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n return new EmptyDocumentDeltaStorageService();\n }\n\n public connectToDeltaStream(_client: IClient): never {\n const toThrow = new UsageError(\"\\\"connectToDeltaStream\\\" is not supported by LocalOdspDocumentService\");\n this.logger.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n throw toThrow;\n }\n\n public dispose(_error?: any): void {\n // Do nothing\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDocumentService, IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { TelemetryLogger } from "@fluidframework/telemetry-utils";
|
|
7
|
+
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
8
|
+
import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
9
|
+
import { ICacheAndTracker } from "../epochTracker";
|
|
10
|
+
import { OdspDocumentServiceFactoryCore } from "../odspDocumentServiceFactoryCore";
|
|
11
|
+
/**
|
|
12
|
+
* Factory for creating sharepoint document service with a provided snapshot.
|
|
13
|
+
* Use if you don't want to connect to any kind of external/internal storages and want to provide
|
|
14
|
+
* content directly.
|
|
15
|
+
*/
|
|
16
|
+
export declare class LocalOdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
|
|
17
|
+
private readonly localSnapshot;
|
|
18
|
+
private logger;
|
|
19
|
+
constructor(localSnapshot: Uint8Array | string);
|
|
20
|
+
private throwUnsupportedUsageError;
|
|
21
|
+
createContainer(_createNewSummary: ISummaryTree | undefined, _createNewResolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, _clientIsSummarizer?: boolean): never;
|
|
22
|
+
protected createDocumentServiceCore(resolvedUrl: IResolvedUrl, odspLogger: TelemetryLogger, _cacheAndTrackerArg?: ICacheAndTracker, _clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=localOdspDocumentServiceFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localOdspDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAGnF;;;;GAIG;AACH,qBAAa,+BAAgC,SAAQ,8BAA8B;IAI3E,OAAO,CAAC,QAAQ,CAAC,aAAa;IAHlC,OAAO,CAAC,MAAM,CAA8B;gBAGvB,aAAa,EAAE,UAAU,GAAG,MAAM;IASvD,OAAO,CAAC,0BAA0B;IAO3B,eAAe,CAClB,iBAAiB,EAAE,YAAY,GAAG,SAAS,EAC3C,qBAAqB,EAAE,YAAY,EACnC,MAAM,CAAC,EAAE,oBAAoB,EAC7B,mBAAmB,CAAC,EAAE,OAAO,GAC9B,KAAK;cAMQ,yBAAyB,CACrC,WAAW,EAAE,YAAY,EACzB,UAAU,EAAE,eAAe,EAC3B,mBAAmB,CAAC,EAAE,gBAAgB,EACtC,mBAAmB,CAAC,EAAE,OAAO,GAC9B,OAAO,CAAC,gBAAgB,CAAC;CAU/B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LocalOdspDocumentServiceFactory = void 0;
|
|
8
|
+
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
9
|
+
const odspUtils_1 = require("../odspUtils");
|
|
10
|
+
const odspDocumentServiceFactoryCore_1 = require("../odspDocumentServiceFactoryCore");
|
|
11
|
+
const localOdspDocumentService_1 = require("./localOdspDocumentService");
|
|
12
|
+
/**
|
|
13
|
+
* Factory for creating sharepoint document service with a provided snapshot.
|
|
14
|
+
* Use if you don't want to connect to any kind of external/internal storages and want to provide
|
|
15
|
+
* content directly.
|
|
16
|
+
*/
|
|
17
|
+
class LocalOdspDocumentServiceFactory extends odspDocumentServiceFactoryCore_1.OdspDocumentServiceFactoryCore {
|
|
18
|
+
constructor(localSnapshot) {
|
|
19
|
+
super((_options) => this.throwUnsupportedUsageError("Getting storage token"), (_options) => this.throwUnsupportedUsageError("Getting websocket token"), () => this.throwUnsupportedUsageError("Getting SocketIO Client"));
|
|
20
|
+
this.localSnapshot = localSnapshot;
|
|
21
|
+
}
|
|
22
|
+
throwUnsupportedUsageError(unsupportedFuncName) {
|
|
23
|
+
var _a;
|
|
24
|
+
const toThrow = new driver_utils_1.UsageError(`${unsupportedFuncName} is not supported by LocalOdspDocumentServiceFactory`);
|
|
25
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
|
|
26
|
+
throw toThrow;
|
|
27
|
+
}
|
|
28
|
+
createContainer(_createNewSummary, _createNewResolvedUrl, logger, _clientIsSummarizer) {
|
|
29
|
+
const toThrow = new driver_utils_1.UsageError("\"createContainer\" is not supported by LocalOdspDocumentServiceFactory");
|
|
30
|
+
(0, odspUtils_1.createOdspLogger)(logger).sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
|
|
31
|
+
throw toThrow;
|
|
32
|
+
}
|
|
33
|
+
async createDocumentServiceCore(resolvedUrl, odspLogger, _cacheAndTrackerArg, _clientIsSummarizer) {
|
|
34
|
+
if (_cacheAndTrackerArg !== undefined) {
|
|
35
|
+
throw new driver_utils_1.UsageError("Invalid usage. \"_cacheAndTrackerArg\" should not be provided");
|
|
36
|
+
}
|
|
37
|
+
if (_clientIsSummarizer) {
|
|
38
|
+
throw new driver_utils_1.UsageError("Invalid usage. \"_clientIsSummarizer\" should not be provided");
|
|
39
|
+
}
|
|
40
|
+
this.logger = odspLogger;
|
|
41
|
+
return new localOdspDocumentService_1.LocalOdspDocumentService((0, odspUtils_1.getOdspResolvedUrl)(resolvedUrl), odspLogger, this.localSnapshot);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.LocalOdspDocumentServiceFactory = LocalOdspDocumentServiceFactory;
|
|
45
|
+
//# sourceMappingURL=localOdspDocumentServiceFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localOdspDocumentServiceFactory.js","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA0D;AAI1D,4CAAoE;AAEpE,sFAAmF;AACnF,yEAAsE;AAEtE;;;;GAIG;AACH,MAAa,+BAAgC,SAAQ,+DAA8B;IAG/E,YACqB,aAAkC;QAEnD,KAAK,CACD,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,uBAAuB,CAAC,EACtE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EACxE,GAAG,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,CACnE,CAAC;QANe,kBAAa,GAAb,aAAa,CAAqB;IAOvD,CAAC;IAEO,0BAA0B,CAAC,mBAA2B;;QAC1D,MAAM,OAAO,GAAG,IAAI,yBAAU,CAC1B,GAAG,mBAAmB,sDAAsD,CAAC,CAAC;QAClF,MAAA,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACxE,MAAM,OAAO,CAAC;IAClB,CAAC;IAEM,eAAe,CAClB,iBAA2C,EAC3C,qBAAmC,EACnC,MAA6B,EAC7B,mBAA6B;QAE7B,MAAM,OAAO,GAAG,IAAI,yBAAU,CAAC,yEAAyE,CAAC,CAAC;QAC1G,IAAA,4BAAgB,EAAC,MAAM,CAAC,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACpF,MAAM,OAAO,CAAC;IAClB,CAAC;IAES,KAAK,CAAC,yBAAyB,CACrC,WAAyB,EACzB,UAA2B,EAC3B,mBAAsC,EACtC,mBAA6B;QAE7B,IAAI,mBAAmB,KAAK,SAAS,EAAE;YACnC,MAAM,IAAI,yBAAU,CAAC,+DAA+D,CAAC,CAAC;SACzF;QACD,IAAI,mBAAmB,EAAE;YACrB,MAAM,IAAI,yBAAU,CAAC,+DAA+D,CAAC,CAAC;SACzF;QACD,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;QACzB,OAAO,IAAI,mDAAwB,CAAC,IAAA,8BAAkB,EAAC,WAAW,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzG,CAAC;CACJ;AA9CD,0EA8CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentService, IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport { TelemetryLogger } from \"@fluidframework/telemetry-utils\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { createOdspLogger, getOdspResolvedUrl } from \"../odspUtils\";\nimport { ICacheAndTracker } from \"../epochTracker\";\nimport { OdspDocumentServiceFactoryCore } from \"../odspDocumentServiceFactoryCore\";\nimport { LocalOdspDocumentService } from \"./localOdspDocumentService\";\n\n/**\n * Factory for creating sharepoint document service with a provided snapshot.\n * Use if you don't want to connect to any kind of external/internal storages and want to provide\n * content directly.\n */\nexport class LocalOdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {\n private logger: TelemetryLogger | undefined;\n\n constructor(\n private readonly localSnapshot: Uint8Array | string,\n ) {\n super(\n (_options) => this.throwUnsupportedUsageError(\"Getting storage token\"),\n (_options) => this.throwUnsupportedUsageError(\"Getting websocket token\"),\n () => this.throwUnsupportedUsageError(\"Getting SocketIO Client\"),\n );\n }\n\n private throwUnsupportedUsageError(unsupportedFuncName: string): never {\n const toThrow = new UsageError(\n `${unsupportedFuncName} is not supported by LocalOdspDocumentServiceFactory`);\n this.logger?.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n throw toThrow;\n }\n\n public createContainer(\n _createNewSummary: ISummaryTree | undefined,\n _createNewResolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n _clientIsSummarizer?: boolean,\n ): never {\n const toThrow = new UsageError(\"\\\"createContainer\\\" is not supported by LocalOdspDocumentServiceFactory\");\n createOdspLogger(logger).sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n throw toThrow;\n }\n\n protected async createDocumentServiceCore(\n resolvedUrl: IResolvedUrl,\n odspLogger: TelemetryLogger,\n _cacheAndTrackerArg?: ICacheAndTracker,\n _clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n if (_cacheAndTrackerArg !== undefined) {\n throw new UsageError(\"Invalid usage. \\\"_cacheAndTrackerArg\\\" should not be provided\");\n }\n if (_clientIsSummarizer) {\n throw new UsageError(\"Invalid usage. \\\"_clientIsSummarizer\\\" should not be provided\");\n }\n this.logger = odspLogger;\n return new LocalOdspDocumentService(getOdspResolvedUrl(resolvedUrl), odspLogger, this.localSnapshot);\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
|
+
import { ISummaryContext } from "@fluidframework/driver-definitions";
|
|
7
|
+
import * as api from "@fluidframework/protocol-definitions";
|
|
8
|
+
import { OdspDocumentStorageServiceBase } from "../odspDocumentStorageServiceBase";
|
|
9
|
+
/**
|
|
10
|
+
* ODSP document storage service that works on a provided snapshot for all its processing.
|
|
11
|
+
* Attempting to use unsupported actions/methods will result in errors being thrown.
|
|
12
|
+
*/
|
|
13
|
+
export declare class LocalOdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private readonly localSnapshot;
|
|
16
|
+
private snapshotTreeId;
|
|
17
|
+
constructor(logger: ITelemetryLogger, localSnapshot: Uint8Array | string);
|
|
18
|
+
private calledGetVersions;
|
|
19
|
+
getVersions(blobid: string | null, count: number, _scenarioName?: string): Promise<api.IVersion[]>;
|
|
20
|
+
private getSnapshotVersion;
|
|
21
|
+
protected fetchTreeFromSnapshot(_id: string, _scenarioName?: string): never;
|
|
22
|
+
protected fetchBlobFromStorage(_blobId: string, _evicted: boolean): never;
|
|
23
|
+
uploadSummaryWithContext(_summary: api.ISummaryTree, _context: ISummaryContext): never;
|
|
24
|
+
createBlob(_file: ArrayBufferLike): never;
|
|
25
|
+
private throwUsageError;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=localOdspDocumentStorageManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localOdspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAOnF;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,8BAA8B;IAI3E,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAJlC,OAAO,CAAC,cAAc,CAAqB;gBAGtB,MAAM,EAAE,gBAAgB,EACxB,aAAa,EAAE,UAAU,GAAG,MAAM;IAKvD,OAAO,CAAC,iBAAiB,CAAS;IAErB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAwB/G,OAAO,CAAC,kBAAkB;IAI1B,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK;IAI3E,SAAS,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,KAAK;IAIlE,wBAAwB,CAAC,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,eAAe,GAAG,KAAK;IAItF,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK;IAIhD,OAAO,CAAC,eAAe;CAK1B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LocalOdspDocumentStorageService = void 0;
|
|
8
|
+
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
+
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
10
|
+
const odspDocumentStorageServiceBase_1 = require("../odspDocumentStorageServiceBase");
|
|
11
|
+
const odspSnapshotParser_1 = require("../odspSnapshotParser");
|
|
12
|
+
const compactSnapshotParser_1 = require("../compactSnapshotParser");
|
|
13
|
+
const ReadBufferUtils_1 = require("../ReadBufferUtils");
|
|
14
|
+
/**
|
|
15
|
+
* ODSP document storage service that works on a provided snapshot for all its processing.
|
|
16
|
+
* Attempting to use unsupported actions/methods will result in errors being thrown.
|
|
17
|
+
*/
|
|
18
|
+
class LocalOdspDocumentStorageService extends odspDocumentStorageServiceBase_1.OdspDocumentStorageServiceBase {
|
|
19
|
+
constructor(logger, localSnapshot) {
|
|
20
|
+
super();
|
|
21
|
+
this.logger = logger;
|
|
22
|
+
this.localSnapshot = localSnapshot;
|
|
23
|
+
this.calledGetVersions = false;
|
|
24
|
+
}
|
|
25
|
+
async getVersions(blobid, count, _scenarioName) {
|
|
26
|
+
(0, common_utils_1.assert)(blobid === null, 0x342 /* Invalid usage. "blobid" should always be null */);
|
|
27
|
+
(0, common_utils_1.assert)(count === 1, 0x343 /* Invalid usage. "count" should always be 1 */);
|
|
28
|
+
// No reason to re-parse the data since it will never change
|
|
29
|
+
if (this.calledGetVersions) {
|
|
30
|
+
return this.getSnapshotVersion();
|
|
31
|
+
}
|
|
32
|
+
this.calledGetVersions = true;
|
|
33
|
+
let snapshotContents;
|
|
34
|
+
if (typeof this.localSnapshot === "string") {
|
|
35
|
+
const content = JSON.parse(this.localSnapshot);
|
|
36
|
+
snapshotContents = (0, odspSnapshotParser_1.convertOdspSnapshotToSnapshotTreeAndBlobs)(content);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
snapshotContents = (0, compactSnapshotParser_1.parseCompactSnapshotResponse)(new ReadBufferUtils_1.ReadBuffer(this.localSnapshot));
|
|
40
|
+
}
|
|
41
|
+
this.snapshotTreeId = this.initializeFromSnapshot(snapshotContents);
|
|
42
|
+
return this.getSnapshotVersion();
|
|
43
|
+
}
|
|
44
|
+
getSnapshotVersion() {
|
|
45
|
+
return this.snapshotTreeId ? [{ id: this.snapshotTreeId, treeId: undefined }] : [];
|
|
46
|
+
}
|
|
47
|
+
fetchTreeFromSnapshot(_id, _scenarioName) {
|
|
48
|
+
this.throwUsageError("fetchTreeFromSnapshot");
|
|
49
|
+
}
|
|
50
|
+
fetchBlobFromStorage(_blobId, _evicted) {
|
|
51
|
+
this.throwUsageError("fetchBlobFromStorage");
|
|
52
|
+
}
|
|
53
|
+
uploadSummaryWithContext(_summary, _context) {
|
|
54
|
+
this.throwUsageError("uploadSummaryWithContext");
|
|
55
|
+
}
|
|
56
|
+
createBlob(_file) {
|
|
57
|
+
this.throwUsageError("createBlob");
|
|
58
|
+
}
|
|
59
|
+
throwUsageError(methodName) {
|
|
60
|
+
const toThrow = new driver_utils_1.UsageError(`"${methodName}" is not supported by LocalOdspDocumentStorageService`);
|
|
61
|
+
this.logger.sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
|
|
62
|
+
throw toThrow;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.LocalOdspDocumentStorageService = LocalOdspDocumentStorageService;
|
|
66
|
+
//# sourceMappingURL=localOdspDocumentStorageManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localOdspDocumentStorageManager.js","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentStorageManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAGtD,+DAA0D;AAE1D,sFAAmF;AAGnF,8DAAkF;AAClF,oEAAwE;AACxE,wDAAgD;AAEhD;;;GAGG;AACH,MAAa,+BAAgC,SAAQ,+DAA8B;IAG/E,YACqB,MAAwB,EACxB,aAAkC;QAEnD,KAAK,EAAE,CAAC;QAHS,WAAM,GAAN,MAAM,CAAkB;QACxB,kBAAa,GAAb,aAAa,CAAqB;QAK/C,sBAAiB,GAAG,KAAK,CAAC;IAFlC,CAAC;IAIM,KAAK,CAAC,WAAW,CAAC,MAAqB,EAAE,KAAa,EAAE,aAAsB;QACjF,IAAA,qBAAM,EAAC,MAAM,KAAK,IAAI,EAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACnF,IAAA,qBAAM,EAAC,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAE3E,4DAA4D;QAC5D,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACxB,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;SACpC;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAE9B,IAAI,gBAAmC,CAAC;QAExC,IAAI,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ,EAAE;YACxC,MAAM,OAA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microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { OdspDocumentStorageServiceBase } from \"../odspDocumentStorageServiceBase\";\nimport { ISnapshotContents } from \"../odspPublicUtils\";\nimport { IOdspSnapshot } from \"../contracts\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"../odspSnapshotParser\";\nimport { parseCompactSnapshotResponse } from \"../compactSnapshotParser\";\nimport { ReadBuffer } from \"../ReadBufferUtils\";\n\n/**\n * ODSP document storage service that works on a provided snapshot for all its processing.\n * Attempting to use unsupported actions/methods will result in errors being thrown.\n */\nexport class LocalOdspDocumentStorageService extends OdspDocumentStorageServiceBase {\n private snapshotTreeId: string | undefined;\n\n constructor(\n private readonly logger: ITelemetryLogger,\n private readonly localSnapshot: Uint8Array | string,\n ) {\n super();\n }\n\n private calledGetVersions = false;\n\n public async getVersions(blobid: string | null, count: number, _scenarioName?: string): Promise<api.IVersion[]> {\n assert(blobid === null, 0x342 /* Invalid usage. \"blobid\" should always be null */);\n assert(count === 1, 0x343 /* Invalid usage. \"count\" should always be 1 */);\n\n // No reason to re-parse the data since it will never change\n if (this.calledGetVersions) {\n return this.getSnapshotVersion();\n }\n this.calledGetVersions = true;\n\n let snapshotContents: ISnapshotContents;\n\n if (typeof this.localSnapshot === \"string\") {\n const content: IOdspSnapshot = JSON.parse(this.localSnapshot);\n snapshotContents = convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n } else {\n snapshotContents = parseCompactSnapshotResponse(\n new ReadBuffer(this.localSnapshot));\n }\n\n this.snapshotTreeId = this.initializeFromSnapshot(snapshotContents);\n return this.getSnapshotVersion();\n }\n\n private getSnapshotVersion(): api.IVersion[] {\n return this.snapshotTreeId ? [{ id: this.snapshotTreeId, treeId: undefined! }] : [];\n }\n\n protected fetchTreeFromSnapshot(_id: string, _scenarioName?: string): never {\n this.throwUsageError(\"fetchTreeFromSnapshot\");\n }\n\n protected fetchBlobFromStorage(_blobId: string, _evicted: boolean): never {\n this.throwUsageError(\"fetchBlobFromStorage\");\n }\n\n public uploadSummaryWithContext(_summary: api.ISummaryTree, _context: ISummaryContext): never {\n this.throwUsageError(\"uploadSummaryWithContext\");\n }\n\n public createBlob(_file: ArrayBufferLike): never {\n this.throwUsageError(\"createBlob\");\n }\n\n private throwUsageError(methodName: string): never {\n const toThrow = new UsageError(`\"${methodName}\" is not supported by LocalOdspDocumentStorageService`);\n this.logger.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n throw toThrow;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDeltaStorageService.js","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAC9D,+BAAkC;AAElC,+DAAsD;AAItD,+DAGsC;AAGtC,2CAA0D;AAE1D;;GAEG;AACH,MAAa,uBAAuB;IAChC,YACqB,YAAoB,EACpB,eAAgD,EAChD,YAA0B,EAC1B,MAAwB;QAHxB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,oBAAe,GAAf,eAAe,CAAiC;QAChD,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAkB;IAE7C,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,GAAG,CACb,IAAY,EACZ,EAAU,EACV,cAAoC,EACpC,WAAoB;QAEpB,OAAO,IAAA,uCAA2B,EAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACjD,gFAAgF;YAChF,kFAAkF;YAClF,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxC,MAAM,YAAY,GAAG,MAAM,IAA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AAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,IAAI,IAAI,eAAe,GAAG,YAAY,GAAG,cAAc,KAAK,CAAC,EAAE;gBACtE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,mBAAmB;oBAC9B,eAAe;oBACf,YAAY;oBACZ,cAAc;iBACjB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACX,CAAC;CACA;AA3HD,8DA2HC","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 { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { IDeltasFetchResult, IDocumentDeltaStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n requestOps,\n streamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n constructor(\n private readonly deltaFeedUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly epochTracker: EpochTracker,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n /**\n * Retrieves ops from cache\n * @param from - inclusive\n * @param to - exclusive\n * @param telemetryProps - properties to add when issuing telemetry events\n * @returns ops retrieved & info if result was partial (i.e. more is available)\n */\n public async get(\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string,\n ): Promise<IDeltasFetchResult> {\n return getWithRetryForTokenRefresh(async (options) => {\n // Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n // Thus it needs to be done before we call getStorageToken() to reduce extra calls\n const baseUrl = this.buildUrl(from, to);\n const storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n const headers: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n\n // Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n // of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n // networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n // So adding some timeout to ensure we retry again in hope of faster success.\n // Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n const abort = new AbortController();\n const timer = setTimeout(() => abort.abort(), 30000);\n\n const response = await this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n baseUrl,\n {\n headers,\n body: postBody,\n method: \"POST\",\n signal: abort.signal,\n },\n \"ops\",\n true,\n fetchReason,\n );\n clearTimeout(timer);\n const deltaStorageResponse = response.content;\n let messages: ISequencedDocumentMessage[];\n if (deltaStorageResponse.value.length > 0 && \"op\" in deltaStorageResponse.value[0]) {\n messages = (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map((operation) => operation.op);\n } else {\n messages = deltaStorageResponse.value as ISequencedDocumentMessage[];\n }\n\n this.logger.sendPerformanceEvent({\n eventName: \"OpsFetch\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n length: messages.length,\n duration: response.duration, // this duration for single attempt!\n ...response.propsToLog,\n attempts: options.refresh ? 2 : 1,\n from,\n to,\n ...telemetryProps,\n });\n\n // It is assumed that server always returns all the ops that it has in the range that was requested.\n // This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n return { messages, partialResult: false };\n });\n }\n\n public buildUrl(from: number, to: number) {\n const filter = encodeURIComponent(`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`);\n const queryString = `?ump=1&filter=${filter}`;\n return `${this.deltaFeedUrl}${queryString}`;\n }\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n private firstCacheMiss = Number.MAX_SAFE_INTEGER;\n\n public constructor(\n private snapshotOps: ISequencedDocumentMessage[] | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly batchSize: number,\n private readonly concurrency: number,\n private readonly getFromStorage: (\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string) => Promise<IDeltasFetchResult>,\n private readonly getCached: (from: number, to: number) => Promise<ISequencedDocumentMessage[]>,\n private readonly requestFromSocket: (from: number, to: number) => void,\n private readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n ) {\n }\n\n protected validateMessages(reason: string, messages: ISequencedDocumentMessage[], from: number) {\n if (messages.length !== 0) {\n const start = messages[0].sequenceNumber;\n const length = messages.length;\n const last = messages[length - 1].sequenceNumber;\n if (start !== from) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n messages.length = 0;\n }\n if (last + 1 !== from + length) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n // we can do better here by finding consecutive sub-block and return it\n messages.length = 0;\n }\n }\n }\n\n public fetchMessages(\n fromTotal: number,\n toTotal: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n fetchReason?: string) {\n // We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n // storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n // cache and it's not there.\n // Better implementation would be to return only what we have in cache, but that also breaks API\n assert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n let opsFromSnapshot = 0;\n let opsFromCache = 0;\n let opsFromStorage = 0;\n\n const requestCallback = async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n if (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n const messages = this.snapshotOps.filter((op) =>\n op.sequenceNumber >= from && op.sequenceNumber < to);\n this.validateMessages(\"cached\", messages, from);\n if (messages.length > 0 && messages[0].sequenceNumber === from) {\n this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n opsFromSnapshot = messages.length;\n return { messages, partialResult: true };\n }\n this.snapshotOps = undefined;\n }\n\n // Kick out request to PUSH for ops if it has them\n this.requestFromSocket(from, to);\n\n // Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n // This saves a bit of processing time\n if (from < this.firstCacheMiss) {\n const messagesFromCache = await this.getCached(from, to);\n this.validateMessages(\"cached\", messagesFromCache, from);\n if (messagesFromCache.length !== 0) {\n opsFromCache += messagesFromCache.length;\n return {\n messages: messagesFromCache,\n partialResult: true,\n };\n }\n this.firstCacheMiss = Math.min(this.firstCacheMiss, from);\n }\n\n if (cachedOnly) {\n return { messages: [], partialResult: false };\n }\n\n const ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n this.validateMessages(\"storage\", ops.messages, from);\n opsFromStorage += ops.messages.length;\n this.opsReceived(ops.messages);\n return ops;\n };\n\n const stream = requestOps(\n async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n const result = await requestCallback(from, to, telemetryProps);\n // Catch all case, just in case\n this.validateMessages(\"catch all\", result.messages, from);\n return result;\n },\n // Staging: starting with no concurrency, listening for feedback first.\n // In future releases we will switch to actual concurrency\n this.concurrency,\n fromTotal, // inclusive\n toTotal, // exclusive\n this.batchSize,\n this.logger,\n abortSignal,\n fetchReason,\n );\n\n return streamObserver(stream, (result) => {\n if (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsRetrieved\",\n opsFromSnapshot,\n opsFromCache,\n opsFromStorage,\n });\n }\n });\n}\n}\n"]}
|
|
1
|
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CAAC,CAAC;YACrD,cAAc,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC/B,OAAO,GAAG,CAAC;QACf,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,yBAAU,EACrB,KAAK,EAAE,IAAY,EAAE,EAAU,EAAE,cAAoC,EAAE,EAAE;YACrE,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;YAC/D,+BAA+B;YAC/B,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,uEAAuE;QACvE,0DAA0D;QAC1D,IAAI,CAAC,WAAW,EAChB,SAAS,EAAE,YAAY;QACvB,OAAO,EAAE,YAAY;QACrB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,EACX,WAAW,EACX,WAAW,CACd,CAAC;QAEF,OAAO,IAAA,6BAAc,EAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,IAAI,IAAI,eAAe,GAAG,YAAY,GAAG,cAAc,KAAK,CAAC,EAAE;gBACtE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,mBAAmB;oBAC9B,eAAe;oBACf,YAAY;oBACZ,cAAc;iBACjB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA3HD,8DA2HC","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 { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { IDeltasFetchResult, IDocumentDeltaStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n requestOps,\n streamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n constructor(\n private readonly deltaFeedUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly epochTracker: EpochTracker,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n /**\n * Retrieves ops from cache\n * @param from - inclusive\n * @param to - exclusive\n * @param telemetryProps - properties to add when issuing telemetry events\n * @returns ops retrieved & info if result was partial (i.e. more is available)\n */\n public async get(\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string,\n ): Promise<IDeltasFetchResult> {\n return getWithRetryForTokenRefresh(async (options) => {\n // Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n // Thus it needs to be done before we call getStorageToken() to reduce extra calls\n const baseUrl = this.buildUrl(from, to);\n const storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n const headers: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n\n // Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n // of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n // networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n // So adding some timeout to ensure we retry again in hope of faster success.\n // Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n const abort = new AbortController();\n const timer = setTimeout(() => abort.abort(), 30000);\n\n const response = await this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n baseUrl,\n {\n headers,\n body: postBody,\n method: \"POST\",\n signal: abort.signal,\n },\n \"ops\",\n true,\n fetchReason,\n );\n clearTimeout(timer);\n const deltaStorageResponse = response.content;\n let messages: ISequencedDocumentMessage[];\n if (deltaStorageResponse.value.length > 0 && \"op\" in deltaStorageResponse.value[0]) {\n messages = (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map((operation) => operation.op);\n } else {\n messages = deltaStorageResponse.value as ISequencedDocumentMessage[];\n }\n\n this.logger.sendPerformanceEvent({\n eventName: \"OpsFetch\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n length: messages.length,\n duration: response.duration, // this duration for single attempt!\n ...response.propsToLog,\n attempts: options.refresh ? 2 : 1,\n from,\n to,\n ...telemetryProps,\n });\n\n // It is assumed that server always returns all the ops that it has in the range that was requested.\n // This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n return { messages, partialResult: false };\n });\n }\n\n public buildUrl(from: number, to: number) {\n const filter = encodeURIComponent(`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`);\n const queryString = `?ump=1&filter=${filter}`;\n return `${this.deltaFeedUrl}${queryString}`;\n }\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n private firstCacheMiss = Number.MAX_SAFE_INTEGER;\n\n public constructor(\n private snapshotOps: ISequencedDocumentMessage[] | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly batchSize: number,\n private readonly concurrency: number,\n private readonly getFromStorage: (\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string) => Promise<IDeltasFetchResult>,\n private readonly getCached: (from: number, to: number) => Promise<ISequencedDocumentMessage[]>,\n private readonly requestFromSocket: (from: number, to: number) => void,\n private readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n ) {\n }\n\n protected validateMessages(reason: string, messages: ISequencedDocumentMessage[], from: number) {\n if (messages.length !== 0) {\n const start = messages[0].sequenceNumber;\n const length = messages.length;\n const last = messages[length - 1].sequenceNumber;\n if (start !== from) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n messages.length = 0;\n }\n if (last + 1 !== from + length) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n // we can do better here by finding consecutive sub-block and return it\n messages.length = 0;\n }\n }\n }\n\n public fetchMessages(\n fromTotal: number,\n toTotal: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n fetchReason?: string) {\n // We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n // storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n // cache and it's not there.\n // Better implementation would be to return only what we have in cache, but that also breaks API\n assert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n let opsFromSnapshot = 0;\n let opsFromCache = 0;\n let opsFromStorage = 0;\n\n const requestCallback = async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n if (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n const messages = this.snapshotOps.filter((op) =>\n op.sequenceNumber >= from && op.sequenceNumber < to);\n this.validateMessages(\"cached\", messages, from);\n if (messages.length > 0 && messages[0].sequenceNumber === from) {\n this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n opsFromSnapshot = messages.length;\n return { messages, partialResult: true };\n }\n this.snapshotOps = undefined;\n }\n\n // Kick out request to PUSH for ops if it has them\n this.requestFromSocket(from, to);\n\n // Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n // This saves a bit of processing time\n if (from < this.firstCacheMiss) {\n const messagesFromCache = await this.getCached(from, to);\n this.validateMessages(\"cached\", messagesFromCache, from);\n if (messagesFromCache.length !== 0) {\n opsFromCache += messagesFromCache.length;\n return {\n messages: messagesFromCache,\n partialResult: true,\n };\n }\n this.firstCacheMiss = Math.min(this.firstCacheMiss, from);\n }\n\n if (cachedOnly) {\n return { messages: [], partialResult: false };\n }\n\n const ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n this.validateMessages(\"storage\", ops.messages, from);\n opsFromStorage += ops.messages.length;\n this.opsReceived(ops.messages);\n return ops;\n };\n\n const stream = requestOps(\n async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n const result = await requestCallback(from, to, telemetryProps);\n // Catch all case, just in case\n this.validateMessages(\"catch all\", result.messages, from);\n return result;\n },\n // Staging: starting with no concurrency, listening for feedback first.\n // In future releases we will switch to actual concurrency\n this.concurrency,\n fromTotal, // inclusive\n toTotal, // exclusive\n this.batchSize,\n this.logger,\n abortSignal,\n fetchReason,\n );\n\n return streamObserver(stream, (result) => {\n if (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsRetrieved\",\n opsFromSnapshot,\n opsFromCache,\n opsFromStorage,\n });\n }\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentService.d.ts","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAStE,OAAO,EACH,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,wBAAwB,EAE3B,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"odspDocumentService.d.ts","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAStE,OAAO,EACH,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,YAAY,EACZ,uBA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