@fluidframework/runtime-utils 2.53.1 → 2.61.0-355054

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 (137) hide show
  1. package/.eslintrc.cjs +1 -4
  2. package/.mocharc.cjs +1 -2
  3. package/CHANGELOG.md +4 -0
  4. package/api-report/{runtime-utils.legacy.alpha.api.md → runtime-utils.legacy.beta.api.md} +12 -12
  5. package/dist/compatibilityBase.d.ts +1 -3
  6. package/dist/compatibilityBase.d.ts.map +1 -1
  7. package/dist/compatibilityBase.js +3 -0
  8. package/dist/compatibilityBase.js.map +1 -1
  9. package/dist/dataStoreHandleContextUtils.d.ts +1 -1
  10. package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
  11. package/dist/dataStoreHandleContextUtils.js.map +1 -1
  12. package/dist/dataStoreHelpers.d.ts +18 -6
  13. package/dist/dataStoreHelpers.d.ts.map +1 -1
  14. package/dist/dataStoreHelpers.js +43 -15
  15. package/dist/dataStoreHelpers.js.map +1 -1
  16. package/dist/deltaManager.d.ts +1 -2
  17. package/dist/deltaManager.d.ts.map +1 -1
  18. package/dist/deltaManager.js +3 -2
  19. package/dist/deltaManager.js.map +1 -1
  20. package/dist/handles.d.ts +8 -12
  21. package/dist/handles.d.ts.map +1 -1
  22. package/dist/handles.js +14 -12
  23. package/dist/handles.js.map +1 -1
  24. package/dist/index.d.ts +6 -3
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/legacy.d.ts +4 -2
  28. package/dist/objectstoragepartition.d.ts +1 -1
  29. package/dist/objectstoragepartition.d.ts.map +1 -1
  30. package/dist/objectstoragepartition.js.map +1 -1
  31. package/dist/objectstorageutils.d.ts +9 -1
  32. package/dist/objectstorageutils.d.ts.map +1 -1
  33. package/dist/objectstorageutils.js +15 -6
  34. package/dist/objectstorageutils.js.map +1 -1
  35. package/dist/packageVersion.d.ts +1 -1
  36. package/dist/packageVersion.d.ts.map +1 -1
  37. package/dist/packageVersion.js +1 -1
  38. package/dist/packageVersion.js.map +1 -1
  39. package/dist/public.d.ts +2 -1
  40. package/dist/remoteFluidObjectHandle.d.ts +2 -2
  41. package/dist/remoteFluidObjectHandle.d.ts.map +1 -1
  42. package/dist/remoteFluidObjectHandle.js +1 -0
  43. package/dist/remoteFluidObjectHandle.js.map +1 -1
  44. package/dist/requestParser.d.ts +2 -3
  45. package/dist/requestParser.d.ts.map +1 -1
  46. package/dist/requestParser.js +9 -11
  47. package/dist/requestParser.js.map +1 -1
  48. package/dist/runtimeFactoryHelper.d.ts +3 -4
  49. package/dist/runtimeFactoryHelper.d.ts.map +1 -1
  50. package/dist/runtimeFactoryHelper.js +1 -2
  51. package/dist/runtimeFactoryHelper.js.map +1 -1
  52. package/dist/summaryUtils.d.ts +29 -20
  53. package/dist/summaryUtils.d.ts.map +1 -1
  54. package/dist/summaryUtils.js +49 -21
  55. package/dist/summaryUtils.js.map +1 -1
  56. package/dist/unpackUsedRoutes.d.ts.map +1 -1
  57. package/dist/unpackUsedRoutes.js +3 -3
  58. package/dist/unpackUsedRoutes.js.map +1 -1
  59. package/dist/utils.d.ts +1 -1
  60. package/dist/utils.d.ts.map +1 -1
  61. package/dist/utils.js.map +1 -1
  62. package/internal.d.ts +1 -1
  63. package/legacy.d.ts +1 -1
  64. package/lib/compatibilityBase.d.ts +1 -3
  65. package/lib/compatibilityBase.d.ts.map +1 -1
  66. package/lib/compatibilityBase.js +3 -0
  67. package/lib/compatibilityBase.js.map +1 -1
  68. package/lib/dataStoreHandleContextUtils.d.ts +1 -1
  69. package/lib/dataStoreHandleContextUtils.d.ts.map +1 -1
  70. package/lib/dataStoreHandleContextUtils.js.map +1 -1
  71. package/lib/dataStoreHelpers.d.ts +18 -6
  72. package/lib/dataStoreHelpers.d.ts.map +1 -1
  73. package/lib/dataStoreHelpers.js +43 -15
  74. package/lib/dataStoreHelpers.js.map +1 -1
  75. package/lib/deltaManager.d.ts +1 -2
  76. package/lib/deltaManager.d.ts.map +1 -1
  77. package/lib/deltaManager.js +3 -2
  78. package/lib/deltaManager.js.map +1 -1
  79. package/lib/handles.d.ts +8 -12
  80. package/lib/handles.d.ts.map +1 -1
  81. package/lib/handles.js +14 -12
  82. package/lib/handles.js.map +1 -1
  83. package/lib/index.d.ts +6 -3
  84. package/lib/index.d.ts.map +1 -1
  85. package/lib/index.js.map +1 -1
  86. package/lib/legacy.d.ts +4 -2
  87. package/lib/objectstoragepartition.d.ts +1 -1
  88. package/lib/objectstoragepartition.d.ts.map +1 -1
  89. package/lib/objectstoragepartition.js.map +1 -1
  90. package/lib/objectstorageutils.d.ts +9 -1
  91. package/lib/objectstorageutils.d.ts.map +1 -1
  92. package/lib/objectstorageutils.js +15 -6
  93. package/lib/objectstorageutils.js.map +1 -1
  94. package/lib/packageVersion.d.ts +1 -1
  95. package/lib/packageVersion.d.ts.map +1 -1
  96. package/lib/packageVersion.js +1 -1
  97. package/lib/packageVersion.js.map +1 -1
  98. package/lib/public.d.ts +2 -1
  99. package/lib/remoteFluidObjectHandle.d.ts +2 -2
  100. package/lib/remoteFluidObjectHandle.d.ts.map +1 -1
  101. package/lib/remoteFluidObjectHandle.js +1 -0
  102. package/lib/remoteFluidObjectHandle.js.map +1 -1
  103. package/lib/requestParser.d.ts +2 -3
  104. package/lib/requestParser.d.ts.map +1 -1
  105. package/lib/requestParser.js +9 -11
  106. package/lib/requestParser.js.map +1 -1
  107. package/lib/runtimeFactoryHelper.d.ts +3 -4
  108. package/lib/runtimeFactoryHelper.d.ts.map +1 -1
  109. package/lib/runtimeFactoryHelper.js +1 -2
  110. package/lib/runtimeFactoryHelper.js.map +1 -1
  111. package/lib/summaryUtils.d.ts +29 -20
  112. package/lib/summaryUtils.d.ts.map +1 -1
  113. package/lib/summaryUtils.js +51 -23
  114. package/lib/summaryUtils.js.map +1 -1
  115. package/lib/tsdoc-metadata.json +1 -1
  116. package/lib/unpackUsedRoutes.d.ts.map +1 -1
  117. package/lib/unpackUsedRoutes.js +3 -3
  118. package/lib/unpackUsedRoutes.js.map +1 -1
  119. package/lib/utils.d.ts +1 -1
  120. package/lib/utils.d.ts.map +1 -1
  121. package/lib/utils.js.map +1 -1
  122. package/package.json +22 -22
  123. package/src/compatibilityBase.ts +4 -3
  124. package/src/dataStoreHandleContextUtils.ts +1 -1
  125. package/src/dataStoreHelpers.ts +52 -20
  126. package/src/deltaManager.ts +3 -2
  127. package/src/handles.ts +14 -13
  128. package/src/index.ts +6 -4
  129. package/src/objectstoragepartition.ts +2 -2
  130. package/src/objectstorageutils.ts +17 -8
  131. package/src/packageVersion.ts +1 -1
  132. package/src/remoteFluidObjectHandle.ts +4 -3
  133. package/src/requestParser.ts +15 -15
  134. package/src/runtimeFactoryHelper.ts +4 -5
  135. package/src/summaryUtils.ts +70 -43
  136. package/src/unpackUsedRoutes.ts +7 -5
  137. package/src/utils.ts +2 -2
@@ -4,10 +4,10 @@
4
4
  */
5
5
  import { IsoBuffer, Uint8ArrayToString, bufferToString, fromBase64ToUtf8, } from "@fluid-internal/client-utils";
6
6
  import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
7
- import { SummaryType, } from "@fluidframework/driver-definitions";
7
+ import { SummaryType } from "@fluidframework/driver-definitions";
8
8
  import { TreeEntry } from "@fluidframework/driver-definitions/internal";
9
9
  import { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry, } from "@fluidframework/driver-utils/internal";
10
- import { gcDataBlobKey, } from "@fluidframework/runtime-definitions/internal";
10
+ import { gcDataBlobKey } from "@fluidframework/runtime-definitions/internal";
11
11
  /**
12
12
  * Combines summary stats by adding their totals together.
13
13
  * Returns empty stats if called without args.
@@ -32,26 +32,34 @@ export function mergeStats(...stats) {
32
32
  return results;
33
33
  }
34
34
  /**
35
+ * Calculates the byte length of an UTF-8 encoded string
36
+ * @param str - The string to calculate the byte length of
37
+ * @returns The byte length of the string
35
38
  * @internal
36
39
  */
37
40
  export function utf8ByteLength(str) {
38
41
  // returns the byte length of an utf8 string
39
42
  let s = str.length;
40
43
  for (let i = str.length - 1; i >= 0; i--) {
41
- const code = str.charCodeAt(i);
42
- if (code > 0x7f && code <= 0x7ff) {
43
- s++;
44
- }
45
- else if (code > 0x7ff && code <= 0xffff) {
46
- s += 2;
47
- }
48
- if (code >= 0xdc00 && code <= 0xdfff) {
49
- i--; // trail surrogate
44
+ const code = str.codePointAt(i);
45
+ if (code !== undefined) {
46
+ if (code > 0x7f && code <= 0x7ff) {
47
+ s++;
48
+ }
49
+ else if (code > 0x7ff && code <= 0xffff) {
50
+ s += 2;
51
+ }
52
+ if (code >= 0xdc00 && code <= 0xdfff) {
53
+ i--; // trail surrogate
54
+ }
50
55
  }
51
56
  }
52
57
  return s;
53
58
  }
54
59
  /**
60
+ * Gets the size of a blob
61
+ * @param content - The content of the blob
62
+ * @returns The size of the blob in bytes
55
63
  * @internal
56
64
  */
57
65
  export function getBlobSize(content) {
@@ -75,11 +83,15 @@ function calculateStatsCore(summaryObject, stats) {
75
83
  stats.totalBlobSize += getBlobSize(summaryObject.content);
76
84
  return;
77
85
  }
78
- default:
86
+ default: {
79
87
  return;
88
+ }
80
89
  }
81
90
  }
82
91
  /**
92
+ * Calculates the stats for a summary object
93
+ * @param summary - The summary object to calculate stats for
94
+ * @returns The calculated stats
83
95
  * @internal
84
96
  */
85
97
  export function calculateStats(summary) {
@@ -88,6 +100,10 @@ export function calculateStats(summary) {
88
100
  return stats;
89
101
  }
90
102
  /**
103
+ * Adds a blob to the summary tree
104
+ * @param summary - The summary tree to add the blob to
105
+ * @param key - The key to store the blob at
106
+ * @param content - The content of the blob to be added
91
107
  * @internal
92
108
  */
93
109
  export function addBlobToSummary(summary, key, content) {
@@ -100,6 +116,10 @@ export function addBlobToSummary(summary, key, content) {
100
116
  summary.stats.totalBlobSize += getBlobSize(content);
101
117
  }
102
118
  /**
119
+ * Adds a summarize result to the summary tree
120
+ * @param summary - The summary tree to add the summarize result to
121
+ * @param key - The key to store the summarize result at
122
+ * @param summarizeResult - The summarize result to be added
103
123
  * @internal
104
124
  */
105
125
  export function addSummarizeResultToSummary(summary, key, summarizeResult) {
@@ -109,8 +129,7 @@ export function addSummarizeResultToSummary(summary, key, summarizeResult) {
109
129
  /**
110
130
  * A helper class for building summary trees.
111
131
  * @remarks Uses the builder pattern.
112
- * @legacy
113
- * @alpha
132
+ * @legacy @beta
114
133
  */
115
134
  export class SummaryTreeBuilder {
116
135
  get summary() {
@@ -195,8 +214,7 @@ export class SummaryTreeBuilder {
195
214
  * Converts snapshot ITree to ISummaryTree format and tracks stats.
196
215
  * @param snapshot - snapshot in ITree format
197
216
  * @param fullTree - true to never use handles, even if id is specified
198
- * @legacy
199
- * @alpha
217
+ * @legacy @beta
200
218
  */
201
219
  export function convertToSummaryTreeWithStats(snapshot, fullTree = false) {
202
220
  const builder = new SummaryTreeBuilder();
@@ -218,8 +236,9 @@ export function convertToSummaryTreeWithStats(snapshot, fullTree = false) {
218
236
  builder.addAttachment(id);
219
237
  break;
220
238
  }
221
- default:
239
+ default: {
222
240
  throw new Error("Unexpected TreeEntry type");
241
+ }
223
242
  }
224
243
  }
225
244
  const summaryTree = builder.getSummaryTree();
@@ -266,6 +285,8 @@ export function convertSnapshotTreeToSummaryTree(snapshot) {
266
285
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
267
286
  const content = snapshot.blobsContents[id];
268
287
  if (content !== undefined) {
288
+ // Cannot change "utf-8" to "utf8" as this encoding value is stored in summaries and would be a breaking change which needs to be done first before changing to utf8.
289
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- External on-disk format is 'utf-8'.
269
290
  decoded = bufferToString(content, "utf-8");
270
291
  }
271
292
  // 0.44 back-compat We still put contents in same blob for back-compat so need to add blob
@@ -300,6 +321,8 @@ export function convertSummaryTreeToITree(summaryTree) {
300
321
  switch (value.type) {
301
322
  case SummaryType.Blob: {
302
323
  let parsedContent;
324
+ // Cannot change "utf-8" to "utf8" as this encoding value is stored in summaries and would be a breaking change which needs to be done first before changing to utf8.
325
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- external contract uses 'utf-8'.
303
326
  let encoding = "utf-8";
304
327
  if (typeof value.content === "string") {
305
328
  parsedContent = value.content;
@@ -322,8 +345,9 @@ export function convertSummaryTreeToITree(summaryTree) {
322
345
  case SummaryType.Handle: {
323
346
  throw new Error("Should not have Handle type in summary tree");
324
347
  }
325
- default:
348
+ default: {
326
349
  unreachableCase(value, "Unexpected summary tree type");
350
+ }
327
351
  }
328
352
  }
329
353
  return {
@@ -352,12 +376,16 @@ export function processAttachMessageGCData(snapshot, addedGCOutboundRoute) {
352
376
  if (gcDataEntry === undefined) {
353
377
  return false;
354
378
  }
355
- assert(gcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === "utf-8", 0x8ff /* GC data should be a utf-8-encoded blob */);
379
+ assert(
380
+ // Cannot change "utf-8" to "utf8" as this encoding value is stored in summaries and would be a breaking change which needs to be done first before changing to utf8.
381
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case -- external contract uses 'utf-8'.
382
+ gcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === "utf-8", 0x8ff /* GC data should be a utf-8-encoded blob */);
383
+ // Type assertion is safe as we expect the GC data to conform to IGarbageCollectionData schema
356
384
  const gcData = JSON.parse(gcDataEntry.value.contents);
357
385
  for (const [nodeId, outboundRoutes] of Object.entries(gcData.gcNodes)) {
358
- outboundRoutes.forEach((toPath) => {
386
+ for (const toPath of outboundRoutes) {
359
387
  addedGCOutboundRoute(nodeId, toPath);
360
- });
388
+ }
361
389
  }
362
390
  return true;
363
391
  }
@@ -394,9 +422,9 @@ export class TelemetryContext {
394
422
  */
395
423
  serialize() {
396
424
  const jsonObject = {};
397
- this.telemetry.forEach((value, key) => {
425
+ for (const [key, value] of this.telemetry.entries()) {
398
426
  jsonObject[key] = value;
399
- });
427
+ }
400
428
  return JSON.stringify(jsonObject);
401
429
  }
402
430
  }
@@ -1 +1 @@
1
- {"version":3,"file":"summaryUtils.js","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,QAAgB,EAAE,OAAmC;QAC7E,KAAK,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5D,0CAA0C;YAC1C,IAAI,YAAY,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;YAC1C,4CAA4C;YAC5C,YAAY,GAAG,IAAI,QAAQ,IAAI,YAAY,EAAE,CAAC;YAC9C,uGAAuG;YACvG,mEAAmE;YACnE,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;YAEjD,qFAAqF;YACrF,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAEM,QAAQ,CAAC,OAAmC;QAClD,KAAK,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,aAAqB;QAC9C,KAAK,MAAM,cAAc,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IAEM,SAAS;QACf,OAAO;YACN,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tfromBase64ToUtf8,\n} from \"@fluid-internal/client-utils\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISummaryBlob,\n\tISummaryTree,\n\tSummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport { ITree, ITreeEntry, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tAttachmentTreeEntry,\n\tBlobTreeEntry,\n\tTreeTreeEntry,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tISummaryStats,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContextExt,\n\tgcDataBlobKey,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { TelemetryEventPropertyTypeExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Combines summary stats by adding their totals together.\n * Returns empty stats if called without args.\n * @param stats - stats to merge\n * @internal\n */\nexport function mergeStats(...stats: ISummaryStats[]): ISummaryStats {\n\tconst results = {\n\t\ttreeNodeCount: 0,\n\t\tblobNodeCount: 0,\n\t\thandleNodeCount: 0,\n\t\ttotalBlobSize: 0,\n\t\tunreferencedBlobSize: 0,\n\t};\n\tfor (const stat of stats) {\n\t\tresults.treeNodeCount += stat.treeNodeCount;\n\t\tresults.blobNodeCount += stat.blobNodeCount;\n\t\tresults.handleNodeCount += stat.handleNodeCount;\n\t\tresults.totalBlobSize += stat.totalBlobSize;\n\t\tresults.unreferencedBlobSize += stat.unreferencedBlobSize;\n\t}\n\treturn results;\n}\n\n/**\n * @internal\n */\nexport function utf8ByteLength(str: string): number {\n\t// returns the byte length of an utf8 string\n\tlet s = str.length;\n\tfor (let i = str.length - 1; i >= 0; i--) {\n\t\tconst code = str.charCodeAt(i);\n\t\tif (code > 0x7f && code <= 0x7ff) {\n\t\t\ts++;\n\t\t} else if (code > 0x7ff && code <= 0xffff) {\n\t\t\ts += 2;\n\t\t}\n\t\tif (code >= 0xdc00 && code <= 0xdfff) {\n\t\t\ti--; // trail surrogate\n\t\t}\n\t}\n\treturn s;\n}\n\n/**\n * @internal\n */\nexport function getBlobSize(content: ISummaryBlob[\"content\"]): number {\n\treturn typeof content === \"string\" ? utf8ByteLength(content) : content.byteLength;\n}\n\nfunction calculateStatsCore(summaryObject: SummaryObject, stats: ISummaryStats): void {\n\tswitch (summaryObject.type) {\n\t\tcase SummaryType.Tree: {\n\t\t\tstats.treeNodeCount++;\n\t\t\tfor (const value of Object.values(summaryObject.tree)) {\n\t\t\t\tcalculateStatsCore(value, stats);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Handle: {\n\t\t\tstats.handleNodeCount++;\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Blob: {\n\t\t\tstats.blobNodeCount++;\n\t\t\tstats.totalBlobSize += getBlobSize(summaryObject.content);\n\t\t\treturn;\n\t\t}\n\t\tdefault:\n\t\t\treturn;\n\t}\n}\n\n/**\n * @internal\n */\nexport function calculateStats(summary: SummaryObject): ISummaryStats {\n\tconst stats = mergeStats();\n\tcalculateStatsCore(summary, stats);\n\treturn stats;\n}\n\n/**\n * @internal\n */\nexport function addBlobToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tcontent: string | Uint8Array,\n): void {\n\tconst blob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent,\n\t};\n\tsummary.summary.tree[key] = blob;\n\tsummary.stats.blobNodeCount++;\n\tsummary.stats.totalBlobSize += getBlobSize(content);\n}\n\n/**\n * @internal\n */\nexport function addSummarizeResultToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tsummarizeResult: ISummarizeResult,\n): void {\n\tsummary.summary.tree[key] = summarizeResult.summary;\n\tsummary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\n/**\n * An object who's properties are used to initialize a {@link SummaryTreeBuilder}\n * @legacy\n * @alpha\n */\nexport interface SummaryTreeBuilderParams {\n\t/**\n\t * This value will become the {@link @fluidframework/driver-definitions#ISummaryTree.groupId}\n\t * of the {@link @fluidframework/driver-definitions#ISummaryTree} built by the {@link SummaryTreeBuilder}.\n\t */\n\tgroupId?: string;\n}\n/**\n * A helper class for building summary trees.\n * @remarks Uses the builder pattern.\n * @legacy\n * @alpha\n */\nexport class SummaryTreeBuilder implements ISummaryTreeWithStats {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly groupId?: string;\n\n\tpublic get summary(): ISummaryTree {\n\t\tconst summary: ISummaryTree = {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t};\n\t\tif (this.groupId !== undefined) {\n\t\t\tsummary.groupId = this.groupId;\n\t\t}\n\t\treturn summary;\n\t}\n\n\tpublic get stats(): Readonly<ISummaryStats> {\n\t\treturn { ...this.summaryStats };\n\t}\n\n\tconstructor(params?: { groupId?: string }) {\n\t\tthis.summaryStats = mergeStats();\n\t\tthis.summaryStats.treeNodeCount++;\n\t\tthis.groupId = params?.groupId;\n\t}\n\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\tprivate summaryStats: ISummaryStats;\n\n\t/**\n\t * Add a blob to the summary tree. This blob will be stored at the given key in the summary tree.\n\t * @param key - The key to store the blob at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * @param content - The content of the blob to be added to the summary tree.\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\t// Prevent cloning by directly referencing underlying private properties\n\t\taddBlobToSummary(\n\t\t\t{\n\t\t\t\tsummary: {\n\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\ttree: this.summaryTree,\n\t\t\t\t},\n\t\t\t\tstats: this.summaryStats,\n\t\t\t},\n\t\t\tkey,\n\t\t\tcontent,\n\t\t);\n\t}\n\n\t/**\n\t * Adds an {@link @fluidframework/driver-definitions#ISummaryHandle} that references a subtree, blob, or attachment in a previous summary.\n\t *\n\t * @param key - The key to store the handle at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * @param handleType - the type of {@link @fluidframework/driver-definitions#SummaryObject} besides a SummaryHandle, i.e. {@link @fluidframework/driver-definitions#SummaryType.Tree}, {@link @fluidframework/driver-definitions#SummaryType.Blob}, {@link @fluidframework/driver-definitions#SummaryType.Attachment}\n\t * @param handle - The path pointing to the part of the previous summary being used to duplicate the data. Use {@link @fluidframework/driver-definitions#ISummaryHandle.handle} to help generate proper handle strings. Should not contain any \"/\" characters.\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t\tthis.summaryStats.handleNodeCount++;\n\t}\n\n\t/**\n\t * Adds a child and updates the stats accordingly.\n\t * @param key - The key to store the handle at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * The key should be unique within the current summary tree, and not transform when encodeURIComponent is called.\n\t * @param summarizeResult - Similar to {@link @fluidframework/runtime-definitions#ISummaryTreeWithStats}. The provided summary can be either a {@link @fluidframework/driver-definitions#ISummaryHandle} or {@link @fluidframework/driver-definitions#ISummaryTree}.\n\t */\n\tpublic addWithStats(key: string, summarizeResult: ISummarizeResult): void {\n\t\tthis.summaryTree[key] = summarizeResult.summary;\n\t\tthis.summaryStats = mergeStats(this.summaryStats, summarizeResult.stats);\n\t}\n\n\t/**\n\t * Adds an {@link @fluidframework/driver-definitions#ISummaryAttachment} to the summary. This blob needs to already be uploaded to storage.\n\t * @param id - The id of the uploaded attachment to be added to the summary tree.\n\t */\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n\n\t/**\n\t * Gives you the in-memory summary tree with stats built by the SummaryTreeBuilder.\n\t *\n\t * @remarks\n\t * Use this once you're done building the summary tree, the stats should automatically be generated.\n\t * @returns The summary tree and stats built by the SummaryTreeBuilder.\n\t */\n\tpublic getSummaryTree(): ISummaryTreeWithStats {\n\t\treturn { summary: this.summary, stats: this.stats };\n\t}\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @legacy\n * @alpha\n */\nexport function convertToSummaryTreeWithStats(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const entry of snapshot.entries) {\n\t\tswitch (entry.type) {\n\t\t\tcase TreeEntry.Blob: {\n\t\t\t\tconst blob = entry.value;\n\t\t\t\tconst content =\n\t\t\t\t\tblob.encoding === \"base64\" ? IsoBuffer.from(blob.contents, \"base64\") : blob.contents;\n\t\t\t\tbuilder.addBlob(entry.path, content);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Tree: {\n\t\t\t\tconst subtree = convertToSummaryTree(entry.value, fullTree);\n\t\t\t\tbuilder.addWithStats(entry.path, subtree);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Attachment: {\n\t\t\t\tconst id = entry.value.id;\n\t\t\t\tbuilder.addAttachment(id);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unexpected TreeEntry type\");\n\t\t}\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @internal\n */\nexport function convertToSummaryTree(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummarizeResult {\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (snapshot.id && !fullTree) {\n\t\tconst stats = mergeStats();\n\t\tstats.handleNodeCount++;\n\t\treturn {\n\t\t\tsummary: {\n\t\t\t\thandle: snapshot.id,\n\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\ttype: SummaryType.Handle,\n\t\t\t},\n\t\t\tstats,\n\t\t};\n\t} else {\n\t\treturn convertToSummaryTreeWithStats(snapshot, fullTree);\n\t}\n}\n\n/**\n * Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was\n * was taken by serialize api in detached container.\n * @param snapshot - snapshot in ISnapshotTree format\n * @internal\n */\nexport function convertSnapshotTreeToSummaryTree(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tlet decoded: string | undefined;\n\t\tif (snapshot.blobsContents !== undefined) {\n\t\t\t// TODO Why are we non null asserting here?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst content: ArrayBufferLike = snapshot.blobsContents[id]!;\n\t\t\tif (content !== undefined) {\n\t\t\t\tdecoded = bufferToString(content, \"utf-8\");\n\t\t\t}\n\t\t\t// 0.44 back-compat We still put contents in same blob for back-compat so need to add blob\n\t\t\t// only for blobPath -> blobId mapping and not for blobId -> blob value contents.\n\t\t} else if (snapshot.blobs[id] !== undefined) {\n\t\t\t// Non null asserting here because of the undefined check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tdecoded = fromBase64ToUtf8(snapshot.blobs[id]!);\n\t\t}\n\t\tif (decoded !== undefined) {\n\t\t\tbuilder.addBlob(path, decoded);\n\t\t}\n\t}\n\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotTreeToSummaryTree(tree);\n\t\tbuilder.addWithStats(key, subtree);\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.\n * @param summaryTree - summary tree in ISummaryTree format\n * @internal\n */\nexport function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tfor (const [key, value] of Object.entries(summaryTree.tree)) {\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(key, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(key, convertSummaryTreeToITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(key, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t\tgroupId: summaryTree.groupId,\n\t};\n}\n\n/**\n * Looks in the given attach message snapshot for the .gcdata blob, which would\n * contain the initial GC Data for the node being attached.\n * If it finds it, it notifies GC of all the new outbound routes being added by the attach.\n *\n * @param snapshot - The snapshot from the attach message\n * @param addedGCOutboundRoute - Callback to notify GC of a new outbound route.\n * IMPORTANT: addedGCOutboundRoute's param nodeId is \"/\" for the attaching node itself, or \"/<id>\" for its children.\n *\n * @returns true if it found/processed GC Data, false otherwise\n *\n * @internal\n */\nexport function processAttachMessageGCData(\n\tsnapshot: ITree | null,\n\taddedGCOutboundRoute: (fromNodeId: string, toPath: string) => void,\n): boolean {\n\tconst gcDataEntry = snapshot?.entries.find((e) => e.path === gcDataBlobKey);\n\n\t// Old attach messages won't have GC Data\n\t// (And REALLY old DataStore Attach messages won't even have a snapshot!)\n\tif (gcDataEntry === undefined) {\n\t\treturn false;\n\t}\n\n\tassert(\n\t\tgcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === \"utf-8\",\n\t\t0x8ff /* GC data should be a utf-8-encoded blob */,\n\t);\n\n\tconst gcData = JSON.parse(gcDataEntry.value.contents) as IGarbageCollectionData;\n\tfor (const [nodeId, outboundRoutes] of Object.entries(gcData.gcNodes)) {\n\t\toutboundRoutes.forEach((toPath) => {\n\t\t\taddedGCOutboundRoute(nodeId, toPath);\n\t\t});\n\t}\n\treturn true;\n}\n\n/**\n * @internal\n */\nexport class TelemetryContext implements ITelemetryContext, ITelemetryContextExt {\n\tprivate readonly telemetry = new Map<string, TelemetryEventPropertyTypeExt>();\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}\n\t */\n\tset(prefix: string, property: string, value: TelemetryEventPropertyTypeExt): void {\n\t\tthis.telemetry.set(`${prefix}${property}`, value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setMultiple}\n\t */\n\tsetMultiple(\n\t\tprefix: string,\n\t\tproperty: string,\n\t\tvalues: Record<string, TelemetryEventPropertyTypeExt>,\n\t): void {\n\t\t// Set the values individually so that they are logged as a flat list along with other properties.\n\t\tfor (const key of Object.keys(values)) {\n\t\t\tthis.set(prefix, `${property}_${key}`, values[key]);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}\n\t */\n\tget(prefix: string, property: string): TelemetryEventPropertyTypeExt {\n\t\treturn this.telemetry.get(`${prefix}${property}`);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}\n\t */\n\tserialize(): string {\n\t\tconst jsonObject = {};\n\t\tthis.telemetry.forEach((value, key) => {\n\t\t\tjsonObject[key] = value;\n\t\t});\n\t\treturn JSON.stringify(jsonObject);\n\t}\n}\n\n/**\n * Trims the leading slashes from the given string.\n * @param str - A string that may contain leading slashes.\n * @returns A new string without leading slashes.\n */\nfunction trimLeadingSlashes(str: string) {\n\treturn str.replace(/^\\/+/g, \"\");\n}\n\n/**\n * Trims the trailing slashes from the given string.\n * @param str - A string that may contain trailing slashes.\n * @returns A new string without trailing slashes.\n */\nfunction trimTrailingSlashes(str: string) {\n\treturn str.replace(/\\/+$/g, \"\");\n}\n\n/**\n * Helper class to build the garbage collection data of a node by combining the data from multiple nodes.\n * @internal\n */\nexport class GCDataBuilder implements IGarbageCollectionData {\n\tprivate readonly gcNodesSet: { [id: string]: Set<string> } = {};\n\tpublic get gcNodes(): { [id: string]: string[] } {\n\t\tconst gcNodes = {};\n\t\tfor (const [nodeId, outboundRoutes] of Object.entries(this.gcNodesSet)) {\n\t\t\tgcNodes[nodeId] = [...outboundRoutes];\n\t\t}\n\t\treturn gcNodes;\n\t}\n\n\tpublic addNode(id: string, outboundRoutes: string[]) {\n\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t}\n\n\t/**\n\t * Adds the given GC nodes. It does the following:\n\t * - Normalizes the ids of the given nodes.\n\t * - Prefixes the given `prefixId` to the given nodes' ids.\n\t * - Adds the outbound routes of the nodes against the normalized and prefixed id.\n\t */\n\tpublic prefixAndAddNodes(prefixId: string, gcNodes: { [id: string]: string[] }) {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\t// Remove any leading slashes from the id.\n\t\t\tlet normalizedId = trimLeadingSlashes(id);\n\t\t\t// Prefix the given id to the normalized id.\n\t\t\tnormalizedId = `/${prefixId}/${normalizedId}`;\n\t\t\t// Remove any trailing slashes from the normalized id. Note that the trailing slashes are removed after\n\t\t\t// adding the prefix for handling the special case where id is \"/\".\n\t\t\tnormalizedId = trimTrailingSlashes(normalizedId);\n\n\t\t\t// Add the outbound routes against the normalized and prefixed id without duplicates.\n\t\t\tthis.gcNodesSet[normalizedId] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\tpublic addNodes(gcNodes: { [id: string]: string[] }) {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\t/**\n\t * Adds the given outbound route to the outbound routes of all GC nodes.\n\t */\n\tpublic addRouteToAllNodes(outboundRoute: string) {\n\t\tfor (const outboundRoutes of Object.values(this.gcNodesSet)) {\n\t\t\toutboundRoutes.add(outboundRoute);\n\t\t}\n\t}\n\n\tpublic getGCData(): IGarbageCollectionData {\n\t\treturn {\n\t\t\tgcNodes: this.gcNodes,\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"summaryUtils.js","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAM9E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AACxE,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,aAAa,GACb,MAAM,uCAAuC,CAAC;AAS/C,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAG7E;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAAsB;IACnD,MAAM,OAAO,GAAG;QACf,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,CAAC;QAChB,eAAe,EAAE,CAAC;QAClB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AG,mBAAmB,CAAC,YAAY,CAAC,CAAC;YAEjD,qFAAqF;YACrF,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAEM,QAAQ,CAAC,OAAiC;QAChD,KAAK,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC;IAED;;OAEG;IACI,kBAAkB,CAAC,aAAqB;QAC9C,KAAK,MAAM,cAAc,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IAEM,SAAS;QACf,OAAO;YACN,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tfromBase64ToUtf8,\n} from \"@fluid-internal/client-utils\";\nimport type { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tISummaryBlob,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/driver-definitions\";\nimport { SummaryType } from \"@fluidframework/driver-definitions\";\nimport type { ITree, ITreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport { TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tAttachmentTreeEntry,\n\tBlobTreeEntry,\n\tTreeTreeEntry,\n} from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryStats,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContextExt,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { gcDataBlobKey } from \"@fluidframework/runtime-definitions/internal\";\nimport type { TelemetryEventPropertyTypeExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Combines summary stats by adding their totals together.\n * Returns empty stats if called without args.\n * @param stats - stats to merge\n * @internal\n */\nexport function mergeStats(...stats: ISummaryStats[]): ISummaryStats {\n\tconst results = {\n\t\ttreeNodeCount: 0,\n\t\tblobNodeCount: 0,\n\t\thandleNodeCount: 0,\n\t\ttotalBlobSize: 0,\n\t\tunreferencedBlobSize: 0,\n\t};\n\tfor (const stat of stats) {\n\t\tresults.treeNodeCount += stat.treeNodeCount;\n\t\tresults.blobNodeCount += stat.blobNodeCount;\n\t\tresults.handleNodeCount += stat.handleNodeCount;\n\t\tresults.totalBlobSize += stat.totalBlobSize;\n\t\tresults.unreferencedBlobSize += stat.unreferencedBlobSize;\n\t}\n\treturn results;\n}\n\n/**\n * Calculates the byte length of an UTF-8 encoded string\n * @param str - The string to calculate the byte length of\n * @returns The byte length of the string\n * @internal\n */\nexport function utf8ByteLength(str: string): number {\n\t// returns the byte length of an utf8 string\n\tlet s = str.length;\n\tfor (let i = str.length - 1; i >= 0; i--) {\n\t\tconst code = str.codePointAt(i);\n\t\tif (code !== undefined) {\n\t\t\tif (code > 0x7f && code <= 0x7ff) {\n\t\t\t\ts++;\n\t\t\t} else if (code > 0x7ff && code <= 0xffff) {\n\t\t\t\ts += 2;\n\t\t\t}\n\t\t\tif (code >= 0xdc00 && code <= 0xdfff) {\n\t\t\t\ti--; // trail surrogate\n\t\t\t}\n\t\t}\n\t}\n\treturn s;\n}\n\n/**\n * Gets the size of a blob\n * @param content - The content of the blob\n * @returns The size of the blob in bytes\n * @internal\n */\nexport function getBlobSize(content: ISummaryBlob[\"content\"]): number {\n\treturn typeof content === \"string\" ? utf8ByteLength(content) : content.byteLength;\n}\n\nfunction calculateStatsCore(summaryObject: SummaryObject, stats: ISummaryStats): void {\n\tswitch (summaryObject.type) {\n\t\tcase SummaryType.Tree: {\n\t\t\tstats.treeNodeCount++;\n\t\t\tfor (const value of Object.values(summaryObject.tree)) {\n\t\t\t\tcalculateStatsCore(value, stats);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Handle: {\n\t\t\tstats.handleNodeCount++;\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Blob: {\n\t\t\tstats.blobNodeCount++;\n\t\t\tstats.totalBlobSize += getBlobSize(summaryObject.content);\n\t\t\treturn;\n\t\t}\n\t\tdefault: {\n\t\t\treturn;\n\t\t}\n\t}\n}\n\n/**\n * Calculates the stats for a summary object\n * @param summary - The summary object to calculate stats for\n * @returns The calculated stats\n * @internal\n */\nexport function calculateStats(summary: SummaryObject): ISummaryStats {\n\tconst stats = mergeStats();\n\tcalculateStatsCore(summary, stats);\n\treturn stats;\n}\n\n/**\n * Adds a blob to the summary tree\n * @param summary - The summary tree to add the blob to\n * @param key - The key to store the blob at\n * @param content - The content of the blob to be added\n * @internal\n */\nexport function addBlobToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tcontent: string | Uint8Array,\n): void {\n\tconst blob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent,\n\t};\n\tsummary.summary.tree[key] = blob;\n\tsummary.stats.blobNodeCount++;\n\tsummary.stats.totalBlobSize += getBlobSize(content);\n}\n\n/**\n * Adds a summarize result to the summary tree\n * @param summary - The summary tree to add the summarize result to\n * @param key - The key to store the summarize result at\n * @param summarizeResult - The summarize result to be added\n * @internal\n */\nexport function addSummarizeResultToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tsummarizeResult: ISummarizeResult,\n): void {\n\tsummary.summary.tree[key] = summarizeResult.summary;\n\tsummary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\n/**\n * An object who's properties are used to initialize a {@link SummaryTreeBuilder}\n * @legacy @beta\n */\nexport interface SummaryTreeBuilderParams {\n\t/**\n\t * This value will become the {@link @fluidframework/driver-definitions#ISummaryTree.groupId}\n\t * of the {@link @fluidframework/driver-definitions#ISummaryTree} built by the {@link SummaryTreeBuilder}.\n\t */\n\tgroupId?: string;\n}\n/**\n * A helper class for building summary trees.\n * @remarks Uses the builder pattern.\n * @legacy @beta\n */\nexport class SummaryTreeBuilder implements ISummaryTreeWithStats {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly groupId?: string;\n\n\tpublic get summary(): ISummaryTree {\n\t\tconst summary: ISummaryTree = {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t};\n\t\tif (this.groupId !== undefined) {\n\t\t\tsummary.groupId = this.groupId;\n\t\t}\n\t\treturn summary;\n\t}\n\n\tpublic get stats(): Readonly<ISummaryStats> {\n\t\treturn { ...this.summaryStats };\n\t}\n\n\tpublic constructor(params?: { groupId?: string }) {\n\t\tthis.summaryStats = mergeStats();\n\t\tthis.summaryStats.treeNodeCount++;\n\t\tthis.groupId = params?.groupId;\n\t}\n\n\tprivate readonly summaryTree: Record<string, SummaryObject> = {};\n\tprivate summaryStats: ISummaryStats;\n\n\t/**\n\t * Add a blob to the summary tree. This blob will be stored at the given key in the summary tree.\n\t * @param key - The key to store the blob at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * @param content - The content of the blob to be added to the summary tree.\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\t// Prevent cloning by directly referencing underlying private properties\n\t\taddBlobToSummary(\n\t\t\t{\n\t\t\t\tsummary: {\n\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\ttree: this.summaryTree,\n\t\t\t\t},\n\t\t\t\tstats: this.summaryStats,\n\t\t\t},\n\t\t\tkey,\n\t\t\tcontent,\n\t\t);\n\t}\n\n\t/**\n\t * Adds an {@link @fluidframework/driver-definitions#ISummaryHandle} that references a subtree, blob, or attachment in a previous summary.\n\t *\n\t * @param key - The key to store the handle at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * @param handleType - the type of {@link @fluidframework/driver-definitions#SummaryObject} besides a SummaryHandle, i.e. {@link @fluidframework/driver-definitions#SummaryType.Tree}, {@link @fluidframework/driver-definitions#SummaryType.Blob}, {@link @fluidframework/driver-definitions#SummaryType.Attachment}\n\t * @param handle - The path pointing to the part of the previous summary being used to duplicate the data. Use {@link @fluidframework/driver-definitions#ISummaryHandle.handle} to help generate proper handle strings. Should not contain any \"/\" characters.\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t\tthis.summaryStats.handleNodeCount++;\n\t}\n\n\t/**\n\t * Adds a child and updates the stats accordingly.\n\t * @param key - The key to store the handle at in the current summary tree being generated. Should not contain any \"/\" characters.\n\t * The key should be unique within the current summary tree, and not transform when encodeURIComponent is called.\n\t * @param summarizeResult - Similar to {@link @fluidframework/runtime-definitions#ISummaryTreeWithStats}. The provided summary can be either a {@link @fluidframework/driver-definitions#ISummaryHandle} or {@link @fluidframework/driver-definitions#ISummaryTree}.\n\t */\n\tpublic addWithStats(key: string, summarizeResult: ISummarizeResult): void {\n\t\tthis.summaryTree[key] = summarizeResult.summary;\n\t\tthis.summaryStats = mergeStats(this.summaryStats, summarizeResult.stats);\n\t}\n\n\t/**\n\t * Adds an {@link @fluidframework/driver-definitions#ISummaryAttachment} to the summary. This blob needs to already be uploaded to storage.\n\t * @param id - The id of the uploaded attachment to be added to the summary tree.\n\t */\n\tpublic addAttachment(id: string): void {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n\n\t/**\n\t * Gives you the in-memory summary tree with stats built by the SummaryTreeBuilder.\n\t *\n\t * @remarks\n\t * Use this once you're done building the summary tree, the stats should automatically be generated.\n\t * @returns The summary tree and stats built by the SummaryTreeBuilder.\n\t */\n\tpublic getSummaryTree(): ISummaryTreeWithStats {\n\t\treturn { summary: this.summary, stats: this.stats };\n\t}\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @legacy @beta\n */\nexport function convertToSummaryTreeWithStats(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const entry of snapshot.entries) {\n\t\tswitch (entry.type) {\n\t\t\tcase TreeEntry.Blob: {\n\t\t\t\tconst blob = entry.value;\n\t\t\t\tconst content =\n\t\t\t\t\tblob.encoding === \"base64\" ? IsoBuffer.from(blob.contents, \"base64\") : blob.contents;\n\t\t\t\tbuilder.addBlob(entry.path, content);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Tree: {\n\t\t\t\tconst subtree = convertToSummaryTree(entry.value, fullTree);\n\t\t\t\tbuilder.addWithStats(entry.path, subtree);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Attachment: {\n\t\t\t\tconst id = entry.value.id;\n\t\t\t\tbuilder.addAttachment(id);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(\"Unexpected TreeEntry type\");\n\t\t\t}\n\t\t}\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @internal\n */\nexport function convertToSummaryTree(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummarizeResult {\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (snapshot.id && !fullTree) {\n\t\tconst stats = mergeStats();\n\t\tstats.handleNodeCount++;\n\t\treturn {\n\t\t\tsummary: {\n\t\t\t\thandle: snapshot.id,\n\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\ttype: SummaryType.Handle,\n\t\t\t},\n\t\t\tstats,\n\t\t};\n\t} else {\n\t\treturn convertToSummaryTreeWithStats(snapshot, fullTree);\n\t}\n}\n\n/**\n * Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was\n * was taken by serialize api in detached container.\n * @param snapshot - snapshot in ISnapshotTree format\n * @internal\n */\nexport function convertSnapshotTreeToSummaryTree(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tlet decoded: string | undefined;\n\t\tif (snapshot.blobsContents !== undefined) {\n\t\t\t// TODO Why are we non null asserting here?\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst content: ArrayBufferLike = snapshot.blobsContents[id]!;\n\t\t\tif (content !== undefined) {\n\t\t\t\t// Cannot change \"utf-8\" to \"utf8\" as this encoding value is stored in summaries and would be a breaking change which needs to be done first before changing to utf8.\n\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- External on-disk format is 'utf-8'.\n\t\t\t\tdecoded = bufferToString(content, \"utf-8\");\n\t\t\t}\n\t\t\t// 0.44 back-compat We still put contents in same blob for back-compat so need to add blob\n\t\t\t// only for blobPath -> blobId mapping and not for blobId -> blob value contents.\n\t\t} else if (snapshot.blobs[id] !== undefined) {\n\t\t\t// Non null asserting here because of the undefined check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tdecoded = fromBase64ToUtf8(snapshot.blobs[id]!);\n\t\t}\n\t\tif (decoded !== undefined) {\n\t\t\tbuilder.addBlob(path, decoded);\n\t\t}\n\t}\n\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotTreeToSummaryTree(tree);\n\t\tbuilder.addWithStats(key, subtree);\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.\n * @param summaryTree - summary tree in ISummaryTree format\n * @internal\n */\nexport function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tfor (const [key, value] of Object.entries(summaryTree.tree)) {\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\t// Cannot change \"utf-8\" to \"utf8\" as this encoding value is stored in summaries and would be a breaking change which needs to be done first before changing to utf8.\n\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- external contract uses 'utf-8'.\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(key, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(key, convertSummaryTreeToITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(key, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t\tgroupId: summaryTree.groupId,\n\t};\n}\n\n/**\n * Looks in the given attach message snapshot for the .gcdata blob, which would\n * contain the initial GC Data for the node being attached.\n * If it finds it, it notifies GC of all the new outbound routes being added by the attach.\n *\n * @param snapshot - The snapshot from the attach message\n * @param addedGCOutboundRoute - Callback to notify GC of a new outbound route.\n * IMPORTANT: addedGCOutboundRoute's param nodeId is \"/\" for the attaching node itself, or \"/<id>\" for its children.\n *\n * @returns true if it found/processed GC Data, false otherwise\n *\n * @internal\n */\nexport function processAttachMessageGCData(\n\tsnapshot: ITree | undefined,\n\taddedGCOutboundRoute: (fromNodeId: string, toPath: string) => void,\n): boolean {\n\tconst gcDataEntry = snapshot?.entries.find((e) => e.path === gcDataBlobKey);\n\n\t// Old attach messages won't have GC Data\n\t// (And REALLY old DataStore Attach messages won't even have a snapshot!)\n\tif (gcDataEntry === undefined) {\n\t\treturn false;\n\t}\n\n\tassert(\n\t\t// Cannot change \"utf-8\" to \"utf8\" as this encoding value is stored in summaries and would be a breaking change which needs to be done first before changing to utf8.\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case -- external contract uses 'utf-8'.\n\t\tgcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === \"utf-8\",\n\t\t0x8ff /* GC data should be a utf-8-encoded blob */,\n\t);\n\n\t// Type assertion is safe as we expect the GC data to conform to IGarbageCollectionData schema\n\tconst gcData = JSON.parse(gcDataEntry.value.contents) as IGarbageCollectionData;\n\tfor (const [nodeId, outboundRoutes] of Object.entries(gcData.gcNodes)) {\n\t\tfor (const toPath of outboundRoutes) {\n\t\t\taddedGCOutboundRoute(nodeId, toPath);\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * @internal\n */\nexport class TelemetryContext implements ITelemetryContext, ITelemetryContextExt {\n\tprivate readonly telemetry = new Map<string, TelemetryEventPropertyTypeExt>();\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}\n\t */\n\tpublic set(prefix: string, property: string, value: TelemetryEventPropertyTypeExt): void {\n\t\tthis.telemetry.set(`${prefix}${property}`, value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setMultiple}\n\t */\n\tpublic setMultiple(\n\t\tprefix: string,\n\t\tproperty: string,\n\t\tvalues: Record<string, TelemetryEventPropertyTypeExt>,\n\t): void {\n\t\t// Set the values individually so that they are logged as a flat list along with other properties.\n\t\tfor (const key of Object.keys(values)) {\n\t\t\tthis.set(prefix, `${property}_${key}`, values[key]);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}\n\t */\n\tpublic get(prefix: string, property: string): TelemetryEventPropertyTypeExt {\n\t\treturn this.telemetry.get(`${prefix}${property}`);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}\n\t */\n\tpublic serialize(): string {\n\t\tconst jsonObject = {};\n\t\tfor (const [key, value] of this.telemetry.entries()) {\n\t\t\tjsonObject[key] = value;\n\t\t}\n\t\treturn JSON.stringify(jsonObject);\n\t}\n}\n\n/**\n * Trims the leading slashes from the given string.\n * @param str - A string that may contain leading slashes.\n * @returns A new string without leading slashes.\n */\nfunction trimLeadingSlashes(str: string): string {\n\treturn str.replace(/^\\/+/g, \"\");\n}\n\n/**\n * Trims the trailing slashes from the given string.\n * @param str - A string that may contain trailing slashes.\n * @returns A new string without trailing slashes.\n */\nfunction trimTrailingSlashes(str: string): string {\n\treturn str.replace(/\\/+$/g, \"\");\n}\n\n/**\n * Helper class to build the garbage collection data of a node by combining the data from multiple nodes.\n * @internal\n */\nexport class GCDataBuilder implements IGarbageCollectionData {\n\tprivate readonly gcNodesSet: Record<string, Set<string>> = {};\n\tpublic get gcNodes(): Record<string, string[]> {\n\t\tconst gcNodes = {};\n\t\tfor (const [nodeId, outboundRoutes] of Object.entries(this.gcNodesSet)) {\n\t\t\tgcNodes[nodeId] = [...outboundRoutes];\n\t\t}\n\t\treturn gcNodes;\n\t}\n\n\tpublic addNode(id: string, outboundRoutes: string[]): void {\n\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t}\n\n\t/**\n\t * Adds the given GC nodes. It does the following:\n\t * - Normalizes the ids of the given nodes.\n\t * - Prefixes the given `prefixId` to the given nodes' ids.\n\t * - Adds the outbound routes of the nodes against the normalized and prefixed id.\n\t */\n\tpublic prefixAndAddNodes(prefixId: string, gcNodes: Record<string, string[]>): void {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\t// Remove any leading slashes from the id.\n\t\t\tlet normalizedId = trimLeadingSlashes(id);\n\t\t\t// Prefix the given id to the normalized id.\n\t\t\tnormalizedId = `/${prefixId}/${normalizedId}`;\n\t\t\t// Remove any trailing slashes from the normalized id. Note that the trailing slashes are removed after\n\t\t\t// adding the prefix for handling the special case where id is \"/\".\n\t\t\tnormalizedId = trimTrailingSlashes(normalizedId);\n\n\t\t\t// Add the outbound routes against the normalized and prefixed id without duplicates.\n\t\t\tthis.gcNodesSet[normalizedId] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\tpublic addNodes(gcNodes: Record<string, string[]>): void {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\t/**\n\t * Adds the given outbound route to the outbound routes of all GC nodes.\n\t */\n\tpublic addRouteToAllNodes(outboundRoute: string): void {\n\t\tfor (const outboundRoutes of Object.values(this.gcNodesSet)) {\n\t\t\toutboundRoutes.add(outboundRoute);\n\t\t}\n\t}\n\n\tpublic getGCData(): IGarbageCollectionData {\n\t\treturn {\n\t\t\tgcNodes: this.gcNodes,\n\t\t};\n\t}\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.8"
8
+ "packageVersion": "7.52.11"
9
9
  }
10
10
  ]
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"unpackUsedRoutes.d.ts","sourceRoot":"","sources":["../src/unpackUsedRoutes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,yBAqBvE"}
1
+ {"version":3,"file":"unpackUsedRoutes.d.ts","sourceRoot":"","sources":["../src/unpackUsedRoutes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACzC,UAAU,EAAE,SAAS,MAAM,EAAE,GAC3B,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAqBvB"}
@@ -19,11 +19,11 @@ export function unpackChildNodesUsedRoutes(usedRoutes) {
19
19
  assert(childId !== undefined, 0x9ab /* childId is undefined in unpackChildNodesUsedRoutes */);
20
20
  const childUsedRoute = route.slice(childId.length + 1);
21
21
  const childUsedRoutes = childUsedRoutesMap.get(childId);
22
- if (childUsedRoutes !== undefined) {
23
- childUsedRoutes.push(childUsedRoute);
22
+ if (childUsedRoutes === undefined) {
23
+ childUsedRoutesMap.set(childId, [childUsedRoute]);
24
24
  }
25
25
  else {
26
- childUsedRoutesMap.set(childId, [childUsedRoute]);
26
+ childUsedRoutes.push(childUsedRoute);
27
27
  }
28
28
  }
29
29
  return childUsedRoutesMap;
@@ -1 +1 @@
1
- {"version":3,"file":"unpackUsedRoutes.js","sourceRoot":"","sources":["../src/unpackUsedRoutes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,UAA6B;IACvE,oFAAoF;IACpF,MAAM,kBAAkB,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC;IACvF,MAAM,kBAAkB,GAA0B,IAAI,GAAG,EAAE,CAAC;IAC5D,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACzF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,CACL,OAAO,KAAK,SAAS,EACrB,KAAK,CAAC,wDAAwD,CAC9D,CAAC;QACF,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAEvD,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YACnC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACP,kBAAkB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC3B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * Helper function that unpacks the used routes of children from a given node's used routes.\n * @param usedRoutes - The used routes of a node.\n * @returns A map of used routes of each children of the the given node.\n * @internal\n */\nexport function unpackChildNodesUsedRoutes(usedRoutes: readonly string[]) {\n\t// Remove the node's self used route, if any, and generate the children used routes.\n\tconst filteredUsedRoutes = usedRoutes.filter((route) => route !== \"\" && route !== \"/\");\n\tconst childUsedRoutesMap: Map<string, string[]> = new Map();\n\tfor (const route of filteredUsedRoutes) {\n\t\tassert(route.startsWith(\"/\"), 0x5e0 /* Used route should always be an absolute route */);\n\t\tconst childId = route.split(\"/\")[1];\n\t\tassert(\n\t\t\tchildId !== undefined,\n\t\t\t0x9ab /* childId is undefined in unpackChildNodesUsedRoutes */,\n\t\t);\n\t\tconst childUsedRoute = route.slice(childId.length + 1);\n\n\t\tconst childUsedRoutes = childUsedRoutesMap.get(childId);\n\t\tif (childUsedRoutes !== undefined) {\n\t\t\tchildUsedRoutes.push(childUsedRoute);\n\t\t} else {\n\t\t\tchildUsedRoutesMap.set(childId, [childUsedRoute]);\n\t\t}\n\t}\n\treturn childUsedRoutesMap;\n}\n"]}
1
+ {"version":3,"file":"unpackUsedRoutes.js","sourceRoot":"","sources":["../src/unpackUsedRoutes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACzC,UAA6B;IAE7B,oFAAoF;IACpF,MAAM,kBAAkB,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC;IACvF,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvD,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACzF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,CACL,OAAO,KAAK,SAAS,EACrB,KAAK,CAAC,wDAAwD,CAC9D,CAAC;QACF,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAEvD,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YACnC,kBAAkB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACP,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC3B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * Helper function that unpacks the used routes of children from a given node's used routes.\n * @param usedRoutes - The used routes of a node.\n * @returns A map of used routes of each children of the the given node.\n * @internal\n */\nexport function unpackChildNodesUsedRoutes(\n\tusedRoutes: readonly string[],\n): Map<string, string[]> {\n\t// Remove the node's self used route, if any, and generate the children used routes.\n\tconst filteredUsedRoutes = usedRoutes.filter((route) => route !== \"\" && route !== \"/\");\n\tconst childUsedRoutesMap = new Map<string, string[]>();\n\tfor (const route of filteredUsedRoutes) {\n\t\tassert(route.startsWith(\"/\"), 0x5e0 /* Used route should always be an absolute route */);\n\t\tconst childId = route.split(\"/\")[1];\n\t\tassert(\n\t\t\tchildId !== undefined,\n\t\t\t0x9ab /* childId is undefined in unpackChildNodesUsedRoutes */,\n\t\t);\n\t\tconst childUsedRoute = route.slice(childId.length + 1);\n\n\t\tconst childUsedRoutes = childUsedRoutesMap.get(childId);\n\t\tif (childUsedRoutes === undefined) {\n\t\t\tchildUsedRoutesMap.set(childId, [childUsedRoute]);\n\t\t} else {\n\t\t\tchildUsedRoutes.push(childUsedRoute);\n\t\t}\n\t}\n\treturn childUsedRoutesMap;\n}\n"]}
package/lib/utils.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ISnapshotTree } from "@fluidframework/driver-definitions/internal";
5
+ import type { ISnapshotTree } from "@fluidframework/driver-definitions/internal";
6
6
  /**
7
7
  * Accepted header keys for requests coming to the runtime.
8
8
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,aAAa,EACb,MAAM,6CAA6C,CAAC;AAErD;;;GAGG;AACH,oBAAY,cAAc;IACzB;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,SAAS,cAAc;IACvB;;OAEG;IACH,cAAc,mBAAmB;CACjC;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE,aAAa,EACnB,gBAAgB,EAAE,gBAAgB,GAChC,OAAO,CAAC,MAAM,CAAC,CAMjB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,qEACiC,CAAC;AAEpE;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,SAAK,UA6B1E"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAEX,aAAa,EACb,MAAM,6CAA6C,CAAC;AAErD;;;GAGG;AACH,oBAAY,cAAc;IACzB;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,SAAS,cAAc;IACvB;;OAEG;IACH,cAAc,mBAAmB;CACjC;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CA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O,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,0DAA0D;IAC1D,yEAAyE;IACzE,wFAAwF;IACxF,iEAAiE;IACjE,8FAA8F;IAC9F,gDAAgD;IAChD,8EAA8E;IAC9E,wDAAwD;IACxD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzE,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,IAAI,GAAG,GAAG,KAAK,CAAC;IAChB,GAAG,CAAC;QACH,gDAAgD;QAChD,WAAW;QACX,WAAW;QACX,aAAa;QACb,cAAc;QACd,iBAAiB;QACjB,kBAAkB;QAClB,MAAM,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC;QACxB,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACxC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,EAAE;IACrB,OAAO,MAAM,GAAG,EAAE,CAAC;AACpB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentAttributes,\n\tISnapshotTree,\n} from \"@fluidframework/driver-definitions/internal\";\n\n/**\n * Accepted header keys for requests coming to the runtime.\n * @internal\n */\nexport enum RuntimeHeaders {\n\t/**\n\t * True to wait for a data store to be created and loaded before returning it.\n\t */\n\twait = \"wait\",\n\t/**\n\t * True if the request is coming from an IFluidHandle.\n\t */\n\tviaHandle = \"viaHandle\",\n\t/**\n\t * True if the request is coming from a handle with a pending payload.\n\t */\n\tpayloadPending = \"payloadPending\",\n}\n\n/**\n * Reads a blob from storage and parses it from JSON.\n *\n * @internal\n */\nexport type ReadAndParseBlob = <T>(id: string) => Promise<T>;\n\n/**\n * Fetches the sequence number of the snapshot tree by examining the protocol.\n * @param tree - snapshot tree to examine\n * @param readAndParseBlob - function to read blob contents from storage\n * and parse the result from JSON.\n * @internal\n */\nexport async function seqFromTree(\n\ttree: ISnapshotTree,\n\treadAndParseBlob: ReadAndParseBlob,\n): Promise<number> {\n\t// TODO why are we non null asserting here?\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst attributesHash = tree.trees[\".protocol\"]!.blobs.attributes!;\n\tconst attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);\n\treturn attrib.sequenceNumber;\n}\n\n/**\n * The following characters emulates the UTF-16 code sequence from 65 - 123, except for the `[` and `{`\n * positioned at 91 and 123 respectively - which are changed to '(' and ')'. Used in the `encodeCompactIdToString` utility below.\n * NOTE: The character set must never be changed - since it could result in collisions with existing ids.\n * If changing, make sure to choose new characters that have never been\n * used before, and the characters must not change their encoding with 'encodeURIComponent'.\n * @internal\n */\nexport const charSetForEncodingIds =\n\t\"ABCDEFGHIJKLMNOPQRSTUVWXYZ(abcdefghijklmnopqrstuvwxyz)0123456789\";\n\n/**\n * Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.\n * While this is the main usage pattern, it works with any non-negative integer or a string.\n * Strings are returned as is, and assumed to be UUIDs, i.e. unique enough to never overlap with\n * numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!\n * This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not\n * gaining any efficiency from having a number type.\n * We do not provide a decode function, so this API is only useful only result is stored and there is no need to go back to original form.\n * @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form\n * @param prefix - optional string prefix\n * @returns A string - representation of an input\n * @internal\n */\nexport function encodeCompactIdToString(idArg: number | string, prefix = \"\") {\n\tif (typeof idArg === \"string\") {\n\t\treturn idArg;\n\t}\n\n\t// WARNING: result of this function are stored in storage!\n\t// If you ever need to change this function, you will need to ensure that\n\t// for any inputs N1 & N2, old(N1) !== new(N2), where old() - is the old implementation,\n\t// and new() - is new implementation of encodeCompactIdToString()\n\t// This likely means - this function can't be changed, unless it uses some prefix that ensures\n\t// new values have zero overlap with old values.\n\t// Also resulting string can't contain \"/\", as that's disallowed by some users\n\t// (data store and DDS IDs can't have \"/\" in their IDs).\n\tassert(Number.isInteger(idArg) && idArg >= 0, 0x900 /* invalid input */);\n\tlet id = \"\";\n\tlet num = idArg;\n\tdo {\n\t\t// Here are some examples of the input & output:\n\t\t// 0 -> 'A'\n\t\t// 1 -> 'B'\n\t\t// 64 -> \"AA\"\n\t\t// 100 -> 'Aj'\n\t\t// 10000 -> 'BaQ'\n\t\t// 100000 -> 'XZf'\n\t\tconst encode = num % 64;\n\t\tid = charSetForEncodingIds[encode] + id;\n\t\tnum = Math.floor(num / 64) - 1;\n\t} while (num !== -1);\n\treturn prefix + id;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D;;;GAGG;AACH,MAAM,CAAN,IAAY,cAaX;AAbD,WAAY,cAAc;IACzB;;OAEG;IACH,+BAAa,CAAA;IACb;;OAEG;IACH,yCAAuB,CAAA;IACvB;;OAEG;IACH,mDAAiC,CAAA;AAClC,CAAC,EAbW,cAAc,KAAd,cAAc,QAazB;AASD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,IAAmB,EACnB,gBAAkC;IAElC,2CAA2C;IAC3C,oEAAoE;IACpE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAE,CAAC,KAAK,CAAC,UAAW,CAAC;IAClE,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAsB,cAAc,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,cAAc,CAAC;AAC9B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GACjC,kEAAkE,CAAC;AAEpE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAsB,EAAE,MAAM,GAAG,EAAE;IAC1E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,0DAA0D;IAC1D,yEAAyE;IACzE,wFAAwF;IACxF,iEAAiE;IACjE,8FAA8F;IAC9F,gDAAgD;IAChD,8EAA8E;IAC9E,wDAAwD;IACxD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzE,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,IAAI,GAAG,GAAG,KAAK,CAAC;IAChB,GAAG,CAAC;QACH,gDAAgD;QAChD,WAAW;QACX,WAAW;QACX,aAAa;QACb,cAAc;QACd,iBAAiB;QACjB,kBAAkB;QAClB,MAAM,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC;QACxB,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACxC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,EAAE;IACrB,OAAO,MAAM,GAAG,EAAE,CAAC;AACpB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIDocumentAttributes,\n\tISnapshotTree,\n} from \"@fluidframework/driver-definitions/internal\";\n\n/**\n * Accepted header keys for requests coming to the runtime.\n * @internal\n */\nexport enum RuntimeHeaders {\n\t/**\n\t * True to wait for a data store to be created and loaded before returning it.\n\t */\n\twait = \"wait\",\n\t/**\n\t * True if the request is coming from an IFluidHandle.\n\t */\n\tviaHandle = \"viaHandle\",\n\t/**\n\t * True if the request is coming from a handle with a pending payload.\n\t */\n\tpayloadPending = \"payloadPending\",\n}\n\n/**\n * Reads a blob from storage and parses it from JSON.\n *\n * @internal\n */\nexport type ReadAndParseBlob = <T>(id: string) => Promise<T>;\n\n/**\n * Fetches the sequence number of the snapshot tree by examining the protocol.\n * @param tree - snapshot tree to examine\n * @param readAndParseBlob - function to read blob contents from storage\n * and parse the result from JSON.\n * @internal\n */\nexport async function seqFromTree(\n\ttree: ISnapshotTree,\n\treadAndParseBlob: ReadAndParseBlob,\n): Promise<number> {\n\t// TODO why are we non null asserting here?\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst attributesHash = tree.trees[\".protocol\"]!.blobs.attributes!;\n\tconst attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);\n\treturn attrib.sequenceNumber;\n}\n\n/**\n * The following characters emulates the UTF-16 code sequence from 65 - 123, except for the `[` and `{`\n * positioned at 91 and 123 respectively - which are changed to '(' and ')'. Used in the `encodeCompactIdToString` utility below.\n * NOTE: The character set must never be changed - since it could result in collisions with existing ids.\n * If changing, make sure to choose new characters that have never been\n * used before, and the characters must not change their encoding with 'encodeURIComponent'.\n * @internal\n */\nexport const charSetForEncodingIds =\n\t\"ABCDEFGHIJKLMNOPQRSTUVWXYZ(abcdefghijklmnopqrstuvwxyz)0123456789\";\n\n/**\n * Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.\n * While this is the main usage pattern, it works with any non-negative integer or a string.\n * Strings are returned as is, and assumed to be UUIDs, i.e. unique enough to never overlap with\n * numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!\n * This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not\n * gaining any efficiency from having a number type.\n * We do not provide a decode function, so this API is only useful only result is stored and there is no need to go back to original form.\n * @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form\n * @param prefix - optional string prefix\n * @returns A string - representation of an input\n * @internal\n */\nexport function encodeCompactIdToString(idArg: number | string, prefix = \"\"): string {\n\tif (typeof idArg === \"string\") {\n\t\treturn idArg;\n\t}\n\n\t// WARNING: result of this function are stored in storage!\n\t// If you ever need to change this function, you will need to ensure that\n\t// for any inputs N1 & N2, old(N1) !== new(N2), where old() - is the old implementation,\n\t// and new() - is new implementation of encodeCompactIdToString()\n\t// This likely means - this function can't be changed, unless it uses some prefix that ensures\n\t// new values have zero overlap with old values.\n\t// Also resulting string can't contain \"/\", as that's disallowed by some users\n\t// (data store and DDS IDs can't have \"/\" in their IDs).\n\tassert(Number.isInteger(idArg) && idArg >= 0, 0x900 /* invalid input */);\n\tlet id = \"\";\n\tlet num = idArg;\n\tdo {\n\t\t// Here are some examples of the input & output:\n\t\t// 0 -> 'A'\n\t\t// 1 -> 'B'\n\t\t// 64 -> \"AA\"\n\t\t// 100 -> 'Aj'\n\t\t// 10000 -> 'BaQ'\n\t\t// 100000 -> 'XZf'\n\t\tconst encode = num % 64;\n\t\tid = charSetForEncodingIds[encode] + id;\n\t\tnum = Math.floor(num / 64) - 1;\n\t} while (num !== -1);\n\treturn prefix + id;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/runtime-utils",
3
- "version": "2.53.1",
3
+ "version": "2.61.0-355054",
4
4
  "description": "Collection of utility functions for Fluid Runtime",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -69,32 +69,32 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "~2.53.1",
73
- "@fluidframework/container-definitions": "~2.53.1",
74
- "@fluidframework/container-runtime-definitions": "~2.53.1",
75
- "@fluidframework/core-interfaces": "~2.53.1",
76
- "@fluidframework/core-utils": "~2.53.1",
77
- "@fluidframework/datastore-definitions": "~2.53.1",
78
- "@fluidframework/driver-definitions": "~2.53.1",
79
- "@fluidframework/driver-utils": "~2.53.1",
80
- "@fluidframework/runtime-definitions": "~2.53.1",
81
- "@fluidframework/telemetry-utils": "~2.53.1",
72
+ "@fluid-internal/client-utils": "2.61.0-355054",
73
+ "@fluidframework/container-definitions": "2.61.0-355054",
74
+ "@fluidframework/container-runtime-definitions": "2.61.0-355054",
75
+ "@fluidframework/core-interfaces": "2.61.0-355054",
76
+ "@fluidframework/core-utils": "2.61.0-355054",
77
+ "@fluidframework/datastore-definitions": "2.61.0-355054",
78
+ "@fluidframework/driver-definitions": "2.61.0-355054",
79
+ "@fluidframework/driver-utils": "2.61.0-355054",
80
+ "@fluidframework/runtime-definitions": "2.61.0-355054",
81
+ "@fluidframework/telemetry-utils": "2.61.0-355054",
82
82
  "semver-ts": "^1.0.3"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@arethetypeswrong/cli": "^0.17.1",
86
86
  "@biomejs/biome": "~1.9.3",
87
- "@fluid-internal/mocha-test-setup": "~2.53.1",
88
- "@fluid-tools/build-cli": "^0.57.0",
87
+ "@fluid-internal/mocha-test-setup": "2.61.0-355054",
88
+ "@fluid-tools/build-cli": "^0.58.2",
89
89
  "@fluidframework/build-common": "^2.0.3",
90
- "@fluidframework/build-tools": "^0.57.0",
91
- "@fluidframework/eslint-config-fluid": "^5.7.4",
92
- "@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.53.0",
93
- "@microsoft/api-extractor": "7.52.8",
90
+ "@fluidframework/build-tools": "^0.58.2",
91
+ "@fluidframework/eslint-config-fluid": "^6.0.0",
92
+ "@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.60.0",
93
+ "@microsoft/api-extractor": "7.52.11",
94
94
  "@types/mocha": "^10.0.10",
95
95
  "@types/node": "^18.19.0",
96
96
  "@types/sinon": "^17.0.3",
97
- "c8": "^8.0.1",
97
+ "c8": "^10.1.3",
98
98
  "concurrently": "^8.2.1",
99
99
  "copyfiles": "^2.4.1",
100
100
  "cross-env": "^7.0.3",
@@ -112,8 +112,8 @@
112
112
  },
113
113
  "scripts": {
114
114
  "api": "fluid-build . --task api",
115
- "api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
116
- "api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
115
+ "api-extractor:commonjs": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./dist",
116
+ "api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat",
117
117
  "build": "fluid-build . --task build",
118
118
  "build:api-reports": "concurrently \"npm:build:api-reports:*\"",
119
119
  "build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
@@ -149,8 +149,8 @@
149
149
  "test": "npm run test:mocha",
150
150
  "test:coverage": "c8 npm test",
151
151
  "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
152
- "test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\"",
153
- "test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\"",
152
+ "test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
153
+ "test:mocha:esm": "mocha",
154
154
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
155
155
  "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
156
156
  "typetests:gen": "flub generate typetests --dir . -v",
@@ -68,9 +68,7 @@ export type SemanticVersion =
68
68
  * @internal
69
69
  */
70
70
  export type ConfigMap<T extends Record<string, unknown>> = {
71
- [K in keyof T]-?: {
72
- [version: MinimumMinorSemanticVersion]: T[K];
73
- };
71
+ [K in keyof T]-?: Record<MinimumMinorSemanticVersion, T[K]>;
74
72
  };
75
73
 
76
74
  /**
@@ -94,6 +92,7 @@ export function getConfigsForMinVersionForCollab<T extends Record<SemanticVersio
94
92
  const defaultConfigs: Partial<T> = {};
95
93
  // Iterate over configMap to get default values for each option.
96
94
  for (const key of Object.keys(configMap)) {
95
+ // Type assertion is safe as key comes from Object.keys(configMap)
97
96
  const config = configMap[key as keyof T];
98
97
  // Sort the versions in ascending order so we can short circuit the loop.
99
98
  const versions = Object.keys(config).sort(compare);
@@ -102,6 +101,7 @@ export function getConfigsForMinVersionForCollab<T extends Record<SemanticVersio
102
101
  // value that is compatible with the version specified as the minVersionForCollab.
103
102
  for (const version of versions) {
104
103
  if (gte(minVersionForCollab, version)) {
104
+ // Type assertion is safe as version is a key from the config object
105
105
  defaultConfigs[key] = config[version as MinimumMinorSemanticVersion];
106
106
  } else {
107
107
  // If the minVersionForCollab is less than the version, we break out of the loop since we don't need to check
@@ -145,6 +145,7 @@ export function getValidationForRuntimeOptions<T extends Record<string, unknown>
145
145
  return;
146
146
  }
147
147
  // Iterate through each runtime option passed in by the user
148
+ // Type assertion is safe as entries come from runtimeOptions object
148
149
  for (const [passedRuntimeOption, passedRuntimeOptionValue] of Object.entries(
149
150
  runtimeOptions,
150
151
  ) as [keyof T & string, T[keyof T & string]][]) {
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IFluidHandleContext } from "@fluidframework/core-interfaces/internal";
6
+ import type { IFluidHandleContext } from "@fluidframework/core-interfaces/internal";
7
7
 
8
8
  /**
9
9
  * Generates the absolute path for a Fluid object given its path and its parent routeContext.