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

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 (73) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +68 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +4 -4
  6. package/dist/index.js.map +1 -1
  7. package/dist/packageVersion.d.ts +1 -1
  8. package/dist/packageVersion.js +1 -1
  9. package/dist/packageVersion.js.map +1 -1
  10. package/dist/summaryUtils.d.ts +33 -1
  11. package/dist/summaryUtils.d.ts.map +1 -1
  12. package/dist/summaryUtils.js +83 -1
  13. package/dist/summaryUtils.js.map +1 -1
  14. package/dist/unpackUsedRoutes.d.ts +11 -0
  15. package/dist/unpackUsedRoutes.d.ts.map +1 -0
  16. package/dist/unpackUsedRoutes.js +33 -0
  17. package/dist/unpackUsedRoutes.js.map +1 -0
  18. package/lib/index.d.ts +2 -2
  19. package/lib/index.d.ts.map +1 -1
  20. package/lib/index.js +2 -2
  21. package/lib/index.js.map +1 -1
  22. package/lib/packageVersion.d.ts +1 -1
  23. package/lib/packageVersion.js +1 -1
  24. package/lib/packageVersion.js.map +1 -1
  25. package/lib/summaryUtils.d.ts +33 -1
  26. package/lib/summaryUtils.d.ts.map +1 -1
  27. package/lib/summaryUtils.js +81 -0
  28. package/lib/summaryUtils.js.map +1 -1
  29. package/lib/unpackUsedRoutes.d.ts +11 -0
  30. package/lib/unpackUsedRoutes.d.ts.map +1 -0
  31. package/lib/unpackUsedRoutes.js +29 -0
  32. package/lib/unpackUsedRoutes.js.map +1 -0
  33. package/package.json +53 -55
  34. package/src/index.ts +2 -8
  35. package/src/packageVersion.ts +1 -1
  36. package/src/summaryUtils.ts +94 -0
  37. package/src/unpackUsedRoutes.ts +30 -0
  38. package/dist/summarizerNode/index.d.ts +0 -8
  39. package/dist/summarizerNode/index.d.ts.map +0 -1
  40. package/dist/summarizerNode/index.js +0 -12
  41. package/dist/summarizerNode/index.js.map +0 -1
  42. package/dist/summarizerNode/summarizerNode.d.ts +0 -140
  43. package/dist/summarizerNode/summarizerNode.d.ts.map +0 -1
  44. package/dist/summarizerNode/summarizerNode.js +0 -448
  45. package/dist/summarizerNode/summarizerNode.js.map +0 -1
  46. package/dist/summarizerNode/summarizerNodeUtils.d.ts +0 -128
  47. package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +0 -1
  48. package/dist/summarizerNode/summarizerNodeUtils.js +0 -132
  49. package/dist/summarizerNode/summarizerNodeUtils.js.map +0 -1
  50. package/dist/summarizerNode/summarizerNodeWithGc.d.ts +0 -135
  51. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +0 -1
  52. package/dist/summarizerNode/summarizerNodeWithGc.js +0 -361
  53. package/dist/summarizerNode/summarizerNodeWithGc.js.map +0 -1
  54. package/lib/summarizerNode/index.d.ts +0 -8
  55. package/lib/summarizerNode/index.d.ts.map +0 -1
  56. package/lib/summarizerNode/index.js +0 -7
  57. package/lib/summarizerNode/index.js.map +0 -1
  58. package/lib/summarizerNode/summarizerNode.d.ts +0 -140
  59. package/lib/summarizerNode/summarizerNode.d.ts.map +0 -1
  60. package/lib/summarizerNode/summarizerNode.js +0 -443
  61. package/lib/summarizerNode/summarizerNode.js.map +0 -1
  62. package/lib/summarizerNode/summarizerNodeUtils.d.ts +0 -128
  63. package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +0 -1
  64. package/lib/summarizerNode/summarizerNodeUtils.js +0 -125
  65. package/lib/summarizerNode/summarizerNodeUtils.js.map +0 -1
  66. package/lib/summarizerNode/summarizerNodeWithGc.d.ts +0 -135
  67. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +0 -1
  68. package/lib/summarizerNode/summarizerNodeWithGc.js +0 -356
  69. package/lib/summarizerNode/summarizerNodeWithGc.js.map +0 -1
  70. package/src/summarizerNode/index.ts +0 -8
  71. package/src/summarizerNode/summarizerNode.ts +0 -631
  72. package/src/summarizerNode/summarizerNodeUtils.ts +0 -219
  73. package/src/summarizerNode/summarizerNodeWithGc.ts +0 -556
@@ -1,219 +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 { ISnapshotTree, ISummaryTree, SummaryObject } from "@fluidframework/protocol-definitions";
8
- import { channelsTreeName, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
9
- import { ReadAndParseBlob } from "../utils";
10
-
11
- /**
12
- * Return value of refreshSummaryAck function. There can be three different scenarios based on the passed params:
13
- *
14
- * 1. The latest summary was not udpated.
15
- *
16
- * 2. The latest summary was updated and the summary corresponding to the params was tracked by this client.
17
- *
18
- * 3. The latest summary was updated but the summary corresponding to the params was not tracked. In this case, the
19
- * latest summary is updated based on the downloaded snapshot which is also returned.
20
- */
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
- };
34
-
35
- export interface ISummarizerNodeRootContract {
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>;
46
- }
47
-
48
- /** Path for nodes in a tree with escaped special characters */
49
- export class EscapedPath {
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
- }
67
- }
68
-
69
- /** Information about a summary relevant to a specific node in the tree */
70
- export class SummaryNode {
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
- }
79
-
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
- ) {}
107
-
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
- }
112
-
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
- }
122
-
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
- }
134
- }
135
-
136
- /**
137
- * Parameter to help encode summary with conditional behavior.
138
- * When fromSummary is true, it will contain the SummaryNode of
139
- * its previous summary, which it can use to point to with a handle.
140
- * When fromSummary is false, it will use an actual summary tree
141
- * as its base summary in case the first summary is a differential summary.
142
- */
143
- export type EncodeSummaryParam =
144
- | {
145
- fromSummary: true;
146
- summaryNode: SummaryNode;
147
- }
148
- | {
149
- fromSummary: false;
150
- initialSummary: ISummaryTreeWithStats;
151
- };
152
-
153
- /**
154
- * Information about the initial summary tree found from an attach op.
155
- */
156
- export interface IInitialSummary {
157
- sequenceNumber: number;
158
- id: string;
159
- summary: ISummaryTreeWithStats | undefined;
160
- }
161
-
162
- /**
163
- * Represents the details needed to create a child summarizer node.
164
- */
165
- export interface ICreateChildDetails {
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;
172
- }
173
-
174
- export interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {
175
- /** Tree to use to find children subtrees */
176
- childrenTree: T;
177
- /** Additional path part where children are isolated */
178
- childrenPathPart: string | undefined;
179
- }
180
-
181
- /**
182
- * Checks if the summary contains .channels subtree where the children subtrees
183
- * would be located if exists.
184
- * @param baseSummary - summary to check
185
- */
186
- export function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISubtreeInfo<ISnapshotTree> {
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
- };
199
- }
200
-
201
- /**
202
- * Checks if the summary contains .channels subtree where the children subtrees
203
- * would be located if exists.
204
- * @param baseSummary - summary to check
205
- */
206
- export function parseSummaryTreeForSubtrees(summary: ISummaryTree): ISubtreeInfo<SummaryObject> {
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
- };
219
- }