@fluidframework/odsp-driver 1.3.0 → 2.0.0-dev.1.4.5.105745

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 (252) hide show
  1. package/.mocharc.js +12 -0
  2. package/README.md +19 -0
  3. package/dist/ReadBufferUtils.d.ts.map +1 -1
  4. package/dist/ReadBufferUtils.js +1 -0
  5. package/dist/ReadBufferUtils.js.map +1 -1
  6. package/dist/WriteBufferUtils.d.ts +3 -5
  7. package/dist/WriteBufferUtils.d.ts.map +1 -1
  8. package/dist/WriteBufferUtils.js +59 -55
  9. package/dist/WriteBufferUtils.js.map +1 -1
  10. package/dist/compactSnapshotParser.d.ts +2 -2
  11. package/dist/compactSnapshotParser.d.ts.map +1 -1
  12. package/dist/compactSnapshotParser.js +93 -33
  13. package/dist/compactSnapshotParser.js.map +1 -1
  14. package/dist/compactSnapshotWriter.d.ts +1 -2
  15. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  16. package/dist/compactSnapshotWriter.js +22 -16
  17. package/dist/compactSnapshotWriter.js.map +1 -1
  18. package/dist/contracts.d.ts +1 -18
  19. package/dist/contracts.d.ts.map +1 -1
  20. package/dist/contracts.js.map +1 -1
  21. package/dist/createFile.d.ts +1 -1
  22. package/dist/createFile.d.ts.map +1 -1
  23. package/dist/createFile.js +53 -16
  24. package/dist/createFile.js.map +1 -1
  25. package/dist/createNewUtils.d.ts.map +1 -1
  26. package/dist/createNewUtils.js +0 -1
  27. package/dist/createNewUtils.js.map +1 -1
  28. package/dist/createOdspCreateContainerRequest.d.ts +4 -3
  29. package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
  30. package/dist/createOdspCreateContainerRequest.js +6 -3
  31. package/dist/createOdspCreateContainerRequest.js.map +1 -1
  32. package/dist/epochTracker.d.ts +1 -0
  33. package/dist/epochTracker.d.ts.map +1 -1
  34. package/dist/epochTracker.js +24 -5
  35. package/dist/epochTracker.js.map +1 -1
  36. package/dist/fetchSnapshot.d.ts.map +1 -1
  37. package/dist/fetchSnapshot.js +14 -19
  38. package/dist/fetchSnapshot.js.map +1 -1
  39. package/dist/getFileLink.d.ts +3 -6
  40. package/dist/getFileLink.d.ts.map +1 -1
  41. package/dist/getFileLink.js +11 -14
  42. package/dist/getFileLink.js.map +1 -1
  43. package/dist/index.d.ts +1 -2
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +3 -3
  46. package/dist/index.js.map +1 -1
  47. package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
  48. package/dist/localOdspDriver/localOdspDocumentStorageManager.js +1 -2
  49. package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
  50. package/dist/odspDeltaStorageService.d.ts +1 -1
  51. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  52. package/dist/odspDeltaStorageService.js +4 -8
  53. package/dist/odspDeltaStorageService.js.map +1 -1
  54. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  55. package/dist/odspDocumentDeltaConnection.js +3 -6
  56. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  57. package/dist/odspDocumentService.d.ts +1 -0
  58. package/dist/odspDocumentService.d.ts.map +1 -1
  59. package/dist/odspDocumentService.js +10 -5
  60. package/dist/odspDocumentService.js.map +1 -1
  61. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  62. package/dist/odspDocumentServiceFactoryCore.js +29 -6
  63. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  64. package/dist/odspDocumentStorageManager.d.ts +4 -3
  65. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  66. package/dist/odspDocumentStorageManager.js +73 -64
  67. package/dist/odspDocumentStorageManager.js.map +1 -1
  68. package/dist/odspDocumentStorageServiceBase.d.ts +1 -1
  69. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  70. package/dist/odspDocumentStorageServiceBase.js +4 -2
  71. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  72. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  73. package/dist/odspDriverUrlResolverForShareLink.js +4 -4
  74. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  75. package/dist/odspFluidFileLink.js +1 -1
  76. package/dist/odspFluidFileLink.js.map +1 -1
  77. package/dist/odspLocationRedirection.d.ts +14 -0
  78. package/dist/odspLocationRedirection.d.ts.map +1 -0
  79. package/dist/odspLocationRedirection.js +24 -0
  80. package/dist/odspLocationRedirection.js.map +1 -0
  81. package/dist/odspSnapshotParser.d.ts.map +1 -1
  82. package/dist/odspSnapshotParser.js +1 -2
  83. package/dist/odspSnapshotParser.js.map +1 -1
  84. package/dist/odspSummaryUploadManager.d.ts +6 -3
  85. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  86. package/dist/odspSummaryUploadManager.js +18 -16
  87. package/dist/odspSummaryUploadManager.js.map +1 -1
  88. package/dist/odspUrlHelper.js +2 -1
  89. package/dist/odspUrlHelper.js.map +1 -1
  90. package/dist/odspUtils.d.ts +11 -2
  91. package/dist/odspUtils.d.ts.map +1 -1
  92. package/dist/odspUtils.js +32 -5
  93. package/dist/odspUtils.js.map +1 -1
  94. package/dist/opsCaching.d.ts.map +1 -1
  95. package/dist/opsCaching.js +3 -2
  96. package/dist/opsCaching.js.map +1 -1
  97. package/dist/packageVersion.d.ts +1 -1
  98. package/dist/packageVersion.d.ts.map +1 -1
  99. package/dist/packageVersion.js +1 -1
  100. package/dist/packageVersion.js.map +1 -1
  101. package/dist/prefetchLatestSnapshot.d.ts +6 -4
  102. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  103. package/dist/prefetchLatestSnapshot.js +6 -4
  104. package/dist/prefetchLatestSnapshot.js.map +1 -1
  105. package/dist/retryUtils.d.ts.map +1 -1
  106. package/dist/retryUtils.js +8 -4
  107. package/dist/retryUtils.js.map +1 -1
  108. package/dist/zipItDataRepresentationUtils.d.ts +30 -18
  109. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  110. package/dist/zipItDataRepresentationUtils.js +170 -76
  111. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  112. package/lib/ReadBufferUtils.d.ts.map +1 -1
  113. package/lib/ReadBufferUtils.js +1 -0
  114. package/lib/ReadBufferUtils.js.map +1 -1
  115. package/lib/WriteBufferUtils.d.ts +3 -5
  116. package/lib/WriteBufferUtils.d.ts.map +1 -1
  117. package/lib/WriteBufferUtils.js +61 -57
  118. package/lib/WriteBufferUtils.js.map +1 -1
  119. package/lib/compactSnapshotParser.d.ts +2 -2
  120. package/lib/compactSnapshotParser.d.ts.map +1 -1
  121. package/lib/compactSnapshotParser.js +94 -34
  122. package/lib/compactSnapshotParser.js.map +1 -1
  123. package/lib/compactSnapshotWriter.d.ts +1 -2
  124. package/lib/compactSnapshotWriter.d.ts.map +1 -1
  125. package/lib/compactSnapshotWriter.js +23 -17
  126. package/lib/compactSnapshotWriter.js.map +1 -1
  127. package/lib/contracts.d.ts +1 -18
  128. package/lib/contracts.d.ts.map +1 -1
  129. package/lib/contracts.js.map +1 -1
  130. package/lib/createFile.d.ts +1 -1
  131. package/lib/createFile.d.ts.map +1 -1
  132. package/lib/createFile.js +54 -17
  133. package/lib/createFile.js.map +1 -1
  134. package/lib/createNewUtils.d.ts.map +1 -1
  135. package/lib/createNewUtils.js +0 -1
  136. package/lib/createNewUtils.js.map +1 -1
  137. package/lib/createOdspCreateContainerRequest.d.ts +4 -3
  138. package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
  139. package/lib/createOdspCreateContainerRequest.js +6 -3
  140. package/lib/createOdspCreateContainerRequest.js.map +1 -1
  141. package/lib/epochTracker.d.ts +1 -0
  142. package/lib/epochTracker.d.ts.map +1 -1
  143. package/lib/epochTracker.js +26 -7
  144. package/lib/epochTracker.js.map +1 -1
  145. package/lib/fetchSnapshot.d.ts.map +1 -1
  146. package/lib/fetchSnapshot.js +14 -19
  147. package/lib/fetchSnapshot.js.map +1 -1
  148. package/lib/getFileLink.d.ts +3 -6
  149. package/lib/getFileLink.d.ts.map +1 -1
  150. package/lib/getFileLink.js +11 -14
  151. package/lib/getFileLink.js.map +1 -1
  152. package/lib/index.d.ts +1 -2
  153. package/lib/index.d.ts.map +1 -1
  154. package/lib/index.js +1 -3
  155. package/lib/index.js.map +1 -1
  156. package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -1
  157. package/lib/localOdspDriver/localOdspDocumentStorageManager.js +1 -2
  158. package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -1
  159. package/lib/odspDeltaStorageService.d.ts +1 -1
  160. package/lib/odspDeltaStorageService.d.ts.map +1 -1
  161. package/lib/odspDeltaStorageService.js +4 -8
  162. package/lib/odspDeltaStorageService.js.map +1 -1
  163. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  164. package/lib/odspDocumentDeltaConnection.js +3 -6
  165. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  166. package/lib/odspDocumentService.d.ts +1 -0
  167. package/lib/odspDocumentService.d.ts.map +1 -1
  168. package/lib/odspDocumentService.js +11 -6
  169. package/lib/odspDocumentService.js.map +1 -1
  170. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  171. package/lib/odspDocumentServiceFactoryCore.js +29 -6
  172. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  173. package/lib/odspDocumentStorageManager.d.ts +4 -3
  174. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  175. package/lib/odspDocumentStorageManager.js +74 -65
  176. package/lib/odspDocumentStorageManager.js.map +1 -1
  177. package/lib/odspDocumentStorageServiceBase.d.ts +1 -1
  178. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
  179. package/lib/odspDocumentStorageServiceBase.js +4 -2
  180. package/lib/odspDocumentStorageServiceBase.js.map +1 -1
  181. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  182. package/lib/odspDriverUrlResolverForShareLink.js +4 -4
  183. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  184. package/lib/odspFluidFileLink.js +1 -1
  185. package/lib/odspFluidFileLink.js.map +1 -1
  186. package/lib/odspLocationRedirection.d.ts +14 -0
  187. package/lib/odspLocationRedirection.d.ts.map +1 -0
  188. package/lib/odspLocationRedirection.js +20 -0
  189. package/lib/odspLocationRedirection.js.map +1 -0
  190. package/lib/odspSnapshotParser.d.ts.map +1 -1
  191. package/lib/odspSnapshotParser.js +1 -2
  192. package/lib/odspSnapshotParser.js.map +1 -1
  193. package/lib/odspSummaryUploadManager.d.ts +6 -3
  194. package/lib/odspSummaryUploadManager.d.ts.map +1 -1
  195. package/lib/odspSummaryUploadManager.js +18 -16
  196. package/lib/odspSummaryUploadManager.js.map +1 -1
  197. package/lib/odspUrlHelper.js +2 -1
  198. package/lib/odspUrlHelper.js.map +1 -1
  199. package/lib/odspUtils.d.ts +11 -2
  200. package/lib/odspUtils.d.ts.map +1 -1
  201. package/lib/odspUtils.js +31 -5
  202. package/lib/odspUtils.js.map +1 -1
  203. package/lib/opsCaching.d.ts.map +1 -1
  204. package/lib/opsCaching.js +3 -2
  205. package/lib/opsCaching.js.map +1 -1
  206. package/lib/packageVersion.d.ts +1 -1
  207. package/lib/packageVersion.d.ts.map +1 -1
  208. package/lib/packageVersion.js +1 -1
  209. package/lib/packageVersion.js.map +1 -1
  210. package/lib/prefetchLatestSnapshot.d.ts +6 -4
  211. package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
  212. package/lib/prefetchLatestSnapshot.js +6 -4
  213. package/lib/prefetchLatestSnapshot.js.map +1 -1
  214. package/lib/retryUtils.d.ts.map +1 -1
  215. package/lib/retryUtils.js +9 -5
  216. package/lib/retryUtils.js.map +1 -1
  217. package/lib/zipItDataRepresentationUtils.d.ts +30 -18
  218. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  219. package/lib/zipItDataRepresentationUtils.js +166 -75
  220. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  221. package/package.json +33 -20
  222. package/src/ReadBufferUtils.ts +1 -0
  223. package/src/WriteBufferUtils.ts +67 -58
  224. package/src/compactSnapshotParser.ts +103 -39
  225. package/src/compactSnapshotWriter.ts +30 -19
  226. package/src/contracts.ts +2 -14
  227. package/src/createFile.ts +75 -15
  228. package/src/createNewUtils.ts +2 -4
  229. package/src/createOdspCreateContainerRequest.ts +7 -4
  230. package/src/epochTracker.ts +47 -7
  231. package/src/fetchSnapshot.ts +19 -19
  232. package/src/getFileLink.ts +12 -22
  233. package/src/index.ts +1 -3
  234. package/src/localOdspDriver/localOdspDocumentStorageManager.ts +2 -2
  235. package/src/odspDeltaStorageService.ts +4 -7
  236. package/src/odspDocumentDeltaConnection.ts +3 -5
  237. package/src/odspDocumentService.ts +13 -11
  238. package/src/odspDocumentServiceFactoryCore.ts +40 -4
  239. package/src/odspDocumentStorageManager.ts +55 -45
  240. package/src/odspDocumentStorageServiceBase.ts +4 -2
  241. package/src/odspDriverUrlResolverForShareLink.ts +2 -5
  242. package/src/odspFluidFileLink.ts +1 -1
  243. package/src/odspLocationRedirection.ts +23 -0
  244. package/src/odspSnapshotParser.ts +3 -4
  245. package/src/odspSummaryUploadManager.ts +14 -10
  246. package/src/odspUrlHelper.ts +1 -1
  247. package/src/odspUtils.ts +40 -7
  248. package/src/opsCaching.ts +3 -2
  249. package/src/packageVersion.ts +1 -1
  250. package/src/prefetchLatestSnapshot.ts +6 -4
  251. package/src/retryUtils.ts +8 -5
  252. package/src/zipItDataRepresentationUtils.ts +198 -75
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
6
- import { IOdspUrlParts, OdspResourceTokenFetchOptions, IdentityType, TokenFetcher } from "@fluidframework/odsp-driver-definitions";
6
+ import { IOdspUrlParts, OdspResourceTokenFetchOptions, TokenFetcher } from "@fluidframework/odsp-driver-definitions";
7
7
  /**
8
8
  * Returns file link for a file with given drive and item ids.
9
9
  * Scope needed: files.readwrite.all.
@@ -11,12 +11,9 @@ import { IOdspUrlParts, OdspResourceTokenFetchOptions, IdentityType, TokenFetche
11
11
  * throttling error. In future, we are thinking of app allowing to pass some cancel token, with which
12
12
  * we would be able to stop retrying.
13
13
  * @param getToken - used to fetch access tokens needed to execute operation
14
- * @param siteUrl - url of the site that contains the file
15
- * @param driveId - drive where file is stored
16
- * @param itemId - file id
17
- * @param identityType - type of client account
14
+ * @param odspUrlParts - object describing file storage identity
18
15
  * @param logger - used to log results of operation, including any error
19
16
  * @returns Promise which resolves to file link url when successful; otherwise, undefined.
20
17
  */
21
- export declare function getFileLink(getToken: TokenFetcher<OdspResourceTokenFetchOptions>, odspUrlParts: IOdspUrlParts, identityType: IdentityType, logger: ITelemetryLogger): Promise<string>;
18
+ export declare function getFileLink(getToken: TokenFetcher<OdspResourceTokenFetchOptions>, odspUrlParts: IOdspUrlParts, logger: ITelemetryLogger): Promise<string>;
22
19
  //# sourceMappingURL=getFileLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getFileLink.d.ts","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAKtE,OAAO,EACH,aAAa,EACb,6BAA6B,EAC7B,YAAY,EACZ,YAAY,EACf,MAAM,yCAAyC,CAAC;AASjD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAC7B,QAAQ,EAAE,YAAY,CAAC,6BAA6B,CAAC,EACrD,YAAY,EAAE,aAAa,EAC3B,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,MAAM,CAAC,CAgCjB"}
1
+ {"version":3,"file":"getFileLink.d.ts","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAKtE,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AASrH;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAC7B,QAAQ,EAAE,YAAY,CAAC,6BAA6B,CAAC,EACrD,YAAY,EAAE,aAAa,EAC3B,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,MAAM,CAAC,CAgCjB"}
@@ -22,14 +22,11 @@ const fileLinkCache = new Map();
22
22
  * throttling error. In future, we are thinking of app allowing to pass some cancel token, with which
23
23
  * we would be able to stop retrying.
24
24
  * @param getToken - used to fetch access tokens needed to execute operation
25
- * @param siteUrl - url of the site that contains the file
26
- * @param driveId - drive where file is stored
27
- * @param itemId - file id
28
- * @param identityType - type of client account
25
+ * @param odspUrlParts - object describing file storage identity
29
26
  * @param logger - used to log results of operation, including any error
30
27
  * @returns Promise which resolves to file link url when successful; otherwise, undefined.
31
28
  */
32
- async function getFileLink(getToken, odspUrlParts, identityType, logger) {
29
+ async function getFileLink(getToken, odspUrlParts, logger) {
33
30
  const cacheKey = `${odspUrlParts.siteUrl}_${odspUrlParts.driveId}_${odspUrlParts.itemId}`;
34
31
  const maybeFileLinkCacheEntry = fileLinkCache.get(cacheKey);
35
32
  if (maybeFileLinkCacheEntry !== undefined) {
@@ -38,7 +35,7 @@ async function getFileLink(getToken, odspUrlParts, identityType, logger) {
38
35
  const fileLinkGenerator = async function () {
39
36
  let fileLinkCore;
40
37
  try {
41
- fileLinkCore = await (0, retryUtils_1.runWithRetry)(async () => getFileLinkCore(getToken, odspUrlParts, identityType, logger), "getFileLinkCore", logger);
38
+ fileLinkCore = await (0, retryUtils_1.runWithRetry)(async () => getFileLinkCore(getToken, odspUrlParts, logger), "getFileLinkCore", logger);
42
39
  }
43
40
  catch (err) {
44
41
  // runWithRetry throws a non retriable error after it hits the max # of attempts
@@ -58,10 +55,10 @@ async function getFileLink(getToken, odspUrlParts, identityType, logger) {
58
55
  return fileLink;
59
56
  }
60
57
  exports.getFileLink = getFileLink;
61
- async function getFileLinkCore(getToken, odspUrlParts, identityType, logger) {
62
- const fileItem = await getFileItemLite(getToken, odspUrlParts, logger, identityType === "Consumer");
58
+ async function getFileLinkCore(getToken, odspUrlParts, logger) {
59
+ const fileItem = await getFileItemLite(getToken, odspUrlParts, logger, true);
63
60
  // ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder
64
- return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "odspFileLink", requestName: "getSharingLink" }, async (event) => {
61
+ return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "odspFileLink", requestName: "getSharingInformation" }, async (event) => {
65
62
  let attempts = 0;
66
63
  let additionalProps;
67
64
  const fileLink = await (0, odspUtils_1.getWithRetryForTokenRefresh)(async (options) => {
@@ -70,7 +67,7 @@ async function getFileLinkCore(getToken, odspUrlParts, identityType, logger) {
70
67
  const storageTokenFetcher = (0, odspUtils_1.toInstrumentedOdspTokenFetcher)(logger, odspUrlParts, getToken, true /* throwOnNullToken */);
71
68
  const storageToken = await storageTokenFetcher(options, "GetFileLinkCore");
72
69
  (0, common_utils_1.assert)(storageToken !== null, 0x2bb /* "Instrumented token fetcher with throwOnNullToken = true should never return null" */);
73
- const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(`${odspUrlParts.siteUrl}/_api/web/GetFileByServerRelativeUrl(@a1)/Linkingurl?@a1=${encodeURIComponent(`'${new URL(fileItem.webDavUrl).pathname}'`)}`, storageToken, false);
70
+ const { url, headers } = (0, getUrlAndHeadersWithAuth_1.getUrlAndHeadersWithAuth)(`${odspUrlParts.siteUrl}/_api/web/GetFileByUrl(@a1)/ListItemAllFields/GetSharingInformation?@a1=${encodeURIComponent(`'${fileItem.webDavUrl}'`)}`, storageToken, true);
74
71
  const requestInit = {
75
72
  method: "POST",
76
73
  headers: Object.assign({ "Content-Type": "application/json;odata=verbose", "Accept": "application/json;odata=verbose" }, headers),
@@ -78,12 +75,12 @@ async function getFileLinkCore(getToken, odspUrlParts, identityType, logger) {
78
75
  const response = await (0, odspUtils_1.fetchHelper)(url, requestInit);
79
76
  additionalProps = response.propsToLog;
80
77
  const sharingInfo = await response.content.json();
81
- const linkingUrl = (_a = sharingInfo === null || sharingInfo === void 0 ? void 0 : sharingInfo.d) === null || _a === void 0 ? void 0 : _a.LinkingUrl;
82
- if (typeof linkingUrl !== "string") {
78
+ const directUrl = (_a = sharingInfo === null || sharingInfo === void 0 ? void 0 : sharingInfo.d) === null || _a === void 0 ? void 0 : _a.directUrl;
79
+ if (typeof directUrl !== "string") {
83
80
  // This will retry once in getWithRetryForTokenRefresh
84
- throw new driver_utils_1.NonRetryableError("Malformed GetSharingLink response", driver_definitions_1.DriverErrorType.incorrectServerResponse, { driverVersion: packageVersion_1.pkgVersion });
81
+ throw new driver_utils_1.NonRetryableError("Malformed GetSharingInformation response", driver_definitions_1.DriverErrorType.incorrectServerResponse, { driverVersion: packageVersion_1.pkgVersion });
85
82
  }
86
- return linkingUrl;
83
+ return directUrl;
87
84
  });
88
85
  event.end(Object.assign(Object.assign({}, additionalProps), { attempts }));
89
86
  return fileLink;
@@ -1 +1 @@
1
- {"version":3,"file":"getFileLink.js","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAsD;AACtD,+DAAkF;AAClF,qEAAmE;AACnE,2EAAqE;AAOrE,yEAAsE;AACtE,2CAAuG;AACvG,qDAA+D;AAC/D,6CAA4C;AAE5C,2GAA2G;AAC3G,MAAM,aAAa,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,WAAW,CAC7B,QAAqD,EACrD,YAA2B,EAC3B,YAA0B,EAC1B,MAAwB;IAExB,MAAM,QAAQ,GAAG,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;IAC1F,MAAM,uBAAuB,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ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qB,OAAO,UAAU,MAAM,0BAA0B,EAChF,YAAY,EACZ,sCAAsC,CACzC,CAAC;YACF,MAAM,WAAW,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;YAC/C,MAAM,QAAQ,GAAG,MAAM,IAAA,uBAAW,EAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YACrD,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC;YAEtC,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACnD,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE;gBAC/B,sDAAsD;gBACtD,MAAM,IAAI,gCAAiB,CACvB,oCAAoC,EACpC,oCAAe,CAAC,uBAAuB,EACvC,EAAE,aAAa,EAAb,2BAAa,EAAE,CAAC,CAAC;aAC1B;YACD,OAAO,YAAY,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,GAAG,iCAAM,eAAe,KAAE,QAAQ,IAAG,CAAC;QAC5C,OAAO,QAAQ,CAAC;IACpB,CAAC,CACJ,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { canRetryOnError, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n IOdspUrlParts,\n OdspResourceTokenFetchOptions,\n IdentityType,\n TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { fetchHelper, getWithRetryForTokenRefresh, toInstrumentedOdspTokenFetcher } from \"./odspUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { runWithRetry } from \"./retryUtils\";\n\n// Store cached responses for the lifetime of web session as file link remains the same for given file item\nconst fileLinkCache = new Map<string, Promise<string>>();\n\n/**\n * Returns file link for a file with given drive and item ids.\n * Scope needed: files.readwrite.all.\n * This function keeps retrying if it gets a retriable error or wait for some delay if it gets a\n * throttling error. In future, we are thinking of app allowing to pass some cancel token, with which\n * we would be able to stop retrying.\n * @param getToken - used to fetch access tokens needed to execute operation\n * @param siteUrl - url of the site that contains the file\n * @param driveId - drive where file is stored\n * @param itemId - file id\n * @param identityType - type of client account\n * @param logger - used to log results of operation, including any error\n * @returns Promise which resolves to file link url when successful; otherwise, undefined.\n */\nexport async function getFileLink(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n identityType: IdentityType,\n logger: ITelemetryLogger,\n): Promise<string> {\n const cacheKey = `${odspUrlParts.siteUrl}_${odspUrlParts.driveId}_${odspUrlParts.itemId}`;\n const maybeFileLinkCacheEntry = fileLinkCache.get(cacheKey);\n if (maybeFileLinkCacheEntry !== undefined) {\n return maybeFileLinkCacheEntry;\n }\n\n const fileLinkGenerator = async function() {\n let fileLinkCore: string;\n try {\n fileLinkCore = await runWithRetry(\n async () => getFileLinkCore(getToken, odspUrlParts, identityType, logger),\n \"getFileLinkCore\",\n logger,\n );\n } catch (err) {\n // runWithRetry throws a non retriable error after it hits the max # of attempts\n // or encounters an unexpected error type\n if (!canRetryOnError(err)) {\n // Delete from the cache to permit retrying later.\n fileLinkCache.delete(cacheKey);\n }\n throw err;\n }\n\n // We are guaranteed to run the getFileLinkCore at least once with successful result (which must be a string)\n assert(fileLinkCore !== undefined, 0x292 /* \"Unexpected undefined result from getFileLinkCore\" */);\n return fileLinkCore;\n };\n const fileLink = fileLinkGenerator();\n fileLinkCache.set(cacheKey, fileLink);\n return fileLink;\n}\n\nasync function getFileLinkCore(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n identityType: IdentityType,\n logger: ITelemetryLogger,\n): Promise<string> {\n const fileItem = await getFileItemLite(getToken, odspUrlParts, logger, identityType === \"Consumer\");\n\n // ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"odspFileLink\", requestName: \"getSharingLink\" },\n async (event) => {\n let attempts = 0;\n let additionalProps;\n const fileLink = await getWithRetryForTokenRefresh(async (options) => {\n attempts++;\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n logger,\n odspUrlParts,\n getToken,\n true /* throwOnNullToken */,\n );\n const storageToken = await storageTokenFetcher(options, \"GetFileLinkCore\");\n assert(storageToken !== null,\n 0x2bb /* \"Instrumented token fetcher with throwOnNullToken = true should never return null\" */);\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${odspUrlParts.siteUrl}/_api/web/GetFileByServerRelativeUrl(@a1)/Linkingurl?@a1=${\n encodeURIComponent(`'${new URL(fileItem.webDavUrl).pathname}'`)\n }`,\n storageToken,\n false,\n );\n const requestInit = {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json;odata=verbose\",\n \"Accept\": \"application/json;odata=verbose\",\n ...headers,\n },\n };\n const response = await fetchHelper(url, requestInit);\n additionalProps = response.propsToLog;\n\n const sharingInfo = await response.content.json();\n const linkingUrl = sharingInfo?.d?.LinkingUrl;\n if (typeof linkingUrl !== \"string\") {\n // This will retry once in getWithRetryForTokenRefresh\n throw new NonRetryableError(\n \"Malformed GetSharingLink response\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n return linkingUrl;\n });\n event.end({ ...additionalProps, attempts });\n return fileLink;\n },\n );\n}\n\n/**\n * This represents a lite version of file item containing only the webUrl and webDavUrl properties\n */\ninterface FileItemLite {\n webUrl: string;\n webDavUrl: string;\n}\n\nconst isFileItemLite = (maybeFileItemLite: any): maybeFileItemLite is FileItemLite => {\n if (typeof maybeFileItemLite.webUrl !== \"string\" || typeof maybeFileItemLite.webDavUrl !== \"string\") {\n return false;\n }\n return true;\n};\n\nasync function getFileItemLite(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<FileItemLite> {\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"odspFileLink\", requestName: \"getFileItemLite\" },\n async (event) => {\n let attempts = 0;\n let additionalProps;\n const fileItem = await getWithRetryForTokenRefresh(async (options) => {\n attempts++;\n const { siteUrl, driveId, itemId } = odspUrlParts;\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n logger,\n odspUrlParts,\n getToken,\n true /* throwOnNullToken */,\n );\n const storageToken = await storageTokenFetcher(options, \"GetFileItemLite\");\n assert(storageToken !== null,\n 0x2bc /* \"Instrumented token fetcher with throwOnNullToken =true should never return null\" */);\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${siteUrl}/_api/v2.0/drives/${driveId}/items/${itemId}?select=webUrl,webDavUrl`,\n storageToken,\n forceAccessTokenViaAuthorizationHeader,\n );\n const requestInit = { method: \"GET\", headers };\n const response = await fetchHelper(url, requestInit);\n additionalProps = response.propsToLog;\n\n const responseJson = await response.content.json();\n if (!isFileItemLite(responseJson)) {\n // This will retry once in getWithRetryForTokenRefresh\n throw new NonRetryableError(\n \"Malformed getFileItemLite response\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n return responseJson;\n });\n event.end({ ...additionalProps, attempts });\n return fileItem;\n },\n );\n}\n"]}
1
+ {"version":3,"file":"getFileLink.js","sourceRoot":"","sources":["../src/getFileLink.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAsD;AACtD,+DAAkF;AAClF,qEAAmE;AACnE,2EAAqE;AAErE,yEAAsE;AACtE,2CAAuG;AACvG,qDAA+D;AAC/D,6CAA4C;AAE5C,2GAA2G;AAC3G,MAAM,aAAa,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEzD;;;;;;;;;;GAUG;AAC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AAM,EAAC,YAAY,KAAK,IAAI,EACxB,KAAK,CAAC,uFAAuF,CAAC,CAAC;YAEnG,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAA,mDAAwB,EAC7C,GAAG,OAAO,qBAAqB,OAAO,UAAU,MAAM,0BAA0B,EAChF,YAAY,EACZ,sCAAsC,CACzC,CAAC;YACF,MAAM,WAAW,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;YAC/C,MAAM,QAAQ,GAAG,MAAM,IAAA,uBAAW,EAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YACrD,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC;YAEtC,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACnD,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE;gBAC/B,sDAAsD;gBACtD,MAAM,IAAI,gCAAiB,CACvB,oCAAoC,EACpC,oCAAe,CAAC,uBAAuB,EACvC,EAAE,aAAa,EAAb,2BAAa,EAAE,CAAC,CAAC;aAC1B;YACD,OAAO,YAAY,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,GAAG,iCAAM,eAAe,KAAE,QAAQ,IAAG,CAAC;QAC5C,OAAO,QAAQ,CAAC;IACpB,CAAC,CACJ,CAAC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { canRetryOnError, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { IOdspUrlParts, OdspResourceTokenFetchOptions, TokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { fetchHelper, getWithRetryForTokenRefresh, toInstrumentedOdspTokenFetcher } from \"./odspUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { runWithRetry } from \"./retryUtils\";\n\n// Store cached responses for the lifetime of web session as file link remains the same for given file item\nconst fileLinkCache = new Map<string, Promise<string>>();\n\n/**\n * Returns file link for a file with given drive and item ids.\n * Scope needed: files.readwrite.all.\n * This function keeps retrying if it gets a retriable error or wait for some delay if it gets a\n * throttling error. In future, we are thinking of app allowing to pass some cancel token, with which\n * we would be able to stop retrying.\n * @param getToken - used to fetch access tokens needed to execute operation\n * @param odspUrlParts - object describing file storage identity\n * @param logger - used to log results of operation, including any error\n * @returns Promise which resolves to file link url when successful; otherwise, undefined.\n */\nexport async function getFileLink(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n logger: ITelemetryLogger,\n): Promise<string> {\n const cacheKey = `${odspUrlParts.siteUrl}_${odspUrlParts.driveId}_${odspUrlParts.itemId}`;\n const maybeFileLinkCacheEntry = fileLinkCache.get(cacheKey);\n if (maybeFileLinkCacheEntry !== undefined) {\n return maybeFileLinkCacheEntry;\n }\n\n const fileLinkGenerator = async function() {\n let fileLinkCore: string;\n try {\n fileLinkCore = await runWithRetry(\n async () => getFileLinkCore(getToken, odspUrlParts, logger),\n \"getFileLinkCore\",\n logger,\n );\n } catch (err) {\n // runWithRetry throws a non retriable error after it hits the max # of attempts\n // or encounters an unexpected error type\n if (!canRetryOnError(err)) {\n // Delete from the cache to permit retrying later.\n fileLinkCache.delete(cacheKey);\n }\n throw err;\n }\n\n // We are guaranteed to run the getFileLinkCore at least once with successful result (which must be a string)\n assert(fileLinkCore !== undefined, 0x292 /* \"Unexpected undefined result from getFileLinkCore\" */);\n return fileLinkCore;\n };\n const fileLink = fileLinkGenerator();\n fileLinkCache.set(cacheKey, fileLink);\n return fileLink;\n}\n\nasync function getFileLinkCore(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n logger: ITelemetryLogger,\n): Promise<string> {\n const fileItem = await getFileItemLite(getToken, odspUrlParts, logger, true);\n\n // ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"odspFileLink\", requestName: \"getSharingInformation\" },\n async (event) => {\n let attempts = 0;\n let additionalProps;\n const fileLink = await getWithRetryForTokenRefresh(async (options) => {\n attempts++;\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n logger,\n odspUrlParts,\n getToken,\n true /* throwOnNullToken */,\n );\n const storageToken = await storageTokenFetcher(options, \"GetFileLinkCore\");\n assert(storageToken !== null,\n 0x2bb /* \"Instrumented token fetcher with throwOnNullToken = true should never return null\" */);\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${odspUrlParts.siteUrl}/_api/web/GetFileByUrl(@a1)/ListItemAllFields/GetSharingInformation?@a1=${\n encodeURIComponent(`'${fileItem.webDavUrl}'`)\n }`,\n storageToken,\n true,\n );\n const requestInit = {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json;odata=verbose\",\n \"Accept\": \"application/json;odata=verbose\",\n ...headers,\n },\n };\n const response = await fetchHelper(url, requestInit);\n additionalProps = response.propsToLog;\n\n const sharingInfo = await response.content.json();\n const directUrl = sharingInfo?.d?.directUrl;\n if (typeof directUrl !== \"string\") {\n // This will retry once in getWithRetryForTokenRefresh\n throw new NonRetryableError(\n \"Malformed GetSharingInformation response\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n return directUrl;\n });\n event.end({ ...additionalProps, attempts });\n return fileLink;\n },\n );\n}\n\n/**\n * This represents a lite version of file item containing only the webUrl and webDavUrl properties\n */\ninterface FileItemLite {\n webUrl: string;\n webDavUrl: string;\n}\n\nconst isFileItemLite = (maybeFileItemLite: any): maybeFileItemLite is FileItemLite => {\n if (typeof maybeFileItemLite.webUrl !== \"string\" || typeof maybeFileItemLite.webDavUrl !== \"string\") {\n return false;\n }\n return true;\n};\n\nasync function getFileItemLite(\n getToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n odspUrlParts: IOdspUrlParts,\n logger: ITelemetryLogger,\n forceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<FileItemLite> {\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"odspFileLink\", requestName: \"getFileItemLite\" },\n async (event) => {\n let attempts = 0;\n let additionalProps;\n const fileItem = await getWithRetryForTokenRefresh(async (options) => {\n attempts++;\n const { siteUrl, driveId, itemId } = odspUrlParts;\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n logger,\n odspUrlParts,\n getToken,\n true /* throwOnNullToken */,\n );\n const storageToken = await storageTokenFetcher(options, \"GetFileItemLite\");\n assert(storageToken !== null,\n 0x2bc /* \"Instrumented token fetcher with throwOnNullToken =true should never return null\" */);\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${siteUrl}/_api/v2.0/drives/${driveId}/items/${itemId}?select=webUrl,webDavUrl`,\n storageToken,\n forceAccessTokenViaAuthorizationHeader,\n );\n const requestInit = { method: \"GET\", headers };\n const response = await fetchHelper(url, requestInit);\n additionalProps = response.propsToLog;\n\n const responseJson = await response.content.json();\n if (!isFileItemLite(responseJson)) {\n // This will retry once in getWithRetryForTokenRefresh\n throw new NonRetryableError(\n \"Malformed getFileItemLite response\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n return responseJson;\n });\n event.end({ ...additionalProps, attempts });\n return fileItem;\n },\n );\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -16,6 +16,5 @@ export * from "./createOdspCreateContainerRequest";
16
16
  export * from "./odspDriverUrlResolverForShareLink";
17
17
  export * from "./odspDriverUrlResolver";
18
18
  export * from "./odspFluidFileLink";
19
- export * from "./compactSnapshotParser";
20
- export * from "./ReadBufferUtils";
19
+ export { parseCompactSnapshotResponse } from "./compactSnapshotParser";
21
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,aAAa,CAAC;AAE5B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAG3B,cAAc,0BAA0B,CAAC;AAGzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2CAA2C,CAAC;AAG1D,cAAc,oCAAoC,CAAC;AAGnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AAGxC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,aAAa,CAAC;AAE5B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAG3B,cAAc,0BAA0B,CAAC;AAGzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2CAA2C,CAAC;AAG1D,cAAc,oCAAoC,CAAC;AAGnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AAGxC,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.parseCompactSnapshotResponse = void 0;
17
18
  // Constants
18
19
  __exportStar(require("./constants"), exports);
19
20
  __exportStar(require("./contractsPublic"), exports);
@@ -35,7 +36,6 @@ __exportStar(require("./odspDriverUrlResolverForShareLink"), exports);
35
36
  __exportStar(require("./odspDriverUrlResolver"), exports);
36
37
  // It's used by URL resolve code, but also has some public functions
37
38
  __exportStar(require("./odspFluidFileLink"), exports);
38
- // Wire format related
39
- __exportStar(require("./compactSnapshotParser"), exports);
40
- __exportStar(require("./ReadBufferUtils"), exports);
39
+ var compactSnapshotParser_1 = require("./compactSnapshotParser");
40
+ Object.defineProperty(exports, "parseCompactSnapshotResponse", { enumerable: true, get: function () { return compactSnapshotParser_1.parseCompactSnapshotResponse; } });
41
41
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,YAAY;AACZ,8CAA4B;AAE5B,oDAAkC;AAElC,eAAe;AACf,oDAAkC;AAClC,kDAAgC;AAChC,kDAAgC;AAChC,6CAA2B;AAE3B,iDAAiD;AACjD,2DAAyC;AAEzC,UAAU;AACV,mEAAiD;AACjD,+DAA6C;AAC7C,4EAA0D;AAE1D,gBAAgB;AAChB,qEAAmD;AAEnD,6CAA6C;AAC7C,sEAAoD;AACpD,0DAAwC;AAExC,oEAAoE;AACpE,sDAAoC;AAEpC,sBAAsB;AACtB,0DAAwC;AACxC,oDAAkC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Constants\nexport * from \"./constants\";\n\nexport * from \"./contractsPublic\";\n\n// public utils\nexport * from \"./odspPublicUtils\";\nexport * from \"./odspUrlHelper\";\nexport * from \"./createOdspUrl\";\nexport * from \"./checkUrl\";\n\n// prefetch latest snapshot before container load\nexport * from \"./prefetchLatestSnapshot\";\n\n// Factory\nexport * from \"./odspDocumentServiceFactoryCore\";\nexport * from \"./odspDocumentServiceFactory\";\nexport * from \"./odspDocumentServiceFactoryWithCodeSplit\";\n\n// File creation\nexport * from \"./createOdspCreateContainerRequest\";\n\n// URI Resolver functionality, URI management\nexport * from \"./odspDriverUrlResolverForShareLink\";\nexport * from \"./odspDriverUrlResolver\";\n\n// It's used by URL resolve code, but also has some public functions\nexport * from \"./odspFluidFileLink\";\n\n// Wire format related\nexport * from \"./compactSnapshotParser\";\nexport * from \"./ReadBufferUtils\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAEH,YAAY;AACZ,8CAA4B;AAE5B,oDAAkC;AAElC,eAAe;AACf,oDAAkC;AAClC,kDAAgC;AAChC,kDAAgC;AAChC,6CAA2B;AAE3B,iDAAiD;AACjD,2DAAyC;AAEzC,UAAU;AACV,mEAAiD;AACjD,+DAA6C;AAC7C,4EAA0D;AAE1D,gBAAgB;AAChB,qEAAmD;AAEnD,6CAA6C;AAC7C,sEAAoD;AACpD,0DAAwC;AAExC,oEAAoE;AACpE,sDAAoC;AAEpC,iEAAuE;AAA9D,qIAAA,4BAA4B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Constants\nexport * from \"./constants\";\n\nexport * from \"./contractsPublic\";\n\n// public utils\nexport * from \"./odspPublicUtils\";\nexport * from \"./odspUrlHelper\";\nexport * from \"./createOdspUrl\";\nexport * from \"./checkUrl\";\n\n// prefetch latest snapshot before container load\nexport * from \"./prefetchLatestSnapshot\";\n\n// Factory\nexport * from \"./odspDocumentServiceFactoryCore\";\nexport * from \"./odspDocumentServiceFactory\";\nexport * from \"./odspDocumentServiceFactoryWithCodeSplit\";\n\n// File creation\nexport * from \"./createOdspCreateContainerRequest\";\n\n// URI Resolver functionality, URI management\nexport * from \"./odspDriverUrlResolverForShareLink\";\nexport * from \"./odspDriverUrlResolver\";\n\n// It's used by URL resolve code, but also has some public functions\nexport * from \"./odspFluidFileLink\";\n\nexport { parseCompactSnapshotResponse } from \"./compactSnapshotParser\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localOdspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAOnF;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,8BAA8B;IAI3E,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAJlC,OAAO,CAAC,cAAc,CAAqB;gBAGtB,MAAM,EAAE,gBAAgB,EACxB,aAAa,EAAE,UAAU,GAAG,MAAM;IAKvD,OAAO,CAAC,iBAAiB,CAAS;IAErB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAwB/G,OAAO,CAAC,kBAAkB;IAI1B,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK;IAI3E,SAAS,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,KAAK;IAIlE,wBAAwB,CAAC,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,eAAe,GAAG,KAAK;IAItF,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK;IAIhD,OAAO,CAAC,eAAe;CAK1B"}
1
+ {"version":3,"file":"localOdspDocumentStorageManager.d.ts","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAMnF;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,8BAA8B;IAI3E,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAJlC,OAAO,CAAC,cAAc,CAAqB;gBAGtB,MAAM,EAAE,gBAAgB,EACxB,aAAa,EAAE,UAAU,GAAG,MAAM;IAKvD,OAAO,CAAC,iBAAiB,CAAS;IAErB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAyB/G,OAAO,CAAC,kBAAkB;IAI1B,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK;IAI3E,SAAS,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,KAAK;IAIlE,wBAAwB,CAAC,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,eAAe,GAAG,KAAK;IAItF,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK;IAIhD,OAAO,CAAC,eAAe;CAK1B"}
@@ -10,7 +10,6 @@ const driver_utils_1 = require("@fluidframework/driver-utils");
10
10
  const odspDocumentStorageServiceBase_1 = require("../odspDocumentStorageServiceBase");
11
11
  const odspSnapshotParser_1 = require("../odspSnapshotParser");
12
12
  const compactSnapshotParser_1 = require("../compactSnapshotParser");
13
- const ReadBufferUtils_1 = require("../ReadBufferUtils");
14
13
  /**
15
14
  * ODSP document storage service that works on a provided snapshot for all its processing.
16
15
  * Attempting to use unsupported actions/methods will result in errors being thrown.
@@ -36,7 +35,7 @@ class LocalOdspDocumentStorageService extends odspDocumentStorageServiceBase_1.O
36
35
  snapshotContents = (0, odspSnapshotParser_1.convertOdspSnapshotToSnapshotTreeAndBlobs)(content);
37
36
  }
38
37
  else {
39
- snapshotContents = (0, compactSnapshotParser_1.parseCompactSnapshotResponse)(new ReadBufferUtils_1.ReadBuffer(this.localSnapshot));
38
+ snapshotContents = (0, compactSnapshotParser_1.parseCompactSnapshotResponse)(this.localSnapshot, this.logger);
40
39
  }
41
40
  this.snapshotTreeId = this.initializeFromSnapshot(snapshotContents);
42
41
  return this.getSnapshotVersion();
@@ -1 +1 @@
1
- {"version":3,"file":"localOdspDocumentStorageManager.js","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentStorageManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAGtD,+DAA0D;AAE1D,sFAAmF;AAGnF,8DAAkF;AAClF,oEAAwE;AACxE,wDAAgD;AAEhD;;;GAGG;AACH,MAAa,+BAAgC,SAAQ,+DAA8B;IAG/E,YACqB,MAAwB,EACxB,aAAkC;QAEnD,KAAK,EAAE,CAAC;QAHS,WAAM,GAAN,MAAM,CAAkB;QACxB,kBAAa,GAAb,aAAa,CAAqB;QAK/C,sBAAiB,GAAG,KAAK,CAAC;IAFlC,CAAC;IAIM,KAAK,CAAC,WAAW,CAAC,MAAqB,EAAE,KAAa,EAAE,aAAsB;QACjF,IAAA,qBAAM,EAAC,MAAM,KAAK,IAAI,EAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACnF,IAAA,qBAAM,EAAC,KAAK,KAAK,CAAC,EAAE,KAAK,CA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CAAC,UAAkB;QACtC,MAAM,OAAO,GAAG,IAAI,yBAAU,CAAC,IAAI,UAAU,uDAAuD,CAAC,CAAC;QACtG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,OAAO,CAAC;IAClB,CAAC;CACJ;AA7DD,0EA6DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { OdspDocumentStorageServiceBase } from \"../odspDocumentStorageServiceBase\";\nimport { ISnapshotContents } from \"../odspPublicUtils\";\nimport { IOdspSnapshot } from \"../contracts\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"../odspSnapshotParser\";\nimport { parseCompactSnapshotResponse } from \"../compactSnapshotParser\";\nimport { ReadBuffer } from \"../ReadBufferUtils\";\n\n/**\n * ODSP document storage service that works on a provided snapshot for all its processing.\n * Attempting to use unsupported actions/methods will result in errors being thrown.\n */\nexport class LocalOdspDocumentStorageService extends OdspDocumentStorageServiceBase {\n private snapshotTreeId: string | undefined;\n\n constructor(\n private readonly logger: ITelemetryLogger,\n private readonly localSnapshot: Uint8Array | string,\n ) {\n super();\n }\n\n private calledGetVersions = false;\n\n public async getVersions(blobid: string | null, count: number, _scenarioName?: string): Promise<api.IVersion[]> {\n assert(blobid === null, 0x342 /* Invalid usage. \"blobid\" should always be null */);\n assert(count === 1, 0x343 /* Invalid usage. \"count\" should always be 1 */);\n\n // No reason to re-parse the data since it will never change\n if (this.calledGetVersions) {\n return this.getSnapshotVersion();\n }\n this.calledGetVersions = true;\n\n let snapshotContents: ISnapshotContents;\n\n if (typeof this.localSnapshot === \"string\") {\n const content: IOdspSnapshot = JSON.parse(this.localSnapshot);\n snapshotContents = convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n } else {\n snapshotContents = parseCompactSnapshotResponse(\n new ReadBuffer(this.localSnapshot));\n }\n\n this.snapshotTreeId = this.initializeFromSnapshot(snapshotContents);\n return this.getSnapshotVersion();\n }\n\n private getSnapshotVersion(): api.IVersion[] {\n return this.snapshotTreeId ? [{ id: this.snapshotTreeId, treeId: undefined! }] : [];\n }\n\n protected fetchTreeFromSnapshot(_id: string, _scenarioName?: string): never {\n this.throwUsageError(\"fetchTreeFromSnapshot\");\n }\n\n protected fetchBlobFromStorage(_blobId: string, _evicted: boolean): never {\n this.throwUsageError(\"fetchBlobFromStorage\");\n }\n\n public uploadSummaryWithContext(_summary: api.ISummaryTree, _context: ISummaryContext): never {\n this.throwUsageError(\"uploadSummaryWithContext\");\n }\n\n public createBlob(_file: ArrayBufferLike): never {\n this.throwUsageError(\"createBlob\");\n }\n\n private throwUsageError(methodName: string): never {\n const toThrow = new UsageError(`\"${methodName}\" is not supported by LocalOdspDocumentStorageService`);\n this.logger.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n throw toThrow;\n }\n}\n"]}
1
+ {"version":3,"file":"localOdspDocumentStorageManager.js","sourceRoot":"","sources":["../../src/localOdspDriver/localOdspDocumentStorageManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAGtD,+DAA0D;AAE1D,sFAAmF;AAGnF,8DAAkF;AAClF,oEAAwE;AAExE;;;GAGG;AACH,MAAa,+BAAgC,SAAQ,+DAA8B;IAG/E,YACqB,MAAwB,EACxB,aAAkC;QAEnD,KAAK,EAAE,CAAC;QAHS,WAAM,GAAN,MAAM,CAAkB;QACxB,kBAAa,GAAb,aAAa,CAAqB;QAK/C,sBAAiB,GAAG,KAAK,CAAC;IAFlC,CAAC;IAIM,KAAK,CAAC,WAAW,CAAC,MAAqB,EAAE,KAAa,EAAE,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C,eAAe,CAAC,0BAA0B,CAAC,CAAC;IACrD,CAAC;IAEM,UAAU,CAAC,KAAsB;QACpC,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAEO,eAAe,CAAC,UAAkB;QACtC,MAAM,OAAO,GAAG,IAAI,yBAAU,CAAC,IAAI,UAAU,uDAAuD,CAAC,CAAC;QACtG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,OAAO,CAAC;IAClB,CAAC;CACJ;AA9DD,0EA8DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { OdspDocumentStorageServiceBase } from \"../odspDocumentStorageServiceBase\";\nimport { ISnapshotContents } from \"../odspPublicUtils\";\nimport { IOdspSnapshot } from \"../contracts\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"../odspSnapshotParser\";\nimport { parseCompactSnapshotResponse } from \"../compactSnapshotParser\";\n\n/**\n * ODSP document storage service that works on a provided snapshot for all its processing.\n * Attempting to use unsupported actions/methods will result in errors being thrown.\n */\nexport class LocalOdspDocumentStorageService extends OdspDocumentStorageServiceBase {\n private snapshotTreeId: string | undefined;\n\n constructor(\n private readonly logger: ITelemetryLogger,\n private readonly localSnapshot: Uint8Array | string,\n ) {\n super();\n }\n\n private calledGetVersions = false;\n\n public async getVersions(blobid: string | null, count: number, _scenarioName?: string): Promise<api.IVersion[]> {\n assert(blobid === null, 0x342 /* Invalid usage. \"blobid\" should always be null */);\n assert(count === 1, 0x343 /* Invalid usage. \"count\" should always be 1 */);\n\n // No reason to re-parse the data since it will never change\n if (this.calledGetVersions) {\n return this.getSnapshotVersion();\n }\n this.calledGetVersions = true;\n\n let snapshotContents: ISnapshotContents;\n\n if (typeof this.localSnapshot === \"string\") {\n const content: IOdspSnapshot = JSON.parse(this.localSnapshot);\n snapshotContents = convertOdspSnapshotToSnapshotTreeAndBlobs(content);\n } else {\n snapshotContents = parseCompactSnapshotResponse(\n this.localSnapshot,\n this.logger);\n }\n\n this.snapshotTreeId = this.initializeFromSnapshot(snapshotContents);\n return this.getSnapshotVersion();\n }\n\n private getSnapshotVersion(): api.IVersion[] {\n return this.snapshotTreeId ? [{ id: this.snapshotTreeId, treeId: undefined! }] : [];\n }\n\n protected fetchTreeFromSnapshot(_id: string, _scenarioName?: string): never {\n this.throwUsageError(\"fetchTreeFromSnapshot\");\n }\n\n protected fetchBlobFromStorage(_blobId: string, _evicted: boolean): never {\n this.throwUsageError(\"fetchBlobFromStorage\");\n }\n\n public uploadSummaryWithContext(_summary: api.ISummaryTree, _context: ISummaryContext): never {\n this.throwUsageError(\"uploadSummaryWithContext\");\n }\n\n public createBlob(_file: ArrayBufferLike): never {\n this.throwUsageError(\"createBlob\");\n }\n\n private throwUsageError(methodName: string): never {\n const toThrow = new UsageError(`\"${methodName}\" is not supported by LocalOdspDocumentStorageService`);\n this.logger.sendErrorEvent({ eventName: \"UnsupportedUsage\" }, toThrow);\n throw toThrow;\n }\n}\n"]}
@@ -17,7 +17,7 @@ export declare class OdspDeltaStorageService {
17
17
  private readonly logger;
18
18
  constructor(deltaFeedUrl: string, getStorageToken: InstrumentedStorageTokenFetcher, epochTracker: EpochTracker, logger: ITelemetryLogger);
19
19
  /**
20
- * Retrieves ops from cache
20
+ * Retrieves ops from storage
21
21
  * @param from - inclusive
22
22
  * @param to - exclusive
23
23
  * @param telemetryProps - properties to add when issuing telemetry events
@@ -1 +1 @@
1
- {"version":3,"file":"odspDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":"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E,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,EACrD,WAAW,EAAE,CAAC,GAAG,EAAE,yBAAyB,EAAE,KAAK,IAAI;IAI5E,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,yBAAyB,EAAE,EAAE,IAAI,EAAE,MAAM;IAiBvF,aAAa,CAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,EACpB,WAAW,CAAC,EAAE,MAAM;CAkF3B"}
@@ -24,7 +24,7 @@ class OdspDeltaStorageService {
24
24
  this.logger = logger;
25
25
  }
26
26
  /**
27
- * Retrieves ops from cache
27
+ * Retrieves ops from storage
28
28
  * @param from - inclusive
29
29
  * @param to - exclusive
30
30
  * @param telemetryProps - properties to add when issuing telemetry events
@@ -61,13 +61,9 @@ class OdspDeltaStorageService {
61
61
  }, "ops", true, scenarioName);
62
62
  clearTimeout(timer);
63
63
  const deltaStorageResponse = response.content;
64
- let messages;
65
- if (deltaStorageResponse.value.length > 0 && "op" in deltaStorageResponse.value[0]) {
66
- messages = deltaStorageResponse.value.map((operation) => operation.op);
67
- }
68
- else {
69
- messages = deltaStorageResponse.value;
70
- }
64
+ const messages = deltaStorageResponse.value.length > 0 && "op" in deltaStorageResponse.value[0]
65
+ ? deltaStorageResponse.value.map((operation) => operation.op)
66
+ : deltaStorageResponse.value;
71
67
  this.logger.sendPerformanceEvent(Object.assign(Object.assign(Object.assign(Object.assign({ eventName: "OpsFetch", headers: Object.keys(headers).length !== 0 ? true : undefined, length: messages.length, duration: response.duration }, response.propsToLog), { attempts: options.refresh ? 2 : 1, from,
72
68
  to }), telemetryProps), { reason: scenarioName }));
73
69
  // It is assumed that server always returns all the ops that it has in the range that was requested.
@@ -1 +1 @@
1
- {"version":3,"file":"odspDeltaStorageService.js","sourceRoot":"","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,cAAc,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC/B,OAAO,GAAG,CAAC;QACf,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,yBAAU,EACrB,KAAK,EAAE,IAAY,EAAE,EAAU,EAAE,cAAoC,EAAE,EAAE;YACrE,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;YAC/D,+BAA+B;YAC/B,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,uEAAuE;QACvE,0DAA0D;QAC1D,IAAI,CAAC,WAAW,EAChB,SAAS,EAAE,YAAY;QACvB,OAAO,EAAE,YAAY;QACrB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,EACX,WAAW,EACX,WAAW,CACd,CAAC;QAEF,OAAO,IAAA,6BAAc,EAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,IAAI,IAAI,eAAe,GAAG,YAAY,GAAG,cAAc,KAAK,CAAC,EAAE;gBACtE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,mBAAmB;oBAC9B,eAAe;oBACf,YAAY;oBACZ,cAAc;iBACjB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA3HD,8DA2HC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { IDeltasFetchResult, IDocumentDeltaStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n requestOps,\n streamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n constructor(\n private readonly deltaFeedUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly epochTracker: EpochTracker,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n /**\n * Retrieves ops from cache\n * @param from - inclusive\n * @param to - exclusive\n * @param telemetryProps - properties to add when issuing telemetry events\n * @param scenarioName - reason for fetching ops\n * @returns ops retrieved & info if result was partial (i.e. more is available)\n */\n public async get(\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n scenarioName?: string,\n ): Promise<IDeltasFetchResult> {\n return getWithRetryForTokenRefresh(async (options) => {\n // Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n // Thus it needs to be done before we call getStorageToken() to reduce extra calls\n const baseUrl = this.buildUrl(from, to);\n const storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n const headers: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n\n // Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n // of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n // networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n // So adding some timeout to ensure we retry again in hope of faster success.\n // Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n const abort = new AbortController();\n const timer = setTimeout(() => abort.abort(), 30000);\n\n const response = await this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n baseUrl,\n {\n headers,\n body: postBody,\n method: \"POST\",\n signal: abort.signal,\n },\n \"ops\",\n true,\n scenarioName,\n );\n clearTimeout(timer);\n const deltaStorageResponse = response.content;\n let messages: ISequencedDocumentMessage[];\n if (deltaStorageResponse.value.length > 0 && \"op\" in deltaStorageResponse.value[0]) {\n messages = (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map((operation) => operation.op);\n } else {\n messages = deltaStorageResponse.value as ISequencedDocumentMessage[];\n }\n\n this.logger.sendPerformanceEvent({\n eventName: \"OpsFetch\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n length: messages.length,\n duration: response.duration, // this duration for single attempt!\n ...response.propsToLog,\n attempts: options.refresh ? 2 : 1,\n from,\n to,\n ...telemetryProps,\n reason: scenarioName,\n });\n\n // It is assumed that server always returns all the ops that it has in the range that was requested.\n // This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n return { messages, partialResult: false };\n });\n }\n\n public buildUrl(from: number, to: number) {\n const filter = encodeURIComponent(`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`);\n const queryString = `?ump=1&filter=${filter}`;\n return `${this.deltaFeedUrl}${queryString}`;\n }\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n private firstCacheMiss = Number.MAX_SAFE_INTEGER;\n\n public constructor(\n private snapshotOps: ISequencedDocumentMessage[] | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly batchSize: number,\n private readonly concurrency: number,\n private readonly getFromStorage: (\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string) => Promise<IDeltasFetchResult>,\n private readonly getCached: (from: number, to: number) => Promise<ISequencedDocumentMessage[]>,\n private readonly requestFromSocket: (from: number, to: number) => void,\n private readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n ) {\n }\n\n protected validateMessages(reason: string, messages: ISequencedDocumentMessage[], from: number) {\n if (messages.length !== 0) {\n const start = messages[0].sequenceNumber;\n const length = messages.length;\n const last = messages[length - 1].sequenceNumber;\n if (start !== from) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n messages.length = 0;\n }\n if (last + 1 !== from + length) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n // we can do better here by finding consecutive sub-block and return it\n messages.length = 0;\n }\n }\n }\n\n public fetchMessages(\n fromTotal: number,\n toTotal: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n fetchReason?: string) {\n // We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n // storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n // cache and it's not there.\n // Better implementation would be to return only what we have in cache, but that also breaks API\n assert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n let opsFromSnapshot = 0;\n let opsFromCache = 0;\n let opsFromStorage = 0;\n\n const requestCallback = async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n if (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n const messages = this.snapshotOps.filter((op) =>\n op.sequenceNumber >= from && op.sequenceNumber < to);\n this.validateMessages(\"cached\", messages, from);\n if (messages.length > 0 && messages[0].sequenceNumber === from) {\n this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n opsFromSnapshot = messages.length;\n return { messages, partialResult: true };\n }\n this.snapshotOps = undefined;\n }\n\n // Kick out request to PUSH for ops if it has them\n this.requestFromSocket(from, to);\n\n // Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n // This saves a bit of processing time\n if (from < this.firstCacheMiss) {\n const messagesFromCache = await this.getCached(from, to);\n this.validateMessages(\"cached\", messagesFromCache, from);\n if (messagesFromCache.length !== 0) {\n opsFromCache += messagesFromCache.length;\n return {\n messages: messagesFromCache,\n partialResult: true,\n };\n }\n this.firstCacheMiss = Math.min(this.firstCacheMiss, from);\n }\n\n if (cachedOnly) {\n return { messages: [], partialResult: false };\n }\n\n const ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n this.validateMessages(\"storage\", ops.messages, from);\n opsFromStorage += ops.messages.length;\n this.opsReceived(ops.messages);\n return ops;\n };\n\n const stream = requestOps(\n async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n const result = await requestCallback(from, to, telemetryProps);\n // Catch all case, just in case\n this.validateMessages(\"catch all\", result.messages, from);\n return result;\n },\n // Staging: starting with no concurrency, listening for feedback first.\n // In future releases we will switch to actual concurrency\n this.concurrency,\n fromTotal, // inclusive\n toTotal, // exclusive\n this.batchSize,\n this.logger,\n abortSignal,\n fetchReason,\n );\n\n return streamObserver(stream, (result) => {\n if (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsRetrieved\",\n opsFromSnapshot,\n opsFromCache,\n opsFromStorage,\n });\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"odspDeltaStorageService.js","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,wEAA8D;AAC9D,+BAAkC;AAElC,+DAAsD;AAItD,+DAGsC;AAGtC,2CAA0D;AAE1D;;GAEG;AACH,MAAa,uBAAuB;IAChC,YACqB,YAAoB,EACpB,eAAgD,EAChD,YAA0B,EAC1B,MAAwB;QAHxB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,oBAAe,GAAf,eAAe,CAAiC;QAChD,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAkB;IAE7C,CAAC;IAED;;;;;;;OAOG;IACK,KAAK,CAAC,GAAG,CACb,IAAY,EACZ,EAAU,EACV,cAAoC,EACpC,YAAqB;QAErB,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D,IAAI,CAAC,WAAW,EAChB,SAAS,EAAE,YAAY;QACvB,OAAO,EAAE,YAAY;QACrB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,EACX,WAAW,EACX,WAAW,CACd,CAAC;QAEF,OAAO,IAAA,6BAAc,EAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,IAAI,IAAI,eAAe,GAAG,YAAY,GAAG,cAAc,KAAK,CAAC,EAAE;gBACtE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,mBAAmB;oBAC9B,eAAe;oBACf,YAAY;oBACZ,cAAc;iBACjB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA3HD,8DA2HC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { IDeltasFetchResult, IDocumentDeltaStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n requestOps,\n streamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n constructor(\n private readonly deltaFeedUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly epochTracker: EpochTracker,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n /**\n * Retrieves ops from storage\n * @param from - inclusive\n * @param to - exclusive\n * @param telemetryProps - properties to add when issuing telemetry events\n * @param scenarioName - reason for fetching ops\n * @returns ops retrieved & info if result was partial (i.e. more is available)\n */\n public async get(\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n scenarioName?: string,\n ): Promise<IDeltasFetchResult> {\n return getWithRetryForTokenRefresh(async (options) => {\n // Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n // Thus it needs to be done before we call getStorageToken() to reduce extra calls\n const baseUrl = this.buildUrl(from, to);\n const storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n const headers: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n\n // Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n // of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n // networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n // So adding some timeout to ensure we retry again in hope of faster success.\n // Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n const abort = new AbortController();\n const timer = setTimeout(() => abort.abort(), 30000);\n\n const response = await this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n baseUrl,\n {\n headers,\n body: postBody,\n method: \"POST\",\n signal: abort.signal,\n },\n \"ops\",\n true,\n scenarioName,\n );\n clearTimeout(timer);\n const deltaStorageResponse = response.content;\n const messages = deltaStorageResponse.value.length > 0 && \"op\" in deltaStorageResponse.value[0]\n ? (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map((operation) => operation.op)\n : deltaStorageResponse.value as ISequencedDocumentMessage[];\n\n this.logger.sendPerformanceEvent({\n eventName: \"OpsFetch\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n length: messages.length,\n duration: response.duration, // this duration for single attempt!\n ...response.propsToLog,\n attempts: options.refresh ? 2 : 1,\n from,\n to,\n ...telemetryProps,\n reason: scenarioName,\n });\n\n // It is assumed that server always returns all the ops that it has in the range that was requested.\n // This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n return { messages, partialResult: false };\n });\n }\n\n public buildUrl(from: number, to: number) {\n const filter = encodeURIComponent(`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`);\n const queryString = `?ump=1&filter=${filter}`;\n return `${this.deltaFeedUrl}${queryString}`;\n }\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n private firstCacheMiss = Number.MAX_SAFE_INTEGER;\n\n public constructor(\n private snapshotOps: ISequencedDocumentMessage[] | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly batchSize: number,\n private readonly concurrency: number,\n private readonly getFromStorage: (\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string) => Promise<IDeltasFetchResult>,\n private readonly getCached: (from: number, to: number) => Promise<ISequencedDocumentMessage[]>,\n private readonly requestFromSocket: (from: number, to: number) => void,\n private readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n ) {\n }\n\n protected validateMessages(reason: string, messages: ISequencedDocumentMessage[], from: number) {\n if (messages.length !== 0) {\n const start = messages[0].sequenceNumber;\n const length = messages.length;\n const last = messages[length - 1].sequenceNumber;\n if (start !== from) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n messages.length = 0;\n }\n if (last + 1 !== from + length) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n // we can do better here by finding consecutive sub-block and return it\n messages.length = 0;\n }\n }\n }\n\n public fetchMessages(\n fromTotal: number,\n toTotal: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n fetchReason?: string) {\n // We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n // storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n // cache and it's not there.\n // Better implementation would be to return only what we have in cache, but that also breaks API\n assert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n let opsFromSnapshot = 0;\n let opsFromCache = 0;\n let opsFromStorage = 0;\n\n const requestCallback = async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n if (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n const messages = this.snapshotOps.filter((op) =>\n op.sequenceNumber >= from && op.sequenceNumber < to);\n this.validateMessages(\"cached\", messages, from);\n if (messages.length > 0 && messages[0].sequenceNumber === from) {\n this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n opsFromSnapshot = messages.length;\n return { messages, partialResult: true };\n }\n this.snapshotOps = undefined;\n }\n\n // Kick out request to PUSH for ops if it has them\n this.requestFromSocket(from, to);\n\n // Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n // This saves a bit of processing time\n if (from < this.firstCacheMiss) {\n const messagesFromCache = await this.getCached(from, to);\n this.validateMessages(\"cached\", messagesFromCache, from);\n if (messagesFromCache.length !== 0) {\n opsFromCache += messagesFromCache.length;\n return {\n messages: messagesFromCache,\n partialResult: true,\n };\n }\n this.firstCacheMiss = Math.min(this.firstCacheMiss, from);\n }\n\n if (cachedOnly) {\n return { messages: [], partialResult: false };\n }\n\n const ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n this.validateMessages(\"storage\", ops.messages, from);\n opsFromStorage += ops.messages.length;\n this.opsReceived(ops.messages);\n return ops;\n };\n\n const stream = requestOps(\n async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n const result = await requestCallback(from, to, telemetryProps);\n // Catch all case, just in case\n this.validateMessages(\"catch all\", result.messages, from);\n return result;\n },\n // Staging: starting with no concurrency, listening for feedback first.\n // In future releases we will switch to actual concurrency\n this.concurrency,\n fromTotal, // inclusive\n toTotal, // exclusive\n this.batchSize,\n this.logger,\n abortSignal,\n fetchReason,\n );\n\n return streamObserver(stream, (result) => {\n if (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsRetrieved\",\n opsFromSnapshot,\n opsFromCache,\n opsFromStorage,\n });\n }\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/odspDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAA6B,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EACH,OAAO,EACP,QAAQ,EAIX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAU,EAAE,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG3E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,MAAM,WAAW,WAAW;IACxB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD,MAAM,WAAW,aAAc,SAAQ,MAAM;IACzC,CAAC,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,KAAK,IAAI,OAAE;CACxF;AAyID;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,uBAAuB;IAoKhE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IAnKxC;;;;;;;;;;;;;;;OAeG;WACiB,MAAM,CACtB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GAAG,IAA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B,CAAS;IAC/C,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwE;IAClG,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAoC;IAEzD;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,UAAO,GAAG,eAAe;IAS3F;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,4BAA4B;IA8B3C;;;;;;OAMG;IACH,OAAO;IAYP;;;;;OAKG;IACK,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAwD9B,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC;IA4B1C,SAAS,CAAC,uBAAuB,UAAW,eAAe,GAAG,SAAS,UAGrE;cAEc,UAAU,CAAC,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM;IAqFpE,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;IAiD9E;;OAEG;IACH,SAAS,CAAC,UAAU,CAAC,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe;CAe7E"}
@@ -232,12 +232,9 @@ class OdspDocumentDeltaConnection extends driver_base_1.DocumentDeltaConnection
232
232
  // Note: we suspect the incoming error object is either:
233
233
  // - a socketError: add it to the OdspError object for driver to be able to parse it and reason over it.
234
234
  // - anything else: let base class handle it
235
- if (canRetry && Number.isInteger(error === null || error === void 0 ? void 0 : error.code) && typeof (error === null || error === void 0 ? void 0 : error.message) === "string") {
236
- return (0, odspError_1.errorObjectFromSocketError)(error, handler);
237
- }
238
- else {
239
- return super.createErrorObject(handler, error, canRetry);
240
- }
235
+ return canRetry && Number.isInteger(error === null || error === void 0 ? void 0 : error.code) && typeof (error === null || error === void 0 ? void 0 : error.message) === "string"
236
+ ? (0, odspError_1.errorObjectFromSocketError)(error, handler)
237
+ : super.createErrorObject(handler, error, canRetry);
241
238
  }
242
239
  /**
243
240
  * Gets or create a socket io connection for the given key