@fluidframework/runtime-utils 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.3.1.0.125672

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 (94) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
  5. package/dist/dataStoreHandleContextUtils.js +3 -1
  6. package/dist/dataStoreHandleContextUtils.js.map +1 -1
  7. package/dist/dataStoreHelpers.d.ts +3 -1
  8. package/dist/dataStoreHelpers.d.ts.map +1 -1
  9. package/dist/dataStoreHelpers.js +27 -8
  10. package/dist/dataStoreHelpers.js.map +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/objectstoragepartition.d.ts.map +1 -1
  14. package/dist/objectstoragepartition.js.map +1 -1
  15. package/dist/objectstorageutils.d.ts.map +1 -1
  16. package/dist/objectstorageutils.js.map +1 -1
  17. package/dist/packageVersion.d.ts +1 -1
  18. package/dist/packageVersion.js +1 -1
  19. package/dist/packageVersion.js.map +1 -1
  20. package/dist/requestParser.d.ts.map +1 -1
  21. package/dist/requestParser.js.map +1 -1
  22. package/dist/runtimeFactoryHelper.d.ts +1 -1
  23. package/dist/runtimeFactoryHelper.d.ts.map +1 -1
  24. package/dist/runtimeFactoryHelper.js +7 -6
  25. package/dist/runtimeFactoryHelper.js.map +1 -1
  26. package/dist/summarizerNode/summarizerNode.d.ts +1 -1
  27. package/dist/summarizerNode/summarizerNode.d.ts.map +1 -1
  28. package/dist/summarizerNode/summarizerNode.js +13 -4
  29. package/dist/summarizerNode/summarizerNode.js.map +1 -1
  30. package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  31. package/dist/summarizerNode/summarizerNodeUtils.js.map +1 -1
  32. package/dist/summarizerNode/summarizerNodeWithGc.d.ts +6 -2
  33. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  34. package/dist/summarizerNode/summarizerNodeWithGc.js +112 -26
  35. package/dist/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  36. package/dist/summaryUtils.d.ts.map +1 -1
  37. package/dist/summaryUtils.js +3 -2
  38. package/dist/summaryUtils.js.map +1 -1
  39. package/dist/utils.d.ts.map +1 -1
  40. package/dist/utils.js.map +1 -1
  41. package/lib/dataStoreHandleContextUtils.d.ts.map +1 -1
  42. package/lib/dataStoreHandleContextUtils.js +3 -1
  43. package/lib/dataStoreHandleContextUtils.js.map +1 -1
  44. package/lib/dataStoreHelpers.d.ts +3 -1
  45. package/lib/dataStoreHelpers.d.ts.map +1 -1
  46. package/lib/dataStoreHelpers.js +27 -8
  47. package/lib/dataStoreHelpers.js.map +1 -1
  48. package/lib/index.d.ts.map +1 -1
  49. package/lib/index.js.map +1 -1
  50. package/lib/objectstoragepartition.d.ts.map +1 -1
  51. package/lib/objectstoragepartition.js.map +1 -1
  52. package/lib/objectstorageutils.d.ts.map +1 -1
  53. package/lib/objectstorageutils.js.map +1 -1
  54. package/lib/packageVersion.d.ts +1 -1
  55. package/lib/packageVersion.js +1 -1
  56. package/lib/packageVersion.js.map +1 -1
  57. package/lib/requestParser.d.ts.map +1 -1
  58. package/lib/requestParser.js.map +1 -1
  59. package/lib/runtimeFactoryHelper.d.ts +1 -1
  60. package/lib/runtimeFactoryHelper.d.ts.map +1 -1
  61. package/lib/runtimeFactoryHelper.js +7 -6
  62. package/lib/runtimeFactoryHelper.js.map +1 -1
  63. package/lib/summarizerNode/summarizerNode.d.ts +1 -1
  64. package/lib/summarizerNode/summarizerNode.d.ts.map +1 -1
  65. package/lib/summarizerNode/summarizerNode.js +13 -4
  66. package/lib/summarizerNode/summarizerNode.js.map +1 -1
  67. package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  68. package/lib/summarizerNode/summarizerNodeUtils.js.map +1 -1
  69. package/lib/summarizerNode/summarizerNodeWithGc.d.ts +6 -2
  70. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  71. package/lib/summarizerNode/summarizerNodeWithGc.js +115 -29
  72. package/lib/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  73. package/lib/summaryUtils.d.ts.map +1 -1
  74. package/lib/summaryUtils.js +3 -2
  75. package/lib/summaryUtils.js.map +1 -1
  76. package/lib/utils.d.ts.map +1 -1
  77. package/lib/utils.js.map +1 -1
  78. package/package.json +20 -19
  79. package/prettier.config.cjs +1 -1
  80. package/src/dataStoreHandleContextUtils.ts +23 -16
  81. package/src/dataStoreHelpers.ts +104 -82
  82. package/src/index.ts +1 -1
  83. package/src/objectstoragepartition.ts +13 -13
  84. package/src/objectstorageutils.ts +31 -28
  85. package/src/packageVersion.ts +1 -1
  86. package/src/requestParser.ts +80 -82
  87. package/src/runtimeFactoryHelper.ts +24 -22
  88. package/src/summarizerNode/summarizerNode.ts +587 -549
  89. package/src/summarizerNode/summarizerNodeUtils.ts +146 -143
  90. package/src/summarizerNode/summarizerNodeWithGc.ts +508 -384
  91. package/src/summaryUtils.ts +299 -291
  92. package/src/utils.ts +6 -6
  93. package/tsconfig.esnext.json +6 -6
  94. package/tsconfig.json +8 -12
@@ -4,11 +4,7 @@
4
4
  */
5
5
 
6
6
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
- import {
8
- ISnapshotTree,
9
- ISummaryTree,
10
- SummaryObject,
11
- } from "@fluidframework/protocol-definitions";
7
+ import { ISnapshotTree, ISummaryTree, SummaryObject } from "@fluidframework/protocol-definitions";
12
8
  import { channelsTreeName, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
13
9
  import { ReadAndParseBlob } from "../utils";
14
10
 
@@ -22,114 +18,119 @@ import { ReadAndParseBlob } from "../utils";
22
18
  * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this case, the
23
19
  * latest summary is updated based on the downloaded snapshot which is also returned.
24
20
  */
25
- export type RefreshSummaryResult = {
26
- latestSummaryUpdated: false;
27
- } | {
28
- latestSummaryUpdated: true;
29
- wasSummaryTracked: true;
30
- } | {
31
- latestSummaryUpdated: true;
32
- wasSummaryTracked: false;
33
- snapshot: ISnapshotTree;
34
- };
21
+ export type RefreshSummaryResult =
22
+ | {
23
+ latestSummaryUpdated: false;
24
+ }
25
+ | {
26
+ latestSummaryUpdated: true;
27
+ wasSummaryTracked: true;
28
+ }
29
+ | {
30
+ latestSummaryUpdated: true;
31
+ wasSummaryTracked: false;
32
+ snapshot: ISnapshotTree;
33
+ };
35
34
 
36
35
  export interface ISummarizerNodeRootContract {
37
- startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger): void;
38
- completeSummary(proposalHandle: string): void;
39
- clearSummary(): void;
40
- refreshLatestSummary(
41
- proposalHandle: string | undefined,
42
- summaryRefSeq: number,
43
- getSnapshot: () => Promise<ISnapshotTree>,
44
- readAndParseBlob: ReadAndParseBlob,
45
- correlatedSummaryLogger: ITelemetryLogger,
46
- ): Promise<RefreshSummaryResult>;
36
+ startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger): void;
37
+ completeSummary(proposalHandle: string): void;
38
+ clearSummary(): void;
39
+ refreshLatestSummary(
40
+ proposalHandle: string | undefined,
41
+ summaryRefSeq: number,
42
+ getSnapshot: () => Promise<ISnapshotTree>,
43
+ readAndParseBlob: ReadAndParseBlob,
44
+ correlatedSummaryLogger: ITelemetryLogger,
45
+ ): Promise<RefreshSummaryResult>;
47
46
  }
48
47
 
49
48
  /** Path for nodes in a tree with escaped special characters */
50
49
  export class EscapedPath {
51
- private constructor(public readonly path: string) { }
52
- public static create(path: string): EscapedPath {
53
- return new EscapedPath(encodeURIComponent(path));
54
- }
55
- public static createAndConcat(pathParts: string[]): EscapedPath {
56
- let ret = EscapedPath.create(pathParts[0] ?? "");
57
- for (let i = 1; i < pathParts.length; i++) {
58
- ret = ret.concat(EscapedPath.create(pathParts[i]));
59
- }
60
- return ret;
61
- }
62
- public toString(): string {
63
- return this.path;
64
- }
65
- public concat(path: EscapedPath): EscapedPath {
66
- return new EscapedPath(`${this.path}/${path.path}`);
67
- }
50
+ private constructor(public readonly path: string) {}
51
+ public static create(path: string): EscapedPath {
52
+ return new EscapedPath(encodeURIComponent(path));
53
+ }
54
+ public static createAndConcat(pathParts: string[]): EscapedPath {
55
+ let ret = EscapedPath.create(pathParts[0] ?? "");
56
+ for (let i = 1; i < pathParts.length; i++) {
57
+ ret = ret.concat(EscapedPath.create(pathParts[i]));
58
+ }
59
+ return ret;
60
+ }
61
+ public toString(): string {
62
+ return this.path;
63
+ }
64
+ public concat(path: EscapedPath): EscapedPath {
65
+ return new EscapedPath(`${this.path}/${path.path}`);
66
+ }
68
67
  }
69
68
 
70
69
  /** Information about a summary relevant to a specific node in the tree */
71
70
  export class SummaryNode {
72
- /** Creates an instance that is valid for the root with specific basePath and localPath */
73
- public static createForRoot(referenceSequenceNumber: number): SummaryNode {
74
- return new SummaryNode({
75
- referenceSequenceNumber,
76
- basePath: undefined,
77
- localPath: EscapedPath.create(""), // root hard-coded to ""
78
- });
79
- }
71
+ /** Creates an instance that is valid for the root with specific basePath and localPath */
72
+ public static createForRoot(referenceSequenceNumber: number): SummaryNode {
73
+ return new SummaryNode({
74
+ referenceSequenceNumber,
75
+ basePath: undefined,
76
+ localPath: EscapedPath.create(""), // root hard-coded to ""
77
+ });
78
+ }
80
79
 
81
- /** Summary reference sequence number, i.e. last sequence number seen when it was created */
82
- public get referenceSequenceNumber(): number {
83
- return this.summary.referenceSequenceNumber;
84
- }
85
- /** Full path to parent node, or undefined if this is the root */
86
- public get basePath(): EscapedPath | undefined {
87
- return this.summary.basePath;
88
- }
89
- /** Relative path to this node from its parent node */
90
- public get localPath(): EscapedPath {
91
- return this.summary.localPath;
92
- }
93
- /** Relative path from this node to its node innermost base summary */
94
- public get additionalPath(): EscapedPath | undefined {
95
- return this.summary.additionalPath;
96
- }
97
- public set additionalPath(additionalPath: EscapedPath | undefined) {
98
- this.summary.additionalPath = additionalPath;
99
- }
100
- constructor(private readonly summary: {
101
- readonly referenceSequenceNumber: number;
102
- readonly basePath: EscapedPath | undefined;
103
- readonly localPath: EscapedPath;
104
- additionalPath?: EscapedPath;
105
- }) { }
80
+ /** Summary reference sequence number, i.e. last sequence number seen when it was created */
81
+ public get referenceSequenceNumber(): number {
82
+ return this.summary.referenceSequenceNumber;
83
+ }
84
+ /** Full path to parent node, or undefined if this is the root */
85
+ public get basePath(): EscapedPath | undefined {
86
+ return this.summary.basePath;
87
+ }
88
+ /** Relative path to this node from its parent node */
89
+ public get localPath(): EscapedPath {
90
+ return this.summary.localPath;
91
+ }
92
+ /** Relative path from this node to its node innermost base summary */
93
+ public get additionalPath(): EscapedPath | undefined {
94
+ return this.summary.additionalPath;
95
+ }
96
+ public set additionalPath(additionalPath: EscapedPath | undefined) {
97
+ this.summary.additionalPath = additionalPath;
98
+ }
99
+ constructor(
100
+ private readonly summary: {
101
+ readonly referenceSequenceNumber: number;
102
+ readonly basePath: EscapedPath | undefined;
103
+ readonly localPath: EscapedPath;
104
+ additionalPath?: EscapedPath;
105
+ },
106
+ ) {}
106
107
 
107
- /** Gets the full path to this node, to be used when sending a handle */
108
- public get fullPath(): EscapedPath {
109
- return this.basePath?.concat(this.localPath) ?? this.localPath;
110
- }
108
+ /** Gets the full path to this node, to be used when sending a handle */
109
+ public get fullPath(): EscapedPath {
110
+ return this.basePath?.concat(this.localPath) ?? this.localPath;
111
+ }
111
112
 
112
- /**
113
- * Gets the full path to this node's innermost base summary.
114
- * The children nodes can use this as their basePath to determine their path.
115
- */
116
- public get fullPathForChildren(): EscapedPath {
117
- return this.additionalPath !== undefined
118
- ? this.fullPath.concat(this.additionalPath)
119
- : this.fullPath;
120
- }
113
+ /**
114
+ * Gets the full path to this node's innermost base summary.
115
+ * The children nodes can use this as their basePath to determine their path.
116
+ */
117
+ public get fullPathForChildren(): EscapedPath {
118
+ return this.additionalPath !== undefined
119
+ ? this.fullPath.concat(this.additionalPath)
120
+ : this.fullPath;
121
+ }
121
122
 
122
- /**
123
- * Creates a new node within the same summary for a child of this node.
124
- * @param id - id of the child node
125
- */
126
- public createForChild(id: string): SummaryNode {
127
- return new SummaryNode({
128
- referenceSequenceNumber: this.referenceSequenceNumber,
129
- basePath: this.fullPathForChildren,
130
- localPath: EscapedPath.create(id),
131
- });
132
- }
123
+ /**
124
+ * Creates a new node within the same summary for a child of this node.
125
+ * @param id - id of the child node
126
+ */
127
+ public createForChild(id: string): SummaryNode {
128
+ return new SummaryNode({
129
+ referenceSequenceNumber: this.referenceSequenceNumber,
130
+ basePath: this.fullPathForChildren,
131
+ localPath: EscapedPath.create(id),
132
+ });
133
+ }
133
134
  }
134
135
 
135
136
  /**
@@ -139,40 +140,42 @@ export class SummaryNode {
139
140
  * When fromSummary is false, it will use an actual summary tree
140
141
  * as its base summary in case the first summary is a differential summary.
141
142
  */
142
- export type EncodeSummaryParam = {
143
- fromSummary: true;
144
- summaryNode: SummaryNode;
145
- } | {
146
- fromSummary: false;
147
- initialSummary: ISummaryTreeWithStats;
148
- };
143
+ export type EncodeSummaryParam =
144
+ | {
145
+ fromSummary: true;
146
+ summaryNode: SummaryNode;
147
+ }
148
+ | {
149
+ fromSummary: false;
150
+ initialSummary: ISummaryTreeWithStats;
151
+ };
149
152
 
150
153
  /**
151
154
  * Information about the initial summary tree found from an attach op.
152
155
  */
153
156
  export interface IInitialSummary {
154
- sequenceNumber: number;
155
- id: string;
156
- summary: ISummaryTreeWithStats | undefined;
157
+ sequenceNumber: number;
158
+ id: string;
159
+ summary: ISummaryTreeWithStats | undefined;
157
160
  }
158
161
 
159
162
  /**
160
163
  * Represents the details needed to create a child summarizer node.
161
164
  */
162
165
  export interface ICreateChildDetails {
163
- /** Summary from attach op if known */
164
- initialSummary: IInitialSummary | undefined;
165
- /** Latest summary from server node data */
166
- latestSummary: SummaryNode | undefined;
167
- /** Sequence number of latest known change to the node */
168
- changeSequenceNumber: number;
166
+ /** Summary from attach op if known */
167
+ initialSummary: IInitialSummary | undefined;
168
+ /** Latest summary from server node data */
169
+ latestSummary: SummaryNode | undefined;
170
+ /** Sequence number of latest known change to the node */
171
+ changeSequenceNumber: number;
169
172
  }
170
173
 
171
174
  export interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {
172
- /** Tree to use to find children subtrees */
173
- childrenTree: T;
174
- /** Additional path part where children are isolated */
175
- childrenPathPart: string | undefined;
175
+ /** Tree to use to find children subtrees */
176
+ childrenTree: T;
177
+ /** Additional path part where children are isolated */
178
+ childrenPathPart: string | undefined;
176
179
  }
177
180
 
178
181
  /**
@@ -181,18 +184,18 @@ export interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {
181
184
  * @param baseSummary - summary to check
182
185
  */
183
186
  export function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISubtreeInfo<ISnapshotTree> {
184
- // New versions of snapshots have child nodes isolated in .channels subtree
185
- const channelsSubtree = baseSummary.trees[channelsTreeName];
186
- if (channelsSubtree !== undefined) {
187
- return {
188
- childrenTree: channelsSubtree,
189
- childrenPathPart: channelsTreeName,
190
- };
191
- }
192
- return {
193
- childrenTree: baseSummary,
194
- childrenPathPart: undefined,
195
- };
187
+ // New versions of snapshots have child nodes isolated in .channels subtree
188
+ const channelsSubtree = baseSummary.trees[channelsTreeName];
189
+ if (channelsSubtree !== undefined) {
190
+ return {
191
+ childrenTree: channelsSubtree,
192
+ childrenPathPart: channelsTreeName,
193
+ };
194
+ }
195
+ return {
196
+ childrenTree: baseSummary,
197
+ childrenPathPart: undefined,
198
+ };
196
199
  }
197
200
 
198
201
  /**
@@ -201,16 +204,16 @@ export function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISubtreeInf
201
204
  * @param baseSummary - summary to check
202
205
  */
203
206
  export function parseSummaryTreeForSubtrees(summary: ISummaryTree): ISubtreeInfo<SummaryObject> {
204
- // New versions of snapshots have child nodes isolated in .channels subtree
205
- const channelsSubtree = summary.tree[channelsTreeName];
206
- if (channelsSubtree !== undefined) {
207
- return {
208
- childrenTree: channelsSubtree,
209
- childrenPathPart: channelsTreeName,
210
- };
211
- }
212
- return {
213
- childrenTree: summary,
214
- childrenPathPart: undefined,
215
- };
207
+ // New versions of snapshots have child nodes isolated in .channels subtree
208
+ const channelsSubtree = summary.tree[channelsTreeName];
209
+ if (channelsSubtree !== undefined) {
210
+ return {
211
+ childrenTree: channelsSubtree,
212
+ childrenPathPart: channelsTreeName,
213
+ };
214
+ }
215
+ return {
216
+ childrenTree: summary,
217
+ childrenPathPart: undefined,
218
+ };
216
219
  }