@fluidframework/odsp-driver 0.59.3003 → 0.59.4000

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 (69) hide show
  1. package/dist/WriteBufferUtils.js +1 -1
  2. package/dist/WriteBufferUtils.js.map +1 -1
  3. package/dist/createFile.d.ts +1 -1
  4. package/dist/createFile.d.ts.map +1 -1
  5. package/dist/createFile.js +36 -6
  6. package/dist/createFile.js.map +1 -1
  7. package/dist/fetchSnapshot.d.ts.map +1 -1
  8. package/dist/fetchSnapshot.js +2 -4
  9. package/dist/fetchSnapshot.js.map +1 -1
  10. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  11. package/dist/odspDocumentDeltaConnection.js +15 -2
  12. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  13. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  14. package/dist/odspDocumentServiceFactoryCore.js +5 -1
  15. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  16. package/dist/odspSnapshotParser.js +1 -1
  17. package/dist/odspSnapshotParser.js.map +1 -1
  18. package/dist/odspUtils.d.ts +1 -0
  19. package/dist/odspUtils.d.ts.map +1 -1
  20. package/dist/odspUtils.js +8 -9
  21. package/dist/odspUtils.js.map +1 -1
  22. package/dist/packageVersion.d.ts +1 -1
  23. package/dist/packageVersion.js +1 -1
  24. package/dist/packageVersion.js.map +1 -1
  25. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  26. package/dist/prefetchLatestSnapshot.js +1 -1
  27. package/dist/prefetchLatestSnapshot.js.map +1 -1
  28. package/dist/zipItDataRepresentationUtils.js +2 -2
  29. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  30. package/lib/WriteBufferUtils.js +1 -1
  31. package/lib/WriteBufferUtils.js.map +1 -1
  32. package/lib/createFile.d.ts +1 -1
  33. package/lib/createFile.d.ts.map +1 -1
  34. package/lib/createFile.js +37 -7
  35. package/lib/createFile.js.map +1 -1
  36. package/lib/fetchSnapshot.d.ts.map +1 -1
  37. package/lib/fetchSnapshot.js +2 -4
  38. package/lib/fetchSnapshot.js.map +1 -1
  39. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  40. package/lib/odspDocumentDeltaConnection.js +15 -2
  41. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  42. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  43. package/lib/odspDocumentServiceFactoryCore.js +5 -1
  44. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  45. package/lib/odspSnapshotParser.js +1 -1
  46. package/lib/odspSnapshotParser.js.map +1 -1
  47. package/lib/odspUtils.d.ts +1 -0
  48. package/lib/odspUtils.d.ts.map +1 -1
  49. package/lib/odspUtils.js +7 -8
  50. package/lib/odspUtils.js.map +1 -1
  51. package/lib/packageVersion.d.ts +1 -1
  52. package/lib/packageVersion.js +1 -1
  53. package/lib/packageVersion.js.map +1 -1
  54. package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
  55. package/lib/prefetchLatestSnapshot.js +1 -1
  56. package/lib/prefetchLatestSnapshot.js.map +1 -1
  57. package/lib/zipItDataRepresentationUtils.js +2 -2
  58. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  59. package/package.json +17 -15
  60. package/src/WriteBufferUtils.ts +1 -1
  61. package/src/createFile.ts +41 -5
  62. package/src/fetchSnapshot.ts +2 -4
  63. package/src/odspDocumentDeltaConnection.ts +14 -2
  64. package/src/odspDocumentServiceFactoryCore.ts +7 -0
  65. package/src/odspSnapshotParser.ts +1 -1
  66. package/src/odspUtils.ts +9 -8
  67. package/src/packageVersion.ts +1 -1
  68. package/src/prefetchLatestSnapshot.ts +1 -1
  69. package/src/zipItDataRepresentationUtils.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"odspUtils.d.ts","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,E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H,wBAAsB,yBAAyB,CAAC,CAAC,EAC7C,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,GAAG,SAAS,GACrC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CA4B3B;AAED,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACnC;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,YAAY,GAAG,gBAAgB,CAG9E;AAED,eAAO,MAAM,gBAAgB,0GAQnB,CAAC;AAEX,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa;;;;;EAqBxD;AAED,wBAAgB,8BAA8B,CAC1C,MAAM,EAAE,gBAAgB,EACxB,gBAAgB,EAAE,aAAa,EAC/B,YAAY,EAAE,YAAY,CAAC,6BAA6B,CAAC,EACzD,gBAAgB,EAAE,OAAO,GAC1B,+BAA+B,CAkDjC;AAED,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,gBAAgB,GAAG,WAAW,CAUrF;AAID,eAAO,MAAM,kBAAkB,QAAQ,CAAC"}
package/lib/odspUtils.js CHANGED
@@ -69,20 +69,14 @@ export async function fetchHelper(requestInfo, requestInit) {
69
69
  duration: performance.now() - start,
70
70
  };
71
71
  }, (error) => {
72
- // While we do not know for sure whether computer is offline, this error is not actionable and
73
- // is pretty good indicator we are offline. Treating it as offline scenario will make it
74
- // easier to see other errors in telemetry.
75
- let online = isOnline();
72
+ const online = isOnline();
76
73
  const errorText = `${error}`;
77
- if (errorText === "TypeError: Failed to fetch") {
78
- online = OnlineStatus.Offline;
79
- }
80
74
  // This error is thrown by fetch() when AbortSignal is provided and it gets cancelled
81
75
  if (error.name === "AbortError") {
82
76
  throw new RetryableError("Fetch Timeout (AbortError)", OdspErrorType.fetchTimeout, { driverVersion });
83
77
  }
84
78
  // TCP/IP timeout
85
- if (errorText.indexOf("ETIMEDOUT") !== -1) {
79
+ if (errorText.includes("ETIMEDOUT")) {
86
80
  throw new RetryableError("Fetch Timeout (ETIMEDOUT)", OdspErrorType.fetchTimeout, { driverVersion });
87
81
  }
88
82
  //
@@ -96,6 +90,8 @@ export async function fetchHelper(requestInfo, requestInit) {
96
90
  `ODSP fetch failure (Offline): ${errorText}`, DriverErrorType.offlineError, { driverVersion });
97
91
  }
98
92
  else {
93
+ // It is perhaps still possible that this is due to being offline, the error does not reveal enough
94
+ // information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.
99
95
  throw new RetryableError(
100
96
  // pre-0.58 error message prefix: Fetch error
101
97
  `ODSP fetch failure: ${errorText}`, DriverErrorType.fetchFailure, { driverVersion });
@@ -227,4 +223,7 @@ export function createCacheSnapshotKey(odspResolvedUrl) {
227
223
  };
228
224
  return cacheEntry;
229
225
  }
226
+ // 80KB is the max body size that we can put in ump post body for server to be able to accept it.
227
+ // Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.
228
+ export const maxUmpPostBodySize = 79872;
230
229
  //# sourceMappingURL=odspUtils.js.map
@@ -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;AAEnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC3F,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,oCAAoC,GACvC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,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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","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 { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\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 ISnapshotContents {\n snapshotTree: ISnapshotTree;\n blobs: Map<string, ArrayBuffer>;\n ops: ISequencedDocumentMessage[];\n sequenceNumber: number | undefined;\n}\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 // While we do not know for sure whether computer is offline, this error is not actionable and\n // is pretty good indicator we are offline. Treating it as offline scenario will make it\n // easier to see other errors in telemetry.\n let online = isOnline();\n const errorText = `${error}`;\n if (errorText === \"TypeError: Failed to fetch\") {\n online = OnlineStatus.Offline;\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.indexOf(\"ETIMEDOUT\") !== -1) {\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 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 { 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 for ${name} call 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 for ${name} call 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"]}
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;AAEnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC3F,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,oCAAoC,GACvC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAGH,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAKhB,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,CAA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C;aACrF;YACD,IAAI,KAAK,KAAK,IAAI,IAAI,gBAAgB,EAAE;gBACpC,MAAM,IAAI,iBAAiB;gBACvB,yDAAyD;gBACzD,uCAAuC,IAAI,qBAAqB,EAChE,aAAa,CAAC,eAAe,EAC7B,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;aACxC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;YACT,kGAAkG;YAClG,2FAA2F;YAC3F,MAAM,WAAW,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC;YACpC,MAAM,UAAU,GAAG,SAAS,CACxB,KAAK,EACL,CAAC,YAAY,EAAE,EAAE,CAAC,IAAI,iBAAiB,CACnC,uCAAuC,IAAI,yBAAyB,YAAY,EAAE,EAClF,aAAa,CAAC,eAAe,EAC7B,OAAO,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,EACrE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;YAC1C,MAAM,UAAU,CAAC;QACrB,CAAC,CAAC,EACF,EAAE,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 { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\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 ISnapshotContents {\n snapshotTree: ISnapshotTree;\n blobs: Map<string, ArrayBuffer>;\n ops: ISequencedDocumentMessage[];\n sequenceNumber: number | undefined;\n}\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 { 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 for ${name} call 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 for ${name} call 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"]}
@@ -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 = "0.59.3003";
8
+ export declare const pkgVersion = "0.59.4000";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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 = "0.59.3003";
8
+ export const pkgVersion = "0.59.4000";
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,WAAW,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 = \"0.59.3003\";\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,WAAW,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 = \"0.59.4000\";\n"]}
@@ -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,CAAC,EAAE,OAAO,EAC9B,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;;;;;;;;;;;;;;;;;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"}
@@ -24,7 +24,7 @@ import { downloadSnapshot, fetchSnapshotWithRedeem } from "./fetchSnapshot";
24
24
  * @param snapshotFormatFetchType - Snapshot format to fetch.
25
25
  * @returns - True if the snapshot is cached, false otherwise.
26
26
  */
27
- export async function prefetchLatestSnapshot(resolvedUrl, getStorageToken, persistedCache, forceAccessTokenViaAuthorizationHeader, logger, hostSnapshotFetchOptions, enableRedeemFallback, fetchBinarySnapshotFormat, snapshotFormatFetchType) {
27
+ export async function prefetchLatestSnapshot(resolvedUrl, getStorageToken, persistedCache, forceAccessTokenViaAuthorizationHeader, logger, hostSnapshotFetchOptions, enableRedeemFallback = true, fetchBinarySnapshotFormat, snapshotFormatFetchType) {
28
28
  const odspLogger = createOdspLogger(ChildLogger.create(logger, "PrefetchSnapshot"));
29
29
  const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);
30
30
  const resolvedUrlData = {
@@ -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,EAClB,8BAA8B,GACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAA6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gB,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,\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;;;;;;;;;;;;;;;;;GAiBG;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,MAAM,eAAe,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAExD,MAAM,eAAe,GAAkB;QACnC,OAAO,EAA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AC,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"]}
@@ -94,7 +94,7 @@ export const codeToBytesMap = {
94
94
  };
95
95
  export function getValueSafely(map, key) {
96
96
  const val = map[key];
97
- assert(val !== undefined, 0x287 /* `key= ${key} must exist in the map` */);
97
+ assert(val !== undefined, 0x287 /* key must exist in the map */);
98
98
  return val;
99
99
  }
100
100
  export function getAndValidateNodeProps(node, props, enforceAllProps = true) {
@@ -109,7 +109,7 @@ export function getAndValidateNodeProps(node, props, enforceAllProps = true) {
109
109
  }
110
110
  }
111
111
  if (enforceAllProps) {
112
- assert(propSet.size === 0, 0x288 /* `All properties should exist, Not found: ${[...propSet.keys()]}` */);
112
+ assert(propSet.size === 0, 0x288 /* All properties should exist */);
113
113
  }
114
114
  return res;
115
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;EAGE;AAEF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/D,mCAAmC;AACnC,wJAAwJ;AACxJ;;;GAGG;AACH,MAAM,CAAN,IAAY,WA8BX;AA9BD,WAAY,WAAW;IACnB,sDAAa,CAAA;IACb,wDAAc,CAAA;IAEd,4DAAgB,CAAA;IAChB,gEAAkB,CAAA;IAClB,kEAAmB,CAAA;IACnB,kEAAmB,CAAA;IAEnB,kEAAmB,CAAA;IACnB,oEAAoB,CAAA;IACpB,oEAAoB,CAAA;IACpB,0EAAuB,CAAA;IACvB,gFAA0B,CAAA;IAE1B,6CAAQ,CAAA;IACR,+CAAS,CAAA;IACT,iDAAU,CA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EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QACnC,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n*/\n\nimport { assert, IsoBuffer, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n// eslint-disable-next-line max-len\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n BoolTrue = 11, // value = true\n BoolFalse = 12, // value = false\n\n StringEmpty = 13, // value = \"\"\n String8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n String16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n String32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n ConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n ConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n ConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n ConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n ConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n Int0 = 1, // value = 0\n UInt8 = 3, // unsigned-8-bit little-endian follows\n UInt16 = 5, // unsigned-16-bit little-endian follows\n UInt32 = 7, // unsigned-32-bit little-endian follows\n UInt64 = 9, // unsigned-64-bit little-endian follows\n Int8 = 2, // signed-8-bit little-endian follows\n Int16 = 4, // signed-16-bit little-endian follows\n Int32 = 6, // signed-32-bit little-endian follows\n Int64 = 8, // signed-64-bit little-endian follows\n\n BinaryEmpty = 32, // value = byte[]\n BinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n BinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n BinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n BinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n \"list\" = 49,\n \"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n \"list\" = 50,\n \"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n*/\nexport const codeToBytesMap = {\n // Integer code to bytes\n 1: 0,\n 2: 1,\n 3: 1,\n 4: 2,\n 5: 2,\n 6: 4,\n 7: 4,\n 8: 8,\n 9: 8,\n\n // String code to Bytes\n 13: 0,\n 14: 1,\n 15: 2,\n 16: 4,\n\n 17: 1,\n 18: 2,\n 19: 4,\n\n 20: 1,\n 21: 4,\n\n // Binary code to bytes\n 32: 0,\n 33: 1,\n 34: 2,\n 35: 4,\n 36: 8,\n};\n\nexport function getValueSafely(map: { [index: number]: number; }, key: number) {\n const val = map[key];\n assert(val !== undefined, 0x287 /* `key= ${key} must exist in the map` */);\n return val;\n}\n\nexport function getAndValidateNodeProps(node: NodeCore, props: string[], enforceAllProps = true) {\n const propSet = new Set(props);\n const res: Record<string, NodeTypes> = {};\n for (const [keyNode, valueNode] of node.iteratePairs()) {\n assertBlobCoreInstance(keyNode, \"keynode should be a blob\");\n const keyStr = keyNode.toString();\n if (propSet.has(keyStr)) {\n propSet.delete(keyStr);\n res[keyStr] = valueNode;\n }\n }\n if (enforceAllProps) {\n assert(propSet.size === 0, 0x288 /* `All properties should exist, Not found: ${[...propSet.keys()]}` */);\n }\n return res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>) {\n const res: IterableIterator<[T, T]> = {\n next: () => {\n const a = it.next();\n if (a.done) {\n return { value: undefined, done: true };\n }\n const b = it.next();\n assert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n return { value: [a.value, b.value], done: b.done };\n },\n [Symbol.iterator]: () => { return res; },\n };\n return res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: { [Symbol.iterator]: () => IterableIterator<T>; }) {\n return obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n public abstract get buffer(): Uint8Array;\n public get arrayBuffer(): ArrayBufferLike {\n return Uint8ArrayToArrayBuffer(this.buffer);\n }\n\n /**\n * Represents a blob.\n * @param constString - Whether it contains const string declaration.\n * @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.\n */\n constructor(public readonly constString: boolean, public readonly useUtf8Code: boolean = false) {}\n\n public toString() {\n return Uint8ArrayToString(this.buffer, \"utf-8\");\n }\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n*/\nclass BlobDeepCopy extends BlobCore {\n /**\n * Represents a deep copy of the blob.\n * @param data - Data array of the blob\n * @param constString - Whether it contains const string declaration.\n * @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.\n */\n constructor(protected readonly data: Uint8Array, constString: boolean, useUtf8Code: boolean = false) {\n super(constString, useUtf8Code);\n }\n\n public get buffer() {\n return this.data;\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number, constString: boolean): BlobCore {\n const length = buffer.read(lengthLen);\n const data = new Uint8Array(length);\n for (let counter = 0; counter < length; counter++) {\n data[counter] = buffer.read();\n }\n return new BlobDeepCopy(data, constString);\n }\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\n export class BlobShallowCopy extends BlobCore {\n /**\n * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n * @param data - Data array of the blob\n * @param start - Start point of the blob in the buffer.\n * @param end - End point of the blob in the buffer.\n * @param constString - Whether it contains const string declaration.\n */\n constructor(\n protected data: ReadBuffer,\n protected start: number,\n protected end: number,\n constString: boolean,\n ) {\n super(constString);\n }\n\n public get buffer() {\n return this.data.buffer.subarray(this.start, this.end);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number, constString: boolean): BlobCore {\n const length = buffer.read(lengthLen);\n const pos = buffer.pos;\n buffer.skip(length);\n return new BlobShallowCopy(buffer, pos, pos + length, constString);\n }\n}\n\nexport const addStringProperty =\n (node: NodeCore, a: string, b: string, encodeValAsConstString: boolean = false) => {\n node.addString(a, true); node.addString(b, encodeValAsConstString);\n };\nexport const addNumberProperty = (node: NodeCore, a: string, b: number) => {\n node.addString(a, true); node.addNumber(b);\n};\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean) => {\n node.addString(a, true); node.addBool(b);\n};\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n // It is an array of nodes.\n private readonly children: NodeTypes[] = [];\n public get nodes() {\n return this.children;\n }\n\n constructor(public type: NodeCoreTypes = \"set\") {}\n\n public [Symbol.iterator]() {\n return this.children[Symbol.iterator]();\n }\n\n public iteratePairs() {\n assert((this.length % 2) === 0, 0x22c /* \"reading pairs\" */);\n return iteratePairs(iterate(this));\n }\n\n public get length() { return this.children.length; }\n\n public get(index: number) { return this.children[index]; }\n\n public getString(index: number): string {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getString should return stringblob\");\n return node.toString();\n }\n\n public getBlob(index: number): BlobCore {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getBlob should return a blob\");\n return node;\n }\n\n public getNode(index: number): NodeCore {\n const node = this.children[index];\n assertNodeCoreInstance(node, \"getNode should return a node\");\n return node;\n }\n\n public getNumber(index: number): number {\n const node = this.children[index];\n assertNumberInstance(node, \"getNumber should return a number\");\n return node;\n }\n\n public getBool(index: number): boolean {\n const node = this.children[index];\n assertBoolInstance(node, \"getBool should return a boolean\");\n return node;\n }\n\n public addNode(type?: NodeCoreTypes): NodeCore {\n const node = new NodeCore(type);\n this.children.push(node);\n return node;\n }\n\n public addBlob(blob: Uint8Array, constString: boolean, useUtf8Code: boolean = false) {\n this.children.push(new BlobDeepCopy(blob, constString, useUtf8Code));\n }\n\n public addString(payload: string, constString: boolean) {\n this.addBlob(IsoBuffer.from(payload, \"utf-8\"), constString, true);\n }\n\n public addNumber(payload: number | undefined) {\n assert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n assert(payload !== undefined && payload >= 0, 0x232 /* \"Payload should not be negative\" */);\n this.children.push(payload);\n }\n\n public addBool(payload: boolean) {\n this.children.push(payload);\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected load(buffer: ReadBuffer, dictionary: BlobCore[]) {\n for (;!buffer.eof;) {\n let childValue: NodeTypes | undefined;\n const code = buffer.read();\n switch (code) {\n case MarkerCodesStart.list:\n case MarkerCodesStart.set: {\n childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n this.children.push(childValue);\n childValue.load(buffer, dictionary);\n break;\n }\n case MarkerCodes.ConstStringDeclare:\n case MarkerCodes.ConstStringDeclareBig:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const constString = BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code), true);\n dictionary[stringId] = constString;\n break;\n }\n case MarkerCodes.ConstString8Id:\n case MarkerCodes.ConstString16Id:\n case MarkerCodes.ConstString32Id:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n childValue = dictionary[stringId];\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.StringEmpty:\n case MarkerCodes.String8Length:\n case MarkerCodes.String16Length:\n case MarkerCodes.String32Length:\n case MarkerCodes.BinaryEmpty:\n case MarkerCodes.BinarySingle8:\n case MarkerCodes.BinarySingle16:\n case MarkerCodes.BinarySingle32:\n case MarkerCodes.BinarySingle64:\n {\n childValue = BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code), false);\n this.children.push(childValue);\n break;\n }\n // If integer is 0.\n case MarkerCodes.Int0:\n {\n childValue = 0;\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.UInt8:\n case MarkerCodes.UInt16:\n case MarkerCodes.UInt32:\n case MarkerCodes.UInt64:\n case MarkerCodes.Int8:\n case MarkerCodes.Int16:\n case MarkerCodes.Int32:\n case MarkerCodes.Int64:\n {\n childValue = buffer.read(getValueSafely(codeToBytesMap, code));\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.BoolTrue:\n this.children.push(true);\n break;\n case MarkerCodes.BoolFalse:\n this.children.push(false);\n break;\n case MarkerCodesEnd.list:\n case MarkerCodesEnd.set:\n return;\n default:\n throw new Error(`Invalid code: ${code}`);\n }\n }\n }\n}\n\n /**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n static load(buffer: ReadBuffer): TreeBuilder {\n const builder = new TreeBuilder();\n const dictionary = new Array<BlobCore>();\n builder.load(buffer, dictionary);\n assert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n return builder;\n }\n}\n\nexport function assertBlobCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is BlobCore {\n if (node instanceof BlobCore) {\n return;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is NodeCore {\n if (node instanceof NodeCore) {\n return;\n }\n throwBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n node: NodeTypes,\n message: string,\n): asserts node is number {\n if (typeof node === \"number\") {\n return;\n }\n throwBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(\n node: NodeTypes,\n message: string,\n): asserts node is boolean {\n if (typeof node === \"boolean\") {\n return;\n }\n throwBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n node: NodeTypes,\n expectedNodeType: NodeType,\n message: string,\n): never {\n throw new NonRetryableError(\n `Buffer parsing exception: ${message}`,\n DriverErrorType.incorrectServerResponse,\n {\n nodeType: getNodeType(node),\n expectedNodeType,\n driverVersion,\n });\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n if (typeof value === \"number\") {\n return \"Number\";\n } else if (value instanceof BlobCore) {\n return \"BlobCore\";\n } else if (value instanceof NodeCore) {\n return \"NodeCore\";\n } else if (typeof value === \"boolean\") {\n return \"Boolean\";\n }\n return \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\";\n"]}
1
+ {"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;EAGE;AAEF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCA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,SAAS,yBAAyB,CAC9B,IAAe,EACf,gBAA0B,EAC1B,OAAe;IAEf,MAAM,IAAI,iBAAiB,CACvB,6BAA6B,OAAO,EAAE,EACtC,eAAe,CAAC,uBAAuB,EACvC;QACI,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC;QAC3B,gBAAgB;QAChB,aAAa;KAChB,CAAC,CAAC;AACX,CAAC;AAED,SAAS,WAAW,CAAC,KAAgB;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,QAAQ,CAAC;KACnB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QACnC,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n*/\n\nimport { assert, IsoBuffer, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n// eslint-disable-next-line max-len\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n BoolTrue = 11, // value = true\n BoolFalse = 12, // value = false\n\n StringEmpty = 13, // value = \"\"\n String8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n String16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n String32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n ConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n ConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n ConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n ConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n ConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n Int0 = 1, // value = 0\n UInt8 = 3, // unsigned-8-bit little-endian follows\n UInt16 = 5, // unsigned-16-bit little-endian follows\n UInt32 = 7, // unsigned-32-bit little-endian follows\n UInt64 = 9, // unsigned-64-bit little-endian follows\n Int8 = 2, // signed-8-bit little-endian follows\n Int16 = 4, // signed-16-bit little-endian follows\n Int32 = 6, // signed-32-bit little-endian follows\n Int64 = 8, // signed-64-bit little-endian follows\n\n BinaryEmpty = 32, // value = byte[]\n BinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n BinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n BinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n BinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n \"list\" = 49,\n \"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n \"list\" = 50,\n \"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n*/\nexport const codeToBytesMap = {\n // Integer code to bytes\n 1: 0,\n 2: 1,\n 3: 1,\n 4: 2,\n 5: 2,\n 6: 4,\n 7: 4,\n 8: 8,\n 9: 8,\n\n // String code to Bytes\n 13: 0,\n 14: 1,\n 15: 2,\n 16: 4,\n\n 17: 1,\n 18: 2,\n 19: 4,\n\n 20: 1,\n 21: 4,\n\n // Binary code to bytes\n 32: 0,\n 33: 1,\n 34: 2,\n 35: 4,\n 36: 8,\n};\n\nexport function getValueSafely(map: { [index: number]: number; }, key: number) {\n const val = map[key];\n assert(val !== undefined, 0x287 /* key must exist in the map */);\n return val;\n}\n\nexport function getAndValidateNodeProps(node: NodeCore, props: string[], enforceAllProps = true) {\n const propSet = new Set(props);\n const res: Record<string, NodeTypes> = {};\n for (const [keyNode, valueNode] of node.iteratePairs()) {\n assertBlobCoreInstance(keyNode, \"keynode should be a blob\");\n const keyStr = keyNode.toString();\n if (propSet.has(keyStr)) {\n propSet.delete(keyStr);\n res[keyStr] = valueNode;\n }\n }\n if (enforceAllProps) {\n assert(propSet.size === 0, 0x288 /* All properties should exist */);\n }\n return res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>) {\n const res: IterableIterator<[T, T]> = {\n next: () => {\n const a = it.next();\n if (a.done) {\n return { value: undefined, done: true };\n }\n const b = it.next();\n assert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n return { value: [a.value, b.value], done: b.done };\n },\n [Symbol.iterator]: () => { return res; },\n };\n return res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: { [Symbol.iterator]: () => IterableIterator<T>; }) {\n return obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n public abstract get buffer(): Uint8Array;\n public get arrayBuffer(): ArrayBufferLike {\n return Uint8ArrayToArrayBuffer(this.buffer);\n }\n\n /**\n * Represents a blob.\n * @param constString - Whether it contains const string declaration.\n * @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.\n */\n constructor(public readonly constString: boolean, public readonly useUtf8Code: boolean = false) {}\n\n public toString() {\n return Uint8ArrayToString(this.buffer, \"utf-8\");\n }\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n*/\nclass BlobDeepCopy extends BlobCore {\n /**\n * Represents a deep copy of the blob.\n * @param data - Data array of the blob\n * @param constString - Whether it contains const string declaration.\n * @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.\n */\n constructor(protected readonly data: Uint8Array, constString: boolean, useUtf8Code: boolean = false) {\n super(constString, useUtf8Code);\n }\n\n public get buffer() {\n return this.data;\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number, constString: boolean): BlobCore {\n const length = buffer.read(lengthLen);\n const data = new Uint8Array(length);\n for (let counter = 0; counter < length; counter++) {\n data[counter] = buffer.read();\n }\n return new BlobDeepCopy(data, constString);\n }\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\n export class BlobShallowCopy extends BlobCore {\n /**\n * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n * @param data - Data array of the blob\n * @param start - Start point of the blob in the buffer.\n * @param end - End point of the blob in the buffer.\n * @param constString - Whether it contains const string declaration.\n */\n constructor(\n protected data: ReadBuffer,\n protected start: number,\n protected end: number,\n constString: boolean,\n ) {\n super(constString);\n }\n\n public get buffer() {\n return this.data.buffer.subarray(this.start, this.end);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number, constString: boolean): BlobCore {\n const length = buffer.read(lengthLen);\n const pos = buffer.pos;\n buffer.skip(length);\n return new BlobShallowCopy(buffer, pos, pos + length, constString);\n }\n}\n\nexport const addStringProperty =\n (node: NodeCore, a: string, b: string, encodeValAsConstString: boolean = false) => {\n node.addString(a, true); node.addString(b, encodeValAsConstString);\n };\nexport const addNumberProperty = (node: NodeCore, a: string, b: number) => {\n node.addString(a, true); node.addNumber(b);\n};\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean) => {\n node.addString(a, true); node.addBool(b);\n};\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n // It is an array of nodes.\n private readonly children: NodeTypes[] = [];\n public get nodes() {\n return this.children;\n }\n\n constructor(public type: NodeCoreTypes = \"set\") {}\n\n public [Symbol.iterator]() {\n return this.children[Symbol.iterator]();\n }\n\n public iteratePairs() {\n assert((this.length % 2) === 0, 0x22c /* \"reading pairs\" */);\n return iteratePairs(iterate(this));\n }\n\n public get length() { return this.children.length; }\n\n public get(index: number) { return this.children[index]; }\n\n public getString(index: number): string {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getString should return stringblob\");\n return node.toString();\n }\n\n public getBlob(index: number): BlobCore {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getBlob should return a blob\");\n return node;\n }\n\n public getNode(index: number): NodeCore {\n const node = this.children[index];\n assertNodeCoreInstance(node, \"getNode should return a node\");\n return node;\n }\n\n public getNumber(index: number): number {\n const node = this.children[index];\n assertNumberInstance(node, \"getNumber should return a number\");\n return node;\n }\n\n public getBool(index: number): boolean {\n const node = this.children[index];\n assertBoolInstance(node, \"getBool should return a boolean\");\n return node;\n }\n\n public addNode(type?: NodeCoreTypes): NodeCore {\n const node = new NodeCore(type);\n this.children.push(node);\n return node;\n }\n\n public addBlob(blob: Uint8Array, constString: boolean, useUtf8Code: boolean = false) {\n this.children.push(new BlobDeepCopy(blob, constString, useUtf8Code));\n }\n\n public addString(payload: string, constString: boolean) {\n this.addBlob(IsoBuffer.from(payload, \"utf-8\"), constString, true);\n }\n\n public addNumber(payload: number | undefined) {\n assert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n assert(payload !== undefined && payload >= 0, 0x232 /* \"Payload should not be negative\" */);\n this.children.push(payload);\n }\n\n public addBool(payload: boolean) {\n this.children.push(payload);\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected load(buffer: ReadBuffer, dictionary: BlobCore[]) {\n for (;!buffer.eof;) {\n let childValue: NodeTypes | undefined;\n const code = buffer.read();\n switch (code) {\n case MarkerCodesStart.list:\n case MarkerCodesStart.set: {\n childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n this.children.push(childValue);\n childValue.load(buffer, dictionary);\n break;\n }\n case MarkerCodes.ConstStringDeclare:\n case MarkerCodes.ConstStringDeclareBig:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const constString = BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code), true);\n dictionary[stringId] = constString;\n break;\n }\n case MarkerCodes.ConstString8Id:\n case MarkerCodes.ConstString16Id:\n case MarkerCodes.ConstString32Id:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n childValue = dictionary[stringId];\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.StringEmpty:\n case MarkerCodes.String8Length:\n case MarkerCodes.String16Length:\n case MarkerCodes.String32Length:\n case MarkerCodes.BinaryEmpty:\n case MarkerCodes.BinarySingle8:\n case MarkerCodes.BinarySingle16:\n case MarkerCodes.BinarySingle32:\n case MarkerCodes.BinarySingle64:\n {\n childValue = BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code), false);\n this.children.push(childValue);\n break;\n }\n // If integer is 0.\n case MarkerCodes.Int0:\n {\n childValue = 0;\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.UInt8:\n case MarkerCodes.UInt16:\n case MarkerCodes.UInt32:\n case MarkerCodes.UInt64:\n case MarkerCodes.Int8:\n case MarkerCodes.Int16:\n case MarkerCodes.Int32:\n case MarkerCodes.Int64:\n {\n childValue = buffer.read(getValueSafely(codeToBytesMap, code));\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.BoolTrue:\n this.children.push(true);\n break;\n case MarkerCodes.BoolFalse:\n this.children.push(false);\n break;\n case MarkerCodesEnd.list:\n case MarkerCodesEnd.set:\n return;\n default:\n throw new Error(`Invalid code: ${code}`);\n }\n }\n }\n}\n\n /**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n static load(buffer: ReadBuffer): TreeBuilder {\n const builder = new TreeBuilder();\n const dictionary = new Array<BlobCore>();\n builder.load(buffer, dictionary);\n assert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n return builder;\n }\n}\n\nexport function assertBlobCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is BlobCore {\n if (node instanceof BlobCore) {\n return;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is NodeCore {\n if (node instanceof NodeCore) {\n return;\n }\n throwBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n node: NodeTypes,\n message: string,\n): asserts node is number {\n if (typeof node === \"number\") {\n return;\n }\n throwBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(\n node: NodeTypes,\n message: string,\n): asserts node is boolean {\n if (typeof node === \"boolean\") {\n return;\n }\n throwBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n node: NodeTypes,\n expectedNodeType: NodeType,\n message: string,\n): never {\n throw new NonRetryableError(\n `Buffer parsing exception: ${message}`,\n DriverErrorType.incorrectServerResponse,\n {\n nodeType: getNodeType(node),\n expectedNodeType,\n driverVersion,\n });\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n if (typeof value === \"number\") {\n return \"Number\";\n } else if (value instanceof BlobCore) {\n return \"BlobCore\";\n } else if (value instanceof NodeCore) {\n return \"NodeCore\";\n } else if (typeof value === \"boolean\") {\n return \"Boolean\";\n }\n return \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/odsp-driver",
3
- "version": "0.59.3003",
3
+ "version": "0.59.4000",
4
4
  "description": "Socket storage implementation for SPO and ODC",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -63,15 +63,15 @@
63
63
  "@fluidframework/common-definitions": "^0.20.1",
64
64
  "@fluidframework/common-utils": "^0.32.1",
65
65
  "@fluidframework/core-interfaces": "^0.43.1000",
66
- "@fluidframework/driver-base": "^0.59.3003",
67
- "@fluidframework/driver-definitions": "^0.46.1000",
68
- "@fluidframework/driver-utils": "^0.59.3003",
69
- "@fluidframework/gitresources": "^0.1036.3000",
70
- "@fluidframework/odsp-doclib-utils": "^0.59.3003",
71
- "@fluidframework/odsp-driver-definitions": "^0.59.3003",
72
- "@fluidframework/protocol-base": "^0.1036.3000",
73
- "@fluidframework/protocol-definitions": "^0.1028.1000",
74
- "@fluidframework/telemetry-utils": "^0.59.3003",
66
+ "@fluidframework/driver-base": "^0.59.4000",
67
+ "@fluidframework/driver-definitions": "^0.46.2000",
68
+ "@fluidframework/driver-utils": "^0.59.4000",
69
+ "@fluidframework/gitresources": "^0.1036.4000",
70
+ "@fluidframework/odsp-doclib-utils": "^0.59.4000",
71
+ "@fluidframework/odsp-driver-definitions": "^0.59.4000",
72
+ "@fluidframework/protocol-base": "^0.1036.4000",
73
+ "@fluidframework/protocol-definitions": "^0.1028.2000",
74
+ "@fluidframework/telemetry-utils": "^0.59.4000",
75
75
  "abort-controller": "^3.0.0",
76
76
  "node-fetch": "^2.6.1",
77
77
  "socket.io-client": "^4.4.1",
@@ -79,13 +79,13 @@
79
79
  },
80
80
  "devDependencies": {
81
81
  "@fluidframework/build-common": "^0.23.0",
82
- "@fluidframework/build-tools": "^0.2.66793",
82
+ "@fluidframework/build-tools": "^0.2.70857",
83
83
  "@fluidframework/eslint-config-fluid": "^0.28.2000",
84
- "@fluidframework/mocha-test-setup": "^0.59.3003",
84
+ "@fluidframework/mocha-test-setup": "^0.59.4000",
85
85
  "@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@0.59.3000",
86
86
  "@microsoft/api-extractor": "^7.22.2",
87
87
  "@rushstack/eslint-config": "^2.5.1",
88
- "@types/mocha": "^8.2.2",
88
+ "@types/mocha": "^9.1.1",
89
89
  "@types/node-fetch": "^2.5.10",
90
90
  "@types/sha.js": "^2.4.0",
91
91
  "@typescript-eslint/eslint-plugin": "~5.9.0",
@@ -98,12 +98,14 @@
98
98
  "eslint-plugin-eslint-comments": "~3.2.0",
99
99
  "eslint-plugin-import": "~2.25.4",
100
100
  "eslint-plugin-jest": "~26.1.3",
101
+ "eslint-plugin-jsdoc": "~39.3.0",
101
102
  "eslint-plugin-mocha": "~10.0.3",
102
103
  "eslint-plugin-promise": "~6.0.0",
103
104
  "eslint-plugin-react": "~7.28.0",
104
105
  "eslint-plugin-tsdoc": "~0.2.14",
105
106
  "eslint-plugin-unicorn": "~40.0.0",
106
- "mocha": "^8.4.0",
107
+ "eslint-plugin-unused-imports": "~2.0.0",
108
+ "mocha": "^10.0.0",
107
109
  "nyc": "^15.0.0",
108
110
  "rimraf": "^2.6.2",
109
111
  "sinon": "^7.4.2",
@@ -111,7 +113,7 @@
111
113
  "typescript-formatter": "7.1.0"
112
114
  },
113
115
  "typeValidation": {
114
- "version": "0.59.3001",
116
+ "version": "0.59.4000",
115
117
  "broken": {}
116
118
  }
117
119
  }
@@ -49,7 +49,7 @@ export class WriteBuffer {
49
49
  code = Math.floor(code / 256);
50
50
  length--;
51
51
  }
52
- assert(code === 0, 0x226 /* `Should write complete data code= ${codeArg} ${lengthArg}` */);
52
+ assert(code === 0, 0x226 /* Should write complete data */);
53
53
  }
54
54
 
55
55
  public done(): ReadBuffer {
package/src/createFile.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { v4 as uuid } from "uuid";
6
7
  import { assert, Uint8ArrayToString } from "@fluidframework/common-utils";
7
8
  import { getDocAttributesFromProtocolSummary, NonRetryableError } from "@fluidframework/driver-utils";
8
9
  import { getGitType } from "@fluidframework/protocol-base";
@@ -30,6 +31,7 @@ import {
30
31
  INewFileInfo,
31
32
  getOrigin,
32
33
  ISnapshotContents,
34
+ maxUmpPostBodySize,
33
35
  } from "./odspUtils";
34
36
  import { createOdspUrl } from "./createOdspUrl";
35
37
  import { getApiRoot } from "./odspUrlHelper";
@@ -38,6 +40,7 @@ import { OdspDriverUrlResolver } from "./odspDriverUrlResolver";
38
40
  import { convertCreateNewSummaryTreeToTreeAndBlobs } from "./createNewUtils";
39
41
  import { runWithRetry } from "./retryUtils";
40
42
  import { pkgVersion as driverVersion } from "./packageVersion";
43
+ import { ClpCompliantAppHeader } from "./contractsPublic";
41
44
 
42
45
  const isInvalidFileName = (fileName: string): boolean => {
43
46
  const invalidCharsRegex = /["*/:<>?\\|]+/g;
@@ -57,6 +60,7 @@ export async function createNewFluidFile(
57
60
  fileEntry: IFileEntry,
58
61
  createNewCaching: boolean,
59
62
  forceAccessTokenViaAuthorizationHeader: boolean,
63
+ isClpCompliantApp?: boolean,
60
64
  ): Promise<IOdspResolvedUrl> {
61
65
  // Check for valid filename before the request to create file is actually made.
62
66
  if (isInvalidFileName(newFileInfo.filename)) {
@@ -89,7 +93,10 @@ export async function createNewFluidFile(
89
93
 
90
94
  const odspUrl = createOdspUrl({ ... newFileInfo, itemId, dataStorePath: "/" });
91
95
  const resolver = new OdspDriverUrlResolver();
92
- const odspResolvedUrl = await resolver.resolve({ url: odspUrl });
96
+ const odspResolvedUrl = await resolver.resolve({
97
+ url: odspUrl,
98
+ headers: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },
99
+ });
93
100
  fileEntry.docId = odspResolvedUrl.hashedDocumentId;
94
101
  fileEntry.resolvedUrl = odspResolvedUrl;
95
102
 
@@ -195,19 +202,48 @@ export async function createNewFluidFileFromSummary(
195
202
  logger,
196
203
  { eventName: "createNewFile" },
197
204
  async (event) => {
198
- const { url, headers } = getUrlAndHeadersWithAuth(
199
- initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
200
- headers["Content-Type"] = "application/json";
205
+ const snapshotBody = JSON.stringify(containerSnapshot);
206
+ let url: string;
207
+ let headers: { [index: string]: string; };
208
+ let addInBody = false;
209
+ const formBoundary = uuid();
210
+ let postBody = `--${formBoundary}\r\n`;
211
+ postBody += `Authorization: Bearer ${storageToken}\r\n`;
212
+ postBody += `X-HTTP-Method-Override: POST\r\n`;
213
+ postBody += `Content-Type: application/json\r\n`;
214
+ postBody += `_post: 1\r\n`;
215
+ postBody += `\r\n${snapshotBody}\r\n`;
216
+ postBody += `\r\n--${formBoundary}--`;
217
+
218
+ if (postBody.length <= maxUmpPostBodySize) {
219
+ const urlObj = new URL(initialUrl);
220
+ urlObj.searchParams.set("ump", "1");
221
+ url = urlObj.href;
222
+ headers = {
223
+ "Content-Type": `multipart/form-data;boundary=${formBoundary}`,
224
+ };
225
+ addInBody = true;
226
+ } else {
227
+ const parts = getUrlAndHeadersWithAuth(
228
+ initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);
229
+ url = parts.url;
230
+ headers = {
231
+ ...parts.headers,
232
+ "Content-Type": "application/json",
233
+ };
234
+ postBody = snapshotBody;
235
+ }
201
236
 
202
237
  const fetchResponse = await runWithRetry(
203
238
  async () => epochTracker.fetchAndParseAsJSON<ICreateFileResponse>(
204
239
  url,
205
240
  {
206
- body: JSON.stringify(containerSnapshot),
241
+ body: postBody,
207
242
  headers,
208
243
  method: "POST",
209
244
  },
210
245
  "createFile",
246
+ addInBody,
211
247
  ),
212
248
  "createFile",
213
249
  logger,
@@ -16,7 +16,7 @@ import {
16
16
  InstrumentedStorageTokenFetcher,
17
17
  } from "@fluidframework/odsp-driver-definitions";
18
18
  import { ISnapshotTree } from "@fluidframework/protocol-definitions";
19
- import { isSystemMessage } from "@fluidframework/protocol-base";
19
+ import { isRuntimeMessage } from "@fluidframework/driver-utils";
20
20
  import { IOdspSnapshot, ISnapshotCachedEntry, IVersionedValueWithEpoch, persistedCacheValueVersion } from "./contracts";
21
21
  import { getQueryString } from "./getQueryString";
22
22
  import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
@@ -323,7 +323,7 @@ async function fetchLatestSnapshotCore(
323
323
  encodedBlobsSize,
324
324
  sequenceNumber,
325
325
  ops: snapshot.ops?.length ?? 0,
326
- nonSysOps: snapshot.ops?.filter((op) => !isSystemMessage(op)).length ?? 0,
326
+ userOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,
327
327
  headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,
328
328
  // Interval between the first fetch until the last byte of the last redirect.
329
329
  redirectTime,
@@ -354,8 +354,6 @@ async function fetchLatestSnapshotCore(
354
354
  ).catch((error) => {
355
355
  // We hit these errors in stress tests, under load
356
356
  // It's useful to try one more time in such case.
357
- // We might want to add DriverErrorType.offlineError in the future if we see evidence it happens
358
- // (not in "real" offline) and it actually helps.
359
357
  if (typeof error === "object" && error !== null && (error.errorType === DriverErrorType.fetchFailure ||
360
358
  error.errorType === OdspErrorType.fetchTimeout)) {
361
359
  error[getWithRetryForTokenRefreshRepeat] = true;