@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
@@ -1 +1 @@
1
- {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAgB,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACH,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACnE,O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AE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/B,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,eAAiC;IACpE,MAAM,UAAU,GAAgB;QAC5B,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,EAAE;QACP,IAAI,EAAE;YACF,WAAW,EAAE,eAAe;YAC5B,KAAK,EAAE,eAAe,CAAC,gBAAgB;SAC1C;KACJ,CAAC;IACF,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,iGAAiG;AACjG,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties, ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IResolvedUrl, DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n isOnline,\n OnlineStatus,\n RetryableError,\n NonRetryableError,\n NetworkErrorBasic,\n} from \"@fluidframework/driver-utils\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { ChildLogger, PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n fetchIncorrectResponse,\n throwOdspNetworkError,\n getSPOAndGraphRequestIdsFromResponse,\n} from \"@fluidframework/odsp-doclib-utils\";\nimport {\n IOdspResolvedUrl,\n TokenFetchOptions,\n OdspErrorType,\n tokenFromResponse,\n isTokenFromCache,\n OdspResourceTokenFetchOptions,\n ShareLinkTypes,\n TokenFetcher,\n ICacheEntry,\n snapshotKey,\n InstrumentedStorageTokenFetcher,\n IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { fetch } from \"./fetch\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { IOdspSnapshot } from \"./contracts\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/** Parse the given url and return the origin (host name) */\nexport const getOrigin = (url: string) => new URL(url).origin;\n\nexport interface IOdspResponse<T> {\n content: T;\n headers: Map<string, string>;\n propsToLog: ITelemetryProperties;\n duration: number;\n}\n\nexport interface TokenFetchOptionsEx extends TokenFetchOptions {\n /** previous error we hit in getWithRetryForTokenRefresh */\n previousError?: any;\n}\n\nfunction headersToMap(headers: Headers) {\n const newHeaders = new Map<string, string>();\n for (const [key, value] of headers.entries()) {\n newHeaders.set(key, value);\n }\n return newHeaders;\n}\n\n/**\n * This API should be used with pretty much all network calls (fetch, webSocket connection) in order\n * to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch\n * token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors\n * simply propagate to caller\n */\nexport async function getWithRetryForTokenRefresh<T>(get: (options: TokenFetchOptionsEx) => Promise<T>) {\n return get({ refresh: false }).catch(async (e) => {\n const options: TokenFetchOptionsEx = { refresh: true, previousError: e };\n switch (e.errorType) {\n // If the error is 401 or 403 refresh the token and try once more.\n case DriverErrorType.authorizationError:\n return get({ ...options, claims: e.claims, tenantId: e.tenantId });\n\n case DriverErrorType.incorrectServerResponse: // some error on the wire, retry once\n case OdspErrorType.fetchTokenError: // If the token was null, then retry once.\n return get(options);\n\n default:\n // Caller may determine that it wants one retry\n if (e[getWithRetryForTokenRefreshRepeat] === true) {\n return get(options);\n }\n throw e;\n }\n });\n}\n\nexport async function fetchHelper(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n const start = performance.now();\n\n // Node-fetch and dom have conflicting typing, force them to work by casting for now\n return fetch(requestInfo, requestInit).then(async (fetchResponse) => {\n const response = fetchResponse as any as Response;\n // Let's assume we can retry.\n if (!response) {\n throw new NonRetryableError(\n // pre-0.58 error message: No response from fetch call\n \"No response from ODSP fetch call\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n if (!response.ok || response.status < 200 || response.status >= 300) {\n throwOdspNetworkError(\n // pre-0.58 error message prefix: odspFetchError\n `ODSP fetch error [${response.status}]`, response.status, response, await response.text());\n }\n\n const headers = headersToMap(response.headers);\n return {\n content: response,\n headers,\n propsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n duration: performance.now() - start,\n };\n }, (error) => {\n const online = isOnline();\n const errorText = `${error}`;\n\n // This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n if (error.name === \"AbortError\") {\n throw new RetryableError(\n \"Fetch Timeout (AbortError)\", OdspErrorType.fetchTimeout, { driverVersion });\n }\n // TCP/IP timeout\n if (errorText.includes(\"ETIMEDOUT\")) {\n throw new RetryableError(\n \"Fetch Timeout (ETIMEDOUT)\", OdspErrorType.fetchTimeout, { driverVersion });\n }\n\n //\n // WARNING: Do not log error object itself or any of its properties!\n // It could contain PII, like URI in message itself, or token in properties.\n // It is also non-serializable object due to circular references.\n //\n if (online === OnlineStatus.Offline) {\n throw new RetryableError(\n // pre-0.58 error message prefix: Offline\n `ODSP fetch failure (Offline): ${errorText}`, DriverErrorType.offlineError, { driverVersion });\n } else {\n // It is perhaps still possible that this is due to being offline, the error does not reveal enough\n // information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n throw new RetryableError(\n // pre-0.58 error message prefix: Fetch error\n `ODSP fetch failure: ${errorText}`, DriverErrorType.fetchFailure, { driverVersion });\n }\n });\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchArray(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n const { content, headers, propsToLog, duration } = await fetchHelper(requestInfo, requestInit);\n\n const arrayBuffer = await content.arrayBuffer();\n propsToLog.bodySize = arrayBuffer.byteLength;\n return {\n headers,\n content: arrayBuffer,\n propsToLog,\n duration,\n };\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchAndParseAsJSONHelper<T>(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n const { content, headers, propsToLog, duration } = await fetchHelper(requestInfo, requestInit);\n let text: string | undefined;\n try {\n text = await content.text();\n } catch (e) {\n // JSON.parse() can fail and message would container full request URI, including\n // tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n // (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n // succeeds on retry.\n // So do not log error object itself.\n throwOdspNetworkError(\n // pre-0.58 error message: errorWhileParsingFetchResponse\n \"Error while parsing fetch response\",\n fetchIncorrectResponse,\n content, // response\n text,\n );\n }\n\n propsToLog.bodySize = text.length;\n const res = {\n headers,\n content: JSON.parse(text),\n propsToLog,\n duration,\n };\n return res;\n}\n\nexport interface INewFileInfo {\n siteUrl: string;\n driveId: string;\n filename: string;\n filePath: string;\n /**\n * application can request creation of a share link along with the creation of a new file\n * by passing in an optional param to specify the kind of sharing link\n * (at the time of adding this comment Sept/2021), odsp only supports csl\n */\n createLinkType?: ShareLinkTypes;\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n assert((resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true, 0x1de /* \"Not an ODSP resolved url\" */);\n return resolvedUrl as IOdspResolvedUrl;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger) =>\n ChildLogger.create(\n logger,\n \"OdspDriver\",\n {\n all:\n {\n driverVersion,\n },\n });\n\nexport function evalBlobsAndTrees(snapshot: IOdspSnapshot) {\n let numTrees = 0;\n let numBlobs = 0;\n let encodedBlobsSize = 0;\n let decodedBlobsSize = 0;\n for (const tree of snapshot.trees) {\n for (const treeEntry of tree.entries) {\n if (treeEntry.type === \"blob\") {\n numBlobs++;\n } else if (treeEntry.type === \"tree\") {\n numTrees++;\n }\n }\n }\n if (snapshot.blobs !== undefined) {\n for (const blob of snapshot.blobs) {\n decodedBlobsSize += blob.size;\n encodedBlobsSize += blob.content.length;\n }\n }\n return { numTrees, numBlobs, encodedBlobsSize, decodedBlobsSize };\n}\n\nexport function toInstrumentedOdspTokenFetcher(\n logger: ITelemetryLogger,\n resolvedUrlParts: IOdspUrlParts,\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n throwOnNullToken: boolean,\n): InstrumentedStorageTokenFetcher {\n return async (options: TokenFetchOptions, name: string, alwaysRecordTokenFetchTelemetry: boolean = false) => {\n // Telemetry note: if options.refresh is true, there is a potential perf issue:\n // Host should optimize and provide non-expired tokens on all critical paths.\n // Exceptions: race conditions around expiration, revoked tokens, host that does not care\n // (fluid-fetcher)\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: `${name}_GetToken`,\n attempts: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n },\n async (event) => tokenFetcher({\n ...options,\n ...resolvedUrlParts,\n }).then((tokenResponse) => {\n const token = tokenFromResponse(tokenResponse);\n // This event alone generates so many events that is materially impacts cost of telemetry\n // Thus do not report end event when it comes back quickly.\n // Note that most of the hosts do not report if result is comming from cache or not,\n // so we can't rely on that here. But always record if specified explicitly for cases such as\n // calling trees/latest during load.\n if (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n event.end({ fromCache: isTokenFromCache(tokenResponse), isNull: token === null });\n }\n if (token === null && throwOnNullToken) {\n throw new NonRetryableError(\n // pre-0.58 error message: Token is null for ${name} call\n `The Host-provided token fetcher returned null`,\n OdspErrorType.fetchTokenError,\n { method: name, driverVersion });\n }\n return token;\n }, (error) => {\n // There is an important but unofficial contract here where token providers can set canRetry: true\n // to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n const rawCanRetry = error?.canRetry;\n const tokenError = wrapError(\n error,\n (errorMessage) => new NetworkErrorBasic(\n `The Host-provided token fetcher threw an error: ${errorMessage}`,\n OdspErrorType.fetchTokenError,\n typeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n { method: name, driverVersion }));\n throw tokenError;\n }),\n { cancel: \"generic\" });\n };\n}\n\nexport function createCacheSnapshotKey(odspResolvedUrl: IOdspResolvedUrl): ICacheEntry {\n const cacheEntry: ICacheEntry = {\n type: snapshotKey,\n key: \"\",\n file: {\n resolvedUrl: odspResolvedUrl,\n docId: odspResolvedUrl.hashedDocumentId,\n },\n };\n return cacheEntry;\n}\n\n// 80KB is the max body size that we can put in ump post body for server to be able to accept it.\n// Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.\nexport const maxUmpPostBodySize = 79872;\n"]}
1
+ {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAgB,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACH,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC7G,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,oCAAoC,GACvC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAGH,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAMhB,WAAW,GAGd,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAG/D,MAAM,CAAC,MAAM,iCAAiC,GAAG,mCAAmC,CAAC;AAErF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,C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AAE,eAAe,CAAC,gBAAgB;SAC1C;KACJ,CAAC;IACF,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,iGAAiG;AACjG,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAExC;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,aAA4D;IACpG,IAAI,CAAC,aAAa,EAAE;QAChB,OAAO;KACV;IACD,MAAM,KAAK,GAAI,aAAkC,CAAC,KAAK,CAAC;IACxD,IAAI,CAAC,KAAK,EAAE;QACR,OAAO,kBAAkB,aAAa,EAAE,CAAC;KAC5C;IACD,IAAI,sBAAsB,GAAG,mBAAmB,KAAK,EAAE,CAAC;IACxD,MAAM,IAAI,GAAI,aAAkC,CAAC,IAAI,CAAC;IACtD,sBAAsB,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,sBAAsB,mBAAmB,IAAI,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC;IAC5G,OAAO,sBAAsB,CAAC;AAClC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties, ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IResolvedUrl, DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n isOnline,\n OnlineStatus,\n RetryableError,\n NonRetryableError,\n NetworkErrorBasic,\n} from \"@fluidframework/driver-utils\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { ChildLogger, PerformanceEvent, TelemetryDataTag, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n fetchIncorrectResponse,\n throwOdspNetworkError,\n getSPOAndGraphRequestIdsFromResponse,\n} from \"@fluidframework/odsp-doclib-utils\";\nimport {\n IOdspResolvedUrl,\n TokenFetchOptions,\n OdspErrorType,\n tokenFromResponse,\n isTokenFromCache,\n OdspResourceTokenFetchOptions,\n ShareLinkTypes,\n ISharingLinkKind,\n TokenFetcher,\n ICacheEntry,\n snapshotKey,\n InstrumentedStorageTokenFetcher,\n IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { fetch } from \"./fetch\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { IOdspSnapshot } from \"./contracts\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/** Parse the given url and return the origin (host name) */\nexport const getOrigin = (url: string) => new URL(url).origin;\n\nexport interface IOdspResponse<T> {\n content: T;\n headers: Map<string, string>;\n propsToLog: ITelemetryProperties;\n duration: number;\n}\n\nexport interface TokenFetchOptionsEx extends TokenFetchOptions {\n /** previous error we hit in getWithRetryForTokenRefresh */\n previousError?: any;\n}\n\nfunction headersToMap(headers: Headers) {\n const newHeaders = new Map<string, string>();\n for (const [key, value] of headers.entries()) {\n newHeaders.set(key, value);\n }\n return newHeaders;\n}\n\n/**\n * This API should be used with pretty much all network calls (fetch, webSocket connection) in order\n * to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch\n * token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors\n * simply propagate to caller\n */\nexport async function getWithRetryForTokenRefresh<T>(get: (options: TokenFetchOptionsEx) => Promise<T>) {\n return get({ refresh: false }).catch(async (e) => {\n const options: TokenFetchOptionsEx = { refresh: true, previousError: e };\n switch (e.errorType) {\n // If the error is 401 or 403 refresh the token and try once more.\n case DriverErrorType.authorizationError:\n return get({ ...options, claims: e.claims, tenantId: e.tenantId });\n\n case DriverErrorType.incorrectServerResponse: // some error on the wire, retry once\n case OdspErrorType.fetchTokenError: // If the token was null, then retry once.\n return get(options);\n\n default:\n // Caller may determine that it wants one retry\n if (e[getWithRetryForTokenRefreshRepeat] === true) {\n return get(options);\n }\n throw e;\n }\n });\n}\n\nexport async function fetchHelper(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n const start = performance.now();\n\n // Node-fetch and dom have conflicting typing, force them to work by casting for now\n return fetch(requestInfo, requestInit).then(async (fetchResponse) => {\n const response = fetchResponse as any as Response;\n // Let's assume we can retry.\n if (!response) {\n throw new NonRetryableError(\n // pre-0.58 error message: No response from fetch call\n \"No response from ODSP fetch call\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n if (!response.ok || response.status < 200 || response.status >= 300) {\n throwOdspNetworkError(\n // pre-0.58 error message prefix: odspFetchError\n `ODSP fetch error [${response.status}]`, response.status, response, await response.text());\n }\n\n const headers = headersToMap(response.headers);\n return {\n content: response,\n headers,\n propsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n duration: performance.now() - start,\n };\n }, (error) => {\n const online = isOnline();\n const errorText = `${error}`;\n const urlRegex = /((http|https):\\/\\/(\\S*))/i;\n const redactedErrorText = errorText.replace(urlRegex, \"REDACTED_URL\");\n // This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n if (error.name === \"AbortError\") {\n throw new RetryableError(\n \"Fetch Timeout (AbortError)\", OdspErrorType.fetchTimeout, { driverVersion });\n }\n // TCP/IP timeout\n if (errorText.includes(\"ETIMEDOUT\")) {\n throw new RetryableError(\n \"Fetch Timeout (ETIMEDOUT)\", OdspErrorType.fetchTimeout, { driverVersion });\n }\n\n // WARNING: Do not log error object itself or any of its properties!\n // It could contain PII, like URI in message itself, or token in properties.\n // It is also non-serializable object due to circular references.\n // eslint-disable-next-line unicorn/prefer-ternary\n if (online === OnlineStatus.Offline) {\n throw new RetryableError(\n // pre-0.58 error message prefix: Offline\n `ODSP fetch failure (Offline): ${redactedErrorText}`,\n DriverErrorType.offlineError,\n {\n driverVersion,\n rawErrorMessage: { value: errorText, tag: TelemetryDataTag.UserData },\n });\n } else {\n // It is perhaps still possible that this is due to being offline, the error does not reveal enough\n // information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n throw new RetryableError(\n // pre-0.58 error message prefix: Fetch error\n `ODSP fetch failure: ${redactedErrorText}`,\n DriverErrorType.fetchFailure,\n {\n driverVersion,\n rawErrorMessage: { value: errorText, tag: TelemetryDataTag.UserData },\n });\n }\n });\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchArray(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n const { content, headers, propsToLog, duration } = await fetchHelper(requestInfo, requestInit);\n\n const arrayBuffer = await content.arrayBuffer();\n propsToLog.bodySize = arrayBuffer.byteLength;\n return {\n headers,\n content: arrayBuffer,\n propsToLog,\n duration,\n };\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchAndParseAsJSONHelper<T>(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n const { content, headers, propsToLog, duration } = await fetchHelper(requestInfo, requestInit);\n let text: string | undefined;\n try {\n text = await content.text();\n } catch (e) {\n // JSON.parse() can fail and message would container full request URI, including\n // tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n // (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n // succeeds on retry.\n // So do not log error object itself.\n throwOdspNetworkError(\n // pre-0.58 error message: errorWhileParsingFetchResponse\n \"Error while parsing fetch response\",\n fetchIncorrectResponse,\n content, // response\n text,\n );\n }\n\n propsToLog.bodySize = text.length;\n const res = {\n headers,\n content: JSON.parse(text),\n propsToLog,\n duration,\n };\n return res;\n}\n\nexport interface INewFileInfo {\n siteUrl: string;\n driveId: string;\n filename: string;\n filePath: string;\n /**\n * application can request creation of a share link along with the creation of a new file\n * by passing in an optional param to specify the kind of sharing link\n * (at the time of adding this comment Sept/2021), odsp only supports csl\n * ShareLinkTypes will deprecated in future. Use ISharingLinkKind instead which specifies both\n * share link type and the role type.\n */\n createLinkType?: ShareLinkTypes | ISharingLinkKind;\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n assert((resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true, 0x1de /* \"Not an ODSP resolved url\" */);\n return resolvedUrl as IOdspResolvedUrl;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger) =>\n ChildLogger.create(\n logger,\n \"OdspDriver\",\n {\n all:\n {\n driverVersion,\n },\n });\n\nexport function evalBlobsAndTrees(snapshot: IOdspSnapshot) {\n let numTrees = 0;\n let numBlobs = 0;\n let encodedBlobsSize = 0;\n let decodedBlobsSize = 0;\n for (const tree of snapshot.trees) {\n for (const treeEntry of tree.entries) {\n if (treeEntry.type === \"blob\") {\n numBlobs++;\n } else if (treeEntry.type === \"tree\") {\n numTrees++;\n }\n }\n }\n if (snapshot.blobs !== undefined) {\n for (const blob of snapshot.blobs) {\n decodedBlobsSize += blob.size;\n encodedBlobsSize += blob.content.length;\n }\n }\n return { numTrees, numBlobs, encodedBlobsSize, decodedBlobsSize };\n}\n\nexport function toInstrumentedOdspTokenFetcher(\n logger: ITelemetryLogger,\n resolvedUrlParts: IOdspUrlParts,\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n throwOnNullToken: boolean,\n): InstrumentedStorageTokenFetcher {\n return async (options: TokenFetchOptions, name: string, alwaysRecordTokenFetchTelemetry: boolean = false) => {\n // Telemetry note: if options.refresh is true, there is a potential perf issue:\n // Host should optimize and provide non-expired tokens on all critical paths.\n // Exceptions: race conditions around expiration, revoked tokens, host that does not care\n // (fluid-fetcher)\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: `${name}_GetToken`,\n attempts: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n },\n async (event) => tokenFetcher({\n ...options,\n ...resolvedUrlParts,\n }).then((tokenResponse) => {\n const token = tokenFromResponse(tokenResponse);\n // This event alone generates so many events that is materially impacts cost of telemetry\n // Thus do not report end event when it comes back quickly.\n // Note that most of the hosts do not report if result is comming from cache or not,\n // so we can't rely on that here. But always record if specified explicitly for cases such as\n // calling trees/latest during load.\n if (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n event.end({ fromCache: isTokenFromCache(tokenResponse), isNull: token === null });\n }\n if (token === null && throwOnNullToken) {\n throw new NonRetryableError(\n // pre-0.58 error message: Token is null for ${name} call\n `The Host-provided token fetcher returned null`,\n OdspErrorType.fetchTokenError,\n { method: name, driverVersion });\n }\n return token;\n }, (error) => {\n // There is an important but unofficial contract here where token providers can set canRetry: true\n // to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n const rawCanRetry = error?.canRetry;\n const tokenError = wrapError(\n error,\n (errorMessage) => new NetworkErrorBasic(\n `The Host-provided token fetcher threw an error: ${errorMessage}`,\n OdspErrorType.fetchTokenError,\n typeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n { method: name, driverVersion }));\n throw tokenError;\n }),\n { cancel: \"generic\" });\n };\n}\n\nexport function createCacheSnapshotKey(odspResolvedUrl: IOdspResolvedUrl): ICacheEntry {\n const cacheEntry: ICacheEntry = {\n type: snapshotKey,\n key: \"\",\n file: {\n resolvedUrl: odspResolvedUrl,\n docId: odspResolvedUrl.hashedDocumentId,\n },\n };\n return cacheEntry;\n}\n\n// 80KB is the max body size that we can put in ump post body for server to be able to accept it.\n// Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.\nexport const maxUmpPostBodySize = 79872;\n\n/**\n * Build request parameters to request for the creation of a sharing link along with the creation of the file\n * through the /snapshot api call.\n * @param shareLinkType - Kind of sharing link requested\n * @returns A string of request parameters that can be concatenated with the base URI\n */\nexport function buildOdspShareLinkReqParams(shareLinkType: ShareLinkTypes | ISharingLinkKind | undefined) {\n if (!shareLinkType) {\n return;\n }\n const scope = (shareLinkType as ISharingLinkKind).scope;\n if (!scope) {\n return `createLinkType=${shareLinkType}`;\n }\n let shareLinkRequestParams = `createLinkScope=${scope}`;\n const role = (shareLinkType as ISharingLinkKind).role;\n shareLinkRequestParams = role ? `${shareLinkRequestParams}&createLinkRole=${role}` : shareLinkRequestParams;\n return shareLinkRequestParams;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"opsCaching.d.ts","sourceRoot":"","sources":["../src/opsCaching.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAItE,MAAM,WAAW,QAAQ;IACrB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,oBAAY,UAAU,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,EAAE,CAAC;AAElD,MAAM,WAAW,MAAM;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,UAAU,CAAC;IACtB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACvD,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qBAAa,QAAQ;IAMjB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,eAAe;IATzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;IACjE,OAAO,CAAC,KAAK,CAA4C;gBAGvD,sBAAsB,EAAE,MAAM,EACb,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,gBAAgB,KAAA,EACzB,eAAe,KAAA;IAehB,OAAO;IAQP,QAAQ;IAUR,MAAM,CAAC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CAAC,OAAO,CAAyC;IACjE,OAAO,CAAC,KAAK,CAA4C;gBAGvD,sBAAsB,EAAE,MAAM,EACb,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,gBAAgB,KAAA,EACzB,eAAe,KAAA;IAgBhB,OAAO;IAQP,QAAQ;IAUR,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE;IA8C7B;;;;;OAKG;YACY,OAAO;IAiCtB;;;;;OAKG;IACU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAkBhE,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAQpD,SAAS,CAAC,aAAa;IASvB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,2BAA2B;CAKtC"}
package/lib/opsCaching.js CHANGED
@@ -11,8 +11,9 @@ export class OpsCache {
11
11
  this.timerGranularity = timerGranularity;
12
12
  this.totalOpsToCache = totalOpsToCache;
13
13
  this.batches = new Map();
14
- /** initial batch is a special case because it will never be full - all ops prior (inclusive) to
15
- * startingSequenceNumber are never going to show up (undefined)
14
+ /**
15
+ * Initial batch is a special case because it will never be full - all ops prior (inclusive) to
16
+ * `startingSequenceNumber` are never going to show up (undefined)
16
17
  */
17
18
  const remainingSlots = this.batchSize - this.getPositionInBatchArray(startingSequenceNumber) - 1;
18
19
  if (remainingSlots !== 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"opsCaching.js","sourceRoot":"","sources":["../src/opsCaching.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAwB3D,MAAM,OAAO,QAAQ;IAInB,YACE,sBAA8B,EACb,MAAwB,EACxB,KAAa,EACb,SAAiB,EACjB,gBAAgB,EACzB,eAAe;QA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;IACvD,CAAC;IAEO,uBAAuB,CAAC,cAAsB;QAClD,OAAO,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC;IAC3C,CAAC;IAEO,2BAA2B;QAC/B,MAAM,SAAS,GAAe,EAAE,CAAC;QACjC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,sCAAsC;QACzE,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","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 { performance } from \"@fluidframework/common-utils\";\n\n// ISequencedDocumentMessage\nexport interface IMessage {\n sequenceNumber: number;\n}\n\nexport type CacheEntry = (IMessage | undefined)[];\n\nexport interface IBatch {\n remainingSlots: number;\n batchData: CacheEntry;\n /**\n * Tells if this batch is dirty, i.e. it contains ops that were not flushed to cache\n */\n dirty: boolean;\n}\n\nexport interface ICache {\n write(batchNumber: string, data: string): Promise<void>;\n read(batchNumber: string): Promise<string | undefined>;\n remove(): void;\n}\n\nexport class OpsCache {\n private readonly batches: Map<number, null | IBatch> = new Map();\n private timer: ReturnType<typeof setTimeout> | undefined;\n\n constructor(\n startingSequenceNumber: number,\n private readonly logger: ITelemetryLogger,\n private readonly cache: ICache,\n private readonly batchSize: number,\n private readonly timerGranularity,\n private totalOpsToCache,\n ) {\n /** initial batch is a special case because it will never be full - all ops prior (inclusive) to\n * startingSequenceNumber are never going to show up (undefined)\n */\n const remainingSlots = this.batchSize - this.getPositionInBatchArray(startingSequenceNumber) - 1;\n if (remainingSlots !== 0) {\n this.batches.set(this.getBatchNumber(startingSequenceNumber), {\n remainingSlots,\n batchData: this.initializeNewBatchDataArray(),\n dirty: false,\n });\n }\n }\n\n public dispose() {\n this.batches.clear();\n if (this.timer !== undefined) {\n clearTimeout(this.timer);\n this.timer = undefined;\n }\n }\n\n public flushOps() {\n for (const [key, value] of this.batches) {\n if (value === null || !value.dirty) {\n continue;\n }\n value.dirty = false;\n this.write(key, value);\n }\n }\n\n public addOps(ops: IMessage[]) {\n if (this.totalOpsToCache <= 0) {\n return;\n }\n\n for (const op of ops) {\n const batchNumber = this.getBatchNumber(op.sequenceNumber);\n const positionInBatch = this.getPositionInBatchArray(op.sequenceNumber);\n\n let currentBatch = this.batches.get(batchNumber);\n\n if (currentBatch === undefined) {\n currentBatch = {\n remainingSlots: this.batchSize - 1,\n batchData: this.initializeNewBatchDataArray(),\n dirty: true,\n };\n currentBatch.batchData[positionInBatch] = op;\n this.batches.set(batchNumber, currentBatch);\n } else if (currentBatch !== null && currentBatch.batchData[positionInBatch] === undefined) {\n currentBatch.batchData[positionInBatch] = op;\n currentBatch.remainingSlots--;\n currentBatch.dirty = true;\n } else {\n // Either batch was flushed or this op was already there - nothing to do!\n return;\n }\n\n if (currentBatch.remainingSlots === 0) {\n // batch is full, flush to cache\n this.write(batchNumber, currentBatch);\n this.batches.set(batchNumber, null);\n } else {\n this.scheduleTimer();\n }\n\n this.totalOpsToCache--;\n if (this.totalOpsToCache === 0) {\n this.logger.sendPerformanceEvent({ eventName: \"CacheOpsLimitHit\" });\n this.cache.remove();\n this.dispose();\n break;\n }\n }\n }\n\n /**\n * Retrieves ops from cache\n * @param from - inclusive\n * @param to - exclusive\n * @returns ops retrieved\n */\n private async getCore(from: number, to?: number): Promise<IMessage[]> {\n const messages: IMessage[] = [];\n let batchNumber = this.getBatchNumber(from);\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const res = await this.cache.read(`${this.batchSize}_${batchNumber}`);\n if (res === undefined) {\n return messages;\n }\n const result: CacheEntry = JSON.parse(res);\n for (const op of result) {\n // Note that we write out undefined, but due to JSON.stringify, it turns into null!\n if (op) {\n if (to !== undefined && op.sequenceNumber >= to) {\n return messages;\n }\n if (messages.length === 0) {\n if (op.sequenceNumber > from) {\n return messages;\n } else if (op.sequenceNumber < from) {\n continue;\n }\n }\n messages.push(op);\n } else if (messages.length !== 0) {\n return messages;\n }\n }\n\n batchNumber++;\n }\n }\n\n /**\n * Retrieves ops from cache\n * @param from - inclusive\n * @param to - exclusive\n * @returns ops retrieved\n */\n public async get(from: number, to?: number): Promise<IMessage[]> {\n const start = performance.now();\n\n const messages = await this.getCore(from, to);\n\n const duration = performance.now() - start;\n if (messages.length > 0 || duration > 1000) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsUsed\",\n from,\n to,\n length: messages.length,\n duration,\n });\n }\n return messages;\n }\n\n protected write(batchNumber: number, payload: IBatch) {\n // Errors are caught and logged by PersistedCacheWithErrorHandling that sits\n // in the adapter chain of cache adapters\n this.cache.write(`${this.batchSize}_${batchNumber}`, JSON.stringify(payload.batchData)).catch(() => {\n this.totalOpsToCache = 0;\n });\n }\n\n protected scheduleTimer() {\n if (!this.timer && this.timerGranularity > 0) {\n this.timer = setTimeout(() => {\n this.timer = undefined;\n this.flushOps();\n }, this.timerGranularity);\n }\n }\n\n private getBatchNumber(sequenceNumber: number) {\n return Math.floor(sequenceNumber / this.batchSize);\n }\n\n private getPositionInBatchArray(sequenceNumber: number) {\n return sequenceNumber % this.batchSize;\n }\n\n private initializeNewBatchDataArray() {\n const tempArray: IMessage[] = [];\n tempArray.length = this.batchSize; // fill with empty, undefined elements\n return tempArray;\n }\n}\n"]}
1
+ {"version":3,"file":"opsCaching.js","sourceRoot":"","sources":["../src/opsCaching.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAwB3D,MAAM,OAAO,QAAQ;IAInB,YACE,sBAA8B,EACb,MAAwB,EACxB,KAAa,EACb,SAAiB,EACjB,gBAAgB,EACzB,eAAe;QAJN,WAAM,GAAN,MAAM,CAAkB;QACxB,UAAK,GAAL,KAAK,CAAQ;QACb,cAAS,GAAT,SAAS,CAAQ;QACjB,qBAAgB,GAAhB,gBAAgB,CAAA;QACzB,oBAAe,GAAf,eAAe,CAAA;QATR,YAAO,GAA+B,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AM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,sCAAsC;QACzE,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ","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 { performance } from \"@fluidframework/common-utils\";\n\n// ISequencedDocumentMessage\nexport interface IMessage {\n sequenceNumber: number;\n}\n\nexport type CacheEntry = (IMessage | undefined)[];\n\nexport interface IBatch {\n remainingSlots: number;\n batchData: CacheEntry;\n /**\n * Tells if this batch is dirty, i.e. it contains ops that were not flushed to cache\n */\n dirty: boolean;\n}\n\nexport interface ICache {\n write(batchNumber: string, data: string): Promise<void>;\n read(batchNumber: string): Promise<string | undefined>;\n remove(): void;\n}\n\nexport class OpsCache {\n private readonly batches: Map<number, null | IBatch> = new Map();\n private timer: ReturnType<typeof setTimeout> | undefined;\n\n constructor(\n startingSequenceNumber: number,\n private readonly logger: ITelemetryLogger,\n private readonly cache: ICache,\n private readonly batchSize: number,\n private readonly timerGranularity,\n private totalOpsToCache,\n ) {\n /**\n * Initial batch is a special case because it will never be full - all ops prior (inclusive) to\n * `startingSequenceNumber` are never going to show up (undefined)\n */\n const remainingSlots = this.batchSize - this.getPositionInBatchArray(startingSequenceNumber) - 1;\n if (remainingSlots !== 0) {\n this.batches.set(this.getBatchNumber(startingSequenceNumber), {\n remainingSlots,\n batchData: this.initializeNewBatchDataArray(),\n dirty: false,\n });\n }\n }\n\n public dispose() {\n this.batches.clear();\n if (this.timer !== undefined) {\n clearTimeout(this.timer);\n this.timer = undefined;\n }\n }\n\n public flushOps() {\n for (const [key, value] of this.batches) {\n if (value === null || !value.dirty) {\n continue;\n }\n value.dirty = false;\n this.write(key, value);\n }\n }\n\n public addOps(ops: IMessage[]) {\n if (this.totalOpsToCache <= 0) {\n return;\n }\n\n for (const op of ops) {\n const batchNumber = this.getBatchNumber(op.sequenceNumber);\n const positionInBatch = this.getPositionInBatchArray(op.sequenceNumber);\n\n let currentBatch = this.batches.get(batchNumber);\n\n if (currentBatch === undefined) {\n currentBatch = {\n remainingSlots: this.batchSize - 1,\n batchData: this.initializeNewBatchDataArray(),\n dirty: true,\n };\n currentBatch.batchData[positionInBatch] = op;\n this.batches.set(batchNumber, currentBatch);\n } else if (currentBatch !== null && currentBatch.batchData[positionInBatch] === undefined) {\n currentBatch.batchData[positionInBatch] = op;\n currentBatch.remainingSlots--;\n currentBatch.dirty = true;\n } else {\n // Either batch was flushed or this op was already there - nothing to do!\n return;\n }\n\n if (currentBatch.remainingSlots === 0) {\n // batch is full, flush to cache\n this.write(batchNumber, currentBatch);\n this.batches.set(batchNumber, null);\n } else {\n this.scheduleTimer();\n }\n\n this.totalOpsToCache--;\n if (this.totalOpsToCache === 0) {\n this.logger.sendPerformanceEvent({ eventName: \"CacheOpsLimitHit\" });\n this.cache.remove();\n this.dispose();\n break;\n }\n }\n }\n\n /**\n * Retrieves ops from cache\n * @param from - inclusive\n * @param to - exclusive\n * @returns ops retrieved\n */\n private async getCore(from: number, to?: number): Promise<IMessage[]> {\n const messages: IMessage[] = [];\n let batchNumber = this.getBatchNumber(from);\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const res = await this.cache.read(`${this.batchSize}_${batchNumber}`);\n if (res === undefined) {\n return messages;\n }\n const result: CacheEntry = JSON.parse(res);\n for (const op of result) {\n // Note that we write out undefined, but due to JSON.stringify, it turns into null!\n if (op) {\n if (to !== undefined && op.sequenceNumber >= to) {\n return messages;\n }\n if (messages.length === 0) {\n if (op.sequenceNumber > from) {\n return messages;\n } else if (op.sequenceNumber < from) {\n continue;\n }\n }\n messages.push(op);\n } else if (messages.length !== 0) {\n return messages;\n }\n }\n\n batchNumber++;\n }\n }\n\n /**\n * Retrieves ops from cache\n * @param from - inclusive\n * @param to - exclusive\n * @returns ops retrieved\n */\n public async get(from: number, to?: number): Promise<IMessage[]> {\n const start = performance.now();\n\n const messages = await this.getCore(from, to);\n\n const duration = performance.now() - start;\n if (messages.length > 0 || duration > 1000) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsUsed\",\n from,\n to,\n length: messages.length,\n duration,\n });\n }\n return messages;\n }\n\n protected write(batchNumber: number, payload: IBatch) {\n // Errors are caught and logged by PersistedCacheWithErrorHandling that sits\n // in the adapter chain of cache adapters\n this.cache.write(`${this.batchSize}_${batchNumber}`, JSON.stringify(payload.batchData)).catch(() => {\n this.totalOpsToCache = 0;\n });\n }\n\n protected scheduleTimer() {\n if (!this.timer && this.timerGranularity > 0) {\n this.timer = setTimeout(() => {\n this.timer = undefined;\n this.flushOps();\n }, this.timerGranularity);\n }\n }\n\n private getBatchNumber(sequenceNumber: number) {\n return Math.floor(sequenceNumber / this.batchSize);\n }\n\n private getPositionInBatchArray(sequenceNumber: number) {\n return sequenceNumber % this.batchSize;\n }\n\n private initializeNewBatchDataArray() {\n const tempArray: IMessage[] = [];\n tempArray.length = this.batchSize; // fill with empty, undefined elements\n return tempArray;\n }\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/odsp-driver";
8
- export declare const pkgVersion = "1.3.0";
8
+ export declare const pkgVersion = "2.0.0-dev.1.4.5.105745";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,UAAU,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,2BAA2B,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/odsp-driver";
8
- export const pkgVersion = "1.3.0";
8
+ export const pkgVersion = "2.0.0-dev.1.4.5.105745";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"1.3.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"2.0.0-dev.1.4.5.105745\";\n"]}
@@ -9,19 +9,21 @@ import { SnapshotFormatSupportType } from "./fetchSnapshot";
9
9
  /**
10
10
  * Function to prefetch the snapshot and cached it in the persistant cache, so that when the container is loaded
11
11
  * the cached latest snapshot could be used and removes the network call from the critical path.
12
+ *
12
13
  * @param resolvedUrl - Resolved url to fetch the snapshot.
13
14
  * @param getStorageToken - function that can provide the storage token for a given site. This is
14
- * is also referred to as the "VROOM" token in SPO.
15
+ * is also referred to as the "VROOM" token in SPO.
15
16
  * @param persistedCache - Cache to store the fetched snapshot.
16
17
  * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header.
17
18
  * @param logger - Logger to have telemetry events.
18
19
  * @param hostSnapshotFetchOptions - Options to fetch the snapshot if any. Otherwise default will be used.
19
20
  * @param enableRedeemFallback - True to have the sharing link redeem fallback in case the Trees Latest/Redeem
20
- * 1RT call fails with redeem error. During fallback it will first redeem the sharing link and then make
21
- * the Trees latest call.
22
- * @deprecated - This will be replaced with snapshotFormatFetchType.
21
+ * 1RT call fails with redeem error. During fallback it will first redeem the sharing link and then make
22
+ * the Trees latest call.
23
+ * Note: this can be considered deprecated - it will be replaced with `snapshotFormatFetchType`.
23
24
  * @param fetchBinarySnapshotFormat - Control if we want to fetch binary format snapshot.
24
25
  * @param snapshotFormatFetchType - Snapshot format to fetch.
26
+ *
25
27
  * @returns - True if the snapshot is cached, false otherwise.
26
28
  */
27
29
  export declare function prefetchLatestSnapshot(resolvedUrl: IResolvedUrl, getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, persistedCache: IPersistedCache, forceAccessTokenViaAuthorizationHeader: boolean, logger: ITelemetryBaseLogger, hostSnapshotFetchOptions: ISnapshotOptions | undefined, enableRedeemFallback?: boolean, fetchBinarySnapshotFormat?: boolean, snapshotFormatFetchType?: SnapshotFormatSupportType): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"prefetchLatestSnapshot.d.ts","sourceRoot":"","sources":["../src/prefetchLatestSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAEH,eAAe,EACf,gBAAgB,EAChB,6BAA6B,EAC7B,YAAY,EAEf,MAAM,yCAAyC,CAAC;AAQjD,OAAO,EAA6C,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAGvG;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,sBAAsB,CACxC,WAAW,EAAE,YAAY,EACzB,eAAe,EAAE,YAAY,CAAC,6BAA6B,CAAC,EAC5D,cAAc,EAAE,eAAe,EAC/B,sCAAsC,EAAE,OAAO,EAC/C,MAAM,EAAE,oBAAoB,EAC5B,wBAAwB,EAAE,gBAAgB,GAAG,SAAS,EACtD,oBAAoB,GAAE,OAAc,EACpC,yBAAyB,CAAC,EAAE,OAAO,EACnC,uBAAuB,CAAC,EAAE,yBAAyB,GACpD,OAAO,CAAC,OAAO,CAAC,CAsDlB"}
1
+ {"version":3,"file":"prefetchLatestSnapshot.d.ts","sourceRoot":"","sources":["../src/prefetchLatestSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAEH,eAAe,EACf,gBAAgB,EAChB,6BAA6B,EAC7B,YAAY,EAEf,MAAM,yCAAyC,CAAC;AAQjD,OAAO,EAA6C,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAGvG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,sBAAsB,CACxC,WAAW,EAAE,YAAY,EACzB,eAAe,EAAE,YAAY,CAAC,6BAA6B,CAAC,EAC5D,cAAc,EAAE,eAAe,EAC/B,sCAAsC,EAAE,OAAO,EAC/C,MAAM,EAAE,oBAAoB,EAC5B,wBAAwB,EAAE,gBAAgB,GAAG,SAAS,EACtD,oBAAoB,GAAE,OAAc,EACpC,yBAAyB,CAAC,EAAE,OAAO,EACnC,uBAAuB,CAAC,EAAE,yBAAyB,GACpD,OAAO,CAAC,OAAO,CAAC,CAsDlB"}
@@ -9,19 +9,21 @@ import { downloadSnapshot, fetchSnapshotWithRedeem } from "./fetchSnapshot";
9
9
  /**
10
10
  * Function to prefetch the snapshot and cached it in the persistant cache, so that when the container is loaded
11
11
  * the cached latest snapshot could be used and removes the network call from the critical path.
12
+ *
12
13
  * @param resolvedUrl - Resolved url to fetch the snapshot.
13
14
  * @param getStorageToken - function that can provide the storage token for a given site. This is
14
- * is also referred to as the "VROOM" token in SPO.
15
+ * is also referred to as the "VROOM" token in SPO.
15
16
  * @param persistedCache - Cache to store the fetched snapshot.
16
17
  * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header.
17
18
  * @param logger - Logger to have telemetry events.
18
19
  * @param hostSnapshotFetchOptions - Options to fetch the snapshot if any. Otherwise default will be used.
19
20
  * @param enableRedeemFallback - True to have the sharing link redeem fallback in case the Trees Latest/Redeem
20
- * 1RT call fails with redeem error. During fallback it will first redeem the sharing link and then make
21
- * the Trees latest call.
22
- * @deprecated - This will be replaced with snapshotFormatFetchType.
21
+ * 1RT call fails with redeem error. During fallback it will first redeem the sharing link and then make
22
+ * the Trees latest call.
23
+ * Note: this can be considered deprecated - it will be replaced with `snapshotFormatFetchType`.
23
24
  * @param fetchBinarySnapshotFormat - Control if we want to fetch binary format snapshot.
24
25
  * @param snapshotFormatFetchType - Snapshot format to fetch.
26
+ *
25
27
  * @returns - True if the snapshot is cached, false otherwise.
26
28
  */
27
29
  export async function prefetchLatestSnapshot(resolvedUrl, getStorageToken, persistedCache, forceAccessTokenViaAuthorizationHeader, logger, hostSnapshotFetchOptions, enableRedeemFallback = true, fetchBinarySnapshotFormat, snapshotFormatFetchType) {
@@ -1 +1 @@
1
- {"version":3,"file":"prefetchLatestSnapshot.js","sourceRoot":"","sources":["../src/prefetchLatestSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAUtD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EA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AI,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACjF,OAAO,gBAAgB,CAAC,cAAc,CAClC,UAAU,EACV,EAAE,SAAS,EAAE,wBAAwB,EAAE,EACvC,KAAK,IAAI,EAAE;QACP,MAAM,uBAAuB,CACrB,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,sCAAsC,EACtC,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,oBAAoB,CACvB,CAAC;QACN,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACvE,MAAM,MAAM,CAAC;QACb,OAAO,IAAI,CAAC;IACpB,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC","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 { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport {\n IOdspResolvedUrl,\n IPersistedCache,\n ISnapshotOptions,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ChildLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n createCacheSnapshotKey,\n createOdspLogger,\n getOdspResolvedUrl,\n toInstrumentedOdspTokenFetcher,\n} from \"./odspUtils\";\nimport { downloadSnapshot, fetchSnapshotWithRedeem, SnapshotFormatSupportType } from \"./fetchSnapshot\";\nimport { IVersionedValueWithEpoch } from \"./contracts\";\n\n/**\n * Function to prefetch the snapshot and cached it in the persistant cache, so that when the container is loaded\n * the cached latest snapshot could be used and removes the network call from the critical path.\n * @param resolvedUrl - Resolved url to fetch the snapshot.\n * @param getStorageToken - function that can provide the storage token for a given site. This is\n * is also referred to as the \"VROOM\" token in SPO.\n * @param persistedCache - Cache to store the fetched snapshot.\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header.\n * @param logger - Logger to have telemetry events.\n * @param hostSnapshotFetchOptions - Options to fetch the snapshot if any. Otherwise default will be used.\n * @param enableRedeemFallback - True to have the sharing link redeem fallback in case the Trees Latest/Redeem\n * 1RT call fails with redeem error. During fallback it will first redeem the sharing link and then make\n * the Trees latest call.\n * @deprecated - This will be replaced with snapshotFormatFetchType.\n * @param fetchBinarySnapshotFormat - Control if we want to fetch binary format snapshot.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @returns - True if the snapshot is cached, false otherwise.\n */\nexport async function prefetchLatestSnapshot(\n resolvedUrl: IResolvedUrl,\n getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n persistedCache: IPersistedCache,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryBaseLogger,\n hostSnapshotFetchOptions: ISnapshotOptions | undefined,\n enableRedeemFallback: boolean = true,\n fetchBinarySnapshotFormat?: boolean,\n snapshotFormatFetchType?: SnapshotFormatSupportType,\n): Promise<boolean> {\n const odspLogger = createOdspLogger(ChildLogger.create(logger, \"PrefetchSnapshot\"));\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n getStorageToken,\n true /* throwOnNullToken */,\n );\n\n const snapshotDownloader = async (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => {\n return downloadSnapshot(\n finalOdspResolvedUrl, storageToken, odspLogger, snapshotOptions, snapshotFormatFetchType, controller);\n };\n const snapshotKey = createCacheSnapshotKey(odspResolvedUrl);\n let cacheP: Promise<void> | undefined;\n const putInCache = async (valueWithEpoch: IVersionedValueWithEpoch) => {\n cacheP = persistedCache.put(\n snapshotKey,\n valueWithEpoch,\n );\n return cacheP;\n };\n const removeEntries = async () => persistedCache.removeEntries(snapshotKey.file);\n return PerformanceEvent.timedExecAsync(\n odspLogger,\n { eventName: \"PrefetchLatestSnapshot\" },\n async () => {\n await fetchSnapshotWithRedeem(\n odspResolvedUrl,\n storageTokenFetcher,\n hostSnapshotFetchOptions,\n forceAccessTokenViaAuthorizationHeader,\n odspLogger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n enableRedeemFallback,\n );\n assert(cacheP !== undefined, 0x1e7 /* \"caching was not performed!\" */);\n await cacheP;\n return true;\n }).catch(async (error) => false);\n}\n"]}
1
+ {"version":3,"file":"prefetchLatestSnapshot.js","sourceRoot":"","sources":["../src/prefetchLatestSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAUtD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,8BAA8B,GACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAA6B,MAAM,iBAAiB,CAAC;AAGvG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CACxC,WAAyB,EACzB,eAA4D,EAC5D,cAA+B,EAC/B,sCAA+C,EAC/C,MAA4B,EAC5B,wBAAsD,EACtD,uBAAgC,IAAI,EACpC,yBAAmC,EACnC,uBAAmD;IAEnD,MAAM,UAAU,GAAG,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACpF,M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ACb,OAAO,IAAI,CAAC;IACpB,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC","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 { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport {\n IOdspResolvedUrl,\n IPersistedCache,\n ISnapshotOptions,\n OdspResourceTokenFetchOptions,\n TokenFetcher,\n IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ChildLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n createCacheSnapshotKey,\n createOdspLogger,\n getOdspResolvedUrl,\n toInstrumentedOdspTokenFetcher,\n} from \"./odspUtils\";\nimport { downloadSnapshot, fetchSnapshotWithRedeem, SnapshotFormatSupportType } from \"./fetchSnapshot\";\nimport { IVersionedValueWithEpoch } from \"./contracts\";\n\n/**\n * Function to prefetch the snapshot and cached it in the persistant cache, so that when the container is loaded\n * the cached latest snapshot could be used and removes the network call from the critical path.\n *\n * @param resolvedUrl - Resolved url to fetch the snapshot.\n * @param getStorageToken - function that can provide the storage token for a given site. This is\n * is also referred to as the \"VROOM\" token in SPO.\n * @param persistedCache - Cache to store the fetched snapshot.\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header.\n * @param logger - Logger to have telemetry events.\n * @param hostSnapshotFetchOptions - Options to fetch the snapshot if any. Otherwise default will be used.\n * @param enableRedeemFallback - True to have the sharing link redeem fallback in case the Trees Latest/Redeem\n * 1RT call fails with redeem error. During fallback it will first redeem the sharing link and then make\n * the Trees latest call.\n * Note: this can be considered deprecated - it will be replaced with `snapshotFormatFetchType`.\n * @param fetchBinarySnapshotFormat - Control if we want to fetch binary format snapshot.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n *\n * @returns - True if the snapshot is cached, false otherwise.\n */\nexport async function prefetchLatestSnapshot(\n resolvedUrl: IResolvedUrl,\n getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n persistedCache: IPersistedCache,\n forceAccessTokenViaAuthorizationHeader: boolean,\n logger: ITelemetryBaseLogger,\n hostSnapshotFetchOptions: ISnapshotOptions | undefined,\n enableRedeemFallback: boolean = true,\n fetchBinarySnapshotFormat?: boolean,\n snapshotFormatFetchType?: SnapshotFormatSupportType,\n): Promise<boolean> {\n const odspLogger = createOdspLogger(ChildLogger.create(logger, \"PrefetchSnapshot\"));\n const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n const resolvedUrlData: IOdspUrlParts = {\n siteUrl: odspResolvedUrl.siteUrl,\n driveId: odspResolvedUrl.driveId,\n itemId: odspResolvedUrl.itemId,\n };\n const storageTokenFetcher = toInstrumentedOdspTokenFetcher(\n odspLogger,\n resolvedUrlData,\n getStorageToken,\n true /* throwOnNullToken */,\n );\n\n const snapshotDownloader = async (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n snapshotOptions: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => {\n return downloadSnapshot(\n finalOdspResolvedUrl, storageToken, odspLogger, snapshotOptions, snapshotFormatFetchType, controller);\n };\n const snapshotKey = createCacheSnapshotKey(odspResolvedUrl);\n let cacheP: Promise<void> | undefined;\n const putInCache = async (valueWithEpoch: IVersionedValueWithEpoch) => {\n cacheP = persistedCache.put(\n snapshotKey,\n valueWithEpoch,\n );\n return cacheP;\n };\n const removeEntries = async () => persistedCache.removeEntries(snapshotKey.file);\n return PerformanceEvent.timedExecAsync(\n odspLogger,\n { eventName: \"PrefetchLatestSnapshot\" },\n async () => {\n await fetchSnapshotWithRedeem(\n odspResolvedUrl,\n storageTokenFetcher,\n hostSnapshotFetchOptions,\n forceAccessTokenViaAuthorizationHeader,\n odspLogger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n enableRedeemFallback,\n );\n assert(cacheP !== undefined, 0x1e7 /* \"caching was not performed!\" */);\n await cacheP;\n return true;\n }).catch(async (error) => false);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"retryUtils.d.ts","sourceRoot":"","sources":["../src/retryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,EACxB,aAAa,CAAC,EAAE,MAAM,IAAI,GAC3B,OAAO,CAAC,CAAC,CAAC,CAsDZ"}
1
+ {"version":3,"file":"retryUtils.d.ts","sourceRoot":"","sources":["../src/retryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,EACxB,aAAa,CAAC,EAAE,MAAM,IAAI,GAC3B,OAAO,CAAC,CAAC,CAAC,CAyDZ"}
package/lib/retryUtils.js CHANGED
@@ -3,13 +3,14 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { delay, performance } from "@fluidframework/common-utils";
6
- import { canRetryOnError } from "@fluidframework/driver-utils";
6
+ import { canRetryOnError, getRetryDelayFromError } from "@fluidframework/driver-utils";
7
7
  import { OdspErrorType } from "@fluidframework/odsp-driver-definitions";
8
8
  import { Odsp409Error } from "./epochTracker";
9
9
  /**
10
10
  * This method retries only for retriable coherency and service read only errors.
11
11
  */
12
12
  export async function runWithRetry(api, callName, logger, checkDisposed) {
13
+ var _a;
13
14
  let retryAfter = 1000;
14
15
  const start = performance.now();
15
16
  let lastError;
@@ -33,8 +34,10 @@ export async function runWithRetry(api, callName, logger, checkDisposed) {
33
34
  const canRetry = canRetryOnError(error);
34
35
  const coherencyError = (error === null || error === void 0 ? void 0 : error[Odsp409Error]) === true;
35
36
  const serviceReadonlyError = (error === null || error === void 0 ? void 0 : error.errorType) === OdspErrorType.serviceReadOnly;
36
- // Retry for retriable 409 coherency errors or serviceReadOnly errors.
37
- if (!(coherencyError || serviceReadonlyError || canRetry)) {
37
+ // Retry for retriable 409 coherency errors or serviceReadOnly errors. These errors are always retriable
38
+ // unless someone specifically set canRetry = false on the error like in fetchSnapshot() flow. So in
39
+ // that case don't retry.
40
+ if (!((coherencyError || serviceReadonlyError) && canRetry)) {
38
41
  throw error;
39
42
  }
40
43
  // SPO itself does number of retries internally before returning 409 to client.
@@ -42,8 +45,8 @@ export async function runWithRetry(api, callName, logger, checkDisposed) {
42
45
  // too much time / bandwidth doing the same thing without any progress.
43
46
  if (attempts === 5) {
44
47
  logger.sendErrorEvent({
45
- eventName: coherencyError ?
46
- "CoherencyErrorTooManyRetries" : "ServiceReadonlyErrorTooManyRetries",
48
+ eventName: coherencyError ? "CoherencyErrorTooManyRetries" :
49
+ "ServiceReadonlyErrorTooManyRetries",
47
50
  callName,
48
51
  attempts,
49
52
  duration: performance.now() - start, // record total wait time.
@@ -52,6 +55,7 @@ export async function runWithRetry(api, callName, logger, checkDisposed) {
52
55
  error.canRetry = false;
53
56
  throw error;
54
57
  }
58
+ retryAfter = (_a = getRetryDelayFromError(error)) !== null && _a !== void 0 ? _a : retryAfter;
55
59
  await delay(Math.floor(retryAfter));
56
60
  retryAfter += retryAfter / 4 * (1 + Math.random());
57
61
  lastError = error;
@@ -1 +1 @@
1
- {"version":3,"file":"retryUtils.js","sourceRoot":"","sources":["../src/retryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MA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E;YAC/E,oFAAoF;YACpF,uEAAuE;YACvE,IAAI,QAAQ,KAAK,CAAC,EAAE;gBAChB,MAAM,CAAC,cAAc,CACjB;oBACI,SAAS,EAAE,cAAc,CAAC,CAAC;wBACvB,8BAA8B,CAAC,CAAC,CAAC,oCAAoC;oBACzE,QAAQ;oBACR,QAAQ;oBACR,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,0BAA0B;iBAClE,EACD,KAAK,CAAC,CAAC;gBACX,aAAa;gBACb,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACvB,MAAM,KAAK,CAAC;aACf;YAED,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;YACpC,UAAU,IAAI,UAAU,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YACnD,SAAS,GAAG,KAAK,CAAC;SACrB;KACJ;AACL,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 { delay, performance } from \"@fluidframework/common-utils\";\nimport { canRetryOnError } from \"@fluidframework/driver-utils\";\nimport { OdspErrorType } from \"@fluidframework/odsp-driver-definitions\";\nimport { Odsp409Error } from \"./epochTracker\";\n\n/**\n * This method retries only for retriable coherency and service read only errors.\n */\nexport async function runWithRetry<T>(\n api: () => Promise<T>,\n callName: string,\n logger: ITelemetryLogger,\n checkDisposed?: () => void,\n): Promise<T> {\n let retryAfter = 1000;\n const start = performance.now();\n let lastError: any;\n for (let attempts = 1; ; attempts++) {\n if (checkDisposed !== undefined) {\n checkDisposed();\n }\n try {\n const result = await api();\n if (attempts > 1) {\n logger.sendTelemetryEvent(\n {\n eventName: \"MultipleRetries\",\n callName,\n attempts,\n duration: performance.now() - start,\n },\n lastError);\n }\n return result;\n } catch (error: any) {\n const canRetry = canRetryOnError(error);\n\n const coherencyError = error?.[Odsp409Error] === true;\n const serviceReadonlyError = error?.errorType === OdspErrorType.serviceReadOnly;\n // Retry for retriable 409 coherency errors or serviceReadOnly errors.\n if (!(coherencyError || serviceReadonlyError || canRetry)) {\n throw error;\n }\n\n // SPO itself does number of retries internally before returning 409 to client.\n // That multiplied to 5 suggests need to reconsider current design, as client spends\n // too much time / bandwidth doing the same thing without any progress.\n if (attempts === 5) {\n logger.sendErrorEvent(\n {\n eventName: coherencyError ?\n \"CoherencyErrorTooManyRetries\" : \"ServiceReadonlyErrorTooManyRetries\",\n callName,\n attempts,\n duration: performance.now() - start, // record total wait time.\n },\n error);\n // Fail hard.\n error.canRetry = false;\n throw error;\n }\n\n await delay(Math.floor(retryAfter));\n retryAfter += retryAfter / 4 * (1 + Math.random());\n lastError = error;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"retryUtils.js","sourceRoot":"","sources":["../src/retryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAC9B,GAAqB,EACrB,QAAgB,EAChB,MAAwB,EACxB,aAA0B;;IAE1B,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,IAAI,SAAc,CAAC;IACnB,KAAK,IAAI,QAAQ,GAAG,CAAC,GAAI,QAAQ,EAAE,EAAE;QACjC,IAAI,aAAa,KAAK,SAAS,EAAE;YAC7B,aAAa,EAAE,CAAC;SACnB;QACD,IAAI;YACA,MAAM,MAAM,GAAG,M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,CAAC,CAAC,CAAC;YACpC,UAAU,IAAI,UAAU,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YACnD,SAAS,GAAG,KAAK,CAAC;SACrB;KACJ;AACL,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 { delay, performance } from \"@fluidframework/common-utils\";\nimport { canRetryOnError, getRetryDelayFromError } from \"@fluidframework/driver-utils\";\nimport { OdspErrorType } from \"@fluidframework/odsp-driver-definitions\";\nimport { Odsp409Error } from \"./epochTracker\";\n\n/**\n * This method retries only for retriable coherency and service read only errors.\n */\nexport async function runWithRetry<T>(\n api: () => Promise<T>,\n callName: string,\n logger: ITelemetryLogger,\n checkDisposed?: () => void,\n): Promise<T> {\n let retryAfter = 1000;\n const start = performance.now();\n let lastError: any;\n for (let attempts = 1; ; attempts++) {\n if (checkDisposed !== undefined) {\n checkDisposed();\n }\n try {\n const result = await api();\n if (attempts > 1) {\n logger.sendTelemetryEvent(\n {\n eventName: \"MultipleRetries\",\n callName,\n attempts,\n duration: performance.now() - start,\n },\n lastError);\n }\n return result;\n } catch (error: any) {\n const canRetry = canRetryOnError(error);\n\n const coherencyError = error?.[Odsp409Error] === true;\n const serviceReadonlyError = error?.errorType === OdspErrorType.serviceReadOnly;\n // Retry for retriable 409 coherency errors or serviceReadOnly errors. These errors are always retriable\n // unless someone specifically set canRetry = false on the error like in fetchSnapshot() flow. So in\n // that case don't retry.\n if (!((coherencyError || serviceReadonlyError) && canRetry)) {\n throw error;\n }\n\n // SPO itself does number of retries internally before returning 409 to client.\n // That multiplied to 5 suggests need to reconsider current design, as client spends\n // too much time / bandwidth doing the same thing without any progress.\n if (attempts === 5) {\n logger.sendErrorEvent(\n {\n eventName: coherencyError ? \"CoherencyErrorTooManyRetries\" :\n \"ServiceReadonlyErrorTooManyRetries\",\n callName,\n attempts,\n duration: performance.now() - start, // record total wait time.\n },\n error);\n // Fail hard.\n error.canRetry = false;\n throw error;\n }\n\n retryAfter = getRetryDelayFromError(error) ?? retryAfter;\n await delay(Math.floor(retryAfter));\n retryAfter += retryAfter / 4 * (1 + Math.random());\n lastError = error;\n }\n }\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
5
6
  import { ReadBuffer } from "./ReadBufferUtils";
6
7
  /**
7
8
  * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on
@@ -80,7 +81,7 @@ export declare const codeToBytesMap: {
80
81
  export declare function getValueSafely(map: {
81
82
  [index: number]: number;
82
83
  }, key: number): number;
83
- export declare function getAndValidateNodeProps(node: NodeCore, props: string[], enforceAllProps?: boolean): Record<string, NodeTypes>;
84
+ export declare function getNodeProps(node: NodeCore): Record<string, NodeTypes>;
84
85
  export declare function iteratePairs<T>(it: IterableIterator<T>): IterableIterator<[T, T]>;
85
86
  /**
86
87
  * Helper function that returns iterator from an object
@@ -95,24 +96,19 @@ export declare function iterate<T>(obj: {
95
96
  * Note: concrete implementations (derived classes) are not exposed from this module
96
97
  */
97
98
  export declare abstract class BlobCore {
98
- readonly constString: boolean;
99
- readonly useUtf8Code: boolean;
100
99
  abstract get buffer(): Uint8Array;
101
- get arrayBuffer(): ArrayBufferLike;
100
+ abstract get arrayBuffer(): ArrayBufferLike;
102
101
  /**
103
102
  * Represents a blob.
104
- * @param constString - Whether it contains const string declaration.
105
- * @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.
106
103
  */
107
- constructor(constString: boolean, useUtf8Code?: boolean);
108
- toString(): string;
104
+ constructor();
109
105
  }
110
106
  /**
111
107
  * Shallow copy blob, keeps a reference to portion of ReadBuffer
112
108
  * it was constructed from. It takes much less memory compared to BlobDeepCopy
113
109
  */
114
110
  export declare class BlobShallowCopy extends BlobCore {
115
- protected data: ReadBuffer;
111
+ protected data: Uint8Array;
116
112
  protected start: number;
117
113
  protected end: number;
118
114
  /**
@@ -120,15 +116,26 @@ export declare class BlobShallowCopy extends BlobCore {
120
116
  * @param data - Data array of the blob
121
117
  * @param start - Start point of the blob in the buffer.
122
118
  * @param end - End point of the blob in the buffer.
123
- * @param constString - Whether it contains const string declaration.
124
119
  */
125
- constructor(data: ReadBuffer, start: number, end: number, constString: boolean);
120
+ constructor(data: Uint8Array, start: number, end: number);
126
121
  get buffer(): Uint8Array;
127
- static read(buffer: ReadBuffer, lengthLen: number, constString: boolean): BlobCore;
122
+ get arrayBuffer(): ArrayBufferLike;
123
+ static read(buffer: ReadBuffer, lengthLen: number): BlobCore;
128
124
  }
129
- export declare const addStringProperty: (node: NodeCore, a: string, b: string, encodeValAsConstString?: boolean) => void;
125
+ export declare const addStringProperty: (node: NodeCore, a: string, b: string) => void;
126
+ export declare const addDictionaryStringProperty: (node: NodeCore, a: string, b: string) => void;
130
127
  export declare const addNumberProperty: (node: NodeCore, a: string, b: number) => void;
131
128
  export declare const addBoolProperty: (node: NodeCore, a: string, b: boolean) => void;
129
+ export interface IStringElement {
130
+ content: string;
131
+ dictionary: boolean;
132
+ _stringElement: true;
133
+ }
134
+ export interface IStringElementInternal extends Omit<IStringElement, "content"> {
135
+ content?: string;
136
+ startPos: number;
137
+ endPos: number;
138
+ }
132
139
  /**
133
140
  * Three leaf types supported by tree:
134
141
  * 1. Node (sub-tree)
@@ -136,7 +143,7 @@ export declare const addBoolProperty: (node: NodeCore, a: string, b: boolean) =>
136
143
  * 3. integer
137
144
  * 4. boolean
138
145
  */
139
- export declare type NodeTypes = NodeCore | BlobCore | number | boolean;
146
+ export declare type NodeTypes = NodeCore | BlobCore | number | boolean | IStringElement;
140
147
  export declare type NodeCoreTypes = "list" | "set";
141
148
  /**
142
149
  * Node - node in the tree (non-leaf element of the tree)
@@ -151,28 +158,33 @@ export declare class NodeCore {
151
158
  get length(): number;
152
159
  get(index: number): NodeTypes;
153
160
  getString(index: number): string;
161
+ getMaybeString(index: number): string | undefined;
154
162
  getBlob(index: number): BlobCore;
155
163
  getNode(index: number): NodeCore;
156
164
  getNumber(index: number): number;
157
165
  getBool(index: number): boolean;
158
166
  addNode(type?: NodeCoreTypes): NodeCore;
159
- addBlob(blob: Uint8Array, constString: boolean, useUtf8Code?: boolean): void;
160
- addString(payload: string, constString: boolean): void;
167
+ addBlob(blob: Uint8Array): void;
168
+ addDictionaryString(payload: string): void;
169
+ addString(payload: string): void;
161
170
  addNumber(payload: number | undefined): void;
162
171
  addBool(payload: boolean): void;
172
+ private static readString;
163
173
  /**
164
174
  * Load and parse the buffer into a tree.
165
175
  * @param buffer - buffer to read from.
166
176
  */
167
- protected load(buffer: ReadBuffer, dictionary: BlobCore[]): void;
177
+ protected load(buffer: ReadBuffer, logger: ITelemetryLogger): void;
168
178
  }
169
179
  /**
170
180
  * TreeBuilder - Root of the tree.
171
181
  * Provides loading and serialization capabilities.
172
182
  */
173
183
  export declare class TreeBuilder extends NodeCore {
174
- static load(buffer: ReadBuffer): TreeBuilder;
184
+ static load(buffer: ReadBuffer, logger: ITelemetryLogger): TreeBuilder;
175
185
  }
186
+ export declare function getMaybeStringInstance(node: NodeTypes): string | undefined;
187
+ export declare function getStringInstance(node: NodeTypes, message: string): string;
176
188
  export declare function assertBlobCoreInstance(node: NodeTypes, message: string): asserts node is BlobCore;
177
189
  export declare function assertNodeCoreInstance(node: NodeTypes, message: string): asserts node is NodeCore;
178
190
  export declare function assertNumberInstance(node: NodeTypes, message: string): asserts node is number;
@@ -1 +1 @@
1
- {"version":3,"file":"zipItDataRepresentationUtils.d.ts","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C;;;GAGG;AACH,oBAAY,WAAW;IACnB,QAAQ,KAAK;IACb,SAAS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