@fluidframework/runtime-utils 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419

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 (187) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +191 -0
  4. package/README.md +68 -1
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/runtime-utils.api.md +201 -0
  8. package/dist/{dataStoreHandleContextUtils.js → dataStoreHandleContextUtils.cjs} +5 -2
  9. package/dist/dataStoreHandleContextUtils.cjs.map +1 -0
  10. package/dist/dataStoreHandleContextUtils.d.ts +1 -0
  11. package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
  12. package/dist/{dataStoreHelpers.js → dataStoreHelpers.cjs} +44 -25
  13. package/dist/dataStoreHelpers.cjs.map +1 -0
  14. package/dist/dataStoreHelpers.d.ts +23 -4
  15. package/dist/dataStoreHelpers.d.ts.map +1 -1
  16. package/dist/index.cjs +44 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.ts +9 -9
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/{objectstoragepartition.js → objectstoragepartition.cjs} +4 -3
  21. package/dist/objectstoragepartition.cjs.map +1 -0
  22. package/dist/objectstoragepartition.d.ts +1 -0
  23. package/dist/objectstoragepartition.d.ts.map +1 -1
  24. package/dist/{objectstorageutils.js → objectstorageutils.cjs} +11 -15
  25. package/dist/objectstorageutils.cjs.map +1 -0
  26. package/dist/objectstorageutils.d.ts +6 -0
  27. package/dist/objectstorageutils.d.ts.map +1 -1
  28. package/dist/{requestParser.js → requestParser.cjs} +7 -11
  29. package/dist/requestParser.cjs.map +1 -0
  30. package/dist/requestParser.d.ts +1 -0
  31. package/dist/requestParser.d.ts.map +1 -1
  32. package/dist/runtime-utils-alpha.d.ts +155 -0
  33. package/dist/runtime-utils-beta.d.ts +103 -0
  34. package/dist/runtime-utils-public.d.ts +103 -0
  35. package/dist/runtime-utils-untrimmed.d.ts +306 -0
  36. package/dist/{runtimeFactoryHelper.js → runtimeFactoryHelper.cjs} +11 -12
  37. package/dist/runtimeFactoryHelper.cjs.map +1 -0
  38. package/dist/runtimeFactoryHelper.d.ts +4 -1
  39. package/dist/runtimeFactoryHelper.d.ts.map +1 -1
  40. package/dist/{summaryUtils.js → summaryUtils.cjs} +138 -34
  41. package/dist/summaryUtils.cjs.map +1 -0
  42. package/dist/summaryUtils.d.ts +66 -4
  43. package/dist/summaryUtils.d.ts.map +1 -1
  44. package/dist/tsdoc-metadata.json +11 -0
  45. package/dist/unpackUsedRoutes.cjs +34 -0
  46. package/dist/unpackUsedRoutes.cjs.map +1 -0
  47. package/dist/unpackUsedRoutes.d.ts +12 -0
  48. package/dist/unpackUsedRoutes.d.ts.map +1 -0
  49. package/dist/{utils.js → utils.cjs} +2 -1
  50. package/dist/utils.cjs.map +1 -0
  51. package/dist/utils.d.ts +7 -2
  52. package/dist/utils.d.ts.map +1 -1
  53. package/lib/{dataStoreHandleContextUtils.d.ts → dataStoreHandleContextUtils.d.mts} +1 -0
  54. package/lib/dataStoreHandleContextUtils.d.mts.map +1 -0
  55. package/lib/{dataStoreHandleContextUtils.js → dataStoreHandleContextUtils.mjs} +5 -2
  56. package/lib/dataStoreHandleContextUtils.mjs.map +1 -0
  57. package/lib/{dataStoreHelpers.d.ts → dataStoreHelpers.d.mts} +23 -4
  58. package/lib/dataStoreHelpers.d.mts.map +1 -0
  59. package/lib/{dataStoreHelpers.js → dataStoreHelpers.mjs} +42 -22
  60. package/lib/dataStoreHelpers.mjs.map +1 -0
  61. package/lib/index.d.mts +14 -0
  62. package/lib/index.d.mts.map +1 -0
  63. package/lib/index.mjs +14 -0
  64. package/lib/index.mjs.map +1 -0
  65. package/lib/{objectstoragepartition.d.ts → objectstoragepartition.d.mts} +1 -0
  66. package/lib/objectstoragepartition.d.mts.map +1 -0
  67. package/lib/{objectstoragepartition.js → objectstoragepartition.mjs} +3 -2
  68. package/lib/objectstoragepartition.mjs.map +1 -0
  69. package/lib/{objectstorageutils.d.ts → objectstorageutils.d.mts} +6 -0
  70. package/lib/objectstorageutils.d.mts.map +1 -0
  71. package/lib/{objectstorageutils.js → objectstorageutils.mjs} +11 -15
  72. package/lib/objectstorageutils.mjs.map +1 -0
  73. package/lib/{requestParser.d.ts → requestParser.d.mts} +1 -4
  74. package/lib/requestParser.d.mts.map +1 -0
  75. package/lib/{requestParser.js → requestParser.mjs} +7 -11
  76. package/lib/requestParser.mjs.map +1 -0
  77. package/lib/runtime-utils-alpha.d.mts +155 -0
  78. package/lib/runtime-utils-beta.d.mts +103 -0
  79. package/lib/runtime-utils-public.d.mts +103 -0
  80. package/lib/runtime-utils-untrimmed.d.mts +306 -0
  81. package/lib/{runtimeFactoryHelper.d.ts → runtimeFactoryHelper.d.mts} +4 -1
  82. package/lib/runtimeFactoryHelper.d.mts.map +1 -0
  83. package/lib/runtimeFactoryHelper.mjs +24 -0
  84. package/lib/runtimeFactoryHelper.mjs.map +1 -0
  85. package/lib/{summaryUtils.d.ts → summaryUtils.d.mts} +66 -4
  86. package/lib/summaryUtils.d.mts.map +1 -0
  87. package/lib/{summaryUtils.js → summaryUtils.mjs} +129 -26
  88. package/lib/summaryUtils.mjs.map +1 -0
  89. package/lib/unpackUsedRoutes.d.mts +12 -0
  90. package/lib/unpackUsedRoutes.d.mts.map +1 -0
  91. package/lib/unpackUsedRoutes.mjs +30 -0
  92. package/lib/unpackUsedRoutes.mjs.map +1 -0
  93. package/lib/{utils.d.ts → utils.d.mts} +7 -2
  94. package/lib/utils.d.mts.map +1 -0
  95. package/lib/{utils.js → utils.mjs} +2 -1
  96. package/lib/utils.mjs.map +1 -0
  97. package/package.json +102 -66
  98. package/prettier.config.cjs +8 -0
  99. package/src/dataStoreHandleContextUtils.ts +24 -16
  100. package/src/dataStoreHelpers.ts +106 -83
  101. package/src/index.ts +31 -9
  102. package/src/objectstoragepartition.ts +18 -14
  103. package/src/objectstorageutils.ts +37 -36
  104. package/src/requestParser.ts +81 -86
  105. package/src/runtimeFactoryHelper.ts +27 -26
  106. package/src/summaryUtils.ts +425 -299
  107. package/src/unpackUsedRoutes.ts +31 -0
  108. package/src/utils.ts +12 -7
  109. package/tsc-multi.test.json +4 -0
  110. package/tsconfig.json +10 -12
  111. package/dist/dataStoreHandleContextUtils.js.map +0 -1
  112. package/dist/dataStoreHelpers.js.map +0 -1
  113. package/dist/index.js +0 -26
  114. package/dist/index.js.map +0 -1
  115. package/dist/objectstoragepartition.js.map +0 -1
  116. package/dist/objectstorageutils.js.map +0 -1
  117. package/dist/packageVersion.d.ts +0 -9
  118. package/dist/packageVersion.d.ts.map +0 -1
  119. package/dist/packageVersion.js +0 -12
  120. package/dist/packageVersion.js.map +0 -1
  121. package/dist/requestParser.js.map +0 -1
  122. package/dist/runtimeFactoryHelper.js.map +0 -1
  123. package/dist/summarizerNode/index.d.ts +0 -8
  124. package/dist/summarizerNode/index.d.ts.map +0 -1
  125. package/dist/summarizerNode/index.js +0 -12
  126. package/dist/summarizerNode/index.js.map +0 -1
  127. package/dist/summarizerNode/summarizerNode.d.ts +0 -139
  128. package/dist/summarizerNode/summarizerNode.d.ts.map +0 -1
  129. package/dist/summarizerNode/summarizerNode.js +0 -480
  130. package/dist/summarizerNode/summarizerNode.js.map +0 -1
  131. package/dist/summarizerNode/summarizerNodeUtils.d.ts +0 -161
  132. package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +0 -1
  133. package/dist/summarizerNode/summarizerNodeUtils.js +0 -225
  134. package/dist/summarizerNode/summarizerNodeUtils.js.map +0 -1
  135. package/dist/summarizerNode/summarizerNodeWithGc.d.ts +0 -133
  136. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +0 -1
  137. package/dist/summarizerNode/summarizerNodeWithGc.js +0 -294
  138. package/dist/summarizerNode/summarizerNodeWithGc.js.map +0 -1
  139. package/dist/summaryUtils.js.map +0 -1
  140. package/dist/utils.js.map +0 -1
  141. package/lib/dataStoreHandleContextUtils.d.ts.map +0 -1
  142. package/lib/dataStoreHandleContextUtils.js.map +0 -1
  143. package/lib/dataStoreHelpers.d.ts.map +0 -1
  144. package/lib/dataStoreHelpers.js.map +0 -1
  145. package/lib/index.d.ts +0 -14
  146. package/lib/index.d.ts.map +0 -1
  147. package/lib/index.js +0 -14
  148. package/lib/index.js.map +0 -1
  149. package/lib/objectstoragepartition.d.ts.map +0 -1
  150. package/lib/objectstoragepartition.js.map +0 -1
  151. package/lib/objectstorageutils.d.ts.map +0 -1
  152. package/lib/objectstorageutils.js.map +0 -1
  153. package/lib/packageVersion.d.ts +0 -9
  154. package/lib/packageVersion.d.ts.map +0 -1
  155. package/lib/packageVersion.js +0 -9
  156. package/lib/packageVersion.js.map +0 -1
  157. package/lib/requestParser.d.ts.map +0 -1
  158. package/lib/requestParser.js.map +0 -1
  159. package/lib/runtimeFactoryHelper.d.ts.map +0 -1
  160. package/lib/runtimeFactoryHelper.js +0 -25
  161. package/lib/runtimeFactoryHelper.js.map +0 -1
  162. package/lib/summarizerNode/index.d.ts +0 -8
  163. package/lib/summarizerNode/index.d.ts.map +0 -1
  164. package/lib/summarizerNode/index.js +0 -7
  165. package/lib/summarizerNode/index.js.map +0 -1
  166. package/lib/summarizerNode/summarizerNode.d.ts +0 -139
  167. package/lib/summarizerNode/summarizerNode.d.ts.map +0 -1
  168. package/lib/summarizerNode/summarizerNode.js +0 -475
  169. package/lib/summarizerNode/summarizerNode.js.map +0 -1
  170. package/lib/summarizerNode/summarizerNodeUtils.d.ts +0 -161
  171. package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +0 -1
  172. package/lib/summarizerNode/summarizerNodeUtils.js +0 -216
  173. package/lib/summarizerNode/summarizerNodeUtils.js.map +0 -1
  174. package/lib/summarizerNode/summarizerNodeWithGc.d.ts +0 -133
  175. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +0 -1
  176. package/lib/summarizerNode/summarizerNodeWithGc.js +0 -289
  177. package/lib/summarizerNode/summarizerNodeWithGc.js.map +0 -1
  178. package/lib/summaryUtils.d.ts.map +0 -1
  179. package/lib/summaryUtils.js.map +0 -1
  180. package/lib/utils.d.ts.map +0 -1
  181. package/lib/utils.js.map +0 -1
  182. package/src/packageVersion.ts +0 -9
  183. package/src/summarizerNode/index.ts +0 -8
  184. package/src/summarizerNode/summarizerNode.ts +0 -662
  185. package/src/summarizerNode/summarizerNodeUtils.ts +0 -339
  186. package/src/summarizerNode/summarizerNodeWithGc.ts +0 -459
  187. package/tsconfig.esnext.json +0 -7
@@ -1,339 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
- import { assert } from "@fluidframework/common-utils";
8
- import {
9
- ISnapshotTree,
10
- ISequencedDocumentMessage,
11
- SummaryType,
12
- ISummaryTree,
13
- SummaryObject,
14
- } from "@fluidframework/protocol-definitions";
15
- import { channelsTreeName, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
16
- import { SummaryTreeBuilder } from "../summaryUtils";
17
- import { ReadAndParseBlob } from "../utils";
18
-
19
- const baseSummaryTreeKey = "_baseSummary";
20
- const outstandingOpsBlobKey = "_outstandingOps";
21
- const maxDecodeDepth = 100;
22
-
23
- /**
24
- * Return value of refreshSummaryAck function. There can be three different scenarios based on the passed params:
25
- * 1. The latest summary was not udpated.
26
- * 2. The latest summary was updated and the summary corresponding to the params was tracked by this client.
27
- * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this case, the
28
- * latest summary is updated based on the downloaded snapshot which is also returned.
29
- */
30
- export type RefreshSummaryResult = {
31
- latestSummaryUpdated: false;
32
- } | {
33
- latestSummaryUpdated: true;
34
- wasSummaryTracked: true;
35
- } | {
36
- latestSummaryUpdated: true;
37
- wasSummaryTracked: false;
38
- snapshot: ISnapshotTree;
39
- };
40
-
41
- export interface ISummarizerNodeRootContract {
42
- startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger): void;
43
- completeSummary(proposalHandle: string): void;
44
- clearSummary(): void;
45
- refreshLatestSummary(
46
- proposalHandle: string | undefined,
47
- summaryRefSeq: number,
48
- getSnapshot: () => Promise<ISnapshotTree>,
49
- readAndParseBlob: ReadAndParseBlob,
50
- correlatedSummaryLogger: ITelemetryLogger,
51
- ): Promise<RefreshSummaryResult>;
52
- }
53
-
54
- /** Path for nodes in a tree with escaped special characters */
55
- export class EscapedPath {
56
- private constructor(public readonly path: string) { }
57
- public static create(path: string): EscapedPath {
58
- return new EscapedPath(encodeURIComponent(path));
59
- }
60
- public static createAndConcat(pathParts: string[]): EscapedPath {
61
- let ret = EscapedPath.create(pathParts[0] ?? "");
62
- for (let i = 1; i < pathParts.length; i++) {
63
- ret = ret.concat(EscapedPath.create(pathParts[i]));
64
- }
65
- return ret;
66
- }
67
- public toString(): string {
68
- return this.path;
69
- }
70
- public concat(path: EscapedPath): EscapedPath {
71
- return new EscapedPath(`${this.path}/${path.path}`);
72
- }
73
- }
74
-
75
- /** Information about a summary relevant to a specific node in the tree */
76
- export class SummaryNode {
77
- /** Creates an instance that is valid for the root with specific basePath and localPath */
78
- public static createForRoot(referenceSequenceNumber: number): SummaryNode {
79
- return new SummaryNode({
80
- referenceSequenceNumber,
81
- basePath: undefined,
82
- localPath: EscapedPath.create(""), // root hard-coded to ""
83
- });
84
- }
85
-
86
- /** Summary reference sequence number, i.e. last sequence number seen when it was created */
87
- public get referenceSequenceNumber(): number {
88
- return this.summary.referenceSequenceNumber;
89
- }
90
- /** Full path to parent node, or undefined if this is the root */
91
- public get basePath(): EscapedPath | undefined {
92
- return this.summary.basePath;
93
- }
94
- /** Relative path to this node from its parent node */
95
- public get localPath(): EscapedPath {
96
- return this.summary.localPath;
97
- }
98
- /** Relative path from this node to its node innermost base summary */
99
- public get additionalPath(): EscapedPath | undefined {
100
- return this.summary.additionalPath;
101
- }
102
- public set additionalPath(additionalPath: EscapedPath | undefined) {
103
- this.summary.additionalPath = additionalPath;
104
- }
105
- constructor(private readonly summary: {
106
- readonly referenceSequenceNumber: number;
107
- readonly basePath: EscapedPath | undefined;
108
- readonly localPath: EscapedPath;
109
- additionalPath?: EscapedPath;
110
- }) { }
111
-
112
- /** Gets the full path to this node, to be used when sending a handle */
113
- public get fullPath(): EscapedPath {
114
- return this.basePath?.concat(this.localPath) ?? this.localPath;
115
- }
116
-
117
- /**
118
- * Gets the full path to this node's innermost base summary.
119
- * The children nodes can use this as their basePath to determine their path.
120
- */
121
- public get fullPathForChildren(): EscapedPath {
122
- return this.additionalPath !== undefined
123
- ? this.fullPath.concat(this.additionalPath)
124
- : this.fullPath;
125
- }
126
-
127
- /**
128
- * Creates a new node within the same summary for a child of this node.
129
- * @param id - id of the child node
130
- */
131
- public createForChild(id: string): SummaryNode {
132
- return new SummaryNode({
133
- referenceSequenceNumber: this.referenceSequenceNumber,
134
- basePath: this.fullPathForChildren,
135
- localPath: EscapedPath.create(id),
136
- });
137
- }
138
- }
139
-
140
- /** Result from decoding summary which may have been a differential summary. */
141
- interface IDecodedSummary {
142
- /** The innermost base summary which is not itself a differential summary */
143
- readonly baseSummary: ISnapshotTree;
144
- /** The entire path name to the innermost base summary */
145
- readonly pathParts: string[];
146
- /** Function to fetch all outstanding ops since the innermost base summary */
147
- getOutstandingOps(readAndParseBlob: ReadAndParseBlob): Promise<ISequencedDocumentMessage[]>;
148
- }
149
-
150
- /**
151
- * Checks if the snapshot is created by referencing a previous successful
152
- * summary plus outstanding ops. If so, it will recursively "decode" it until
153
- * it gets to the last successful summary (the base summary) and returns that
154
- * as well as a function for fetching the outstanding ops. Also returns the
155
- * full path to the previous base summary for child summarizer nodes to use as
156
- * their base path when necessary.
157
- * @param snapshot - snapshot tree to decode
158
- */
159
- export function decodeSummary(
160
- snapshot: ISnapshotTree,
161
- logger: Pick<ITelemetryLogger, "sendTelemetryEvent">,
162
- ): IDecodedSummary {
163
- let baseSummary = snapshot;
164
- const pathParts: string[] = [];
165
- const opsBlobs: string[] = [];
166
-
167
- for (let i = 0; ; i++) {
168
- if (i > maxDecodeDepth) {
169
- logger.sendTelemetryEvent({
170
- eventName: "DecodeSummaryMaxDepth",
171
- maxDecodeDepth,
172
- });
173
- }
174
- const outstandingOpsBlob = baseSummary.blobs[outstandingOpsBlobKey];
175
- const newBaseSummary = baseSummary.trees[baseSummaryTreeKey];
176
- if (outstandingOpsBlob === undefined && newBaseSummary === undefined) {
177
- return {
178
- baseSummary,
179
- pathParts,
180
- async getOutstandingOps(readAndParseBlob: ReadAndParseBlob) {
181
- let outstandingOps: ISequencedDocumentMessage[] = [];
182
- for (const opsBlob of opsBlobs) {
183
- const newOutstandingOps = await readAndParseBlob<ISequencedDocumentMessage[]>(opsBlob);
184
- if (outstandingOps.length > 0 && newOutstandingOps.length > 0) {
185
- const latestSeq = outstandingOps[outstandingOps.length - 1].sequenceNumber;
186
- const newEarliestSeq = newOutstandingOps[0].sequenceNumber;
187
- if (newEarliestSeq <= latestSeq) {
188
- logger.sendTelemetryEvent({
189
- eventName: "DuplicateOutstandingOps",
190
- // eslint-disable-next-line max-len
191
- message: `newEarliestSeq <= latestSeq in decodeSummary: ${newEarliestSeq} <= ${latestSeq}`,
192
- });
193
- while (newOutstandingOps.length > 0
194
- && newOutstandingOps[0].sequenceNumber <= latestSeq) {
195
- newOutstandingOps.shift();
196
- }
197
- }
198
- }
199
- outstandingOps = outstandingOps.concat(newOutstandingOps);
200
- }
201
- return outstandingOps;
202
- },
203
- };
204
- }
205
-
206
- assert(!!outstandingOpsBlob, 0x1af /* "Outstanding ops blob missing, but base summary tree exists" */);
207
- assert(newBaseSummary !== undefined, 0x1b0 /* "Base summary tree missing, but outstanding ops blob exists" */);
208
- baseSummary = newBaseSummary;
209
- pathParts.push(baseSummaryTreeKey);
210
- opsBlobs.unshift(outstandingOpsBlob);
211
- }
212
- }
213
-
214
- /**
215
- * Summary tree which is a handle of the previous successfully acked summary
216
- * and a blob of the outstanding ops since that summary.
217
- */
218
- interface IEncodedSummary extends ISummaryTreeWithStats {
219
- readonly additionalPath: EscapedPath;
220
- }
221
-
222
- /**
223
- * Parameter to help encode summary with conditional behavior.
224
- * When fromSummary is true, it will contain the SummaryNode of
225
- * its previous summary, which it can use to point to with a handle.
226
- * When fromSummary is false, it will use an actual summary tree
227
- * as its base summary in case the first summary is a differential summary.
228
- */
229
- export type EncodeSummaryParam = {
230
- fromSummary: true;
231
- summaryNode: SummaryNode;
232
- } | {
233
- fromSummary: false;
234
- initialSummary: ISummaryTreeWithStats;
235
- };
236
-
237
- /**
238
- * Creates a summary tree which is a handle of the previous successfully acked summary
239
- * and a blob of the outstanding ops since that summary. If there is no acked summary yet,
240
- * it will create with the tree found in the initial attach op and the blob of outstanding ops.
241
- * @param summaryParam - information about last acked summary and paths to encode if from summary,
242
- * otherwise the initial summary from the attach op.
243
- * @param outstandingOps - outstanding ops since last acked summary
244
- */
245
- export function encodeSummary(
246
- summaryParam: EncodeSummaryParam,
247
- outstandingOps: ISequencedDocumentMessage[],
248
- ): IEncodedSummary {
249
- let additionalPath = EscapedPath.create(baseSummaryTreeKey);
250
-
251
- const builder = new SummaryTreeBuilder();
252
- builder.addBlob(outstandingOpsBlobKey, JSON.stringify(outstandingOps));
253
-
254
- if (summaryParam.fromSummary) {
255
- // Create using handle of latest acked summary
256
- const summaryNode = summaryParam.summaryNode;
257
- if (summaryNode.additionalPath !== undefined) {
258
- additionalPath = additionalPath.concat(summaryNode.additionalPath);
259
- }
260
- builder.addHandle(baseSummaryTreeKey, SummaryType.Tree, summaryNode.fullPath.path);
261
- } else {
262
- // Create using initial summary from attach op
263
- builder.addWithStats(baseSummaryTreeKey, summaryParam.initialSummary);
264
- }
265
-
266
- const summary = builder.getSummaryTree();
267
- return {
268
- ...summary,
269
- additionalPath,
270
- };
271
- }
272
-
273
- /**
274
- * Information about the initial summary tree found from an attach op.
275
- */
276
- export interface IInitialSummary {
277
- sequenceNumber: number;
278
- id: string;
279
- summary: ISummaryTreeWithStats | undefined;
280
- }
281
-
282
- /**
283
- * Represents the details needed to create a child summarizer node.
284
- */
285
- export interface ICreateChildDetails {
286
- /** Summary from attach op if known */
287
- initialSummary: IInitialSummary | undefined;
288
- /** Latest summary from server node data */
289
- latestSummary: SummaryNode | undefined;
290
- /** Sequence number of latest known change to the node */
291
- changeSequenceNumber: number;
292
- }
293
-
294
- export interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {
295
- /** Tree to use to find children subtrees */
296
- childrenTree: T;
297
- /** Additional path part where children are isolated */
298
- childrenPathPart: string | undefined;
299
- }
300
-
301
- /**
302
- * Checks if the summary contains .channels subtree where the children subtrees
303
- * would be located if exists.
304
- * @param baseSummary - summary to check
305
- */
306
- export function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISubtreeInfo<ISnapshotTree> {
307
- // New versions of snapshots have child nodes isolated in .channels subtree
308
- const channelsSubtree = baseSummary.trees[channelsTreeName];
309
- if (channelsSubtree !== undefined) {
310
- return {
311
- childrenTree: channelsSubtree,
312
- childrenPathPart: channelsTreeName,
313
- };
314
- }
315
- return {
316
- childrenTree: baseSummary,
317
- childrenPathPart: undefined,
318
- };
319
- }
320
-
321
- /**
322
- * Checks if the summary contains .channels subtree where the children subtrees
323
- * would be located if exists.
324
- * @param baseSummary - summary to check
325
- */
326
- export function parseSummaryTreeForSubtrees(summary: ISummaryTree): ISubtreeInfo<SummaryObject> {
327
- // New versions of snapshots have child nodes isolated in .channels subtree
328
- const channelsSubtree = summary.tree[channelsTreeName];
329
- if (channelsSubtree !== undefined) {
330
- return {
331
- childrenTree: channelsSubtree,
332
- childrenPathPart: channelsTreeName,
333
- };
334
- }
335
- return {
336
- childrenTree: summary,
337
- childrenPathPart: undefined,
338
- };
339
- }