@fluidframework/odsp-driver 2.11.0 → 2.13.0

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 (39) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/api-report/odsp-driver.legacy.alpha.api.md +3 -0
  3. package/dist/WriteBufferUtils.js.map +1 -1
  4. package/dist/compactSnapshotParser.js +5 -5
  5. package/dist/compactSnapshotParser.js.map +1 -1
  6. package/dist/legacy.d.ts +1 -0
  7. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  8. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  9. package/dist/odspDriverUrlResolver.js +1 -1
  10. package/dist/odspDriverUrlResolver.js.map +1 -1
  11. package/dist/odspUtils.d.ts +2 -1
  12. package/dist/odspUtils.d.ts.map +1 -1
  13. package/dist/odspUtils.js +2 -1
  14. package/dist/odspUtils.js.map +1 -1
  15. package/dist/packageVersion.d.ts +1 -1
  16. package/dist/packageVersion.js +1 -1
  17. package/dist/packageVersion.js.map +1 -1
  18. package/lib/WriteBufferUtils.js.map +1 -1
  19. package/lib/compactSnapshotParser.js +5 -5
  20. package/lib/compactSnapshotParser.js.map +1 -1
  21. package/lib/legacy.d.ts +1 -0
  22. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
  23. package/lib/odspDocumentStorageServiceBase.js.map +1 -1
  24. package/lib/odspDriverUrlResolver.js +1 -1
  25. package/lib/odspDriverUrlResolver.js.map +1 -1
  26. package/lib/odspUtils.d.ts +2 -1
  27. package/lib/odspUtils.d.ts.map +1 -1
  28. package/lib/odspUtils.js +2 -1
  29. package/lib/odspUtils.js.map +1 -1
  30. package/lib/packageVersion.d.ts +1 -1
  31. package/lib/packageVersion.js +1 -1
  32. package/lib/packageVersion.js.map +1 -1
  33. package/package.json +15 -22
  34. package/src/WriteBufferUtils.ts +3 -3
  35. package/src/compactSnapshotParser.ts +5 -5
  36. package/src/odspDocumentStorageServiceBase.ts +3 -2
  37. package/src/odspDriverUrlResolver.ts +1 -1
  38. package/src/odspUtils.ts +2 -1
  39. package/src/packageVersion.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAK3D,kEAA6D;AAM7D,oEAO+C;AAC/C,yEAIoD;AACpD,+EAgB0D;AAC1D,uEAQkD;AAElD,yCAAmC;AACnC,iEAA+D;AAG/D,2DAAkE;AAErD,QAAA,iCAAiC,GAAG,mCAAmC,CAAC;AA2BrF,SAAS,YAAY,CAAC,OAAgB;IACrC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC9C,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,2BAA2B,CAChD,GAAiD;IAEjD,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACpD,MAAM,OAAO,GAAwB,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;QAC7E,QAAS,KAAkC,CAAC,SAAS,EAAE,CAAC;YACvD,kEAAkE;YAClE,KAAK,yBAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC;gBACxC,MAAM,SAAS,GAAG,KAA2B,CAAC;gBAC9C,OAAO,GAAG,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpF,CAAC;YAED,KAAK,yBAAc,CAAC,uBAAuB,CA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AAC,CAAC;IAEH,OAAO,GAAG,CAAC,IAAI,CAAC;AACjB,CAAC;AAvBD,wCAuBC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CACtC,iBAAoD;IAEpD,IAAI,oBAAwC,CAAC;IAC7C,IAAI,iBAAiB,IAAI,MAAM,IAAI,iBAAiB,EAAE,CAAC;QACtD,oBAAoB,GAAG,iBAAiB,CAAC,IAAI,CAAC;QAC9C,wGAAwG;QACxG,4BAA4B;QAC5B,iJAAiJ;IAClJ,CAAC;SAAM,IAAI,cAAc,CAAE,iBAAyB,EAAE,OAAO,CAAC,EAAE,CAAC;QAChE,4BAA4B;QAC5B,mJAAmJ;QACnJ,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC,IAAI,CAAC;IACjE,CAAC;SAAM,CAAC;QACP,4BAA4B;QAC5B,mJAAmJ;QACnJ,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC;IAC5D,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC;AAnBD,0DAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIResolvedUrl,\n\tISnapshot,\n\tIContainerPackageInfo,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype AuthorizationError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tisOnline,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tgetSPOAndGraphRequestIdsFromResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tICacheEntry,\n\tIOdspResolvedUrl,\n\tIOdspUrlParts,\n\tISharingLinkKind,\n\tInstrumentedStorageTokenFetcher,\n\tInstrumentedTokenFetcher,\n\tOdspErrorTypes,\n\tauthHeaderFromTokenResponse,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetchOptions,\n\tTokenFetcher,\n\tisTokenFromCache,\n\tsnapshotKey,\n\ttokenFromResponse,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype IConfigProvider,\n\ttype IFluidErrorBase,\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\tcreateChildLogger,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { fetch } from \"./fetch.js\";\nimport { storeLocatorInOdspUrl } from \"./odspFluidFileLink.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ISnapshotContents } from \"./odspPublicUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IOdspResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\tduration: number;\n}\n\n/**\n * This interface captures the portion of TokenFetchOptions required for refreshing tokens\n * It is controlled by logic in getWithRetryForTokenRefresh to specify what is the required refresh behavior\n */\nexport interface TokenFetchOptionsEx {\n\trefresh: boolean;\n\tclaims?: string;\n\ttenantId?: string;\n\t/**\n\t * The previous error we hit in {@link getWithRetryForTokenRefresh}.\n\t */\n\tpreviousError?: unknown;\n}\n\nfunction headersToMap(headers: Headers): Map<string, string> {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn 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>(\n\tget: (options: TokenFetchOptionsEx) => Promise<T>,\n): Promise<T> {\n\treturn get({ refresh: false }).catch(async (error) => {\n\t\tconst options: TokenFetchOptionsEx = { refresh: true, previousError: error };\n\t\tswitch ((error as Partial<IFluidErrorBase>).errorType) {\n\t\t\t// If the error is 401 or 403 refresh the token and try once more.\n\t\t\tcase OdspErrorTypes.authorizationError: {\n\t\t\t\tconst authError = error as AuthorizationError;\n\t\t\t\treturn get({ ...options, claims: authError.claims, tenantId: authError.tenantId });\n\t\t\t}\n\n\t\t\tcase OdspErrorTypes.incorrectServerResponse: // some error on the wire, retry once\n\t\t\tcase OdspErrorTypes.fetchTokenError: {\n\t\t\t\t// If the token was null, then retry once.\n\t\t\t\treturn get(options);\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\t// Caller may determine that it wants one retry\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-explicit-any\n\t\t\t\tif ((error as any)[getWithRetryForTokenRefreshRepeat] === true) {\n\t\t\t\t\treturn get(options);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t});\n}\n\nexport async function fetchHelper(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n\tconst start = performance.now();\n\n\t// Node-fetch and dom have conflicting typing, force them to work by casting for now\n\treturn fetch(requestInfo, requestInit).then(\n\t\tasync (fetchResponse) => {\n\t\t\tconst response = fetchResponse as unknown as Response;\n\t\t\t// Let's assume we can retry.\n\t\t\tif (!response) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t// pre-0.58 error message: No response from fetch call\n\t\t\t\t\t\"No response from ODSP fetch call\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!response.ok || response.status < 200 || response.status >= 300) {\n\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t// pre-0.58 error message prefix: odspFetchError\n\t\t\t\t\t`ODSP fetch error [${response.status}]`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tresponse,\n\t\t\t\t\tawait response.text(),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: response,\n\t\t\t\theaders,\n\t\t\t\tpropsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n\t\t\t\tduration: performance.now() - start,\n\t\t\t};\n\t\t},\n\t\t(error) => {\n\t\t\tconst online = isOnline();\n\n\t\t\t// The error message may not be suitable to log for privacy reasons, so tag it as such\n\t\t\tconst taggedErrorMessage = {\n\t\t\t\tvalue: `${error}`, // This uses toString for objects, which often results in `${error.name}: ${error.message}`\n\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t};\n\t\t\t// After redacting URLs we believe the error message is safe to log\n\t\t\tconst urlRegex = /((http|https):\\/\\/(\\S*))/i;\n\t\t\tconst redactedErrorText = taggedErrorMessage.value.replace(urlRegex, \"REDACTED_URL\");\n\n\t\t\t// This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\tif (error.name === \"AbortError\") {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (AbortError)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\t\t\t// TCP/IP timeout\n\t\t\tif (redactedErrorText.includes(\"ETIMEDOUT\")) {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (ETIMEDOUT)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (online === OnlineStatus.Offline) {\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Offline\n\t\t\t\t\t`ODSP fetch failure (Offline): ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.offlineError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// It is perhaps still possible that this is due to being offline, the error does not reveal enough\n\t\t\t\t// information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Fetch error\n\t\t\t\t\t`ODSP fetch failure: ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.fetchFailure,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t);\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\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet arrayBuffer: ArrayBuffer;\n\ttry {\n\t\tarrayBuffer = await content.arrayBuffer();\n\t} catch {\n\t\t// Parsing can fail and message could contain full request URI, including\n\t\t// tokens, etc. So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\tundefined, // response text\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = arrayBuffer.byteLength;\n\treturn {\n\t\theaders,\n\t\tcontent: arrayBuffer,\n\t\tpropsToLog,\n\t\tduration,\n\t};\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\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet text: string | undefined;\n\ttry {\n\t\ttext = await content.text();\n\t} catch {\n\t\t// JSON.parse() can fail and message would container full request URI, including\n\t\t// tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n\t\t// (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n\t\t// succeeds on retry.\n\t\t// So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t// pre-0.58 error message: errorWhileParsingFetchResponse\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\ttext,\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = text.length;\n\tconst res = {\n\t\theaders,\n\t\tcontent: JSON.parse(text) as T,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n\treturn res;\n}\n\nexport interface IFileInfoBase {\n\ttype: \"New\" | \"Existing\";\n\tsiteUrl: string;\n\tdriveId: string;\n}\n\nexport interface INewFileInfo extends IFileInfoBase {\n\ttype: \"New\";\n\tfilename: string;\n\tfilePath: string;\n\t/**\n\t * application can request creation of a share link along with the creation of a new file\n\t * by passing in an optional param to specify the kind of sharing link\n\t */\n\tcreateLinkType?: ISharingLinkKind;\n}\n\nexport interface IExistingFileInfo extends IFileInfoBase {\n\ttype: \"Existing\";\n\titemId: string;\n}\n\nexport function isNewFileInfo(\n\tfileInfo: INewFileInfo | IExistingFileInfo,\n): fileInfo is INewFileInfo {\n\treturn fileInfo.type === undefined || fileInfo.type === \"New\";\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n\tassert(\n\t\t(resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true,\n\t\t0x1de /* \"Not an ODSP resolved url\" */,\n\t);\n\treturn resolvedUrl as IOdspResolvedUrl;\n}\n\n/**\n * Type narrowing utility to determine if the provided {@link @fluidframework/driver-definitions#IResolvedUrl}\n * is an {@link @fluidframework/odsp-driver-definitions#IOdspResolvedUrl}.\n * @internal\n */\nexport function isOdspResolvedUrl(resolvedUrl: IResolvedUrl): resolvedUrl is IOdspResolvedUrl {\n\treturn \"odspResolvedUrl\" in resolvedUrl && resolvedUrl.odspResolvedUrl === true;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger): ITelemetryLoggerExt =>\n\tcreateChildLogger({\n\t\tlogger,\n\t\tnamespace: \"OdspDriver\",\n\t\tproperties: {\n\t\t\tall: {\n\t\t\t\tdriverVersion,\n\t\t\t},\n\t\t},\n\t});\n\n/**\n * Returns a function that can be used to fetch storage token.\n * Storage token can not be empty - if original delegate (tokenFetcher argument) returns null result, exception will be thrown\n */\nexport function toInstrumentedOdspStorageTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n): InstrumentedStorageTokenFetcher {\n\tconst res = toInstrumentedOdspTokenFetcher(\n\t\tlogger,\n\t\tresolvedUrlParts,\n\t\ttokenFetcher,\n\t\ttrue, // throwOnNullToken\n\t\tfalse, // returnPlainToken\n\t);\n\t// Drop undefined from signature - we can do it safely due to throwOnNullToken == true above\n\treturn res as InstrumentedStorageTokenFetcher;\n}\n\n/**\n * Returns a function that can be used to fetch storage or websocket token.\n * There are scenarios where websocket token is not required / present (consumer stack and ordering service token),\n * thus it could return null. Use toInstrumentedOdspStorageTokenFetcher if you deal with storage token.\n * @param returnPlainToken - When true, tokenResponse.token is returned. When false, tokenResponse.authorizationHeader is returned or an authorization header value is created based on tokenResponse.token\n */\nexport function toInstrumentedOdspTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tthrowOnNullToken: boolean,\n\treturnPlainToken: boolean,\n): InstrumentedTokenFetcher {\n\treturn async (\n\t\toptions: TokenFetchOptions,\n\t\tname: string,\n\t\talwaysRecordTokenFetchTelemetry: boolean = false,\n\t) => {\n\t\t// Telemetry note: if options.refresh is true, there is a potential perf issue:\n\t\t// Host should optimize and provide non-expired tokens on all critical paths.\n\t\t// Exceptions: race conditions around expiration, revoked tokens, host that does not care\n\t\t// (fluid-fetcher)\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: `${name}_GetToken`,\n\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\thasClaims: !!options.claims,\n\t\t\t\thasTenantId: !!options.tenantId,\n\t\t\t},\n\t\t\tasync (event) =>\n\t\t\t\ttokenFetcher({\n\t\t\t\t\t...options,\n\t\t\t\t\t...resolvedUrlParts,\n\t\t\t\t}).then(\n\t\t\t\t\t(tokenResponse) => {\n\t\t\t\t\t\tconst returnVal = returnPlainToken\n\t\t\t\t\t\t\t? tokenFromResponse(tokenResponse)\n\t\t\t\t\t\t\t: authHeaderFromTokenResponse(tokenResponse);\n\t\t\t\t\t\t// This event alone generates so many events that is materially impacts cost of telemetry\n\t\t\t\t\t\t// Thus do not report end event when it comes back quickly.\n\t\t\t\t\t\t// Note that most of the hosts do not report if result is comming from cache or not,\n\t\t\t\t\t\t// so we can't rely on that here. But always record if specified explicitly for cases such as\n\t\t\t\t\t\t// calling trees/latest during load.\n\t\t\t\t\t\tif (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n\t\t\t\t\t\t\tevent.end({\n\t\t\t\t\t\t\t\tfromCache: isTokenFromCache(tokenResponse),\n\t\t\t\t\t\t\t\tisNull: returnVal === null,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (returnVal === null && throwOnNullToken) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t// pre-0.58 error message: Token is null for ${name} call\n\t\t\t\t\t\t\t\t`The Host-provided token fetcher returned null`,\n\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t{ method: name, driverVersion },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn returnVal;\n\t\t\t\t\t},\n\t\t\t\t\t(error) => {\n\t\t\t\t\t\t// There is an important but unofficial contract here where token providers can set canRetry: true\n\t\t\t\t\t\t// to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\tconst rawCanRetry = error?.canRetry;\n\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\ttypeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n\t\t\t\t\t\t\t\t\t{ method: name, errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t{ cancel: \"generic\" },\n\t\t);\n\t};\n}\n\nexport function createCacheSnapshotKey(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tsnapshotWithLoadingGroupId: boolean | undefined,\n): ICacheEntry {\n\tconst cacheEntry: ICacheEntry = {\n\t\ttype: snapshotWithLoadingGroupId ? snapshotWithLoadingGroupIdKey : snapshotKey,\n\t\tkey: odspResolvedUrl.fileVersion ?? \"\",\n\t\tfile: {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t},\n\t};\n\treturn cacheEntry;\n}\n\nexport function snapshotWithLoadingGroupIdSupported(\n\tconfig: IConfigProvider,\n): boolean | undefined {\n\treturn config.getBoolean(\"Fluid.Container.UseLoadingGroupIdForSnapshotFetch2\");\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(\n\tshareLinkType: ISharingLinkKind | undefined,\n): string | undefined {\n\tif (!shareLinkType) {\n\t\treturn;\n\t}\n\tconst scope = shareLinkType.scope;\n\tlet shareLinkRequestParams = `createLinkScope=${scope}`;\n\tconst role = shareLinkType.role;\n\tshareLinkRequestParams = role\n\t\t? `${shareLinkRequestParams}&createLinkRole=${role}`\n\t\t: shareLinkRequestParams;\n\treturn shareLinkRequestParams;\n}\n\nexport function measure<T>(callback: () => T): [T, number] {\n\tconst start = performance.now();\n\tconst result = callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport async function measureP<T>(callback: () => Promise<T>): Promise<[T, number]> {\n\tconst start = performance.now();\n\tconst result = await callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport function getJoinSessionCacheKey(odspResolvedUrl: IOdspResolvedUrl): string {\n\treturn `${odspResolvedUrl.hashedDocumentId}/joinsession`;\n}\n\n/**\n * Utility API to check if the type of snapshot contents is `ISnapshot`.\n * @internal\n * @param obj - obj whose type needs to be identified.\n */\nexport function isInstanceOfISnapshot(\n\t// eslint-disable-next-line import/no-deprecated\n\tobj: ISnapshotContents | ISnapshot | undefined,\n): obj is ISnapshot {\n\treturn obj !== undefined && \"snapshotFormatV\" in obj && obj.snapshotFormatV === 1;\n}\n\n/**\n * This tells whether request if for a specific loading group or not. The snapshot which\n * we fetch on initial load, fetches all ungrouped content.\n */\nexport function isSnapshotFetchForLoadingGroup(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds !== undefined && loadingGroupIds.length > 0;\n}\n\n/*\n * This tells whether we are using legacy flow for fetching snapshot where we don't use\n * groupId query param in the trees latest network call.\n */\nexport function useLegacyFlowWithoutGroupsForSnapshotFetch(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds === undefined;\n}\n\n// back-compat: GitHub #9653\nconst isFluidPackage = (pkg: Record<string, unknown>): boolean =>\n\ttypeof pkg === \"object\" && typeof pkg?.name === \"string\" && typeof pkg?.fluid === \"object\";\n\n/**\n * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application\n * has a base URL (for example a sharing link) of the Fluid file, but does not have the locator information that would be used by Fluid\n * to load the file later.\n * @param baseUrl - The input URL on which the locator params will be appended.\n * @param resolvedUrl - odsp-driver's resolvedURL object.\n * @param dataStorePath - The relative data store path URL.\n * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n * will be extracted from the resolved url if present.\n * @param containerPackageName - Name of the package to be included in the URL.\n * @returns The provided base URL appended with odsp-specific locator information\n */\nexport function appendNavParam(\n\tbaseUrl: string,\n\todspResolvedUrl: IOdspResolvedUrl,\n\tdataStorePath: string,\n\tcontainerPackageName?: string,\n): string {\n\tconst url = new URL(baseUrl);\n\n\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\tconst actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? \"\");\n\n\tstoreLocatorInOdspUrl(url, {\n\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\tdriveId: odspResolvedUrl.driveId,\n\t\titemId: odspResolvedUrl.itemId,\n\t\tdataStorePath: actualDataStorePath,\n\t\tappName: odspResolvedUrl.appName,\n\t\tcontainerPackageName,\n\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\tcontext: odspResolvedUrl.context,\n\t});\n\n\treturn url.href;\n}\n\n/**\n * Returns the package name of the container package information.\n * @param packageInfoSource - Information of the package connected to the URL\n * @returns The package name of the container package\n */\nexport function getContainerPackageName(\n\tpackageInfoSource: IContainerPackageInfo | undefined,\n): string | undefined {\n\tlet containerPackageName: string | undefined;\n\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\tcontainerPackageName = packageInfoSource.name;\n\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t} else {\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t}\n\treturn containerPackageName;\n}\n"]}
1
+ {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAK3D,kEAA6D;AAM7D,oEAO+C;AAC/C,yEAIoD;AACpD,+EAgB0D;AAC1D,uEAQkD;AAElD,yCAAmC;AACnC,iEAA+D;AAG/D,2DAAkE;AAErD,QAAA,iCAAiC,GAAG,mCAAmC,CAAC;AA2BrF,SAAS,YAAY,CAAC,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A4B;QAC5B,mJAAmJ;QACnJ,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC,IAAI,CAAC;IACjE,CAAC;SAAM,CAAC;QACP,4BAA4B;QAC5B,mJAAmJ;QACnJ,oBAAoB,GAAI,iBAAyB,EAAE,OAAO,CAAC;IAC5D,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC;AAnBD,0DAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIResolvedUrl,\n\tISnapshot,\n\tIContainerPackageInfo,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype AuthorizationError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tisOnline,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tgetSPOAndGraphRequestIdsFromResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tICacheEntry,\n\tIOdspResolvedUrl,\n\tIOdspUrlParts,\n\tISharingLinkKind,\n\tInstrumentedStorageTokenFetcher,\n\tInstrumentedTokenFetcher,\n\tOdspErrorTypes,\n\tauthHeaderFromTokenResponse,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetchOptions,\n\tTokenFetcher,\n\tisTokenFromCache,\n\tsnapshotKey,\n\ttokenFromResponse,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype IConfigProvider,\n\ttype IFluidErrorBase,\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\tcreateChildLogger,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { fetch } from \"./fetch.js\";\nimport { storeLocatorInOdspUrl } from \"./odspFluidFileLink.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ISnapshotContents } from \"./odspPublicUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IOdspResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\tduration: number;\n}\n\n/**\n * This interface captures the portion of TokenFetchOptions required for refreshing tokens\n * It is controlled by logic in getWithRetryForTokenRefresh to specify what is the required refresh behavior\n */\nexport interface TokenFetchOptionsEx {\n\trefresh: boolean;\n\tclaims?: string;\n\ttenantId?: string;\n\t/**\n\t * The previous error we hit in {@link getWithRetryForTokenRefresh}.\n\t */\n\tpreviousError?: unknown;\n}\n\nfunction headersToMap(headers: Headers): Map<string, string> {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn 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>(\n\tget: (options: TokenFetchOptionsEx) => Promise<T>,\n): Promise<T> {\n\treturn get({ refresh: false }).catch(async (error) => {\n\t\tconst options: TokenFetchOptionsEx = { refresh: true, previousError: error };\n\t\tswitch ((error as Partial<IFluidErrorBase>).errorType) {\n\t\t\t// If the error is 401 or 403 refresh the token and try once more.\n\t\t\tcase OdspErrorTypes.authorizationError: {\n\t\t\t\tconst authError = error as AuthorizationError;\n\t\t\t\treturn get({ ...options, claims: authError.claims, tenantId: authError.tenantId });\n\t\t\t}\n\n\t\t\tcase OdspErrorTypes.incorrectServerResponse: // some error on the wire, retry once\n\t\t\tcase OdspErrorTypes.fetchTokenError: {\n\t\t\t\t// If the token was null, then retry once.\n\t\t\t\treturn get(options);\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\t// Caller may determine that it wants one retry\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-explicit-any\n\t\t\t\tif ((error as any)[getWithRetryForTokenRefreshRepeat] === true) {\n\t\t\t\t\treturn get(options);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t});\n}\n\nexport async function fetchHelper(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n\tconst start = performance.now();\n\n\t// Node-fetch and dom have conflicting typing, force them to work by casting for now\n\treturn fetch(requestInfo, requestInit).then(\n\t\tasync (fetchResponse) => {\n\t\t\tconst response = fetchResponse as unknown as Response;\n\t\t\t// Let's assume we can retry.\n\t\t\tif (!response) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t// pre-0.58 error message: No response from fetch call\n\t\t\t\t\t\"No response from ODSP fetch call\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!response.ok || response.status < 200 || response.status >= 300) {\n\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t// pre-0.58 error message prefix: odspFetchError\n\t\t\t\t\t`ODSP fetch error [${response.status}]`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tresponse,\n\t\t\t\t\tawait response.text(),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: response,\n\t\t\t\theaders,\n\t\t\t\tpropsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n\t\t\t\tduration: performance.now() - start,\n\t\t\t};\n\t\t},\n\t\t(error) => {\n\t\t\tconst online = isOnline();\n\n\t\t\t// The error message may not be suitable to log for privacy reasons, so tag it as such\n\t\t\tconst taggedErrorMessage = {\n\t\t\t\tvalue: `${error}`, // This uses toString for objects, which often results in `${error.name}: ${error.message}`\n\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t};\n\t\t\t// After redacting URLs we believe the error message is safe to log\n\t\t\tconst urlRegex = /((http|https):\\/\\/(\\S*))/i;\n\t\t\tconst redactedErrorText = taggedErrorMessage.value.replace(urlRegex, \"REDACTED_URL\");\n\n\t\t\t// This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\tif (error.name === \"AbortError\") {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (AbortError)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\t\t\t// TCP/IP timeout\n\t\t\tif (redactedErrorText.includes(\"ETIMEDOUT\")) {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (ETIMEDOUT)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (online === OnlineStatus.Offline) {\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Offline\n\t\t\t\t\t`ODSP fetch failure (Offline): ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.offlineError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// It is perhaps still possible that this is due to being offline, the error does not reveal enough\n\t\t\t\t// information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Fetch error\n\t\t\t\t\t`ODSP fetch failure: ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.fetchFailure,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t);\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\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet arrayBuffer: ArrayBuffer;\n\ttry {\n\t\tarrayBuffer = await content.arrayBuffer();\n\t} catch {\n\t\t// Parsing can fail and message could contain full request URI, including\n\t\t// tokens, etc. So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\tundefined, // response text\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = arrayBuffer.byteLength;\n\treturn {\n\t\theaders,\n\t\tcontent: arrayBuffer,\n\t\tpropsToLog,\n\t\tduration,\n\t};\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\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet text: string | undefined;\n\ttry {\n\t\ttext = await content.text();\n\t} catch {\n\t\t// JSON.parse() can fail and message would container full request URI, including\n\t\t// tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n\t\t// (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n\t\t// succeeds on retry.\n\t\t// So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t// pre-0.58 error message: errorWhileParsingFetchResponse\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\ttext,\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = text.length;\n\tconst res = {\n\t\theaders,\n\t\tcontent: JSON.parse(text) as T,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n\treturn res;\n}\n\nexport interface IFileInfoBase {\n\ttype: \"New\" | \"Existing\";\n\tsiteUrl: string;\n\tdriveId: string;\n}\n\nexport interface INewFileInfo extends IFileInfoBase {\n\ttype: \"New\";\n\tfilename: string;\n\tfilePath: string;\n\t/**\n\t * application can request creation of a share link along with the creation of a new file\n\t * by passing in an optional param to specify the kind of sharing link\n\t */\n\tcreateLinkType?: ISharingLinkKind;\n}\n\nexport interface IExistingFileInfo extends IFileInfoBase {\n\ttype: \"Existing\";\n\titemId: string;\n}\n\nexport function isNewFileInfo(\n\tfileInfo: INewFileInfo | IExistingFileInfo,\n): fileInfo is INewFileInfo {\n\treturn fileInfo.type === undefined || fileInfo.type === \"New\";\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n\tassert(\n\t\t(resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true,\n\t\t0x1de /* \"Not an ODSP resolved url\" */,\n\t);\n\treturn resolvedUrl as IOdspResolvedUrl;\n}\n\n/**\n * Type narrowing utility to determine if the provided {@link @fluidframework/driver-definitions#IResolvedUrl}\n * is an {@link @fluidframework/odsp-driver-definitions#IOdspResolvedUrl}.\n * @legacy\n * @alpha\n */\nexport function isOdspResolvedUrl(resolvedUrl: IResolvedUrl): resolvedUrl is IOdspResolvedUrl {\n\treturn \"odspResolvedUrl\" in resolvedUrl && resolvedUrl.odspResolvedUrl === true;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger): ITelemetryLoggerExt =>\n\tcreateChildLogger({\n\t\tlogger,\n\t\tnamespace: \"OdspDriver\",\n\t\tproperties: {\n\t\t\tall: {\n\t\t\t\tdriverVersion,\n\t\t\t},\n\t\t},\n\t});\n\n/**\n * Returns a function that can be used to fetch storage token.\n * Storage token can not be empty - if original delegate (tokenFetcher argument) returns null result, exception will be thrown\n */\nexport function toInstrumentedOdspStorageTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n): InstrumentedStorageTokenFetcher {\n\tconst res = toInstrumentedOdspTokenFetcher(\n\t\tlogger,\n\t\tresolvedUrlParts,\n\t\ttokenFetcher,\n\t\ttrue, // throwOnNullToken\n\t\tfalse, // returnPlainToken\n\t);\n\t// Drop undefined from signature - we can do it safely due to throwOnNullToken == true above\n\treturn res as InstrumentedStorageTokenFetcher;\n}\n\n/**\n * Returns a function that can be used to fetch storage or websocket token.\n * There are scenarios where websocket token is not required / present (consumer stack and ordering service token),\n * thus it could return null. Use toInstrumentedOdspStorageTokenFetcher if you deal with storage token.\n * @param returnPlainToken - When true, tokenResponse.token is returned. When false, tokenResponse.authorizationHeader is returned or an authorization header value is created based on tokenResponse.token\n */\nexport function toInstrumentedOdspTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tthrowOnNullToken: boolean,\n\treturnPlainToken: boolean,\n): InstrumentedTokenFetcher {\n\treturn async (\n\t\toptions: TokenFetchOptions,\n\t\tname: string,\n\t\talwaysRecordTokenFetchTelemetry: boolean = false,\n\t) => {\n\t\t// Telemetry note: if options.refresh is true, there is a potential perf issue:\n\t\t// Host should optimize and provide non-expired tokens on all critical paths.\n\t\t// Exceptions: race conditions around expiration, revoked tokens, host that does not care\n\t\t// (fluid-fetcher)\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: `${name}_GetToken`,\n\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\thasClaims: !!options.claims,\n\t\t\t\thasTenantId: !!options.tenantId,\n\t\t\t},\n\t\t\tasync (event) =>\n\t\t\t\ttokenFetcher({\n\t\t\t\t\t...options,\n\t\t\t\t\t...resolvedUrlParts,\n\t\t\t\t}).then(\n\t\t\t\t\t(tokenResponse) => {\n\t\t\t\t\t\tconst returnVal = returnPlainToken\n\t\t\t\t\t\t\t? tokenFromResponse(tokenResponse)\n\t\t\t\t\t\t\t: authHeaderFromTokenResponse(tokenResponse);\n\t\t\t\t\t\t// This event alone generates so many events that is materially impacts cost of telemetry\n\t\t\t\t\t\t// Thus do not report end event when it comes back quickly.\n\t\t\t\t\t\t// Note that most of the hosts do not report if result is comming from cache or not,\n\t\t\t\t\t\t// so we can't rely on that here. But always record if specified explicitly for cases such as\n\t\t\t\t\t\t// calling trees/latest during load.\n\t\t\t\t\t\tif (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n\t\t\t\t\t\t\tevent.end({\n\t\t\t\t\t\t\t\tfromCache: isTokenFromCache(tokenResponse),\n\t\t\t\t\t\t\t\tisNull: returnVal === null,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (returnVal === null && throwOnNullToken) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t// pre-0.58 error message: Token is null for ${name} call\n\t\t\t\t\t\t\t\t`The Host-provided token fetcher returned null`,\n\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t{ method: name, driverVersion },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn returnVal;\n\t\t\t\t\t},\n\t\t\t\t\t(error) => {\n\t\t\t\t\t\t// There is an important but unofficial contract here where token providers can set canRetry: true\n\t\t\t\t\t\t// to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\tconst rawCanRetry = error?.canRetry;\n\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\ttypeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n\t\t\t\t\t\t\t\t\t{ method: name, errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t{ cancel: \"generic\" },\n\t\t);\n\t};\n}\n\nexport function createCacheSnapshotKey(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tsnapshotWithLoadingGroupId: boolean | undefined,\n): ICacheEntry {\n\tconst cacheEntry: ICacheEntry = {\n\t\ttype: snapshotWithLoadingGroupId ? snapshotWithLoadingGroupIdKey : snapshotKey,\n\t\tkey: odspResolvedUrl.fileVersion ?? \"\",\n\t\tfile: {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t},\n\t};\n\treturn cacheEntry;\n}\n\nexport function snapshotWithLoadingGroupIdSupported(\n\tconfig: IConfigProvider,\n): boolean | undefined {\n\treturn config.getBoolean(\"Fluid.Container.UseLoadingGroupIdForSnapshotFetch2\");\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(\n\tshareLinkType: ISharingLinkKind | undefined,\n): string | undefined {\n\tif (!shareLinkType) {\n\t\treturn;\n\t}\n\tconst scope = shareLinkType.scope;\n\tlet shareLinkRequestParams = `createLinkScope=${scope}`;\n\tconst role = shareLinkType.role;\n\tshareLinkRequestParams = role\n\t\t? `${shareLinkRequestParams}&createLinkRole=${role}`\n\t\t: shareLinkRequestParams;\n\treturn shareLinkRequestParams;\n}\n\nexport function measure<T>(callback: () => T): [T, number] {\n\tconst start = performance.now();\n\tconst result = callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport async function measureP<T>(callback: () => Promise<T>): Promise<[T, number]> {\n\tconst start = performance.now();\n\tconst result = await callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport function getJoinSessionCacheKey(odspResolvedUrl: IOdspResolvedUrl): string {\n\treturn `${odspResolvedUrl.hashedDocumentId}/joinsession`;\n}\n\n/**\n * Utility API to check if the type of snapshot contents is `ISnapshot`.\n * @internal\n * @param obj - obj whose type needs to be identified.\n */\nexport function isInstanceOfISnapshot(\n\t// eslint-disable-next-line import/no-deprecated\n\tobj: ISnapshotContents | ISnapshot | undefined,\n): obj is ISnapshot {\n\treturn obj !== undefined && \"snapshotFormatV\" in obj && obj.snapshotFormatV === 1;\n}\n\n/**\n * This tells whether request if for a specific loading group or not. The snapshot which\n * we fetch on initial load, fetches all ungrouped content.\n */\nexport function isSnapshotFetchForLoadingGroup(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds !== undefined && loadingGroupIds.length > 0;\n}\n\n/*\n * This tells whether we are using legacy flow for fetching snapshot where we don't use\n * groupId query param in the trees latest network call.\n */\nexport function useLegacyFlowWithoutGroupsForSnapshotFetch(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds === undefined;\n}\n\n// back-compat: GitHub #9653\nconst isFluidPackage = (pkg: Record<string, unknown>): boolean =>\n\ttypeof pkg === \"object\" && typeof pkg?.name === \"string\" && typeof pkg?.fluid === \"object\";\n\n/**\n * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application\n * has a base URL (for example a sharing link) of the Fluid file, but does not have the locator information that would be used by Fluid\n * to load the file later.\n * @param baseUrl - The input URL on which the locator params will be appended.\n * @param resolvedUrl - odsp-driver's resolvedURL object.\n * @param dataStorePath - The relative data store path URL.\n * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n * will be extracted from the resolved url if present.\n * @param containerPackageName - Name of the package to be included in the URL.\n * @returns The provided base URL appended with odsp-specific locator information\n */\nexport function appendNavParam(\n\tbaseUrl: string,\n\todspResolvedUrl: IOdspResolvedUrl,\n\tdataStorePath: string,\n\tcontainerPackageName?: string,\n): string {\n\tconst url = new URL(baseUrl);\n\n\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\tconst actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? \"\");\n\n\tstoreLocatorInOdspUrl(url, {\n\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\tdriveId: odspResolvedUrl.driveId,\n\t\titemId: odspResolvedUrl.itemId,\n\t\tdataStorePath: actualDataStorePath,\n\t\tappName: odspResolvedUrl.appName,\n\t\tcontainerPackageName,\n\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\tcontext: odspResolvedUrl.context,\n\t});\n\n\treturn url.href;\n}\n\n/**\n * Returns the package name of the container package information.\n * @param packageInfoSource - Information of the package connected to the URL\n * @returns The package name of the container package\n */\nexport function getContainerPackageName(\n\tpackageInfoSource: IContainerPackageInfo | undefined,\n): string | undefined {\n\tlet containerPackageName: string | undefined;\n\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\tcontainerPackageName = packageInfoSource.name;\n\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t} else {\n\t\t// TODO: use a stronger type\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t}\n\treturn containerPackageName;\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 = "2.11.0";
8
+ export declare const pkgVersion = "2.13.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/odsp-driver";
11
- exports.pkgVersion = "2.11.0";
11
+ exports.pkgVersion = "2.13.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,QAAQ,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.11.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,QAAQ,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.13.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WriteBufferUtils.js","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,QAAQ,EACR,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,cAAc,GACd,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,WAAW;IAAxB;QACW,SAAI,GAAgB,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,UAAK,GAAG,CAAC,CAAC;IAsCrB,CAAC;IApCU,IAAI,CAAC,IAAY;QAC1B,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAChC,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,G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,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,kBAAmB,SAAQ,QAAQ;IACxC;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS,CAAC,MAAmB;QACnC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;IAC5D,CAAC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,kBAAkB;IAC5D;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS;QACf,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tBlobCore,\n\tMarkerCodes,\n\tMarkerCodesEnd,\n\tMarkerCodesStart,\n\tNodeCore,\n\tcodeToBytesMap,\n\tgetValueSafely,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Buffer class, used to sequentially writ data.\n * Used by tree code to serialize tree into binary representation.\n */\nexport class WriteBuffer {\n\tprotected data?: Uint8Array = new Uint8Array(4096);\n\tprotected index = 0;\n\n\tprotected push(code: number): void {\n\t\tassert(this.data !== undefined, 0x225 /* \"Data should be there\" */);\n\t\tconst length = this.data.length;\n\t\tif (this.index === length) {\n\t\t\tconst newData = new Uint8Array(length * 1.2 + 4096);\n\t\t\tlet index = 0;\n\t\t\tconst oldData = this.data;\n\t\t\twhile (index < length) {\n\t\t\t\tnewData[index] = oldData[index];\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tthis.data = newData;\n\t\t}\n\t\tthis.data[this.index] = code % 256;\n\t\tthis.index++;\n\t}\n\n\tpublic write(codeArg: number, lengthArg = 1): void {\n\t\tlet code = codeArg;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tthis.push(code % 256);\n\t\t\tcode = Math.floor(code / 256);\n\t\t\tlength--;\n\t\t}\n\t\tassert(code === 0, 0x226 /* Should write complete data */);\n\t}\n\n\tpublic done(): Uint8Array {\n\t\tassert(this.data !== undefined, 0x227 /* \"Data should be there\" */);\n\t\t// We can slice it to have smaller memory representation.\n\t\t// But it will be way more expensive in terms of CPU cycles!\n\t\tconst buffer = this.data.subarray(0, this.index);\n\t\tthis.data = undefined;\n\t\treturn buffer;\n\t}\n}\n\n// This list of maps below is reverse mapping of Marker Codes specified in zipItDataRepresentationUtils.ts file.\n// We can also found them on server filestore code.\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n\n/**\n * This contains mapping of number of bytes representing the corresponding string length to Marker Codes.\n */\nconst utf8StringBytesToCodeMap = {\n\t0: 13,\n\t1: 14,\n\t2: 15,\n\t4: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding length in which actual data(base64 string)\n * will be stored to Marker Codes.\n */\nconst binaryBytesToCodeMap = {\n\t0: 32,\n\t1: 33,\n\t2: 34,\n\t4: 35,\n\t8: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding const string id to Marker Codes.\n */\nconst constStringBytesToCodeMap = {\n\t1: 17,\n\t2: 18,\n\t4: 19,\n};\n\n/**\n * This contains mapping of number of bytes to Marker Codes representing the corresponding Integer.\n */\nconst integerBytesToCodeMap = {\n\t0: 1,\n\t1: 3,\n\t2: 5,\n\t4: 7,\n\t8: 9,\n};\n\n/**\n * This contains mapping of boolean to Marker Codes representing the corresponding bool value.\n */\nconst boolToCodeMap = [\n\t12, // false\n\t11, // true\n];\n\n/**\n * Calculate how many bytes are required to encode an integer. This is always power of 2.\n * So if 6 bytes are required to store an integer than it will return 8. 0 is a special case for which we\n * return 0 as it is usually just represented by marker code and we don't store the actual data.\n * @param num - number to encode.\n */\nexport function calcLength(numArg: number): number {\n\tif (numArg === 0) {\n\t\treturn 0;\n\t}\n\tlet num = numArg;\n\tlet lengthLen = 0;\n\twhile (num > 0) {\n\t\tnum = Math.floor(num / 256);\n\t\tlengthLen++;\n\t}\n\tlet res = 1;\n\twhile (res < lengthLen) {\n\t\tres *= 2;\n\t}\n\treturn res;\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param content - string to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeDictionaryString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tdictionary: Map<string, number>,\n): void {\n\tlet id = dictionary.get(content);\n\tlet idLength: number;\n\tif (id === undefined) {\n\t\tconst data = IsoBuffer.from(content, \"utf8\");\n\t\tconst lengthOfDataLen = calcLength(data.length);\n\n\t\tid = dictionary.size + 1;\n\t\tidLength = calcLength(id);\n\t\tdictionary.set(content, id);\n\t\tconst code =\n\t\t\tlengthOfDataLen > 1 || idLength > 1\n\t\t\t\t? MarkerCodes.ConstStringDeclareBig\n\t\t\t\t: MarkerCodes.ConstStringDeclare;\n\t\t// Write marker code for const string.\n\t\tbuffer.write(code);\n\t\tconst bytes = getValueSafely(codeToBytesMap, code);\n\t\tassert(\n\t\t\tbytes >= lengthOfDataLen,\n\t\t\t0x283 /* \"Length of data len should fit in the bytes from the map\" */,\n\t\t);\n\t\tassert(bytes >= idLength, 0x284 /* \"Length of id should fit in the bytes from the map\" */);\n\t\t// Assign and write id for const string.\n\t\tbuffer.write(id, bytes);\n\t\t// Write length of const string.\n\t\tbuffer.write(data.length, bytes);\n\t\t// Write const string data.\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t} else {\n\t\tidLength = calcLength(id);\n\t}\n\t// Write Marker Code\n\tbuffer.write(getValueSafely(constStringBytesToCodeMap, idLength));\n\t// Write id of const string\n\tbuffer.write(id, idLength);\n}\n\nfunction serializeString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tcodeMap = binaryBytesToCodeMap,\n): void {\n\tserializeBlob(buffer, IsoBuffer.from(content, \"utf8\"), utf8StringBytesToCodeMap);\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param blob - blob to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeBlob(\n\tbuffer: WriteBuffer,\n\tdata: Uint8Array,\n\tcodeMap: Record<number, number> = binaryBytesToCodeMap,\n): void {\n\tconst lengthOfDataLen = calcLength(data.length);\n\t// Write Marker code.\n\tbuffer.write(getValueSafely(codeMap, lengthOfDataLen));\n\t// Write actual data if length greater than 0, otherwise Marker Code is enough.\n\tif (lengthOfDataLen > 0) {\n\t\tbuffer.write(data.length, lengthOfDataLen);\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t}\n}\n\n/**\n * Implementation of serialization of nodes with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param nodeCore - Node to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeNodeCore(\n\tbuffer: WriteBuffer,\n\tnodeCore: NodeCore,\n\tdictionary: Map<string, number>,\n): void {\n\tfor (const child of nodeCore.nodes) {\n\t\tif (child instanceof NodeCore) {\n\t\t\t// For a tree node start and end with set/list start and end marker codes.\n\t\t\tconst startCode = MarkerCodesStart[child.type];\n\t\t\tconst endCode = MarkerCodesEnd[child.type];\n\t\t\tassert(startCode !== undefined, 0x285 /* \"Start code should not undefined\" */);\n\t\t\tassert(endCode !== undefined, 0x286 /* \"End code should not undefined\" */);\n\t\t\tbuffer.write(startCode);\n\t\t\tserializeNodeCore(buffer, child, dictionary);\n\t\t\tbuffer.write(endCode);\n\t\t} else if (child instanceof BlobCore) {\n\t\t\tserializeBlob(buffer, child.buffer);\n\t\t} else if (typeof child === \"number\") {\n\t\t\t// Calculate length in which integer will be stored\n\t\t\tconst len = calcLength(child);\n\t\t\t// Write corresponding Marker code for length of integer.\n\t\t\tbuffer.write(getValueSafely(integerBytesToCodeMap, len));\n\t\t\t// Write actual number if greater than 0, otherwise Marker Code is enough.\n\t\t\tif (len > 0) {\n\t\t\t\tbuffer.write(child, len);\n\t\t\t}\n\t\t} else if (typeof child === \"boolean\") {\n\t\t\tbuffer.write(boolToCodeMap[child ? 1 : 0]);\n\t\t} else {\n\t\t\tassert(child._stringElement, 0x3dd /* Unsupported node type */);\n\t\t\tif (child.dictionary) {\n\t\t\t\tserializeDictionaryString(buffer, child.content, dictionary);\n\t\t\t} else {\n\t\t\t\tserializeString(buffer, child.content);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass NodeCoreSerializer extends NodeCore {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(buffer: WriteBuffer): void {\n\t\tserializeNodeCore(buffer, this, new Map<string, number>());\n\t}\n}\n\nexport class TreeBuilderSerializer extends NodeCoreSerializer {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst buffer = new WriteBuffer();\n\t\tsuper.serialize(buffer);\n\t\treturn buffer.done();\n\t}\n}\n"]}
1
+ {"version":3,"file":"WriteBufferUtils.js","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EACN,QAAQ,EACR,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,cAAc,GACd,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,WAAW;IAAxB;QACW,SAAI,GAAgB,IAAI,UAAU,C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,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAChE,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtB,yBAAyB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACP,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,kBAAmB,SAAQ,QAAQ;IACxC;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS,CAAC,MAAmB;QACnC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;IAC5D,CAAC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,kBAAkB;IAC5D;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS;QACf,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tBlobCore,\n\tMarkerCodes,\n\tMarkerCodesEnd,\n\tMarkerCodesStart,\n\tNodeCore,\n\tcodeToBytesMap,\n\tgetValueSafely,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Buffer class, used to sequentially writ data.\n * Used by tree code to serialize tree into binary representation.\n */\nexport class WriteBuffer {\n\tprotected data?: Uint8Array = new Uint8Array(4096);\n\tprotected index = 0;\n\n\tprotected push(code: number): void {\n\t\tassert(this.data !== undefined, 0x225 /* \"Data should be there\" */);\n\t\tconst length = this.data.length;\n\t\tif (this.index === length) {\n\t\t\tconst newData = new Uint8Array(length * 1.2 + 4096);\n\t\t\tlet index = 0;\n\t\t\tconst oldData = this.data;\n\t\t\twhile (index < length) {\n\t\t\t\tnewData[index] = oldData[index]!;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tthis.data = newData;\n\t\t}\n\t\tthis.data[this.index] = code % 256;\n\t\tthis.index++;\n\t}\n\n\tpublic write(codeArg: number, lengthArg = 1): void {\n\t\tlet code = codeArg;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tthis.push(code % 256);\n\t\t\tcode = Math.floor(code / 256);\n\t\t\tlength--;\n\t\t}\n\t\tassert(code === 0, 0x226 /* Should write complete data */);\n\t}\n\n\tpublic done(): Uint8Array {\n\t\tassert(this.data !== undefined, 0x227 /* \"Data should be there\" */);\n\t\t// We can slice it to have smaller memory representation.\n\t\t// But it will be way more expensive in terms of CPU cycles!\n\t\tconst buffer = this.data.subarray(0, this.index);\n\t\tthis.data = undefined;\n\t\treturn buffer;\n\t}\n}\n\n// This list of maps below is reverse mapping of Marker Codes specified in zipItDataRepresentationUtils.ts file.\n// We can also found them on server filestore code.\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n\n/**\n * This contains mapping of number of bytes representing the corresponding string length to Marker Codes.\n */\nconst utf8StringBytesToCodeMap = {\n\t0: 13,\n\t1: 14,\n\t2: 15,\n\t4: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding length in which actual data(base64 string)\n * will be stored to Marker Codes.\n */\nconst binaryBytesToCodeMap = {\n\t0: 32,\n\t1: 33,\n\t2: 34,\n\t4: 35,\n\t8: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding const string id to Marker Codes.\n */\nconst constStringBytesToCodeMap = {\n\t1: 17,\n\t2: 18,\n\t4: 19,\n};\n\n/**\n * This contains mapping of number of bytes to Marker Codes representing the corresponding Integer.\n */\nconst integerBytesToCodeMap = {\n\t0: 1,\n\t1: 3,\n\t2: 5,\n\t4: 7,\n\t8: 9,\n};\n\n/**\n * This contains mapping of boolean to Marker Codes representing the corresponding bool value.\n */\nconst boolToCodeMap = [\n\t12, // false\n\t11, // true\n];\n\n/**\n * Calculate how many bytes are required to encode an integer. This is always power of 2.\n * So if 6 bytes are required to store an integer than it will return 8. 0 is a special case for which we\n * return 0 as it is usually just represented by marker code and we don't store the actual data.\n * @param num - number to encode.\n */\nexport function calcLength(numArg: number): number {\n\tif (numArg === 0) {\n\t\treturn 0;\n\t}\n\tlet num = numArg;\n\tlet lengthLen = 0;\n\twhile (num > 0) {\n\t\tnum = Math.floor(num / 256);\n\t\tlengthLen++;\n\t}\n\tlet res = 1;\n\twhile (res < lengthLen) {\n\t\tres *= 2;\n\t}\n\treturn res;\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param content - string to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeDictionaryString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tdictionary: Map<string, number>,\n): void {\n\tlet id = dictionary.get(content);\n\tlet idLength: number;\n\tif (id === undefined) {\n\t\tconst data = IsoBuffer.from(content, \"utf8\");\n\t\tconst lengthOfDataLen = calcLength(data.length);\n\n\t\tid = dictionary.size + 1;\n\t\tidLength = calcLength(id);\n\t\tdictionary.set(content, id);\n\t\tconst code =\n\t\t\tlengthOfDataLen > 1 || idLength > 1\n\t\t\t\t? MarkerCodes.ConstStringDeclareBig\n\t\t\t\t: MarkerCodes.ConstStringDeclare;\n\t\t// Write marker code for const string.\n\t\tbuffer.write(code);\n\t\tconst bytes = getValueSafely(codeToBytesMap, code);\n\t\tassert(\n\t\t\tbytes >= lengthOfDataLen,\n\t\t\t0x283 /* \"Length of data len should fit in the bytes from the map\" */,\n\t\t);\n\t\tassert(bytes >= idLength, 0x284 /* \"Length of id should fit in the bytes from the map\" */);\n\t\t// Assign and write id for const string.\n\t\tbuffer.write(id, bytes);\n\t\t// Write length of const string.\n\t\tbuffer.write(data.length, bytes);\n\t\t// Write const string data.\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t} else {\n\t\tidLength = calcLength(id);\n\t}\n\t// Write Marker Code\n\tbuffer.write(getValueSafely(constStringBytesToCodeMap, idLength));\n\t// Write id of const string\n\tbuffer.write(id, idLength);\n}\n\nfunction serializeString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tcodeMap = binaryBytesToCodeMap,\n): void {\n\tserializeBlob(buffer, IsoBuffer.from(content, \"utf8\"), utf8StringBytesToCodeMap);\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param blob - blob to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeBlob(\n\tbuffer: WriteBuffer,\n\tdata: Uint8Array,\n\tcodeMap: Record<number, number> = binaryBytesToCodeMap,\n): void {\n\tconst lengthOfDataLen = calcLength(data.length);\n\t// Write Marker code.\n\tbuffer.write(getValueSafely(codeMap, lengthOfDataLen));\n\t// Write actual data if length greater than 0, otherwise Marker Code is enough.\n\tif (lengthOfDataLen > 0) {\n\t\tbuffer.write(data.length, lengthOfDataLen);\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t}\n}\n\n/**\n * Implementation of serialization of nodes with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param nodeCore - Node to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeNodeCore(\n\tbuffer: WriteBuffer,\n\tnodeCore: NodeCore,\n\tdictionary: Map<string, number>,\n): void {\n\tfor (const child of nodeCore.nodes) {\n\t\tif (child instanceof NodeCore) {\n\t\t\t// For a tree node start and end with set/list start and end marker codes.\n\t\t\tconst startCode: MarkerCodesStart | undefined = MarkerCodesStart[child.type];\n\t\t\tconst endCode: MarkerCodesEnd | undefined = MarkerCodesEnd[child.type];\n\t\t\tassert(startCode !== undefined, 0x285 /* \"Start code should not undefined\" */);\n\t\t\tassert(endCode !== undefined, 0x286 /* \"End code should not undefined\" */);\n\t\t\tbuffer.write(startCode);\n\t\t\tserializeNodeCore(buffer, child, dictionary);\n\t\t\tbuffer.write(endCode);\n\t\t} else if (child instanceof BlobCore) {\n\t\t\tserializeBlob(buffer, child.buffer);\n\t\t} else if (typeof child === \"number\") {\n\t\t\t// Calculate length in which integer will be stored\n\t\t\tconst len = calcLength(child);\n\t\t\t// Write corresponding Marker code for length of integer.\n\t\t\tbuffer.write(getValueSafely(integerBytesToCodeMap, len));\n\t\t\t// Write actual number if greater than 0, otherwise Marker Code is enough.\n\t\t\tif (len > 0) {\n\t\t\t\tbuffer.write(child, len);\n\t\t\t}\n\t\t} else if (typeof child === \"boolean\") {\n\t\t\tbuffer.write(boolToCodeMap[child ? 1 : 0]);\n\t\t} else {\n\t\t\tassert(child._stringElement, 0x3dd /* Unsupported node type */);\n\t\t\tif (child.dictionary) {\n\t\t\t\tserializeDictionaryString(buffer, child.content, dictionary);\n\t\t\t} else {\n\t\t\t\tserializeString(buffer, child.content);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass NodeCoreSerializer extends NodeCore {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(buffer: WriteBuffer): void {\n\t\tserializeNodeCore(buffer, this, new Map<string, number>());\n\t}\n}\n\nexport class TreeBuilderSerializer extends NodeCoreSerializer {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst buffer = new WriteBuffer();\n\t\tsuper.serialize(buffer);\n\t\treturn buffer.done();\n\t}\n}\n"]}
@@ -38,7 +38,7 @@ function readBlobSection(node) {
38
38
  const records = getNodeProps(blob);
39
39
  assertBlobCoreInstance(records.data, "data should be of BlobCore type");
40
40
  const id = getStringInstance(records.id, "blob id should be string");
41
- blobContents.set(id, records.data.arrayBuffer);
41
+ blobContents.set(id, records.data?.arrayBuffer);
42
42
  }
43
43
  }
44
44
  return { blobContents, slowBlobStructureCount };
@@ -53,14 +53,14 @@ function readOpsSection(node) {
53
53
  const records = getNodeProps(node);
54
54
  assertNumberInstance(records.firstSequenceNumber, "Seq number should be a number");
55
55
  assertNodeCoreInstance(records.deltas, "Deltas should be a Node");
56
- for (let i = 0; i < records.deltas.length; ++i) {
56
+ for (let i = 0; i < records.deltas?.length; ++i) {
57
57
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
58
- ops.push(JSON.parse(records.deltas.getString(i)));
58
+ ops.push(JSON.parse(records.deltas?.getString(i)));
59
59
  }
60
60
  // Due to a bug at service side, in an edge case service was serializing deltas even
61
61
  // when there are no ops. So just make the code resilient to that bug. Service has also
62
62
  // fixed that bug.
63
- assert(ops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber, 0x280 /* "Validate first op seq number" */);
63
+ assert(ops.length === 0 || records.firstSequenceNumber?.valueOf() === ops[0].sequenceNumber, 0x280 /* "Validate first op seq number" */);
64
64
  return ops;
65
65
  }
66
66
  /**
@@ -183,7 +183,7 @@ function readSnapshotSection(node) {
183
183
  assertNumberInstance(records.sequenceNumber, "sequenceNumber should be of type number");
184
184
  const { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } = readTreeSection(records.treeNodes);
185
185
  snapshotTree.id = getStringInstance(records.id, "snapshotId should be string");
186
- const sequenceNumber = records.sequenceNumber.valueOf();
186
+ const sequenceNumber = records.sequenceNumber?.valueOf();
187
187
  return {
188
188
  sequenceNumber,
189
189
  snapshotTree,
@@ -1 +1 @@
1
- {"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[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AC3D,6BAA6B,EAAE,QAAQ,CAAC,6BAA6B;SACrE;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport {\n\tNodeCore,\n\tNodeTypes,\n\tTreeBuilder,\n\tassertBlobCoreInstance,\n\tassertBoolInstance,\n\tassertNodeCoreInstance,\n\tassertNumberInstance,\n\tgetNodeProps,\n\tgetStringInstance,\n} from \"./zipItDataRepresentationUtils.js\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\n/**\n * The parsing is significantly faster if the position of props is well known instead of dynamic. So these variables\n * represents how many times slower parsing path is executed. This will be then logged into telemetry.\n * @internal\n */\nexport interface ISnapshotContentsWithProps extends ISnapshot {\n\ttelemetryProps: Record<string, number>;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes): {\n\tblobContents: Map<string, ArrayBuffer>;\n\tslowBlobStructureCount: number;\n} {\n\tassertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n\tlet slowBlobStructureCount = 0;\n\tconst blobContents: Map<string, ArrayBuffer> = new Map();\n\tfor (const blob of node) {\n\t\tassertNodeCoreInstance(blob, \"blob should be node\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tif (\n\t\t\tblob.length === 4 &&\n\t\t\tblob.getMaybeString(0) === \"id\" &&\n\t\t\tblob.getMaybeString(2) === \"data\"\n\t\t) {\n\t\t\t// \"id\": <node name>\n\t\t\t// \"data\": <blob>\n\t\t\tblobContents.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n\t\t} else {\n\t\t\t/**\n\t\t\t * More generalized workflow\n\t\t\t */\n\t\t\tslowBlobStructureCount += 1;\n\t\t\tconst records = getNodeProps(blob);\n\t\t\tassertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n\t\t\tconst id = getStringInstance(records.id, \"blob id should be string\");\n\t\t\tblobContents.set(id, records.data.arrayBuffer);\n\t\t}\n\t}\n\treturn { blobContents, slowBlobStructureCount };\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes): ISequencedDocumentMessage[] {\n\tassertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n\tconst ops: ISequencedDocumentMessage[] = [];\n\tconst records = getNodeProps(node);\n\tassertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n\tassertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n\tfor (let i = 0; i < records.deltas.length; ++i) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\tops.push(JSON.parse(records.deltas.getString(i)));\n\t}\n\t// Due to a bug at service side, in an edge case service was serializing deltas even\n\t// when there are no ops. So just make the code resilient to that bug. Service has also\n\t// fixed that bug.\n\tassert(\n\t\tops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,\n\t\t0x280 /* \"Validate first op seq number\" */,\n\t);\n\treturn ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore): {\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tlet slowTreeStructureCount = 0;\n\tlet treeStructureCountWithGroupId = 0;\n\tconst trees: Record<string, ISnapshotTree> = {};\n\tconst snapshotTree: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees,\n\t};\n\tfor (const treeNode of node) {\n\t\tassertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tconst length = treeNode.length;\n\t\tif (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n\t\t\tswitch (length) {\n\t\t\t\tcase 2: {\n\t\t\t\t\t// empty tree case\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\ttrees[treeNode.getString(1)] = { blobs: {}, trees: {} };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase 4: {\n\t\t\t\t\tconst content = treeNode.getMaybeString(2);\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (content === \"children\") {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(3));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (content === \"value\") {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 6: {\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"nodeType\": 3\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"nodeType\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"value\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"unreferenced\": true\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"unreferenced\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"children\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(5));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tassert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n\t\t\t\t\t\tsnapshotTree.unreferenced = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * More generalized workflow\n\t\t */\n\t\tslowTreeStructureCount++;\n\t\tconst records = getNodeProps(treeNode);\n\n\t\tif (records.unreferenced !== undefined) {\n\t\t\tassertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n\t\t\tassert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n\t\t\tsnapshotTree.unreferenced = true;\n\t\t}\n\n\t\tconst path = getStringInstance(records.name, \"Path name should be string\");\n\t\tif (records.value !== undefined) {\n\t\t\tsnapshotTree.blobs[path] = getStringInstance(\n\t\t\t\trecords.value,\n\t\t\t\t\"Blob value should be string\",\n\t\t\t);\n\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t} else if (records.children !== undefined) {\n\t\t\tassertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n\t\t\tconst result = readTreeSection(records.children);\n\t\t\ttrees[path] = result.snapshotTree;\n\t\t\tif (records.groupId !== undefined) {\n\t\t\t\tconst groupId = getStringInstance(records.groupId, \"groupId should be a string\");\n\t\t\t\ttrees[path].groupId = groupId;\n\t\t\t\ttreeStructureCountWithGroupId++;\n\t\t\t}\n\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t} else {\n\t\t\ttrees[path] = { blobs: {}, trees: {} };\n\t\t}\n\t}\n\treturn { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId };\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): {\n\tsequenceNumber: number;\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tassertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n\tconst records = getNodeProps(node);\n\n\tassertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n\tassertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n\tconst { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } =\n\t\treadTreeSection(records.treeNodes);\n\tsnapshotTree.id = getStringInstance(records.id, \"snapshotId should be string\");\n\tconst sequenceNumber = records.sequenceNumber.valueOf();\n\treturn {\n\t\tsequenceNumber,\n\t\tsnapshotTree,\n\t\tslowTreeStructureCount,\n\t\ttreeStructureCountWithGroupId,\n\t};\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns Tree, blobs and ops from the snapshot.\n * @internal\n */\nexport function parseCompactSnapshotResponse(\n\tbuffer: Uint8Array,\n\tlogger: ITelemetryLoggerExt,\n): ISnapshotContentsWithProps {\n\tconst { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);\n\tassert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n\tconst root = builder.getNode(0);\n\n\tconst records = getNodeProps(root);\n\n\tconst mrv = getStringInstance(records.mrv, \"minReadVersion should be string\");\n\tconst cv = getStringInstance(records.cv, \"createVersion should be string\");\n\tif (records.lsn !== undefined) {\n\t\tassertNumberInstance(records.lsn, \"lsn should be a number\");\n\t}\n\n\tassert(\n\t\tNumber.parseFloat(snapshotMinReadVersion) >= Number.parseFloat(mrv),\n\t\t0x20f /* \"Driver min read version should >= to server minReadVersion\" */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(cv) >= Number.parseFloat(snapshotMinReadVersion),\n\t\t0x210 /* \"Snapshot should be created with minReadVersion or above\" */,\n\t);\n\tassert(\n\t\tcurrentReadVersion === cv,\n\t\t0x2c2 /* \"Create Version should be equal to currentReadVersion\" */,\n\t);\n\n\tconst [snapshot, durationSnapshotTree] = measure(() =>\n\t\treadSnapshotSection(records.snapshot),\n\t);\n\tconst [blobContents, durationBlobs] = measure(() => readBlobSection(records.blobs));\n\n\treturn {\n\t\t...snapshot,\n\t\tblobContents: blobContents.blobContents,\n\t\tops: records.deltas === undefined ? [] : readOpsSection(records.deltas),\n\t\tlatestSequenceNumber: records.lsn,\n\t\tsnapshotFormatV: 1,\n\t\ttelemetryProps: {\n\t\t\t...telemetryProps,\n\t\t\tdurationSnapshotTree,\n\t\t\tdurationBlobs,\n\t\t\tslowTreeStructureCount: snapshot.slowTreeStructureCount,\n\t\t\tslowBlobStructureCount: blobContents.slowBlobStructureCount,\n\t\t\ttreeStructureCountWithGroupId: snapshot.treeStructureCountWithGroupId,\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EAAE,UAAU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oft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport {\n\tNodeCore,\n\tNodeTypes,\n\tTreeBuilder,\n\tassertBlobCoreInstance,\n\tassertBoolInstance,\n\tassertNodeCoreInstance,\n\tassertNumberInstance,\n\tgetNodeProps,\n\tgetStringInstance,\n} from \"./zipItDataRepresentationUtils.js\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\n/**\n * The parsing is significantly faster if the position of props is well known instead of dynamic. So these variables\n * represents how many times slower parsing path is executed. This will be then logged into telemetry.\n * @internal\n */\nexport interface ISnapshotContentsWithProps extends ISnapshot {\n\ttelemetryProps: Record<string, number>;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes): {\n\tblobContents: Map<string, ArrayBuffer>;\n\tslowBlobStructureCount: number;\n} {\n\tassertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n\tlet slowBlobStructureCount = 0;\n\tconst blobContents: Map<string, ArrayBuffer> = new Map();\n\tfor (const blob of node) {\n\t\tassertNodeCoreInstance(blob, \"blob should be node\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tif (\n\t\t\tblob.length === 4 &&\n\t\t\tblob.getMaybeString(0) === \"id\" &&\n\t\t\tblob.getMaybeString(2) === \"data\"\n\t\t) {\n\t\t\t// \"id\": <node name>\n\t\t\t// \"data\": <blob>\n\t\t\tblobContents.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n\t\t} else {\n\t\t\t/**\n\t\t\t * More generalized workflow\n\t\t\t */\n\t\t\tslowBlobStructureCount += 1;\n\t\t\tconst records = getNodeProps(blob);\n\t\t\tassertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n\t\t\tconst id = getStringInstance(records.id, \"blob id should be string\");\n\t\t\tblobContents.set(id, records.data?.arrayBuffer);\n\t\t}\n\t}\n\treturn { blobContents, slowBlobStructureCount };\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes): ISequencedDocumentMessage[] {\n\tassertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n\tconst ops: ISequencedDocumentMessage[] = [];\n\tconst records = getNodeProps(node);\n\tassertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n\tassertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n\tfor (let i = 0; i < records.deltas?.length; ++i) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\tops.push(JSON.parse(records.deltas?.getString(i)));\n\t}\n\t// Due to a bug at service side, in an edge case service was serializing deltas even\n\t// when there are no ops. So just make the code resilient to that bug. Service has also\n\t// fixed that bug.\n\tassert(\n\t\tops.length === 0 || records.firstSequenceNumber?.valueOf() === ops[0].sequenceNumber,\n\t\t0x280 /* \"Validate first op seq number\" */,\n\t);\n\treturn ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore): {\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tlet slowTreeStructureCount = 0;\n\tlet treeStructureCountWithGroupId = 0;\n\tconst trees: Record<string, ISnapshotTree> = {};\n\tconst snapshotTree: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees,\n\t};\n\tfor (const treeNode of node) {\n\t\tassertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tconst length = treeNode.length;\n\t\tif (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n\t\t\tswitch (length) {\n\t\t\t\tcase 2: {\n\t\t\t\t\t// empty tree case\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\ttrees[treeNode.getString(1)] = { blobs: {}, trees: {} };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase 4: {\n\t\t\t\t\tconst content = treeNode.getMaybeString(2);\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (content === \"children\") {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(3));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (content === \"value\") {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 6: {\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"nodeType\": 3\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"nodeType\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"value\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"unreferenced\": true\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"unreferenced\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"children\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(5));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tassert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n\t\t\t\t\t\tsnapshotTree.unreferenced = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * More generalized workflow\n\t\t */\n\t\tslowTreeStructureCount++;\n\t\tconst records = getNodeProps(treeNode);\n\n\t\tif (records.unreferenced !== undefined) {\n\t\t\tassertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n\t\t\tassert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n\t\t\tsnapshotTree.unreferenced = true;\n\t\t}\n\n\t\tconst path = getStringInstance(records.name, \"Path name should be string\");\n\t\tif (records.value !== undefined) {\n\t\t\tsnapshotTree.blobs[path] = getStringInstance(\n\t\t\t\trecords.value,\n\t\t\t\t\"Blob value should be string\",\n\t\t\t);\n\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t} else if (records.children !== undefined) {\n\t\t\tassertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n\t\t\tconst result = readTreeSection(records.children);\n\t\t\ttrees[path] = result.snapshotTree;\n\t\t\tif (records.groupId !== undefined) {\n\t\t\t\tconst groupId = getStringInstance(records.groupId, \"groupId should be a string\");\n\t\t\t\ttrees[path].groupId = groupId;\n\t\t\t\ttreeStructureCountWithGroupId++;\n\t\t\t}\n\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t} else {\n\t\t\ttrees[path] = { blobs: {}, trees: {} };\n\t\t}\n\t}\n\treturn { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId };\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): {\n\tsequenceNumber: number;\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tassertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n\tconst records = getNodeProps(node);\n\n\tassertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n\tassertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n\tconst { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } =\n\t\treadTreeSection(records.treeNodes);\n\tsnapshotTree.id = getStringInstance(records.id, \"snapshotId should be string\");\n\tconst sequenceNumber = records.sequenceNumber?.valueOf();\n\treturn {\n\t\tsequenceNumber,\n\t\tsnapshotTree,\n\t\tslowTreeStructureCount,\n\t\ttreeStructureCountWithGroupId,\n\t};\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns Tree, blobs and ops from the snapshot.\n * @internal\n */\nexport function parseCompactSnapshotResponse(\n\tbuffer: Uint8Array,\n\tlogger: ITelemetryLoggerExt,\n): ISnapshotContentsWithProps {\n\tconst { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);\n\tassert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n\tconst root = builder.getNode(0);\n\n\tconst records = getNodeProps(root);\n\n\tconst mrv = getStringInstance(records.mrv, \"minReadVersion should be string\");\n\tconst cv = getStringInstance(records.cv, \"createVersion should be string\");\n\tif (records.lsn !== undefined) {\n\t\tassertNumberInstance(records.lsn, \"lsn should be a number\");\n\t}\n\n\tassert(\n\t\tNumber.parseFloat(snapshotMinReadVersion) >= Number.parseFloat(mrv),\n\t\t0x20f /* \"Driver min read version should >= to server minReadVersion\" */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(cv) >= Number.parseFloat(snapshotMinReadVersion),\n\t\t0x210 /* \"Snapshot should be created with minReadVersion or above\" */,\n\t);\n\tassert(\n\t\tcurrentReadVersion === cv,\n\t\t0x2c2 /* \"Create Version should be equal to currentReadVersion\" */,\n\t);\n\n\tconst [snapshot, durationSnapshotTree] = measure(() =>\n\t\treadSnapshotSection(records.snapshot),\n\t);\n\tconst [blobContents, durationBlobs] = measure(() => readBlobSection(records.blobs));\n\n\treturn {\n\t\t...snapshot,\n\t\tblobContents: blobContents.blobContents,\n\t\tops: records.deltas === undefined ? [] : readOpsSection(records.deltas),\n\t\tlatestSequenceNumber: records.lsn,\n\t\tsnapshotFormatV: 1,\n\t\ttelemetryProps: {\n\t\t\t...telemetryProps,\n\t\t\tdurationSnapshotTree,\n\t\t\tdurationBlobs,\n\t\t\tslowTreeStructureCount: snapshot.slowTreeStructureCount,\n\t\t\tslowBlobStructureCount: blobContents.slowBlobStructureCount,\n\t\t\ttreeStructureCountWithGroupId: snapshot.treeStructureCountWithGroupId,\n\t\t},\n\t};\n}\n"]}
package/lib/legacy.d.ts CHANGED
@@ -36,6 +36,7 @@ export {
36
36
  encodeOdspFluidDataStoreLocator,
37
37
  getHashedDocumentId,
38
38
  getLocatorFromOdspUrl,
39
+ isOdspResolvedUrl,
39
40
  locatorQueryParamName,
40
41
  prefetchLatestSnapshot,
41
42
  storeLocatorInOdspUrl
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentStorageServiceBase.d.ts","sourceRo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QAChB,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tFetchSource,\n\tFiveDaysMs,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tLoaderCachingPolicy,\n\tISnapshotTree,\n\tICreateBlobResponse,\n\tIVersion,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { maximumCacheDurationMs } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { IConfigProvider } from \"@fluidframework/telemetry-utils/internal\";\n\nclass BlobCache {\n\t// Save the timeout so we can cancel and reschedule it as needed\n\tprivate blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n\t// If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n\t// This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n\t// too many calls to setTimeout/clearTimeout.\n\tprivate deferBlobCacheClear: boolean = false;\n\n\tprivate readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n\t// Tracks all blob IDs evicted from cache\n\tprivate readonly blobsEvicted: Set<string> = new Set();\n\n\t// Initial time-out to purge data from cache\n\t// If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n\t// requests to storage, which brings down perf and may trip protection limits causing 429s\n\tprivate blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n\t// SPO does not keep old snapshots around for long, so we are running chances of not\n\t// being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n\t// even if blob read by runtime, it could be read again in the future)\n\t// So for now, purging is disabled.\n\tprivate readonly purgeEnabled = false;\n\n\tpublic get value(): Map<string, ArrayBuffer> {\n\t\treturn this._blobCache;\n\t}\n\n\tpublic addBlobs(blobs: Map<string, ArrayBuffer>): void {\n\t\tfor (const [blobId, value] of blobs.entries()) {\n\t\t\tthis._blobCache.set(blobId, value);\n\t\t}\n\t\t// Reset the timer on cache set\n\t\tthis.scheduleClearBlobsCache();\n\t}\n\n\t/**\n\t * Schedule a timer for clearing the blob cache or defer the current one.\n\t */\n\tprivate scheduleClearBlobsCache(): void {\n\t\tif (this.blobCacheTimeout !== undefined) {\n\t\t\t// If we already have an outstanding timer, just signal that we should defer the clear\n\t\t\tthis.deferBlobCacheClear = true;\n\t\t} else if (this.purgeEnabled) {\n\t\t\t// If we don't have an outstanding timer, set a timer\n\t\t\t// When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n\t\t\tconst clearCacheOrDefer = (): void => {\n\t\t\t\tthis.blobCacheTimeout = undefined;\n\t\t\t\tif (this.deferBlobCacheClear) {\n\t\t\t\t\tthis.deferBlobCacheClear = false;\n\t\t\t\t\tthis.scheduleClearBlobsCache();\n\t\t\t\t} else {\n\t\t\t\t\t// NOTE: Slightly better algorithm here would be to purge either only big blobs,\n\t\t\t\t\t// or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n\t\t\t\t\t// Purging is optimizing memory footprint. But count controls potential number of storage requests\n\t\t\t\t\t// We want to optimize both - memory footprint and number of future requests to storage.\n\t\t\t\t\t// Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n\t\t\t\t\t// control when blobs will be used.\n\t\t\t\t\tfor (const blobId of this._blobCache.keys()) {\n\t\t\t\t\t\tthis.blobsEvicted.add(blobId);\n\t\t\t\t\t}\n\t\t\t\t\tthis._blobCache.clear();\n\t\t\t\t}\n\t\t\t};\n\t\t\tthis.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n\t\t\t// any future storage reads that get into the cache should be cleared from cache rather quickly -\n\t\t\t// there is not much value in keeping them longer\n\t\t\tthis.blobCacheTimeoutDuration = 10 * 1000;\n\t\t}\n\t}\n\n\tpublic getBlob(blobId: string): {\n\t\tblobContent: ArrayBuffer | undefined;\n\t\tevicted: boolean;\n\t} {\n\t\t// Reset the timer on attempted cache read\n\t\tthis.scheduleClearBlobsCache();\n\t\tconst blobContent = this._blobCache.get(blobId);\n\t\tconst evicted = this.blobsEvicted.has(blobId);\n\t\treturn { blobContent, evicted };\n\t}\n\n\tpublic setBlob(blobId: string, blob: ArrayBuffer): Map<string, ArrayBuffer> | undefined {\n\t\t// This API is called as result of cache miss and reading blob from storage.\n\t\t// Runtime never reads same blob twice.\n\t\t// The only reason we may get read request for same blob is blob de-duping in summaries.\n\t\t// Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n\t\t// Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n\t\t// blobs are de-duped.\n\t\tconst size = blob.byteLength;\n\t\tif (size < 256 * 1024) {\n\t\t\t// Reset the timer on cache set\n\t\t\tthis.scheduleClearBlobsCache();\n\t\t\treturn this._blobCache.set(blobId, blob);\n\t\t} else {\n\t\t\t// we evicted it here by not caching.\n\t\t\tthis.blobsEvicted.add(blobId);\n\t\t}\n\t}\n}\n\nexport abstract class OdspDocumentStorageServiceBase implements IDocumentStorageService {\n\treadonly policies: IDocumentStorageServicePolicies;\n\n\tconstructor(config: IConfigProvider) {\n\t\t// We circumvent the restrictions on the policy only when using this TestOverride setting,\n\t\t// which also applies to the code that reads from the cache in epochTracker.ts\n\t\t// This may result in files created for testing being unusable in production sessions,\n\t\t// due to the GC code guarding against this policy changing over the lifetime of a file.\n\t\tconst maximumCacheDurationMsInEffect = (\n\t\t\tconfig.getBoolean(\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\")\n\t\t\t\t? 0\n\t\t\t\t: maximumCacheDurationMs\n\t\t) as FiveDaysMs;\n\n\t\tthis.policies = {\n\t\t\t// By default, ODSP tells the container not to prefetch/cache.\n\t\t\tcaching: LoaderCachingPolicy.NoCaching,\n\t\t\tmaximumCacheDurationMs: maximumCacheDurationMsInEffect,\n\t\t};\n\t}\n\tprotected readonly commitCache: Map<string, ISnapshotTree> = new Map();\n\n\tprivate _ops: ISequencedDocumentMessage[] | undefined;\n\n\tprivate _snapshotSequenceNumber: number | undefined;\n\n\tprotected readonly blobCache = new BlobCache();\n\n\tpublic set ops(ops: ISequencedDocumentMessage[] | undefined) {\n\t\tassert(\n\t\t\tthis._ops === undefined,\n\t\t\t0x0a5 /* \"Trying to set ops when they are already set!\" */,\n\t\t);\n\t\tthis._ops = ops;\n\t}\n\n\tpublic get ops(): ISequencedDocumentMessage[] | undefined {\n\t\treturn this._ops;\n\t}\n\n\tpublic get snapshotSequenceNumber(): number | undefined {\n\t\treturn this._snapshotSequenceNumber;\n\t}\n\n\tpublic abstract createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;\n\n\tprivate async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n\t\tconst { blobContent, evicted } = this.blobCache.getBlob(blobId);\n\t\treturn blobContent ?? this.fetchBlobFromStorage(blobId, evicted);\n\t}\n\n\tprotected abstract fetchBlobFromStorage(\n\t\tblobId: string,\n\t\tevicted: boolean,\n\t): Promise<ArrayBuffer>;\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.readBlobCore(blobId);\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tlet id: string;\n\t\tif (version?.id) {\n\t\t\tid = version.id;\n\t\t} else {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst versions = await this.getVersions(null, 1, scenarioName);\n\t\t\tif (!versions || versions.length === 0) {\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tid = versions[0].id;\n\t\t}\n\n\t\tconst snapshotTree = await this.readTree(id, scenarioName);\n\t\tif (!snapshotTree) {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this.combineProtocolAndAppSnapshotTree(snapshotTree);\n\t}\n\n\tpublic abstract getSnapshot(\n\t\tsnapshotFetchOptions?: ISnapshotFetchOptions,\n\t): Promise<ISnapshot>;\n\n\tpublic abstract getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]>;\n\n\tpublic abstract uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string>;\n\n\tpublic async downloadSummary(commit: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"Not implemented yet\");\n\t}\n\n\tprotected setRootTree(id: string, tree: ISnapshotTree): void {\n\t\tthis.commitCache.set(id, tree);\n\t}\n\n\tprotected initBlobsCache(blobs: Map<string, ArrayBuffer>): void {\n\t\tthis.blobCache.addBlobs(blobs);\n\t}\n\n\tprivate async readTree(id: string, scenarioName?: string): Promise<ISnapshotTree | null> {\n\t\tlet tree = this.commitCache.get(id);\n\t\tif (!tree) {\n\t\t\ttree = await this.fetchTreeFromSnapshot(id, scenarioName);\n\t\t}\n\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\treturn tree ?? null;\n\t}\n\n\tprotected abstract fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | undefined>;\n\n\tprotected combineProtocolAndAppSnapshotTree(snapshotTree: ISnapshotTree): ISnapshotTree {\n\t\t// When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n\t\t// So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n\t\tconst hierarchicalAppTree = snapshotTree.trees[\".app\"];\n\t\tconst hierarchicalProtocolTree = snapshotTree.trees[\".protocol\"];\n\t\tconst summarySnapshotTree: ISnapshotTree = {\n\t\t\tblobs: {\n\t\t\t\t...hierarchicalAppTree.blobs,\n\t\t\t},\n\t\t\ttrees: {\n\t\t\t\t...hierarchicalAppTree.trees,\n\t\t\t},\n\t\t\tid: snapshotTree.id,\n\t\t};\n\n\t\t// The app tree could have a .protocol in that case we want to server protocol to override it.\n\t\t// Snapshot which are for a loading GroupId, will not have a protocol tree.\n\t\tif (hierarchicalProtocolTree !== undefined) {\n\t\t\tsummarySnapshotTree.trees[\".protocol\"] = hierarchicalProtocolTree;\n\t\t}\n\n\t\treturn summarySnapshotTree;\n\t}\n\n\tprotected initializeFromSnapshot(\n\t\todspSnapshotCacheValue: ISnapshot,\n\t\tcacheOps: boolean = true,\n\t\tcacheSnapshot: boolean = true,\n\t): string | undefined {\n\t\tthis._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n\t\tconst { snapshotTree, blobContents, ops } = odspSnapshotCacheValue;\n\n\t\t// id should be undefined in case of just ops in snapshot.\n\t\tlet id: string | undefined;\n\t\tif (snapshotTree) {\n\t\t\tid = snapshotTree.id;\n\t\t\tassert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n\t\t\tif (cacheSnapshot) {\n\t\t\t\tthis.setRootTree(id, snapshotTree);\n\t\t\t}\n\t\t}\n\n\t\t// Currently always cache blobs as container runtime is not caching them.\n\t\tif (blobContents !== undefined) {\n\t\t\tthis.initBlobsCache(blobContents);\n\t\t}\n\n\t\tif (cacheOps) {\n\t\t\tthis.ops = ops;\n\t\t}\n\t\treturn id;\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDocumentStorageServiceBase.js","sourceRoot":"","sources":["../src/odspDocumentStorageServiceBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAQN,mBAAmB,GAKnB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAG1F,MAAM,SAAS;IAAf;QAGC,kGAAkG;Q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,CAAC;QACnC,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAChB,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tFetchSource,\n\tFiveDaysMs,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tLoaderCachingPolicy,\n\tISnapshotTree,\n\tICreateBlobResponse,\n\tIVersion,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { maximumCacheDurationMs } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { IConfigProvider } from \"@fluidframework/telemetry-utils/internal\";\n\nclass BlobCache {\n\t// Save the timeout so we can cancel and reschedule it as needed\n\tprivate blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n\t// If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n\t// This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n\t// too many calls to setTimeout/clearTimeout.\n\tprivate deferBlobCacheClear: boolean = false;\n\n\tprivate readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n\t// Tracks all blob IDs evicted from cache\n\tprivate readonly blobsEvicted: Set<string> = new Set();\n\n\t// Initial time-out to purge data from cache\n\t// If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n\t// requests to storage, which brings down perf and may trip protection limits causing 429s\n\tprivate blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n\t// SPO does not keep old snapshots around for long, so we are running chances of not\n\t// being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n\t// even if blob read by runtime, it could be read again in the future)\n\t// So for now, purging is disabled.\n\tprivate readonly purgeEnabled = false;\n\n\tpublic get value(): Map<string, ArrayBuffer> {\n\t\treturn this._blobCache;\n\t}\n\n\tpublic addBlobs(blobs: Map<string, ArrayBuffer>): void {\n\t\tfor (const [blobId, value] of blobs.entries()) {\n\t\t\tthis._blobCache.set(blobId, value);\n\t\t}\n\t\t// Reset the timer on cache set\n\t\tthis.scheduleClearBlobsCache();\n\t}\n\n\t/**\n\t * Schedule a timer for clearing the blob cache or defer the current one.\n\t */\n\tprivate scheduleClearBlobsCache(): void {\n\t\tif (this.blobCacheTimeout !== undefined) {\n\t\t\t// If we already have an outstanding timer, just signal that we should defer the clear\n\t\t\tthis.deferBlobCacheClear = true;\n\t\t} else if (this.purgeEnabled) {\n\t\t\t// If we don't have an outstanding timer, set a timer\n\t\t\t// When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n\t\t\tconst clearCacheOrDefer = (): void => {\n\t\t\t\tthis.blobCacheTimeout = undefined;\n\t\t\t\tif (this.deferBlobCacheClear) {\n\t\t\t\t\tthis.deferBlobCacheClear = false;\n\t\t\t\t\tthis.scheduleClearBlobsCache();\n\t\t\t\t} else {\n\t\t\t\t\t// NOTE: Slightly better algorithm here would be to purge either only big blobs,\n\t\t\t\t\t// or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n\t\t\t\t\t// Purging is optimizing memory footprint. But count controls potential number of storage requests\n\t\t\t\t\t// We want to optimize both - memory footprint and number of future requests to storage.\n\t\t\t\t\t// Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n\t\t\t\t\t// control when blobs will be used.\n\t\t\t\t\tfor (const blobId of this._blobCache.keys()) {\n\t\t\t\t\t\tthis.blobsEvicted.add(blobId);\n\t\t\t\t\t}\n\t\t\t\t\tthis._blobCache.clear();\n\t\t\t\t}\n\t\t\t};\n\t\t\tthis.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n\t\t\t// any future storage reads that get into the cache should be cleared from cache rather quickly -\n\t\t\t// there is not much value in keeping them longer\n\t\t\tthis.blobCacheTimeoutDuration = 10 * 1000;\n\t\t}\n\t}\n\n\tpublic getBlob(blobId: string): {\n\t\tblobContent: ArrayBuffer | undefined;\n\t\tevicted: boolean;\n\t} {\n\t\t// Reset the timer on attempted cache read\n\t\tthis.scheduleClearBlobsCache();\n\t\tconst blobContent = this._blobCache.get(blobId);\n\t\tconst evicted = this.blobsEvicted.has(blobId);\n\t\treturn { blobContent, evicted };\n\t}\n\n\tpublic setBlob(blobId: string, blob: ArrayBuffer): Map<string, ArrayBuffer> | undefined {\n\t\t// This API is called as result of cache miss and reading blob from storage.\n\t\t// Runtime never reads same blob twice.\n\t\t// The only reason we may get read request for same blob is blob de-duping in summaries.\n\t\t// Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n\t\t// Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n\t\t// blobs are de-duped.\n\t\tconst size = blob.byteLength;\n\t\tif (size < 256 * 1024) {\n\t\t\t// Reset the timer on cache set\n\t\t\tthis.scheduleClearBlobsCache();\n\t\t\treturn this._blobCache.set(blobId, blob);\n\t\t} else {\n\t\t\t// we evicted it here by not caching.\n\t\t\tthis.blobsEvicted.add(blobId);\n\t\t}\n\t}\n}\n\nexport abstract class OdspDocumentStorageServiceBase implements IDocumentStorageService {\n\treadonly policies: IDocumentStorageServicePolicies;\n\n\tconstructor(config: IConfigProvider) {\n\t\t// We circumvent the restrictions on the policy only when using this TestOverride setting,\n\t\t// which also applies to the code that reads from the cache in epochTracker.ts\n\t\t// This may result in files created for testing being unusable in production sessions,\n\t\t// due to the GC code guarding against this policy changing over the lifetime of a file.\n\t\tconst maximumCacheDurationMsInEffect = (\n\t\t\tconfig.getBoolean(\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\")\n\t\t\t\t? 0\n\t\t\t\t: maximumCacheDurationMs\n\t\t) as FiveDaysMs;\n\n\t\tthis.policies = {\n\t\t\t// By default, ODSP tells the container not to prefetch/cache.\n\t\t\tcaching: LoaderCachingPolicy.NoCaching,\n\t\t\tmaximumCacheDurationMs: maximumCacheDurationMsInEffect,\n\t\t};\n\t}\n\tprotected readonly commitCache: Map<string, ISnapshotTree> = new Map();\n\n\tprivate _ops: ISequencedDocumentMessage[] | undefined;\n\n\tprivate _snapshotSequenceNumber: number | undefined;\n\n\tprotected readonly blobCache = new BlobCache();\n\n\tpublic set ops(ops: ISequencedDocumentMessage[] | undefined) {\n\t\tassert(\n\t\t\tthis._ops === undefined,\n\t\t\t0x0a5 /* \"Trying to set ops when they are already set!\" */,\n\t\t);\n\t\tthis._ops = ops;\n\t}\n\n\tpublic get ops(): ISequencedDocumentMessage[] | undefined {\n\t\treturn this._ops;\n\t}\n\n\tpublic get snapshotSequenceNumber(): number | undefined {\n\t\treturn this._snapshotSequenceNumber;\n\t}\n\n\tpublic abstract createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;\n\n\tprivate async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n\t\tconst { blobContent, evicted } = this.blobCache.getBlob(blobId);\n\t\treturn blobContent ?? this.fetchBlobFromStorage(blobId, evicted);\n\t}\n\n\tprotected abstract fetchBlobFromStorage(\n\t\tblobId: string,\n\t\tevicted: boolean,\n\t): Promise<ArrayBuffer>;\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.readBlobCore(blobId);\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tlet id: string;\n\t\tif (version?.id) {\n\t\t\tid = version.id;\n\t\t} else {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst versions = await this.getVersions(null, 1, scenarioName);\n\t\t\tif (!versions || versions.length === 0) {\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tid = versions[0].id;\n\t\t}\n\n\t\tconst snapshotTree = await this.readTree(id, scenarioName);\n\t\tif (!snapshotTree) {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this.combineProtocolAndAppSnapshotTree(snapshotTree);\n\t}\n\n\tpublic abstract getSnapshot(\n\t\tsnapshotFetchOptions?: ISnapshotFetchOptions,\n\t): Promise<ISnapshot>;\n\n\tpublic abstract getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]>;\n\n\tpublic abstract uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string>;\n\n\tpublic async downloadSummary(commit: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"Not implemented yet\");\n\t}\n\n\tprotected setRootTree(id: string, tree: ISnapshotTree): void {\n\t\tthis.commitCache.set(id, tree);\n\t}\n\n\tprotected initBlobsCache(blobs: Map<string, ArrayBuffer>): void {\n\t\tthis.blobCache.addBlobs(blobs);\n\t}\n\n\tprivate async readTree(id: string, scenarioName?: string): Promise<ISnapshotTree | null> {\n\t\tlet tree = this.commitCache.get(id);\n\t\tif (!tree) {\n\t\t\ttree = await this.fetchTreeFromSnapshot(id, scenarioName);\n\t\t}\n\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\treturn tree ?? null;\n\t}\n\n\tprotected abstract fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | undefined>;\n\n\tprotected combineProtocolAndAppSnapshotTree(snapshotTree: ISnapshotTree): ISnapshotTree {\n\t\t// When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n\t\t// So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n\t\tconst hierarchicalAppTree: ISnapshotTree | undefined = snapshotTree.trees[\".app\"];\n\t\tconst hierarchicalProtocolTree: ISnapshotTree | undefined =\n\t\t\tsnapshotTree.trees[\".protocol\"];\n\t\tconst summarySnapshotTree: ISnapshotTree = {\n\t\t\tblobs: {\n\t\t\t\t...hierarchicalAppTree.blobs,\n\t\t\t},\n\t\t\ttrees: {\n\t\t\t\t...hierarchicalAppTree.trees,\n\t\t\t},\n\t\t\tid: snapshotTree.id,\n\t\t};\n\n\t\t// The app tree could have a .protocol in that case we want to server protocol to override it.\n\t\t// Snapshot which are for a loading GroupId, will not have a protocol tree.\n\t\tif (hierarchicalProtocolTree !== undefined) {\n\t\t\tsummarySnapshotTree.trees[\".protocol\"] = hierarchicalProtocolTree;\n\t\t}\n\n\t\treturn summarySnapshotTree;\n\t}\n\n\tprotected initializeFromSnapshot(\n\t\todspSnapshotCacheValue: ISnapshot,\n\t\tcacheOps: boolean = true,\n\t\tcacheSnapshot: boolean = true,\n\t): string | undefined {\n\t\tthis._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n\t\tconst { snapshotTree, blobContents, ops } = odspSnapshotCacheValue;\n\n\t\t// id should be undefined in case of just ops in snapshot.\n\t\tlet id: string | undefined;\n\t\tif (snapshotTree) {\n\t\t\tid = snapshotTree.id;\n\t\t\tassert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n\t\t\tif (cacheSnapshot) {\n\t\t\t\tthis.setRootTree(id, snapshotTree);\n\t\t\t}\n\t\t}\n\n\t\t// Currently always cache blobs as container runtime is not caching them.\n\t\tif (blobContents !== undefined) {\n\t\t\tthis.initBlobsCache(blobContents);\n\t\t}\n\n\t\tif (cacheOps) {\n\t\t\tthis.ops = ops;\n\t\t}\n\t\treturn id;\n\t}\n}\n"]}
@@ -60,7 +60,7 @@ export class OdspDriverUrlResolver {
60
60
  const [siteURL, queryString] = request.url.split("?");
61
61
  const searchParams = new URLSearchParams(queryString);
62
62
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
63
- const fileName = request.headers[DriverHeader.createNew].fileName;
63
+ const fileName = request.headers[DriverHeader.createNew]?.fileName;
64
64
  const driveID = searchParams.get("driveId");
65
65
  const filePath = searchParams.get("path");
66
66
  const packageName = searchParams.get("containerPackageName");