@fluidframework/container-definitions 0.42.0-43895 → 0.43.0

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 (66) hide show
  1. package/api-report/container-definitions.api.md +124 -31
  2. package/dist/deltas.d.ts +12 -5
  3. package/dist/deltas.d.ts.map +1 -1
  4. package/dist/deltas.js +3 -0
  5. package/dist/deltas.js.map +1 -1
  6. package/dist/error.d.ts +17 -1
  7. package/dist/error.d.ts.map +1 -1
  8. package/dist/error.js.map +1 -1
  9. package/dist/fluidModule.d.ts +3 -2
  10. package/dist/fluidModule.d.ts.map +1 -1
  11. package/dist/fluidModule.js.map +1 -1
  12. package/dist/fluidPackage.d.ts +109 -0
  13. package/dist/fluidPackage.d.ts.map +1 -0
  14. package/dist/fluidPackage.js +24 -0
  15. package/dist/fluidPackage.js.map +1 -0
  16. package/dist/index.d.ts +1 -6
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +5 -4
  19. package/dist/index.js.map +1 -1
  20. package/dist/legacy/chaincode.d.ts +15 -2
  21. package/dist/legacy/chaincode.d.ts.map +1 -1
  22. package/dist/legacy/chaincode.js +3 -0
  23. package/dist/legacy/chaincode.js.map +1 -1
  24. package/dist/loader.d.ts +107 -6
  25. package/dist/loader.d.ts.map +1 -1
  26. package/dist/loader.js.map +1 -1
  27. package/dist/runtime.d.ts +10 -2
  28. package/dist/runtime.d.ts.map +1 -1
  29. package/dist/runtime.js.map +1 -1
  30. package/lib/deltas.d.ts +12 -5
  31. package/lib/deltas.d.ts.map +1 -1
  32. package/lib/deltas.js +3 -0
  33. package/lib/deltas.js.map +1 -1
  34. package/lib/error.d.ts +17 -1
  35. package/lib/error.d.ts.map +1 -1
  36. package/lib/error.js.map +1 -1
  37. package/lib/fluidModule.d.ts +3 -2
  38. package/lib/fluidModule.d.ts.map +1 -1
  39. package/lib/fluidModule.js.map +1 -1
  40. package/lib/fluidPackage.d.ts +109 -0
  41. package/lib/fluidPackage.d.ts.map +1 -0
  42. package/lib/fluidPackage.js +19 -0
  43. package/lib/fluidPackage.js.map +1 -0
  44. package/lib/index.d.ts +1 -6
  45. package/lib/index.d.ts.map +1 -1
  46. package/lib/index.js +1 -0
  47. package/lib/index.js.map +1 -1
  48. package/lib/legacy/chaincode.d.ts +15 -2
  49. package/lib/legacy/chaincode.d.ts.map +1 -1
  50. package/lib/legacy/chaincode.js +3 -0
  51. package/lib/legacy/chaincode.js.map +1 -1
  52. package/lib/loader.d.ts +107 -6
  53. package/lib/loader.d.ts.map +1 -1
  54. package/lib/loader.js.map +1 -1
  55. package/lib/runtime.d.ts +10 -2
  56. package/lib/runtime.d.ts.map +1 -1
  57. package/lib/runtime.js.map +1 -1
  58. package/package.json +86 -6
  59. package/src/deltas.ts +13 -6
  60. package/src/error.ts +19 -1
  61. package/src/fluidModule.ts +3 -2
  62. package/src/fluidPackage.ts +132 -0
  63. package/src/index.ts +1 -11
  64. package/src/legacy/chaincode.ts +16 -6
  65. package/src/loader.ts +123 -6
  66. package/src/runtime.ts +12 -2
package/src/loader.ts CHANGED
@@ -20,7 +20,8 @@ import {
20
20
  } from "@fluidframework/protocol-definitions";
21
21
  import { IResolvedUrl } from "@fluidframework/driver-definitions";
22
22
  import { IEvent, IEventProvider } from "@fluidframework/common-definitions";
23
- import { IDeltaManager } from "./deltas";
23
+ import { IAudience } from "./audience";
24
+ import { IDeltaManager, ReadOnlyInfo } from "./deltas";
24
25
  import { ICriticalContainerError, ContainerWarning } from "./error";
25
26
  import { IFluidModule } from "./fluidModule";
26
27
  import { AttachState } from "./runtime";
@@ -37,6 +38,35 @@ export interface ICodeLoader extends Partial<IProvideFluidCodeDetailsComparer> {
37
38
  load(source: IFluidCodeDetails): Promise<IFluidModule>;
38
39
  }
39
40
 
41
+ /**
42
+ * Encapsulates a module entry point with corresponding code details.
43
+ */
44
+ export interface IFluidModuleWithDetails {
45
+ /** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */
46
+ module: IFluidModule;
47
+ /**
48
+ * Code details associated with the module. Represents a document schema this module supports.
49
+ * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,
50
+ * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.
51
+ */
52
+ details: IFluidCodeDetails;
53
+ }
54
+
55
+ /**
56
+ * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as
57
+ * a package name and package version range.
58
+ */
59
+ export interface ICodeDetailsLoader
60
+ extends Partial<IProvideFluidCodeDetailsComparer> {
61
+ /**
62
+ * Load the code module (package) that is capable to interact with the document.
63
+ *
64
+ * @param source - Code proposal that articulates the current schema the document is written in.
65
+ * @returns - Code module entry point along with the code details associated with it.
66
+ */
67
+ load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;
68
+ }
69
+
40
70
  /**
41
71
  * The interface returned from a IFluidCodeResolver which represents IFluidCodeDetails
42
72
  * that have been resolved and are ready to load
@@ -93,6 +123,31 @@ export interface IContainerEvents extends IEvent {
93
123
  (event: "dirty" | "saved", listener: (dirty: boolean) => void);
94
124
  }
95
125
 
126
+ /**
127
+ * Namespace for the different connection states a container can be in
128
+ */
129
+ export namespace ConnectionState {
130
+ /**
131
+ * The document is no longer connected to the delta server
132
+ */
133
+ export type Disconnected = 0;
134
+
135
+ /**
136
+ * The document has an inbound connection but is still pending for outbound deltas
137
+ */
138
+ export type Connecting = 1;
139
+
140
+ /**
141
+ * The document is fully connected
142
+ */
143
+ export type Connected = 2;
144
+ }
145
+
146
+ /**
147
+ * Type defining the different states of connectivity a container can be in
148
+ */
149
+ export type ConnectionState = ConnectionState.Disconnected | ConnectionState.Connecting | ConnectionState.Connected;
150
+
96
151
  /**
97
152
  * The Host's view of the Container and its connection to storage
98
153
  */
@@ -124,8 +179,9 @@ export interface IContainer extends IEventProvider<IContainerEvents>, IFluidRout
124
179
  * @deprecated use getSpecifiedCodeDetails for the code details currently specified for this container, or
125
180
  * getLoadedCodeDetails for the code details that the container's context was loaded with.
126
181
  * To be removed after getSpecifiedCodeDetails and getLoadedCodeDetails become ubiquitous.
182
+ * This is now marked as optional and due to be removed in next release.
127
183
  */
128
- readonly codeDetails: IFluidCodeDetails | undefined;
184
+ readonly codeDetails?: IFluidCodeDetails | undefined;
129
185
 
130
186
  /**
131
187
  * Get the code details that are currently specified for the container.
@@ -197,12 +253,69 @@ export interface IContainer extends IEventProvider<IContainerEvents>, IFluidRout
197
253
  * @param request - The request to be issued against the container
198
254
  */
199
255
  request(request: IRequest): Promise<IResponse>;
256
+
257
+ /**
258
+ * Provides the current connected state of the container
259
+ */
260
+ readonly connectionState?: ConnectionState;
261
+
262
+ /**
263
+ * Boolean indicating whether the container is currently connected or not
264
+ */
265
+ readonly connected?: boolean;
266
+
267
+ /**
268
+ * Dictates whether or not the current container will automatically attempt to reconnect to the delta stream
269
+ * after receiving a disconnect event
270
+ * @param reconnect - Boolean indicating if reconnect should automatically occur
271
+ * @alpha
272
+ */
273
+ setAutoReconnect?(reconnect: boolean): void;
274
+
275
+ /**
276
+ * Have the container attempt to resume processing ops
277
+ * @alpha
278
+ */
279
+ resume?(): void;
280
+
281
+ /**
282
+ * The audience information for all clients currently associated with the document in the current session
283
+ */
284
+ readonly audience?: IAudience;
285
+
286
+ /**
287
+ * The server provided ID of the client.
288
+ * Set once this.connected is true, otherwise undefined
289
+ * @alpha
290
+ */
291
+ readonly clientId?: string | undefined;
292
+
293
+ /**
294
+ * Tells if container is in read-only mode.
295
+ * Data stores should listen for "readonly" notifications and disallow user making changes to data stores.
296
+ * Readonly state can be because of no storage write permission,
297
+ * or due to host forcing readonly mode for container.
298
+ *
299
+ * We do not differentiate here between no write access to storage vs. host disallowing changes to container -
300
+ * in all cases container runtime and data stores should respect readonly state and not allow local changes.
301
+ *
302
+ * It is undefined if we have not yet established websocket connection
303
+ * and do not know if user has write access to a file.
304
+ */
305
+ readonly readOnlyInfo?: ReadOnlyInfo;
306
+
307
+ /**
308
+ * Allows the host to have the container force to be in read-only mode
309
+ * @param readonly - Boolean that toggles if read-only policies will be enforced
310
+ * @alpha
311
+ */
312
+ forceReadonly?(readonly: boolean);
200
313
  }
201
314
 
202
315
  /**
203
316
  * The Runtime's view of the Loader, used for loading Containers
204
317
  */
205
- export interface ILoader extends IFluidRouter {
318
+ export interface ILoader extends IFluidRouter, Partial<IProvideLoader> {
206
319
  /**
207
320
  * Resolves the resource specified by the URL + headers contained in the request object
208
321
  * to the underlying container that will resolve the request.
@@ -353,7 +466,7 @@ export interface ILoaderHeader {
353
466
  [LoaderHeader.version]: string | undefined;
354
467
  }
355
468
 
356
- interface IProvideLoader {
469
+ export interface IProvideLoader {
357
470
  readonly ILoader: ILoader;
358
471
  }
359
472
 
@@ -361,8 +474,12 @@ declare module "@fluidframework/core-interfaces" {
361
474
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
362
475
  export interface IRequestHeader extends Partial<ILoaderHeader> { }
363
476
 
364
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
365
- export interface IFluidObject extends Readonly<Partial<IProvideLoader>> { }
477
+ export interface IFluidObject {
478
+ /**
479
+ * @deprecated - use `FluidObject<ILoader>` instead
480
+ */
481
+ readonly ILoader?: ILoader;
482
+ }
366
483
  }
367
484
 
368
485
  export interface IPendingLocalState {
package/src/runtime.ts CHANGED
@@ -5,8 +5,10 @@
5
5
 
6
6
  import { ITelemetryBaseLogger, IDisposable } from "@fluidframework/common-definitions";
7
7
  import {
8
- IFluidObject,
8
+ FluidObject,
9
+ IFluidCodeDetails,
9
10
  IFluidConfiguration,
11
+ IFluidObject,
10
12
  IRequest,
11
13
  IResponse,
12
14
  } from "@fluidframework/core-interfaces";
@@ -133,6 +135,14 @@ export interface IContainerContext extends IDisposable {
133
135
  readonly closeFn: (error?: ICriticalContainerError) => void;
134
136
  readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
135
137
  readonly quorum: IQuorum;
138
+ /**
139
+ * @deprecated This method is provided as a migration tool for customers currently reading the code details
140
+ * from within the Container by directly accessing the Quorum proposals. The code details should not be accessed
141
+ * from within the Container as this requires coupling between the container contents and the code loader.
142
+ * Direct access to Quorum proposals will be removed in an upcoming release, and in a further future release this
143
+ * migration tool will be removed.
144
+ */
145
+ getSpecifiedCodeDetails?(): IFluidCodeDetails | undefined;
136
146
  readonly audience: IAudience | undefined;
137
147
  readonly loader: ILoader;
138
148
  /** @deprecated - Use `taggedLogger` if present. Otherwise, be sure to handle tagged data
@@ -150,7 +160,7 @@ export interface IContainerContext extends IDisposable {
150
160
  /**
151
161
  * Ambient services provided with the context
152
162
  */
153
- readonly scope: IFluidObject;
163
+ readonly scope: IFluidObject & FluidObject;
154
164
 
155
165
  raiseContainerWarning(warning: ContainerWarning): void;
156
166