@fluidframework/runtime-definitions 2.0.0-dev.2.2.0.111723 → 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 (41) hide show
  1. package/.eslintrc.js +5 -7
  2. package/README.md +6 -6
  3. package/api-extractor.json +2 -2
  4. package/dist/attribution.d.ts +41 -0
  5. package/dist/attribution.d.ts.map +1 -0
  6. package/dist/attribution.js +7 -0
  7. package/dist/attribution.js.map +1 -0
  8. package/dist/dataStoreContext.d.ts +27 -8
  9. package/dist/dataStoreContext.d.ts.map +1 -1
  10. package/dist/dataStoreContext.js +6 -2
  11. package/dist/dataStoreContext.js.map +1 -1
  12. package/dist/dataStoreFactory.d.ts.map +1 -1
  13. package/dist/dataStoreFactory.js.map +1 -1
  14. package/dist/dataStoreRegistry.d.ts +1 -1
  15. package/dist/dataStoreRegistry.d.ts.map +1 -1
  16. package/dist/dataStoreRegistry.js.map +1 -1
  17. package/dist/garbageCollection.d.ts +17 -6
  18. package/dist/garbageCollection.d.ts.map +1 -1
  19. package/dist/garbageCollection.js +9 -3
  20. package/dist/garbageCollection.js.map +1 -1
  21. package/dist/index.d.ts +4 -3
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +5 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/protocol.d.ts +2 -2
  26. package/dist/protocol.d.ts.map +1 -1
  27. package/dist/protocol.js.map +1 -1
  28. package/dist/summary.d.ts +64 -14
  29. package/dist/summary.d.ts.map +1 -1
  30. package/dist/summary.js.map +1 -1
  31. package/package.json +15 -15
  32. package/prettier.config.cjs +1 -1
  33. package/src/attribution.ts +44 -0
  34. package/src/dataStoreContext.ts +409 -392
  35. package/src/dataStoreFactory.ts +14 -11
  36. package/src/dataStoreRegistry.ts +8 -6
  37. package/src/garbageCollection.ts +20 -10
  38. package/src/index.ts +18 -2
  39. package/src/protocol.ts +39 -38
  40. package/src/summary.ts +226 -175
  41. package/tsconfig.json +8 -12
package/src/summary.ts CHANGED
@@ -5,26 +5,23 @@
5
5
 
6
6
  import { TelemetryEventPropertyType } from "@fluidframework/common-definitions";
7
7
  import {
8
- SummaryTree,
9
- ISummaryTree,
10
- ISequencedDocumentMessage,
11
- ISnapshotTree,
12
- ITree,
8
+ SummaryTree,
9
+ ISummaryTree,
10
+ ISequencedDocumentMessage,
11
+ ISnapshotTree,
12
+ ITree,
13
13
  } from "@fluidframework/protocol-definitions";
14
- import {
15
- IGarbageCollectionData,
16
- IGarbageCollectionDetailsBase,
17
- } from "./garbageCollection";
14
+ import { IGarbageCollectionData, IGarbageCollectionDetailsBase } from "./garbageCollection";
18
15
 
19
16
  /**
20
17
  * Contains the aggregation data from a Tree/Subtree.
21
18
  */
22
19
  export interface ISummaryStats {
23
- treeNodeCount: number;
24
- blobNodeCount: number;
25
- handleNodeCount: number;
26
- totalBlobSize: number;
27
- unreferencedBlobSize: number;
20
+ treeNodeCount: number;
21
+ blobNodeCount: number;
22
+ handleNodeCount: number;
23
+ totalBlobSize: number;
24
+ unreferencedBlobSize: number;
28
25
  }
29
26
 
30
27
  /**
@@ -35,21 +32,23 @@ export interface ISummaryStats {
35
32
  * will be taking part of the summarization process.
36
33
  */
37
34
  export interface ISummaryTreeWithStats {
38
- /** Represents an aggregation of node counts and blob sizes associated to the current summary information */
39
- stats: ISummaryStats;
40
- /**
41
- * A recursive data structure that will be converted to a snapshot tree and uploaded
42
- * to the backend.
43
- */
44
- summary: ISummaryTree;
35
+ /**
36
+ * Represents an aggregation of node counts and blob sizes associated to the current summary information
37
+ */
38
+ stats: ISummaryStats;
39
+ /**
40
+ * A recursive data structure that will be converted to a snapshot tree and uploaded
41
+ * to the backend.
42
+ */
43
+ summary: ISummaryTree;
45
44
  }
46
45
 
47
46
  /**
48
47
  * Represents a summary at a current sequence number.
49
48
  */
50
49
  export interface ISummarizeResult {
51
- stats: ISummaryStats;
52
- summary: SummaryTree;
50
+ stats: ISummaryStats;
51
+ summary: SummaryTree;
53
52
  }
54
53
 
55
54
  /**
@@ -67,17 +66,25 @@ export interface ISummarizeResult {
67
66
  * ```
68
67
  */
69
68
  export interface ISummarizeInternalResult extends ISummarizeResult {
70
- id: string;
71
- /** Additional path parts between this node's ID and its children's IDs. */
72
- pathPartsForChildren?: string[];
69
+ id: string;
70
+ /**
71
+ * Additional path parts between this node's ID and its children's IDs.
72
+ */
73
+ pathPartsForChildren?: string[];
73
74
  }
74
75
 
75
- /** The garbage collection data of each node in the reference graph. */
76
+ /**
77
+ * The garbage collection data of each node in the reference graph.
78
+ */
76
79
  export interface IGarbageCollectionNodeData {
77
- /** The set of routes to other nodes in the graph. */
78
- outboundRoutes: string[];
79
- /** If the node is unreferenced, the timestamp of when it was marked unreferenced. */
80
- unreferencedTimestampMs?: number;
80
+ /**
81
+ * The set of routes to other nodes in the graph.
82
+ */
83
+ outboundRoutes: string[];
84
+ /**
85
+ * If the node is unreferenced, the timestamp of when it was marked unreferenced.
86
+ */
87
+ unreferencedTimestampMs?: number;
81
88
  }
82
89
 
83
90
  /**
@@ -85,110 +92,143 @@ export interface IGarbageCollectionNodeData {
85
92
  * GC data.
86
93
  */
87
94
  export interface IGarbageCollectionState {
88
- gcNodes: { [ id: string ]: IGarbageCollectionNodeData; };
95
+ gcNodes: { [id: string]: IGarbageCollectionNodeData };
96
+ }
97
+
98
+ /**
99
+ * @deprecated - IGarbageCollectionState is written in the root of the summary now.
100
+ * Legacy GC details from when the GC details were written at the data store's summary tree.
101
+ */
102
+ export interface IGarbageCollectionSummaryDetailsLegacy {
103
+ /** A list of routes to Fluid objects that are used in this node. */
104
+ usedRoutes?: string[];
105
+ /** The GC data of this node. */
106
+ gcData?: IGarbageCollectionData;
107
+ /** If this node is unreferenced, the time when it was marked as such. */
108
+ unrefTimestamp?: number;
109
+ }
110
+
111
+ /**
112
+ * The GC data that is read from a snapshot. It contains the Garbage CollectionState state and tombstone state.
113
+ */
114
+ export interface IGarbageCollectionSnapshotData {
115
+ gcState: IGarbageCollectionState;
116
+ tombstones: string[] | undefined;
117
+ deletedNodes: string[] | undefined;
89
118
  }
90
119
 
91
120
  export type SummarizeInternalFn = (
92
- fullTree: boolean,
93
- trackState: boolean,
94
- telemetryContext?: ITelemetryContext,
121
+ fullTree: boolean,
122
+ trackState: boolean,
123
+ telemetryContext?: ITelemetryContext,
95
124
  ) => Promise<ISummarizeInternalResult>;
96
125
 
97
126
  export interface ISummarizerNodeConfig {
98
- /**
99
- * True to reuse previous handle when unchanged since last acked summary.
100
- * Defaults to true.
101
- */
102
- readonly canReuseHandle?: boolean;
103
- /**
104
- * True to always stop execution on error during summarize, or false to
105
- * attempt creating a summary that is a pointer ot the last acked summary
106
- * plus outstanding ops in case of internal summarize failure.
107
- * Defaults to false.
108
- *
109
- * BUG BUG: Default to true while we investigate problem
110
- * with differential summaries
111
- */
112
- readonly throwOnFailure?: true;
127
+ /**
128
+ * True to reuse previous handle when unchanged since last acked summary.
129
+ * Defaults to true.
130
+ */
131
+ readonly canReuseHandle?: boolean;
132
+ /**
133
+ * True to always stop execution on error during summarize, or false to
134
+ * attempt creating a summary that is a pointer ot the last acked summary
135
+ * plus outstanding ops in case of internal summarize failure.
136
+ * Defaults to false.
137
+ *
138
+ * BUG BUG: Default to true while we investigate problem
139
+ * with differential summaries
140
+ */
141
+ readonly throwOnFailure?: true;
113
142
  }
114
143
 
115
144
  export interface ISummarizerNodeConfigWithGC extends ISummarizerNodeConfig {
116
- /**
117
- * True if GC is disabled. If so, don't track GC related state for a summary.
118
- * This is propagated to all child nodes.
119
- */
120
- readonly gcDisabled?: boolean;
145
+ /**
146
+ * True if GC is disabled. If so, don't track GC related state for a summary.
147
+ * This is propagated to all child nodes.
148
+ */
149
+ readonly gcDisabled?: boolean;
121
150
  }
122
151
 
123
152
  export enum CreateSummarizerNodeSource {
124
- FromSummary,
125
- FromAttach,
126
- Local,
153
+ FromSummary,
154
+ FromAttach,
155
+ Local,
127
156
  }
128
- export type CreateChildSummarizerNodeParam = {
129
- type: CreateSummarizerNodeSource.FromSummary;
130
- } | {
131
- type: CreateSummarizerNodeSource.FromAttach;
132
- sequenceNumber: number;
133
- snapshot: ITree;
134
- } | {
135
- type: CreateSummarizerNodeSource.Local;
136
- };
157
+ export type CreateChildSummarizerNodeParam =
158
+ | {
159
+ type: CreateSummarizerNodeSource.FromSummary;
160
+ }
161
+ | {
162
+ type: CreateSummarizerNodeSource.FromAttach;
163
+ sequenceNumber: number;
164
+ snapshot: ITree;
165
+ }
166
+ | {
167
+ type: CreateSummarizerNodeSource.Local;
168
+ };
137
169
 
138
170
  export interface ISummarizerNode {
139
- /** Latest successfully acked summary reference sequence number */
140
- readonly referenceSequenceNumber: number;
141
- /**
142
- * Marks the node as having a change with the given sequence number.
143
- * @param sequenceNumber - sequence number of change
144
- */
145
- invalidate(sequenceNumber: number): void;
146
- /**
147
- * Calls the internal summarize function and handles internal state tracking.
148
- * If unchanged and fullTree is false, it will reuse previous summary subtree.
149
- * If an error is encountered and throwOnFailure is false, it will try to make
150
- * a summary with a pointer to the previous summary + a blob of outstanding ops.
151
- * @param fullTree - true to skip optimizations and always generate the full tree
152
- * @param trackState - indicates whether the summarizer node should track the state of the summary or not
153
- * @param telemetryContext - summary data passed through the layers for telemetry purposes
154
- */
155
- summarize(
156
- fullTree: boolean,
157
- trackState?: boolean,
158
- telemetryContext?: ITelemetryContext,
159
- ): Promise<ISummarizeResult>;
160
- /**
161
- * Checks if there are any additional path parts for children that need to
162
- * be loaded from the base summary. Additional path parts represent parts
163
- * of the path between this SummarizerNode and any child SummarizerNodes
164
- * that it might have. For example: if datastore "a" contains dds "b", but the
165
- * path is "/a/.channels/b", then the additional path part is ".channels".
166
- * @param snapshot - the base summary to parse
167
- */
168
- updateBaseSummaryState(snapshot: ISnapshotTree): void;
169
- /**
170
- * Records an op representing a change to this node/subtree.
171
- * @param op - op of change to record
172
- */
173
- recordChange(op: ISequencedDocumentMessage): void;
171
+ /**
172
+ * Latest successfully acked summary reference sequence number
173
+ */
174
+ readonly referenceSequenceNumber: number;
175
+ /**
176
+ * Marks the node as having a change with the given sequence number.
177
+ * @param sequenceNumber - sequence number of change
178
+ */
179
+ invalidate(sequenceNumber: number): void;
180
+ /**
181
+ * Calls the internal summarize function and handles internal state tracking.
182
+ * If unchanged and fullTree is false, it will reuse previous summary subtree.
183
+ * If an error is encountered and throwOnFailure is false, it will try to make
184
+ * a summary with a pointer to the previous summary + a blob of outstanding ops.
185
+ * @param fullTree - true to skip optimizations and always generate the full tree
186
+ * @param trackState - indicates whether the summarizer node should track the state of the summary or not
187
+ * @param telemetryContext - summary data passed through the layers for telemetry purposes
188
+ */
189
+ summarize(
190
+ fullTree: boolean,
191
+ trackState?: boolean,
192
+ telemetryContext?: ITelemetryContext,
193
+ ): Promise<ISummarizeResult>;
194
+ /**
195
+ * Checks if there are any additional path parts for children that need to
196
+ * be loaded from the base summary. Additional path parts represent parts
197
+ * of the path between this SummarizerNode and any child SummarizerNodes
198
+ * that it might have. For example: if datastore "a" contains dds "b", but the
199
+ * path is "/a/.channels/b", then the additional path part is ".channels".
200
+ * @param snapshot - the base summary to parse
201
+ */
202
+ updateBaseSummaryState(snapshot: ISnapshotTree): void;
203
+ /**
204
+ * Records an op representing a change to this node/subtree.
205
+ * @param op - op of change to record
206
+ */
207
+ recordChange(op: ISequencedDocumentMessage): void;
174
208
 
175
- createChild(
176
- /** Summarize function */
177
- summarizeInternalFn: SummarizeInternalFn,
178
- /** Initial id or path part of this node */
179
- id: string,
180
- /**
181
- * Information needed to create the node.
182
- * If it is from a base summary, it will assert that a summary has been seen.
183
- * Attach information if it is created from an attach op.
184
- * If it is local, it will throw unsupported errors on calls to summarize.
185
- */
186
- createParam: CreateChildSummarizerNodeParam,
187
- /** Optional configuration affecting summarize behavior */
188
- config?: ISummarizerNodeConfig,
189
- ): ISummarizerNode;
209
+ createChild(
210
+ /**
211
+ * Summarize function
212
+ */
213
+ summarizeInternalFn: SummarizeInternalFn,
214
+ /**
215
+ * Initial id or path part of this node
216
+ */
217
+ id: string,
218
+ /**
219
+ * Information needed to create the node.
220
+ * If it is from a base summary, it will assert that a summary has been seen.
221
+ * Attach information if it is created from an attach op.
222
+ * If it is local, it will throw unsupported errors on calls to summarize.
223
+ */
224
+ createParam: CreateChildSummarizerNodeParam,
225
+ /**
226
+ * Optional configuration affecting summarize behavior
227
+ */
228
+ config?: ISummarizerNodeConfig,
229
+ ): ISummarizerNode;
190
230
 
191
- getChild(id: string): ISummarizerNode | undefined;
231
+ getChild(id: string): ISummarizerNode | undefined;
192
232
  }
193
233
 
194
234
  /**
@@ -214,49 +254,60 @@ export interface ISummarizerNode {
214
254
  * `updateUsedRoutes`: Used to notify this node of routes that are currently in use in it.
215
255
  */
216
256
  export interface ISummarizerNodeWithGC extends ISummarizerNode {
217
- createChild(
218
- /** Summarize function */
219
- summarizeInternalFn: SummarizeInternalFn,
220
- /** Initial id or path part of this node */
221
- id: string,
222
- /**
223
- * Information needed to create the node.
224
- * If it is from a base summary, it will assert that a summary has been seen.
225
- * Attach information if it is created from an attach op.
226
- * If it is local, it will throw unsupported errors on calls to summarize.
227
- */
228
- createParam: CreateChildSummarizerNodeParam,
229
- /** Optional configuration affecting summarize behavior */
230
- config?: ISummarizerNodeConfigWithGC,
231
- getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,
232
- getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,
233
- ): ISummarizerNodeWithGC;
257
+ createChild(
258
+ /**
259
+ * Summarize function
260
+ */
261
+ summarizeInternalFn: SummarizeInternalFn,
262
+ /**
263
+ * Initial id or path part of this node
264
+ */
265
+ id: string,
266
+ /**
267
+ * Information needed to create the node.
268
+ * If it is from a base summary, it will assert that a summary has been seen.
269
+ * Attach information if it is created from an attach op.
270
+ * If it is local, it will throw unsupported errors on calls to summarize.
271
+ */
272
+ createParam: CreateChildSummarizerNodeParam,
273
+ /**
274
+ * Optional configuration affecting summarize behavior
275
+ */
276
+ config?: ISummarizerNodeConfigWithGC,
277
+ getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,
278
+ /**
279
+ * @deprecated - The functionality to update child's base GC details is incorporated in the summarizer node.
280
+ */
281
+ getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,
282
+ ): ISummarizerNodeWithGC;
234
283
 
235
- /**
236
- * Delete the child with the given id..
237
- */
238
- deleteChild(id: string): void;
284
+ /**
285
+ * Delete the child with the given id..
286
+ */
287
+ deleteChild(id: string): void;
239
288
 
240
- getChild(id: string): ISummarizerNodeWithGC | undefined;
289
+ getChild(id: string): ISummarizerNodeWithGC | undefined;
241
290
 
242
- /**
243
- * Returns this node's data that is used for garbage collection. This includes a list of GC nodes that represent
244
- * this node. Each node has a set of outbound routes to other GC nodes in the document.
245
- * @param fullGC - true to bypass optimizations and force full generation of GC data.
246
- */
247
- getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
291
+ /**
292
+ * Returns this node's data that is used for garbage collection. This includes a list of GC nodes that represent
293
+ * this node. Each node has a set of outbound routes to other GC nodes in the document.
294
+ * @param fullGC - true to bypass optimizations and force full generation of GC data.
295
+ */
296
+ getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
248
297
 
249
- /** Tells whether this node is being referenced in this document or not. Unreferenced node will get GC'd */
250
- isReferenced(): boolean;
298
+ /**
299
+ * Tells whether this node is being referenced in this document or not. Unreferenced node will get GC'd
300
+ */
301
+ isReferenced(): boolean;
251
302
 
252
- /**
253
- * After GC has run, called to notify this node of routes that are used in it. These are used for the following:
254
- * 1. To identify if this node is being referenced in the document or not.
255
- * 2. To identify if this node or any of its children's used routes changed since last summary.
256
- *
257
- * @param usedRoutes - The routes that are used in this node.
258
- */
259
- updateUsedRoutes(usedRoutes: string[]): void;
303
+ /**
304
+ * After GC has run, called to notify this node of routes that are used in it. These are used for the following:
305
+ * 1. To identify if this node is being referenced in the document or not.
306
+ * 2. To identify if this node or any of its children's used routes changed since last summary.
307
+ *
308
+ * @param usedRoutes - The routes that are used in this node.
309
+ */
310
+ updateUsedRoutes(usedRoutes: string[]): void;
260
311
  }
261
312
 
262
313
  export const channelsTreeName = ".channels";
@@ -266,27 +317,27 @@ export const channelsTreeName = ".channels";
266
317
  * This object is expected to be modified directly by various summarize methods.
267
318
  */
268
319
  export interface ITelemetryContext {
269
- /**
270
- * Sets value for telemetry data being tracked.
271
- * @param prefix - unique prefix to tag this data with (ex: "fluid:map:")
272
- * @param property - property name of the telemetry data being tracked (ex: "DirectoryCount")
273
- * @param value - value to attribute to this summary telemetry data
274
- */
275
- set(prefix: string, property: string, value: TelemetryEventPropertyType): void;
320
+ /**
321
+ * Sets value for telemetry data being tracked.
322
+ * @param prefix - unique prefix to tag this data with (ex: "fluid:map:")
323
+ * @param property - property name of the telemetry data being tracked (ex: "DirectoryCount")
324
+ * @param value - value to attribute to this summary telemetry data
325
+ */
326
+ set(prefix: string, property: string, value: TelemetryEventPropertyType): void;
276
327
 
277
- /**
278
- * Get the telemetry data being tracked
279
- * @param prefix - unique prefix for this data (ex: "fluid:map:")
280
- * @param property - property name of the telemetry data being tracked (ex: "DirectoryCount")
281
- * @returns undefined if item not found
282
- */
283
- get(prefix: string, property: string): TelemetryEventPropertyType;
328
+ /**
329
+ * Get the telemetry data being tracked
330
+ * @param prefix - unique prefix for this data (ex: "fluid:map:")
331
+ * @param property - property name of the telemetry data being tracked (ex: "DirectoryCount")
332
+ * @returns undefined if item not found
333
+ */
334
+ get(prefix: string, property: string): TelemetryEventPropertyType;
284
335
 
285
- /**
286
- * Returns a serialized version of all the telemetry data.
287
- * Should be used when logging in telemetry events.
288
- */
289
- serialize(): string;
336
+ /**
337
+ * Returns a serialized version of all the telemetry data.
338
+ * Should be used when logging in telemetry events.
339
+ */
340
+ serialize(): string;
290
341
  }
291
342
 
292
343
  export const blobCountPropertyName = "BlobCount";
package/tsconfig.json CHANGED
@@ -1,14 +1,10 @@
1
1
  {
2
- "extends": "@fluidframework/build-common/ts-common-config.json",
3
- "exclude": [
4
- "src/test/**/*"
5
- ],
6
- "compilerOptions": {
7
- "rootDir": "./src",
8
- "outDir": "./dist",
9
- "composite": true,
10
- },
11
- "include": [
12
- "src/**/*"
13
- ]
2
+ "extends": "@fluidframework/build-common/ts-common-config.json",
3
+ "exclude": ["src/test/**/*"],
4
+ "compilerOptions": {
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
+ "composite": true,
8
+ },
9
+ "include": ["src/**/*"],
14
10
  }