@fluidframework/datastore-definitions 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277

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 (40) hide show
  1. package/.eslintrc.cjs +11 -0
  2. package/CHANGELOG.md +215 -0
  3. package/README.md +45 -7
  4. package/api-extractor-lint.json +4 -0
  5. package/api-extractor.json +2 -2
  6. package/api-report/datastore-definitions.api.md +156 -0
  7. package/dist/channel.d.ts +71 -16
  8. package/dist/channel.d.ts.map +1 -1
  9. package/dist/channel.js.map +1 -1
  10. package/dist/dataStoreRuntime.d.ts +28 -7
  11. package/dist/dataStoreRuntime.d.ts.map +1 -1
  12. package/dist/dataStoreRuntime.js.map +1 -1
  13. package/dist/datastore-definitions-alpha.d.ts +480 -0
  14. package/dist/datastore-definitions-beta.d.ts +395 -0
  15. package/dist/datastore-definitions-public.d.ts +395 -0
  16. package/dist/datastore-definitions-untrimmed.d.ts +480 -0
  17. package/dist/index.d.ts +10 -10
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +0 -21
  20. package/dist/index.js.map +1 -1
  21. package/dist/jsonable.d.ts +46 -14
  22. package/dist/jsonable.d.ts.map +1 -1
  23. package/dist/jsonable.js.map +1 -1
  24. package/dist/serializable.d.ts +5 -4
  25. package/dist/serializable.d.ts.map +1 -1
  26. package/dist/serializable.js.map +1 -1
  27. package/dist/storage.d.ts +1 -0
  28. package/dist/storage.d.ts.map +1 -1
  29. package/dist/storage.js.map +1 -1
  30. package/dist/tsdoc-metadata.json +11 -0
  31. package/package.json +99 -40
  32. package/prettier.config.cjs +8 -0
  33. package/src/channel.ts +256 -200
  34. package/src/dataStoreRuntime.ts +117 -96
  35. package/src/index.ts +17 -10
  36. package/src/jsonable.ts +80 -23
  37. package/src/serializable.ts +5 -4
  38. package/src/storage.ts +14 -13
  39. package/tsconfig.json +10 -12
  40. package/.eslintrc.js +0 -13
package/src/channel.ts CHANGED
@@ -6,239 +6,295 @@
6
6
  import { IFluidHandle, IFluidLoadable } from "@fluidframework/core-interfaces";
7
7
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
8
  import {
9
- IGarbageCollectionData,
10
- ISummaryTreeWithStats,
11
- ITelemetryContext,
9
+ IGarbageCollectionData,
10
+ IExperimentalIncrementalSummaryContext,
11
+ ISummaryTreeWithStats,
12
+ ITelemetryContext,
12
13
  } from "@fluidframework/runtime-definitions";
13
14
  import { IChannelAttributes } from "./storage";
14
15
  import { IFluidDataStoreRuntime } from "./dataStoreRuntime";
15
16
 
17
+ /**
18
+ * @public
19
+ */
16
20
  export interface IChannel extends IFluidLoadable {
17
- /**
18
- * A readonly identifier for the channel
19
- */
20
- readonly id: string;
21
-
22
- readonly owner?: string;
23
-
24
- readonly attributes: IChannelAttributes;
25
-
26
- /**
27
- * Generates summary of the channel synchronously. It is called when an `attach message`
28
- * for a local channel is generated. In other words, when the channel is being attached
29
- * to make it visible to other clients.
30
- * Note: Since Attach Summary is generated for local channels when making them visible to
31
- * remote clients, they don't have any previous summaries to compare against. For this reason,
32
- * The attach summary cannot contain summary handles (paths to sub-trees or blobs).
33
- * It can, however, contain ISummaryAttachment (handles to blobs uploaded async via the blob manager).
34
- * @param fullTree - flag indicating whether the attempt should generate a full
35
- * summary tree without any handles for unchanged subtrees.
36
- * @param trackState - optimization for tracking state of objects across summaries. If the state
37
- * of an object did not change since last successful summary, an ISummaryHandle can be used
38
- * instead of re-summarizing it. If this is false, the expectation is that you should never
39
- * send an ISummaryHandle since you are not expected to track state.
40
- * Note: The goal is to remove the trackState and automatically decided whether the
41
- * handles will be used or not: https://github.com/microsoft/FluidFramework/issues/10455
42
- * @returns A summary capturing the current state of the channel.
43
- */
44
- getAttachSummary(
45
- fullTree?: boolean,
46
- trackState?: boolean,
47
- telemetryContext?: ITelemetryContext,
48
- ): ISummaryTreeWithStats;
49
-
50
- /**
51
- * Generates summary of the channel asynchronously.
52
- * This should not be called where the channel can be modified while summarization is in progress.
53
- * @param fullTree - flag indicating whether the attempt should generate a full
54
- * summary tree without any handles for unchanged subtrees. It is only set to true when generating
55
- * a summary from the entire container.
56
- * @param trackState - This tells whether we should track state from this summary.
57
- * @returns A summary capturing the current state of the channel.
58
- */
59
- summarize(
60
- fullTree?: boolean,
61
- trackState?: boolean,
62
- telemetryContext?: ITelemetryContext,
63
- ): Promise<ISummaryTreeWithStats>;
64
-
65
- /**
66
- * Checks if the channel is attached to storage.
67
- * @returns True iff the channel is attached.
68
- */
69
- isAttached(): boolean;
70
-
71
- /**
72
- * Enables the channel to send and receive ops.
73
- * @param services - Services to connect to
74
- */
75
- connect(services: IChannelServices): void;
76
-
77
- /**
78
- * Returns the GC data for this channel. It contains a list of GC nodes that contains references to
79
- * other GC nodes.
80
- * @param fullGC - true to bypass optimizations and force full generation of GC data.
81
- */
82
- getGCData(fullGC?: boolean): IGarbageCollectionData;
21
+ /**
22
+ * A readonly identifier for the channel
23
+ */
24
+ readonly id: string;
25
+
26
+ readonly attributes: IChannelAttributes;
27
+
28
+ /**
29
+ * Generates summary of the channel synchronously. It is called when an `attach message`
30
+ * for a local channel is generated. In other words, when the channel is being attached
31
+ * to make it visible to other clients.
32
+ *
33
+ * @remarks
34
+ *
35
+ * Note: Since the Attach Summary is generated for local channels when making them visible to
36
+ * remote clients, they don't have any previous summaries to compare against. For this reason,
37
+ * the attach summary cannot contain summary handles (paths to sub-trees or blobs).
38
+ * It can, however, contain {@link @fluidframework/protocol-definitions#ISummaryAttachment}
39
+ * (handles to blobs uploaded async via the blob manager).
40
+ *
41
+ * @param fullTree - A flag indicating whether the attempt should generate a full
42
+ * summary tree without any handles for unchanged subtrees.
43
+ *
44
+ * Default: `false`
45
+ *
46
+ * @param trackState - An optimization for tracking state of objects across summaries. If the state
47
+ * of an object did not change since last successful summary, an
48
+ * {@link @fluidframework/protocol-definitions#ISummaryHandle} can be used
49
+ * instead of re-summarizing it. If this is `false`, the expectation is that you should never
50
+ * send an `ISummaryHandle`, since you are not expected to track state.
51
+ *
52
+ * Note: The goal is to remove the trackState and automatically decided whether the
53
+ * handles will be used or not: {@link https://github.com/microsoft/FluidFramework/issues/10455}
54
+ *
55
+ * Default: `false`
56
+ *
57
+ * @param telemetryContext - See {@link @fluidframework/runtime-definitions#ITelemetryContext}.
58
+ *
59
+ * @returns A summary capturing the current state of the channel.
60
+ */
61
+ getAttachSummary(
62
+ fullTree?: boolean,
63
+ trackState?: boolean,
64
+ telemetryContext?: ITelemetryContext,
65
+ ): ISummaryTreeWithStats;
66
+
67
+ /**
68
+ * Generates summary of the channel asynchronously.
69
+ * This should not be called where the channel can be modified while summarization is in progress.
70
+ *
71
+ * @param fullTree - flag indicating whether the attempt should generate a full
72
+ * summary tree without any handles for unchanged subtrees. It should only be set to true when generating
73
+ * a summary from the entire container.
74
+ *
75
+ * Default: `false`
76
+ *
77
+ * @param trackState - An optimization for tracking state of objects across summaries. If the state
78
+ * of an object did not change since last successful summary, an
79
+ * {@link @fluidframework/protocol-definitions#ISummaryHandle} can be used
80
+ * instead of re-summarizing it. If this is `false`, the expectation is that you should never
81
+ * send an `ISummaryHandle`, since you are not expected to track state.
82
+ *
83
+ * Default: `false`
84
+ *
85
+ * Note: The goal is to remove the trackState and automatically decided whether the
86
+ * handles will be used or not: {@link https://github.com/microsoft/FluidFramework/issues/10455}
87
+ *
88
+ * @param telemetryContext - See {@link @fluidframework/runtime-definitions#ITelemetryContext}.
89
+ *
90
+ * @returns A summary capturing the current state of the channel.
91
+ */
92
+ summarize(
93
+ fullTree?: boolean,
94
+ trackState?: boolean,
95
+ telemetryContext?: ITelemetryContext,
96
+ incrementalSummaryContext?: IExperimentalIncrementalSummaryContext,
97
+ ): Promise<ISummaryTreeWithStats>;
98
+
99
+ /**
100
+ * Checks if the channel is attached to storage.
101
+ * @returns True iff the channel is attached.
102
+ */
103
+ isAttached(): boolean;
104
+
105
+ /**
106
+ * Enables the channel to send and receive ops.
107
+ * @param services - The services to connect to.
108
+ */
109
+ connect(services: IChannelServices): void;
110
+
111
+ /**
112
+ * Returns the GC data for this channel. It contains a list of GC nodes that contains references to
113
+ * other GC nodes.
114
+ * @param fullGC - true to bypass optimizations and force full generation of GC data.
115
+ */
116
+ getGCData(fullGC?: boolean): IGarbageCollectionData;
83
117
  }
84
118
 
85
119
  /**
86
120
  * Handler provided by shared data structure to process requests from the runtime.
121
+ * @public
87
122
  */
88
123
  export interface IDeltaHandler {
89
- /**
90
- * Processes the op.
91
- * @param message - The message to process
92
- * @param local - Whether the message originated from the local client
93
- * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
94
- * For messages from a remote client, this will be undefined.
95
- */
96
- process: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => void;
97
-
98
- /**
99
- * State change events to indicate changes to the delta connection
100
- * @param connected - true if connected, false otherwise
101
- */
102
- setConnectionState(connected: boolean): void;
103
-
104
- /**
105
- * Called when the runtime asks the client to resubmit an op. This may be because the Container reconnected and
106
- * this op was not acked.
107
- * The client can choose to resubmit the same message, submit different / multiple messages or not submit anything
108
- * at all.
109
- * @param message - The original message that was submitted.
110
- * @param localOpMetadata - The local metadata associated with the original message.
111
- */
112
- reSubmit(message: any, localOpMetadata: unknown): void;
113
-
114
- /**
115
- * Apply changes from an op. Used when rehydrating an attached container
116
- * with pending changes. This prepares the SharedObject for seeing an ACK
117
- * for the op or resubmitting the op upon reconnection.
118
- * @param message - Contents of a stashed op.
119
- * @returns localMetadata of the op, to be passed to process() or resubmit()
120
- * when the op is ACKed or resubmitted, respectively
121
- */
122
- applyStashedOp(message: any): unknown;
123
-
124
- /**
125
- * Revert a local op.
126
- * @param message - The original message that was submitted.
127
- * @param localOpMetadata - The local metadata associated with the original message.
128
- */
129
- rollback?(message: any, localOpMetadata: unknown): void;
124
+ /**
125
+ * Processes the op.
126
+ * @param message - The message to process
127
+ * @param local - Whether the message originated from the local client
128
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
129
+ * For messages from a remote client, this will be undefined.
130
+ */
131
+ process: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => void;
132
+
133
+ /**
134
+ * State change events to indicate changes to the delta connection
135
+ * @param connected - true if connected, false otherwise
136
+ */
137
+ setConnectionState(connected: boolean): void;
138
+
139
+ /**
140
+ * Called when the runtime asks the client to resubmit an op. This may be because the Container reconnected and
141
+ * this op was not acked.
142
+ * The client can choose to resubmit the same message, submit different / multiple messages or not submit anything
143
+ * at all.
144
+ * @param message - The original message that was submitted.
145
+ * @param localOpMetadata - The local metadata associated with the original message.
146
+ */
147
+ reSubmit(message: any, localOpMetadata: unknown): void;
148
+
149
+ /**
150
+ * Apply changes from an op. Used when rehydrating an attached container
151
+ * with pending changes. This prepares the SharedObject for seeing an ACK
152
+ * for the op or resubmitting the op upon reconnection.
153
+ * @param message - Contents of a stashed op.
154
+ * @returns localMetadata of the op, to be passed to process() or resubmit()
155
+ * when the op is ACKed or resubmitted, respectively
156
+ */
157
+ applyStashedOp(message: any): unknown;
158
+
159
+ /**
160
+ * Revert a local op.
161
+ * @param message - The original message that was submitted.
162
+ * @param localOpMetadata - The local metadata associated with the original message.
163
+ */
164
+ rollback?(message: any, localOpMetadata: unknown): void;
130
165
  }
131
166
 
132
167
  /**
133
168
  * Interface to represent a connection to a delta notification stream.
169
+ * @public
134
170
  */
135
171
  export interface IDeltaConnection {
136
- connected: boolean;
137
-
138
- /**
139
- * Send new messages to the server.
140
- * @param messageContent - The content of the message to be sent.
141
- * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime
142
- * and not sent to the server. It will be provided back when this message is acknowledged by the server. It will
143
- * also be provided back when asked to resubmit the message.
144
- */
145
- submit(messageContent: any, localOpMetadata: unknown): void;
146
-
147
- /**
148
- * Attaches a message handler to the delta connection
149
- */
150
- attach(handler: IDeltaHandler): void;
151
-
152
- /**
153
- * Indicates that the channel is dirty and needs to be part of the summary. It is called by a SharedSummaryBlock
154
- * that needs to be part of the summary but does not generate ops.
155
- */
156
- dirty(): void;
157
-
158
- /**
159
- * Called when a new outbound reference is added to another node. This is used by garbage collection to identify
160
- * all references added in the system.
161
- * @param srcHandle - The handle of the node that added the reference.
162
- * @param outboundHandle - The handle of the outbound node that is referenced.
163
- */
164
- addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;
172
+ connected: boolean;
173
+
174
+ /**
175
+ * Send new messages to the server.
176
+ * @param messageContent - The content of the message to be sent.
177
+ * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime
178
+ * and not sent to the server. It will be provided back when this message is acknowledged by the server. It will
179
+ * also be provided back when asked to resubmit the message.
180
+ */
181
+ submit(messageContent: any, localOpMetadata: unknown): void;
182
+
183
+ /**
184
+ * Attaches a message handler to the delta connection
185
+ */
186
+ attach(handler: IDeltaHandler): void;
187
+
188
+ /**
189
+ * Indicates that the channel is dirty and needs to be part of the summary. It is called by a SharedSummaryBlock
190
+ * that needs to be part of the summary but does not generate ops.
191
+ */
192
+ dirty(): void;
193
+
194
+ /**
195
+ * Called when a new outbound reference is added to another node. This is used by garbage collection to identify
196
+ * all references added in the system.
197
+ * @param srcHandle - The handle of the node that added the reference.
198
+ * @param outboundHandle - The handle of the outbound node that is referenced.
199
+ */
200
+ addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;
165
201
  }
166
202
 
167
203
  /**
168
204
  * Storage services to read the objects at a given path.
205
+ * @public
169
206
  */
170
207
  export interface IChannelStorageService {
171
- /**
172
- * Reads the object contained at the given path. Returns a buffer representation for the object.
173
- */
174
- readBlob(path: string): Promise<ArrayBufferLike>;
175
-
176
- /**
177
- * Determines if there is an object contained at the given path.
178
- */
179
- contains(path: string): Promise<boolean>;
180
-
181
- /**
182
- * Lists the blobs that exist at a specific path.
183
- */
184
- list(path: string): Promise<string[]>;
208
+ /**
209
+ * Reads the object contained at the given path. Returns a buffer representation for the object.
210
+ */
211
+ readBlob(path: string): Promise<ArrayBufferLike>;
212
+
213
+ /**
214
+ * Determines if there is an object contained at the given path.
215
+ */
216
+ contains(path: string): Promise<boolean>;
217
+
218
+ /**
219
+ * Lists the blobs that exist at a specific path.
220
+ */
221
+ list(path: string): Promise<string[]>;
185
222
  }
186
223
 
187
224
  /**
188
225
  * Storage services to read the objects at a given path using the given delta connection.
226
+ * @public
189
227
  */
190
228
  export interface IChannelServices {
191
- deltaConnection: IDeltaConnection;
229
+ deltaConnection: IDeltaConnection;
192
230
 
193
- objectStorage: IChannelStorageService;
231
+ objectStorage: IChannelStorageService;
194
232
  }
195
233
 
196
234
  /**
197
- * Definitions of a channel factory. Factories follow a common model but enable custom behavior.
235
+ * Definitions of a channel factory.
236
+ *
237
+ * @remarks
238
+ *
239
+ * The runtime must be able to produce "channels" of the correct in-memory object type for the collaborative session.
240
+ * Here "channels" are typically distributed data structures (DDSs).
241
+ *
242
+ * The runtime will consult with a registry of such factories during
243
+ * {@link https://fluidframework.com/docs/build/containers/ | Container} load and when receiving "attach" operations
244
+ * (ops), which indicate a new instance of a channel being introduced to the collaboration session, to produce the
245
+ * appropriate in-memory object.
246
+ *
247
+ * Factories follow a common model but enable custom behavior.
248
+ *
249
+ * @example
250
+ *
251
+ * If a collaboration includes a {@link https://fluidframework.com/docs/data-structures/map/ | SharedMap},
252
+ * the collaborating clients will need to have access to a factory that can produce the `SharedMap` object.
253
+ * @public
198
254
  */
199
255
  export interface IChannelFactory {
200
- /**
201
- * String representing the type of the factory.
202
- */
203
- readonly type: string;
204
-
205
- /**
206
- * Attributes of the channel.
207
- */
208
- readonly attributes: IChannelAttributes;
209
-
210
- /**
211
- * Loads the given channel. This call is only ever invoked internally as the only thing
212
- * that is ever directly loaded is the document itself. Load will then only be called on documents that
213
- * were created and added to a channel.
214
- * @param runtime - Data store runtime containing state/info/helper methods about the data store.
215
- * @param id - ID of the channel.
216
- * @param services - Services to read objects at a given path using the delta connection.
217
- * @param channelAttributes - The attributes for the the channel to be loaded.
218
- * @returns The loaded object
219
- *
220
- * @privateRemarks
221
- * Thought: should the storage object include the version information and limit access to just files
222
- * for the given object? The latter seems good in general. But both are probably good things. We then just
223
- * need a way to allow the document to provide later storage for the object.
224
- */
225
- load(
226
- runtime: IFluidDataStoreRuntime,
227
- id: string,
228
- services: IChannelServices,
229
- channelAttributes: Readonly<IChannelAttributes>,
230
- ): Promise<IChannel>;
231
-
232
- /**
233
- * Creates a local version of the channel.
234
- * Calling attach on the object later will insert it into the object stream.
235
- * @param runtime - The runtime the new object will be associated with
236
- * @param id - The unique ID of the new object
237
- * @returns The newly created object.
238
- *
239
- * @privateRemarks
240
- * NOTE here - When we attach we need to submit all the pending ops prior to actually doing the attach
241
- * for consistency.
242
- */
243
- create(runtime: IFluidDataStoreRuntime, id: string): IChannel;
256
+ /**
257
+ * String representing the type of the factory.
258
+ */
259
+ readonly type: string;
260
+
261
+ /**
262
+ * Attributes of the channel.
263
+ */
264
+ readonly attributes: IChannelAttributes;
265
+
266
+ /**
267
+ * Loads the given channel. This call is only ever invoked internally as the only thing
268
+ * that is ever directly loaded is the document itself. Load will then only be called on documents that
269
+ * were created and added to a channel.
270
+ * @param runtime - Data store runtime containing state/info/helper methods about the data store.
271
+ * @param id - ID of the channel.
272
+ * @param services - Services to read objects at a given path using the delta connection.
273
+ * @param channelAttributes - The attributes for the the channel to be loaded.
274
+ * @returns The loaded object
275
+ *
276
+ * @privateRemarks
277
+ * Thought: should the storage object include the version information and limit access to just files
278
+ * for the given object? The latter seems good in general. But both are probably good things. We then just
279
+ * need a way to allow the document to provide later storage for the object.
280
+ */
281
+ load(
282
+ runtime: IFluidDataStoreRuntime,
283
+ id: string,
284
+ services: IChannelServices,
285
+ channelAttributes: Readonly<IChannelAttributes>,
286
+ ): Promise<IChannel>;
287
+
288
+ /**
289
+ * Creates a local version of the channel.
290
+ * Calling attach on the object later will insert it into the object stream.
291
+ * @param runtime - The runtime the new object will be associated with
292
+ * @param id - The unique ID of the new object
293
+ * @returns The newly created object.
294
+ *
295
+ * @privateRemarks
296
+ * NOTE here - When we attach we need to submit all the pending ops prior to actually doing the attach
297
+ * for consistency.
298
+ */
299
+ create(runtime: IFluidDataStoreRuntime, id: string): IChannel;
244
300
  }