@fluidframework/odsp-driver 2.0.0-internal.2.1.2 → 2.0.0-internal.2.2.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 (83) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/compactSnapshotParser.d.ts +1 -2
  3. package/dist/compactSnapshotParser.d.ts.map +1 -1
  4. package/dist/compactSnapshotParser.js +6 -2
  5. package/dist/compactSnapshotParser.js.map +1 -1
  6. package/dist/fetchSnapshot.d.ts.map +1 -1
  7. package/dist/fetchSnapshot.js +13 -18
  8. package/dist/fetchSnapshot.js.map +1 -1
  9. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
  10. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  11. package/dist/localOdspDriver/localOdspDeltaStorageService.js +35 -0
  12. package/dist/localOdspDriver/localOdspDeltaStorageService.js.map +1 -0
  13. package/dist/localOdspDriver/localOdspDocumentService.d.ts +1 -0
  14. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  15. package/dist/localOdspDriver/localOdspDocumentService.js +5 -2
  16. package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -1
  17. package/dist/odspDeltaStorageService.d.ts +0 -1
  18. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  19. package/dist/odspDeltaStorageService.js +4 -20
  20. package/dist/odspDeltaStorageService.js.map +1 -1
  21. package/dist/odspDocumentDeltaConnection.js +1 -1
  22. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  23. package/dist/odspDocumentService.d.ts.map +1 -1
  24. package/dist/odspDocumentService.js +9 -2
  25. package/dist/odspDocumentService.js.map +1 -1
  26. package/dist/odspUtils.d.ts +4 -0
  27. package/dist/odspUtils.d.ts.map +1 -1
  28. package/dist/odspUtils.js +32 -1
  29. package/dist/odspUtils.js.map +1 -1
  30. package/dist/packageVersion.d.ts +1 -1
  31. package/dist/packageVersion.js +1 -1
  32. package/dist/packageVersion.js.map +1 -1
  33. package/dist/zipItDataRepresentationUtils.d.ts +17 -2
  34. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  35. package/dist/zipItDataRepresentationUtils.js +15 -2
  36. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  37. package/lib/compactSnapshotParser.d.ts +1 -2
  38. package/lib/compactSnapshotParser.d.ts.map +1 -1
  39. package/lib/compactSnapshotParser.js +6 -2
  40. package/lib/compactSnapshotParser.js.map +1 -1
  41. package/lib/fetchSnapshot.d.ts.map +1 -1
  42. package/lib/fetchSnapshot.js +14 -19
  43. package/lib/fetchSnapshot.js.map +1 -1
  44. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
  45. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  46. package/lib/localOdspDriver/localOdspDeltaStorageService.js +31 -0
  47. package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -0
  48. package/lib/localOdspDriver/localOdspDocumentService.d.ts +1 -0
  49. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  50. package/lib/localOdspDriver/localOdspDocumentService.js +6 -3
  51. package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -1
  52. package/lib/odspDeltaStorageService.d.ts +0 -1
  53. package/lib/odspDeltaStorageService.d.ts.map +1 -1
  54. package/lib/odspDeltaStorageService.js +5 -21
  55. package/lib/odspDeltaStorageService.js.map +1 -1
  56. package/lib/odspDocumentDeltaConnection.js +1 -1
  57. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  58. package/lib/odspDocumentService.d.ts.map +1 -1
  59. package/lib/odspDocumentService.js +10 -3
  60. package/lib/odspDocumentService.js.map +1 -1
  61. package/lib/odspUtils.d.ts +4 -0
  62. package/lib/odspUtils.d.ts.map +1 -1
  63. package/lib/odspUtils.js +28 -0
  64. package/lib/odspUtils.js.map +1 -1
  65. package/lib/packageVersion.d.ts +1 -1
  66. package/lib/packageVersion.js +1 -1
  67. package/lib/packageVersion.js.map +1 -1
  68. package/lib/zipItDataRepresentationUtils.d.ts +17 -2
  69. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  70. package/lib/zipItDataRepresentationUtils.js +15 -2
  71. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  72. package/package.json +19 -14
  73. package/prettier.config.cjs +8 -0
  74. package/src/compactSnapshotParser.ts +16 -12
  75. package/src/fetchSnapshot.ts +29 -24
  76. package/src/localOdspDriver/localOdspDeltaStorageService.ts +46 -0
  77. package/src/localOdspDriver/localOdspDocumentService.ts +9 -3
  78. package/src/odspDeltaStorageService.ts +5 -22
  79. package/src/odspDocumentDeltaConnection.ts +1 -1
  80. package/src/odspDocumentService.ts +9 -2
  81. package/src/odspUtils.ts +37 -0
  82. package/src/packageVersion.ts +1 -1
  83. package/src/zipItDataRepresentationUtils.ts +18 -3
@@ -1 +1 @@
1
- {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAgB,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACH,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC7G,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,oCAAoC,GACvC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAGH,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAMhB,WAAW,GAGd,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAG/D,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AC;AAED,MAAM,UAAU,sBAAsB,CAAC,eAAiC;;IACpE,MAAM,UAAU,GAAgB;QAC5B,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,MAAA,eAAe,CAAC,WAAW,mCAAI,EAAE;QACtC,IAAI,EAAE;YACF,WAAW,EAAE,eAAe;YAC5B,KAAK,EAAE,eAAe,CAAC,gBAAgB;SAC1C;KACJ,CAAC;IACF,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,iGAAiG;AACjG,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAExC;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,aAA4D;IACpG,IAAI,CAAC,aAAa,EAAE;QAChB,OAAO;KACV;IACD,MAAM,KAAK,GAAI,aAAkC,CAAC,KAAK,CAAC;IACxD,IAAI,CAAC,KAAK,EAAE;QACR,OAAO,kBAAkB,aAAa,EAAE,CAAC;KAC5C;IACD,IAAI,sBAAsB,GAAG,mBAAmB,KAAK,EAAE,CAAC;IACxD,MAAM,IAAI,GAAI,aAAkC,CAAC,IAAI,CAAC;IACtD,sBAAsB,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,sBAAsB,mBAAmB,IAAI,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC;IAC5G,OAAO,sBAAsB,CAAC;AAClC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties, ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IResolvedUrl, DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n isOnline,\n OnlineStatus,\n RetryableError,\n NonRetryableError,\n NetworkErrorBasic,\n} from \"@fluidframework/driver-utils\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { ChildLogger, PerformanceEvent, TelemetryDataTag, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n fetchIncorrectResponse,\n throwOdspNetworkError,\n getSPOAndGraphRequestIdsFromResponse,\n} from \"@fluidframework/odsp-doclib-utils\";\nimport {\n IOdspResolvedUrl,\n TokenFetchOptions,\n OdspErrorType,\n tokenFromResponse,\n isTokenFromCache,\n OdspResourceTokenFetchOptions,\n ShareLinkTypes,\n ISharingLinkKind,\n TokenFetcher,\n ICacheEntry,\n snapshotKey,\n InstrumentedStorageTokenFetcher,\n IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { fetch } from \"./fetch\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { IOdspSnapshot } from \"./contracts\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/** Parse the given url and return the origin (host name) */\nexport const getOrigin = (url: string) => new URL(url).origin;\n\nexport interface IOdspResponse<T> {\n content: T;\n headers: Map<string, string>;\n propsToLog: ITelemetryProperties;\n duration: number;\n}\n\nexport interface TokenFetchOptionsEx extends TokenFetchOptions {\n /** previous error we hit in getWithRetryForTokenRefresh */\n previousError?: any;\n}\n\nfunction headersToMap(headers: Headers) {\n const newHeaders = new Map<string, string>();\n for (const [key, value] of headers.entries()) {\n newHeaders.set(key, value);\n }\n return newHeaders;\n}\n\n/**\n * This API should be used with pretty much all network calls (fetch, webSocket connection) in order\n * to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch\n * token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors\n * simply propagate to caller\n */\nexport async function getWithRetryForTokenRefresh<T>(get: (options: TokenFetchOptionsEx) => Promise<T>) {\n return get({ refresh: false }).catch(async (e) => {\n const options: TokenFetchOptionsEx = { refresh: true, previousError: e };\n switch (e.errorType) {\n // If the error is 401 or 403 refresh the token and try once more.\n case DriverErrorType.authorizationError:\n return get({ ...options, claims: e.claims, tenantId: e.tenantId });\n\n case DriverErrorType.incorrectServerResponse: // some error on the wire, retry once\n case OdspErrorType.fetchTokenError: // If the token was null, then retry once.\n return get(options);\n\n default:\n // Caller may determine that it wants one retry\n if (e[getWithRetryForTokenRefreshRepeat] === true) {\n return get(options);\n }\n throw e;\n }\n });\n}\n\nexport async function fetchHelper(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n const start = performance.now();\n\n // Node-fetch and dom have conflicting typing, force them to work by casting for now\n return fetch(requestInfo, requestInit).then(async (fetchResponse) => {\n const response = fetchResponse as any as Response;\n // Let's assume we can retry.\n if (!response) {\n throw new NonRetryableError(\n // pre-0.58 error message: No response from fetch call\n \"No response from ODSP fetch call\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n if (!response.ok || response.status < 200 || response.status >= 300) {\n throwOdspNetworkError(\n // pre-0.58 error message prefix: odspFetchError\n `ODSP fetch error [${response.status}]`, response.status, response, await response.text());\n }\n\n const headers = headersToMap(response.headers);\n return {\n content: response,\n headers,\n propsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n duration: performance.now() - start,\n };\n }, (error) => {\n const online = isOnline();\n const errorText = `${error}`;\n const urlRegex = /((http|https):\\/\\/(\\S*))/i;\n const redactedErrorText = errorText.replace(urlRegex, \"REDACTED_URL\");\n // This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n if (error.name === \"AbortError\") {\n throw new RetryableError(\n \"Fetch Timeout (AbortError)\", OdspErrorType.fetchTimeout, { driverVersion });\n }\n // TCP/IP timeout\n if (errorText.includes(\"ETIMEDOUT\")) {\n throw new RetryableError(\n \"Fetch Timeout (ETIMEDOUT)\", OdspErrorType.fetchTimeout, { driverVersion });\n }\n\n // WARNING: Do not log error object itself or any of its properties!\n // It could contain PII, like URI in message itself, or token in properties.\n // It is also non-serializable object due to circular references.\n // eslint-disable-next-line unicorn/prefer-ternary\n if (online === OnlineStatus.Offline) {\n throw new RetryableError(\n // pre-0.58 error message prefix: Offline\n `ODSP fetch failure (Offline): ${redactedErrorText}`,\n DriverErrorType.offlineError,\n {\n driverVersion,\n rawErrorMessage: { value: errorText, tag: TelemetryDataTag.UserData },\n });\n } else {\n // It is perhaps still possible that this is due to being offline, the error does not reveal enough\n // information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n throw new RetryableError(\n // pre-0.58 error message prefix: Fetch error\n `ODSP fetch failure: ${redactedErrorText}`,\n DriverErrorType.fetchFailure,\n {\n driverVersion,\n rawErrorMessage: { value: errorText, tag: TelemetryDataTag.UserData },\n });\n }\n });\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchArray(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n const { content, headers, propsToLog, duration } = await fetchHelper(requestInfo, requestInit);\n\n const arrayBuffer = await content.arrayBuffer();\n propsToLog.bodySize = arrayBuffer.byteLength;\n return {\n headers,\n content: arrayBuffer,\n propsToLog,\n duration,\n };\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchAndParseAsJSONHelper<T>(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n const { content, headers, propsToLog, duration } = await fetchHelper(requestInfo, requestInit);\n let text: string | undefined;\n try {\n text = await content.text();\n } catch (e) {\n // JSON.parse() can fail and message would container full request URI, including\n // tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n // (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n // succeeds on retry.\n // So do not log error object itself.\n throwOdspNetworkError(\n // pre-0.58 error message: errorWhileParsingFetchResponse\n \"Error while parsing fetch response\",\n fetchIncorrectResponse,\n content, // response\n text,\n );\n }\n\n propsToLog.bodySize = text.length;\n const res = {\n headers,\n content: JSON.parse(text),\n propsToLog,\n duration,\n };\n return res;\n}\n\nexport interface INewFileInfo {\n siteUrl: string;\n driveId: string;\n filename: string;\n filePath: string;\n /**\n * application can request creation of a share link along with the creation of a new file\n * by passing in an optional param to specify the kind of sharing link\n * (at the time of adding this comment Sept/2021), odsp only supports csl\n * ShareLinkTypes will deprecated in future. Use ISharingLinkKind instead which specifies both\n * share link type and the role type.\n */\n createLinkType?: ShareLinkTypes | ISharingLinkKind;\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n assert((resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true, 0x1de /* \"Not an ODSP resolved url\" */);\n return resolvedUrl as IOdspResolvedUrl;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger) =>\n ChildLogger.create(\n logger,\n \"OdspDriver\",\n {\n all:\n {\n driverVersion,\n },\n });\n\nexport function evalBlobsAndTrees(snapshot: IOdspSnapshot) {\n let numTrees = 0;\n let numBlobs = 0;\n let encodedBlobsSize = 0;\n let decodedBlobsSize = 0;\n for (const tree of snapshot.trees) {\n for (const treeEntry of tree.entries) {\n if (treeEntry.type === \"blob\") {\n numBlobs++;\n } else if (treeEntry.type === \"tree\") {\n numTrees++;\n }\n }\n }\n if (snapshot.blobs !== undefined) {\n for (const blob of snapshot.blobs) {\n decodedBlobsSize += blob.size;\n encodedBlobsSize += blob.content.length;\n }\n }\n return { numTrees, numBlobs, encodedBlobsSize, decodedBlobsSize };\n}\n\nexport function toInstrumentedOdspTokenFetcher(\n logger: ITelemetryLogger,\n resolvedUrlParts: IOdspUrlParts,\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n throwOnNullToken: boolean,\n): InstrumentedStorageTokenFetcher {\n return async (options: TokenFetchOptions, name: string, alwaysRecordTokenFetchTelemetry: boolean = false) => {\n // Telemetry note: if options.refresh is true, there is a potential perf issue:\n // Host should optimize and provide non-expired tokens on all critical paths.\n // Exceptions: race conditions around expiration, revoked tokens, host that does not care\n // (fluid-fetcher)\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: `${name}_GetToken`,\n attempts: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n },\n async (event) => tokenFetcher({\n ...options,\n ...resolvedUrlParts,\n }).then((tokenResponse) => {\n const token = tokenFromResponse(tokenResponse);\n // This event alone generates so many events that is materially impacts cost of telemetry\n // Thus do not report end event when it comes back quickly.\n // Note that most of the hosts do not report if result is comming from cache or not,\n // so we can't rely on that here. But always record if specified explicitly for cases such as\n // calling trees/latest during load.\n if (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n event.end({ fromCache: isTokenFromCache(tokenResponse), isNull: token === null });\n }\n if (token === null && throwOnNullToken) {\n throw new NonRetryableError(\n // pre-0.58 error message: Token is null for ${name} call\n `The Host-provided token fetcher returned null`,\n OdspErrorType.fetchTokenError,\n { method: name, driverVersion });\n }\n return token;\n }, (error) => {\n // There is an important but unofficial contract here where token providers can set canRetry: true\n // to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n const rawCanRetry = error?.canRetry;\n const tokenError = wrapError(\n error,\n (errorMessage) => new NetworkErrorBasic(\n `The Host-provided token fetcher threw an error`,\n OdspErrorType.fetchTokenError,\n typeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n { method: name, errorMessage, driverVersion }));\n throw tokenError;\n }),\n { cancel: \"generic\" });\n };\n}\n\nexport function createCacheSnapshotKey(odspResolvedUrl: IOdspResolvedUrl): ICacheEntry {\n const cacheEntry: ICacheEntry = {\n type: snapshotKey,\n key: odspResolvedUrl.fileVersion ?? \"\",\n file: {\n resolvedUrl: odspResolvedUrl,\n docId: odspResolvedUrl.hashedDocumentId,\n },\n };\n return cacheEntry;\n}\n\n// 80KB is the max body size that we can put in ump post body for server to be able to accept it.\n// Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.\nexport const maxUmpPostBodySize = 79872;\n\n/**\n * Build request parameters to request for the creation of a sharing link along with the creation of the file\n * through the /snapshot api call.\n * @param shareLinkType - Kind of sharing link requested\n * @returns A string of request parameters that can be concatenated with the base URI\n */\nexport function buildOdspShareLinkReqParams(shareLinkType: ShareLinkTypes | ISharingLinkKind | undefined) {\n if (!shareLinkType) {\n return;\n }\n const scope = (shareLinkType as ISharingLinkKind).scope;\n if (!scope) {\n return `createLinkType=${shareLinkType}`;\n }\n let shareLinkRequestParams = `createLinkScope=${scope}`;\n const role = (shareLinkType as ISharingLinkKind).role;\n shareLinkRequestParams = role ? `${shareLinkRequestParams}&createLinkRole=${role}` : shareLinkRequestParams;\n return shareLinkRequestParams;\n}\n"]}
1
+ {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAgB,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EACH,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC7G,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,oCAAoC,GACvC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAGH,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAMhB,WAAW,GAGd,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAG/D,MAAM,CAAC,MAAM,iCAAiC,GAAG,mCAAmC,CAAC;AAErF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AAc9D,SAAS,YAAY,CAAC,O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rC,IAAY,EACZ,MAAwB;IAExB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;QACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC;QACjD,IAAI,KAAK,KAAK,IAAI,EAAE;YAChB,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7F,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;SACvB;QACD,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,MAAM,EAAE;YAC5B,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7F,uEAAuE;YACvE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;SACvB;KACJ;AACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties, ITelemetryBaseLogger, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IResolvedUrl, DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n isOnline,\n OnlineStatus,\n RetryableError,\n NonRetryableError,\n NetworkErrorBasic,\n} from \"@fluidframework/driver-utils\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { ChildLogger, PerformanceEvent, TelemetryDataTag, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n fetchIncorrectResponse,\n throwOdspNetworkError,\n getSPOAndGraphRequestIdsFromResponse,\n} from \"@fluidframework/odsp-doclib-utils\";\nimport {\n IOdspResolvedUrl,\n TokenFetchOptions,\n OdspErrorType,\n tokenFromResponse,\n isTokenFromCache,\n OdspResourceTokenFetchOptions,\n ShareLinkTypes,\n ISharingLinkKind,\n TokenFetcher,\n ICacheEntry,\n snapshotKey,\n InstrumentedStorageTokenFetcher,\n IOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { fetch } from \"./fetch\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { IOdspSnapshot } from \"./contracts\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/** Parse the given url and return the origin (host name) */\nexport const getOrigin = (url: string) => new URL(url).origin;\n\nexport interface IOdspResponse<T> {\n content: T;\n headers: Map<string, string>;\n propsToLog: ITelemetryProperties;\n duration: number;\n}\n\nexport interface TokenFetchOptionsEx extends TokenFetchOptions {\n /** previous error we hit in getWithRetryForTokenRefresh */\n previousError?: any;\n}\n\nfunction headersToMap(headers: Headers) {\n const newHeaders = new Map<string, string>();\n for (const [key, value] of headers.entries()) {\n newHeaders.set(key, value);\n }\n return newHeaders;\n}\n\n/**\n * This API should be used with pretty much all network calls (fetch, webSocket connection) in order\n * to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch\n * token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors\n * simply propagate to caller\n */\nexport async function getWithRetryForTokenRefresh<T>(get: (options: TokenFetchOptionsEx) => Promise<T>) {\n return get({ refresh: false }).catch(async (e) => {\n const options: TokenFetchOptionsEx = { refresh: true, previousError: e };\n switch (e.errorType) {\n // If the error is 401 or 403 refresh the token and try once more.\n case DriverErrorType.authorizationError:\n return get({ ...options, claims: e.claims, tenantId: e.tenantId });\n\n case DriverErrorType.incorrectServerResponse: // some error on the wire, retry once\n case OdspErrorType.fetchTokenError: // If the token was null, then retry once.\n return get(options);\n\n default:\n // Caller may determine that it wants one retry\n if (e[getWithRetryForTokenRefreshRepeat] === true) {\n return get(options);\n }\n throw e;\n }\n });\n}\n\nexport async function fetchHelper(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n const start = performance.now();\n\n // Node-fetch and dom have conflicting typing, force them to work by casting for now\n return fetch(requestInfo, requestInit).then(async (fetchResponse) => {\n const response = fetchResponse as any as Response;\n // Let's assume we can retry.\n if (!response) {\n throw new NonRetryableError(\n // pre-0.58 error message: No response from fetch call\n \"No response from ODSP fetch call\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n if (!response.ok || response.status < 200 || response.status >= 300) {\n throwOdspNetworkError(\n // pre-0.58 error message prefix: odspFetchError\n `ODSP fetch error [${response.status}]`, response.status, response, await response.text());\n }\n\n const headers = headersToMap(response.headers);\n return {\n content: response,\n headers,\n propsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n duration: performance.now() - start,\n };\n }, (error) => {\n const online = isOnline();\n const errorText = `${error}`;\n const urlRegex = /((http|https):\\/\\/(\\S*))/i;\n const redactedErrorText = errorText.replace(urlRegex, \"REDACTED_URL\");\n // This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n if (error.name === \"AbortError\") {\n throw new RetryableError(\n \"Fetch Timeout (AbortError)\", OdspErrorType.fetchTimeout, { driverVersion });\n }\n // TCP/IP timeout\n if (errorText.includes(\"ETIMEDOUT\")) {\n throw new RetryableError(\n \"Fetch Timeout (ETIMEDOUT)\", OdspErrorType.fetchTimeout, { driverVersion });\n }\n\n // WARNING: Do not log error object itself or any of its properties!\n // It could contain PII, like URI in message itself, or token in properties.\n // It is also non-serializable object due to circular references.\n // eslint-disable-next-line unicorn/prefer-ternary\n if (online === OnlineStatus.Offline) {\n throw new RetryableError(\n // pre-0.58 error message prefix: Offline\n `ODSP fetch failure (Offline): ${redactedErrorText}`,\n DriverErrorType.offlineError,\n {\n driverVersion,\n rawErrorMessage: { value: errorText, tag: TelemetryDataTag.UserData },\n });\n } else {\n // It is perhaps still possible that this is due to being offline, the error does not reveal enough\n // information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n throw new RetryableError(\n // pre-0.58 error message prefix: Fetch error\n `ODSP fetch failure: ${redactedErrorText}`,\n DriverErrorType.fetchFailure,\n {\n driverVersion,\n rawErrorMessage: { value: errorText, tag: TelemetryDataTag.UserData },\n });\n }\n });\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchArray(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n const { content, headers, propsToLog, duration } = await fetchHelper(requestInfo, requestInit);\n\n const arrayBuffer = await content.arrayBuffer();\n propsToLog.bodySize = arrayBuffer.byteLength;\n return {\n headers,\n content: arrayBuffer,\n propsToLog,\n duration,\n };\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchAndParseAsJSONHelper<T>(\n requestInfo: RequestInfo,\n requestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n const { content, headers, propsToLog, duration } = await fetchHelper(requestInfo, requestInit);\n let text: string | undefined;\n try {\n text = await content.text();\n } catch (e) {\n // JSON.parse() can fail and message would container full request URI, including\n // tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n // (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n // succeeds on retry.\n // So do not log error object itself.\n throwOdspNetworkError(\n // pre-0.58 error message: errorWhileParsingFetchResponse\n \"Error while parsing fetch response\",\n fetchIncorrectResponse,\n content, // response\n text,\n );\n }\n\n propsToLog.bodySize = text.length;\n const res = {\n headers,\n content: JSON.parse(text),\n propsToLog,\n duration,\n };\n return res;\n}\n\nexport interface INewFileInfo {\n siteUrl: string;\n driveId: string;\n filename: string;\n filePath: string;\n /**\n * application can request creation of a share link along with the creation of a new file\n * by passing in an optional param to specify the kind of sharing link\n * (at the time of adding this comment Sept/2021), odsp only supports csl\n * ShareLinkTypes will deprecated in future. Use ISharingLinkKind instead which specifies both\n * share link type and the role type.\n */\n createLinkType?: ShareLinkTypes | ISharingLinkKind;\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n assert((resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true, 0x1de /* \"Not an ODSP resolved url\" */);\n return resolvedUrl as IOdspResolvedUrl;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger) =>\n ChildLogger.create(\n logger,\n \"OdspDriver\",\n {\n all:\n {\n driverVersion,\n },\n });\n\nexport function evalBlobsAndTrees(snapshot: IOdspSnapshot) {\n let numTrees = 0;\n let numBlobs = 0;\n let encodedBlobsSize = 0;\n let decodedBlobsSize = 0;\n for (const tree of snapshot.trees) {\n for (const treeEntry of tree.entries) {\n if (treeEntry.type === \"blob\") {\n numBlobs++;\n } else if (treeEntry.type === \"tree\") {\n numTrees++;\n }\n }\n }\n if (snapshot.blobs !== undefined) {\n for (const blob of snapshot.blobs) {\n decodedBlobsSize += blob.size;\n encodedBlobsSize += blob.content.length;\n }\n }\n return { numTrees, numBlobs, encodedBlobsSize, decodedBlobsSize };\n}\n\nexport function toInstrumentedOdspTokenFetcher(\n logger: ITelemetryLogger,\n resolvedUrlParts: IOdspUrlParts,\n tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n throwOnNullToken: boolean,\n): InstrumentedStorageTokenFetcher {\n return async (options: TokenFetchOptions, name: string, alwaysRecordTokenFetchTelemetry: boolean = false) => {\n // Telemetry note: if options.refresh is true, there is a potential perf issue:\n // Host should optimize and provide non-expired tokens on all critical paths.\n // Exceptions: race conditions around expiration, revoked tokens, host that does not care\n // (fluid-fetcher)\n return PerformanceEvent.timedExecAsync(\n logger,\n {\n eventName: `${name}_GetToken`,\n attempts: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n },\n async (event) => tokenFetcher({\n ...options,\n ...resolvedUrlParts,\n }).then((tokenResponse) => {\n const token = tokenFromResponse(tokenResponse);\n // This event alone generates so many events that is materially impacts cost of telemetry\n // Thus do not report end event when it comes back quickly.\n // Note that most of the hosts do not report if result is comming from cache or not,\n // so we can't rely on that here. But always record if specified explicitly for cases such as\n // calling trees/latest during load.\n if (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n event.end({ fromCache: isTokenFromCache(tokenResponse), isNull: token === null });\n }\n if (token === null && throwOnNullToken) {\n throw new NonRetryableError(\n // pre-0.58 error message: Token is null for ${name} call\n `The Host-provided token fetcher returned null`,\n OdspErrorType.fetchTokenError,\n { method: name, driverVersion });\n }\n return token;\n }, (error) => {\n // There is an important but unofficial contract here where token providers can set canRetry: true\n // to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n const rawCanRetry = error?.canRetry;\n const tokenError = wrapError(\n error,\n (errorMessage) => new NetworkErrorBasic(\n `The Host-provided token fetcher threw an error`,\n OdspErrorType.fetchTokenError,\n typeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n { method: name, errorMessage, driverVersion }));\n throw tokenError;\n }),\n { cancel: \"generic\" });\n };\n}\n\nexport function createCacheSnapshotKey(odspResolvedUrl: IOdspResolvedUrl): ICacheEntry {\n const cacheEntry: ICacheEntry = {\n type: snapshotKey,\n key: odspResolvedUrl.fileVersion ?? \"\",\n file: {\n resolvedUrl: odspResolvedUrl,\n docId: odspResolvedUrl.hashedDocumentId,\n },\n };\n return cacheEntry;\n}\n\n// 80KB is the max body size that we can put in ump post body for server to be able to accept it.\n// Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.\nexport const maxUmpPostBodySize = 79872;\n\n/**\n * Build request parameters to request for the creation of a sharing link along with the creation of the file\n * through the /snapshot api call.\n * @param shareLinkType - Kind of sharing link requested\n * @returns A string of request parameters that can be concatenated with the base URI\n */\nexport function buildOdspShareLinkReqParams(shareLinkType: ShareLinkTypes | ISharingLinkKind | undefined) {\n if (!shareLinkType) {\n return;\n }\n const scope = (shareLinkType as ISharingLinkKind).scope;\n if (!scope) {\n return `createLinkType=${shareLinkType}`;\n }\n let shareLinkRequestParams = `createLinkScope=${scope}`;\n const role = (shareLinkType as ISharingLinkKind).role;\n shareLinkRequestParams = role ? `${shareLinkRequestParams}&createLinkRole=${role}` : shareLinkRequestParams;\n return shareLinkRequestParams;\n}\n\nexport function measure<T>(callback: () => T): [T, number] {\n const start = performance.now();\n const result = callback();\n const time = performance.now() - start;\n return [result, time];\n}\n\nexport async function measureP<T>(callback: () => Promise<T>): Promise<[T, number]> {\n const start = performance.now();\n const result = await callback();\n const time = performance.now() - start;\n return [result, time];\n}\n\nexport function validateMessages(\n reason: string,\n messages: ISequencedDocumentMessage[],\n from: number,\n logger: ITelemetryLogger,\n) {\n if (messages.length !== 0) {\n const start = messages[0].sequenceNumber;\n const length = messages.length;\n const last = messages[length - 1].sequenceNumber;\n if (start !== from) {\n logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n messages.length = 0;\n }\n if (last + 1 !== from + length) {\n logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n // we can do better here by finding consecutive sub-block and return it\n messages.length = 0;\n }\n }\n}\n"]}
@@ -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.0.0-internal.2.1.2";
8
+ export declare const pkgVersion = "2.0.0-internal.2.2.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/odsp-driver";
8
- export const pkgVersion = "2.0.0-internal.2.1.2";
8
+ export const pkgVersion = "2.0.0-internal.2.2.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"2.0.0-internal.2.1.2\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"2.0.0-internal.2.2.0\";\n"]}
@@ -174,14 +174,29 @@ export declare class NodeCore {
174
174
  * Load and parse the buffer into a tree.
175
175
  * @param buffer - buffer to read from.
176
176
  */
177
- protected load(buffer: ReadBuffer, logger: ITelemetryLogger): void;
177
+ protected load(buffer: ReadBuffer, logger: ITelemetryLogger): {
178
+ durationStructure: number;
179
+ durationStrings: number;
180
+ };
181
+ /**
182
+ * Load and parse the buffer into a tree.
183
+ * @param buffer - buffer to read from.
184
+ */
185
+ protected loadStructure(buffer: ReadBuffer, logger: ITelemetryLogger): IStringElementInternal[];
186
+ private loadStrings;
178
187
  }
179
188
  /**
180
189
  * TreeBuilder - Root of the tree.
181
190
  * Provides loading and serialization capabilities.
182
191
  */
183
192
  export declare class TreeBuilder extends NodeCore {
184
- static load(buffer: ReadBuffer, logger: ITelemetryLogger): TreeBuilder;
193
+ static load(buffer: ReadBuffer, logger: ITelemetryLogger): {
194
+ builder: TreeBuilder;
195
+ telemetryProps: {
196
+ durationStructure: number;
197
+ durationStrings: number;
198
+ };
199
+ };
185
200
  }
186
201
  export declare function getMaybeStringInstance(node: NodeTypes): string | undefined;
187
202
  export declare function getStringInstance(node: NodeTypes, message: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"zipItDataRepresentationUtils.d.ts","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C;;;GAGG;AACH,oBAAY,WAAW;IACnB,QAAQ,KAAK;IACb,SAAS,KAAK;IAEd,WAAW,KAAK;IAChB,aAAa,KAAK;IAClB,cAAc,KAAK;IACnB,cAAc,KAAK;IAEnB,cAAc,KAAK;IACnB,eAAe,KAAK;IACpB,eAAe,KAAK;IACpB,kBAAkB,KAAK;IACvB,qBAAqB,KAAK;IAE1B,IAAI,IAAI;IACR,KAAK,IAAI;IACT,MAAM,IAAI;IACV,MAAM,IAAI;IACV,MAAM,IAAI;IACV,IAAI,IAAI;IACR,KAAK,IAAI;IACT,KAAK,IAAI;IACT,KAAK,IAAI;IAET,WAAW,KAAK;IAChB,aAAa,KAAK;IAClB,cAAc,KAAK;IACnB,cAAc,KAAK;IACnB,cAAc,KAAK;CACtB;AAED;;GAEG;AACH,oBAAY,gBAAgB;IACxB,MAAM,KAAK;IACX,KAAK,KAAK;CACb;AAED;;GAEG;AACH,oBAAY,cAAc;IACtB,MAAM,KAAK;IACX,KAAK,KAAK;CACb;AAED;;;EAGE;AACF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7B,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,GAChB,MAAM,CAMR;AAED,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,IAAI,QAAQ,CAK1B;AAED,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,IAAI,QAAQ,CAK1B;AAED,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,IAAI,MAAM,CAKxB;AAED,wBAAgB,kBAAkB,CAC9B,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,IAAI,OAAO,CAKzB"}
@@ -10,6 +10,7 @@ import { assert, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from "@fluidframe
10
10
  import { NonRetryableError } from "@fluidframework/driver-utils";
11
11
  import { DriverErrorType } from "@fluidframework/driver-definitions";
12
12
  import { pkgVersion as driverVersion } from "./packageVersion";
13
+ import { measure } from "./odspUtils";
13
14
  // eslint-disable-next-line max-len
14
15
  // https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents
15
16
  /**
@@ -318,6 +319,15 @@ export class NodeCore {
318
319
  * @param buffer - buffer to read from.
319
320
  */
320
321
  load(buffer, logger) {
322
+ const [stringsToResolve, durationStructure] = measure(() => this.loadStructure(buffer, logger));
323
+ const [, durationStrings] = measure(() => this.loadStrings(buffer, stringsToResolve, logger));
324
+ return { durationStructure, durationStrings };
325
+ }
326
+ /**
327
+ * Load and parse the buffer into a tree.
328
+ * @param buffer - buffer to read from.
329
+ */
330
+ loadStructure(buffer, logger) {
321
331
  const stack = [];
322
332
  const stringsToResolve = [];
323
333
  const dictionary = [];
@@ -412,6 +422,9 @@ export class NodeCore {
412
422
  }
413
423
  // This also ensures that stack.length === 0.
414
424
  assert(children === this.children, 0x3e7 /* Unpaired start/end list/set markers! */);
425
+ return stringsToResolve;
426
+ }
427
+ loadStrings(buffer, stringsToResolve, logger) {
415
428
  /**
416
429
  * Process all the strings at once!
417
430
  */
@@ -456,9 +469,9 @@ export class NodeCore {
456
469
  export class TreeBuilder extends NodeCore {
457
470
  static load(buffer, logger) {
458
471
  const builder = new TreeBuilder();
459
- builder.load(buffer, logger);
472
+ const telemetryProps = builder.load(buffer, logger);
460
473
  assert(buffer.eof, 0x233 /* "Unexpected data at the end of buffer" */);
461
- return builder;
474
+ return { builder, telemetryProps };
462
475
  }
463
476
  }
464
477
  export function getMaybeStringInstance(node) {
@@ -1 +1 @@
1
- {"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;EAGE;AAEF,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/D,mCAAmC;AACnC,wJAAwJ;AACxJ;;;GAGG;AACH,MAAM,CAAN,IAAY,WA8BX;AA9BD,WAAY,WAAW;IACnB,sDAAa,CAAA;IACb,wDAAc,CAAA;IAEd,4DAAgB,CAAA;IAChB,gEAAkB,CAAA;IAClB,kEAAmB,CAAA;IACnB,kEAAmB,CAAA;IAEnB,kEAAmB,CAAA;IACnB,oEAAoB,CAAA;IACpB,oEAAoB,CAAA;IACpB,0EAAuB,CAAA;IACvB,gFAA0B,CAAA;IAE1B,6CAAQ,CAAA;IACR,+CAAS,CAAA;IACT,iDAAU,CAAA;IACV,iDAAU,CAAA;IACV,i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OAAO;KACV;IACD,yBAAyB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,yBAAyB,CAC9B,IAAe,EACf,gBAA0B,EAC1B,OAAe;IAEf,MAAM,IAAI,iBAAiB,CACvB,6BAA6B,OAAO,EAAE,EACtC,eAAe,CAAC,uBAAuB,EACvC;QACI,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC;QAC3B,gBAAgB;QAChB,aAAa;KAChB,CAAC,CAAC;AACX,CAAC;AAED,SAAS,WAAW,CAAC,KAAgB;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,QAAQ,CAAC;KACnB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QACnC,OAAO,SAAS,CAAC;KACpB;SAAM,IAAI,KAAK,CAAC,cAAc,EAAE;QAC7B,OAAO,QAAQ,CAAC;KACnB;IACD,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n*/\n\nimport { assert, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n// eslint-disable-next-line max-len\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n BoolTrue = 11, // value = true\n BoolFalse = 12, // value = false\n\n StringEmpty = 13, // value = \"\"\n String8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n String16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n String32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n ConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n ConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n ConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n ConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n ConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n Int0 = 1, // value = 0\n UInt8 = 3, // unsigned-8-bit little-endian follows\n UInt16 = 5, // unsigned-16-bit little-endian follows\n UInt32 = 7, // unsigned-32-bit little-endian follows\n UInt64 = 9, // unsigned-64-bit little-endian follows\n Int8 = 2, // signed-8-bit little-endian follows\n Int16 = 4, // signed-16-bit little-endian follows\n Int32 = 6, // signed-32-bit little-endian follows\n Int64 = 8, // signed-64-bit little-endian follows\n\n BinaryEmpty = 32, // value = byte[]\n BinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n BinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n BinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n BinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n \"list\" = 49,\n \"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n \"list\" = 50,\n \"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n*/\nexport const codeToBytesMap = {\n // Integer code to bytes\n 1: 0,\n 2: 1,\n 3: 1,\n 4: 2,\n 5: 2,\n 6: 4,\n 7: 4,\n 8: 8,\n 9: 8,\n\n // String code to Bytes\n 13: 0,\n 14: 1,\n 15: 2,\n 16: 4,\n\n 17: 1,\n 18: 2,\n 19: 4,\n\n 20: 1,\n 21: 4,\n\n // Binary code to bytes\n 32: 0,\n 33: 1,\n 34: 2,\n 35: 4,\n 36: 8,\n};\n\nexport function getValueSafely(map: { [index: number]: number; }, key: number) {\n const val = map[key];\n assert(val !== undefined, 0x287 /* key must exist in the map */);\n return val;\n}\n\nexport function getNodeProps(node: NodeCore) {\n const res: Record<string, NodeTypes> = {};\n for (const [keyNode, valueNode] of node.iteratePairs()) {\n const id = getStringInstance(keyNode, \"keynode should be a string\");\n res[id] = valueNode;\n }\n return res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>) {\n const res: IterableIterator<[T, T]> = {\n next: () => {\n const a = it.next();\n if (a.done) {\n return { value: undefined, done: true };\n }\n const b = it.next();\n assert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n return { value: [a.value, b.value], done: b.done };\n },\n [Symbol.iterator]: () => { return res; },\n };\n return res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: { [Symbol.iterator]: () => IterableIterator<T>; }) {\n return obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n public abstract get buffer(): Uint8Array;\n public abstract get arrayBuffer(): ArrayBufferLike;\n\n /**\n * Represents a blob.\n */\n constructor() {}\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n*/\nclass BlobDeepCopy extends BlobCore {\n /**\n * Represents a deep copy of the blob.\n * @param data - Data array of the blob\n */\n constructor(protected readonly data: Uint8Array) {\n super();\n }\n\n public get buffer() {\n return this.data;\n }\n\n public get arrayBuffer(): ArrayBufferLike {\n return Uint8ArrayToArrayBuffer(this.buffer);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n const length = buffer.read(lengthLen);\n const data = new Uint8Array(length);\n for (let counter = 0; counter < length; counter++) {\n data[counter] = buffer.read();\n }\n return new BlobDeepCopy(data);\n }\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\n export class BlobShallowCopy extends BlobCore {\n /**\n * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n * @param data - Data array of the blob\n * @param start - Start point of the blob in the buffer.\n * @param end - End point of the blob in the buffer.\n */\n constructor(\n protected data: Uint8Array,\n protected start: number,\n protected end: number,\n ) {\n super();\n }\n\n public get buffer() {\n return this.data.subarray(this.start, this.end);\n }\n\n // Equivalent to Uint8ArrayToArrayBuffer(this.buffer)\n public get arrayBuffer(): ArrayBufferLike {\n const offset = this.data.byteOffset;\n return this.data.buffer.slice(this.start + offset, this.end + offset);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n const length = buffer.read(lengthLen);\n const pos = buffer.pos;\n buffer.skip(length);\n return new BlobShallowCopy(buffer.buffer, pos, pos + length);\n }\n}\n\nexport const addStringProperty =\n (node: NodeCore, a: string, b: string) => {\n node.addDictionaryString(a); node.addString(b);\n };\nexport const addDictionaryStringProperty =\n (node: NodeCore, a: string, b: string) => {\n node.addDictionaryString(a); node.addString(b);\n };\nexport const addNumberProperty = (node: NodeCore, a: string, b: number) => {\n node.addDictionaryString(a); node.addNumber(b);\n};\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean) => {\n node.addDictionaryString(a); node.addBool(b);\n};\n\nexport interface IStringElement {\n content: string;\n dictionary: boolean;\n _stringElement: true;\n}\n\nexport interface IStringElementInternal extends Omit<IStringElement, \"content\"> {\n content?: string;\n startPos: number;\n endPos: number;\n}\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean | IStringElement;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n // It is an array of nodes.\n private readonly children: NodeTypes[] = [];\n public get nodes() {\n return this.children;\n }\n\n constructor(public type: NodeCoreTypes = \"set\") {}\n\n public [Symbol.iterator]() {\n return this.children[Symbol.iterator]();\n }\n\n public iteratePairs() {\n assert((this.length % 2) === 0, 0x22c /* \"reading pairs\" */);\n return iteratePairs(iterate(this));\n }\n\n public get length() { return this.children.length; }\n\n public get(index: number) { return this.children[index]; }\n\n public getString(index: number): string {\n const node = this.children[index];\n return getStringInstance(node, \"getString should return string\");\n }\n\n public getMaybeString(index: number) {\n const node = this.children[index];\n return getMaybeStringInstance(node);\n }\n\n public getBlob(index: number): BlobCore {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getBlob should return a blob\");\n return node;\n }\n\n public getNode(index: number): NodeCore {\n const node = this.children[index];\n assertNodeCoreInstance(node, \"getNode should return a node\");\n return node;\n }\n\n public getNumber(index: number): number {\n const node = this.children[index];\n assertNumberInstance(node, \"getNumber should return a number\");\n return node;\n }\n\n public getBool(index: number): boolean {\n const node = this.children[index];\n assertBoolInstance(node, \"getBool should return a boolean\");\n return node;\n }\n\n public addNode(type?: NodeCoreTypes): NodeCore {\n const node = new NodeCore(type);\n this.children.push(node);\n return node;\n }\n\n public addBlob(blob: Uint8Array) {\n this.children.push(new BlobDeepCopy(blob));\n }\n\n public addDictionaryString(payload: string) {\n this.children.push({\n content: payload,\n dictionary: true,\n _stringElement: true,\n });\n }\n\n public addString(payload: string) {\n this.children.push({\n content: payload,\n dictionary: false,\n _stringElement: true,\n });\n }\n\n public addNumber(payload: number | undefined) {\n assert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n assert(payload !== undefined && payload >= 0, 0x232 /* \"Payload should not be negative\" */);\n this.children.push(payload);\n }\n\n public addBool(payload: boolean) {\n this.children.push(payload);\n }\n\n // Can we do more efficiently here, without extra objects somehow??\n private static readString(buffer: ReadBuffer, code: number, dictionary: boolean) {\n const lengthLen = getValueSafely(codeToBytesMap, code);\n const length = buffer.read(lengthLen);\n const startPos = buffer.pos;\n buffer.skip(length);\n const result: IStringElementInternal = {\n // Note: Setting here property 'content: undefined' makes code substantially slower!\n dictionary,\n _stringElement: true,\n startPos,\n endPos: buffer.pos,\n };\n\n // We are lying here in terms of presence of `content` property.\n // This will be addressed at the bottom of NodeCore.load() by resolving all strings at once!\n // It's equivalent (but much slower!) to do it here via\n // result.content = Uint8ArrayToString(buffer.buffer.subarray(startPos, buffer.pos), \"utf-8\");\n return result as IStringElementInternal & IStringElement;\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected load(buffer: ReadBuffer, logger: ITelemetryLogger) {\n const stack: NodeTypes[][] = [];\n const stringsToResolve: IStringElementInternal[] = [];\n const dictionary: IStringElement[] = [];\n\n let children = this.children;\n for (;!buffer.eof;) {\n const code = buffer.read();\n switch (code) {\n case MarkerCodesStart.list:\n case MarkerCodesStart.set: {\n const childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n children.push(childValue);\n stack.push(children);\n children = childValue.children;\n continue;\n }\n case MarkerCodes.ConstStringDeclare:\n case MarkerCodes.ConstStringDeclareBig:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const constString = NodeCore.readString(buffer, code, true /* dictionary */);\n stringsToResolve.push(constString);\n dictionary[stringId] = constString;\n continue;\n }\n case MarkerCodes.ConstString8Id:\n case MarkerCodes.ConstString16Id:\n case MarkerCodes.ConstString32Id:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const content = dictionary[stringId];\n assert(content !== undefined, 0x3de /* const string not found */);\n children.push(content);\n continue;\n }\n case MarkerCodes.StringEmpty:\n case MarkerCodes.String8Length:\n case MarkerCodes.String16Length:\n case MarkerCodes.String32Length:\n {\n const str = NodeCore.readString(buffer, code, false /* dictionary */);\n stringsToResolve.push(str);\n children.push(str);\n continue;\n }\n case MarkerCodes.BinaryEmpty:\n case MarkerCodes.BinarySingle8:\n case MarkerCodes.BinarySingle16:\n case MarkerCodes.BinarySingle32:\n case MarkerCodes.BinarySingle64:\n {\n children.push(BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code)));\n continue;\n }\n // If integer is 0.\n case MarkerCodes.Int0:\n {\n children.push(0);\n continue;\n }\n case MarkerCodes.UInt8:\n case MarkerCodes.UInt16:\n case MarkerCodes.UInt32:\n case MarkerCodes.UInt64:\n case MarkerCodes.Int8:\n case MarkerCodes.Int16:\n case MarkerCodes.Int32:\n case MarkerCodes.Int64:\n {\n children.push(buffer.read(getValueSafely(codeToBytesMap, code)));\n continue;\n }\n case MarkerCodes.BoolTrue:\n children.push(true);\n continue;\n case MarkerCodes.BoolFalse:\n children.push(false);\n continue;\n case MarkerCodesEnd.list:\n case MarkerCodesEnd.set:\n // Note: We are not checking that end marker matches start marker.\n // I.e. that we do not have a case where we start a 'list' but end with a 'set'\n // Checking it would require more state tracking that seems not very useful, given\n // our code does not care.\n children = stack.pop()!;\n\n // To my surprise, checking children !== undefined adds measurable cost!\n // We will rely on children.push() crashing in case of mismatch, and check below\n // (outside of the loop)\n continue;\n default:\n throw new Error(`Invalid code: ${code}`);\n }\n }\n\n // This also ensures that stack.length === 0.\n assert(children === this.children, 0x3e7 /* Unpaired start/end list/set markers! */);\n\n /**\n * Process all the strings at once!\n */\n let length = 0;\n for (const el of stringsToResolve) {\n length += el.endPos - el.startPos + 1;\n }\n const stringBuffer = new Uint8Array(length);\n\n length = 0;\n const input = buffer.buffer;\n assert(input.byteOffset === 0, 0x3e8 /* code below assumes no offset */);\n\n for (const el of stringsToResolve) {\n for (let it = el.startPos; it < el.endPos; it++) {\n stringBuffer[length] = input[it];\n length++;\n }\n stringBuffer[length] = 0;\n length++;\n }\n assert(length === stringBuffer.length, 0x418 /* properly encoded */);\n\n const result = Uint8ArrayToString(stringBuffer, \"utf-8\").split(String.fromCharCode(0));\n if (result.length === stringsToResolve.length + 1) {\n // All is good, we expect all the cases to get here\n for (let i = 0; i < stringsToResolve.length; i++) {\n stringsToResolve[i].content = result[i];\n }\n } else {\n // String content has \\0 chars!\n // Recovery code\n logger.sendErrorEvent({ eventName: \"StringParsingError\" });\n for (const el of stringsToResolve) {\n assert(el.content === Uint8ArrayToString(input.subarray(el.startPos, el.endPos), \"utf-8\"),\n 0x3ea /* test */);\n }\n }\n }\n}\n\n /**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n static load(buffer: ReadBuffer, logger: ITelemetryLogger): TreeBuilder {\n const builder = new TreeBuilder();\n builder.load(buffer, logger);\n assert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n return builder;\n }\n}\n\nexport function getMaybeStringInstance(node: NodeTypes): string | undefined {\n const maybeString = node as IStringElement;\n if (maybeString._stringElement) {\n return maybeString.content;\n }\n}\n\nexport function getStringInstance(\n node: NodeTypes,\n message: string,\n): string {\n const maybeString = node as IStringElement;\n if (maybeString._stringElement) {\n return maybeString.content;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertBlobCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is BlobCore {\n if (node instanceof BlobCore) {\n return;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is NodeCore {\n if (node instanceof NodeCore) {\n return;\n }\n throwBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n node: NodeTypes,\n message: string,\n): asserts node is number {\n if (typeof node === \"number\") {\n return;\n }\n throwBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(\n node: NodeTypes,\n message: string,\n): asserts node is boolean {\n if (typeof node === \"boolean\") {\n return;\n }\n throwBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n node: NodeTypes,\n expectedNodeType: NodeType,\n message: string,\n): never {\n throw new NonRetryableError(\n `Buffer parsing exception: ${message}`,\n DriverErrorType.incorrectServerResponse,\n {\n nodeType: getNodeType(node),\n expectedNodeType,\n driverVersion,\n });\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n if (typeof value === \"number\") {\n return \"Number\";\n } else if (value instanceof BlobCore) {\n return \"BlobCore\";\n } else if (value instanceof NodeCore) {\n return \"NodeCore\";\n } else if (typeof value === \"boolean\") {\n return \"Boolean\";\n } else if (value._stringElement) {\n return \"String\";\n }\n return \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\" | \"String\";\n"]}
1
+ {"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;EAGE;AAEF,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,mCAAmC;AACnC,wJAAwJ;AACxJ;;;GAGG;AACH,MAAM,CAAN,IAAY,WA8BX;AA9BD,WAAY,WAAW;IACnB,sDAAa,CAA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B,OAAO,QAAQ,CAAC;KACnB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QACnC,OAAO,SAAS,CAAC;KACpB;SAAM,IAAI,KAAK,CAAC,cAAc,EAAE;QAC7B,OAAO,QAAQ,CAAC;KACnB;IACD,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n*/\n\nimport { assert, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { measure } from \"./odspUtils\";\n\n// eslint-disable-next-line max-len\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n BoolTrue = 11, // value = true\n BoolFalse = 12, // value = false\n\n StringEmpty = 13, // value = \"\"\n String8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n String16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n String32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n ConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n ConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n ConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n ConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n ConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n Int0 = 1, // value = 0\n UInt8 = 3, // unsigned-8-bit little-endian follows\n UInt16 = 5, // unsigned-16-bit little-endian follows\n UInt32 = 7, // unsigned-32-bit little-endian follows\n UInt64 = 9, // unsigned-64-bit little-endian follows\n Int8 = 2, // signed-8-bit little-endian follows\n Int16 = 4, // signed-16-bit little-endian follows\n Int32 = 6, // signed-32-bit little-endian follows\n Int64 = 8, // signed-64-bit little-endian follows\n\n BinaryEmpty = 32, // value = byte[]\n BinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n BinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n BinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n BinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n \"list\" = 49,\n \"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n \"list\" = 50,\n \"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n*/\nexport const codeToBytesMap = {\n // Integer code to bytes\n 1: 0,\n 2: 1,\n 3: 1,\n 4: 2,\n 5: 2,\n 6: 4,\n 7: 4,\n 8: 8,\n 9: 8,\n\n // String code to Bytes\n 13: 0,\n 14: 1,\n 15: 2,\n 16: 4,\n\n 17: 1,\n 18: 2,\n 19: 4,\n\n 20: 1,\n 21: 4,\n\n // Binary code to bytes\n 32: 0,\n 33: 1,\n 34: 2,\n 35: 4,\n 36: 8,\n};\n\nexport function getValueSafely(map: { [index: number]: number; }, key: number) {\n const val = map[key];\n assert(val !== undefined, 0x287 /* key must exist in the map */);\n return val;\n}\n\nexport function getNodeProps(node: NodeCore) {\n const res: Record<string, NodeTypes> = {};\n for (const [keyNode, valueNode] of node.iteratePairs()) {\n const id = getStringInstance(keyNode, \"keynode should be a string\");\n res[id] = valueNode;\n }\n return res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>) {\n const res: IterableIterator<[T, T]> = {\n next: () => {\n const a = it.next();\n if (a.done) {\n return { value: undefined, done: true };\n }\n const b = it.next();\n assert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n return { value: [a.value, b.value], done: b.done };\n },\n [Symbol.iterator]: () => { return res; },\n };\n return res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: { [Symbol.iterator]: () => IterableIterator<T>; }) {\n return obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n public abstract get buffer(): Uint8Array;\n public abstract get arrayBuffer(): ArrayBufferLike;\n\n /**\n * Represents a blob.\n */\n constructor() {}\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n*/\nclass BlobDeepCopy extends BlobCore {\n /**\n * Represents a deep copy of the blob.\n * @param data - Data array of the blob\n */\n constructor(protected readonly data: Uint8Array) {\n super();\n }\n\n public get buffer() {\n return this.data;\n }\n\n public get arrayBuffer(): ArrayBufferLike {\n return Uint8ArrayToArrayBuffer(this.buffer);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n const length = buffer.read(lengthLen);\n const data = new Uint8Array(length);\n for (let counter = 0; counter < length; counter++) {\n data[counter] = buffer.read();\n }\n return new BlobDeepCopy(data);\n }\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\n export class BlobShallowCopy extends BlobCore {\n /**\n * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n * @param data - Data array of the blob\n * @param start - Start point of the blob in the buffer.\n * @param end - End point of the blob in the buffer.\n */\n constructor(\n protected data: Uint8Array,\n protected start: number,\n protected end: number,\n ) {\n super();\n }\n\n public get buffer() {\n return this.data.subarray(this.start, this.end);\n }\n\n // Equivalent to Uint8ArrayToArrayBuffer(this.buffer)\n public get arrayBuffer(): ArrayBufferLike {\n const offset = this.data.byteOffset;\n return this.data.buffer.slice(this.start + offset, this.end + offset);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n const length = buffer.read(lengthLen);\n const pos = buffer.pos;\n buffer.skip(length);\n return new BlobShallowCopy(buffer.buffer, pos, pos + length);\n }\n}\n\nexport const addStringProperty =\n (node: NodeCore, a: string, b: string) => {\n node.addDictionaryString(a); node.addString(b);\n };\nexport const addDictionaryStringProperty =\n (node: NodeCore, a: string, b: string) => {\n node.addDictionaryString(a); node.addString(b);\n };\nexport const addNumberProperty = (node: NodeCore, a: string, b: number) => {\n node.addDictionaryString(a); node.addNumber(b);\n};\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean) => {\n node.addDictionaryString(a); node.addBool(b);\n};\n\nexport interface IStringElement {\n content: string;\n dictionary: boolean;\n _stringElement: true;\n}\n\nexport interface IStringElementInternal extends Omit<IStringElement, \"content\"> {\n content?: string;\n startPos: number;\n endPos: number;\n}\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean | IStringElement;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n // It is an array of nodes.\n private readonly children: NodeTypes[] = [];\n public get nodes() {\n return this.children;\n }\n\n constructor(public type: NodeCoreTypes = \"set\") {}\n\n public [Symbol.iterator]() {\n return this.children[Symbol.iterator]();\n }\n\n public iteratePairs() {\n assert((this.length % 2) === 0, 0x22c /* \"reading pairs\" */);\n return iteratePairs(iterate(this));\n }\n\n public get length() { return this.children.length; }\n\n public get(index: number) { return this.children[index]; }\n\n public getString(index: number): string {\n const node = this.children[index];\n return getStringInstance(node, \"getString should return string\");\n }\n\n public getMaybeString(index: number) {\n const node = this.children[index];\n return getMaybeStringInstance(node);\n }\n\n public getBlob(index: number): BlobCore {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getBlob should return a blob\");\n return node;\n }\n\n public getNode(index: number): NodeCore {\n const node = this.children[index];\n assertNodeCoreInstance(node, \"getNode should return a node\");\n return node;\n }\n\n public getNumber(index: number): number {\n const node = this.children[index];\n assertNumberInstance(node, \"getNumber should return a number\");\n return node;\n }\n\n public getBool(index: number): boolean {\n const node = this.children[index];\n assertBoolInstance(node, \"getBool should return a boolean\");\n return node;\n }\n\n public addNode(type?: NodeCoreTypes): NodeCore {\n const node = new NodeCore(type);\n this.children.push(node);\n return node;\n }\n\n public addBlob(blob: Uint8Array) {\n this.children.push(new BlobDeepCopy(blob));\n }\n\n public addDictionaryString(payload: string) {\n this.children.push({\n content: payload,\n dictionary: true,\n _stringElement: true,\n });\n }\n\n public addString(payload: string) {\n this.children.push({\n content: payload,\n dictionary: false,\n _stringElement: true,\n });\n }\n\n public addNumber(payload: number | undefined) {\n assert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n assert(payload !== undefined && payload >= 0, 0x232 /* \"Payload should not be negative\" */);\n this.children.push(payload);\n }\n\n public addBool(payload: boolean) {\n this.children.push(payload);\n }\n\n // Can we do more efficiently here, without extra objects somehow??\n private static readString(buffer: ReadBuffer, code: number, dictionary: boolean) {\n const lengthLen = getValueSafely(codeToBytesMap, code);\n const length = buffer.read(lengthLen);\n const startPos = buffer.pos;\n buffer.skip(length);\n const result: IStringElementInternal = {\n // Note: Setting here property 'content: undefined' makes code substantially slower!\n dictionary,\n _stringElement: true,\n startPos,\n endPos: buffer.pos,\n };\n\n // We are lying here in terms of presence of `content` property.\n // This will be addressed at the bottom of NodeCore.load() by resolving all strings at once!\n // It's equivalent (but much slower!) to do it here via\n // result.content = Uint8ArrayToString(buffer.buffer.subarray(startPos, buffer.pos), \"utf-8\");\n return result as IStringElementInternal & IStringElement;\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected load(buffer: ReadBuffer, logger: ITelemetryLogger) {\n const [stringsToResolve, durationStructure] = measure(() => this.loadStructure(buffer, logger));\n const [, durationStrings] = measure(() => this.loadStrings(buffer, stringsToResolve, logger));\n return { durationStructure, durationStrings };\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected loadStructure(buffer: ReadBuffer, logger: ITelemetryLogger) {\n const stack: NodeTypes[][] = [];\n const stringsToResolve: IStringElementInternal[] = [];\n const dictionary: IStringElement[] = [];\n\n let children = this.children;\n for (;!buffer.eof;) {\n const code = buffer.read();\n switch (code) {\n case MarkerCodesStart.list:\n case MarkerCodesStart.set: {\n const childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n children.push(childValue);\n stack.push(children);\n children = childValue.children;\n continue;\n }\n case MarkerCodes.ConstStringDeclare:\n case MarkerCodes.ConstStringDeclareBig:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const constString = NodeCore.readString(buffer, code, true /* dictionary */);\n stringsToResolve.push(constString);\n dictionary[stringId] = constString;\n continue;\n }\n case MarkerCodes.ConstString8Id:\n case MarkerCodes.ConstString16Id:\n case MarkerCodes.ConstString32Id:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const content = dictionary[stringId];\n assert(content !== undefined, 0x3de /* const string not found */);\n children.push(content);\n continue;\n }\n case MarkerCodes.StringEmpty:\n case MarkerCodes.String8Length:\n case MarkerCodes.String16Length:\n case MarkerCodes.String32Length:\n {\n const str = NodeCore.readString(buffer, code, false /* dictionary */);\n stringsToResolve.push(str);\n children.push(str);\n continue;\n }\n case MarkerCodes.BinaryEmpty:\n case MarkerCodes.BinarySingle8:\n case MarkerCodes.BinarySingle16:\n case MarkerCodes.BinarySingle32:\n case MarkerCodes.BinarySingle64:\n {\n children.push(BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code)));\n continue;\n }\n // If integer is 0.\n case MarkerCodes.Int0:\n {\n children.push(0);\n continue;\n }\n case MarkerCodes.UInt8:\n case MarkerCodes.UInt16:\n case MarkerCodes.UInt32:\n case MarkerCodes.UInt64:\n case MarkerCodes.Int8:\n case MarkerCodes.Int16:\n case MarkerCodes.Int32:\n case MarkerCodes.Int64:\n {\n children.push(buffer.read(getValueSafely(codeToBytesMap, code)));\n continue;\n }\n case MarkerCodes.BoolTrue:\n children.push(true);\n continue;\n case MarkerCodes.BoolFalse:\n children.push(false);\n continue;\n case MarkerCodesEnd.list:\n case MarkerCodesEnd.set:\n // Note: We are not checking that end marker matches start marker.\n // I.e. that we do not have a case where we start a 'list' but end with a 'set'\n // Checking it would require more state tracking that seems not very useful, given\n // our code does not care.\n children = stack.pop()!;\n\n // To my surprise, checking children !== undefined adds measurable cost!\n // We will rely on children.push() crashing in case of mismatch, and check below\n // (outside of the loop)\n continue;\n default:\n throw new Error(`Invalid code: ${code}`);\n }\n }\n\n // This also ensures that stack.length === 0.\n assert(children === this.children, 0x3e7 /* Unpaired start/end list/set markers! */);\n\n return stringsToResolve;\n }\n\n private loadStrings(buffer: ReadBuffer, stringsToResolve: IStringElementInternal[], logger: ITelemetryLogger) {\n /**\n * Process all the strings at once!\n */\n let length = 0;\n for (const el of stringsToResolve) {\n length += el.endPos - el.startPos + 1;\n }\n const stringBuffer = new Uint8Array(length);\n\n length = 0;\n const input = buffer.buffer;\n assert(input.byteOffset === 0, 0x3e8 /* code below assumes no offset */);\n\n for (const el of stringsToResolve) {\n for (let it = el.startPos; it < el.endPos; it++) {\n stringBuffer[length] = input[it];\n length++;\n }\n stringBuffer[length] = 0;\n length++;\n }\n assert(length === stringBuffer.length, 0x418 /* properly encoded */);\n\n const result = Uint8ArrayToString(stringBuffer, \"utf-8\").split(String.fromCharCode(0));\n if (result.length === stringsToResolve.length + 1) {\n // All is good, we expect all the cases to get here\n for (let i = 0; i < stringsToResolve.length; i++) {\n stringsToResolve[i].content = result[i];\n }\n } else {\n // String content has \\0 chars!\n // Recovery code\n logger.sendErrorEvent({ eventName: \"StringParsingError\" });\n for (const el of stringsToResolve) {\n assert(el.content === Uint8ArrayToString(input.subarray(el.startPos, el.endPos), \"utf-8\"),\n 0x3ea /* test */);\n }\n }\n }\n}\n\n /**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n static load(buffer: ReadBuffer, logger: ITelemetryLogger) {\n const builder = new TreeBuilder();\n const telemetryProps = builder.load(buffer, logger);\n assert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n return { builder, telemetryProps };\n }\n}\n\nexport function getMaybeStringInstance(node: NodeTypes): string | undefined {\n const maybeString = node as IStringElement;\n if (maybeString._stringElement) {\n return maybeString.content;\n }\n}\n\nexport function getStringInstance(\n node: NodeTypes,\n message: string,\n): string {\n const maybeString = node as IStringElement;\n if (maybeString._stringElement) {\n return maybeString.content;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertBlobCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is BlobCore {\n if (node instanceof BlobCore) {\n return;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is NodeCore {\n if (node instanceof NodeCore) {\n return;\n }\n throwBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n node: NodeTypes,\n message: string,\n): asserts node is number {\n if (typeof node === \"number\") {\n return;\n }\n throwBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(\n node: NodeTypes,\n message: string,\n): asserts node is boolean {\n if (typeof node === \"boolean\") {\n return;\n }\n throwBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n node: NodeTypes,\n expectedNodeType: NodeType,\n message: string,\n): never {\n throw new NonRetryableError(\n `Buffer parsing exception: ${message}`,\n DriverErrorType.incorrectServerResponse,\n {\n nodeType: getNodeType(node),\n expectedNodeType,\n driverVersion,\n });\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n if (typeof value === \"number\") {\n return \"Number\";\n } else if (value instanceof BlobCore) {\n return \"BlobCore\";\n } else if (value instanceof NodeCore) {\n return \"NodeCore\";\n } else if (typeof value === \"boolean\") {\n return \"Boolean\";\n } else if (value._stringElement) {\n return \"String\";\n }\n return \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\" | \"String\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/odsp-driver",
3
- "version": "2.0.0-internal.2.1.2",
3
+ "version": "2.0.0-internal.2.2.0",
4
4
  "description": "Socket storage implementation for SPO and ODC",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -28,8 +28,11 @@
28
28
  "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
29
29
  "eslint": "eslint --format stylish src",
30
30
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
31
+ "format": "npm run prettier:fix",
31
32
  "lint": "npm run eslint",
32
33
  "lint:fix": "npm run eslint:fix",
34
+ "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
35
+ "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
33
36
  "test": "npm run test:mocha",
34
37
  "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
35
38
  "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
@@ -61,28 +64,28 @@
61
64
  "dependencies": {
62
65
  "@fluidframework/common-definitions": "^0.20.1",
63
66
  "@fluidframework/common-utils": "^1.0.0",
64
- "@fluidframework/core-interfaces": ">=2.0.0-internal.2.1.2 <2.0.0-internal.3.0.0",
65
- "@fluidframework/driver-base": ">=2.0.0-internal.2.1.2 <2.0.0-internal.3.0.0",
66
- "@fluidframework/driver-definitions": ">=2.0.0-internal.2.1.2 <2.0.0-internal.3.0.0",
67
- "@fluidframework/driver-utils": ">=2.0.0-internal.2.1.2 <2.0.0-internal.3.0.0",
67
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
68
+ "@fluidframework/driver-base": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
69
+ "@fluidframework/driver-definitions": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
70
+ "@fluidframework/driver-utils": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
68
71
  "@fluidframework/gitresources": "^0.1038.2000",
69
- "@fluidframework/odsp-doclib-utils": ">=2.0.0-internal.2.1.2 <2.0.0-internal.3.0.0",
70
- "@fluidframework/odsp-driver-definitions": ">=2.0.0-internal.2.1.2 <2.0.0-internal.3.0.0",
72
+ "@fluidframework/odsp-doclib-utils": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
73
+ "@fluidframework/odsp-driver-definitions": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
71
74
  "@fluidframework/protocol-base": "^0.1038.2000",
72
75
  "@fluidframework/protocol-definitions": "^1.1.0",
73
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.2.1.2 <2.0.0-internal.3.0.0",
76
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
74
77
  "abort-controller": "^3.0.0",
75
78
  "node-fetch": "^2.6.1",
76
79
  "socket.io-client": "^4.4.1",
77
80
  "uuid": "^8.3.1"
78
81
  },
79
82
  "devDependencies": {
80
- "@fluid-tools/build-cli": "^0.6.0",
83
+ "@fluid-tools/build-cli": "^0.7.0",
81
84
  "@fluidframework/build-common": "^1.1.0",
82
- "@fluidframework/build-tools": "^0.6.0",
85
+ "@fluidframework/build-tools": "^0.7.0",
83
86
  "@fluidframework/eslint-config-fluid": "^1.2.0",
84
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.1.2 <2.0.0-internal.3.0.0",
85
- "@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@2.0.0-internal.2.1.1",
87
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.2.0 <2.0.0-internal.3.0.0",
88
+ "@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@2.0.0-internal.2.1.0",
86
89
  "@microsoft/api-extractor": "^7.22.2",
87
90
  "@rushstack/eslint-config": "^2.5.1",
88
91
  "@types/mocha": "^9.1.1",
@@ -94,13 +97,15 @@
94
97
  "eslint": "~8.6.0",
95
98
  "mocha": "^10.0.0",
96
99
  "nyc": "^15.0.0",
100
+ "prettier": "~2.6.2",
97
101
  "rimraf": "^2.6.2",
98
102
  "sinon": "^7.4.2",
99
103
  "typescript": "~4.5.5"
100
104
  },
101
105
  "typeValidation": {
102
- "version": "2.0.0-internal.2.1.2",
103
- "baselineRange": "2.0.0-internal.2.1.1",
106
+ "version": "2.0.0-internal.2.2.0",
107
+ "baselineRange": ">=2.0.0-internal.2.1.0 <2.0.0-internal.2.2.0",
108
+ "baselineVersion": "2.0.0-internal.2.1.0",
104
109
  "broken": {}
105
110
  }
106
111
  }
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ module.exports = {
7
+ ...require("@fluidframework/build-common/prettier.config.cjs"),
8
+ };
@@ -19,23 +19,17 @@ import {
19
19
  NodeTypes,
20
20
  TreeBuilder,
21
21
  } from "./zipItDataRepresentationUtils";
22
+ import { measure } from "./odspUtils";
22
23
 
23
24
  export const snapshotMinReadVersion = "1.0";
24
25
  export const currentReadVersion = "1.0";
25
26
 
26
- interface ISnapshotSection {
27
- snapshotTree: ISnapshotTree;
28
- sequenceNumber: number;
29
- slowTreeStructureCount: number;
30
- }
31
-
32
27
  /**
33
28
  * The parsing is significantly faster if the position of props is well known instead of dynamic. So these variables
34
29
  * represents how many times slower parsing path is executed. This will be then logged into telemetry.
35
30
  */
36
31
  export interface ISnapshotContentsWithProps extends ISnapshotContents {
37
- slowBlobStructureCount?: number;
38
- slowTreeStructureCount?: number;
32
+ telemetryProps: Record<string, number>;
39
33
  }
40
34
 
41
35
  /**
@@ -186,7 +180,7 @@ function readTreeSection(node: NodeCore) {
186
180
  * Recreates snapshot tree out of tree representation.
187
181
  * @param node - tree node to de-serialize from
188
182
  */
189
- function readSnapshotSection(node: NodeTypes): ISnapshotSection {
183
+ function readSnapshotSection(node: NodeTypes) {
190
184
  assertNodeCoreInstance(node, "Snapshot should be of type NodeCore");
191
185
  const records = getNodeProps(node);
192
186
 
@@ -211,7 +205,7 @@ export function parseCompactSnapshotResponse(
211
205
  buffer: Uint8Array,
212
206
  logger: ITelemetryLogger,
213
207
  ): ISnapshotContentsWithProps {
214
- const builder = TreeBuilder.load(new ReadBuffer(buffer), logger);
208
+ const { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);
215
209
  assert(builder.length === 1, 0x219 /* "1 root should be there" */);
216
210
  const root = builder.getNode(0);
217
211
 
@@ -230,10 +224,20 @@ export function parseCompactSnapshotResponse(
230
224
  assert(currentReadVersion === cv,
231
225
  0x2c2 /* "Create Version should be equal to currentReadVersion" */);
232
226
 
227
+ const [snapshot, durationSnapshotTree] = measure(() => readSnapshotSection(records.snapshot));
228
+ const [blobs, durationBlobs] = measure(() => readBlobSection(records.blobs));
229
+
233
230
  return {
234
- ...readSnapshotSection(records.snapshot),
235
- ...readBlobSection(records.blobs),
231
+ ...snapshot,
232
+ ...blobs,
236
233
  ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [],
237
234
  latestSequenceNumber: records.lsn,
235
+ telemetryProps: {
236
+ ...telemetryProps,
237
+ durationSnapshotTree,
238
+ durationBlobs,
239
+ slowTreeStructureCount: snapshot.slowTreeStructureCount,
240
+ slowBlobStructureCount: blobs.slowBlobStructureCount,
241
+ },
238
242
  };
239
243
  }