@fluidframework/runtime-definitions 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 (55) hide show
  1. package/.eslintrc.cjs +12 -0
  2. package/CHANGELOG.md +330 -0
  3. package/README.md +43 -7
  4. package/api-extractor-lint.json +4 -0
  5. package/api-extractor.json +2 -2
  6. package/api-report/runtime-definitions.api.md +474 -0
  7. package/dist/attribution.d.ts +71 -0
  8. package/dist/attribution.d.ts.map +1 -0
  9. package/dist/attribution.js +7 -0
  10. package/dist/attribution.js.map +1 -0
  11. package/dist/dataStoreContext.d.ts +114 -61
  12. package/dist/dataStoreContext.d.ts.map +1 -1
  13. package/dist/dataStoreContext.js +27 -5
  14. package/dist/dataStoreContext.js.map +1 -1
  15. package/dist/dataStoreFactory.d.ts +7 -0
  16. package/dist/dataStoreFactory.d.ts.map +1 -1
  17. package/dist/dataStoreFactory.js +3 -0
  18. package/dist/dataStoreFactory.js.map +1 -1
  19. package/dist/dataStoreRegistry.d.ts +14 -4
  20. package/dist/dataStoreRegistry.d.ts.map +1 -1
  21. package/dist/dataStoreRegistry.js +3 -0
  22. package/dist/dataStoreRegistry.js.map +1 -1
  23. package/dist/garbageCollection.d.ts +35 -10
  24. package/dist/garbageCollection.d.ts.map +1 -1
  25. package/dist/garbageCollection.js +25 -3
  26. package/dist/garbageCollection.js.map +1 -1
  27. package/dist/index.d.ts +52 -6
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +26 -16
  30. package/dist/index.js.map +1 -1
  31. package/dist/protocol.d.ts +10 -3
  32. package/dist/protocol.d.ts.map +1 -1
  33. package/dist/protocol.js.map +1 -1
  34. package/dist/runtime-definitions-alpha.d.ts +993 -0
  35. package/dist/runtime-definitions-beta.d.ts +264 -0
  36. package/dist/runtime-definitions-public.d.ts +264 -0
  37. package/dist/runtime-definitions-untrimmed.d.ts +1068 -0
  38. package/dist/summary.d.ts +138 -70
  39. package/dist/summary.d.ts.map +1 -1
  40. package/dist/summary.js +13 -1
  41. package/dist/summary.js.map +1 -1
  42. package/dist/tsdoc-metadata.json +11 -0
  43. package/package.json +96 -41
  44. package/prettier.config.cjs +8 -0
  45. package/src/aliasing.md +42 -0
  46. package/src/attribution.ts +78 -0
  47. package/src/dataStoreContext.ts +432 -388
  48. package/src/dataStoreFactory.ts +21 -11
  49. package/src/dataStoreRegistry.ts +18 -6
  50. package/src/garbageCollection.ts +38 -15
  51. package/src/index.ts +111 -6
  52. package/src/protocol.ts +46 -38
  53. package/src/summary.ts +298 -225
  54. package/tsconfig.json +10 -12
  55. package/.eslintrc.js +0 -13
@@ -3,457 +3,501 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ITelemetryBaseLogger, IDisposable, IEvent, IEventProvider } from "@fluidframework/common-definitions";
7
6
  import {
8
- IFluidRouter,
9
- IProvideFluidHandleContext,
10
- IFluidHandle,
11
- IRequest,
12
- IResponse,
13
- FluidObject,
7
+ IEvent,
8
+ IEventProvider,
9
+ ITelemetryBaseLogger,
10
+ IDisposable,
11
+ IProvideFluidHandleContext,
12
+ IFluidHandle,
13
+ IRequest,
14
+ IResponse,
15
+ FluidObject,
14
16
  } from "@fluidframework/core-interfaces";
15
17
  import {
16
- IAudience,
17
- IDeltaManager,
18
- AttachState,
19
- ILoaderOptions,
18
+ IAudience,
19
+ IDeltaManager,
20
+ AttachState,
21
+ ILoaderOptions,
20
22
  } from "@fluidframework/container-definitions";
21
23
  import { IDocumentStorageService } from "@fluidframework/driver-definitions";
22
24
  import {
23
- IClientDetails,
24
- IDocumentMessage,
25
- IQuorumClients,
26
- ISequencedDocumentMessage,
27
- ISnapshotTree,
25
+ IClientDetails,
26
+ IDocumentMessage,
27
+ IQuorumClients,
28
+ ISequencedDocumentMessage,
29
+ ISnapshotTree,
28
30
  } from "@fluidframework/protocol-definitions";
31
+ import { IIdCompressor } from "@fluidframework/id-compressor";
29
32
  import { IProvideFluidDataStoreFactory } from "./dataStoreFactory";
30
33
  import { IProvideFluidDataStoreRegistry } from "./dataStoreRegistry";
31
- import {
32
- IGarbageCollectionData,
33
- IGarbageCollectionDetailsBase,
34
- IGarbageCollectionSummaryDetails,
35
- } from "./garbageCollection";
34
+ import { IGarbageCollectionData, IGarbageCollectionDetailsBase } from "./garbageCollection";
36
35
  import { IInboundSignalMessage } from "./protocol";
37
36
  import {
38
- CreateChildSummarizerNodeParam,
39
- ISummarizerNodeWithGC,
40
- ISummaryTreeWithStats,
41
- ITelemetryContext,
42
- SummarizeInternalFn,
37
+ CreateChildSummarizerNodeParam,
38
+ ISummarizerNodeWithGC,
39
+ ISummaryTreeWithStats,
40
+ ITelemetryContext,
41
+ SummarizeInternalFn,
43
42
  } from "./summary";
44
43
 
45
44
  /**
46
45
  * Runtime flush mode handling
46
+ * @alpha
47
47
  */
48
48
  export enum FlushMode {
49
- /**
50
- * In Immediate flush mode the runtime will immediately send all operations to the driver layer.
51
- */
52
- Immediate,
53
-
54
- /**
55
- * When in TurnBased flush mode the runtime will buffer operations in the current turn and send them as a single
56
- * batch at the end of the turn. The flush call on the runtime can be used to force send the current batch.
57
- */
58
- TurnBased,
49
+ /**
50
+ * In Immediate flush mode the runtime will immediately send all operations to the driver layer.
51
+ */
52
+ Immediate,
53
+
54
+ /**
55
+ * When in TurnBased flush mode the runtime will buffer operations in the current turn and send them as a single
56
+ * batch at the end of the turn. The flush call on the runtime can be used to force send the current batch.
57
+ */
58
+ TurnBased,
59
+ }
60
+
61
+ /**
62
+ * @internal
63
+ */
64
+ export enum FlushModeExperimental {
65
+ /**
66
+ * When in Async flush mode, the runtime will accumulate all operations across JS turns and send them as a single
67
+ * batch when all micro-tasks are complete.
68
+ *
69
+ * This feature requires a version of the loader which supports reference sequence numbers. If an older version of
70
+ * the loader is used, the runtime will fall back on FlushMode.TurnBased.
71
+ *
72
+ * @experimental - Not ready for use
73
+ */
74
+ Async = 2,
59
75
  }
60
76
 
61
77
  /**
62
78
  * This tells the visibility state of a Fluid object. It basically tracks whether the object is not visible, visible
63
79
  * locally within the container only or visible globally to all clients.
80
+ * @alpha
64
81
  */
65
82
  export const VisibilityState = {
66
- /** Indicates that the object is not visible. This is the state when an object is first created. */
67
- NotVisible: "NotVisible",
68
-
69
- /**
70
- * Indicates that the object is visible locally within the container. This is the state when an object is attached
71
- * to the container's graph but the container itself isn't globally visible. The object's state goes from not
72
- * visible to locally visible.
73
- */
74
- LocallyVisible: "LocallyVisible",
75
-
76
- /**
77
- * Indicates that the object is visible globally to all clients. This is the state of an object in 2 scenarios:
78
- * 1. It is attached to the container's graph when the container is globally visible. The object's state goes from
79
- * not visible to globally visible.
80
- * 2. When a container becomes globally visible, all locally visible objects go from locally visible to globally
81
- * visible.
82
- */
83
- GloballyVisible: "GloballyVisible",
83
+ /**
84
+ * Indicates that the object is not visible. This is the state when an object is first created.
85
+ */
86
+ NotVisible: "NotVisible",
87
+
88
+ /**
89
+ * Indicates that the object is visible locally within the container. This is the state when an object is attached
90
+ * to the container's graph but the container itself isn't globally visible. The object's state goes from not
91
+ * visible to locally visible.
92
+ */
93
+ LocallyVisible: "LocallyVisible",
94
+
95
+ /**
96
+ * Indicates that the object is visible globally to all clients. This is the state of an object in 2 scenarios:
97
+ *
98
+ * 1. It is attached to the container's graph when the container is globally visible. The object's state goes from
99
+ * not visible to globally visible.
100
+ *
101
+ * 2. When a container becomes globally visible, all locally visible objects go from locally visible to globally
102
+ * visible.
103
+ */
104
+ GloballyVisible: "GloballyVisible",
84
105
  };
85
- export type VisibilityState = typeof VisibilityState[keyof typeof VisibilityState];
106
+ /**
107
+ * @alpha
108
+ */
109
+ export type VisibilityState = (typeof VisibilityState)[keyof typeof VisibilityState];
86
110
 
87
- export interface IContainerRuntimeBaseEvents extends IEvent{
88
- (event: "batchBegin" | "op", listener: (op: ISequencedDocumentMessage) => void);
89
- (event: "batchEnd", listener: (error: any, op: ISequencedDocumentMessage) => void);
90
- (event: "signal", listener: (message: IInboundSignalMessage, local: boolean) => void);
111
+ /**
112
+ * @alpha
113
+ */
114
+ export interface IContainerRuntimeBaseEvents extends IEvent {
115
+ (event: "batchBegin", listener: (op: ISequencedDocumentMessage) => void);
116
+ /**
117
+ * @param runtimeMessage - tells if op is runtime op. If it is, it was unpacked, i.e. it's type and content
118
+ * represent internal container runtime type / content.
119
+ */
120
+ (event: "op", listener: (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => void);
121
+ (event: "batchEnd", listener: (error: any, op: ISequencedDocumentMessage) => void);
122
+ (event: "signal", listener: (message: IInboundSignalMessage, local: boolean) => void);
91
123
  }
92
124
 
93
125
  /**
94
126
  * Encapsulates the return codes of the aliasing API.
95
127
  *
96
128
  * 'Success' - the datastore has been successfully aliased. It can now be used.
97
- * 'Conflict' - there is already a datastore bound to the provided alias. To acquire a handle to it,
98
- * use the `IContainerRuntime.getRootDataStore` function. The current datastore should be discarded
129
+ * 'Conflict' - there is already a datastore bound to the provided alias. To acquire it's entry point, use
130
+ * the `IContainerRuntime.getAliasedDataStoreEntryPoint` function. The current datastore should be discarded
99
131
  * and will be garbage collected. The current datastore cannot be aliased to a different value.
100
- * 'Aliasing' (deprecated) - this value is never returned.
101
132
  * 'AlreadyAliased' - the datastore has already been previously bound to another alias name.
133
+ * @alpha
102
134
  */
103
- export type AliasResult = "Success" | "Conflict" | "Aliasing" | "AlreadyAliased";
135
+ export type AliasResult = "Success" | "Conflict" | "AlreadyAliased";
104
136
 
105
137
  /**
106
- * A fluid router with the capability of being assigned an alias
138
+ * Exposes some functionality/features of a data store:
139
+ * - Handle to the data store's entryPoint
140
+ * - Fluid router for the data store
141
+ * - Can be assigned an alias
142
+ * @alpha
107
143
  */
108
- export interface IDataStore extends IFluidRouter {
109
- /**
110
- * Attempt to assign an alias to the datastore.
111
- * If the operation succeeds, the datastore can be referenced
112
- * by the supplied alias and will not be garbage collected.
113
- *
114
- * @param alias - Given alias for this datastore.
115
- */
116
- trySetAlias(alias: string): Promise<AliasResult>;
144
+ export interface IDataStore {
145
+ /**
146
+ * Attempt to assign an alias to the datastore.
147
+ * If the operation succeeds, the datastore can be referenced
148
+ * by the supplied alias and will not be garbage collected.
149
+ *
150
+ * @param alias - Given alias for this datastore.
151
+ * @returns A promise with the {@link AliasResult}
152
+ */
153
+ trySetAlias(alias: string): Promise<AliasResult>;
154
+
155
+ /**
156
+ * Exposes a handle to the root object / entryPoint of the data store. Use this as the primary way of interacting
157
+ * with it.
158
+ */
159
+ readonly entryPoint: IFluidHandle<FluidObject>;
117
160
  }
118
161
 
119
162
  /**
120
163
  * A reduced set of functionality of IContainerRuntime that a data store context/data store runtime will need
121
164
  * TODO: this should be merged into IFluidDataStoreContext
165
+ * @alpha
122
166
  */
123
- export interface IContainerRuntimeBase extends
124
- IEventProvider<IContainerRuntimeBaseEvents>,
125
- IProvideFluidHandleContext {
126
-
127
- readonly logger: ITelemetryBaseLogger;
128
- readonly clientDetails: IClientDetails;
129
-
130
- /**
131
- * Invokes the given callback and guarantees that all operations generated within the callback will be ordered
132
- * sequentially. Total size of all messages must be less than maxOpSize.
133
- */
134
- orderSequentially(callback: () => void): void;
135
-
136
- /**
137
- * Sets the flush mode for operations on the document.
138
- * @deprecated - Will be removed in 0.60. See #9480.
139
- */
140
- setFlushMode(mode: FlushMode): void;
141
-
142
- /**
143
- * Executes a request against the container runtime
144
- */
145
- request(request: IRequest): Promise<IResponse>;
146
-
147
- /**
148
- * Submits a container runtime level signal to be sent to other clients.
149
- * @param type - Type of the signal.
150
- * @param content - Content of the signal.
151
- */
152
- submitSignal(type: string, content: any): void;
153
-
154
- /**
155
- * @deprecated 0.16 Issue #1537, #3631
156
- * @internal
157
- */
158
- _createDataStoreWithProps(
159
- pkg: string | string[],
160
- props?: any,
161
- id?: string,
162
- isRoot?: boolean,
163
- ): Promise<IDataStore>;
164
-
165
- /**
166
- * Creates data store. Returns router of data store. Data store is not bound to container,
167
- * store in such state is not persisted to storage (file). Storing a handle to this store
168
- * (or any of its parts, like DDS) into already attached DDS (or non-attached DDS that will eventually
169
- * gets attached to storage) will result in this store being attached to storage.
170
- * @param pkg - Package name of the data store factory
171
- */
172
- createDataStore(pkg: string | string[]): Promise<IDataStore>;
173
-
174
- /**
175
- * Creates detached data store context. Only after context.attachRuntime() is called,
176
- * data store initialization is considered complete.
177
- */
178
- createDetachedDataStore(pkg: Readonly<string[]>): IFluidDataStoreContextDetached;
179
-
180
- /**
181
- * Get an absolute url for a provided container-relative request.
182
- * Returns undefined if the container or data store isn't attached to storage.
183
- * @param relativeUrl - A relative request within the container
184
- */
185
- getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
186
-
187
- uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;
188
-
189
- /**
190
- * Returns the current quorum.
191
- */
192
- getQuorum(): IQuorumClients;
193
-
194
- /**
195
- * Returns the current audience.
196
- */
197
- getAudience(): IAudience;
167
+ export interface IContainerRuntimeBase extends IEventProvider<IContainerRuntimeBaseEvents> {
168
+ readonly logger: ITelemetryBaseLogger;
169
+ readonly clientDetails: IClientDetails;
170
+
171
+ /**
172
+ * Invokes the given callback and guarantees that all operations generated within the callback will be ordered
173
+ * sequentially. Total size of all messages must be less than maxOpSize.
174
+ */
175
+ orderSequentially(callback: () => void): void;
176
+
177
+ /**
178
+ * Submits a container runtime level signal to be sent to other clients.
179
+ * @param type - Type of the signal.
180
+ * @param content - Content of the signal.
181
+ */
182
+ submitSignal(type: string, content: any): void;
183
+
184
+ /**
185
+ * @deprecated 0.16 Issue #1537, #3631
186
+ */
187
+ _createDataStoreWithProps(
188
+ pkg: string | string[],
189
+ props?: any,
190
+ id?: string,
191
+ ): Promise<IDataStore>;
192
+
193
+ /**
194
+ * Creates a data store and returns an object that exposes a handle to the data store's entryPoint, and also serves
195
+ * as the data store's router. The data store is not bound to a container, and in such state is not persisted to
196
+ * storage (file). Storing the entryPoint handle (or any other handle inside the data store, e.g. for DDS) into an
197
+ * already attached DDS (or non-attached DDS that will eventually get attached to storage) will result in this
198
+ * store being attached to storage.
199
+ * @param pkg - Package name of the data store factory
200
+ */
201
+ createDataStore(pkg: string | string[]): Promise<IDataStore>;
202
+
203
+ /**
204
+ * Creates detached data store context. Only after context.attachRuntime() is called,
205
+ * data store initialization is considered complete.
206
+ */
207
+ createDetachedDataStore(pkg: Readonly<string[]>): IFluidDataStoreContextDetached;
208
+
209
+ /**
210
+ * Get an absolute url for a provided container-relative request.
211
+ * Returns undefined if the container or data store isn't attached to storage.
212
+ * @param relativeUrl - A relative request within the container
213
+ */
214
+ getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
215
+
216
+ uploadBlob(blob: ArrayBufferLike, signal?: AbortSignal): Promise<IFluidHandle<ArrayBufferLike>>;
217
+
218
+ /**
219
+ * Returns the current quorum.
220
+ */
221
+ getQuorum(): IQuorumClients;
222
+
223
+ /**
224
+ * Returns the current audience.
225
+ */
226
+ getAudience(): IAudience;
198
227
  }
199
228
 
200
229
  /**
201
- * Minimal interface a data store runtime need to provide for IFluidDataStoreContext to bind to control
230
+ * Minimal interface a data store runtime needs to provide for IFluidDataStoreContext to bind to control.
202
231
  *
203
- * Functionality include attach, snapshot, op/signal processing, request routes,
232
+ * Functionality include attach, snapshot, op/signal processing, request routes, expose an entryPoint,
204
233
  * and connection state notifications
234
+ * @alpha
205
235
  */
206
- export interface IFluidDataStoreChannel extends
207
- IFluidRouter,
208
- IDisposable {
209
-
210
- readonly id: string;
211
-
212
- /**
213
- * Indicates the attachment state of the channel to a host service.
214
- */
215
- readonly attachState: AttachState;
216
-
217
- readonly visibilityState?: VisibilityState;
218
-
219
- /**
220
- * @deprecated - This is an internal method that should not be exposed.
221
- * Called to bind the runtime to the container.
222
- * If the container is not attached to storage, then this would also be unknown to other clients.
223
- */
224
- bindToContext(): void;
225
-
226
- /**
227
- * @deprecated - This will be removed in favor of makeVisibleAndAttachGraph.
228
- * Runs through the graph and attaches the bound handles. Then binds this runtime to the container.
229
- */
230
- attachGraph(): void;
231
-
232
- /**
233
- * Makes the data store channel visible in the container. Also, runs through its graph and attaches all
234
- * bound handles that represent its dependencies in the container's graph.
235
- */
236
- makeVisibleAndAttachGraph?(): void;
237
-
238
- /**
239
- * Retrieves the summary used as part of the initial summary message
240
- */
241
- getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
242
-
243
- /**
244
- * Processes the op.
245
- */
246
- process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
247
-
248
- /**
249
- * Processes the signal.
250
- */
251
- processSignal(message: any, local: boolean): void;
252
-
253
- /**
254
- * Generates a summary for the channel.
255
- * Introduced with summarizerNode - will be required in a future release.
256
- * @param fullTree - true to bypass optimizations and force a full summary tree.
257
- * @param trackState - This tells whether we should track state from this summary.
258
- * @param telemetryContext - summary data passed through the layers for telemetry purposes
259
- */
260
- summarize(
261
- fullTree?: boolean,
262
- trackState?: boolean,
263
- telemetryContext?: ITelemetryContext,
264
- ): Promise<ISummaryTreeWithStats>;
265
-
266
- /**
267
- * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context
268
- * including any of its children. Each node has a list of outbound routes to other GC nodes in the document.
269
- * @param fullGC - true to bypass optimizations and force full generation of GC data.
270
- */
271
- getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
272
-
273
- /**
274
- * After GC has run, called to notify this channel of routes that are used in it.
275
- * @param usedRoutes - The routes that are used in this channel.
276
- * @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
277
- * as part of this GC run, this should be used to update the time when it happens.
278
- */
279
- updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): void;
280
-
281
- /**
282
- * Notifies this object about changes in the connection state.
283
- * @param value - New connection state.
284
- * @param clientId - ID of the client. It's old ID when in disconnected state and
285
- * it's new client ID when we are connecting or connected.
286
- */
287
- setConnectionState(connected: boolean, clientId?: string);
288
-
289
- /**
290
- * Ask the DDS to resubmit a message. This could be because we reconnected and this message was not acked.
291
- * @param type - The type of the original message.
292
- * @param content - The content of the original message.
293
- * @param localOpMetadata - The local metadata associated with the original message.
294
- */
295
- reSubmit(type: string, content: any, localOpMetadata: unknown);
296
-
297
- applyStashedOp(content: any): Promise<unknown>;
298
-
299
- /**
300
- * Revert a local message.
301
- * @param type - The type of the original message.
302
- * @param content - The content of the original message.
303
- * @param localOpMetadata - The local metadata associated with the original message.
304
- */
305
- rollback?(type: string, content: any, localOpMetadata: unknown): void;
236
+ export interface IFluidDataStoreChannel extends IDisposable {
237
+ readonly id: string;
238
+
239
+ /**
240
+ * Indicates the attachment state of the channel to a host service.
241
+ */
242
+ readonly attachState: AttachState;
243
+
244
+ readonly visibilityState: VisibilityState;
245
+
246
+ /**
247
+ * Runs through the graph and attaches the bound handles. Then binds this runtime to the container.
248
+ * @deprecated This will be removed in favor of {@link IFluidDataStoreChannel.makeVisibleAndAttachGraph}.
249
+ */
250
+ attachGraph(): void;
251
+
252
+ /**
253
+ * Makes the data store channel visible in the container. Also, runs through its graph and attaches all
254
+ * bound handles that represent its dependencies in the container's graph.
255
+ */
256
+ makeVisibleAndAttachGraph(): void;
257
+
258
+ /**
259
+ * Retrieves the summary used as part of the initial summary message
260
+ */
261
+ getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
262
+
263
+ /**
264
+ * Processes the op.
265
+ */
266
+ process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
267
+
268
+ /**
269
+ * Processes the signal.
270
+ */
271
+ processSignal(message: any, local: boolean): void;
272
+
273
+ /**
274
+ * Generates a summary for the channel.
275
+ * Introduced with summarizerNode - will be required in a future release.
276
+ * @param fullTree - true to bypass optimizations and force a full summary tree.
277
+ * @param trackState - This tells whether we should track state from this summary.
278
+ * @param telemetryContext - summary data passed through the layers for telemetry purposes
279
+ */
280
+ summarize(
281
+ fullTree?: boolean,
282
+ trackState?: boolean,
283
+ telemetryContext?: ITelemetryContext,
284
+ ): Promise<ISummaryTreeWithStats>;
285
+
286
+ /**
287
+ * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context
288
+ * including any of its children. Each node has a list of outbound routes to other GC nodes in the document.
289
+ * @param fullGC - true to bypass optimizations and force full generation of GC data.
290
+ */
291
+ getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
292
+
293
+ /**
294
+ * After GC has run, called to notify this channel of routes that are used in it.
295
+ * @param usedRoutes - The routes that are used in this channel.
296
+ */
297
+ updateUsedRoutes(usedRoutes: string[]): void;
298
+
299
+ /**
300
+ * Notifies this object about changes in the connection state.
301
+ * @param value - New connection state.
302
+ * @param clientId - ID of the client. It's old ID when in disconnected state and
303
+ * it's new client ID when we are connecting or connected.
304
+ */
305
+ setConnectionState(connected: boolean, clientId?: string);
306
+
307
+ /**
308
+ * Ask the DDS to resubmit a message. This could be because we reconnected and this message was not acked.
309
+ * @param type - The type of the original message.
310
+ * @param content - The content of the original message.
311
+ * @param localOpMetadata - The local metadata associated with the original message.
312
+ */
313
+ reSubmit(type: string, content: any, localOpMetadata: unknown);
314
+
315
+ applyStashedOp(content: any): Promise<unknown>;
316
+
317
+ /**
318
+ * Revert a local message.
319
+ * @param type - The type of the original message.
320
+ * @param content - The content of the original message.
321
+ * @param localOpMetadata - The local metadata associated with the original message.
322
+ */
323
+ rollback?(type: string, content: any, localOpMetadata: unknown): void;
324
+
325
+ /**
326
+ * Exposes a handle to the root object / entryPoint of the component. Use this as the primary way of interacting
327
+ * with the component.
328
+ */
329
+ readonly entryPoint: IFluidHandle<FluidObject>;
330
+
331
+ request(request: IRequest): Promise<IResponse>;
306
332
  }
307
333
 
334
+ /**
335
+ * @alpha
336
+ */
308
337
  export type CreateChildSummarizerNodeFn = (
309
- summarizeInternal: SummarizeInternalFn,
310
- getGCDataFn: (fullGC?: boolean) => Promise<IGarbageCollectionData>,
311
- getInitialGCSummaryDetailsFn: () => Promise<IGarbageCollectionSummaryDetails>,
338
+ summarizeInternal: SummarizeInternalFn,
339
+ getGCDataFn: (fullGC?: boolean) => Promise<IGarbageCollectionData>,
340
+ /**
341
+ * @deprecated The functionality to get base GC details has been moved to summarizer node.
342
+ */
343
+ getBaseGCDetailsFn?: () => Promise<IGarbageCollectionDetailsBase>,
312
344
  ) => ISummarizerNodeWithGC;
313
345
 
346
+ /**
347
+ * @alpha
348
+ */
314
349
  export interface IFluidDataStoreContextEvents extends IEvent {
315
- (event: "attaching" | "attached", listener: () => void);
350
+ (event: "attaching" | "attached", listener: () => void);
316
351
  }
317
352
 
318
353
  /**
319
354
  * Represents the context for the data store. It is used by the data store runtime to
320
355
  * get information and call functionality to the container.
356
+ * @alpha
321
357
  */
322
- export interface IFluidDataStoreContext extends
323
- IEventProvider<IFluidDataStoreContextEvents>,
324
- Partial<IProvideFluidDataStoreRegistry>,
325
- IProvideFluidHandleContext {
326
- readonly id: string;
327
- /**
328
- * A data store created by a client, is a local data store for that client. Also, when a detached container loads
329
- * from a snapshot, all the data stores are treated as local data stores because at that stage the container
330
- * still doesn't exists in storage and so the data store couldn't have been created by any other client.
331
- * Value of this never changes even after the data store is attached.
332
- * As implementer of data store runtime, you can use this property to check that this data store belongs to this
333
- * client and hence implement any scenario based on that.
334
- */
335
- readonly isLocalDataStore: boolean;
336
- /**
337
- * The package path of the data store as per the package factory.
338
- */
339
- readonly packagePath: readonly string[];
340
- readonly options: ILoaderOptions;
341
- readonly clientId: string | undefined;
342
- readonly connected: boolean;
343
- readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
344
- readonly storage: IDocumentStorageService;
345
- readonly baseSnapshot: ISnapshotTree | undefined;
346
- readonly logger: ITelemetryBaseLogger;
347
- readonly clientDetails: IClientDetails;
348
- /**
349
- * Indicates the attachment state of the data store to a host service.
350
- */
351
- readonly attachState: AttachState;
352
-
353
- readonly containerRuntime: IContainerRuntimeBase;
354
-
355
- /**
356
- * @deprecated 0.16 Issue #1635, #3631
357
- */
358
- readonly createProps?: any;
359
-
360
- /**
361
- * Ambient services provided with the context
362
- */
363
- readonly scope: FluidObject;
364
-
365
- /**
366
- * Returns the current quorum.
367
- */
368
- getQuorum(): IQuorumClients;
369
-
370
- /**
371
- * Returns the current audience.
372
- */
373
- getAudience(): IAudience;
374
-
375
- /**
376
- * Submits the message to be sent to other clients.
377
- * @param type - Type of the message.
378
- * @param content - Content of the message.
379
- * @param localOpMetadata - The local metadata associated with the message. This is kept locally and not sent to
380
- * the server. This will be sent back when this message is received back from the server. This is also sent if
381
- * we are asked to resubmit the message.
382
- */
383
- submitMessage(type: string, content: any, localOpMetadata: unknown): void;
384
-
385
- /**
386
- * Submits the signal to be sent to other clients.
387
- * @param type - Type of the signal.
388
- * @param content - Content of the signal.
389
- */
390
- submitSignal(type: string, content: any): void;
391
-
392
- /**
393
- * @deprecated - To be removed in favor of makeVisible.
394
- * Register the runtime to the container
395
- */
396
- bindToContext(): void;
397
-
398
- /**
399
- * Called to make the data store locally visible in the container. This happens automatically for root data stores
400
- * when they are marked as root. For non-root data stores, this happens when their handle is added to a visible DDS.
401
- */
402
- makeLocallyVisible?(): void;
403
-
404
- /**
405
- * Call by IFluidDataStoreChannel, indicates that a channel is dirty and needs to be part of the summary.
406
- * @param address - The address of the channel that is dirty.
407
- */
408
- setChannelDirty(address: string): void;
409
-
410
- /**
411
- * Get an absolute url to the container based on the provided relativeUrl.
412
- * Returns undefined if the container or data store isn't attached to storage.
413
- * @param relativeUrl - A relative request within the container
414
- */
415
- getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
416
-
417
- getCreateChildSummarizerNodeFn(
418
- /** Initial id or path part of this node */
419
- id: string,
420
- /**
421
- * Information needed to create the node.
422
- * If it is from a base summary, it will assert that a summary has been seen.
423
- * Attach information if it is created from an attach op.
424
- * If it is local, it will throw unsupported errors on calls to summarize.
425
- */
426
- createParam: CreateChildSummarizerNodeParam,
427
- ): CreateChildSummarizerNodeFn;
428
-
429
- uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;
430
-
431
- /**
432
- * @deprecated - Renamed to getBaseGCDetails.
433
- */
434
- getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
435
-
436
- /**
437
- * Returns the GC details in the initial summary of this data store. This is used to initialize the data store
438
- * and its children with the GC details from the previous summary.
439
- */
440
- getBaseGCDetails?(): Promise<IGarbageCollectionDetailsBase>;
441
-
442
- /**
443
- * Called when a new outbound reference is added to another node. This is used by garbage collection to identify
444
- * all references added in the system.
445
- * @param srcHandle - The handle of the node that added the reference.
446
- * @param outboundHandle - The handle of the outbound node that is referenced.
447
- */
448
- addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;
358
+ export interface IFluidDataStoreContext
359
+ extends IEventProvider<IFluidDataStoreContextEvents>,
360
+ Partial<IProvideFluidDataStoreRegistry>,
361
+ IProvideFluidHandleContext {
362
+ readonly id: string;
363
+ /**
364
+ * A data store created by a client, is a local data store for that client. Also, when a detached container loads
365
+ * from a snapshot, all the data stores are treated as local data stores because at that stage the container
366
+ * still doesn't exists in storage and so the data store couldn't have been created by any other client.
367
+ * Value of this never changes even after the data store is attached.
368
+ * As implementer of data store runtime, you can use this property to check that this data store belongs to this
369
+ * client and hence implement any scenario based on that.
370
+ */
371
+ readonly isLocalDataStore: boolean;
372
+ /**
373
+ * The package path of the data store as per the package factory.
374
+ */
375
+ readonly packagePath: readonly string[];
376
+ readonly options: ILoaderOptions;
377
+ readonly clientId: string | undefined;
378
+ readonly connected: boolean;
379
+ readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
380
+ readonly storage: IDocumentStorageService;
381
+ readonly baseSnapshot: ISnapshotTree | undefined;
382
+ readonly logger: ITelemetryBaseLogger;
383
+ readonly clientDetails: IClientDetails;
384
+ readonly idCompressor?: IIdCompressor;
385
+ /**
386
+ * Indicates the attachment state of the data store to a host service.
387
+ */
388
+ readonly attachState: AttachState;
389
+
390
+ readonly containerRuntime: IContainerRuntimeBase;
391
+
392
+ /**
393
+ * @deprecated 0.16 Issue #1635, #3631
394
+ */
395
+ readonly createProps?: any;
396
+
397
+ /**
398
+ * Ambient services provided with the context
399
+ */
400
+ readonly scope: FluidObject;
401
+
402
+ /**
403
+ * Returns the current quorum.
404
+ */
405
+ getQuorum(): IQuorumClients;
406
+
407
+ /**
408
+ * Returns the current audience.
409
+ */
410
+ getAudience(): IAudience;
411
+
412
+ /**
413
+ * Invokes the given callback and expects that no ops are submitted
414
+ * until execution finishes. If an op is submitted, an error will be raised.
415
+ *
416
+ * Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`
417
+ *
418
+ * @param callback - the callback to be invoked
419
+ */
420
+ ensureNoDataModelChanges<T>(callback: () => T): T;
421
+
422
+ /**
423
+ * Submits the message to be sent to other clients.
424
+ * @param type - Type of the message.
425
+ * @param content - Content of the message.
426
+ * @param localOpMetadata - The local metadata associated with the message. This is kept locally and not sent to
427
+ * the server. This will be sent back when this message is received back from the server. This is also sent if
428
+ * we are asked to resubmit the message.
429
+ */
430
+ submitMessage(type: string, content: any, localOpMetadata: unknown): void;
431
+
432
+ /**
433
+ * Submits the signal to be sent to other clients.
434
+ * @param type - Type of the signal.
435
+ * @param content - Content of the signal.
436
+ * @param targetClientId - When specified, the signal is only sent to the provided client id.
437
+ */
438
+ submitSignal(type: string, content: any, targetClientId?: string): void;
439
+
440
+ /**
441
+ * Called to make the data store locally visible in the container. This happens automatically for root data stores
442
+ * when they are marked as root. For non-root data stores, this happens when their handle is added to a visible DDS.
443
+ */
444
+ makeLocallyVisible(): void;
445
+
446
+ /**
447
+ * Call by IFluidDataStoreChannel, indicates that a channel is dirty and needs to be part of the summary.
448
+ * @param address - The address of the channel that is dirty.
449
+ */
450
+ setChannelDirty(address: string): void;
451
+
452
+ /**
453
+ * Get an absolute url to the container based on the provided relativeUrl.
454
+ * Returns undefined if the container or data store isn't attached to storage.
455
+ * @param relativeUrl - A relative request within the container
456
+ */
457
+ getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
458
+
459
+ getCreateChildSummarizerNodeFn(
460
+ /**
461
+ * Initial id or path part of this node
462
+ */
463
+ id: string,
464
+ /**
465
+ * Information needed to create the node.
466
+ * If it is from a base summary, it will assert that a summary has been seen.
467
+ * Attach information if it is created from an attach op.
468
+ * If it is local, it will throw unsupported errors on calls to summarize.
469
+ */
470
+ createParam: CreateChildSummarizerNodeParam,
471
+ ): CreateChildSummarizerNodeFn;
472
+
473
+ uploadBlob(blob: ArrayBufferLike, signal?: AbortSignal): Promise<IFluidHandle<ArrayBufferLike>>;
474
+
475
+ /**
476
+ * @deprecated The functionality to get base GC details has been moved to summarizer node.
477
+ *
478
+ * Returns the GC details in the initial summary of this data store. This is used to initialize the data store
479
+ * and its children with the GC details from the previous summary.
480
+ */
481
+ getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
482
+
483
+ /**
484
+ * Called when a new outbound reference is added to another node. This is used by garbage collection to identify
485
+ * all references added in the system.
486
+ * @param srcHandle - The handle of the node that added the reference.
487
+ * @param outboundHandle - The handle of the outbound node that is referenced.
488
+ */
489
+ addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;
449
490
  }
450
491
 
492
+ /**
493
+ * @alpha
494
+ */
451
495
  export interface IFluidDataStoreContextDetached extends IFluidDataStoreContext {
452
- /**
453
- * Binds a runtime to the context.
454
- */
455
- attachRuntime(
456
- factory: IProvideFluidDataStoreFactory,
457
- dataStoreRuntime: IFluidDataStoreChannel,
458
- ): Promise<void>;
496
+ /**
497
+ * Binds a runtime to the context.
498
+ */
499
+ attachRuntime(
500
+ factory: IProvideFluidDataStoreFactory,
501
+ dataStoreRuntime: IFluidDataStoreChannel,
502
+ ): Promise<void>;
459
503
  }