@fluidframework/datastore-definitions 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229

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