@fluidframework/odsp-driver 1.1.0 → 1.2.0-77818

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/contractsPublic.d.ts +1 -0
  2. package/dist/contractsPublic.d.ts.map +1 -1
  3. package/dist/contractsPublic.js.map +1 -1
  4. package/dist/localOdspDriver/localOdspDocumentService.d.ts +26 -0
  5. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
  6. package/dist/localOdspDriver/localOdspDocumentService.js +39 -0
  7. package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -0
  8. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +24 -0
  9. package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
  10. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js +45 -0
  11. package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
  12. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +27 -0
  13. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
  14. package/dist/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
  15. package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
  16. package/dist/odspDeltaStorageService.js.map +1 -1
  17. package/dist/odspDocumentService.d.ts.map +1 -1
  18. package/dist/odspDocumentService.js.map +1 -1
  19. package/dist/odspDocumentServiceFactory.d.ts +2 -1
  20. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  21. package/dist/odspDocumentServiceFactory.js +7 -1
  22. package/dist/odspDocumentServiceFactory.js.map +1 -1
  23. package/dist/odspDocumentServiceFactoryCore.d.ts +3 -1
  24. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  25. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  26. package/dist/odspDocumentStorageManager.d.ts +5 -23
  27. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  28. package/dist/odspDocumentStorageManager.js +52 -245
  29. package/dist/odspDocumentStorageManager.js.map +1 -1
  30. package/dist/odspDocumentStorageServiceBase.d.ts +58 -0
  31. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -0
  32. package/dist/odspDocumentStorageServiceBase.js +216 -0
  33. package/dist/odspDocumentStorageServiceBase.js.map +1 -0
  34. package/dist/odspDriverUrlResolver.js +1 -1
  35. package/dist/odspDriverUrlResolver.js.map +1 -1
  36. package/dist/odspDriverUrlResolverForShareLink.d.ts +8 -2
  37. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  38. package/dist/odspDriverUrlResolverForShareLink.js +11 -3
  39. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  40. package/dist/odspFluidFileLink.d.ts.map +1 -1
  41. package/dist/odspFluidFileLink.js +27 -21
  42. package/dist/odspFluidFileLink.js.map +1 -1
  43. package/dist/packageVersion.d.ts +1 -1
  44. package/dist/packageVersion.d.ts.map +1 -1
  45. package/dist/packageVersion.js +1 -1
  46. package/dist/packageVersion.js.map +1 -1
  47. package/lib/contractsPublic.d.ts +1 -0
  48. package/lib/contractsPublic.d.ts.map +1 -1
  49. package/lib/contractsPublic.js.map +1 -1
  50. package/lib/localOdspDriver/localOdspDocumentService.d.ts +26 -0
  51. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
  52. package/lib/localOdspDriver/localOdspDocumentService.js +35 -0
  53. package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -0
  54. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts +24 -0
  55. package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
  56. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js +41 -0
  57. package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
  58. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts +27 -0
  59. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
  60. package/lib/localOdspDriver/localOdspDocumentStorageManager.js +62 -0
  61. package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
  62. package/lib/odspDeltaStorageService.js.map +1 -1
  63. package/lib/odspDocumentService.d.ts.map +1 -1
  64. package/lib/odspDocumentService.js +1 -1
  65. package/lib/odspDocumentService.js.map +1 -1
  66. package/lib/odspDocumentServiceFactory.d.ts +2 -1
  67. package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
  68. package/lib/odspDocumentServiceFactory.js +5 -0
  69. package/lib/odspDocumentServiceFactory.js.map +1 -1
  70. package/lib/odspDocumentServiceFactoryCore.d.ts +3 -1
  71. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  72. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  73. package/lib/odspDocumentStorageManager.d.ts +5 -23
  74. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  75. package/lib/odspDocumentStorageManager.js +53 -246
  76. package/lib/odspDocumentStorageManager.js.map +1 -1
  77. package/lib/odspDocumentStorageServiceBase.d.ts +58 -0
  78. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -0
  79. package/lib/odspDocumentStorageServiceBase.js +212 -0
  80. package/lib/odspDocumentStorageServiceBase.js.map +1 -0
  81. package/lib/odspDriverUrlResolver.js +1 -1
  82. package/lib/odspDriverUrlResolver.js.map +1 -1
  83. package/lib/odspDriverUrlResolverForShareLink.d.ts +8 -2
  84. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  85. package/lib/odspDriverUrlResolverForShareLink.js +11 -3
  86. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  87. package/lib/odspFluidFileLink.d.ts.map +1 -1
  88. package/lib/odspFluidFileLink.js +27 -21
  89. package/lib/odspFluidFileLink.js.map +1 -1
  90. package/lib/packageVersion.d.ts +1 -1
  91. package/lib/packageVersion.d.ts.map +1 -1
  92. package/lib/packageVersion.js +1 -1
  93. package/lib/packageVersion.js.map +1 -1
  94. package/package.json +11 -11
  95. package/src/contractsPublic.ts +1 -0
  96. package/src/localOdspDriver/localOdspDocumentService.ts +54 -0
  97. package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +67 -0
  98. package/src/localOdspDriver/localOdspDocumentStorageManager.ts +83 -0
  99. package/src/odspDeltaStorageService.ts +1 -1
  100. package/src/odspDocumentService.ts +5 -1
  101. package/src/odspDocumentServiceFactory.ts +7 -3
  102. package/src/odspDocumentServiceFactoryCore.ts +1 -1
  103. package/src/odspDocumentStorageManager.ts +81 -312
  104. package/src/odspDocumentStorageServiceBase.ts +268 -0
  105. package/src/odspDriverUrlResolver.ts +1 -1
  106. package/src/odspDriverUrlResolverForShareLink.ts +13 -1
  107. package/src/odspFluidFileLink.ts +26 -22
  108. package/src/packageVersion.ts +1 -1
@@ -4,9 +4,11 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.OdspDocumentServiceFactory = void 0;
7
+ exports.createLocalOdspDocumentServiceFactory = exports.OdspDocumentServiceFactory = void 0;
8
8
  const odspDocumentServiceFactoryCore_1 = require("./odspDocumentServiceFactoryCore");
9
9
  const getSocketIo_1 = require("./getSocketIo");
10
+ // eslint-disable-next-line import/no-internal-modules
11
+ const localOdspDocumentServiceFactory_1 = require("./localOdspDriver/localOdspDocumentServiceFactory");
10
12
  /**
11
13
  * Factory for creating the sharepoint document service. Use this if you want to
12
14
  * use the sharepoint implementation.
@@ -17,4 +19,8 @@ class OdspDocumentServiceFactory extends odspDocumentServiceFactoryCore_1.OdspDo
17
19
  }
18
20
  }
19
21
  exports.OdspDocumentServiceFactory = OdspDocumentServiceFactory;
22
+ function createLocalOdspDocumentServiceFactory(localSnapshot) {
23
+ return new localOdspDocumentServiceFactory_1.LocalOdspDocumentServiceFactory(localSnapshot);
24
+ }
25
+ exports.createLocalOdspDocumentServiceFactory = createLocalOdspDocumentServiceFactory;
20
26
  //# sourceMappingURL=odspDocumentServiceFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentServiceFactory.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,qFAAkF;AAClF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,0BACT,SAAQ,+DAA8B;IAEtC,YACI,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CACD,eAAe,EACf,iBAAiB,EACjB,KAAK,IAAI,EAAE,CAAC,IAAA,yBAAW,GAAE,EACzB,cAAc,EACd,UAAU,CACb,CAAC;IACN,CAAC;CACJ;AAjBD,gEAiBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport {\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n IPersistedCache,\n HostStoragePolicy,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore\";\nimport { getSocketIo } from \"./getSocketIo\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n */\nexport class OdspDocumentServiceFactory\n extends OdspDocumentServiceFactoryCore\n implements IDocumentServiceFactory {\n constructor(\n getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n persistedCache?: IPersistedCache,\n hostPolicy?: HostStoragePolicy,\n ) {\n super(\n getStorageToken,\n getWebsocketToken,\n async () => getSocketIo(),\n persistedCache,\n hostPolicy,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"odspDocumentServiceFactory.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,qFAAkF;AAClF,+CAA4C;AAC5C,sDAAsD;AACtD,uGAAoG;AAEpG;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,+DAA8B;IAC1E,YACI,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CACD,eAAe,EACf,iBAAiB,EACjB,KAAK,IAAI,EAAE,CAAC,IAAA,yBAAW,GAAE,EACzB,cAAc,EACd,UAAU,CACb,CAAC;IACN,CAAC;CACJ;AAfD,gEAeC;AAED,SAAgB,qCAAqC,CAAC,aAAkC;IACpF,OAAO,IAAI,iEAA+B,CAAC,aAAa,CAAC,CAAC;AAC9D,CAAC;AAFD,sFAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentServiceFactory } from \"@fluidframework/driver-definitions\";\nimport {\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n IPersistedCache,\n HostStoragePolicy,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore\";\nimport { getSocketIo } from \"./getSocketIo\";\n// eslint-disable-next-line import/no-internal-modules\nimport { LocalOdspDocumentServiceFactory } from \"./localOdspDriver/localOdspDocumentServiceFactory\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n */\nexport class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {\n constructor(\n getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n persistedCache?: IPersistedCache,\n hostPolicy?: HostStoragePolicy,\n ) {\n super(\n getStorageToken,\n getWebsocketToken,\n async () => getSocketIo(),\n persistedCache,\n hostPolicy,\n );\n }\n}\n\nexport function createLocalOdspDocumentServiceFactory(localSnapshot: Uint8Array | string): IDocumentServiceFactory {\n return new LocalOdspDocumentServiceFactory(localSnapshot);\n}\n"]}
@@ -5,8 +5,10 @@
5
5
  import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
6
6
  import { IDocumentService, IDocumentServiceFactory, IResolvedUrl } from "@fluidframework/driver-definitions";
7
7
  import { ISummaryTree } from "@fluidframework/protocol-definitions";
8
+ import { TelemetryLogger } from "@fluidframework/telemetry-utils";
8
9
  import { OdspResourceTokenFetchOptions, TokenFetcher, IPersistedCache, HostStoragePolicy } from "@fluidframework/odsp-driver-definitions";
9
10
  import type { io as SocketIOClientStatic } from "socket.io-client";
11
+ import { ICacheAndTracker } from "./epochTracker";
10
12
  /**
11
13
  * Factory for creating the sharepoint document service. Use this if you want to
12
14
  * use the sharepoint implementation.
@@ -36,6 +38,6 @@ export declare class OdspDocumentServiceFactoryCore implements IDocumentServiceF
36
38
  */
37
39
  constructor(getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined, getSocketIOClient: () => Promise<typeof SocketIOClientStatic>, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy);
38
40
  createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
39
- private createDocumentServiceCore;
41
+ protected createDocumentServiceCore(resolvedUrl: IResolvedUrl, odspLogger: TelemetryLogger, cacheAndTrackerArg?: ICacheAndTracker, clientIsSummarizer?: boolean): Promise<IDocumentService>;
40
42
  }
41
43
  //# sourceMappingURL=odspDocumentServiceFactoryCore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentServiceFactoryCore.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACH,gBAAgB,EAChB,uBAAuB,EACvB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AASpE,OAAO,EAEH,6BAA6B,EAC7B,YAAY,EACZ,eAAe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mBAAmB,CAAC,CAAC;QAEpC,OAAO,yCAAmB,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;AA9KD,wEA8KC","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 private 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"]}
1
+ {"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,qEAGyC;AACzC,+DAGsC;AAWtC,+BAAkC;AAClC,2CAGqB;AACrB,iDAGwB;AACxB,+DAA4D;AAC5D,2CAAiH;AACjH,6CAAkD;AAElD;;;;;;GAMG;AACH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;YAChC,MAAM,EAAE,eAAe,CAAC,MAAM;SACjC,CAAC;QACF,MAAM,eAAe,GAAG,kBAAkB,aAAlB,kBAAkB,cAAlB,kBAAkB,GAAI,IAAA,wCAAyB,EACnE,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,kBAAkB,EACvB,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,CAAC,gBAAgB,EAAE,EACzE,UAAU,EACV,kBAAkB,CAAC,CAAC;QAExB,MAAM,mBAAmB,GAAG,IAAA,0CAA8B,EACtD,UAAU,EACV,eAAe,EACf,IAAI,CAAC,eAAe,EACpB,IAAI,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,IAAA,0CAA8B,EAClE,UAAU,EACV,eAAe,EACf,IAAI,CAAC,iBAAkB,EACvB,KAAK,CAAC,sBAAsB,CAC/B,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;QAEpC,OAAO,yCAAmB,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;AA9KD,wEA8KC","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 }\n}\n"]}
@@ -4,15 +4,16 @@
4
4
  */
5
5
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
6
6
  import * as api from "@fluidframework/protocol-definitions";
7
- import { ISummaryContext, IDocumentStorageService, LoaderCachingPolicy } from "@fluidframework/driver-definitions";
7
+ import { ISummaryContext } 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";
11
11
  import { IOdspCache } from "./odspCache";
12
12
  import { EpochTracker } from "./epochTracker";
13
13
  import { FlushResult } from "./odspDocumentDeltaConnection";
14
+ import { OdspDocumentStorageServiceBase } from "./odspDocumentStorageServiceBase";
14
15
  export declare const defaultSummarizerCacheExpiryTimeout: number;
15
- export declare class OdspDocumentStorageService implements IDocumentStorageService {
16
+ export declare class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {
16
17
  private readonly odspResolvedUrl;
17
18
  private readonly getStorageToken;
18
19
  private readonly logger;
@@ -22,17 +23,8 @@ export declare class OdspDocumentStorageService implements IDocumentStorageServi
22
23
  private readonly epochTracker;
23
24
  private readonly flushCallback;
24
25
  private readonly snapshotFormatFetchType?;
25
- readonly policies: {
26
- caching: LoaderCachingPolicy;
27
- minBlobSize: number;
28
- maximumCacheDurationMs: number;
29
- };
30
- private readonly commitCache;
31
- private readonly attributesBlobHandles;
32
26
  private readonly odspSummaryUploadManager;
33
- private _ops;
34
27
  private firstVersionCall;
35
- private _snapshotSequenceNumber;
36
28
  private readonly documentId;
37
29
  private readonly snapshotUrl;
38
30
  private readonly attachmentPOSTUrl;
@@ -45,27 +37,17 @@ export declare class OdspDocumentStorageService implements IDocumentStorageServi
45
37
  private readonly maxSnapshotSizeLimit;
46
38
  private readonly maxSnapshotFetchTimeout;
47
39
  private readonly createBlobRateLimiter;
48
- private readonly blobCache;
49
- set ops(ops: api.ISequencedDocumentMessage[] | undefined);
50
- get ops(): api.ISequencedDocumentMessage[] | undefined;
51
- get snapshotSequenceNumber(): number | undefined;
52
40
  constructor(odspResolvedUrl: IOdspResolvedUrl, getStorageToken: InstrumentedStorageTokenFetcher, logger: ITelemetryLogger, fetchFullSnapshot: boolean, cache: IOdspCache, hostPolicy: HostStoragePolicyInternal, epochTracker: EpochTracker, flushCallback: () => Promise<FlushResult>, snapshotFormatFetchType?: SnapshotFormatSupportType | undefined);
53
- get repositoryUrl(): string;
54
41
  createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
55
- private readBlobCore;
56
- readBlob(blobId: string): Promise<ArrayBufferLike>;
42
+ protected fetchBlobFromStorage(blobId: string, evicted: boolean): Promise<ArrayBuffer>;
57
43
  getSnapshotTree(version?: api.IVersion, scenarioName?: string): Promise<api.ISnapshotTree | null>;
58
44
  getVersions(blobid: string | null, count: number, scenarioName?: string): Promise<api.IVersion[]>;
59
45
  private fetchSnapshot;
60
46
  private fetchSnapshotCore;
61
47
  uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
62
- downloadSummary(commit: api.ISummaryHandle): Promise<api.ISummaryTree>;
63
- private setRootTree;
64
- private initBlobsCache;
65
48
  private checkSnapshotUrl;
66
49
  private checkAttachmentPOSTUrl;
67
50
  private checkAttachmentGETUrl;
68
- private readTree;
69
- private combineProtocolAndAppSnapshotTree;
51
+ protected fetchTreeFromSnapshot(id: string, scenarioName?: string): Promise<api.ISnapshotTree | undefined>;
70
52
  }
71
53
  //# sourceMappingURL=odspDocumentStorageManager.d.ts.map
@@ -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,EACf,uBAAuB,EACvB,mBAAmB,EAEtB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,gBAAgB,EAGhB,+BAA+B,EAClC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEH,yBAAyB,EAG5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAA4D,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAEtH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EAA+B,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5D,eAAO,MAAM,mCAAmC,EAAE,MAAkB,CAAC;AAiHrE,qBAAa,0BAA2B,YAAW,uBAAuB;IA6DlE,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IAp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a,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,EACzC,uBAAuB,CAAC,uCAA2B;IAkB3D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;cA0ChE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;IA6C/E,eAAe,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC;IAOjG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YA4JhG,aAAa;YAcb,iBAAiB;IAiFlB,wBAAwB,CAAC,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAuC3G,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,qBAAqB;cASb,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,SAAS,CAAC;CAmCnH"}
@@ -13,9 +13,9 @@ const odsp_driver_definitions_1 = require("@fluidframework/odsp-driver-definitio
13
13
  const fetchSnapshot_1 = require("./fetchSnapshot");
14
14
  const getUrlAndHeadersWithAuth_1 = require("./getUrlAndHeadersWithAuth");
15
15
  const odspUtils_1 = require("./odspUtils");
16
- const epochTracker_1 = require("./epochTracker");
17
16
  const odspSummaryUploadManager_1 = require("./odspSummaryUploadManager");
18
17
  const packageVersion_1 = require("./packageVersion");
18
+ const odspDocumentStorageServiceBase_1 = require("./odspDocumentStorageServiceBase");
19
19
  exports.defaultSummarizerCacheExpiryTimeout = 60 * 1000; // 60 seconds.
20
20
  /* eslint-disable max-len */
21
21
  // An implementation of Promise.race that gives you the winner of the promise race
@@ -26,98 +26,10 @@ async function promiseRaceWithWinner(promises) {
26
26
  });
27
27
  });
28
28
  }
29
- class BlobCache {
30
- constructor() {
31
- // If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately
32
- // This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger
33
- // too many calls to setTimeout/clearTimeout.
34
- this.deferBlobCacheClear = false;
35
- this._blobCache = new Map();
36
- // Tracks all blob IDs evicted from cache
37
- this.blobsEvicted = new Set();
38
- // Initial time-out to purge data from cache
39
- // If this time out is very small, then we purge blobs from cache too soon and that results in a lot of
40
- // requests to storage, which brings down perf and may trip protection limits causing 429s
41
- this.blobCacheTimeoutDuration = 2 * 60 * 1000;
42
- // SPO does not keep old snapshots around for long, so we are running chances of not
43
- // being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,
44
- // even if blob read by runtime, it could be read again in the future)
45
- // So for now, purging is disabled.
46
- this.purgeEnabled = false;
47
- }
48
- get value() {
49
- return this._blobCache;
50
- }
51
- addBlobs(blobs) {
52
- blobs.forEach((value, blobId) => {
53
- this._blobCache.set(blobId, value);
54
- });
55
- // Reset the timer on cache set
56
- this.scheduleClearBlobsCache();
57
- }
58
- /**
59
- * Schedule a timer for clearing the blob cache or defer the current one.
60
- */
61
- scheduleClearBlobsCache() {
62
- if (this.blobCacheTimeout !== undefined) {
63
- // If we already have an outstanding timer, just signal that we should defer the clear
64
- this.deferBlobCacheClear = true;
65
- }
66
- else if (this.purgeEnabled) {
67
- // If we don't have an outstanding timer, set a timer
68
- // When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer
69
- const clearCacheOrDefer = () => {
70
- this.blobCacheTimeout = undefined;
71
- if (this.deferBlobCacheClear) {
72
- this.deferBlobCacheClear = false;
73
- this.scheduleClearBlobsCache();
74
- }
75
- else {
76
- // NOTE: Slightly better algorithm here would be to purge either only big blobs,
77
- // or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache
78
- // Purging is optimizing memory footprint. But count controls potential number of storage requests
79
- // We want to optimize both - memory footprint and number of future requests to storage.
80
- // Note that Container can realize data store or DDS on-demand at any point in time, so we do not
81
- // control when blobs will be used.
82
- this._blobCache.forEach((_, blobId) => this.blobsEvicted.add(blobId));
83
- this._blobCache.clear();
84
- }
85
- };
86
- this.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);
87
- // any future storage reads that get into the cache should be cleared from cache rather quickly -
88
- // there is not much value in keeping them longer
89
- this.blobCacheTimeoutDuration = 10 * 1000;
90
- }
91
- }
92
- getBlob(blobId) {
93
- // Reset the timer on attempted cache read
94
- this.scheduleClearBlobsCache();
95
- const blobContent = this._blobCache.get(blobId);
96
- const evicted = this.blobsEvicted.has(blobId);
97
- return { blobContent, evicted };
98
- }
99
- setBlob(blobId, blob) {
100
- // This API is called as result of cache miss and reading blob from storage.
101
- // Runtime never reads same blob twice.
102
- // The only reason we may get read request for same blob is blob de-duping in summaries.
103
- // Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.
104
- // Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot
105
- // blobs are de-duped.
106
- const size = blob.byteLength;
107
- if (size < 256 * 1024) {
108
- // Reset the timer on cache set
109
- this.scheduleClearBlobsCache();
110
- return this._blobCache.set(blobId, blob);
111
- }
112
- else {
113
- // we evicted it here by not caching.
114
- this.blobsEvicted.add(blobId);
115
- }
116
- }
117
- }
118
- class OdspDocumentStorageService {
29
+ class OdspDocumentStorageService extends odspDocumentStorageServiceBase_1.OdspDocumentStorageServiceBase {
119
30
  constructor(odspResolvedUrl, getStorageToken, logger, fetchFullSnapshot, cache, hostPolicy, epochTracker, flushCallback, snapshotFormatFetchType) {
120
31
  var _a;
32
+ super();
121
33
  this.odspResolvedUrl = odspResolvedUrl;
122
34
  this.getStorageToken = getStorageToken;
123
35
  this.logger = logger;
@@ -127,24 +39,6 @@ class OdspDocumentStorageService {
127
39
  this.epochTracker = epochTracker;
128
40
  this.flushCallback = flushCallback;
129
41
  this.snapshotFormatFetchType = snapshotFormatFetchType;
130
- this.policies = {
131
- // By default, ODSP tells the container not to prefetch/cache.
132
- caching: driver_definitions_1.LoaderCachingPolicy.NoCaching,
133
- // ODSP storage works better if it has less number of blobs / edges
134
- // Runtime creating many small blobs results in sub-optimal perf.
135
- // 2K seems like the sweat spot:
136
- // The smaller the number, less blobs we aggregate. Most storages are very likely to have notion
137
- // of minimal "cluster" size, so having small blobs is wasteful
138
- // At the same time increasing the limit ensure that more blobs with user content are aggregated,
139
- // reducing possibility for de-duping of same blobs (i.e. .attributes rolled into aggregate blob
140
- // are not reused across data stores, or even within data store, resulting in duplication of content)
141
- // Note that duplication of content should not have significant impact for bytes over wire as
142
- // compression of http payload mostly takes care of it, but it does impact storage size and in-memory sizes.
143
- minBlobSize: 2048,
144
- maximumCacheDurationMs: epochTracker_1.defaultCacheExpiryTimeoutMs,
145
- };
146
- this.commitCache = new Map();
147
- this.attributesBlobHandles = new Set();
148
42
  this.firstVersionCall = true;
149
43
  // Driver specified limits for snapshot size and time.
150
44
  /**
@@ -156,26 +50,12 @@ class OdspDocumentStorageService {
156
50
  this.maxSnapshotFetchTimeout = 120000; // 2 min
157
51
  // limits the amount of parallel "attachment" blob uploads
158
52
  this.createBlobRateLimiter = new driver_utils_1.RateLimiter(1);
159
- this.blobCache = new BlobCache();
160
53
  this.documentId = this.odspResolvedUrl.hashedDocumentId;
161
54
  this.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;
162
55
  this.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;
163
56
  this.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;
164
57
  this.odspSummaryUploadManager = new odspSummaryUploadManager_1.OdspSummaryUploadManager(this.snapshotUrl, getStorageToken, logger, epochTracker, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
165
58
  }
166
- set ops(ops) {
167
- (0, common_utils_1.assert)(this._ops === undefined, 0x0a5 /* "Trying to set ops when they are already set!" */);
168
- this._ops = ops;
169
- }
170
- get ops() {
171
- return this._ops;
172
- }
173
- get snapshotSequenceNumber() {
174
- return this._snapshotSequenceNumber;
175
- }
176
- get repositoryUrl() {
177
- return "";
178
- }
179
59
  async createBlob(file) {
180
60
  this.checkAttachmentPOSTUrl();
181
61
  const response = await (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
@@ -199,70 +79,38 @@ class OdspDocumentStorageService {
199
79
  });
200
80
  return response.content;
201
81
  }
202
- async readBlobCore(blobId) {
203
- const { blobContent, evicted } = this.blobCache.getBlob(blobId);
204
- let blob = blobContent;
205
- if (blob === undefined) {
206
- this.checkAttachmentGETUrl();
207
- blob = await (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
208
- var _a;
209
- const storageToken = await this.getStorageToken(options, "GetBlob");
210
- const unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;
211
- const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(unAuthedUrl, storageToken, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
212
- return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
213
- eventName: "readDataBlob",
214
- blobId,
215
- evicted,
216
- headers: Object.keys(headers).length !== 0 ? true : undefined,
217
- waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,
218
- }, async (event) => {
219
- const res = await this.epochTracker.fetchArray(url, { headers }, "blob");
220
- event.end(Object.assign(Object.assign({ waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength }, res.propsToLog), { attempts: options.refresh ? 2 : 1 }));
221
- const cacheControl = res.headers.get("cache-control");
222
- if (cacheControl === undefined || !(cacheControl.includes("private") || cacheControl.includes("public"))) {
223
- this.logger.sendErrorEvent(Object.assign({ eventName: "NonCacheableBlob", cacheControl,
224
- blobId }, res.propsToLog));
225
- }
226
- return res.content;
227
- });
82
+ async fetchBlobFromStorage(blobId, evicted) {
83
+ this.checkAttachmentGETUrl();
84
+ const blob = await (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
85
+ var _a;
86
+ const storageToken = await this.getStorageToken(options, "GetBlob");
87
+ const unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;
88
+ const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(unAuthedUrl, storageToken, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader));
89
+ return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
90
+ eventName: "readDataBlob",
91
+ blobId,
92
+ evicted,
93
+ headers: Object.keys(headers).length !== 0 ? true : undefined,
94
+ waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,
95
+ }, async (event) => {
96
+ const res = await this.epochTracker.fetchArray(url, { headers }, "blob");
97
+ event.end(Object.assign(Object.assign({ waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength }, res.propsToLog), { attempts: options.refresh ? 2 : 1 }));
98
+ const cacheControl = res.headers.get("cache-control");
99
+ if (cacheControl === undefined || !(cacheControl.includes("private") || cacheControl.includes("public"))) {
100
+ this.logger.sendErrorEvent(Object.assign({ eventName: "NonCacheableBlob", cacheControl,
101
+ blobId }, res.propsToLog));
102
+ }
103
+ return res.content;
228
104
  });
229
- this.blobCache.setBlob(blobId, blob);
230
- }
105
+ });
106
+ this.blobCache.setBlob(blobId, blob);
231
107
  return blob;
232
108
  }
233
- async readBlob(blobId) {
234
- return this.readBlobCore(blobId);
235
- }
236
109
  async getSnapshotTree(version, scenarioName) {
237
110
  if (!this.snapshotUrl) {
238
111
  return null;
239
112
  }
240
- let id;
241
- if (!version || !version.id) {
242
- const versions = await this.getVersions(null, 1, scenarioName);
243
- if (!versions || versions.length === 0) {
244
- return null;
245
- }
246
- id = versions[0].id;
247
- }
248
- else {
249
- id = version.id;
250
- }
251
- const snapshotTree = await this.readTree(id, scenarioName);
252
- if (!snapshotTree) {
253
- return null;
254
- }
255
- if (snapshotTree.blobs) {
256
- const attributesBlob = snapshotTree.blobs.attributes;
257
- if (attributesBlob) {
258
- this.attributesBlobHandles.add(attributesBlob);
259
- }
260
- }
261
- // When we upload the container snapshot, we upload appTree in ".app" and protocol tree in ".protocol"
262
- // So when we request the snapshot we get ".app" as tree and not as commit node as in the case just above.
263
- const appTree = snapshotTree.trees[".app"];
264
- const protocolTree = snapshotTree.trees[".protocol"];
265
- return this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);
113
+ return super.getSnapshotTree(version, scenarioName);
266
114
  }
267
115
  async getVersions(blobid, count, scenarioName) {
268
116
  // Regular load workflow uses blobId === documentID to indicate "latest".
@@ -361,19 +209,7 @@ class OdspDocumentStorageService {
361
209
  });
362
210
  // Successful call, make network calls only
363
211
  this.firstVersionCall = false;
364
- this._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;
365
- const { snapshotTree, blobs, ops } = odspSnapshotCacheValue;
366
- // id should be undefined in case of just ops in snapshot.
367
- let id;
368
- if (snapshotTree) {
369
- id = snapshotTree.id;
370
- (0, common_utils_1.assert)(id !== undefined, 0x221 /* "Root tree should contain the id" */);
371
- this.setRootTree(id, snapshotTree);
372
- }
373
- if (blobs) {
374
- this.initBlobsCache(blobs);
375
- }
376
- this.ops = ops;
212
+ const id = this.initializeFromSnapshot(odspSnapshotCacheValue);
377
213
  return id ? [{ id, treeId: undefined }] : [];
378
214
  }
379
215
  return (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
@@ -458,34 +294,25 @@ class OdspDocumentStorageService {
458
294
  this.checkSnapshotUrl();
459
295
  // Enable flushing only if we have single commit summary and this is not the initial summary for an empty file
460
296
  if (".protocol" in summary.tree && context.ackHandle !== undefined) {
461
- let retry = 0;
297
+ let retry = 1;
462
298
  for (;;) {
463
299
  const result = await this.flushCallback();
464
300
  const seq = result.lastPersistedSequenceNumber;
465
301
  if (seq !== undefined && seq >= context.referenceSequenceNumber) {
466
302
  break;
467
303
  }
468
- retry++;
469
304
  if (retry > 3) {
470
305
  this.logger.sendErrorEvent(Object.assign(Object.assign({ eventName: "FlushFailure" }, result), { retry, referenceSequenceNumber: context.referenceSequenceNumber }));
471
306
  break;
472
307
  }
473
308
  this.logger.sendPerformanceEvent(Object.assign(Object.assign({ eventName: "FlushExtraCall" }, result), { retry, referenceSequenceNumber: context.referenceSequenceNumber }));
309
+ retry++;
474
310
  await (0, common_utils_1.delay)(1000 * ((_a = result.retryAfter) !== null && _a !== void 0 ? _a : 1));
475
311
  }
476
312
  }
477
313
  const id = await this.odspSummaryUploadManager.writeSummaryTree(summary, context);
478
314
  return id;
479
315
  }
480
- async downloadSummary(commit) {
481
- throw new Error("Not implemented yet");
482
- }
483
- setRootTree(id, tree) {
484
- this.commitCache.set(id, tree);
485
- }
486
- initBlobsCache(blobs) {
487
- this.blobCache.addBlobs(blobs);
488
- }
489
316
  checkSnapshotUrl() {
490
317
  if (!this.snapshotUrl) {
491
318
  throw new driver_utils_1.NonRetryableError("Method failed because no snapshot url was available", driver_definitions_1.DriverErrorType.genericError, { driverVersion: packageVersion_1.pkgVersion });
@@ -501,47 +328,27 @@ class OdspDocumentStorageService {
501
328
  throw new driver_utils_1.NonRetryableError("Method failed because no attachment GET url was available", driver_definitions_1.DriverErrorType.genericError, { driverVersion: packageVersion_1.pkgVersion });
502
329
  }
503
330
  }
504
- async readTree(id, scenarioName) {
505
- if (!this.snapshotUrl) {
506
- return null;
507
- }
508
- let tree = this.commitCache.get(id);
509
- if (!tree) {
510
- tree = await (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
511
- var _a, _b;
512
- const storageToken = await this.getStorageToken(options, "ReadCommit");
513
- const snapshotDownloader = async (url, fetchOptions) => {
514
- return this.epochTracker.fetchAndParseAsJSON(url, fetchOptions, "snapshotTree", undefined, scenarioName);
515
- };
516
- const snapshot = await (0, fetchSnapshot_1.fetchSnapshot)(this.snapshotUrl, storageToken, id, this.fetchFullSnapshot, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader), this.logger, snapshotDownloader);
517
- let treeId = "";
518
- if (snapshot.snapshotTree) {
519
- (0, common_utils_1.assert)(snapshot.snapshotTree.id !== undefined, 0x222 /* "Root tree should contain the id!!" */);
520
- treeId = snapshot.snapshotTree.id;
521
- this.setRootTree(treeId, snapshot.snapshotTree);
522
- }
523
- if (snapshot.blobs) {
524
- this.initBlobsCache(snapshot.blobs);
525
- }
526
- // If the version id doesn't match with the id of the tree, then use the id of first tree which in that case
527
- // will be the actual id of tree to be fetched.
528
- return (_b = this.commitCache.get(id)) !== null && _b !== void 0 ? _b : this.commitCache.get(treeId);
529
- });
530
- }
531
- if (!tree) {
532
- return null;
533
- }
534
- return tree;
535
- }
536
- combineProtocolAndAppSnapshotTree(hierarchicalAppTree, hierarchicalProtocolTree) {
537
- const summarySnapshotTree = {
538
- blobs: Object.assign({}, hierarchicalAppTree.blobs),
539
- trees: Object.assign(Object.assign({}, hierarchicalAppTree.trees), {
540
- // the app tree could have a .protocol
541
- // in that case we want to server protocol to override it
542
- ".protocol": hierarchicalProtocolTree }),
543
- };
544
- return summarySnapshotTree;
331
+ async fetchTreeFromSnapshot(id, scenarioName) {
332
+ return (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
333
+ var _a, _b;
334
+ const storageToken = await this.getStorageToken(options, "ReadCommit");
335
+ const snapshotDownloader = async (url, fetchOptions) => {
336
+ return this.epochTracker.fetchAndParseAsJSON(url, fetchOptions, "snapshotTree", undefined, scenarioName);
337
+ };
338
+ const snapshot = await (0, fetchSnapshot_1.fetchSnapshot)(this.snapshotUrl, storageToken, id, this.fetchFullSnapshot, !!((_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.forceAccessTokenViaAuthorizationHeader), this.logger, snapshotDownloader);
339
+ let treeId = "";
340
+ if (snapshot.snapshotTree) {
341
+ (0, common_utils_1.assert)(snapshot.snapshotTree.id !== undefined, 0x222 /* "Root tree should contain the id!!" */);
342
+ treeId = snapshot.snapshotTree.id;
343
+ this.setRootTree(treeId, snapshot.snapshotTree);
344
+ }
345
+ if (snapshot.blobs) {
346
+ this.initBlobsCache(snapshot.blobs);
347
+ }
348
+ // If the version id doesn't match with the id of the tree, then use the id of first tree which in that case
349
+ // will be the actual id of tree to be fetched.
350
+ return (_b = this.commitCache.get(id)) !== null && _b !== void 0 ? _b : this.commitCache.get(treeId);
351
+ });
545
352
  }
546
353
  }
547
354
  exports.OdspDocumentStorageService = OdspDocumentStorageService;