@fluidframework/runtime-utils 0.59.4002 → 1.0.2

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 (47) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/objectstorageutils.d.ts +1 -1
  3. package/dist/objectstorageutils.d.ts.map +1 -1
  4. package/dist/objectstorageutils.js +7 -6
  5. package/dist/objectstorageutils.js.map +1 -1
  6. package/dist/packageVersion.d.ts +1 -1
  7. package/dist/packageVersion.d.ts.map +1 -1
  8. package/dist/packageVersion.js +1 -1
  9. package/dist/packageVersion.js.map +1 -1
  10. package/dist/summarizerNode/summarizerNode.d.ts +5 -5
  11. package/dist/summarizerNode/summarizerNode.d.ts.map +1 -1
  12. package/dist/summarizerNode/summarizerNode.js +2 -2
  13. package/dist/summarizerNode/summarizerNode.js.map +1 -1
  14. package/dist/summarizerNode/summarizerNodeWithGc.d.ts +5 -5
  15. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  16. package/dist/summarizerNode/summarizerNodeWithGc.js +4 -2
  17. package/dist/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  18. package/dist/summaryUtils.d.ts +17 -1
  19. package/dist/summaryUtils.d.ts.map +1 -1
  20. package/dist/summaryUtils.js +25 -1
  21. package/dist/summaryUtils.js.map +1 -1
  22. package/lib/objectstorageutils.d.ts +1 -1
  23. package/lib/objectstorageutils.d.ts.map +1 -1
  24. package/lib/objectstorageutils.js +7 -6
  25. package/lib/objectstorageutils.js.map +1 -1
  26. package/lib/packageVersion.d.ts +1 -1
  27. package/lib/packageVersion.d.ts.map +1 -1
  28. package/lib/packageVersion.js +1 -1
  29. package/lib/packageVersion.js.map +1 -1
  30. package/lib/summarizerNode/summarizerNode.d.ts +5 -5
  31. package/lib/summarizerNode/summarizerNode.d.ts.map +1 -1
  32. package/lib/summarizerNode/summarizerNode.js +2 -2
  33. package/lib/summarizerNode/summarizerNode.js.map +1 -1
  34. package/lib/summarizerNode/summarizerNodeWithGc.d.ts +5 -5
  35. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  36. package/lib/summarizerNode/summarizerNodeWithGc.js +4 -2
  37. package/lib/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  38. package/lib/summaryUtils.d.ts +17 -1
  39. package/lib/summaryUtils.d.ts.map +1 -1
  40. package/lib/summaryUtils.js +23 -0
  41. package/lib/summaryUtils.js.map +1 -1
  42. package/package.json +12 -25
  43. package/src/objectstorageutils.ts +10 -8
  44. package/src/packageVersion.ts +1 -1
  45. package/src/summarizerNode/summarizerNode.ts +11 -6
  46. package/src/summarizerNode/summarizerNodeWithGc.ts +17 -5
  47. package/src/summaryUtils.ts +27 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/runtime-utils",
3
- "version": "0.59.4002",
3
+ "version": "1.0.2",
4
4
  "description": "Collection of utility functions for Fluid Runtime",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -62,43 +62,30 @@
62
62
  "dependencies": {
63
63
  "@fluidframework/common-definitions": "^0.20.1",
64
64
  "@fluidframework/common-utils": "^0.32.1",
65
- "@fluidframework/container-definitions": "^0.48.2000",
66
- "@fluidframework/container-runtime-definitions": "^0.59.4002",
67
- "@fluidframework/core-interfaces": "^0.43.1000",
68
- "@fluidframework/datastore-definitions": "^0.59.4002",
69
- "@fluidframework/garbage-collector": "^0.59.4002",
65
+ "@fluidframework/container-definitions": "^1.0.2",
66
+ "@fluidframework/container-runtime-definitions": "^1.0.2",
67
+ "@fluidframework/core-interfaces": "^1.0.2",
68
+ "@fluidframework/datastore-definitions": "^1.0.2",
69
+ "@fluidframework/garbage-collector": "^1.0.2",
70
70
  "@fluidframework/protocol-base": "^0.1036.4000",
71
71
  "@fluidframework/protocol-definitions": "^0.1028.2000",
72
- "@fluidframework/runtime-definitions": "^0.59.4002",
73
- "@fluidframework/telemetry-utils": "^0.59.4002"
72
+ "@fluidframework/runtime-definitions": "^1.0.2",
73
+ "@fluidframework/telemetry-utils": "^1.0.2"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@fluidframework/build-common": "^0.23.0",
77
- "@fluidframework/build-tools": "^0.2.70857",
77
+ "@fluidframework/build-tools": "^0.2.71273",
78
78
  "@fluidframework/eslint-config-fluid": "^0.28.2000",
79
- "@fluidframework/mocha-test-setup": "^0.59.4002",
80
- "@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@0.59.4001",
79
+ "@fluidframework/mocha-test-setup": "^1.0.2",
80
+ "@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@^0.59.0",
81
81
  "@microsoft/api-extractor": "^7.22.2",
82
82
  "@rushstack/eslint-config": "^2.5.1",
83
83
  "@types/mocha": "^9.1.1",
84
84
  "@types/node": "^14.18.0",
85
- "@typescript-eslint/eslint-plugin": "~5.9.0",
86
- "@typescript-eslint/parser": "~5.9.0",
87
85
  "concurrently": "^6.2.0",
88
86
  "copyfiles": "^2.1.0",
89
87
  "cross-env": "^7.0.2",
90
88
  "eslint": "~8.6.0",
91
- "eslint-plugin-editorconfig": "~3.2.0",
92
- "eslint-plugin-eslint-comments": "~3.2.0",
93
- "eslint-plugin-import": "~2.25.4",
94
- "eslint-plugin-jest": "~26.1.3",
95
- "eslint-plugin-jsdoc": "~39.3.0",
96
- "eslint-plugin-mocha": "~10.0.3",
97
- "eslint-plugin-promise": "~6.0.0",
98
- "eslint-plugin-react": "~7.28.0",
99
- "eslint-plugin-tsdoc": "~0.2.14",
100
- "eslint-plugin-unicorn": "~40.0.0",
101
- "eslint-plugin-unused-imports": "~2.0.0",
102
89
  "mocha": "^10.0.0",
103
90
  "nyc": "^15.0.0",
104
91
  "rimraf": "^2.6.2",
@@ -108,7 +95,7 @@
108
95
  "typescript-formatter": "7.1.0"
109
96
  },
110
97
  "typeValidation": {
111
- "version": "0.59.4002",
98
+ "version": "1.0.0",
112
99
  "broken": {}
113
100
  }
114
101
  }
@@ -19,24 +19,26 @@ export function getNormalizedObjectStoragePathParts(path: string) {
19
19
  return [];
20
20
  }
21
21
 
22
- export async function listBlobsAtTreePath(inputTree: ITree, path: string): Promise<string[]> {
22
+ export async function listBlobsAtTreePath(inputTree: ITree | undefined, path: string): Promise<string[]> {
23
23
  const pathParts = getNormalizedObjectStoragePathParts(path);
24
24
  let tree: ITree | undefined = inputTree;
25
25
  while (tree?.entries !== undefined && pathParts.length > 0) {
26
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
27
- const part = pathParts.shift()!;
28
- const index = tree.entries.findIndex((value) => {
26
+ const part = pathParts.shift();
27
+ const treeEntry = tree.entries.find((value) => {
29
28
  if (value.type === "Tree" && value.path === part) {
30
29
  return true;
31
30
  } else {
32
31
  return false;
33
32
  }
34
33
  });
35
- if (index === -1) {
36
- tree = undefined;
37
- } else {
38
- const treeEntry = tree.entries[index];
34
+
35
+ // this check is largely superfluous due to the same check being done
36
+ // immediately above. the type system, however, is not aware of this.
37
+ // so we must redundantly determine that the entry's type is "Tree"
38
+ if (treeEntry?.type === "Tree") {
39
39
  tree = treeEntry.value;
40
+ } else {
41
+ tree = undefined;
40
42
  }
41
43
  }
42
44
  if (tree?.entries === undefined || pathParts.length !== 0) {
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/runtime-utils";
9
- export const pkgVersion = "0.59.4002";
9
+ export const pkgVersion = "1.0.2";
@@ -6,11 +6,12 @@
6
6
  import {
7
7
  ISummarizerNode,
8
8
  ISummarizerNodeConfig,
9
- ISummarizeInternalResult,
10
9
  ISummarizeResult,
11
10
  ISummaryTreeWithStats,
12
11
  CreateChildSummarizerNodeParam,
13
12
  CreateSummarizerNodeSource,
13
+ SummarizeInternalFn,
14
+ ITelemetryContext,
14
15
  } from "@fluidframework/runtime-definitions";
15
16
  import {
16
17
  ISequencedDocumentMessage,
@@ -80,7 +81,11 @@ export class SummarizerNode implements IRootSummarizerNode {
80
81
  this.wipReferenceSequenceNumber = referenceSequenceNumber;
81
82
  }
82
83
 
83
- public async summarize(fullTree: boolean): Promise<ISummarizeResult> {
84
+ public async summarize(
85
+ fullTree: boolean,
86
+ trackState: boolean = true,
87
+ telemetryContext?: ITelemetryContext,
88
+ ): Promise<ISummarizeResult> {
84
89
  assert(this.isTrackingInProgress(), 0x1a1 /* "summarize should not be called when not tracking the summary" */);
85
90
  assert(this.wipSummaryLogger !== undefined,
86
91
  0x1a2 /* "wipSummaryLogger should have been set in startSummary or ctor" */);
@@ -108,7 +113,7 @@ export class SummarizerNode implements IRootSummarizerNode {
108
113
  }
109
114
 
110
115
  try {
111
- const result = await this.summarizeInternalFn(fullTree);
116
+ const result = await this.summarizeInternalFn(fullTree, true, telemetryContext);
112
117
  this.wipLocalPaths = { localPath: EscapedPath.create(result.id) };
113
118
  if (result.pathPartsForChildren !== undefined) {
114
119
  this.wipLocalPaths.additionalPath = EscapedPath.createAndConcat(result.pathPartsForChildren);
@@ -469,7 +474,7 @@ export class SummarizerNode implements IRootSummarizerNode {
469
474
  */
470
475
  public constructor(
471
476
  protected readonly defaultLogger: ITelemetryLogger,
472
- private readonly summarizeInternalFn: (fullTree: boolean) => Promise<ISummarizeInternalResult>,
477
+ private readonly summarizeInternalFn: SummarizeInternalFn,
473
478
  config: ISummarizerNodeConfig,
474
479
  private _changeSequenceNumber: number,
475
480
  /** Undefined means created without summary */
@@ -487,7 +492,7 @@ export class SummarizerNode implements IRootSummarizerNode {
487
492
 
488
493
  public createChild(
489
494
  /** Summarize function */
490
- summarizeInternalFn: (fullTree: boolean) => Promise<ISummarizeInternalResult>,
495
+ summarizeInternalFn: SummarizeInternalFn,
491
496
  /** Initial id or path part of this node */
492
497
  id: string,
493
498
  /**
@@ -644,7 +649,7 @@ export class SummarizerNode implements IRootSummarizerNode {
644
649
  */
645
650
  export const createRootSummarizerNode = (
646
651
  logger: ITelemetryLogger,
647
- summarizeInternalFn: (fullTree: boolean) => Promise<ISummarizeInternalResult>,
652
+ summarizeInternalFn: SummarizeInternalFn,
648
653
  changeSequenceNumber: number,
649
654
  referenceSequenceNumber: number | undefined,
650
655
  config: ISummarizerNodeConfig = {},
@@ -17,6 +17,8 @@ import {
17
17
  ISummarizeResult,
18
18
  ISummarizerNodeConfigWithGC,
19
19
  ISummarizerNodeWithGC,
20
+ SummarizeInternalFn,
21
+ ITelemetryContext,
20
22
  } from "@fluidframework/runtime-definitions";
21
23
  import { ReadAndParseBlob } from "../utils";
22
24
  import { SummarizerNode } from "./summarizerNode";
@@ -86,7 +88,11 @@ export class SummarizerNodeWithGC extends SummarizerNode implements IRootSummari
86
88
  */
87
89
  public constructor(
88
90
  logger: ITelemetryLogger,
89
- private readonly summarizeFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,
91
+ private readonly summarizeFn: (
92
+ fullTree: boolean,
93
+ trackState: boolean,
94
+ telemetryContext?: ITelemetryContext,
95
+ ) => Promise<ISummarizeInternalResult>,
90
96
  config: ISummarizerNodeConfigWithGC,
91
97
  changeSequenceNumber: number,
92
98
  /** Undefined means created without summary */
@@ -155,7 +161,11 @@ export class SummarizerNodeWithGC extends SummarizerNode implements IRootSummari
155
161
  this.unreferencedTimestampMs = baseGCDetails.unrefTimestamp;
156
162
  }
157
163
 
158
- public async summarize(fullTree: boolean, trackState: boolean = true): Promise<ISummarizeResult> {
164
+ public async summarize(
165
+ fullTree: boolean,
166
+ trackState: boolean = true,
167
+ telemetryContext?: ITelemetryContext,
168
+ ): Promise<ISummarizeResult> {
159
169
  // If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this
160
170
  // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.
161
171
  if (!this.gcDisabled && this.isTrackingInProgress()) {
@@ -165,7 +175,9 @@ export class SummarizerNodeWithGC extends SummarizerNode implements IRootSummari
165
175
 
166
176
  // If trackState is true, get summary from base summarizer node which tracks summary state.
167
177
  // If trackState is false, get summary from summarizeInternal.
168
- return trackState ? super.summarize(fullTree) : this.summarizeFn(fullTree, trackState);
178
+ return trackState
179
+ ? super.summarize(fullTree, true /* trackState */, telemetryContext)
180
+ : this.summarizeFn(fullTree, trackState, telemetryContext);
169
181
  }
170
182
 
171
183
  /**
@@ -304,7 +316,7 @@ export class SummarizerNodeWithGC extends SummarizerNode implements IRootSummari
304
316
  */
305
317
  public createChild(
306
318
  /** Summarize function */
307
- summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,
319
+ summarizeInternalFn: SummarizeInternalFn,
308
320
  /** Initial id or path part of this node */
309
321
  id: string,
310
322
  /**
@@ -427,7 +439,7 @@ export class SummarizerNodeWithGC extends SummarizerNode implements IRootSummari
427
439
  */
428
440
  export const createRootSummarizerNodeWithGC = (
429
441
  logger: ITelemetryLogger,
430
- summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,
442
+ summarizeInternalFn: SummarizeInternalFn,
431
443
  changeSequenceNumber: number,
432
444
  referenceSequenceNumber: number | undefined,
433
445
  config: ISummarizerNodeConfigWithGC = {},
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { TelemetryEventPropertyType } from "@fluidframework/common-definitions";
6
7
  import {
7
8
  bufferToString,
8
9
  fromBase64ToUtf8,
@@ -25,6 +26,7 @@ import {
25
26
  ISummaryStats,
26
27
  ISummarizeResult,
27
28
  ISummaryTreeWithStats,
29
+ ITelemetryContext,
28
30
  } from "@fluidframework/runtime-definitions";
29
31
 
30
32
  /**
@@ -342,3 +344,28 @@ export function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {
342
344
  unreferenced: summaryTree.unreferenced,
343
345
  };
344
346
  }
347
+
348
+ export class TelemetryContext implements ITelemetryContext {
349
+ private readonly telemetry = new Map<string, TelemetryEventPropertyType>();
350
+
351
+ /**
352
+ * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}
353
+ */
354
+ set(prefix: string, property: string, value: TelemetryEventPropertyType): void {
355
+ this.telemetry.set(`${prefix}${property}`, value);
356
+ }
357
+
358
+ /**
359
+ * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}
360
+ */
361
+ get(prefix: string, property: string): TelemetryEventPropertyType {
362
+ return this.telemetry.get(`${prefix}${property}`);
363
+ }
364
+
365
+ /**
366
+ * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}
367
+ */
368
+ serialize(): string {
369
+ return JSON.stringify(this.telemetry);
370
+ }
371
+ }