@fluidframework/routerlicious-driver 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191457

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 (180) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +4 -3
  3. package/dist/contracts.d.ts +28 -1
  4. package/dist/contracts.d.ts.map +1 -1
  5. package/dist/contracts.js.map +1 -1
  6. package/dist/createNewUtils.d.ts +1 -1
  7. package/dist/createNewUtils.js +3 -3
  8. package/dist/createNewUtils.js.map +1 -1
  9. package/dist/deltaStorageService.d.ts.map +1 -1
  10. package/dist/deltaStorageService.js +17 -6
  11. package/dist/deltaStorageService.js.map +1 -1
  12. package/dist/documentDeltaConnection.js +1 -1
  13. package/dist/documentDeltaConnection.js.map +1 -1
  14. package/dist/documentService.d.ts +3 -3
  15. package/dist/documentService.d.ts.map +1 -1
  16. package/dist/documentService.js +4 -4
  17. package/dist/documentService.js.map +1 -1
  18. package/dist/documentServiceFactory.d.ts.map +1 -1
  19. package/dist/documentServiceFactory.js +32 -10
  20. package/dist/documentServiceFactory.js.map +1 -1
  21. package/dist/documentStorageService.d.ts +2 -2
  22. package/dist/documentStorageService.d.ts.map +1 -1
  23. package/dist/documentStorageService.js +2 -2
  24. package/dist/documentStorageService.js.map +1 -1
  25. package/dist/errorUtils.d.ts +38 -6
  26. package/dist/errorUtils.d.ts.map +1 -1
  27. package/dist/errorUtils.js +32 -16
  28. package/dist/errorUtils.js.map +1 -1
  29. package/dist/gitManager.d.ts +3 -2
  30. package/dist/gitManager.d.ts.map +1 -1
  31. package/dist/gitManager.js +2 -2
  32. package/dist/gitManager.js.map +1 -1
  33. package/dist/historian.d.ts +3 -2
  34. package/dist/historian.d.ts.map +1 -1
  35. package/dist/historian.js +13 -6
  36. package/dist/historian.js.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +2 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/mapWithExpiration.js +2 -2
  42. package/dist/mapWithExpiration.js.map +1 -1
  43. package/dist/packageVersion.d.ts +1 -1
  44. package/dist/packageVersion.js +1 -1
  45. package/dist/packageVersion.js.map +1 -1
  46. package/dist/policies.d.ts +7 -1
  47. package/dist/policies.d.ts.map +1 -1
  48. package/dist/policies.js.map +1 -1
  49. package/dist/r11sSnapshotParser.d.ts +4 -5
  50. package/dist/r11sSnapshotParser.d.ts.map +1 -1
  51. package/dist/r11sSnapshotParser.js +13 -15
  52. package/dist/r11sSnapshotParser.js.map +1 -1
  53. package/dist/restWrapper.d.ts +3 -3
  54. package/dist/restWrapper.d.ts.map +1 -1
  55. package/dist/restWrapper.js +53 -36
  56. package/dist/restWrapper.js.map +1 -1
  57. package/dist/restWrapperBase.js +39 -5
  58. package/dist/restWrapperBase.js.map +1 -1
  59. package/dist/retriableGitManager.d.ts +3 -2
  60. package/dist/retriableGitManager.d.ts.map +1 -1
  61. package/dist/retriableGitManager.js +2 -2
  62. package/dist/retriableGitManager.js.map +1 -1
  63. package/dist/shreddedSummaryDocumentStorageService.js +13 -16
  64. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
  65. package/dist/storageContracts.d.ts +4 -3
  66. package/dist/storageContracts.d.ts.map +1 -1
  67. package/dist/storageContracts.js.map +1 -1
  68. package/dist/summaryTreeUploadManager.d.ts.map +1 -1
  69. package/dist/summaryTreeUploadManager.js +11 -11
  70. package/dist/summaryTreeUploadManager.js.map +1 -1
  71. package/dist/treeUtils.d.ts +2 -2
  72. package/dist/treeUtils.d.ts.map +1 -1
  73. package/dist/treeUtils.js +8 -8
  74. package/dist/treeUtils.js.map +1 -1
  75. package/dist/wholeSummaryDocumentStorageService.d.ts +2 -2
  76. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  77. package/dist/wholeSummaryDocumentStorageService.js +27 -22
  78. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  79. package/dist/wholeSummaryUploadManager.js +1 -2
  80. package/dist/wholeSummaryUploadManager.js.map +1 -1
  81. package/lib/contracts.d.ts +28 -1
  82. package/lib/contracts.d.ts.map +1 -1
  83. package/lib/contracts.js.map +1 -1
  84. package/lib/createNewUtils.d.ts +1 -1
  85. package/lib/createNewUtils.js +2 -2
  86. package/lib/createNewUtils.js.map +1 -1
  87. package/lib/deltaStorageService.d.ts.map +1 -1
  88. package/lib/deltaStorageService.js +17 -6
  89. package/lib/deltaStorageService.js.map +1 -1
  90. package/lib/documentDeltaConnection.js +1 -1
  91. package/lib/documentDeltaConnection.js.map +1 -1
  92. package/lib/documentService.d.ts +3 -3
  93. package/lib/documentService.d.ts.map +1 -1
  94. package/lib/documentService.js +4 -4
  95. package/lib/documentService.js.map +1 -1
  96. package/lib/documentServiceFactory.d.ts.map +1 -1
  97. package/lib/documentServiceFactory.js +32 -10
  98. package/lib/documentServiceFactory.js.map +1 -1
  99. package/lib/documentStorageService.d.ts +2 -2
  100. package/lib/documentStorageService.d.ts.map +1 -1
  101. package/lib/documentStorageService.js +2 -2
  102. package/lib/documentStorageService.js.map +1 -1
  103. package/lib/errorUtils.d.ts +38 -6
  104. package/lib/errorUtils.d.ts.map +1 -1
  105. package/lib/errorUtils.js +31 -15
  106. package/lib/errorUtils.js.map +1 -1
  107. package/lib/gitManager.d.ts +3 -2
  108. package/lib/gitManager.d.ts.map +1 -1
  109. package/lib/gitManager.js +2 -2
  110. package/lib/gitManager.js.map +1 -1
  111. package/lib/historian.d.ts +3 -2
  112. package/lib/historian.d.ts.map +1 -1
  113. package/lib/historian.js +12 -5
  114. package/lib/historian.js.map +1 -1
  115. package/lib/index.d.ts +1 -1
  116. package/lib/index.d.ts.map +1 -1
  117. package/lib/index.js +1 -1
  118. package/lib/index.js.map +1 -1
  119. package/lib/mapWithExpiration.js +1 -1
  120. package/lib/mapWithExpiration.js.map +1 -1
  121. package/lib/packageVersion.d.ts +1 -1
  122. package/lib/packageVersion.js +1 -1
  123. package/lib/packageVersion.js.map +1 -1
  124. package/lib/policies.d.ts +7 -1
  125. package/lib/policies.d.ts.map +1 -1
  126. package/lib/policies.js.map +1 -1
  127. package/lib/r11sSnapshotParser.d.ts +4 -5
  128. package/lib/r11sSnapshotParser.d.ts.map +1 -1
  129. package/lib/r11sSnapshotParser.js +11 -13
  130. package/lib/r11sSnapshotParser.js.map +1 -1
  131. package/lib/restWrapper.d.ts +3 -3
  132. package/lib/restWrapper.d.ts.map +1 -1
  133. package/lib/restWrapper.js +48 -31
  134. package/lib/restWrapper.js.map +1 -1
  135. package/lib/restWrapperBase.js +39 -5
  136. package/lib/restWrapperBase.js.map +1 -1
  137. package/lib/retriableGitManager.d.ts +3 -2
  138. package/lib/retriableGitManager.d.ts.map +1 -1
  139. package/lib/retriableGitManager.js +2 -2
  140. package/lib/retriableGitManager.js.map +1 -1
  141. package/lib/shreddedSummaryDocumentStorageService.js +12 -15
  142. package/lib/shreddedSummaryDocumentStorageService.js.map +1 -1
  143. package/lib/storageContracts.d.ts +4 -3
  144. package/lib/storageContracts.d.ts.map +1 -1
  145. package/lib/storageContracts.js.map +1 -1
  146. package/lib/summaryTreeUploadManager.d.ts.map +1 -1
  147. package/lib/summaryTreeUploadManager.js +4 -4
  148. package/lib/summaryTreeUploadManager.js.map +1 -1
  149. package/lib/treeUtils.d.ts +2 -2
  150. package/lib/treeUtils.d.ts.map +1 -1
  151. package/lib/treeUtils.js +4 -4
  152. package/lib/treeUtils.js.map +1 -1
  153. package/lib/wholeSummaryDocumentStorageService.d.ts +2 -2
  154. package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  155. package/lib/wholeSummaryDocumentStorageService.js +23 -18
  156. package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
  157. package/lib/wholeSummaryUploadManager.js +1 -2
  158. package/lib/wholeSummaryUploadManager.js.map +1 -1
  159. package/package.json +26 -28
  160. package/src/contracts.ts +45 -1
  161. package/src/createNewUtils.ts +2 -2
  162. package/src/deltaStorageService.ts +8 -1
  163. package/src/documentService.ts +5 -5
  164. package/src/documentServiceFactory.ts +21 -11
  165. package/src/documentStorageService.ts +3 -3
  166. package/src/errorUtils.ts +48 -30
  167. package/src/gitManager.ts +3 -3
  168. package/src/historian.ts +5 -5
  169. package/src/index.ts +1 -1
  170. package/src/mapWithExpiration.ts +1 -1
  171. package/src/packageVersion.ts +1 -1
  172. package/src/policies.ts +7 -1
  173. package/src/r11sSnapshotParser.ts +14 -15
  174. package/src/restWrapper.ts +34 -21
  175. package/src/retriableGitManager.ts +3 -3
  176. package/src/shreddedSummaryDocumentStorageService.ts +3 -3
  177. package/src/storageContracts.ts +3 -3
  178. package/src/summaryTreeUploadManager.ts +2 -7
  179. package/src/treeUtils.ts +4 -3
  180. package/src/wholeSummaryDocumentStorageService.ts +14 -19
@@ -5,14 +5,14 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.DocumentPostCreateError = exports.RouterliciousDocumentServiceFactory = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
9
  const driver_base_1 = require("@fluidframework/driver-base");
10
10
  const driver_definitions_1 = require("@fluidframework/driver-definitions");
11
11
  const driver_utils_1 = require("@fluidframework/driver-utils");
12
12
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
13
+ const server_services_client_1 = require("@fluidframework/server-services-client");
13
14
  const documentService_1 = require("./documentService");
14
15
  const restWrapper_1 = require("./restWrapper");
15
- const createNewUtils_1 = require("./createNewUtils");
16
16
  const urlUtils_1 = require("./urlUtils");
17
17
  const cache_1 = require("./cache");
18
18
  const packageVersion_1 = require("./packageVersion");
@@ -27,6 +27,7 @@ const defaultRouterliciousDriverPolicies = {
27
27
  enableRestLess: true,
28
28
  enableInternalSummaryCaching: true,
29
29
  enableLongPollingDowngrade: true,
30
+ isEphemeralContainer: false,
30
31
  };
31
32
  /**
32
33
  * Factory for creating the routerlicious document service. Use this if you want to
@@ -39,7 +40,10 @@ class RouterliciousDocumentServiceFactory {
39
40
  this.shreddedSummaryTreeCache = new cache_1.NullCache();
40
41
  // Use the maximum allowed by the policy (IDocumentStorageServicePolicies.maximumCacheDurationMs set below)
41
42
  const snapshotCacheExpiryMs = maximumSnapshotCacheDurationMs;
42
- this.driverPolicies = Object.assign(Object.assign({}, defaultRouterliciousDriverPolicies), driverPolicies);
43
+ this.driverPolicies = {
44
+ ...defaultRouterliciousDriverPolicies,
45
+ ...driverPolicies,
46
+ };
43
47
  this.blobCache = new cache_1.InMemoryCache();
44
48
  if (this.driverPolicies.enableInternalSummaryCaching) {
45
49
  if (this.driverPolicies.enableWholeSummaryUpload) {
@@ -60,7 +64,7 @@ class RouterliciousDocumentServiceFactory {
60
64
  if (createNewSummary === undefined) {
61
65
  throw new Error("Empty file summary creation isn't supported in this driver.");
62
66
  }
63
- (0, common_utils_1.assert)(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* "Missing orderer URL!" */);
67
+ (0, core_utils_1.assert)(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* "Missing orderer URL!" */);
64
68
  let parsedUrl = (0, urlUtils_1.parseFluidUrl)(resolvedUrl.url);
65
69
  if (!parsedUrl.pathname) {
66
70
  throw new Error("Parsed url should contain tenant and doc Id!!");
@@ -73,7 +77,7 @@ class RouterliciousDocumentServiceFactory {
73
77
  const appSummary = createNewSummary.tree[".app"];
74
78
  const documentAttributes = (0, driver_utils_1.getDocAttributesFromProtocolSummary)(protocolSummary);
75
79
  const quorumValues = (0, driver_utils_1.getQuorumValuesFromProtocolSummary)(protocolSummary);
76
- const logger2 = telemetry_utils_1.ChildLogger.create(logger, "RouterliciousDriver");
80
+ const logger2 = (0, telemetry_utils_1.createChildLogger)({ logger, namespace: "RouterliciousDriver" });
77
81
  const ordererTokenFetcher = (0, restWrapper_1.toInstrumentedR11sOrdererTokenFetcher)(tenantId, undefined /* documentId */, this.tokenProvider, logger2);
78
82
  const rateLimiter = new driver_utils_1.RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
79
83
  const ordererRestWrapper = await restWrapper_1.RouterliciousOrdererRestWrapper.load(ordererTokenFetcher, logger2, rateLimiter, this.driverPolicies.enableRestLess, resolvedUrl.endpoints.ordererUrl);
@@ -82,15 +86,18 @@ class RouterliciousDocumentServiceFactory {
82
86
  details: JSON.stringify({
83
87
  enableDiscovery: this.driverPolicies.enableDiscovery,
84
88
  sequenceNumber: documentAttributes.sequenceNumber,
89
+ isEphemeralContainer: this.driverPolicies.isEphemeralContainer,
85
90
  }),
86
91
  }, async (event) => {
87
92
  // @TODO: Remove returned "string" type when removing back-compat code
88
93
  const postRes = (await ordererRestWrapper.post(`/documents/${tenantId}`, {
89
- summary: (0, createNewUtils_1.convertSummaryToCreateNewSummary)(appSummary),
94
+ summary: (0, server_services_client_1.convertSummaryTreeToWholeSummaryTree)(undefined, appSummary),
90
95
  sequenceNumber: documentAttributes.sequenceNumber,
91
96
  values: quorumValues,
92
97
  enableDiscovery: this.driverPolicies.enableDiscovery,
93
98
  generateToken: this.tokenProvider.documentPostCreateCallback !== undefined,
99
+ isEphemeralContainer: this.driverPolicies.isEphemeralContainer,
100
+ enableAnyBinaryBlobOnFirstSummary: true,
94
101
  })).content;
95
102
  event.end({
96
103
  docId: typeof postRes === "string" ? postRes : postRes.id,
@@ -134,7 +141,15 @@ class RouterliciousDocumentServiceFactory {
134
141
  }
135
142
  const parsedDeltaStorageUrl = new URL(deltaStorageUrl);
136
143
  parsedDeltaStorageUrl.pathname = (0, urlUtils_1.replaceDocumentIdInPath)(parsedDeltaStorageUrl.pathname, documentId);
137
- return this.createDocumentService(Object.assign(Object.assign({}, resolvedUrl), { url: parsedUrl.toString(), id: documentId, endpoints: Object.assign(Object.assign({}, resolvedUrl.endpoints), { deltaStorageUrl: parsedDeltaStorageUrl.toString() }) }), logger, clientIsSummarizer, session);
144
+ return this.createDocumentService({
145
+ ...resolvedUrl,
146
+ url: parsedUrl.toString(),
147
+ id: documentId,
148
+ endpoints: {
149
+ ...resolvedUrl.endpoints,
150
+ deltaStorageUrl: parsedDeltaStorageUrl.toString(),
151
+ },
152
+ }, logger, clientIsSummarizer, session);
138
153
  }
139
154
  /**
140
155
  * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}
@@ -147,8 +162,12 @@ class RouterliciousDocumentServiceFactory {
147
162
  if (!documentId || !tenantId) {
148
163
  throw new Error(`Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`);
149
164
  }
150
- const logger2 = telemetry_utils_1.ChildLogger.create(logger, "RouterliciousDriver", {
151
- all: { driverVersion: packageVersion_1.pkgVersion },
165
+ const logger2 = (0, telemetry_utils_1.createChildLogger)({
166
+ logger,
167
+ namespace: "RouterliciousDriver",
168
+ properties: {
169
+ all: { driverVersion: packageVersion_1.pkgVersion },
170
+ },
152
171
  });
153
172
  const ordererTokenFetcher = (0, restWrapper_1.toInstrumentedR11sOrdererTokenFetcher)(tenantId, documentId, this.tokenProvider, logger2);
154
173
  const storageTokenFetcher = (0, restWrapper_1.toInstrumentedR11sStorageTokenFetcher)(tenantId, documentId, this.tokenProvider, logger2);
@@ -166,7 +185,10 @@ class RouterliciousDocumentServiceFactory {
166
185
  }, async (event) => {
167
186
  // The service responds with the current document session associated with the container.
168
187
  const response = await ordererRestWrapper.get(`${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`);
169
- event.end(Object.assign(Object.assign({}, response.propsToLog), (0, driver_base_1.getW3CData)(response.requestUrl, "xmlhttprequest")));
188
+ event.end({
189
+ ...response.propsToLog,
190
+ ...(0, driver_base_1.getW3CData)(response.requestUrl, "xmlhttprequest"),
191
+ });
170
192
  return response.content;
171
193
  });
172
194
  return (0, urlUtils_1.getDiscoveredFluidResolvedUrl)(resolvedUrl, discoveredSession);
@@ -1 +1 @@
1
- {"version":3,"file":"documentServiceFactory.js","sourceRoot":"","sources":["../src/documentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAG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ved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport {\n\tFiveDaysMs,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\tLoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n\tRateLimiter,\n} from \"@fluidframework/driver-utils\";\nimport { ChildLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ISession } from \"@fluidframework/server-services-client\";\nimport { DocumentService } from \"./documentService\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ITokenProvider } from \"./tokens\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\ttoInstrumentedR11sOrdererTokenFetcher,\n\ttoInstrumentedR11sStorageTokenFetcher,\n} from \"./restWrapper\";\nimport { convertSummaryToCreateNewSummary } from \"./createNewUtils\";\nimport { parseFluidUrl, replaceDocumentIdInPath, getDiscoveredFluidResolvedUrl } from \"./urlUtils\";\nimport { ICache, InMemoryCache, NullCache } from \"./cache\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { INormalizedWholeSummary } from \"./contracts\";\n\nconst maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms\n\nconst defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {\n\tenablePrefetch: true,\n\tmaxConcurrentStorageRequests: 100,\n\tmaxConcurrentOrdererRequests: 100,\n\taggregateBlobsSmallerThanBytes: undefined,\n\tenableDiscovery: false,\n\tenableWholeSummaryUpload: false,\n\tenableRestLess: true,\n\tenableInternalSummaryCaching: true,\n\tenableLongPollingDowngrade: true,\n};\n\n/**\n * Factory for creating the routerlicious document service. Use this if you want to\n * use the routerlicious implementation.\n */\nexport class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {\n\tprivate readonly driverPolicies: IRouterliciousDriverPolicies;\n\tprivate readonly blobCache: ICache<ArrayBufferLike>;\n\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSummary> = new NullCache();\n\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion> = new NullCache();\n\n\tconstructor(\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tdriverPolicies: Partial<IRouterliciousDriverPolicies> = {},\n\t) {\n\t\t// Use the maximum allowed by the policy (IDocumentStorageServicePolicies.maximumCacheDurationMs set below)\n\t\tconst snapshotCacheExpiryMs: FiveDaysMs = maximumSnapshotCacheDurationMs;\n\n\t\tthis.driverPolicies = {\n\t\t\t...defaultRouterliciousDriverPolicies,\n\t\t\t...driverPolicies,\n\t\t};\n\t\tthis.blobCache = new InMemoryCache<ArrayBufferLike>();\n\t\tif (this.driverPolicies.enableInternalSummaryCaching) {\n\t\t\tif (this.driverPolicies.enableWholeSummaryUpload) {\n\t\t\t\tthis.wholeSnapshotTreeCache = new InMemoryCache<INormalizedWholeSummary>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.shreddedSummaryTreeCache = new InMemoryCache<ISnapshotTreeVersion>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}\n\t *\n\t * @throws {@link DocumentPostCreateError}\n\t * If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.\n\t */\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (createNewSummary === undefined) {\n\t\t\tthrow new Error(\"Empty file summary creation isn't supported in this driver.\");\n\t\t}\n\t\tassert(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* \"Missing orderer URL!\" */);\n\t\tlet parsedUrl = parseFluidUrl(resolvedUrl.url);\n\t\tif (!parsedUrl.pathname) {\n\t\t\tthrow new Error(\"Parsed url should contain tenant and doc Id!!\");\n\t\t}\n\t\tconst [, tenantId] = parsedUrl.pathname.split(\"/\");\n\n\t\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t\t}\n\t\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\t\tconst appSummary = createNewSummary.tree[\".app\"];\n\n\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\t\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\n\t\tconst logger2 = ChildLogger.create(logger, \"RouterliciousDriver\");\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tundefined /* documentId */,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tresolvedUrl.endpoints.ordererUrl,\n\t\t);\n\n\t\tconst res = await PerformanceEvent.timedExecAsync(\n\t\t\tlogger2,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t}),\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\t// @TODO: Remove returned \"string\" type when removing back-compat code\n\t\t\t\tconst postRes = (\n\t\t\t\t\tawait ordererRestWrapper.post<\n\t\t\t\t\t\t{ id: string; token?: string; session?: ISession } | string\n\t\t\t\t\t>(`/documents/${tenantId}`, {\n\t\t\t\t\t\tsummary: convertSummaryToCreateNewSummary(appSummary),\n\t\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t\t\tvalues: quorumValues,\n\t\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\t\tgenerateToken: this.tokenProvider.documentPostCreateCallback !== undefined,\n\t\t\t\t\t})\n\t\t\t\t).content;\n\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: typeof postRes === \"string\" ? postRes : postRes.id,\n\t\t\t\t});\n\t\t\t\treturn postRes;\n\t\t\t},\n\t\t);\n\n\t\t// For supporting backward compatibility, when the request has generateToken === true, it will return\n\t\t// an object instead of string\n\t\t// @TODO: Remove the logic when no need to support back-compat\n\n\t\tlet documentId: string;\n\t\tlet token: string | undefined;\n\t\tlet session: ISession | undefined;\n\t\tif (typeof res === \"string\") {\n\t\t\tdocumentId = res;\n\t\t} else {\n\t\t\tdocumentId = res.id;\n\t\t\ttoken = res.token;\n\t\t\tsession = this.driverPolicies.enableDiscovery ? res.session : undefined;\n\t\t}\n\t\tparsedUrl = parseFluidUrl(resolvedUrl.url);\n\n\t\t// @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined\n\t\t// is sufficient to determine if the token will be undefined or not.\n\t\ttry {\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DocPostCreateCallback\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\tif (token && this.tokenProvider.documentPostCreateCallback !== undefined) {\n\t\t\t\t\t\treturn this.tokenProvider.documentPostCreateCallback(documentId, token);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (error: any) {\n\t\t\tthrow new DocumentPostCreateError(error);\n\t\t}\n\n\t\tparsedUrl.set(\"pathname\", replaceDocumentIdInPath(parsedUrl.pathname, documentId));\n\t\tconst deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl;\n\t\tif (!deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\t\tconst parsedDeltaStorageUrl = new URL(deltaStorageUrl);\n\t\tparsedDeltaStorageUrl.pathname = replaceDocumentIdInPath(\n\t\t\tparsedDeltaStorageUrl.pathname,\n\t\t\tdocumentId,\n\t\t);\n\n\t\treturn this.createDocumentService(\n\t\t\t{\n\t\t\t\t...resolvedUrl,\n\t\t\t\turl: parsedUrl.toString(),\n\t\t\t\tid: documentId,\n\t\t\t\tendpoints: {\n\t\t\t\t\t...resolvedUrl.endpoints,\n\t\t\t\t\tdeltaStorageUrl: parsedDeltaStorageUrl.toString(),\n\t\t\t\t},\n\t\t\t},\n\t\t\tlogger,\n\t\t\tclientIsSummarizer,\n\t\t\tsession,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}\n\t *\n\t * @returns Routerlicious document service.\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t\tsession?: ISession,\n\t): Promise<IDocumentService> {\n\t\tconst parsedUrl = parseFluidUrl(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\t\tconst logger2 = ChildLogger.create(logger, \"RouterliciousDriver\", {\n\t\t\tall: { driverVersion },\n\t\t});\n\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst storageTokenFetcher = toInstrumentedR11sStorageTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst ordererTokenP = ordererTokenFetcher();\n\t\tconst storageTokenP = storageTokenFetcher();\n\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tundefined /* baseUrl */,\n\t\t\tordererTokenP,\n\t\t);\n\n\t\tconst discoverFluidResolvedUrl = async (): Promise<IResolvedUrl> => {\n\t\t\tif (!this.driverPolicies.enableDiscovery) {\n\t\t\t\treturn resolvedUrl;\n\t\t\t}\n\n\t\t\tconst discoveredSession = await PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DiscoverSession\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\t// The service responds with the current document session associated with the container.\n\t\t\t\t\tconst response = await ordererRestWrapper.get<ISession>(\n\t\t\t\t\t\t`${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`,\n\t\t\t\t\t);\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t\t});\n\t\t\t\t\treturn response.content;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);\n\t\t};\n\t\tconst fluidResolvedUrl: IResolvedUrl =\n\t\t\tsession !== undefined\n\t\t\t\t? getDiscoveredFluidResolvedUrl(resolvedUrl, session)\n\t\t\t\t: await discoverFluidResolvedUrl();\n\n\t\tconst storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tconst ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tconst deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tconst deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility\n\t\tif (!ordererUrl || !deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n\t\t\ttenantId,\n\t\t\tstorageTokenFetcher,\n\t\t\tlogger2,\n\t\t\tnew RateLimiter(this.driverPolicies.maxConcurrentStorageRequests),\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tstorageUrl,\n\t\t\tstorageTokenP,\n\t\t);\n\n\t\tconst documentStorageServicePolicies: IDocumentStorageServicePolicies = {\n\t\t\tcaching: this.driverPolicies.enablePrefetch\n\t\t\t\t? LoaderCachingPolicy.Prefetch\n\t\t\t\t: LoaderCachingPolicy.NoCaching,\n\t\t\tminBlobSize: this.driverPolicies.aggregateBlobsSmallerThanBytes,\n\t\t\tmaximumCacheDurationMs: maximumSnapshotCacheDurationMs,\n\t\t};\n\n\t\treturn new DocumentService(\n\t\t\tfluidResolvedUrl,\n\t\t\tordererUrl,\n\t\t\tdeltaStorageUrl,\n\t\t\tdeltaStreamUrl,\n\t\t\tstorageUrl,\n\t\t\tlogger2,\n\t\t\tthis.tokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tordererRestWrapper,\n\t\t\tdocumentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tdiscoverFluidResolvedUrl,\n\t\t\tstorageRestWrapper,\n\t\t\tstorageTokenFetcher,\n\t\t\tordererTokenFetcher,\n\t\t);\n\t}\n}\n\n/**\n * Error returned by {@link RouterliciousDocumentServiceFactory.createContainer} when an error is thrown\n * in {@link ITokenProvider.documentPostCreateCallback}.\n * It is the consumer's responsibility to ensure that any state related to container creation is appropriately\n * cleaned up in the event of failure.\n * This includes the document itself, which will have been created by the time this error was thrown.\n *\n * @remarks TODO: examples of suggested actions for recovery.\n * - How would a user delete the created document?\n * - What would a retry pattern look like here?\n */\nexport class DocumentPostCreateError extends Error {\n\tpublic constructor(\n\t\t/**\n\t\t * Inner error being wrapped.\n\t\t */\n\t\tprivate readonly innerError: Error,\n\t) {\n\t\tsuper(innerError.message);\n\t}\n\n\tpublic readonly name = \"DocumentPostCreateError\";\n\n\tpublic get stack() {\n\t\treturn this.innerError.stack;\n\t}\n}\n"]}
1
+ {"version":3,"file":"documentServiceFactory.js","sourceRoot":"","sources":["../src/documentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,6DAAyD;AACzD,2EAO4C;AAG5C,+DAKsC;AACtC,qEAAsF;AACtF,mFAGgD;AAChD,uDAAoD;AAGpD,+CAKuB;AACvB,yCAAmG;AACnG,mCAA2D;AAC3D,qDAA+D;AAI/D,MAAM,8BAA8B,GAAe,SAAW,CAAC,CAAC,eAAe;AAE/E,MAAM,kCAAkC,GAAiC;IACxE,cAAc,EAAE,IAAI;IACpB,4BAA4B,EAAE,GAAG;IACjC,4BAA4B,EAAE,GAAG;IACjC,8BAA8B,EAAE,SAAS;IACzC,eAAe,EAAE,KAAK;IACtB,wBAAwB,E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AQ,EACR,mBAAmB,EACnB,OAAO,EACP,IAAI,0BAAW,CAAC,IAAI,CAAC,cAAc,CAAC,4BAA4B,CAAC,EACjE,IAAI,CAAC,cAAc,CAAC,cAAc,EAClC,UAAU,EACV,aAAa,CACb,CAAC;QAEF,MAAM,8BAA8B,GAAoC;YACvE,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,cAAc;gBAC1C,CAAC,CAAC,wCAAmB,CAAC,QAAQ;gBAC9B,CAAC,CAAC,wCAAmB,CAAC,SAAS;YAChC,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,8BAA8B;YAC/D,sBAAsB,EAAE,8BAA8B;SACtD,CAAC;QAEF,OAAO,IAAI,iCAAe,CACzB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,OAAO,EACP,IAAI,CAAC,aAAa,EAClB,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,sBAAsB,EAC3B,IAAI,CAAC,wBAAwB,EAC7B,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,CACnB,CAAC;IACH,CAAC;CACD;AAlTD,kFAkTC;AAED;;;;;;;;;;GAUG;AACH,MAAa,uBAAwB,SAAQ,KAAK;IACjD;IACC;;OAEG;IACc,UAAiB;QAElC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAFT,eAAU,GAAV,UAAU,CAAO;QAKnB,SAAI,GAAG,yBAAyB,CAAC;IAFjD,CAAC;IAID,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IAC9B,CAAC;CACD;AAfD,0DAeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport {\n\tFiveDaysMs,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\tLoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n\tRateLimiter,\n} from \"@fluidframework/driver-utils\";\nimport { createChildLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tISession,\n\tconvertSummaryTreeToWholeSummaryTree,\n} from \"@fluidframework/server-services-client\";\nimport { DocumentService } from \"./documentService\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ITokenProvider } from \"./tokens\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\ttoInstrumentedR11sOrdererTokenFetcher,\n\ttoInstrumentedR11sStorageTokenFetcher,\n} from \"./restWrapper\";\nimport { parseFluidUrl, replaceDocumentIdInPath, getDiscoveredFluidResolvedUrl } from \"./urlUtils\";\nimport { ICache, InMemoryCache, NullCache } from \"./cache\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\nconst maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms\n\nconst defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {\n\tenablePrefetch: true,\n\tmaxConcurrentStorageRequests: 100,\n\tmaxConcurrentOrdererRequests: 100,\n\taggregateBlobsSmallerThanBytes: undefined,\n\tenableDiscovery: false,\n\tenableWholeSummaryUpload: false,\n\tenableRestLess: true,\n\tenableInternalSummaryCaching: true,\n\tenableLongPollingDowngrade: true,\n\tisEphemeralContainer: false,\n};\n\n/**\n * Factory for creating the routerlicious document service. Use this if you want to\n * use the routerlicious implementation.\n */\nexport class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {\n\tprivate readonly driverPolicies: IRouterliciousDriverPolicies;\n\tprivate readonly blobCache: ICache<ArrayBufferLike>;\n\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot> = new NullCache();\n\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion> = new NullCache();\n\n\tconstructor(\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tdriverPolicies: Partial<IRouterliciousDriverPolicies> = {},\n\t) {\n\t\t// Use the maximum allowed by the policy (IDocumentStorageServicePolicies.maximumCacheDurationMs set below)\n\t\tconst snapshotCacheExpiryMs: FiveDaysMs = maximumSnapshotCacheDurationMs;\n\n\t\tthis.driverPolicies = {\n\t\t\t...defaultRouterliciousDriverPolicies,\n\t\t\t...driverPolicies,\n\t\t};\n\t\tthis.blobCache = new InMemoryCache<ArrayBufferLike>();\n\t\tif (this.driverPolicies.enableInternalSummaryCaching) {\n\t\t\tif (this.driverPolicies.enableWholeSummaryUpload) {\n\t\t\t\tthis.wholeSnapshotTreeCache = new InMemoryCache<INormalizedWholeSnapshot>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.shreddedSummaryTreeCache = new InMemoryCache<ISnapshotTreeVersion>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}\n\t *\n\t * @throws {@link DocumentPostCreateError}\n\t * If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.\n\t */\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (createNewSummary === undefined) {\n\t\t\tthrow new Error(\"Empty file summary creation isn't supported in this driver.\");\n\t\t}\n\t\tassert(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* \"Missing orderer URL!\" */);\n\t\tlet parsedUrl = parseFluidUrl(resolvedUrl.url);\n\t\tif (!parsedUrl.pathname) {\n\t\t\tthrow new Error(\"Parsed url should contain tenant and doc Id!!\");\n\t\t}\n\t\tconst [, tenantId] = parsedUrl.pathname.split(\"/\");\n\n\t\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t\t}\n\t\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\t\tconst appSummary = createNewSummary.tree[\".app\"];\n\n\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\t\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\n\t\tconst logger2 = createChildLogger({ logger, namespace: \"RouterliciousDriver\" });\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tundefined /* documentId */,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tresolvedUrl.endpoints.ordererUrl,\n\t\t);\n\n\t\tconst res = await PerformanceEvent.timedExecAsync(\n\t\t\tlogger2,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t\tisEphemeralContainer: this.driverPolicies.isEphemeralContainer,\n\t\t\t\t}),\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\t// @TODO: Remove returned \"string\" type when removing back-compat code\n\t\t\t\tconst postRes = (\n\t\t\t\t\tawait ordererRestWrapper.post<\n\t\t\t\t\t\t{ id: string; token?: string; session?: ISession } | string\n\t\t\t\t\t>(`/documents/${tenantId}`, {\n\t\t\t\t\t\tsummary: convertSummaryTreeToWholeSummaryTree(undefined, appSummary),\n\t\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t\t\tvalues: quorumValues,\n\t\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\t\tgenerateToken: this.tokenProvider.documentPostCreateCallback !== undefined,\n\t\t\t\t\t\tisEphemeralContainer: this.driverPolicies.isEphemeralContainer,\n\t\t\t\t\t\tenableAnyBinaryBlobOnFirstSummary: true,\n\t\t\t\t\t})\n\t\t\t\t).content;\n\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: typeof postRes === \"string\" ? postRes : postRes.id,\n\t\t\t\t});\n\t\t\t\treturn postRes;\n\t\t\t},\n\t\t);\n\n\t\t// For supporting backward compatibility, when the request has generateToken === true, it will return\n\t\t// an object instead of string\n\t\t// @TODO: Remove the logic when no need to support back-compat\n\n\t\tlet documentId: string;\n\t\tlet token: string | undefined;\n\t\tlet session: ISession | undefined;\n\t\tif (typeof res === \"string\") {\n\t\t\tdocumentId = res;\n\t\t} else {\n\t\t\tdocumentId = res.id;\n\t\t\ttoken = res.token;\n\t\t\tsession = this.driverPolicies.enableDiscovery ? res.session : undefined;\n\t\t}\n\t\tparsedUrl = parseFluidUrl(resolvedUrl.url);\n\n\t\t// @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined\n\t\t// is sufficient to determine if the token will be undefined or not.\n\t\ttry {\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DocPostCreateCallback\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\tif (token && this.tokenProvider.documentPostCreateCallback !== undefined) {\n\t\t\t\t\t\treturn this.tokenProvider.documentPostCreateCallback(documentId, token);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (error: any) {\n\t\t\tthrow new DocumentPostCreateError(error);\n\t\t}\n\n\t\tparsedUrl.set(\"pathname\", replaceDocumentIdInPath(parsedUrl.pathname, documentId));\n\t\tconst deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl;\n\t\tif (!deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\t\tconst parsedDeltaStorageUrl = new URL(deltaStorageUrl);\n\t\tparsedDeltaStorageUrl.pathname = replaceDocumentIdInPath(\n\t\t\tparsedDeltaStorageUrl.pathname,\n\t\t\tdocumentId,\n\t\t);\n\n\t\treturn this.createDocumentService(\n\t\t\t{\n\t\t\t\t...resolvedUrl,\n\t\t\t\turl: parsedUrl.toString(),\n\t\t\t\tid: documentId,\n\t\t\t\tendpoints: {\n\t\t\t\t\t...resolvedUrl.endpoints,\n\t\t\t\t\tdeltaStorageUrl: parsedDeltaStorageUrl.toString(),\n\t\t\t\t},\n\t\t\t},\n\t\t\tlogger,\n\t\t\tclientIsSummarizer,\n\t\t\tsession,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}\n\t *\n\t * @returns Routerlicious document service.\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t\tsession?: ISession,\n\t): Promise<IDocumentService> {\n\t\tconst parsedUrl = parseFluidUrl(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\t\tconst logger2 = createChildLogger({\n\t\t\tlogger,\n\t\t\tnamespace: \"RouterliciousDriver\",\n\t\t\tproperties: {\n\t\t\t\tall: { driverVersion },\n\t\t\t},\n\t\t});\n\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst storageTokenFetcher = toInstrumentedR11sStorageTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst ordererTokenP = ordererTokenFetcher();\n\t\tconst storageTokenP = storageTokenFetcher();\n\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tundefined /* baseUrl */,\n\t\t\tordererTokenP,\n\t\t);\n\n\t\tconst discoverFluidResolvedUrl = async (): Promise<IResolvedUrl> => {\n\t\t\tif (!this.driverPolicies.enableDiscovery) {\n\t\t\t\treturn resolvedUrl;\n\t\t\t}\n\n\t\t\tconst discoveredSession = await PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DiscoverSession\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\t// The service responds with the current document session associated with the container.\n\t\t\t\t\tconst response = await ordererRestWrapper.get<ISession>(\n\t\t\t\t\t\t`${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`,\n\t\t\t\t\t);\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t\t});\n\t\t\t\t\treturn response.content;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);\n\t\t};\n\t\tconst fluidResolvedUrl: IResolvedUrl =\n\t\t\tsession !== undefined\n\t\t\t\t? getDiscoveredFluidResolvedUrl(resolvedUrl, session)\n\t\t\t\t: await discoverFluidResolvedUrl();\n\n\t\tconst storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tconst ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tconst deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tconst deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility\n\t\tif (!ordererUrl || !deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n\t\t\ttenantId,\n\t\t\tstorageTokenFetcher,\n\t\t\tlogger2,\n\t\t\tnew RateLimiter(this.driverPolicies.maxConcurrentStorageRequests),\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tstorageUrl,\n\t\t\tstorageTokenP,\n\t\t);\n\n\t\tconst documentStorageServicePolicies: IDocumentStorageServicePolicies = {\n\t\t\tcaching: this.driverPolicies.enablePrefetch\n\t\t\t\t? LoaderCachingPolicy.Prefetch\n\t\t\t\t: LoaderCachingPolicy.NoCaching,\n\t\t\tminBlobSize: this.driverPolicies.aggregateBlobsSmallerThanBytes,\n\t\t\tmaximumCacheDurationMs: maximumSnapshotCacheDurationMs,\n\t\t};\n\n\t\treturn new DocumentService(\n\t\t\tfluidResolvedUrl,\n\t\t\tordererUrl,\n\t\t\tdeltaStorageUrl,\n\t\t\tdeltaStreamUrl,\n\t\t\tstorageUrl,\n\t\t\tlogger2,\n\t\t\tthis.tokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tordererRestWrapper,\n\t\t\tdocumentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tdiscoverFluidResolvedUrl,\n\t\t\tstorageRestWrapper,\n\t\t\tstorageTokenFetcher,\n\t\t\tordererTokenFetcher,\n\t\t);\n\t}\n}\n\n/**\n * Error returned by {@link RouterliciousDocumentServiceFactory.createContainer} when an error is thrown\n * in {@link ITokenProvider.documentPostCreateCallback}.\n * It is the consumer's responsibility to ensure that any state related to container creation is appropriately\n * cleaned up in the event of failure.\n * This includes the document itself, which will have been created by the time this error was thrown.\n *\n * @remarks TODO: examples of suggested actions for recovery.\n * - How would a user delete the created document?\n * - What would a retry pattern look like here?\n */\nexport class DocumentPostCreateError extends Error {\n\tpublic constructor(\n\t\t/**\n\t\t * Inner error being wrapped.\n\t\t */\n\t\tprivate readonly innerError: Error,\n\t) {\n\t\tsuper(innerError.message);\n\t}\n\n\tpublic readonly name = \"DocumentPostCreateError\";\n\n\tpublic get stack() {\n\t\treturn this.innerError.stack;\n\t}\n}\n"]}
@@ -10,7 +10,7 @@ import { IRouterliciousDriverPolicies } from "./policies";
10
10
  import { ICache } from "./cache";
11
11
  import { GitManager } from "./gitManager";
12
12
  import { ISnapshotTreeVersion } from "./definitions";
13
- import { INormalizedWholeSummary } from "./contracts";
13
+ import { INormalizedWholeSnapshot } from "./contracts";
14
14
  export declare class DocumentStorageService extends DocumentStorageServiceProxy {
15
15
  readonly id: string;
16
16
  manager: GitManager;
@@ -18,7 +18,7 @@ export declare class DocumentStorageService extends DocumentStorageServiceProxy
18
18
  private _logTailSha;
19
19
  get logTailSha(): string | undefined;
20
20
  private static loadInternalDocumentStorageService;
21
- constructor(id: string, manager: GitManager, logger: ITelemetryLoggerExt, policies: IDocumentStorageServicePolicies, driverPolicies?: IRouterliciousDriverPolicies, blobCache?: ICache<ArrayBufferLike>, snapshotTreeCache?: ICache<INormalizedWholeSummary>, shreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>, noCacheGitManager?: GitManager | undefined, getStorageManager?: (disableCache?: boolean) => Promise<GitManager>);
21
+ constructor(id: string, manager: GitManager, logger: ITelemetryLoggerExt, policies: IDocumentStorageServicePolicies, driverPolicies?: IRouterliciousDriverPolicies, blobCache?: ICache<ArrayBufferLike>, snapshotTreeCache?: ICache<INormalizedWholeSnapshot>, shreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>, noCacheGitManager?: GitManager | undefined, getStorageManager?: (disableCache?: boolean) => Promise<GitManager>);
22
22
  getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
23
23
  }
24
24
  //# sourceMappingURL=documentStorageService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"documentStorageService.d.ts","sourceRoot":"","sources":["../src/documentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAEN,+BAA+B,EAE/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EACN,2BAA2B,EAE3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEt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AAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,qBAAa,sBAAuB,SAAQ,2BAA2B;aAoDrD,EAAE,EAAE,MAAM;IACnB,OAAO,EAAE,UAAU;IAOnB,iBAAiB,CAAC;IA3D1B,OAAO,CAAC,WAAW,CAAiC;IAEpD,IAAW,UAAU,IAAI,MAAM,GAAG,SAAS,CAE1C;IAED,OAAO,CAAC,MAAM,CAAC,kCAAkC;gBA6ChC,EAAE,EAAE,MAAM,EACnB,OAAO,EAAE,UAAU,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,+BAA+B,EACzC,cAAc,CAAC,EAAE,4BAA4B,EAC7C,SAAS,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,EACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC,wBAAwB,CAAC,EACpD,wBAAwB,CAAC,EAAE,MAAM,CAAC,oBAAoB,CAAC,EAChD,iBAAiB,CAAC,wBAAY,EACrC,iBAAiB,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,CAAC;IAkBvD,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;CAQ/E"}
@@ -21,11 +21,11 @@ class DocumentStorageService extends driver_utils_1.DocumentStorageServiceProxy
21
21
  return this._logTailSha;
22
22
  }
23
23
  static loadInternalDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, shreddedSummaryTreeCache, noCacheGitManager, getStorageManager) {
24
- const storageService = (driverPolicies === null || driverPolicies === void 0 ? void 0 : driverPolicies.enableWholeSummaryUpload)
24
+ const storageService = driverPolicies?.enableWholeSummaryUpload
25
25
  ? new wholeSummaryDocumentStorageService_1.WholeSummaryDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache, snapshotTreeCache, noCacheGitManager, getStorageManager)
26
26
  : new shreddedSummaryDocumentStorageService_1.ShreddedSummaryDocumentStorageService(id, manager, logger, policies, driverPolicies, blobCache, shreddedSummaryTreeCache, getStorageManager);
27
27
  // TODO: worth prefetching latest summary making version + snapshot call with WholeSummary storage?
28
- if (!(driverPolicies === null || driverPolicies === void 0 ? void 0 : driverPolicies.enableWholeSummaryUpload) &&
28
+ if (!driverPolicies?.enableWholeSummaryUpload &&
29
29
  policies.caching === driver_definitions_1.LoaderCachingPolicy.Prefetch) {
30
30
  return new driver_utils_1.PrefetchDocumentStorageService(storageService);
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"documentStorageService.js","sourceRoot":"","sources":["../src/documentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAI4C;AAE5C,+DAGsC;AAGtC,6FAA0F;AAC1F,mGAAgG;AAKhG,MAAa,sBAAuB,SAAQ,0CAA2B;IAmDtE,YACiB,EAAU,EACnB,OAAmB,EAC1B,MAA2B,EAC3B,QAAyC,EACzC,cAA6C,EAC7C,SAAmC,EACnC,iBAAmD,EACnD,wBAAuD,EAChD,iBAA8B,EACrC,iBAAmE;QAEnE,KAAK,CACJ,sBAAsB,CAAC,kCAAkC,CACxD,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,CACjB,CACD,CAAC;QAxBc,OAAE,GAAF,EAAE,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAY;QAOnB,sBAAiB,GAAjB,iBAAiB,CAAa;QA3D9B,gBAAW,GAAuB,SAAS,CAAC;IA4EpD,CAAC;IA1ED,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,kCAAkC,CAChD,EAAU,EACV,OAAmB,EACnB,MAA2B,EAC3B,QAAyC,EACzC,cAA6C,EAC7C,SAAmC,EACnC,iBAAmD,EACnD,wBAAuD,EACvD,iBAA8B,EAC9B,iBAAmE;QAEnE,MAAM,cAAc,GAAG,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,wBAAwB;YAC9D,CAAC,CAAC,IAAI,uEAAkC,CACtC,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,CAChB;YACH,CAAC,CAAC,IAAI,6EAAqC,CACzC,EAAE,EACF,OAAO,EACP,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,wBAAwB,EACxB,iBAAiB,CAChB,CAAC;QACL,mGAAmG;QACnG,IACC,CAAC,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,wBAAwB,CAAA;YACzC,QAAQ,CAAC,OAAO,KAAK,wCAAmB,CAAC,QAAQ,EAChD;YACD,OAAO,IAAI,6CAA8B,CAAC,cAAc,CAAC,CAAC;SAC1D;QACD,OAAO,cAAc,CAAC;IACvB,CAAC;IA8BM,KAAK,CAAC,eAAe,CAAC,OAAkB;QAC9C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACxE,IAAI,IAAI,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,WAAW;gBACf,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;SAC7E;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAvFD,wDAuFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tLoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree, IVersion } from \"@fluidframework/protocol-definitions\";\nimport {\n\tDocumentStorageServiceProxy,\n\tPrefetchDocumentStorageService,\n} from \"@fluidframework/driver-utils\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache } from \"./cache\";\nimport { WholeSummaryDocumentStorageService } from \"./wholeSummaryDocumentStorageService\";\nimport { ShreddedSummaryDocumentStorageService } from \"./shreddedSummaryDocumentStorageService\";\nimport { GitManager } from \"./gitManager\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { INormalizedWholeSummary } from \"./contracts\";\n\nexport class DocumentStorageService extends DocumentStorageServiceProxy {\n\tprivate _logTailSha: string | undefined = undefined;\n\n\tpublic get logTailSha(): string | undefined {\n\t\treturn this._logTailSha;\n\t}\n\n\tprivate static loadInternalDocumentStorageService(\n\t\tid: string,\n\t\tmanager: GitManager,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tpolicies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<INormalizedWholeSummary>,\n\t\tshreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tnoCacheGitManager?: GitManager,\n\t\tgetStorageManager?: (disableCache?: boolean) => Promise<GitManager>,\n\t): IDocumentStorageService {\n\t\tconst storageService = driverPolicies?.enableWholeSummaryUpload\n\t\t\t? new WholeSummaryDocumentStorageService(\n\t\t\t\t\tid,\n\t\t\t\t\tmanager,\n\t\t\t\t\tlogger,\n\t\t\t\t\tpolicies,\n\t\t\t\t\tdriverPolicies,\n\t\t\t\t\tblobCache,\n\t\t\t\t\tsnapshotTreeCache,\n\t\t\t\t\tnoCacheGitManager,\n\t\t\t\t\tgetStorageManager,\n\t\t\t )\n\t\t\t: new ShreddedSummaryDocumentStorageService(\n\t\t\t\t\tid,\n\t\t\t\t\tmanager,\n\t\t\t\t\tlogger,\n\t\t\t\t\tpolicies,\n\t\t\t\t\tdriverPolicies,\n\t\t\t\t\tblobCache,\n\t\t\t\t\tshreddedSummaryTreeCache,\n\t\t\t\t\tgetStorageManager,\n\t\t\t );\n\t\t// TODO: worth prefetching latest summary making version + snapshot call with WholeSummary storage?\n\t\tif (\n\t\t\t!driverPolicies?.enableWholeSummaryUpload &&\n\t\t\tpolicies.caching === LoaderCachingPolicy.Prefetch\n\t\t) {\n\t\t\treturn new PrefetchDocumentStorageService(storageService);\n\t\t}\n\t\treturn storageService;\n\t}\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic manager: GitManager,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tpolicies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<INormalizedWholeSummary>,\n\t\tshreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tpublic noCacheGitManager?: GitManager,\n\t\tgetStorageManager?: (disableCache?: boolean) => Promise<GitManager>,\n\t) {\n\t\tsuper(\n\t\t\tDocumentStorageService.loadInternalDocumentStorageService(\n\t\t\t\tid,\n\t\t\t\tmanager,\n\t\t\t\tlogger,\n\t\t\t\tpolicies,\n\t\t\t\tdriverPolicies,\n\t\t\t\tblobCache,\n\t\t\t\tsnapshotTreeCache,\n\t\t\t\tshreddedSummaryTreeCache,\n\t\t\t\tnoCacheGitManager,\n\t\t\t\tgetStorageManager,\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst tree = await this.internalStorageService.getSnapshotTree(version);\n\t\tif (tree !== null) {\n\t\t\tthis._logTailSha =\n\t\t\t\t\".logTail\" in tree.trees ? tree.trees[\".logTail\"].blobs.logTail : undefined;\n\t\t}\n\t\treturn tree;\n\t}\n}\n"]}
1
+ {"version":3,"file":"documentStorageService.js","sourceRoot":"","sources":["../src/documentStorageService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ACzC,QAAQ,CAAC,OAAO,KAAK,wCAAmB,CAAC,QAAQ,EAChD;YACD,OAAO,IAAI,6CAA8B,CAAC,cAAc,CAAC,CAAC;SAC1D;QACD,OAAO,cAAc,CAAC;IACvB,CAAC;IA8BM,KAAK,CAAC,eAAe,CAAC,OAAkB;QAC9C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACxE,IAAI,IAAI,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,WAAW;gBACf,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;SAC7E;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAvFD,wDAuFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tLoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree, IVersion } from \"@fluidframework/protocol-definitions\";\nimport {\n\tDocumentStorageServiceProxy,\n\tPrefetchDocumentStorageService,\n} from \"@fluidframework/driver-utils\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache } from \"./cache\";\nimport { WholeSummaryDocumentStorageService } from \"./wholeSummaryDocumentStorageService\";\nimport { ShreddedSummaryDocumentStorageService } from \"./shreddedSummaryDocumentStorageService\";\nimport { GitManager } from \"./gitManager\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\nexport class DocumentStorageService extends DocumentStorageServiceProxy {\n\tprivate _logTailSha: string | undefined = undefined;\n\n\tpublic get logTailSha(): string | undefined {\n\t\treturn this._logTailSha;\n\t}\n\n\tprivate static loadInternalDocumentStorageService(\n\t\tid: string,\n\t\tmanager: GitManager,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tpolicies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<INormalizedWholeSnapshot>,\n\t\tshreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tnoCacheGitManager?: GitManager,\n\t\tgetStorageManager?: (disableCache?: boolean) => Promise<GitManager>,\n\t): IDocumentStorageService {\n\t\tconst storageService = driverPolicies?.enableWholeSummaryUpload\n\t\t\t? new WholeSummaryDocumentStorageService(\n\t\t\t\t\tid,\n\t\t\t\t\tmanager,\n\t\t\t\t\tlogger,\n\t\t\t\t\tpolicies,\n\t\t\t\t\tdriverPolicies,\n\t\t\t\t\tblobCache,\n\t\t\t\t\tsnapshotTreeCache,\n\t\t\t\t\tnoCacheGitManager,\n\t\t\t\t\tgetStorageManager,\n\t\t\t )\n\t\t\t: new ShreddedSummaryDocumentStorageService(\n\t\t\t\t\tid,\n\t\t\t\t\tmanager,\n\t\t\t\t\tlogger,\n\t\t\t\t\tpolicies,\n\t\t\t\t\tdriverPolicies,\n\t\t\t\t\tblobCache,\n\t\t\t\t\tshreddedSummaryTreeCache,\n\t\t\t\t\tgetStorageManager,\n\t\t\t );\n\t\t// TODO: worth prefetching latest summary making version + snapshot call with WholeSummary storage?\n\t\tif (\n\t\t\t!driverPolicies?.enableWholeSummaryUpload &&\n\t\t\tpolicies.caching === LoaderCachingPolicy.Prefetch\n\t\t) {\n\t\t\treturn new PrefetchDocumentStorageService(storageService);\n\t\t}\n\t\treturn storageService;\n\t}\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic manager: GitManager,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tpolicies: IDocumentStorageServicePolicies,\n\t\tdriverPolicies?: IRouterliciousDriverPolicies,\n\t\tblobCache?: ICache<ArrayBufferLike>,\n\t\tsnapshotTreeCache?: ICache<INormalizedWholeSnapshot>,\n\t\tshreddedSummaryTreeCache?: ICache<ISnapshotTreeVersion>,\n\t\tpublic noCacheGitManager?: GitManager,\n\t\tgetStorageManager?: (disableCache?: boolean) => Promise<GitManager>,\n\t) {\n\t\tsuper(\n\t\t\tDocumentStorageService.loadInternalDocumentStorageService(\n\t\t\t\tid,\n\t\t\t\tmanager,\n\t\t\t\tlogger,\n\t\t\t\tpolicies,\n\t\t\t\tdriverPolicies,\n\t\t\t\tblobCache,\n\t\t\t\tsnapshotTreeCache,\n\t\t\t\tshreddedSummaryTreeCache,\n\t\t\t\tnoCacheGitManager,\n\t\t\t\tgetStorageManager,\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst tree = await this.internalStorageService.getSnapshotTree(version);\n\t\tif (tree !== null) {\n\t\t\tthis._logTailSha =\n\t\t\t\t\".logTail\" in tree.trees ? tree.trees[\".logTail\"].blobs.logTail : undefined;\n\t\t}\n\t\treturn tree;\n\t}\n}\n"]}
@@ -2,16 +2,50 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { DriverError } from "@fluidframework/driver-definitions";
5
+ import { DriverError, IDriverErrorBase } from "@fluidframework/driver-definitions";
6
+ import { IFluidErrorBase } from "@fluidframework/telemetry-utils";
6
7
  /**
7
8
  * Routerlicious Error types
8
9
  * Different error types that may be thrown by the routerlicious driver
9
10
  */
11
+ export declare const RouterliciousErrorTypes: {
12
+ /**
13
+ * SSL Certificate Error.
14
+ */
15
+ readonly sslCertError: "sslCertError";
16
+ readonly genericNetworkError: "genericNetworkError";
17
+ readonly authorizationError: "authorizationError";
18
+ readonly fileNotFoundOrAccessDeniedError: "fileNotFoundOrAccessDeniedError";
19
+ readonly offlineError: "offlineError";
20
+ readonly unsupportedClientProtocolVersion: "unsupportedClientProtocolVersion";
21
+ readonly writeError: "writeError";
22
+ readonly fetchFailure: "fetchFailure";
23
+ readonly fetchTokenError: "fetchTokenError";
24
+ readonly incorrectServerResponse: "incorrectServerResponse";
25
+ readonly fileOverwrittenInStorage: "fileOverwrittenInStorage";
26
+ readonly deltaStreamConnectionForbidden: "deltaStreamConnectionForbidden";
27
+ readonly locationRedirection: "locationRedirection";
28
+ readonly fluidInvalidSchema: "fluidInvalidSchema";
29
+ readonly fileIsLocked: "fileIsLocked";
30
+ readonly genericError: "genericError";
31
+ readonly throttlingError: "throttlingError";
32
+ readonly usageError: "usageError";
33
+ };
34
+ export declare type RouterliciousErrorTypes = typeof RouterliciousErrorTypes[keyof typeof RouterliciousErrorTypes];
35
+ /**
36
+ * Routerlicious Error types
37
+ * Different error types that may be thrown by the routerlicious driver
38
+ *
39
+ * @deprecated Use {@link (RouterliciousErrorTypes:variable)} instead.
40
+ */
10
41
  export declare enum RouterliciousErrorType {
11
42
  /**
12
43
  * File not found, or file deleted during session
13
44
  */
14
45
  fileNotFoundOrAccessDeniedError = "fileNotFoundOrAccessDeniedError",
46
+ /**
47
+ * SSL Certificate Error.
48
+ */
15
49
  sslCertError = "sslCertError"
16
50
  }
17
51
  /**
@@ -40,14 +74,12 @@ export interface IR11sSocketError {
40
74
  */
41
75
  retryAfterMs?: number;
42
76
  }
43
- export interface IR11sError {
77
+ export interface IR11sError extends Omit<IDriverErrorBase, "errorType"> {
44
78
  readonly errorType: RouterliciousErrorType;
45
- readonly message: string;
46
- canRetry: boolean;
47
79
  }
48
80
  export declare type R11sError = DriverError | IR11sError;
49
- export declare function createR11sNetworkError(errorMessage: string, statusCode?: number, retryAfterMs?: number): R11sError;
50
- export declare function throwR11sNetworkError(errorMessage: string, statusCode?: number, retryAfterMs?: number): never;
81
+ export declare function createR11sNetworkError(errorMessage: string, statusCode: number, retryAfterMs?: number): IFluidErrorBase & R11sError;
82
+ export declare function throwR11sNetworkError(errorMessage: string, statusCode: number, retryAfterMs?: number): never;
51
83
  /**
52
84
  * Returns network error based on error object from R11s socket (IR11sSocketError)
53
85
  */
@@ -1 +1 @@
1
- {"version":3,"file":"errorUtils.d.ts","sourceRoot":"","sources":["../src/errorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AASjE;;;GAGG;AACH,oBAAY,sBAAsB;IACjC;;OAEG;IACH,+BAA+B,oCAAoC;IAEnE,YAAY,iBAAiB;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,oBAAY,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AAEjD,wBAAgB,sBAAsB,CACrC,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,GACnB,SAAS,CAsCX;AAED,wBAAgB,qBAAqB,CACpC,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,GACnB,KAAK,CAKP;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,MAAM,GACb,SAAS,CAIX"}
1
+ {"version":3,"file":"errorUtils.d.ts","sourceRoot":"","sources":["../src/errorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EACX,gBAAgB,EAEhB,MAAM,oCAAoC,CAAC;AAO5C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE;;;GAGG;AACH,eAAO,MAAM,uBAAuB;IAInC;;OAEG;;;;;;;;;;;;;;;;;;;CAEM,CAAC;AACX,oBAAY,uBAAuB,GAClC,OAAO,uBAAuB,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAEtE;;;;;GAKG;AACH,oBAAY,sBAAsB;IACjC;;OAEG;IACH,+BAA+B,oCAAoC;IAEnE;;OAEG;IACH,YAAY,iBAAiB;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC;IACtE,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;CAC3C;AAED,oBAAY,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AAEjD,wBAAgB,sBAAsB,CACrC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,GACnB,eAAe,GAAG,SAAS,CAgC7B;AAED,wBAAgB,qBAAqB,CACpC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,GACnB,KAAK,CAKP;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,MAAM,GACb,SAAS,CAIX"}
@@ -4,51 +4,67 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.errorObjectFromSocketError = exports.throwR11sNetworkError = exports.createR11sNetworkError = exports.RouterliciousErrorType = void 0;
7
+ exports.errorObjectFromSocketError = exports.throwR11sNetworkError = exports.createR11sNetworkError = exports.RouterliciousErrorType = exports.RouterliciousErrorTypes = void 0;
8
+ const driver_definitions_1 = require("@fluidframework/driver-definitions");
8
9
  const driver_utils_1 = require("@fluidframework/driver-utils");
9
10
  const packageVersion_1 = require("./packageVersion");
10
11
  /**
11
12
  * Routerlicious Error types
12
13
  * Different error types that may be thrown by the routerlicious driver
13
14
  */
15
+ exports.RouterliciousErrorTypes = {
16
+ // Inherit base driver error types
17
+ ...driver_definitions_1.DriverErrorTypes,
18
+ /**
19
+ * SSL Certificate Error.
20
+ */
21
+ sslCertError: "sslCertError",
22
+ };
23
+ /**
24
+ * Routerlicious Error types
25
+ * Different error types that may be thrown by the routerlicious driver
26
+ *
27
+ * @deprecated Use {@link (RouterliciousErrorTypes:variable)} instead.
28
+ */
14
29
  var RouterliciousErrorType;
15
30
  (function (RouterliciousErrorType) {
16
31
  /**
17
32
  * File not found, or file deleted during session
18
33
  */
19
34
  RouterliciousErrorType["fileNotFoundOrAccessDeniedError"] = "fileNotFoundOrAccessDeniedError";
35
+ /**
36
+ * SSL Certificate Error.
37
+ */
20
38
  RouterliciousErrorType["sslCertError"] = "sslCertError";
21
39
  })(RouterliciousErrorType = exports.RouterliciousErrorType || (exports.RouterliciousErrorType = {}));
22
40
  function createR11sNetworkError(errorMessage, statusCode, retryAfterMs) {
41
+ let error;
23
42
  const props = { statusCode, driverVersion: packageVersion_1.pkgVersion };
24
43
  switch (statusCode) {
25
- case undefined:
26
- // If a service is temporarily down or a browser resource limit is reached, RestWrapper will throw
27
- // a network error with no status code (e.g. err:ERR_CONN_REFUSED or err:ERR_FAILED) and
28
- // the error message will start with NetworkError as defined in restWrapper.ts
29
- // If there exists a self-signed SSL certificates error, throw a NonRetryableError
30
- // TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections
31
- if (errorMessage.includes("failed, reason: self signed certificate")) {
32
- return new driver_utils_1.NonRetryableError(errorMessage, RouterliciousErrorType.sslCertError, props);
33
- }
34
- return new driver_utils_1.GenericNetworkError(errorMessage, errorMessage.startsWith("NetworkError"), props);
35
44
  case 401:
36
45
  // The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,
37
46
  // so we treat repeat 401s the same as 403.
38
47
  case 403:
39
- return new driver_utils_1.AuthorizationError(errorMessage, undefined, undefined, props);
48
+ error = new driver_utils_1.AuthorizationError(errorMessage, undefined, undefined, props);
49
+ break;
40
50
  case 404:
41
51
  const errorType = RouterliciousErrorType.fileNotFoundOrAccessDeniedError;
42
- return new driver_utils_1.NonRetryableError(errorMessage, errorType, props);
52
+ error = new driver_utils_1.NonRetryableError(errorMessage, errorType, props);
53
+ break;
43
54
  case 429:
44
- return (0, driver_utils_1.createGenericNetworkError)(errorMessage, { canRetry: true, retryAfterMs }, props);
55
+ error = (0, driver_utils_1.createGenericNetworkError)(errorMessage, { canRetry: true, retryAfterMs }, props);
56
+ break;
45
57
  case 500:
46
58
  case 502:
47
- return new driver_utils_1.GenericNetworkError(errorMessage, true, props);
59
+ error = new driver_utils_1.GenericNetworkError(errorMessage, true, props);
60
+ break;
48
61
  default:
49
62
  const retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };
50
- return (0, driver_utils_1.createGenericNetworkError)(errorMessage, retryInfo, props);
63
+ error = (0, driver_utils_1.createGenericNetworkError)(errorMessage, retryInfo, props);
64
+ break;
51
65
  }
66
+ error.addTelemetryProperties({ endpointReached: true });
67
+ return error;
52
68
  }
53
69
  exports.createR11sNetworkError = createR11sNetworkError;
54
70
  function throwR11sNetworkError(errorMessage, statusCode, retryAfterMs) {
@@ -1 +1 @@
1
- {"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../src/errorUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAKsC;AACtC,qDAA+D;AAE/D;;;GAGG;AACH,IAAY,sBAOX;AAPD,WAAY,sBA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Y,KAAK,SAAS,EAAE,YAAY,EAAE,CAAC;YACzE,OAAO,IAAA,wCAAyB,EAAC,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;KAClE;AACF,CAAC;AA1CD,wDA0CC;AAED,SAAgB,qBAAqB,CACpC,YAAoB,EACpB,UAAmB,EACnB,YAAqB;IAErB,MAAM,YAAY,GAAG,sBAAsB,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAEpF,+DAA+D;IAC/D,MAAM,YAAY,CAAC;AACpB,CAAC;AATD,sDASC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CACzC,WAA6B,EAC7B,OAAe;IAEf,iDAAiD;IACjD,MAAM,OAAO,GAAG,sBAAsB,OAAO,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IACzE,OAAO,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;AACpF,CAAC;AAPD,gEAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DriverError } from \"@fluidframework/driver-definitions\";\nimport {\n\tNonRetryableError,\n\tGenericNetworkError,\n\tcreateGenericNetworkError,\n\tAuthorizationError,\n} from \"@fluidframework/driver-utils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * Routerlicious Error types\n * Different error types that may be thrown by the routerlicious driver\n */\nexport enum RouterliciousErrorType {\n\t/**\n\t * File not found, or file deleted during session\n\t */\n\tfileNotFoundOrAccessDeniedError = \"fileNotFoundOrAccessDeniedError\",\n\n\tsslCertError = \"sslCertError\",\n}\n\n/**\n * Interface for error responses for the WebSocket connection\n * Intended to be compatible with output from {@link NetworkError.toJSON}\n */\nexport interface IR11sSocketError {\n\t/**\n\t * An error code number for the error that occurred.\n\t * It will be a valid HTTP status code.\n\t */\n\tcode: number;\n\n\t/**\n\t * A message about the error that occurred for debugging / logging purposes.\n\t * This should not be displayed to the user directly.\n\t */\n\tmessage: string;\n\n\t/**\n\t * Optional Retry-After time in seconds.\n\t * The client should wait this many seconds before retrying its request.\n\t */\n\tretryAfter?: number;\n\n\t/**\n\t * Optional Retry-After time in milliseconds.\n\t * The client should wait this many milliseconds before retrying its request.\n\t */\n\tretryAfterMs?: number;\n}\n\nexport interface IR11sError {\n\treadonly errorType: RouterliciousErrorType;\n\treadonly message: string;\n\tcanRetry: boolean;\n}\n\nexport type R11sError = DriverError | IR11sError;\n\nexport function createR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode?: number,\n\tretryAfterMs?: number,\n): R11sError {\n\tconst props = { statusCode, driverVersion };\n\tswitch (statusCode) {\n\t\tcase undefined:\n\t\t\t// If a service is temporarily down or a browser resource limit is reached, RestWrapper will throw\n\t\t\t// a network error with no status code (e.g. err:ERR_CONN_REFUSED or err:ERR_FAILED) and\n\t\t\t// the error message will start with NetworkError as defined in restWrapper.ts\n\t\t\t// If there exists a self-signed SSL certificates error, throw a NonRetryableError\n\t\t\t// TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections\n\t\t\tif (errorMessage.includes(\"failed, reason: self signed certificate\")) {\n\t\t\t\treturn new NonRetryableError(\n\t\t\t\t\terrorMessage,\n\t\t\t\t\tRouterliciousErrorType.sslCertError,\n\t\t\t\t\tprops,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn new GenericNetworkError(\n\t\t\t\terrorMessage,\n\t\t\t\terrorMessage.startsWith(\"NetworkError\"),\n\t\t\t\tprops,\n\t\t\t);\n\t\tcase 401:\n\t\t// The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,\n\t\t// so we treat repeat 401s the same as 403.\n\t\tcase 403:\n\t\t\treturn new AuthorizationError(errorMessage, undefined, undefined, props);\n\t\tcase 404:\n\t\t\tconst errorType = RouterliciousErrorType.fileNotFoundOrAccessDeniedError;\n\t\t\treturn new NonRetryableError(errorMessage, errorType, props);\n\t\tcase 429:\n\t\t\treturn createGenericNetworkError(errorMessage, { canRetry: true, retryAfterMs }, props);\n\t\tcase 500:\n\t\tcase 502:\n\t\t\treturn new GenericNetworkError(errorMessage, true, props);\n\t\tdefault:\n\t\t\tconst retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };\n\t\t\treturn createGenericNetworkError(errorMessage, retryInfo, props);\n\t}\n}\n\nexport function throwR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode?: number,\n\tretryAfterMs?: number,\n): never {\n\tconst networkError = createR11sNetworkError(errorMessage, statusCode, retryAfterMs);\n\n\t// eslint-disable-next-line @typescript-eslint/no-throw-literal\n\tthrow networkError;\n}\n\n/**\n * Returns network error based on error object from R11s socket (IR11sSocketError)\n */\nexport function errorObjectFromSocketError(\n\tsocketError: IR11sSocketError,\n\thandler: string,\n): R11sError {\n\t// pre-0.58 error message prefix: R11sSocketError\n\tconst message = `R11s socket error (${handler}): ${socketError.message}`;\n\treturn createR11sNetworkError(message, socketError.code, socketError.retryAfterMs);\n}\n"]}
1
+ {"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../src/errorUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2EAI4C;AAC5C,+DAKsC;AAEtC,qDAA+D;AAE/D;;;GAGG;AACU,QAAA,uBAAuB,GAAG;IACtC,kCAAkC;IAClC,GAAG,qCAAgB;IAEnB;;OAEG;IACH,YAAY,EAAE,cAAc;CACnB,CAAC;AAIX;;;;;GAKG;AACH,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IACjC;;OAEG;IACH,6FAAmE,CAAA;IAEnE;;OAEG;IACH,uDAA6B,CAAA;AAC9B,CAAC,EAVW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAUjC;AAsCD,SAAgB,sBAAsB,CACrC,YAAoB,EACpB,UAAkB,EAClB,YAAqB;IAErB,IAAI,KAAkC,CAAC;IACvC,MAAM,KAAK,GAAG,EAAE,UAAU,EAAE,aAAa,EAAb,2BAAa,EAAE,CAAC;IA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AAM,OAAO,GAAG,sBAAsB,OAAO,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IACzE,OAAO,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;AACpF,CAAC;AAPD,gEAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tDriverError,\n\tIDriverErrorBase,\n\tDriverErrorTypes,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tNonRetryableError,\n\tGenericNetworkError,\n\tcreateGenericNetworkError,\n\tAuthorizationError,\n} from \"@fluidframework/driver-utils\";\nimport { IFluidErrorBase } from \"@fluidframework/telemetry-utils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n/**\n * Routerlicious Error types\n * Different error types that may be thrown by the routerlicious driver\n */\nexport const RouterliciousErrorTypes = {\n\t// Inherit base driver error types\n\t...DriverErrorTypes,\n\n\t/**\n\t * SSL Certificate Error.\n\t */\n\tsslCertError: \"sslCertError\",\n} as const;\nexport type RouterliciousErrorTypes =\n\ttypeof RouterliciousErrorTypes[keyof typeof RouterliciousErrorTypes];\n\n/**\n * Routerlicious Error types\n * Different error types that may be thrown by the routerlicious driver\n *\n * @deprecated Use {@link (RouterliciousErrorTypes:variable)} instead.\n */\nexport enum RouterliciousErrorType {\n\t/**\n\t * File not found, or file deleted during session\n\t */\n\tfileNotFoundOrAccessDeniedError = \"fileNotFoundOrAccessDeniedError\",\n\n\t/**\n\t * SSL Certificate Error.\n\t */\n\tsslCertError = \"sslCertError\",\n}\n\n/**\n * Interface for error responses for the WebSocket connection\n * Intended to be compatible with output from {@link NetworkError.toJSON}\n */\nexport interface IR11sSocketError {\n\t/**\n\t * An error code number for the error that occurred.\n\t * It will be a valid HTTP status code.\n\t */\n\tcode: number;\n\n\t/**\n\t * A message about the error that occurred for debugging / logging purposes.\n\t * This should not be displayed to the user directly.\n\t */\n\tmessage: string;\n\n\t/**\n\t * Optional Retry-After time in seconds.\n\t * The client should wait this many seconds before retrying its request.\n\t */\n\tretryAfter?: number;\n\n\t/**\n\t * Optional Retry-After time in milliseconds.\n\t * The client should wait this many milliseconds before retrying its request.\n\t */\n\tretryAfterMs?: number;\n}\n\nexport interface IR11sError extends Omit<IDriverErrorBase, \"errorType\"> {\n\treadonly errorType: RouterliciousErrorType;\n}\n\nexport type R11sError = DriverError | IR11sError;\n\nexport function createR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode: number,\n\tretryAfterMs?: number,\n): IFluidErrorBase & R11sError {\n\tlet error: IFluidErrorBase & R11sError;\n\tconst props = { statusCode, driverVersion };\n\tswitch (statusCode) {\n\t\tcase 401:\n\t\t// The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,\n\t\t// so we treat repeat 401s the same as 403.\n\t\tcase 403:\n\t\t\terror = new AuthorizationError(errorMessage, undefined, undefined, props);\n\t\t\tbreak;\n\t\tcase 404:\n\t\t\tconst errorType = RouterliciousErrorType.fileNotFoundOrAccessDeniedError;\n\t\t\terror = new NonRetryableError(errorMessage, errorType, props);\n\t\t\tbreak;\n\t\tcase 429:\n\t\t\terror = createGenericNetworkError(\n\t\t\t\terrorMessage,\n\t\t\t\t{ canRetry: true, retryAfterMs },\n\t\t\t\tprops,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 500:\n\t\tcase 502:\n\t\t\terror = new GenericNetworkError(errorMessage, true, props);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tconst retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };\n\t\t\terror = createGenericNetworkError(errorMessage, retryInfo, props);\n\t\t\tbreak;\n\t}\n\terror.addTelemetryProperties({ endpointReached: true });\n\treturn error;\n}\n\nexport function throwR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode: number,\n\tretryAfterMs?: number,\n): never {\n\tconst networkError = createR11sNetworkError(errorMessage, statusCode, retryAfterMs);\n\n\t// eslint-disable-next-line @typescript-eslint/no-throw-literal\n\tthrow networkError;\n}\n\n/**\n * Returns network error based on error object from R11s socket (IR11sSocketError)\n */\nexport function errorObjectFromSocketError(\n\tsocketError: IR11sSocketError,\n\thandler: string,\n): R11sError {\n\t// pre-0.58 error message prefix: R11sSocketError\n\tconst message = `R11s socket error (${handler}): ${socketError.message}`;\n\treturn createR11sNetworkError(message, socketError.code, socketError.retryAfterMs);\n}\n"]}
@@ -3,9 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import * as resources from "@fluidframework/gitresources";
6
- import { IWholeFlatSummary, IWholeSummaryPayload, IWriteSummaryResponse } from "@fluidframework/server-services-client";
6
+ import { IWholeSummaryPayload, IWriteSummaryResponse } from "@fluidframework/server-services-client";
7
7
  import { IGitManager, IHistorian } from "./storageContracts";
8
8
  import { IR11sResponse } from "./restWrapper";
9
+ import { IWholeFlatSnapshot } from "./contracts";
9
10
  export declare class GitManager implements IGitManager {
10
11
  private readonly historian;
11
12
  private readonly blobCache;
@@ -25,6 +26,6 @@ export declare class GitManager implements IGitManager {
25
26
  createBlob(content: string, encoding: "utf-8" | "base64"): Promise<IR11sResponse<resources.ICreateBlobResponse>>;
26
27
  createGitTree(params: resources.ICreateTreeParams): Promise<IR11sResponse<resources.ITree>>;
27
28
  createSummary(summary: IWholeSummaryPayload, initial?: boolean): Promise<IR11sResponse<IWriteSummaryResponse>>;
28
- getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>>;
29
+ getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>>;
29
30
  }
30
31
  //# sourceMappingURL=gitManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gitManager.d.ts","sourceRoot":"","sources":["../src/gitManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,SAAS,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EACN,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,wCAAwC,CAAC;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AC,CAAC;IAK7B,aAAa,CACzB,OAAO,EAAE,oBAAoB,EAC7B,OAAO,GAAE,OAAe,GACtB,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAInC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;CAGjF"}
@@ -81,8 +81,8 @@ class GitManager {
81
81
  async createSummary(summary, initial = false) {
82
82
  return this.historian.createSummary(summary, initial);
83
83
  }
84
- async getSummary(sha) {
85
- return this.historian.getSummary(sha);
84
+ async getSnapshot(sha) {
85
+ return this.historian.getSnapshot(sha);
86
86
  }
87
87
  }
88
88
  exports.GitManager = GitManager;
@@ -1 +1 @@
1
- {"version":3,"file":"gitManager.js","sourceRoot":"","sources":["../src/gitManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,+CAA6E;AAE7E,MAAa,UAAU;IAMtB,YAA6B,SAAqB;QAArB,cAAS,GAAT,SAAS,CAAY;QALjC,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC/C,gBAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;QACnD,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC/C,aAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAED,CAAC;IAEtD;;OAEG;IACI,KAAK,CAAC,UAAU,CACtB,QAAgB,EAChB,KAAa;QAEb,IAAI,GAAG,GAAuB,QAAQ,CAAC;QAEvC,6CAA6C;QAC7C,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAChC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAElC,kCAAkC;YAClC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAE/B,kFAAkF;YAClF,IAAI,CAAC,GAAG,EAAE;gBACT,OAAO,IAAA,2CAA6B,EAAC,EAAE,CAA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,CAAC,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,UAAU,CACtB,OAAe,EACf,QAA4B;QAE5B,MAAM,IAAI,GAAgC;YACzC,OAAO;YACP,QAAQ;SACR,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,MAAmC;QAEnC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChD,OAAO,KAAK,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,OAA6B,EAC7B,UAAmB,KAAK;QAExB,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,GAAW;QAClC,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;CACD;AArGD,gCAqGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as resources from \"@fluidframework/gitresources\";\nimport {\n\tIWholeFlatSummary,\n\tIWholeSummaryPayload,\n\tIWriteSummaryResponse,\n} from \"@fluidframework/server-services-client\";\nimport { IGitManager, IHistorian } from \"./storageContracts\";\nimport { IR11sResponse, createR11sResponseFromContent } from \"./restWrapper\";\n\nexport class GitManager implements IGitManager {\n\tprivate readonly blobCache = new Map<string, resources.IBlob>();\n\tprivate readonly commitCache = new Map<string, resources.ICommit>();\n\tprivate readonly treeCache = new Map<string, resources.ITree>();\n\tprivate readonly refCache = new Map<string, string>();\n\n\tconstructor(private readonly historian: IHistorian) {}\n\n\t/**\n\t * Reads the object with the given ID. We defer to the client implementation to do the actual read.\n\t */\n\tpublic async getCommits(\n\t\tshaOrRef: string,\n\t\tcount: number,\n\t): Promise<IR11sResponse<resources.ICommitDetails[]>> {\n\t\tlet sha: string | undefined = shaOrRef;\n\n\t\t// See if the sha is really a ref and convert\n\t\tif (this.refCache.has(shaOrRef)) {\n\t\t\tsha = this.refCache.get(shaOrRef);\n\n\t\t\t// Delete refcache after first use\n\t\t\tthis.refCache.delete(shaOrRef);\n\n\t\t\t// If null is stored for the ref then there are no commits - return an empty array\n\t\t\tif (!sha) {\n\t\t\t\treturn createR11sResponseFromContent([]);\n\t\t\t}\n\t\t}\n\n\t\t// See if the commit sha is hashed and return it if so\n\t\tconst commit = this.commitCache.get(sha);\n\t\tif (commit !== undefined) {\n\t\t\treturn createR11sResponseFromContent([\n\t\t\t\t{\n\t\t\t\t\tcommit: {\n\t\t\t\t\t\tauthor: commit.author,\n\t\t\t\t\t\tcommitter: commit.committer,\n\t\t\t\t\t\tmessage: commit.message,\n\t\t\t\t\t\ttree: commit.tree,\n\t\t\t\t\t\turl: commit.url,\n\t\t\t\t\t},\n\t\t\t\t\tparents: commit.parents,\n\t\t\t\t\tsha: commit.sha,\n\t\t\t\t\turl: commit.url,\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\t// Otherwise fall back to the historian\n\t\treturn this.historian.getCommits(sha, count);\n\t}\n\n\t/**\n\t * Reads the object with the given ID. We defer to the client implementation to do the actual read.\n\t */\n\tpublic async getTree(root: string, recursive = true): Promise<IR11sResponse<resources.ITree>> {\n\t\tconst tree = this.treeCache.get(root);\n\t\tif (tree !== undefined) {\n\t\t\treturn createR11sResponseFromContent(tree);\n\t\t}\n\n\t\treturn this.historian.getTree(root, recursive);\n\t}\n\n\tpublic async getBlob(sha: string): Promise<IR11sResponse<resources.IBlob>> {\n\t\tconst blob = this.blobCache.get(sha);\n\t\tif (blob !== undefined) {\n\t\t\treturn createR11sResponseFromContent(blob);\n\t\t}\n\t\treturn this.historian.getBlob(sha);\n\t}\n\n\tpublic async createBlob(\n\t\tcontent: string,\n\t\tencoding: \"utf-8\" | \"base64\",\n\t): Promise<IR11sResponse<resources.ICreateBlobResponse>> {\n\t\tconst blob: resources.ICreateBlobParams = {\n\t\t\tcontent,\n\t\t\tencoding,\n\t\t};\n\t\treturn this.historian.createBlob(blob);\n\t}\n\n\tpublic async createGitTree(\n\t\tparams: resources.ICreateTreeParams,\n\t): Promise<IR11sResponse<resources.ITree>> {\n\t\tconst treeP = this.historian.createTree(params);\n\t\treturn treeP;\n\t}\n\n\tpublic async createSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial: boolean = false,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>> {\n\t\treturn this.historian.createSummary(summary, initial);\n\t}\n\n\tpublic async getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>> {\n\t\treturn this.historian.getSummary(sha);\n\t}\n}\n"]}
1
+ {"version":3,"file":"gitManager.js","sourceRoot":"","sources":["../src/gitManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,+CAA6E;AAG7E,MAAa,UAAU;IAMtB,YAA6B,SAAqB;QAArB,cAAS,GAAT,SAAS,CAAY;QALjC,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC/C,gBAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;QACnD,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC/C,aAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAED,CAAC;IAEtD;;OAEG;IACI,KAAK,CAAC,UAAU,CACtB,QAAgB,EAChB,KAAa;QAEb,IAAI,GAAG,GAAuB,QAAQ,CAAC;QAEvC,6CAA6C;QAC7C,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAChC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAElC,kCAAkC;YAClC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAE/B,kFAAkF;YAClF,IAAI,CAAC,GAAG,EAAE;gBACT,OAAO,IAAA,2CAA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C,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,UAAU,CACtB,OAAe,EACf,QAA4B;QAE5B,MAAM,IAAI,GAAgC;YACzC,OAAO;YACP,QAAQ;SACR,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,MAAmC;QAEnC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChD,OAAO,KAAK,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,aAAa,CACzB,OAA6B,EAC7B,UAAmB,KAAK;QAExB,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,GAAW;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACD;AArGD,gCAqGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as resources from \"@fluidframework/gitresources\";\nimport {\n\tIWholeSummaryPayload,\n\tIWriteSummaryResponse,\n} from \"@fluidframework/server-services-client\";\nimport { IGitManager, IHistorian } from \"./storageContracts\";\nimport { IR11sResponse, createR11sResponseFromContent } from \"./restWrapper\";\nimport { IWholeFlatSnapshot } from \"./contracts\";\n\nexport class GitManager implements IGitManager {\n\tprivate readonly blobCache = new Map<string, resources.IBlob>();\n\tprivate readonly commitCache = new Map<string, resources.ICommit>();\n\tprivate readonly treeCache = new Map<string, resources.ITree>();\n\tprivate readonly refCache = new Map<string, string>();\n\n\tconstructor(private readonly historian: IHistorian) {}\n\n\t/**\n\t * Reads the object with the given ID. We defer to the client implementation to do the actual read.\n\t */\n\tpublic async getCommits(\n\t\tshaOrRef: string,\n\t\tcount: number,\n\t): Promise<IR11sResponse<resources.ICommitDetails[]>> {\n\t\tlet sha: string | undefined = shaOrRef;\n\n\t\t// See if the sha is really a ref and convert\n\t\tif (this.refCache.has(shaOrRef)) {\n\t\t\tsha = this.refCache.get(shaOrRef);\n\n\t\t\t// Delete refcache after first use\n\t\t\tthis.refCache.delete(shaOrRef);\n\n\t\t\t// If null is stored for the ref then there are no commits - return an empty array\n\t\t\tif (!sha) {\n\t\t\t\treturn createR11sResponseFromContent([]);\n\t\t\t}\n\t\t}\n\n\t\t// See if the commit sha is hashed and return it if so\n\t\tconst commit = this.commitCache.get(sha);\n\t\tif (commit !== undefined) {\n\t\t\treturn createR11sResponseFromContent([\n\t\t\t\t{\n\t\t\t\t\tcommit: {\n\t\t\t\t\t\tauthor: commit.author,\n\t\t\t\t\t\tcommitter: commit.committer,\n\t\t\t\t\t\tmessage: commit.message,\n\t\t\t\t\t\ttree: commit.tree,\n\t\t\t\t\t\turl: commit.url,\n\t\t\t\t\t},\n\t\t\t\t\tparents: commit.parents,\n\t\t\t\t\tsha: commit.sha,\n\t\t\t\t\turl: commit.url,\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\t// Otherwise fall back to the historian\n\t\treturn this.historian.getCommits(sha, count);\n\t}\n\n\t/**\n\t * Reads the object with the given ID. We defer to the client implementation to do the actual read.\n\t */\n\tpublic async getTree(root: string, recursive = true): Promise<IR11sResponse<resources.ITree>> {\n\t\tconst tree = this.treeCache.get(root);\n\t\tif (tree !== undefined) {\n\t\t\treturn createR11sResponseFromContent(tree);\n\t\t}\n\n\t\treturn this.historian.getTree(root, recursive);\n\t}\n\n\tpublic async getBlob(sha: string): Promise<IR11sResponse<resources.IBlob>> {\n\t\tconst blob = this.blobCache.get(sha);\n\t\tif (blob !== undefined) {\n\t\t\treturn createR11sResponseFromContent(blob);\n\t\t}\n\t\treturn this.historian.getBlob(sha);\n\t}\n\n\tpublic async createBlob(\n\t\tcontent: string,\n\t\tencoding: \"utf-8\" | \"base64\",\n\t): Promise<IR11sResponse<resources.ICreateBlobResponse>> {\n\t\tconst blob: resources.ICreateBlobParams = {\n\t\t\tcontent,\n\t\t\tencoding,\n\t\t};\n\t\treturn this.historian.createBlob(blob);\n\t}\n\n\tpublic async createGitTree(\n\t\tparams: resources.ICreateTreeParams,\n\t): Promise<IR11sResponse<resources.ITree>> {\n\t\tconst treeP = this.historian.createTree(params);\n\t\treturn treeP;\n\t}\n\n\tpublic async createSummary(\n\t\tsummary: IWholeSummaryPayload,\n\t\tinitial: boolean = false,\n\t): Promise<IR11sResponse<IWriteSummaryResponse>> {\n\t\treturn this.historian.createSummary(summary, initial);\n\t}\n\n\tpublic async getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>> {\n\t\treturn this.historian.getSnapshot(sha);\n\t}\n}\n"]}
@@ -3,10 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import * as git from "@fluidframework/gitresources";
6
- import { IWholeFlatSummary, IWholeSummaryPayload, IWriteSummaryResponse } from "@fluidframework/server-services-client";
6
+ import { IWholeSummaryPayload, IWriteSummaryResponse } from "@fluidframework/server-services-client";
7
7
  import { RestWrapper } from "./restWrapperBase";
8
8
  import { IR11sResponse } from "./restWrapper";
9
9
  import { IHistorian } from "./storageContracts";
10
+ import { IWholeFlatSnapshot } from "./contracts";
10
11
  export interface ICredentials {
11
12
  user: string;
12
13
  password: string;
@@ -27,7 +28,7 @@ export declare class Historian implements IHistorian {
27
28
  createTree(tree: git.ICreateTreeParams): Promise<IR11sResponse<git.ITree>>;
28
29
  getTree(sha: string, recursive: boolean): Promise<IR11sResponse<git.ITree>>;
29
30
  createSummary(summary: IWholeSummaryPayload, initial?: boolean): Promise<IR11sResponse<IWriteSummaryResponse>>;
30
- getSummary(sha: string): Promise<IR11sResponse<IWholeFlatSummary>>;
31
+ getSnapshot(sha: string): Promise<IR11sResponse<IWholeFlatSnapshot>>;
31
32
  private getQueryString;
32
33
  }
33
34
  //# sourceMappingURL=histor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