@fluidframework/odsp-driver 0.51.0 → 0.52.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 (87) hide show
  1. package/dist/contractsPublic.d.ts +0 -4
  2. package/dist/contractsPublic.d.ts.map +1 -1
  3. package/dist/contractsPublic.js.map +1 -1
  4. package/dist/createFile.js +6 -5
  5. package/dist/createFile.js.map +1 -1
  6. package/dist/createNewUtils.js +5 -4
  7. package/dist/createNewUtils.js.map +1 -1
  8. package/dist/epochTracker.d.ts.map +1 -1
  9. package/dist/epochTracker.js +1 -4
  10. package/dist/epochTracker.js.map +1 -1
  11. package/dist/fetchSnapshot.d.ts.map +1 -1
  12. package/dist/fetchSnapshot.js +4 -6
  13. package/dist/fetchSnapshot.js.map +1 -1
  14. package/dist/getFileLink.d.ts +1 -1
  15. package/dist/getFileLink.d.ts.map +1 -1
  16. package/dist/getFileLink.js +32 -22
  17. package/dist/getFileLink.js.map +1 -1
  18. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  19. package/dist/odspDocumentStorageManager.js +1 -8
  20. package/dist/odspDocumentStorageManager.js.map +1 -1
  21. package/dist/odspDriverUrlResolver.d.ts +0 -4
  22. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  23. package/dist/odspDriverUrlResolver.js +0 -7
  24. package/dist/odspDriverUrlResolver.js.map +1 -1
  25. package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -6
  26. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  27. package/dist/odspDriverUrlResolverForShareLink.js +3 -15
  28. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  29. package/dist/odspSummaryUploadManager.js +24 -4
  30. package/dist/odspSummaryUploadManager.js.map +1 -1
  31. package/dist/odspUtils.d.ts.map +1 -1
  32. package/dist/odspUtils.js +0 -1
  33. package/dist/odspUtils.js.map +1 -1
  34. package/dist/packageVersion.d.ts +1 -1
  35. package/dist/packageVersion.js +1 -1
  36. package/dist/packageVersion.js.map +1 -1
  37. package/dist/zipItDataRepresentationUtils.js +0 -1
  38. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  39. package/lib/contractsPublic.d.ts +0 -4
  40. package/lib/contractsPublic.d.ts.map +1 -1
  41. package/lib/contractsPublic.js.map +1 -1
  42. package/lib/createFile.js +6 -5
  43. package/lib/createFile.js.map +1 -1
  44. package/lib/createNewUtils.js +5 -4
  45. package/lib/createNewUtils.js.map +1 -1
  46. package/lib/epochTracker.d.ts.map +1 -1
  47. package/lib/epochTracker.js +2 -5
  48. package/lib/epochTracker.js.map +1 -1
  49. package/lib/fetchSnapshot.d.ts.map +1 -1
  50. package/lib/fetchSnapshot.js +4 -6
  51. package/lib/fetchSnapshot.js.map +1 -1
  52. package/lib/getFileLink.d.ts +1 -1
  53. package/lib/getFileLink.d.ts.map +1 -1
  54. package/lib/getFileLink.js +33 -23
  55. package/lib/getFileLink.js.map +1 -1
  56. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  57. package/lib/odspDocumentStorageManager.js +2 -9
  58. package/lib/odspDocumentStorageManager.js.map +1 -1
  59. package/lib/odspDriverUrlResolver.d.ts +0 -4
  60. package/lib/odspDriverUrlResolver.d.ts.map +1 -1
  61. package/lib/odspDriverUrlResolver.js +0 -7
  62. package/lib/odspDriverUrlResolver.js.map +1 -1
  63. package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -6
  64. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  65. package/lib/odspDriverUrlResolverForShareLink.js +3 -15
  66. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  67. package/lib/odspSummaryUploadManager.js +5 -4
  68. package/lib/odspSummaryUploadManager.js.map +1 -1
  69. package/lib/odspUtils.d.ts.map +1 -1
  70. package/lib/odspUtils.js +0 -1
  71. package/lib/odspUtils.js.map +1 -1
  72. package/lib/packageVersion.d.ts +1 -1
  73. package/lib/packageVersion.js +1 -1
  74. package/lib/packageVersion.js.map +1 -1
  75. package/lib/zipItDataRepresentationUtils.js +0 -1
  76. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  77. package/package.json +12 -12
  78. package/src/contractsPublic.ts +0 -5
  79. package/src/epochTracker.ts +2 -5
  80. package/src/fetchSnapshot.ts +3 -9
  81. package/src/getFileLink.ts +40 -26
  82. package/src/odspDocumentStorageManager.ts +1 -10
  83. package/src/odspDriverUrlResolver.ts +0 -13
  84. package/src/odspDriverUrlResolverForShareLink.ts +5 -23
  85. package/src/odspUtils.ts +0 -1
  86. package/src/packageVersion.ts +1 -1
  87. package/src/zipItDataRepresentationUtils.ts +0 -1
@@ -3,10 +3,30 @@
3
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
4
  * Licensed under the MIT License.
5
5
  */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
6
25
  Object.defineProperty(exports, "__esModule", { value: true });
7
26
  exports.OdspSummaryUploadManager = void 0;
8
27
  const common_utils_1 = require("@fluidframework/common-utils");
9
28
  const protocol_base_1 = require("@fluidframework/protocol-base");
29
+ const api = __importStar(require("@fluidframework/protocol-definitions"));
10
30
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
11
31
  const getUrlAndHeadersWithAuth_1 = require("./getUrlAndHeadersWithAuth");
12
32
  const odspUtils_1 = require("./odspUtils");
@@ -118,14 +138,14 @@ class OdspSummaryUploadManager {
118
138
  let unreferenced;
119
139
  const currentPath = path === "" ? `${rootNodeName}/${key}` : `${path}/${key}`;
120
140
  switch (summaryObject.type) {
121
- case 1 /* Tree */: {
141
+ case api.SummaryType.Tree: {
122
142
  const result = await this.convertSummaryToSnapshotTree(parentHandle, summaryObject, rootNodeName, currentPath);
123
143
  value = result.snapshotTree;
124
144
  unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;
125
145
  blobs += result.blobs;
126
146
  break;
127
147
  }
128
- case 2 /* Blob */: {
148
+ case api.SummaryType.Blob: {
129
149
  if (typeof summaryObject.content === "string") {
130
150
  value = {
131
151
  type: "blob",
@@ -143,7 +163,7 @@ class OdspSummaryUploadManager {
143
163
  blobs++;
144
164
  break;
145
165
  }
146
- case 3 /* Handle */: {
166
+ case api.SummaryType.Handle: {
147
167
  if (!parentHandle) {
148
168
  throw Error("Parent summary does not exist to reference by handle.");
149
169
  }
@@ -155,7 +175,7 @@ class OdspSummaryUploadManager {
155
175
  id = `${parentHandle}/${pathKey}`;
156
176
  break;
157
177
  }
158
- case 4 /* Attachment */: {
178
+ case api.SummaryType.Attachment: {
159
179
  id = summaryObject.id;
160
180
  break;
161
181
  }
@@ -1 +1 @@
1
- {"version":3,"file":"odspSummaryUploadManager.js","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA2F;AAE3F,iEAA2D;AAG3D,qEAAmE;AAUnE,yEAAsE;AACtE,2CAA0D;AAE1D,4BAA4B;AAE5B,mGAAmG;AACnG,SAAS,0BAA0B;IAC/B,IAAI;QACA,sCAAsC;QACtC,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,EAAE;YAC3D,IAAK,YAAY,CAAC,0BAA0B,KAAK,GAAG,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EAAE,iBAAkB,aAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;iBAClF;aACJ;YAED,MAAM,SAAS,GAA8B;gBACzC,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC;gBAC7B,IAAI,EAAE,0BAAU,CAAC,aAAa,CAAC;aAClC,CAAC;YAEF,IAAI,KAA2B,CAAC;YAEhC,IAAI,KAAK,EAAE;gBACP,qBAAM,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,CAAC,iEAAiE,CAAC,CAAC;gBAClG,KAAK,iCACD,KAAK,IACF,SAAS,KACZ,YAAY,GACf,CAAC;aACL;iBAAM,IAAI,EAAE,EAAE;gBACX,KAAK,mCACE,SAAS,KACZ,EAAE,GACL,CAAC;aACL;iBAAM;gBACH,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aACnE;YAED,YAAY,CAAC,OAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;QAED,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ;AAtMD,4DAsMC;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspSummaryPayload,\n IWriteSummaryResponse,\n IOdspSummaryTree,\n IOdspSummaryTreeBaseEntry,\n OdspSummaryTreeEntry,\n OdspSummaryTreeValue,\n} from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/* eslint-disable max-len */\n\n// Gate that when flipped, instructs to mark unreferenced nodes as such in the summary sent to SPO.\nfunction gatesMarkUnreferencedNodes() {\n try {\n // Leave override for testing purposes\n if (typeof localStorage === \"object\" && localStorage !== null) {\n if (localStorage.FluidMarkUnreferencedNodes === \"1\") {\n return true;\n }\n if (localStorage.FluidMarkUnreferencedNodes === \"0\") {\n return false;\n }\n }\n } catch (e) {}\n\n return true;\n}\n\n/**\n * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into\n * a snapshot tree and then uploads that to the server.\n */\nexport class OdspSummaryUploadManager {\n // Last proposed handle of the uploaded app summary.\n private lastSummaryProposalHandle: string | undefined;\n\n constructor(\n private readonly snapshotUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly logger: ITelemetryLogger,\n private readonly epochTracker: EpochTracker,\n ) {\n }\n\n public async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {\n // If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),\n // then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.\n if (context.proposalHandle !== this.lastSummaryProposalHandle) {\n this.logger.sendTelemetryEvent({\n eventName: \"LastSummaryProposedHandleMismatch\",\n ackedSummaryProposedHandle: context.proposalHandle,\n lastSummaryProposalHandle: this.lastSummaryProposalHandle,\n });\n }\n const result = await this.writeSummaryTreeCore(context.ackHandle, context.referenceSequenceNumber, tree);\n const id = result ? result.id : undefined;\n if (!result || !id) {\n throw new Error(`Failed to write summary tree`);\n }\n this.lastSummaryProposalHandle = id;\n return id;\n }\n\n private async writeSummaryTreeCore(\n parentHandle: string | undefined,\n referenceSequenceNumber: number,\n tree: api.ISummaryTree,\n ): Promise<IWriteSummaryResponse> {\n const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(\n parentHandle,\n tree,\n \".app\",\n \"\",\n );\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries!,\n message: \"app\",\n sequenceNumber: referenceSequenceNumber,\n // no ack handle implies this is initial summary after empty file creation.\n // send container payload so server will use it without a summary op\n type: parentHandle === undefined ? \"container\" : \"channel\",\n };\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"WriteSummaryTree\");\n\n const { url, headers } = getUrlAndHeadersWithAuth(`${this.snapshotUrl}/snapshot`, storageToken);\n headers[\"Content-Type\"] = \"application/json\";\n if (parentHandle) {\n headers[\"If-Match\"] = `fluid:containerid=${parentHandle}`;\n }\n\n const postBody = JSON.stringify(snapshot);\n\n return PerformanceEvent.timedExecAsync(this.logger,\n {\n eventName: \"uploadSummary\",\n attempt: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n blobs,\n size: postBody.length,\n },\n async () => {\n const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"uploadSummary\");\n return response.content;\n });\n });\n }\n\n /**\n * Following are the goals of this function.\n * a.) Converts the summary tree to a snapshot/odsp tree to be uploaded. Always upload full snapshot tree.\n * @param parentHandle - Handle of the last uploaded summary or detach new summary.\n * @param tree - Summary Tree which will be converted to snapshot tree to be uploaded.\n * @param rootNodeName - Root node name of the summary tree.\n * @param path - Current path of node which is getting evaluated.\n * @param markUnreferencedNodes - True if we should mark unreferenced nodes.\n */\n private async convertSummaryToSnapshotTree(\n parentHandle: string | undefined,\n tree: api.ISummaryTree,\n rootNodeName: string,\n path: string = \"\",\n markUnreferencedNodes: boolean = gatesMarkUnreferencedNodes(),\n ) {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [] as OdspSummaryTreeEntry[],\n };\n\n let blobs = 0;\n const keys = Object.keys(tree.tree);\n for (const key of keys) {\n const summaryObject = tree.tree[key];\n\n let id: string | undefined;\n let value: OdspSummaryTreeValue | undefined;\n\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is\n // true (which is the only value it can have), the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n const currentPath = path === \"\" ? `${rootNodeName}/${key}` : `${path}/${key}`;\n switch (summaryObject.type) {\n case api.SummaryType.Tree: {\n const result = await this.convertSummaryToSnapshotTree(\n parentHandle,\n summaryObject,\n rootNodeName,\n currentPath);\n value = result.snapshotTree;\n unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;\n blobs += result.blobs;\n break;\n }\n case api.SummaryType.Blob: {\n if (typeof summaryObject.content === \"string\") {\n value = {\n type: \"blob\",\n content: summaryObject.content,\n encoding: \"utf-8\",\n };\n } else {\n value = {\n type: \"blob\",\n content: Uint8ArrayToString(summaryObject.content, \"base64\"),\n encoding: \"base64\",\n };\n }\n blobs++;\n break;\n }\n case api.SummaryType.Handle: {\n if (!parentHandle) {\n throw Error(\"Parent summary does not exist to reference by handle.\");\n }\n let handlePath = summaryObject.handle;\n if (handlePath.length > 0 && !handlePath.startsWith(\"/\")) {\n handlePath = `/${handlePath}`;\n }\n const pathKey = `${rootNodeName}${handlePath}`;\n id = `${parentHandle}/${pathKey}`;\n break;\n }\n case api.SummaryType.Attachment: {\n id = summaryObject.id;\n break;\n }\n default: {\n unreachableCase(summaryObject, `Unknown type: ${(summaryObject as any).type}`);\n }\n }\n\n const baseEntry: IOdspSummaryTreeBaseEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n };\n\n let entry: OdspSummaryTreeEntry;\n\n if (value) {\n assert(id === undefined, 0x0ad /* \"Snapshot entry has both a tree value and a referenced id!\" */);\n entry = {\n value,\n ...baseEntry,\n unreferenced,\n };\n } else if (id) {\n entry = {\n ...baseEntry,\n id,\n };\n } else {\n throw new Error(`Invalid tree entry for ${summaryObject.type}`);\n }\n\n snapshotTree.entries!.push(entry);\n }\n\n return { snapshotTree, blobs };\n }\n}\n\n/* eslint-enable max-len */\n"]}
1
+ {"version":3,"file":"odspSummaryUploadManager.js","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAGH,+DAA2F;AAE3F,iEAA2D;AAC3D,0EAA4D;AAE5D,qEAAmE;AAUnE,yEAAsE;AACtE,2CAA0D;AAE1D,4BAA4B;AAE5B,mGAAmG;AACnG,SAAS,0BAA0B;IAC/B,IAAI;QACA,sCAAsC;QACtC,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,EAAE;YAC3D,IAAK,YAAY,CAAC,0BAA0B,KAAK,GAAG,EAAE;gBAClD,OAAO,IAAI,CAAC;aACf;YACD,IAAK,YAAY,CAAC,0BAA0B,KAAK,GAAG,EAAE;gBAClD,OAAO,KAAK,CAAC;aAChB;SACJ;KACJ;IAAC,OAAO,CAAC,EAAE,GAAE;IAEd,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAa,wBAAwB;IAIjC,YACqB,WAAmB,EACnB,eAAgD,EAChD,MAAwB,EACxB,YAA0B;QAH1B,gBAAW,GAAX,WAAW,CAAQ;QACnB,oBAAe,GAAf,eAAe,CAAiC;QAChD,WAAM,GAAN,MAAM,CAAkB;QACxB,iBAAY,GAAZ,YAAY,CAAc;IAE/C,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,IAAsB,EAAE,OAAwB;QAC1E,8HAA8H;QAC9H,gIAAgI;QAChI,IAAI,OAAO,CAAC,cAAc,KAAK,IAAI,CAAC,yBAAyB,EAAE;YAC3D,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;gBAC3B,SAAS,EAAE,mCAAmC;gBAC9C,0BAA0B,EAAE,OAAO,CAAC,cAAc;gBAClD,yBAAyB,EAAE,IAAI,CAAC,yBAAyB;aAC5D,CAAC,CAAC;SACN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,EAAE,CAAC;IACnC,CAAC;CACJ;AAtMD,4DAsMC;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspSummaryPayload,\n IWriteSummaryResponse,\n IOdspSummaryTree,\n IOdspSummaryTreeBaseEntry,\n OdspSummaryTreeEntry,\n OdspSummaryTreeValue,\n} from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/* eslint-disable max-len */\n\n// Gate that when flipped, instructs to mark unreferenced nodes as such in the summary sent to SPO.\nfunction gatesMarkUnreferencedNodes() {\n try {\n // Leave override for testing purposes\n if (typeof localStorage === \"object\" && localStorage !== null) {\n if (localStorage.FluidMarkUnreferencedNodes === \"1\") {\n return true;\n }\n if (localStorage.FluidMarkUnreferencedNodes === \"0\") {\n return false;\n }\n }\n } catch (e) {}\n\n return true;\n}\n\n/**\n * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into\n * a snapshot tree and then uploads that to the server.\n */\nexport class OdspSummaryUploadManager {\n // Last proposed handle of the uploaded app summary.\n private lastSummaryProposalHandle: string | undefined;\n\n constructor(\n private readonly snapshotUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly logger: ITelemetryLogger,\n private readonly epochTracker: EpochTracker,\n ) {\n }\n\n public async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {\n // If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),\n // then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.\n if (context.proposalHandle !== this.lastSummaryProposalHandle) {\n this.logger.sendTelemetryEvent({\n eventName: \"LastSummaryProposedHandleMismatch\",\n ackedSummaryProposedHandle: context.proposalHandle,\n lastSummaryProposalHandle: this.lastSummaryProposalHandle,\n });\n }\n const result = await this.writeSummaryTreeCore(context.ackHandle, context.referenceSequenceNumber, tree);\n const id = result ? result.id : undefined;\n if (!result || !id) {\n throw new Error(`Failed to write summary tree`);\n }\n this.lastSummaryProposalHandle = id;\n return id;\n }\n\n private async writeSummaryTreeCore(\n parentHandle: string | undefined,\n referenceSequenceNumber: number,\n tree: api.ISummaryTree,\n ): Promise<IWriteSummaryResponse> {\n const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(\n parentHandle,\n tree,\n \".app\",\n \"\",\n );\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries!,\n message: \"app\",\n sequenceNumber: referenceSequenceNumber,\n // no ack handle implies this is initial summary after empty file creation.\n // send container payload so server will use it without a summary op\n type: parentHandle === undefined ? \"container\" : \"channel\",\n };\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"WriteSummaryTree\");\n\n const { url, headers } = getUrlAndHeadersWithAuth(`${this.snapshotUrl}/snapshot`, storageToken);\n headers[\"Content-Type\"] = \"application/json\";\n if (parentHandle) {\n headers[\"If-Match\"] = `fluid:containerid=${parentHandle}`;\n }\n\n const postBody = JSON.stringify(snapshot);\n\n return PerformanceEvent.timedExecAsync(this.logger,\n {\n eventName: \"uploadSummary\",\n attempt: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n blobs,\n size: postBody.length,\n },\n async () => {\n const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"uploadSummary\");\n return response.content;\n });\n });\n }\n\n /**\n * Following are the goals of this function.\n * a.) Converts the summary tree to a snapshot/odsp tree to be uploaded. Always upload full snapshot tree.\n * @param parentHandle - Handle of the last uploaded summary or detach new summary.\n * @param tree - Summary Tree which will be converted to snapshot tree to be uploaded.\n * @param rootNodeName - Root node name of the summary tree.\n * @param path - Current path of node which is getting evaluated.\n * @param markUnreferencedNodes - True if we should mark unreferenced nodes.\n */\n private async convertSummaryToSnapshotTree(\n parentHandle: string | undefined,\n tree: api.ISummaryTree,\n rootNodeName: string,\n path: string = \"\",\n markUnreferencedNodes: boolean = gatesMarkUnreferencedNodes(),\n ) {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [] as OdspSummaryTreeEntry[],\n };\n\n let blobs = 0;\n const keys = Object.keys(tree.tree);\n for (const key of keys) {\n const summaryObject = tree.tree[key];\n\n let id: string | undefined;\n let value: OdspSummaryTreeValue | undefined;\n\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is\n // true (which is the only value it can have), the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n const currentPath = path === \"\" ? `${rootNodeName}/${key}` : `${path}/${key}`;\n switch (summaryObject.type) {\n case api.SummaryType.Tree: {\n const result = await this.convertSummaryToSnapshotTree(\n parentHandle,\n summaryObject,\n rootNodeName,\n currentPath);\n value = result.snapshotTree;\n unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;\n blobs += result.blobs;\n break;\n }\n case api.SummaryType.Blob: {\n if (typeof summaryObject.content === \"string\") {\n value = {\n type: \"blob\",\n content: summaryObject.content,\n encoding: \"utf-8\",\n };\n } else {\n value = {\n type: \"blob\",\n content: Uint8ArrayToString(summaryObject.content, \"base64\"),\n encoding: \"base64\",\n };\n }\n blobs++;\n break;\n }\n case api.SummaryType.Handle: {\n if (!parentHandle) {\n throw Error(\"Parent summary does not exist to reference by handle.\");\n }\n let handlePath = summaryObject.handle;\n if (handlePath.length > 0 && !handlePath.startsWith(\"/\")) {\n handlePath = `/${handlePath}`;\n }\n const pathKey = `${rootNodeName}${handlePath}`;\n id = `${parentHandle}/${pathKey}`;\n break;\n }\n case api.SummaryType.Attachment: {\n id = summaryObject.id;\n break;\n }\n default: {\n unreachableCase(summaryObject, `Unknown type: ${(summaryObject as any).type}`);\n }\n }\n\n const baseEntry: IOdspSummaryTreeBaseEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n };\n\n let entry: OdspSummaryTreeEntry;\n\n if (value) {\n assert(id === undefined, 0x0ad /* \"Snapshot entry has both a tree value and a referenced id!\" */);\n entry = {\n value,\n ...baseEntry,\n unreferenced,\n };\n } else if (id) {\n entry = {\n ...baseEntry,\n id,\n };\n } else {\n throw new Error(`Invalid tree entry for ${summaryObject.type}`);\n }\n\n snapshotTree.entries!.push(entry);\n }\n\n return { snapshotTree, blobs };\n }\n}\n\n/* eslint-enable max-len */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"odspUtils.d.ts","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAClH,OAAO,EAAE,YAAY,EAAmB,MAAM,oCAAoC,CAAC;AAGnF,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAYhG,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EAIjB,6BAA6B,EAC7B,cAAc,EACd,YAAY,EACZ,WAAW,EAEX,+BAA+B,EAClC,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,iCAAiC,sCAAsC,CAAC;AAErF,4DAA4D;AAC5D,eAAO,MAAM,SAAS,QAAS,MAAM,WA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C;AAEX,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa;;;;;EAqBxD;AAED,wBAAgB,8BAA8B,CAC1C,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,gBAAgB,EAC7B,YAAY,EAAE,YAAY,CAAC,6BAA6B,CAAC,EACzD,gBAAgB,EAAE,OAAO,GAC1B,+BAA+B,CAyCjC;AAED,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,gBAAgB,GAAG,WAAW,CAUrF"}
package/dist/odspUtils.js CHANGED
@@ -199,7 +199,6 @@ function toInstrumentedOdspTokenFetcher(logger, resolvedUrl, tokenFetcher, throw
199
199
  return token;
200
200
  }, (error) => {
201
201
  const tokenError = telemetry_utils_1.wrapError(error, (errorMessage) => odsp_doclib_utils_1.createOdspNetworkError("tokenFetcherFailed", errorMessage, odsp_doclib_utils_1.fetchTokenErrorCode));
202
- // eslint-disable-next-line @typescript-eslint/no-throw-literal
203
202
  throw tokenError;
204
203
  }), { cancel: "generic" });
205
204
  };
@@ -1 +1 @@
1
- {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAAmF;AACnF,+DAAsE;AACtE,+DAAmE;AAEnE,qEAA2F;AAC3F,yEAS2C;AAC3C,qFAYiD;AACjD,mCAAgC;AAChC,qDAA8C;AAGjC,QAAA,iCAAiC,GAAG,mCAAmC,CAAC;AAErF,4DAA4D;AACrD,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AAAjD,QAAA,SAAS,aAAwC;AAqB9D,SAAS,YAAY,CAAC,OAAgB;IAClC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE;QAC1C,UAAU,CAAC,GAAG,CAAC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S,CACxB,KAAK,EACL,CAAC,YAAY,EAAE,EAAE,CAAC,0CAAsB,CAAC,oBAAoB,EAAE,YAAY,EAAE,uCAAmB,CAAC,CAAC,CAAC;YACvG,+DAA+D;YAC/D,MAAM,UAAU,CAAC;QACrB,CAAC,CAAC,EACF,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/B,CAAC,CAAC;AACN,CAAC;AA/CD,wEA+CC;AAED,SAAgB,sBAAsB,CAAC,eAAiC;IACpE,MAAM,UAAU,GAAgB;QAC5B,IAAI,EAAE,qCAAW;QACjB,GAAG,EAAE,EAAE;QACP,IAAI,EAAE;YACF,WAAW,EAAE,eAAe;YAC5B,KAAK,EAAE,eAAe,CAAC,gBAAgB;SAC1C;KACJ,CAAC;IACF,OAAO,UAAU,CAAC;AACtB,CAAC;AAVD,wDAUC","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 { isOnline, OnlineStatus } from \"@fluidframework/driver-utils\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { ChildLogger, PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n fetchIncorrectResponse,\n offlineFetchFailureStatusCode,\n fetchFailureStatusCode,\n fetchTimeoutStatusCode,\n throwOdspNetworkError,\n getSPOAndGraphRequestIdsFromResponse,\n fetchTokenErrorCode,\n createOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils\";\nimport {\n IOdspResolvedUrl,\n TokenFetchOptions,\n OdspErrorType,\n tokenFromResponse,\n isTokenFromCache,\n OdspResourceTokenFetchOptions,\n ShareLinkTypes,\n TokenFetcher,\n ICacheEntry,\n snapshotKey,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { fetch } from \"./fetch\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { IOdspSnapshot } from \"./contracts\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/** Parse the given url and return the origin (host name) */\nexport const getOrigin = (url: string) => new URL(url).origin;\n\nexport interface ISnapshotContents {\n snapshotTree: ISnapshotTree,\n blobs: Map<string, ArrayBuffer>,\n ops: ISequencedDocumentMessage[],\n sequenceNumber: number | undefined,\n}\n\nexport interface IOdspResponse<T> {\n content: T;\n headers: Map<string, string>;\n commonSpoHeaders: 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: // fetchIncorrectResponse - 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 throwOdspNetworkError(\"odspFetchErrorNoResponse\", fetchIncorrectResponse);\n }\n if (!response.ok || response.status < 200 || response.status >= 300) {\n throwOdspNetworkError(\n `odspFetchError [${response.status}]`, response.status, response, await response.text());\n }\n\n const headers = headersToMap(response.headers);\n return {\n content: response,\n headers,\n commonSpoHeaders: getSPOAndGraphRequestIdsFromResponse(headers),\n duration: performance.now() - start,\n };\n }, (error) => {\n // While we do not know for sure whether computer is offline, this error is not actionable and\n // is pretty good indicator we are offline. Treating it as offline scenario will make it\n // easier to see other errors in telemetry.\n let online = isOnline();\n const errorText = `${error}`;\n if (errorText === \"TypeError: Failed to fetch\") {\n online = OnlineStatus.Offline;\n }\n if (error.name === \"AbortError\") {\n throwOdspNetworkError(\"timeoutDuringFetch\", fetchTimeoutStatusCode);\n }\n if (errorText.indexOf(\"ETIMEDOUT\") !== -1) {\n throwOdspNetworkError(\"timeoutDuringFetch(ETIMEDOUT)\", fetchTimeoutStatusCode);\n }\n\n //\n // WARNING: Do not log error object itself or any of its properties!\n // It could container PII, like URI in message itself, or token in properties.\n // It is also non-serializable object due to circular references.\n //\n const failureCode = online === OnlineStatus.Offline ? offlineFetchFailureStatusCode : fetchFailureStatusCode;\n throwOdspNetworkError(\n `odspFetchThrewError [${failureCode}]`,\n failureCode,\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, commonSpoHeaders, duration } = await fetchHelper(requestInfo, requestInit);\n\n const arrayBuffer = await content.arrayBuffer();\n commonSpoHeaders.bodySize = arrayBuffer.byteLength;\n return {\n headers,\n content: arrayBuffer,\n commonSpoHeaders,\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, commonSpoHeaders, duration } = await fetchHelper(requestInfo, requestInit);\n // JSON.parse() can fail and message (that goes into telemetry) 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 try {\n const text = await content.text();\n\n commonSpoHeaders.bodySize = text.length;\n const res = {\n headers,\n content: JSON.parse(text),\n commonSpoHeaders,\n duration,\n };\n return res;\n } catch (e) {\n throwOdspNetworkError(\n \"errorWhileParsingFetchResponse\",\n fetchIncorrectResponse,\n content,\n undefined,\n { error: Object(e) },\n );\n }\n}\n\nexport interface INewFileInfo {\n siteUrl: string;\n driveId: string;\n filename: string;\n filePath: string;\n /**\n * application can request creation of a share link along with the creation of a new file\n * by passing in an optional param to specify the kind of sharing link\n * (at the time of adding this comment Sept/2021), odsp only supports csl\n */\n createLinkType?: ShareLinkTypes;\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n assert((resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true, 0x1de /* \"Not an ODSP resolved url\" */);\n return resolvedUrl as IOdspResolvedUrl;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger) =>\n ChildLogger.create(\n logger,\n \"OdspDriver\",\n { all :\n {\n driverVersion: pkgVersion,\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 resolvedUrl: IOdspResolvedUrl,\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 siteUrl: resolvedUrl.siteUrl,\n driveId: resolvedUrl.driveId,\n itemId: resolvedUrl.itemId,\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 throwOdspNetworkError(\"tokenIsNull\", fetchTokenErrorCode, undefined, undefined, { method: name });\n }\n return token;\n }, (error) => {\n const tokenError = wrapError(\n error,\n (errorMessage) => createOdspNetworkError(\"tokenFetcherFailed\", errorMessage, fetchTokenErrorCode));\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw tokenError;\n }),\n { cancel: \"generic\" });\n };\n}\n\nexport function createCacheSnapshotKey(odspResolvedUrl: IOdspResolvedUrl): ICacheEntry {\n const cacheEntry: ICacheEntry = {\n type: snapshotKey,\n key: \"\",\n file: {\n resolvedUrl: odspResolvedUrl,\n docId: odspResolvedUrl.hashedDocumentId,\n },\n };\n return cacheEntry;\n}\n"]}
1
+ {"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2EAAmF;AACnF,+DAAsE;AACtE,+DAAmE;AAEnE,qEAA2F;AAC3F,yEAS2C;AAC3C,qFAYiD;AACjD,mCAAgC;AAChC,qDAA8C;AAGjC,QAAA,iCAAiC,GAAG,mCAAmC,CAAC;AAErF,4DAA4D;AACrD,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AAAjD,QAAA,SAAS,aAAwC;AAqB9D,SAAS,YAAY,CAAC,OAAgB;IAClC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE;QAC1C,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;KAC9B;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,2BAA2B,CAAI,GAAiD;IAClG,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,OAAO,GAAwB,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;QACzE,QAAQ,CAAC,CAAC,SA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AAE,EAAE;QACP,IAAI,EAAE;YACF,WAAW,EAAE,eAAe;YAC5B,KAAK,EAAE,eAAe,CAAC,gBAAgB;SAC1C;KACJ,CAAC;IACF,OAAO,UAAU,CAAC;AACtB,CAAC;AAVD,wDAUC","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 { isOnline, OnlineStatus } from \"@fluidframework/driver-utils\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { ChildLogger, PerformanceEvent, wrapError } from \"@fluidframework/telemetry-utils\";\nimport {\n fetchIncorrectResponse,\n offlineFetchFailureStatusCode,\n fetchFailureStatusCode,\n fetchTimeoutStatusCode,\n throwOdspNetworkError,\n getSPOAndGraphRequestIdsFromResponse,\n fetchTokenErrorCode,\n createOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils\";\nimport {\n IOdspResolvedUrl,\n TokenFetchOptions,\n OdspErrorType,\n tokenFromResponse,\n isTokenFromCache,\n OdspResourceTokenFetchOptions,\n ShareLinkTypes,\n TokenFetcher,\n ICacheEntry,\n snapshotKey,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { fetch } from \"./fetch\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { IOdspSnapshot } from \"./contracts\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/** Parse the given url and return the origin (host name) */\nexport const getOrigin = (url: string) => new URL(url).origin;\n\nexport interface ISnapshotContents {\n snapshotTree: ISnapshotTree,\n blobs: Map<string, ArrayBuffer>,\n ops: ISequencedDocumentMessage[],\n sequenceNumber: number | undefined,\n}\n\nexport interface IOdspResponse<T> {\n content: T;\n headers: Map<string, string>;\n commonSpoHeaders: 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: // fetchIncorrectResponse - 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 throwOdspNetworkError(\"odspFetchErrorNoResponse\", fetchIncorrectResponse);\n }\n if (!response.ok || response.status < 200 || response.status >= 300) {\n throwOdspNetworkError(\n `odspFetchError [${response.status}]`, response.status, response, await response.text());\n }\n\n const headers = headersToMap(response.headers);\n return {\n content: response,\n headers,\n commonSpoHeaders: getSPOAndGraphRequestIdsFromResponse(headers),\n duration: performance.now() - start,\n };\n }, (error) => {\n // While we do not know for sure whether computer is offline, this error is not actionable and\n // is pretty good indicator we are offline. Treating it as offline scenario will make it\n // easier to see other errors in telemetry.\n let online = isOnline();\n const errorText = `${error}`;\n if (errorText === \"TypeError: Failed to fetch\") {\n online = OnlineStatus.Offline;\n }\n if (error.name === \"AbortError\") {\n throwOdspNetworkError(\"timeoutDuringFetch\", fetchTimeoutStatusCode);\n }\n if (errorText.indexOf(\"ETIMEDOUT\") !== -1) {\n throwOdspNetworkError(\"timeoutDuringFetch(ETIMEDOUT)\", fetchTimeoutStatusCode);\n }\n\n //\n // WARNING: Do not log error object itself or any of its properties!\n // It could container PII, like URI in message itself, or token in properties.\n // It is also non-serializable object due to circular references.\n //\n const failureCode = online === OnlineStatus.Offline ? offlineFetchFailureStatusCode : fetchFailureStatusCode;\n throwOdspNetworkError(\n `odspFetchThrewError [${failureCode}]`,\n failureCode,\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, commonSpoHeaders, duration } = await fetchHelper(requestInfo, requestInit);\n\n const arrayBuffer = await content.arrayBuffer();\n commonSpoHeaders.bodySize = arrayBuffer.byteLength;\n return {\n headers,\n content: arrayBuffer,\n commonSpoHeaders,\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, commonSpoHeaders, duration } = await fetchHelper(requestInfo, requestInit);\n // JSON.parse() can fail and message (that goes into telemetry) 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 try {\n const text = await content.text();\n\n commonSpoHeaders.bodySize = text.length;\n const res = {\n headers,\n content: JSON.parse(text),\n commonSpoHeaders,\n duration,\n };\n return res;\n } catch (e) {\n throwOdspNetworkError(\n \"errorWhileParsingFetchResponse\",\n fetchIncorrectResponse,\n content,\n undefined,\n { error: Object(e) },\n );\n }\n}\n\nexport interface INewFileInfo {\n siteUrl: string;\n driveId: string;\n filename: string;\n filePath: string;\n /**\n * application can request creation of a share link along with the creation of a new file\n * by passing in an optional param to specify the kind of sharing link\n * (at the time of adding this comment Sept/2021), odsp only supports csl\n */\n createLinkType?: ShareLinkTypes;\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n assert((resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true, 0x1de /* \"Not an ODSP resolved url\" */);\n return resolvedUrl as IOdspResolvedUrl;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger) =>\n ChildLogger.create(\n logger,\n \"OdspDriver\",\n { all :\n {\n driverVersion: pkgVersion,\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 resolvedUrl: IOdspResolvedUrl,\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 siteUrl: resolvedUrl.siteUrl,\n driveId: resolvedUrl.driveId,\n itemId: resolvedUrl.itemId,\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 throwOdspNetworkError(\"tokenIsNull\", fetchTokenErrorCode, undefined, undefined, { method: name });\n }\n return token;\n }, (error) => {\n const tokenError = wrapError(\n error,\n (errorMessage) => createOdspNetworkError(\"tokenFetcherFailed\", errorMessage, fetchTokenErrorCode));\n throw tokenError;\n }),\n { cancel: \"generic\" });\n };\n}\n\nexport function createCacheSnapshotKey(odspResolvedUrl: IOdspResolvedUrl): ICacheEntry {\n const cacheEntry: ICacheEntry = {\n type: snapshotKey,\n key: \"\",\n file: {\n resolvedUrl: odspResolvedUrl,\n docId: odspResolvedUrl.hashedDocumentId,\n },\n };\n return cacheEntry;\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/odsp-driver";
8
- export declare const pkgVersion = "0.51.0";
8
+ export declare const pkgVersion = "0.52.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 = "0.51.0";
11
+ exports.pkgVersion = "0.52.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 = \"0.51.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 = \"0.52.0\";\n"]}
@@ -421,7 +421,6 @@ function throwBufferParseException(node, expectedNodeType, message) {
421
421
  nodeType: getNodeType(node),
422
422
  expectedNodeType,
423
423
  });
424
- // eslint-disable-next-line @typescript-eslint/no-throw-literal
425
424
  throw error;
426
425
  }
427
426
  function getNodeType(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;EAGE;AAEF,+DAA8G;AAC9G,yEAAmG;AAGnG,mCAAmC;AACnC,wJAAwJ;AACxJ;;;GAGG;AACH,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,iDAAU,CAAA;IACV,6CAAQ,CAAA;IACR,+CAAS,CAAA;IACT,+CAAS,CAAA;IACT,+CAAS,CAAA;IAET,4DAAgB,CAAA;IAChB,gEAAkB,CAAA;IAClB,kEAAmB,CAAA;IACnB,kEAAmB,CAAA;IACnB,kEAAmB,CAAA;AACvB,CAAC,EA9BW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA8BtB;AAED;;GAEG;AACH,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,wDAAW,CAAA;IACX,sDAAU,CAAA;AACd,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B;AAED;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,oDAAW,CAAA;IACX,kDAAU,CAAA;AACd,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB;AAED;;;EAGE;AACW,QAAA,cAAc,GAAG;IAC1B,wBAAwB;IACxB,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ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E,OAAO,CAAC,CAAC;AACvD,CAAC;AARD,oDAQC;AAED,SAAgB,kBAAkB,CAC9B,IAAe,EACf,OAAe;IAEf,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE;QAC3B,OAAO;KACV;IACD,yBAAyB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AARD,gDAQC;AAED,SAAS,yBAAyB,CAC9B,IAAe,EACf,gBAA0B,EAC1B,OAAe;IAEf,MAAM,KAAK,GAAG,0CAAsB,CAChC,wBAAwB,EACxB,OAAO,EACP,0CAAsB,EACtB,SAAS,EACT,SAAS,EACT,SAAS,EACT;QACI,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC;QAC3B,gBAAgB;KACnB,CAAC,CAAC;IACP,+DAA+D;IAC/D,MAAM,KAAK,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,KAAgB;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,QAAQ,CAAC;KACnB;SAAM,IAAG,KAAK,YAAY,QAAQ,EAAE;QACjC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QACnC,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n*/\n\nimport { assert, IsoBuffer, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { createOdspNetworkError, fetchIncorrectResponse } from \"@fluidframework/odsp-doclib-utils\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\n\n// eslint-disable-next-line max-len\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n BoolTrue = 11, // value = true\n BoolFalse = 12, // value = false\n\n StringEmpty = 13, // value = \"\"\n String8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n String16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n String32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n ConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n ConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n ConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n ConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n ConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n Int0 = 1, // value = 0\n UInt8 = 3, // unsigned-8-bit little-endian follows\n UInt16 = 5, // unsigned-16-bit little-endian follows\n UInt32 = 7, // unsigned-32-bit little-endian follows\n UInt64 = 9, // unsigned-64-bit little-endian follows\n Int8 = 2, // signed-8-bit little-endian follows\n Int16 = 4, // signed-16-bit little-endian follows\n Int32 = 6, // signed-32-bit little-endian follows\n Int64 = 8, // signed-64-bit little-endian follows\n\n BinaryEmpty = 32, // value = byte[]\n BinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n BinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n BinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n BinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n \"list\" = 49,\n \"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n \"list\" = 50,\n \"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n*/\nexport const codeToBytesMap = {\n // Integer code to bytes\n 1: 0,\n 2: 1,\n 3: 1,\n 4: 2,\n 5: 2,\n 6: 4,\n 7: 4,\n 8: 8,\n 9: 8,\n\n // String code to Bytes\n 13: 0,\n 14: 1,\n 15: 2,\n 16: 4,\n\n 17: 1,\n 18: 2,\n 19: 4,\n\n 20: 1,\n 21: 4,\n\n // Binary code to bytes\n 32: 0,\n 33: 1,\n 34: 2,\n 35: 4,\n 36: 8,\n};\n\nexport function getValueSafely(map: {[index: number]: number}, key: number) {\n const val = map[key];\n assert(val !== undefined, 0x287 /* `key= ${key} must exist in the map` */);\n return val;\n}\n\nexport function getAndValidateNodeProps(node: NodeCore, props: string[], enforceAllProps = true) {\n const propSet = new Set(props);\n const res: Record<string, NodeTypes> = {};\n for (const [keyNode, valueNode] of node.iteratePairs()) {\n assertBlobCoreInstance(keyNode, \"keynode should be a blob\");\n const keyStr = keyNode.toString();\n if (propSet.has(keyStr)) {\n propSet.delete(keyStr);\n res[keyStr] = valueNode;\n }\n }\n if (enforceAllProps) {\n assert(propSet.size === 0, 0x288 /* `All properties should exist, Not found: ${[...propSet.keys()]}` */);\n }\n return res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>) {\n const res: IterableIterator<[T, T]> = {\n next: () => {\n const a = it.next();\n if (a.done) {\n return { value: undefined, done: true };\n }\n const b = it.next();\n assert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n return { value: [a.value, b.value], done: b.done };\n },\n [Symbol.iterator]: () => { return res; },\n };\n return res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: {[Symbol.iterator]: () => IterableIterator<T>}) {\n return obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n public abstract get buffer(): Uint8Array;\n public get arrayBuffer(): ArrayBufferLike {\n return Uint8ArrayToArrayBuffer(this.buffer);\n }\n\n /**\n * Represents a blob.\n * @param constString - Whether it contains const string declaration.\n * @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.\n */\n constructor(public readonly constString: boolean, public readonly useUtf8Code: boolean = false) {}\n\n public toString() {\n return Uint8ArrayToString(this.buffer, \"utf-8\");\n }\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n*/\nclass BlobDeepCopy extends BlobCore {\n /**\n * Represents a deep copy of the blob.\n * @param data - Data array of the blob\n * @param constString - Whether it contains const string declaration.\n * @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.\n */\n constructor(protected readonly data: Uint8Array, constString: boolean, useUtf8Code: boolean = false) {\n super(constString, useUtf8Code);\n }\n\n public get buffer() {\n return this.data;\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number, constString: boolean): BlobCore {\n const length = buffer.read(lengthLen);\n const data = new Uint8Array(length);\n for (let counter = 0; counter < length; counter++) {\n data[counter] = buffer.read();\n }\n return new BlobDeepCopy(data, constString);\n }\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\n export class BlobShallowCopy extends BlobCore {\n /**\n * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n * @param data - Data array of the blob\n * @param start - Start point of the blob in the buffer.\n * @param end - End point of the blob in the buffer.\n * @param constString - Whether it contains const string declaration.\n */\n constructor(\n protected data: ReadBuffer,\n protected start: number,\n protected end: number,\n constString: boolean,\n ) {\n super(constString);\n }\n\n public get buffer() {\n return this.data.buffer.subarray(this.start, this.end);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number, constString: boolean): BlobCore {\n const length = buffer.read(lengthLen);\n const pos = buffer.pos;\n buffer.skip(length);\n return new BlobShallowCopy(buffer, pos, pos + length, constString);\n }\n}\n\nexport const addStringProperty = (node: NodeCore, a: string, b: string, encodeValAsConstString: boolean = false) =>\n { node.addString(a, true); node.addString(b, encodeValAsConstString); };\nexport const addNumberProperty = (node: NodeCore, a: string, b: number) =>\n { node.addString(a, true); node.addNumber(b); };\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean) =>\n { node.addString(a, true); node.addBool(b); };\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n // It is an array of nodes.\n private readonly children: NodeTypes[] = [];\n public get nodes() {\n return this.children;\n }\n\n constructor(public type: NodeCoreTypes = \"set\") {}\n\n public [Symbol.iterator]() {\n return this.children[Symbol.iterator]();\n }\n\n public iteratePairs() {\n assert((this.length % 2) === 0, 0x22c /* \"reading pairs\" */);\n return iteratePairs(iterate(this));\n }\n\n public get length() { return this.children.length; }\n\n public get(index: number) { return this.children[index]; }\n\n public getString(index: number): string {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getString should return stringblob\");\n return node.toString();\n }\n\n public getBlob(index: number): BlobCore {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getBlob should return a blob\");\n return node;\n }\n\n public getNode(index: number): NodeCore\n {\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 {\n const node = this.children[index];\n assertNumberInstance(node, \"getNumber should return a number\");\n return node;\n }\n\n public getBool(index: number): boolean {\n const node = this.children[index];\n assertBoolInstance(node, \"getBool should return a boolean\");\n return node;\n }\n\n public addNode(type?: NodeCoreTypes): NodeCore {\n const node = new NodeCore(type);\n this.children.push(node);\n return node;\n }\n\n public addBlob(blob: Uint8Array, constString: boolean, useUtf8Code: boolean = false) {\n this.children.push(new BlobDeepCopy(blob, constString, useUtf8Code));\n }\n\n public addString(payload: string, constString: boolean) {\n this.addBlob(IsoBuffer.from(payload, \"utf-8\"), constString, true);\n }\n\n public addNumber(payload: number | undefined) {\n assert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n assert(payload !== undefined && payload >= 0, 0x232 /* \"Payload should not be negative\" */);\n this.children.push(payload);\n }\n\n public addBool(payload: boolean) {\n this.children.push(payload);\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected load(buffer: ReadBuffer, dictionary: BlobCore[]) {\n for (;!buffer.eof;) {\n let childValue: NodeTypes | undefined;\n const code = buffer.read();\n switch (code) {\n case MarkerCodesStart.list:\n case MarkerCodesStart.set: {\n childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n this.children.push(childValue);\n childValue.load(buffer, dictionary);\n break;\n }\n case MarkerCodes.ConstStringDeclare:\n case MarkerCodes.ConstStringDeclareBig:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const constString = BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code), true);\n dictionary[stringId] = constString;\n break;\n }\n case MarkerCodes.ConstString8Id:\n case MarkerCodes.ConstString16Id:\n case MarkerCodes.ConstString32Id:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n childValue = dictionary[stringId];\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.StringEmpty:\n case MarkerCodes.String8Length:\n case MarkerCodes.String16Length:\n case MarkerCodes.String32Length:\n case MarkerCodes.BinaryEmpty:\n case MarkerCodes.BinarySingle8:\n case MarkerCodes.BinarySingle16:\n case MarkerCodes.BinarySingle32:\n case MarkerCodes.BinarySingle64:\n {\n childValue = BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code), false);\n this.children.push(childValue);\n break;\n }\n // If integer is 0.\n case MarkerCodes.Int0:\n {\n childValue = 0;\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.UInt8:\n case MarkerCodes.UInt16:\n case MarkerCodes.UInt32:\n case MarkerCodes.UInt64:\n case MarkerCodes.Int8:\n case MarkerCodes.Int16:\n case MarkerCodes.Int32:\n case MarkerCodes.Int64:\n {\n childValue = buffer.read(getValueSafely(codeToBytesMap, code));\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.BoolTrue:\n this.children.push(true);\n break;\n case MarkerCodes.BoolFalse:\n this.children.push(false);\n break;\n case MarkerCodesEnd.list:\n case MarkerCodesEnd.set:\n return;\n default:\n throw new Error(`Invalid code: ${code}`);\n }\n }\n }\n}\n\n /**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n static load(buffer: ReadBuffer): TreeBuilder {\n const builder = new TreeBuilder();\n const dictionary = new Array<BlobCore>();\n builder.load(buffer, dictionary);\n assert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n return builder;\n }\n}\n\nexport function assertBlobCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is BlobCore {\n if (node instanceof BlobCore) {\n return;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is NodeCore {\n if (node instanceof NodeCore) {\n return;\n }\n throwBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n node: NodeTypes,\n message: string,\n): asserts node is number {\n if (typeof node === \"number\") {\n return;\n }\n throwBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(\n node: NodeTypes,\n message: string,\n): asserts node is boolean {\n if (typeof node === \"boolean\") {\n return;\n }\n throwBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n node: NodeTypes,\n expectedNodeType: NodeType,\n message: string,\n): never {\n const error = createOdspNetworkError(\n \"bufferParsingException\",\n message,\n fetchIncorrectResponse,\n undefined,\n undefined,\n undefined,\n {\n nodeType: getNodeType(node),\n expectedNodeType,\n });\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw error;\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n if (typeof value === \"number\") {\n return \"Number\";\n } else if(value instanceof BlobCore) {\n return \"BlobCore\";\n } else if (value instanceof NodeCore) {\n return \"NodeCore\";\n } else if (typeof value === \"boolean\") {\n return \"Boolean\";\n }\n return \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\";\n"]}
1
+ {"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;EAGE;AAEF,+DAA8G;AAC9G,yEAAmG;AAGnG,mCAAmC;AACnC,wJAAwJ;AACxJ;;;GAGG;AACH,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,iDAAU,CAAA;IACV,6CAAQ,CAAA;IACR,+CAAS,CAAA;IACT,+CAAS,CAAA;IACT,+CAAS,CAAA;IAET,4DAAgB,CAAA;IAChB,gEAAkB,CAAA;IAClB,kEAAmB,CAAA;IACnB,kEAAmB,CAAA;IACnB,kEAAmB,CAAA;AACvB,CAAC,EA9BW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA8BtB;AAED;;GAEG;AACH,IAA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O,SAAS,CAAC;KACpB;IACD,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n*/\n\nimport { assert, IsoBuffer, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { createOdspNetworkError, fetchIncorrectResponse } from \"@fluidframework/odsp-doclib-utils\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\n\n// eslint-disable-next-line max-len\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n BoolTrue = 11, // value = true\n BoolFalse = 12, // value = false\n\n StringEmpty = 13, // value = \"\"\n String8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n String16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n String32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n ConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n ConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n ConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n ConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n ConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n Int0 = 1, // value = 0\n UInt8 = 3, // unsigned-8-bit little-endian follows\n UInt16 = 5, // unsigned-16-bit little-endian follows\n UInt32 = 7, // unsigned-32-bit little-endian follows\n UInt64 = 9, // unsigned-64-bit little-endian follows\n Int8 = 2, // signed-8-bit little-endian follows\n Int16 = 4, // signed-16-bit little-endian follows\n Int32 = 6, // signed-32-bit little-endian follows\n Int64 = 8, // signed-64-bit little-endian follows\n\n BinaryEmpty = 32, // value = byte[]\n BinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n BinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n BinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n BinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n \"list\" = 49,\n \"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n \"list\" = 50,\n \"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n*/\nexport const codeToBytesMap = {\n // Integer code to bytes\n 1: 0,\n 2: 1,\n 3: 1,\n 4: 2,\n 5: 2,\n 6: 4,\n 7: 4,\n 8: 8,\n 9: 8,\n\n // String code to Bytes\n 13: 0,\n 14: 1,\n 15: 2,\n 16: 4,\n\n 17: 1,\n 18: 2,\n 19: 4,\n\n 20: 1,\n 21: 4,\n\n // Binary code to bytes\n 32: 0,\n 33: 1,\n 34: 2,\n 35: 4,\n 36: 8,\n};\n\nexport function getValueSafely(map: {[index: number]: number}, key: number) {\n const val = map[key];\n assert(val !== undefined, 0x287 /* `key= ${key} must exist in the map` */);\n return val;\n}\n\nexport function getAndValidateNodeProps(node: NodeCore, props: string[], enforceAllProps = true) {\n const propSet = new Set(props);\n const res: Record<string, NodeTypes> = {};\n for (const [keyNode, valueNode] of node.iteratePairs()) {\n assertBlobCoreInstance(keyNode, \"keynode should be a blob\");\n const keyStr = keyNode.toString();\n if (propSet.has(keyStr)) {\n propSet.delete(keyStr);\n res[keyStr] = valueNode;\n }\n }\n if (enforceAllProps) {\n assert(propSet.size === 0, 0x288 /* `All properties should exist, Not found: ${[...propSet.keys()]}` */);\n }\n return res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>) {\n const res: IterableIterator<[T, T]> = {\n next: () => {\n const a = it.next();\n if (a.done) {\n return { value: undefined, done: true };\n }\n const b = it.next();\n assert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n return { value: [a.value, b.value], done: b.done };\n },\n [Symbol.iterator]: () => { return res; },\n };\n return res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: {[Symbol.iterator]: () => IterableIterator<T>}) {\n return obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n public abstract get buffer(): Uint8Array;\n public get arrayBuffer(): ArrayBufferLike {\n return Uint8ArrayToArrayBuffer(this.buffer);\n }\n\n /**\n * Represents a blob.\n * @param constString - Whether it contains const string declaration.\n * @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.\n */\n constructor(public readonly constString: boolean, public readonly useUtf8Code: boolean = false) {}\n\n public toString() {\n return Uint8ArrayToString(this.buffer, \"utf-8\");\n }\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n*/\nclass BlobDeepCopy extends BlobCore {\n /**\n * Represents a deep copy of the blob.\n * @param data - Data array of the blob\n * @param constString - Whether it contains const string declaration.\n * @param useUtf8Code - Represents if the utf8 string marker code should be used when representing.\n */\n constructor(protected readonly data: Uint8Array, constString: boolean, useUtf8Code: boolean = false) {\n super(constString, useUtf8Code);\n }\n\n public get buffer() {\n return this.data;\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number, constString: boolean): BlobCore {\n const length = buffer.read(lengthLen);\n const data = new Uint8Array(length);\n for (let counter = 0; counter < length; counter++) {\n data[counter] = buffer.read();\n }\n return new BlobDeepCopy(data, constString);\n }\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\n export class BlobShallowCopy extends BlobCore {\n /**\n * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n * @param data - Data array of the blob\n * @param start - Start point of the blob in the buffer.\n * @param end - End point of the blob in the buffer.\n * @param constString - Whether it contains const string declaration.\n */\n constructor(\n protected data: ReadBuffer,\n protected start: number,\n protected end: number,\n constString: boolean,\n ) {\n super(constString);\n }\n\n public get buffer() {\n return this.data.buffer.subarray(this.start, this.end);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number, constString: boolean): BlobCore {\n const length = buffer.read(lengthLen);\n const pos = buffer.pos;\n buffer.skip(length);\n return new BlobShallowCopy(buffer, pos, pos + length, constString);\n }\n}\n\nexport const addStringProperty = (node: NodeCore, a: string, b: string, encodeValAsConstString: boolean = false) =>\n { node.addString(a, true); node.addString(b, encodeValAsConstString); };\nexport const addNumberProperty = (node: NodeCore, a: string, b: number) =>\n { node.addString(a, true); node.addNumber(b); };\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean) =>\n { node.addString(a, true); node.addBool(b); };\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n // It is an array of nodes.\n private readonly children: NodeTypes[] = [];\n public get nodes() {\n return this.children;\n }\n\n constructor(public type: NodeCoreTypes = \"set\") {}\n\n public [Symbol.iterator]() {\n return this.children[Symbol.iterator]();\n }\n\n public iteratePairs() {\n assert((this.length % 2) === 0, 0x22c /* \"reading pairs\" */);\n return iteratePairs(iterate(this));\n }\n\n public get length() { return this.children.length; }\n\n public get(index: number) { return this.children[index]; }\n\n public getString(index: number): string {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getString should return stringblob\");\n return node.toString();\n }\n\n public getBlob(index: number): BlobCore {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getBlob should return a blob\");\n return node;\n }\n\n public getNode(index: number): NodeCore\n {\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 {\n const node = this.children[index];\n assertNumberInstance(node, \"getNumber should return a number\");\n return node;\n }\n\n public getBool(index: number): boolean {\n const node = this.children[index];\n assertBoolInstance(node, \"getBool should return a boolean\");\n return node;\n }\n\n public addNode(type?: NodeCoreTypes): NodeCore {\n const node = new NodeCore(type);\n this.children.push(node);\n return node;\n }\n\n public addBlob(blob: Uint8Array, constString: boolean, useUtf8Code: boolean = false) {\n this.children.push(new BlobDeepCopy(blob, constString, useUtf8Code));\n }\n\n public addString(payload: string, constString: boolean) {\n this.addBlob(IsoBuffer.from(payload, \"utf-8\"), constString, true);\n }\n\n public addNumber(payload: number | undefined) {\n assert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n assert(payload !== undefined && payload >= 0, 0x232 /* \"Payload should not be negative\" */);\n this.children.push(payload);\n }\n\n public addBool(payload: boolean) {\n this.children.push(payload);\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected load(buffer: ReadBuffer, dictionary: BlobCore[]) {\n for (;!buffer.eof;) {\n let childValue: NodeTypes | undefined;\n const code = buffer.read();\n switch (code) {\n case MarkerCodesStart.list:\n case MarkerCodesStart.set: {\n childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n this.children.push(childValue);\n childValue.load(buffer, dictionary);\n break;\n }\n case MarkerCodes.ConstStringDeclare:\n case MarkerCodes.ConstStringDeclareBig:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const constString = BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code), true);\n dictionary[stringId] = constString;\n break;\n }\n case MarkerCodes.ConstString8Id:\n case MarkerCodes.ConstString16Id:\n case MarkerCodes.ConstString32Id:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n childValue = dictionary[stringId];\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.StringEmpty:\n case MarkerCodes.String8Length:\n case MarkerCodes.String16Length:\n case MarkerCodes.String32Length:\n case MarkerCodes.BinaryEmpty:\n case MarkerCodes.BinarySingle8:\n case MarkerCodes.BinarySingle16:\n case MarkerCodes.BinarySingle32:\n case MarkerCodes.BinarySingle64:\n {\n childValue = BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code), false);\n this.children.push(childValue);\n break;\n }\n // If integer is 0.\n case MarkerCodes.Int0:\n {\n childValue = 0;\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.UInt8:\n case MarkerCodes.UInt16:\n case MarkerCodes.UInt32:\n case MarkerCodes.UInt64:\n case MarkerCodes.Int8:\n case MarkerCodes.Int16:\n case MarkerCodes.Int32:\n case MarkerCodes.Int64:\n {\n childValue = buffer.read(getValueSafely(codeToBytesMap, code));\n this.children.push(childValue);\n break;\n }\n case MarkerCodes.BoolTrue:\n this.children.push(true);\n break;\n case MarkerCodes.BoolFalse:\n this.children.push(false);\n break;\n case MarkerCodesEnd.list:\n case MarkerCodesEnd.set:\n return;\n default:\n throw new Error(`Invalid code: ${code}`);\n }\n }\n }\n}\n\n /**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n static load(buffer: ReadBuffer): TreeBuilder {\n const builder = new TreeBuilder();\n const dictionary = new Array<BlobCore>();\n builder.load(buffer, dictionary);\n assert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n return builder;\n }\n}\n\nexport function assertBlobCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is BlobCore {\n if (node instanceof BlobCore) {\n return;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is NodeCore {\n if (node instanceof NodeCore) {\n return;\n }\n throwBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n node: NodeTypes,\n message: string,\n): asserts node is number {\n if (typeof node === \"number\") {\n return;\n }\n throwBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(\n node: NodeTypes,\n message: string,\n): asserts node is boolean {\n if (typeof node === \"boolean\") {\n return;\n }\n throwBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n node: NodeTypes,\n expectedNodeType: NodeType,\n message: string,\n): never {\n const error = createOdspNetworkError(\n \"bufferParsingException\",\n message,\n fetchIncorrectResponse,\n undefined,\n undefined,\n undefined,\n {\n nodeType: getNodeType(node),\n expectedNodeType,\n });\n throw error;\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n if (typeof value === \"number\") {\n return \"Number\";\n } else if(value instanceof BlobCore) {\n return \"BlobCore\";\n } else if (value instanceof NodeCore) {\n return \"NodeCore\";\n } else if (typeof value === \"boolean\") {\n return \"Boolean\";\n }\n return \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\";\n"]}
@@ -3,10 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { IOdspUrlParts } from "@fluidframework/odsp-driver-definitions";
6
- /**
7
- * @deprecated - use OdspFluidDataStoreLocator
8
- */
9
- export declare type OdspDocumentInfo = OdspFluidDataStoreLocator;
10
6
  export interface OdspFluidDataStoreLocator extends IOdspUrlParts {
11
7
  dataStorePath: string;
12
8
  appName?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"contractsPublic.d.ts","sourceRoot":"","sources":["../src/contractsPublic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE;;GAEG;AACH,oBAAY,gBAAgB,GAAG,yBAAyB,CAAC;AAEzD,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,oBAAY,iBAAiB;IAGzB,qBAAqB,0BAA0B;CAClD;AAED,MAAM,WAAW,kBAAkB;IAC/B,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACtD;AAED,OAAO,QAAQ,iCAAiC,CAAC;IAE7C,UAAiB,cAAe,SAAQ,OAAO,CAAC,kBAAkB,CAAC;KAAI;CAC1E"}
1
+ {"version":3,"file":"contractsPublic.d.ts","sourceRoot":"","sources":["../src/contractsPublic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,oBAAY,iBAAiB;IAGzB,qBAAqB,0BAA0B;CAClD;AAED,MAAM,WAAW,kBAAkB;IAC/B,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACtD;AAED,OAAO,QAAQ,iCAAiC,CAAC;IAE7C,UAAiB,cAAe,SAAQ,OAAO,CAAC,kBAAkB,CAAC;KAAI;CAC1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"contractsPublic.js","sourceRoot":"","sources":["../src/contractsPublic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,yGAAyG;IACzG,sDAAsD;IACtD,oEAA+C,CAAA;AACnD,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions\";\n\n/**\n * @deprecated - use OdspFluidDataStoreLocator\n */\nexport type OdspDocumentInfo = OdspFluidDataStoreLocator;\n\nexport interface OdspFluidDataStoreLocator extends IOdspUrlParts {\n dataStorePath: string;\n appName?: string;\n containerPackageName?: string;\n fileVersion?: string;\n}\n\nexport enum SharingLinkHeader {\n // Can be used in request made to resolver, to tell the resolver that the passed in URL is a sharing link\n // which can be redeemed at server to get permissions.\n isSharingLinkToRedeem = \"isSharingLinkToRedeem\",\n}\n\nexport interface ISharingLinkHeader {\n [SharingLinkHeader.isSharingLinkToRedeem]: boolean;\n}\n\ndeclare module \"@fluidframework/core-interfaces\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface IRequestHeader extends Partial<ISharingLinkHeader> { }\n}\n"]}
1
+ {"version":3,"file":"contractsPublic.js","sourceRoot":"","sources":["../src/contractsPublic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,yGAAyG;IACzG,sDAAsD;IACtD,oEAA+C,CAAA;AACnD,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions\";\n\nexport interface OdspFluidDataStoreLocator extends IOdspUrlParts {\n dataStorePath: string;\n appName?: string;\n containerPackageName?: string;\n fileVersion?: string;\n}\n\nexport enum SharingLinkHeader {\n // Can be used in request made to resolver, to tell the resolver that the passed in URL is a sharing link\n // which can be redeemed at server to get permissions.\n isSharingLinkToRedeem = \"isSharingLinkToRedeem\",\n}\n\nexport interface ISharingLinkHeader {\n [SharingLinkHeader.isSharingLinkToRedeem]: boolean;\n}\n\ndeclare module \"@fluidframework/core-interfaces\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface IRequestHeader extends Partial<ISharingLinkHeader> { }\n}\n"]}
package/lib/createFile.js CHANGED
@@ -6,6 +6,7 @@ import { assert, Uint8ArrayToString } from "@fluidframework/common-utils";
6
6
  import { getDocAttributesFromProtocolSummary } from "@fluidframework/driver-utils";
7
7
  import { fetchIncorrectResponse, invalidFileNameStatusCode, throwOdspNetworkError, } from "@fluidframework/odsp-doclib-utils";
8
8
  import { getGitType } from "@fluidframework/protocol-base";
9
+ import { SummaryType } from "@fluidframework/protocol-definitions";
9
10
  import { PerformanceEvent } from "@fluidframework/telemetry-utils";
10
11
  import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
11
12
  import { createCacheSnapshotKey, getWithRetryForTokenRefresh, getOrigin, } from "./odspUtils";
@@ -124,12 +125,12 @@ function convertSummaryIntoContainerSnapshot(createNewSummary) {
124
125
  }
125
126
  const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
126
127
  const attributesSummaryBlob = {
127
- type: 2 /* Blob */,
128
+ type: SummaryType.Blob,
128
129
  content: JSON.stringify(documentAttributes),
129
130
  };
130
131
  protocolSummary.tree.attributes = attributesSummaryBlob;
131
132
  const convertedCreateNewSummary = {
132
- type: 1 /* Tree */,
133
+ type: SummaryType.Tree,
133
134
  tree: {
134
135
  ".protocol": protocolSummary,
135
136
  ".app": appSummary,
@@ -162,12 +163,12 @@ export function convertSummaryToSnapshotTreeForCreateNew(summary) {
162
163
  // the tree entry is considered unreferenced.
163
164
  let unreferenced;
164
165
  switch (summaryObject.type) {
165
- case 1 /* Tree */: {
166
+ case SummaryType.Tree: {
166
167
  value = convertSummaryToSnapshotTreeForCreateNew(summaryObject);
167
168
  unreferenced = summaryObject.unreferenced;
168
169
  break;
169
170
  }
170
- case 2 /* Blob */: {
171
+ case SummaryType.Blob: {
171
172
  const content = typeof summaryObject.content === "string" ?
172
173
  summaryObject.content : Uint8ArrayToString(summaryObject.content, "base64");
173
174
  const encoding = typeof summaryObject.content === "string" ? "utf-8" : "base64";
@@ -178,7 +179,7 @@ export function convertSummaryToSnapshotTreeForCreateNew(summary) {
178
179
  };
179
180
  break;
180
181
  }
181
- case 3 /* Handle */: {
182
+ case SummaryType.Handle: {
182
183
  throw new Error("No handle should be present for first summary!!");
183
184
  }
184
185
  default: {