@fluidframework/container-definitions 2.0.0-dev.2.3.0.115467 → 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 (72) hide show
  1. package/.eslintrc.js +20 -9
  2. package/README.md +5 -5
  3. package/api-extractor.json +2 -2
  4. package/dist/audience.d.ts +3 -4
  5. package/dist/audience.d.ts.map +1 -1
  6. package/dist/audience.js.map +1 -1
  7. package/dist/browserPackage.d.ts.map +1 -1
  8. package/dist/browserPackage.js +3 -3
  9. package/dist/browserPackage.js.map +1 -1
  10. package/dist/deltas.d.ts +12 -0
  11. package/dist/deltas.d.ts.map +1 -1
  12. package/dist/deltas.js.map +1 -1
  13. package/dist/error.d.ts.map +1 -1
  14. package/dist/error.js.map +1 -1
  15. package/dist/fluidModule.d.ts.map +1 -1
  16. package/dist/fluidModule.js.map +1 -1
  17. package/dist/fluidPackage.d.ts.map +1 -1
  18. package/dist/fluidPackage.js +5 -6
  19. package/dist/fluidPackage.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/loader.d.ts +20 -2
  24. package/dist/loader.d.ts.map +1 -1
  25. package/dist/loader.js.map +1 -1
  26. package/dist/runtime.d.ts +2 -1
  27. package/dist/runtime.d.ts.map +1 -1
  28. package/dist/runtime.js.map +1 -1
  29. package/dist/tokenProvider.d.ts.map +1 -1
  30. package/dist/tokenProvider.js.map +1 -1
  31. package/lib/audience.d.ts +3 -4
  32. package/lib/audience.d.ts.map +1 -1
  33. package/lib/audience.js.map +1 -1
  34. package/lib/browserPackage.d.ts.map +1 -1
  35. package/lib/browserPackage.js +3 -3
  36. package/lib/browserPackage.js.map +1 -1
  37. package/lib/deltas.d.ts +12 -0
  38. package/lib/deltas.d.ts.map +1 -1
  39. package/lib/deltas.js.map +1 -1
  40. package/lib/error.d.ts.map +1 -1
  41. package/lib/error.js.map +1 -1
  42. package/lib/fluidModule.d.ts.map +1 -1
  43. package/lib/fluidModule.js.map +1 -1
  44. package/lib/fluidPackage.d.ts.map +1 -1
  45. package/lib/fluidPackage.js +5 -6
  46. package/lib/fluidPackage.js.map +1 -1
  47. package/lib/index.d.ts +1 -1
  48. package/lib/index.d.ts.map +1 -1
  49. package/lib/index.js +1 -1
  50. package/lib/index.js.map +1 -1
  51. package/lib/loader.d.ts +20 -2
  52. package/lib/loader.d.ts.map +1 -1
  53. package/lib/loader.js.map +1 -1
  54. package/lib/runtime.d.ts +2 -1
  55. package/lib/runtime.d.ts.map +1 -1
  56. package/lib/runtime.js.map +1 -1
  57. package/lib/tokenProvider.d.ts.map +1 -1
  58. package/lib/tokenProvider.js.map +1 -1
  59. package/package.json +17 -14
  60. package/prettier.config.cjs +1 -1
  61. package/src/audience.ts +25 -22
  62. package/src/browserPackage.ts +33 -34
  63. package/src/deltas.ts +267 -245
  64. package/src/error.ts +58 -58
  65. package/src/fluidModule.ts +1 -1
  66. package/src/fluidPackage.ts +86 -86
  67. package/src/index.ts +51 -47
  68. package/src/loader.ts +498 -489
  69. package/src/runtime.ts +144 -148
  70. package/src/tokenProvider.ts +2 -2
  71. package/tsconfig.esnext.json +6 -6
  72. package/tsconfig.json +8 -15
package/src/loader.ts CHANGED
@@ -3,18 +3,14 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { IRequest, IResponse, IFluidRouter } from "@fluidframework/core-interfaces";
6
7
  import {
7
- IRequest,
8
- IResponse,
9
- IFluidRouter,
10
- } from "@fluidframework/core-interfaces";
11
- import {
12
- IClientDetails,
13
- IDocumentMessage,
14
- IQuorumClients,
15
- ISequencedDocumentMessage,
16
- ISequencedProposal,
17
- ISnapshotTree,
8
+ IClientDetails,
9
+ IDocumentMessage,
10
+ IQuorumClients,
11
+ ISequencedDocumentMessage,
12
+ ISequencedProposal,
13
+ ISnapshotTree,
18
14
  } from "@fluidframework/protocol-definitions";
19
15
  import { IResolvedUrl } from "@fluidframework/driver-definitions";
20
16
  import { IEvent, IEventProvider } from "@fluidframework/common-definitions";
@@ -23,43 +19,38 @@ import { IDeltaManager, ReadOnlyInfo } from "./deltas";
23
19
  import { ICriticalContainerError, ContainerWarning } from "./error";
24
20
  import { IFluidModule } from "./fluidModule";
25
21
  import { AttachState } from "./runtime";
26
- import {
27
- IFluidCodeDetails,
28
- IFluidPackage,
29
- IProvideFluidCodeDetailsComparer,
30
- } from "./fluidPackage";
22
+ import { IFluidCodeDetails, IFluidPackage, IProvideFluidCodeDetailsComparer } from "./fluidPackage";
31
23
 
32
24
  /**
33
25
  * Encapsulates a module entry point with corresponding code details.
34
26
  */
35
27
  export interface IFluidModuleWithDetails {
36
- /**
37
- * Fluid code module that implements the runtime factory needed to instantiate the container runtime.
38
- */
39
- module: IFluidModule;
40
-
41
- /**
42
- * Code details associated with the module. Represents a document schema this module supports.
43
- * If the code loader implements the {@link @fluidframework/core-interfaces#(IFluidCodeDetailsComparer:interface)}
44
- * interface, it'll be called to determine whether the module code details satisfy the new code proposal in the
45
- * quorum.
46
- */
47
- details: IFluidCodeDetails;
28
+ /**
29
+ * Fluid code module that implements the runtime factory needed to instantiate the container runtime.
30
+ */
31
+ module: IFluidModule;
32
+
33
+ /**
34
+ * Code details associated with the module. Represents a document schema this module supports.
35
+ * If the code loader implements the {@link @fluidframework/core-interfaces#(IFluidCodeDetailsComparer:interface)}
36
+ * interface, it'll be called to determine whether the module code details satisfy the new code proposal in the
37
+ * quorum.
38
+ */
39
+ details: IFluidCodeDetails;
48
40
  }
49
41
 
50
42
  /**
51
43
  * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as
52
44
  * a package name and package version range.
53
45
  */
54
- export interface ICodeDetailsLoader
55
- extends Partial<IProvideFluidCodeDetailsComparer> {
56
- /**
57
- * Load the code module (package) that can interact with the document.
58
- *
59
- * @param source - Code proposal that articulates the current schema the document is written in.
60
- * @returns - Code module entry point along with the code details associated with it.
61
- */
62
- load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;
46
+ export interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {
47
+ /**
48
+ * Load the code module (package) that can interact with the document.
49
+ *
50
+ * @param source - Code proposal that articulates the current schema the document is written in.
51
+ * @returns - Code module entry point along with the code details associated with it.
52
+ */
53
+ load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;
63
54
  }
64
55
 
65
56
  /**
@@ -67,14 +58,14 @@ export interface ICodeDetailsLoader
67
58
  * that have been resolved and are ready to load
68
59
  */
69
60
  export interface IResolvedFluidCodeDetails extends IFluidCodeDetails {
70
- /**
71
- * A resolved version of the Fluid package. All Fluid browser file entries should be absolute urls.
72
- */
73
- readonly resolvedPackage: Readonly<IFluidPackage>;
74
- /**
75
- * If not undefined, this id will be used to cache the entry point for the code package
76
- */
77
- readonly resolvedPackageCacheId: string | undefined;
61
+ /**
62
+ * A resolved version of the Fluid package. All Fluid browser file entries should be absolute urls.
63
+ */
64
+ readonly resolvedPackage: Readonly<IFluidPackage>;
65
+ /**
66
+ * If not undefined, this id will be used to cache the entry point for the code package
67
+ */
68
+ readonly resolvedPackageCacheId: string | undefined;
78
69
  }
79
70
 
80
71
  /**
@@ -85,160 +76,172 @@ export interface IResolvedFluidCodeDetails extends IFluidCodeDetails {
85
76
  * version of package that supports the provided code details.
86
77
  */
87
78
  export interface IFluidCodeResolver {
88
- /**
89
- * Resolves a Fluid code details into a form that can be loaded.
90
- * @param details - The Fluid code details to resolve.
91
- * @returns - A IResolvedFluidCodeDetails where the resolvedPackage's Fluid file entries are absolute urls, and
92
- * an optional resolvedPackageCacheId if the loaded package should be cached.
93
- */
94
- resolveCodeDetails(details: IFluidCodeDetails): Promise<IResolvedFluidCodeDetails>;
79
+ /**
80
+ * Resolves a Fluid code details into a form that can be loaded.
81
+ * @param details - The Fluid code details to resolve.
82
+ * @returns - A IResolvedFluidCodeDetails where the resolvedPackage's Fluid file entries are absolute urls, and
83
+ * an optional resolvedPackageCacheId if the loaded package should be cached.
84
+ */
85
+ resolveCodeDetails(details: IFluidCodeDetails): Promise<IResolvedFluidCodeDetails>;
95
86
  }
96
87
 
97
88
  /**
98
89
  * Code AllowListing Interface
99
90
  */
100
91
  export interface ICodeAllowList {
101
- testSource(source: IResolvedFluidCodeDetails): Promise<boolean>;
92
+ testSource(source: IResolvedFluidCodeDetails): Promise<boolean>;
102
93
  }
103
94
 
104
95
  /**
105
96
  * Events emitted by the {@link IContainer} "upwards" to the Loader and Host.
106
97
  */
107
- /* eslint-disable @typescript-eslint/unified-signatures */
108
98
  export interface IContainerEvents extends IEvent {
109
- /**
110
- * Emitted when the readonly state of the container changes.
111
- *
112
- * @remarks Listener parameters:
113
- *
114
- * - `readonly`: Whether or not the container is now in a readonly state.
115
- *
116
- * @see {@link IContainer.readOnlyInfo}
117
- */
118
- (event: "readonly", listener: (readonly: boolean) => void): void;
119
-
120
- /**
121
- * Emitted when the {@link IContainer} completes connecting to the Fluid service.
122
- *
123
- * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
124
- *
125
- * @see
126
- *
127
- * - {@link IContainer.connectionState}
128
- *
129
- * - {@link IContainer.connect}
130
- */
131
- (event: "connected", listener: (clientId: string) => void);
132
-
133
- /**
134
- * Fires when new container code details have been proposed, prior to acceptance.
135
- *
136
- * @remarks Listener parameters:
137
- *
138
- * - `codeDetails`: The code details being proposed.
139
- *
140
- * - `proposal`: NOT RECOMMENDED FOR USE.
141
- *
142
- * @see {@link IContainer.proposeCodeDetails}
143
- */
144
- (event: "codeDetailsProposed", listener: (codeDetails: IFluidCodeDetails, proposal: ISequencedProposal) => void);
145
-
146
- /**
147
- * @deprecated No replacement API recommended.
148
- */
149
- (event: "contextChanged", listener: (codeDetails: IFluidCodeDetails) => void);
150
-
151
- /**
152
- * Emitted when the {@link IContainer} becomes disconnected from the Fluid service.
153
- *
154
- * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
155
- *
156
- * @see
157
- *
158
- * - {@link IContainer.connectionState}
159
- *
160
- * - {@link IContainer.disconnect}
161
- */
162
- (event: "disconnected", listener: () => void);
163
-
164
- /**
165
- * Emitted when a {@link AttachState.Detached | detached} container is
166
- * {@link AttachState.Attached | attached} to the Fluid service.
167
- *
168
- * @see
169
- *
170
- * - {@link IContainer.attachState}
171
- *
172
- * - {@link IContainer.attach}
173
- */
174
- (event: "attached", listener: () => void);
175
-
176
- /**
177
- * Emitted when the {@link IContainer} is closed, which permanently disables it.
178
- *
179
- * @remarks Listener parameters:
180
- *
181
- * - `error`: If the container was closed due to error, this will contain details about the error that caused it.
182
- *
183
- * @see {@link IContainer.close}
184
- */
185
- (event: "closed", listener: (error?: ICriticalContainerError) => void);
186
-
187
- /**
188
- * Emitted when the container encounters a state which may lead to errors, which may be actionable by the consumer.
189
- *
190
- * @remarks
191
- *
192
- * Note: this event is not intended for general use.
193
- * The longer-term intention is to surface warnings more directly on the APIs that produce them.
194
- * For now, use of this should be avoided when possible.
195
- *
196
- * Listener parameters:
197
- *
198
- * - `error`: The warning describing the encountered state.
199
- */
200
- (event: "warning", listener: (error: ContainerWarning) => void);
201
-
202
- /**
203
- * Emitted immediately after processing an incoming operation (op).
204
- *
205
- * @remarks
206
- *
207
- * Note: this event is not intended for general use.
208
- * Prefer to listen to events on the appropriate ultimate recipients of the ops, rather than listening to the
209
- * ops directly on the {@link IContainer}.
210
- *
211
- * Listener parameters:
212
- *
213
- * - `message`: The op that was processed.
214
- */
215
- (event: "op", listener: (message: ISequencedDocumentMessage) => void);
216
-
217
- /**
218
- * Emitted upon the first local change while the Container is in the "saved" state.
219
- * That is, when {@link IContainer.isDirty} transitions from `true` to `false`.
220
- *
221
- * @remarks Listener parameters:
222
- *
223
- * - `dirty`: DEPRECATED. This parameter will be removed in a future release.
224
- *
225
- * @see {@link IContainer.isDirty}
226
- */
227
- (event: "dirty", listener: (dirty: boolean) => void);
228
-
229
- /**
230
- * Emitted when all local changes/edits have been acknowledged by the service.
231
- * I.e., when {@link IContainer.isDirty} transitions from `false` to `true`.
232
- *
233
- * @remarks Listener parameters:
234
- *
235
- * - `dirty`: DEPRECATED. This parameter will be removed in a future release.
236
- *
237
- * @see {@link IContainer.isDirty}
238
- */
239
- (event: "saved", listener: (dirty: boolean) => void);
99
+ /**
100
+ * Emitted when the readonly state of the container changes.
101
+ *
102
+ * @remarks Listener parameters:
103
+ *
104
+ * - `readonly`: Whether or not the container is now in a readonly state.
105
+ *
106
+ * @see {@link IContainer.readOnlyInfo}
107
+ */
108
+ (event: "readonly", listener: (readonly: boolean) => void): void;
109
+
110
+ /**
111
+ * Emitted when the {@link IContainer} completes connecting to the Fluid service.
112
+ *
113
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
114
+ *
115
+ * @see
116
+ *
117
+ * - {@link IContainer.connectionState}
118
+ *
119
+ * - {@link IContainer.connect}
120
+ */
121
+ (event: "connected", listener: (clientId: string) => void);
122
+
123
+ /**
124
+ * Fires when new container code details have been proposed, prior to acceptance.
125
+ *
126
+ * @remarks Listener parameters:
127
+ *
128
+ * - `codeDetails`: The code details being proposed.
129
+ *
130
+ * - `proposal`: NOT RECOMMENDED FOR USE.
131
+ *
132
+ * @see {@link IContainer.proposeCodeDetails}
133
+ */
134
+ (
135
+ event: "codeDetailsProposed",
136
+ listener: (codeDetails: IFluidCodeDetails, proposal: ISequencedProposal) => void,
137
+ );
138
+
139
+ /**
140
+ * @deprecated No replacement API recommended.
141
+ */
142
+ (event: "contextChanged", listener: (codeDetails: IFluidCodeDetails) => void);
143
+
144
+ /**
145
+ * Emitted when the {@link IContainer} becomes disconnected from the Fluid service.
146
+ *
147
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
148
+ *
149
+ * @see
150
+ *
151
+ * - {@link IContainer.connectionState}
152
+ *
153
+ * - {@link IContainer.disconnect}
154
+ */
155
+ (event: "disconnected", listener: () => void);
156
+
157
+ /**
158
+ * Emitted when a {@link AttachState.Detached | detached} container is
159
+ * {@link AttachState.Attached | attached} to the Fluid service.
160
+ *
161
+ * @see
162
+ *
163
+ * - {@link IContainer.attachState}
164
+ *
165
+ * - {@link IContainer.attach}
166
+ */
167
+ (event: "attached", listener: () => void);
168
+
169
+ /**
170
+ * Emitted when the {@link IContainer} is closed, which permanently disables it.
171
+ *
172
+ * @remarks Listener parameters:
173
+ *
174
+ * - `error`: If the container was closed due to error, this will contain details about the error that caused it.
175
+ *
176
+ * @see {@link IContainer.close}
177
+ */
178
+ (event: "closed", listener: (error?: ICriticalContainerError) => void);
179
+
180
+ /**
181
+ * Emitted when the {@link IContainer} is disposed, which permanently disables it.
182
+ *
183
+ * @remarks Listener parameters:
184
+ *
185
+ * - `error`: If the container was disposed due to error, this will contain details about the error that caused it.
186
+ *
187
+ * @see {@link IContainer.dispose}
188
+ */
189
+ (event: "disposed", listener: (error?: ICriticalContainerError) => void);
190
+
191
+ /**
192
+ * Emitted when the container encounters a state which may lead to errors, which may be actionable by the consumer.
193
+ *
194
+ * @remarks
195
+ *
196
+ * Note: this event is not intended for general use.
197
+ * The longer-term intention is to surface warnings more directly on the APIs that produce them.
198
+ * For now, use of this should be avoided when possible.
199
+ *
200
+ * Listener parameters:
201
+ *
202
+ * - `error`: The warning describing the encountered state.
203
+ */
204
+ (event: "warning", listener: (error: ContainerWarning) => void);
205
+
206
+ /**
207
+ * Emitted immediately after processing an incoming operation (op).
208
+ *
209
+ * @remarks
210
+ *
211
+ * Note: this event is not intended for general use.
212
+ * Prefer to listen to events on the appropriate ultimate recipients of the ops, rather than listening to the
213
+ * ops directly on the {@link IContainer}.
214
+ *
215
+ * Listener parameters:
216
+ *
217
+ * - `message`: The op that was processed.
218
+ */
219
+ (event: "op", listener: (message: ISequencedDocumentMessage) => void);
220
+
221
+ /**
222
+ * Emitted upon the first local change while the Container is in the "saved" state.
223
+ * That is, when {@link IContainer.isDirty} transitions from `true` to `false`.
224
+ *
225
+ * @remarks Listener parameters:
226
+ *
227
+ * - `dirty`: DEPRECATED. This parameter will be removed in a future release.
228
+ *
229
+ * @see {@link IContainer.isDirty}
230
+ */
231
+ (event: "dirty", listener: (dirty: boolean) => void);
232
+
233
+ /**
234
+ * Emitted when all local changes/edits have been acknowledged by the service.
235
+ * I.e., when {@link IContainer.isDirty} transitions from `false` to `true`.
236
+ *
237
+ * @remarks Listener parameters:
238
+ *
239
+ * - `dirty`: DEPRECATED. This parameter will be removed in a future release.
240
+ *
241
+ * @see {@link IContainer.isDirty}
242
+ */
243
+ (event: "saved", listener: (dirty: boolean) => void);
240
244
  }
241
- /* eslint-enable @typescript-eslint/unified-signatures */
242
245
 
243
246
  /**
244
247
  * Namespace for the different connection states a container can be in.
@@ -246,350 +249,356 @@ export interface IContainerEvents extends IEvent {
246
249
  */
247
250
  // eslint-disable-next-line @typescript-eslint/no-namespace
248
251
  export namespace ConnectionState {
249
- /**
250
- * The container is not connected to the delta server.
251
- * Note - When in this state the container may be about to reconnect,
252
- * or may remain disconnected until explicitly told to connect.
253
- */
254
- export type Disconnected = 0;
255
-
256
- /**
257
- * The container is disconnected but actively trying to establish a new connection.
258
- * PLEASE NOTE that this numerical value falls out of the order you may expect for this state.
259
- */
260
- export type EstablishingConnection = 3;
261
-
262
- /**
263
- * The container has an inbound connection only, and is catching up to the latest known state from the service.
264
- */
265
- export type CatchingUp = 1;
266
-
267
- /**
268
- * The container is fully connected and syncing.
269
- */
270
- export type Connected = 2;
252
+ /**
253
+ * The container is not connected to the delta server.
254
+ * Note - When in this state the container may be about to reconnect,
255
+ * or may remain disconnected until explicitly told to connect.
256
+ */
257
+ export type Disconnected = 0;
258
+
259
+ /**
260
+ * The container is disconnected but actively trying to establish a new connection.
261
+ * PLEASE NOTE that this numerical value falls out of the order you may expect for this state.
262
+ */
263
+ export type EstablishingConnection = 3;
264
+
265
+ /**
266
+ * The container has an inbound connection only, and is catching up to the latest known state from the service.
267
+ */
268
+ export type CatchingUp = 1;
269
+
270
+ /**
271
+ * The container is fully connected and syncing.
272
+ */
273
+ export type Connected = 2;
271
274
  }
272
275
 
273
276
  /**
274
277
  * Type defining the different states of connectivity a Container can be in.
275
278
  */
276
279
  export type ConnectionState =
277
- | ConnectionState.Disconnected
278
- | ConnectionState.EstablishingConnection
279
- | ConnectionState.CatchingUp
280
- | ConnectionState.Connected;
280
+ | ConnectionState.Disconnected
281
+ | ConnectionState.EstablishingConnection
282
+ | ConnectionState.CatchingUp
283
+ | ConnectionState.Connected;
281
284
 
282
285
  /**
283
286
  * The Host's view of a Container and its connection to storage
284
287
  */
285
288
  export interface IContainer extends IEventProvider<IContainerEvents>, IFluidRouter {
286
-
287
- /**
288
- * The Delta Manager supporting the op stream for this Container
289
- */
290
- deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
291
-
292
- /**
293
- * The collection of write clients which were connected as of the current sequence number.
294
- * Also contains a map of key-value pairs that must be agreed upon by all clients before being accepted.
295
- */
296
- getQuorum(): IQuorumClients;
297
-
298
- /**
299
- * Represents the resolved url to the Container.
300
- * Will be undefined only when the container is in the {@link AttachState.Detached | detatched} state.
301
- */
302
- resolvedUrl: IResolvedUrl | undefined;
303
-
304
- /**
305
- * Indicates the attachment state of the container to a host service.
306
- */
307
- readonly attachState: AttachState;
308
-
309
- /**
310
- * Get the code details that are currently specified for the container.
311
- * @returns The current code details if any are specified, undefined if none are specified.
312
- */
313
- getSpecifiedCodeDetails(): IFluidCodeDetails | undefined;
314
-
315
- /**
316
- * Get the code details that were used to load the container.
317
- * @returns The code details that were used to load the container if it is loaded, undefined if it is not yet
318
- * loaded.
319
- */
320
- getLoadedCodeDetails(): IFluidCodeDetails | undefined;
321
-
322
- /**
323
- * Returns true if the container has been closed, otherwise false.
324
- */
325
- readonly closed: boolean;
326
-
327
- /**
328
- * Whether or not there are any local changes that have not been saved.
329
- */
330
- readonly isDirty: boolean;
331
-
332
- /**
333
- * Closes the container.
334
- *
335
- * @param error - If the container is being closed due to error, this provides details about the error that
336
- * resulted in closing it.
337
- */
338
- close(error?: ICriticalContainerError): void;
339
-
340
- /**
341
- * Closes the container and returns serialized local state intended to be
342
- * given to a newly loaded container.
343
- */
344
- closeAndGetPendingLocalState(): string;
345
-
346
- /**
347
- * Propose new code details that define the code to be loaded for this container's runtime.
348
- *
349
- * The returned promise will be true when the proposal is accepted, and false if the proposal is rejected.
350
- */
351
- proposeCodeDetails(codeDetails: IFluidCodeDetails): Promise<boolean>;
352
-
353
- /**
354
- * Attaches the Container to the Container specified by the given Request.
355
- *
356
- * @privateRemarks
357
- *
358
- * TODO - in the case of failure options should give a retry policy.
359
- * Or some continuation function that allows attachment to a secondary document.
360
- */
361
- attach(request: IRequest): Promise<void>;
362
-
363
- /**
364
- * Extract a snapshot of the container as long as it is in detached state. Calling this on an attached container
365
- * is an error.
366
- */
367
- serialize(): string;
368
-
369
- /**
370
- * Get an absolute URL for a provided container-relative request URL.
371
- * If the container is not attached, this will return undefined.
372
- *
373
- * @param relativeUrl - A container-relative request URL.
374
- */
375
- getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
376
-
377
- /**
378
- * Issue a request against the container for a resource.
379
- * @param request - The request to be issued against the container
380
- */
381
- request(request: IRequest): Promise<IResponse>;
382
-
383
- /**
384
- * Provides the current state of the container's connection to the ordering service.
385
- *
386
- * @remarks Consumers can listen for state changes via the "connected" and "disconnected" events.
387
- */
388
- readonly connectionState: ConnectionState;
389
-
390
- /**
391
- * Attempts to connect the container to the delta stream and process ops.
392
- *
393
- * @remarks
394
- *
395
- * {@link IContainer.connectionState} will be set to {@link (ConnectionState:namespace).Connected}, and the
396
- * "connected" event will be fired if/when connection succeeds.
397
- */
398
- connect(): void;
399
-
400
- /**
401
- * Disconnects the container from the delta stream and stops processing ops.
402
- *
403
- * @remarks
404
- *
405
- * {@link IContainer.connectionState} will be set to {@link (ConnectionState:namespace).Disconnected}, and the
406
- * "disconnected" event will be fired when disconnection completes.
407
- */
408
- disconnect(): void;
409
-
410
- /**
411
- * The audience information for all clients currently associated with the document in the current session.
412
- */
413
- readonly audience: IAudience;
414
-
415
- /**
416
- * The server provided ID of the client.
417
- *
418
- * Set once {@link IContainer.connectionState} is {@link (ConnectionState:namespace).Connected},
419
- * otherwise will be `undefined`.
420
- */
421
- readonly clientId?: string | undefined;
422
-
423
- /**
424
- * Tells if container is in read-only mode.
425
- *
426
- * @remarks
427
- *
428
- * Data stores should listen for "readonly" notifications and disallow user making changes to data stores.
429
- * Readonly state can be because of no storage write permission,
430
- * or due to host forcing readonly mode for container.
431
- *
432
- * We do not differentiate here between no write access to storage vs. host disallowing changes to container -
433
- * in all cases container runtime and data stores should respect readonly state and not allow local changes.
434
- *
435
- * It is undefined if we have not yet established websocket connection
436
- * and do not know if user has write access to a file.
437
- */
438
- readonly readOnlyInfo: ReadOnlyInfo;
439
-
440
- /**
441
- * Allows the host to have the container force to be in read-only mode
442
- * @param readonly - Boolean that toggles if read-only policies will be enforced
443
- * @alpha
444
- */
445
- forceReadonly?(readonly: boolean);
289
+ /**
290
+ * The Delta Manager supporting the op stream for this Container
291
+ */
292
+ deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
293
+
294
+ /**
295
+ * The collection of write clients which were connected as of the current sequence number.
296
+ * Also contains a map of key-value pairs that must be agreed upon by all clients before being accepted.
297
+ */
298
+ getQuorum(): IQuorumClients;
299
+
300
+ /**
301
+ * Represents the resolved url to the Container.
302
+ * Will be undefined only when the container is in the {@link AttachState.Detached | detatched} state.
303
+ */
304
+ resolvedUrl: IResolvedUrl | undefined;
305
+
306
+ /**
307
+ * Indicates the attachment state of the container to a host service.
308
+ */
309
+ readonly attachState: AttachState;
310
+
311
+ /**
312
+ * Get the code details that are currently specified for the container.
313
+ * @returns The current code details if any are specified, undefined if none are specified.
314
+ */
315
+ getSpecifiedCodeDetails(): IFluidCodeDetails | undefined;
316
+
317
+ /**
318
+ * Get the code details that were used to load the container.
319
+ * @returns The code details that were used to load the container if it is loaded, undefined if it is not yet
320
+ * loaded.
321
+ */
322
+ getLoadedCodeDetails(): IFluidCodeDetails | undefined;
323
+
324
+ /**
325
+ * Returns true if the container has been closed, otherwise false.
326
+ */
327
+ readonly closed: boolean;
328
+
329
+ /**
330
+ * Whether or not there are any local changes that have not been saved.
331
+ */
332
+ readonly isDirty: boolean;
333
+
334
+ /**
335
+ * Disposes the container. If not already closed, this acts as a closure and then disposes runtime resources.
336
+ * The container is not expected to be used anymore once it is disposed.
337
+ *
338
+ * @param error - If the container is being disposed due to error, this provides details about the error that
339
+ * resulted in disposing it.
340
+ */
341
+ dispose?(error?: ICriticalContainerError): void;
342
+
343
+ /**
344
+ * Closes the container.
345
+ *
346
+ * @param error - If the container is being closed due to error, this provides details about the error that
347
+ * resulted in closing it.
348
+ */
349
+ close(error?: ICriticalContainerError): void;
350
+
351
+ /**
352
+ * Closes the container and returns serialized local state intended to be
353
+ * given to a newly loaded container.
354
+ */
355
+ closeAndGetPendingLocalState(): string;
356
+
357
+ /**
358
+ * Propose new code details that define the code to be loaded for this container's runtime.
359
+ *
360
+ * The returned promise will be true when the proposal is accepted, and false if the proposal is rejected.
361
+ */
362
+ proposeCodeDetails(codeDetails: IFluidCodeDetails): Promise<boolean>;
363
+
364
+ /**
365
+ * Attaches the Container to the Container specified by the given Request.
366
+ *
367
+ * @privateRemarks
368
+ *
369
+ * TODO - in the case of failure options should give a retry policy.
370
+ * Or some continuation function that allows attachment to a secondary document.
371
+ */
372
+ attach(request: IRequest): Promise<void>;
373
+
374
+ /**
375
+ * Extract a snapshot of the container as long as it is in detached state. Calling this on an attached container
376
+ * is an error.
377
+ */
378
+ serialize(): string;
379
+
380
+ /**
381
+ * Get an absolute URL for a provided container-relative request URL.
382
+ * If the container is not attached, this will return undefined.
383
+ *
384
+ * @param relativeUrl - A container-relative request URL.
385
+ */
386
+ getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
387
+
388
+ /**
389
+ * Issue a request against the container for a resource.
390
+ * @param request - The request to be issued against the container
391
+ */
392
+ request(request: IRequest): Promise<IResponse>;
393
+
394
+ /**
395
+ * Provides the current state of the container's connection to the ordering service.
396
+ *
397
+ * @remarks Consumers can listen for state changes via the "connected" and "disconnected" events.
398
+ */
399
+ readonly connectionState: ConnectionState;
400
+
401
+ /**
402
+ * Attempts to connect the container to the delta stream and process ops.
403
+ *
404
+ * @remarks
405
+ *
406
+ * {@link IContainer.connectionState} will be set to {@link (ConnectionState:namespace).Connected}, and the
407
+ * "connected" event will be fired if/when connection succeeds.
408
+ */
409
+ connect(): void;
410
+
411
+ /**
412
+ * Disconnects the container from the delta stream and stops processing ops.
413
+ *
414
+ * @remarks
415
+ *
416
+ * {@link IContainer.connectionState} will be set to {@link (ConnectionState:namespace).Disconnected}, and the
417
+ * "disconnected" event will be fired when disconnection completes.
418
+ */
419
+ disconnect(): void;
420
+
421
+ /**
422
+ * The audience information for all clients currently associated with the document in the current session.
423
+ */
424
+ readonly audience: IAudience;
425
+
426
+ /**
427
+ * The server provided ID of the client.
428
+ *
429
+ * Set once {@link IContainer.connectionState} is {@link (ConnectionState:namespace).Connected},
430
+ * otherwise will be `undefined`.
431
+ */
432
+ readonly clientId?: string | undefined;
433
+
434
+ /**
435
+ * Tells if container is in read-only mode.
436
+ *
437
+ * @remarks
438
+ *
439
+ * Data stores should listen for "readonly" notifications and disallow user making changes to data stores.
440
+ * Readonly state can be because of no storage write permission,
441
+ * or due to host forcing readonly mode for container.
442
+ *
443
+ * We do not differentiate here between no write access to storage vs. host disallowing changes to container -
444
+ * in all cases container runtime and data stores should respect readonly state and not allow local changes.
445
+ *
446
+ * It is undefined if we have not yet established websocket connection
447
+ * and do not know if user has write access to a file.
448
+ */
449
+ readonly readOnlyInfo: ReadOnlyInfo;
450
+
451
+ /**
452
+ * Allows the host to have the container force to be in read-only mode
453
+ * @param readonly - Boolean that toggles if read-only policies will be enforced
454
+ * @alpha
455
+ */
456
+ forceReadonly?(readonly: boolean);
446
457
  }
447
458
 
448
459
  /**
449
460
  * The Runtime's view of the Loader, used for loading Containers
450
461
  */
451
462
  export interface ILoader extends IFluidRouter, Partial<IProvideLoader> {
452
- /**
453
- * Resolves the resource specified by the URL + headers contained in the request object
454
- * to the underlying container that will resolve the request.
455
- *
456
- * @remarks
457
- *
458
- * An analogy for this is resolve is a DNS resolve of a Fluid container. Request then executes
459
- * a request against the server found from the resolve step.
460
- */
461
- resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer>;
463
+ /**
464
+ * Resolves the resource specified by the URL + headers contained in the request object
465
+ * to the underlying container that will resolve the request.
466
+ *
467
+ * @remarks
468
+ *
469
+ * An analogy for this is resolve is a DNS resolve of a Fluid container. Request then executes
470
+ * a request against the server found from the resolve step.
471
+ */
472
+ resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer>;
462
473
  }
463
474
 
464
475
  /**
465
476
  * The Host's view of the Loader, used for loading Containers
466
477
  */
467
478
  export interface IHostLoader extends ILoader {
468
- /**
469
- * Creates a new container using the specified chaincode but in an unattached state. While unattached all
470
- * updates will only be local until the user explicitly attaches the container to a service provider.
471
- */
472
- createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer>;
473
-
474
- /**
475
- * Creates a new container using the specified snapshot but in an unattached state. While unattached all
476
- * updates will only be local until the user explicitly attaches the container to a service provider.
477
- */
478
- rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer>;
479
+ /**
480
+ * Creates a new container using the specified chaincode but in an unattached state. While unattached all
481
+ * updates will only be local until the user explicitly attaches the container to a service provider.
482
+ */
483
+ createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer>;
484
+
485
+ /**
486
+ * Creates a new container using the specified snapshot but in an unattached state. While unattached all
487
+ * updates will only be local until the user explicitly attaches the container to a service provider.
488
+ */
489
+ rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer>;
479
490
  }
480
491
 
481
492
  export type ILoaderOptions = {
482
- [key in string | number]: any;
493
+ [key in string | number]: any;
483
494
  } & {
484
- /**
485
- * Set caching behavior for the loader. If true, we will load a container from cache if one
486
- * with the same id/version exists or create a new container and cache it if it does not. If
487
- * false, always load a new container and don't cache it. If the container has already been
488
- * closed, it will not be cached. A cache option in the LoaderHeader for an individual
489
- * request will override the Loader's value.
490
- * Defaults to true.
491
- */
492
- cache?: boolean;
493
-
494
- /**
495
- * Provide the current Loader through the scope object when creating Containers. It is added
496
- * as the `ILoader` property, and will overwrite an existing property of the same name on the
497
- * scope. Useful for when the host wants to provide the current Loader's functionality to
498
- * individual Data Stores, which is typically expected when creating with a Loader.
499
- * Defaults to true.
500
- */
501
- provideScopeLoader?: boolean;
502
-
503
- /**
504
- * Max time (in ms) container will wait for a leave message of a disconnected client.
505
- */
506
- maxClientLeaveWaitTime?: number;
495
+ /**
496
+ * Set caching behavior for the loader. If true, we will load a container from cache if one
497
+ * with the same id/version exists or create a new container and cache it if it does not. If
498
+ * false, always load a new container and don't cache it. If the container has already been
499
+ * closed, it will not be cached. A cache option in the LoaderHeader for an individual
500
+ * request will override the Loader's value.
501
+ * Defaults to true.
502
+ */
503
+ cache?: boolean;
504
+
505
+ /**
506
+ * Provide the current Loader through the scope object when creating Containers. It is added
507
+ * as the `ILoader` property, and will overwrite an existing property of the same name on the
508
+ * scope. Useful for when the host wants to provide the current Loader's functionality to
509
+ * individual Data Stores, which is typically expected when creating with a Loader.
510
+ * Defaults to true.
511
+ */
512
+ provideScopeLoader?: boolean;
513
+
514
+ /**
515
+ * Max time (in ms) container will wait for a leave message of a disconnected client.
516
+ */
517
+ maxClientLeaveWaitTime?: number;
507
518
  };
508
519
 
509
520
  /**
510
521
  * Accepted header keys for requests coming to the Loader
511
522
  */
512
523
  export enum LoaderHeader {
513
- /**
514
- * Override the Loader's default caching behavior for this container.
515
- */
516
- cache = "fluid-cache",
517
-
518
- clientDetails = "fluid-client-details",
519
-
520
- /**
521
- * Start the container in a paused, unconnected state. Defaults to false
522
- */
523
- loadMode = "loadMode",
524
- reconnect = "fluid-reconnect",
525
- sequenceNumber = "fluid-sequence-number",
526
-
527
- /**
528
- * One of the following:
529
- * null or "null": use ops, no snapshots
530
- * undefined: fetch latest snapshot
531
- * otherwise, version sha to load snapshot
532
- */
533
- version = "version",
524
+ /**
525
+ * Override the Loader's default caching behavior for this container.
526
+ */
527
+ cache = "fluid-cache",
528
+
529
+ clientDetails = "fluid-client-details",
530
+
531
+ /**
532
+ * Start the container in a paused, unconnected state. Defaults to false
533
+ */
534
+ loadMode = "loadMode",
535
+ reconnect = "fluid-reconnect",
536
+ sequenceNumber = "fluid-sequence-number",
537
+
538
+ /**
539
+ * One of the following:
540
+ * null or "null": use ops, no snapshots
541
+ * undefined: fetch latest snapshot
542
+ * otherwise, version sha to load snapshot
543
+ */
544
+ version = "version",
534
545
  }
535
546
 
536
547
  export interface IContainerLoadMode {
537
- opsBeforeReturn?:
538
- /*
539
- * No trailing ops are applied before container is returned.
540
- * Default value.
541
- */
542
- | undefined
543
- /*
544
- * Only cached trailing ops are applied before returning container.
545
- * Caching is optional and could be implemented by the driver.
546
- * If driver does not implement any kind of local caching strategy, this is same as above.
547
- * Driver may cache a lot of ops, so care needs to be exercised (see below).
548
- */
549
- | "cached"
550
- /*
551
- * All trailing ops in storage are fetched and applied before container is returned
552
- * This mode might have significant impact on boot speed (depends on storage perf characteristics)
553
- * Also there might be a lot of trailing ops and applying them might take time, so hosts are
554
- * recommended to have some progress UX / cancellation built into loading flow when using this option.
555
- */
556
- | "all";
557
-
558
- deltaConnection?:
559
- /*
560
- * Connection to delta stream is made only when Container.connect() call is made. Op processing
561
- * is paused (when container is returned from Loader.resolve()) until Container.connect() call is made.
562
- */
563
- | "none"
564
- /*
565
- * Connection to delta stream is made only when Container.connect() call is made.
566
- * Op fetching from storage is performed and ops are applied as they come in.
567
- * This is useful option if connection to delta stream is expensive and thus it's beneficial to move it
568
- * out from critical boot sequence, but it's beneficial to allow catch up to happen as fast as possible.
569
- */
570
- | "delayed"
571
- /*
572
- * Connection to delta stream is made right away.
573
- * Ops processing is enabled and ops are flowing through the system.
574
- * Default value.
575
- */
576
- | undefined;
548
+ opsBeforeReturn?: /*
549
+ * No trailing ops are applied before container is returned.
550
+ * Default value.
551
+ */
552
+ | undefined
553
+ /*
554
+ * Only cached trailing ops are applied before returning container.
555
+ * Caching is optional and could be implemented by the driver.
556
+ * If driver does not implement any kind of local caching strategy, this is same as above.
557
+ * Driver may cache a lot of ops, so care needs to be exercised (see below).
558
+ */
559
+ | "cached"
560
+ /*
561
+ * All trailing ops in storage are fetched and applied before container is returned
562
+ * This mode might have significant impact on boot speed (depends on storage perf characteristics)
563
+ * Also there might be a lot of trailing ops and applying them might take time, so hosts are
564
+ * recommended to have some progress UX / cancellation built into loading flow when using this option.
565
+ */
566
+ | "all";
567
+
568
+ deltaConnection?: /*
569
+ * Connection to delta stream is made only when Container.connect() call is made. Op processing
570
+ * is paused (when container is returned from Loader.resolve()) until Container.connect() call is made.
571
+ */
572
+ | "none"
573
+ /*
574
+ * Connection to delta stream is made only when Container.connect() call is made.
575
+ * Op fetching from storage is performed and ops are applied as they come in.
576
+ * This is useful option if connection to delta stream is expensive and thus it's beneficial to move it
577
+ * out from critical boot sequence, but it's beneficial to allow catch up to happen as fast as possible.
578
+ */
579
+ | "delayed"
580
+ /*
581
+ * Connection to delta stream is made right away.
582
+ * Ops processing is enabled and ops are flowing through the system.
583
+ * Default value.
584
+ */
585
+ | undefined;
577
586
  }
578
587
 
579
588
  /**
580
589
  * Set of Request Headers that the Loader understands and may inspect or modify
581
590
  */
582
591
  export interface ILoaderHeader {
583
- [LoaderHeader.cache]: boolean;
584
- [LoaderHeader.clientDetails]: IClientDetails;
585
- [LoaderHeader.loadMode]: IContainerLoadMode;
586
- [LoaderHeader.sequenceNumber]: number;
587
- [LoaderHeader.reconnect]: boolean;
588
- [LoaderHeader.version]: string | undefined;
592
+ [LoaderHeader.cache]: boolean;
593
+ [LoaderHeader.clientDetails]: IClientDetails;
594
+ [LoaderHeader.loadMode]: IContainerLoadMode;
595
+ [LoaderHeader.sequenceNumber]: number;
596
+ [LoaderHeader.reconnect]: boolean;
597
+ [LoaderHeader.version]: string | undefined;
589
598
  }
590
599
 
591
600
  export interface IProvideLoader {
592
- readonly ILoader: ILoader;
601
+ readonly ILoader: ILoader;
593
602
  }
594
603
 
595
604
  /**
@@ -598,8 +607,8 @@ export interface IProvideLoader {
598
607
  * See {@link https://github.com/microsoft/FluidFramework/issues/9711} for context.
599
608
  */
600
609
  export interface IPendingLocalState {
601
- url: string;
602
- pendingRuntimeState: unknown;
610
+ url: string;
611
+ pendingRuntimeState: unknown;
603
612
  }
604
613
 
605
614
  /**
@@ -609,6 +618,6 @@ export interface IPendingLocalState {
609
618
  * @remarks This is used as the `ContainerContext`'s base snapshot when attaching.
610
619
  */
611
620
  export interface ISnapshotTreeWithBlobContents extends ISnapshotTree {
612
- blobsContents: { [path: string]: ArrayBufferLike; };
613
- trees: { [path: string]: ISnapshotTreeWithBlobContents; };
621
+ blobsContents: { [path: string]: ArrayBufferLike };
622
+ trees: { [path: string]: ISnapshotTreeWithBlobContents };
614
623
  }