@fluidframework/runtime-definitions 2.93.0 → 2.100.1

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.
@@ -132,6 +132,17 @@ export interface IContainerRuntimeBaseEvents extends IEvent {
132
132
  (event: "op", listener: (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => void);
133
133
  (event: "signal", listener: (message: IInboundSignalMessage, local: boolean) => void);
134
134
  (event: "dispose", listener: () => void);
135
+ /**
136
+ * Fires when the container runtime enters or exits staging mode.
137
+ * @param stagingModeInfo - An object describing the staging mode state.
138
+ * If `inStagingMode` is true, the runtime has entered staging mode.
139
+ * If false, it has exited staging mode, and `commit` indicates whether changes were committed or discarded.
140
+ *
141
+ * @remarks
142
+ * This event is not emitted when the container is disposed while in staging mode.
143
+ * If the container is disposed, staged changes are silently dropped.
144
+ */
145
+ (event: "stagingModeChanged", listener: (stagingModeInfo: StagingModeChangedEvent) => void);
135
146
  }
136
147
 
137
148
  /**
@@ -180,6 +191,35 @@ export interface IDataStore {
180
191
  readonly entryPoint: IFluidHandleInternal<FluidObject>;
181
192
  }
182
193
 
194
+ /**
195
+ * Controls for managing staged changes in staging mode.
196
+ *
197
+ * Provides methods to either commit or discard changes made while in staging mode.
198
+ *
199
+ * @see {@link IContainerRuntimeBase.enterStagingMode}
200
+ *
201
+ * @legacy @beta
202
+ * @sealed
203
+ */
204
+ export interface StageControls {
205
+ /**
206
+ * Exit staging mode and commit to any changes made while in staging mode.
207
+ * This will cause them to be sent to the ordering service, and subsequent changes
208
+ * made by this container will additionally flow freely to the ordering service.
209
+ *
210
+ * @remarks
211
+ * Squash-rebase semantics during commit are not yet fully specified.
212
+ */
213
+ readonly commitChanges: () => void;
214
+ /**
215
+ * Exit staging mode and discard any changes made while in staging mode.
216
+ *
217
+ * @remarks
218
+ * DDS rollback support may be incomplete — this may throw for some DDS implementations.
219
+ */
220
+ readonly discardChanges: () => void;
221
+ }
222
+
183
223
  /**
184
224
  * A reduced set of functionality of {@link @fluidframework/container-runtime-definitions#IContainerRuntime} that a data store context/data store runtime will need.
185
225
  * @privateRemarks
@@ -290,6 +330,27 @@ export interface IContainerRuntimeBase extends IEventProvider<IContainerRuntimeB
290
330
  loadingGroupIds: string[],
291
331
  pathParts: string[],
292
332
  ): Promise<{ snapshotTree: ISnapshotTree; sequenceNumber: number }>;
333
+
334
+ /**
335
+ * Enter Staging Mode, such that ops submitted to the ContainerRuntime will not be sent to the ordering service.
336
+ * To exit Staging Mode, call either discardChanges or commitChanges on the Stage Controls returned from this method.
337
+ *
338
+ * @remarks
339
+ * Known limitations:
340
+ * - DDS rollback support may be incomplete — {@link StageControls.discardChanges} may throw for some DDS implementations.
341
+ * - Squash-rebase semantics during {@link StageControls.commitChanges} are not yet fully specified.
342
+ *
343
+ * @returns Controls for committing or discarding staged changes.
344
+ */
345
+ enterStagingMode(): StageControls;
346
+
347
+ /**
348
+ * If true, the ContainerRuntime is not submitting any new ops to the ordering service.
349
+ * Ops submitted to the ContainerRuntime while in Staging Mode will be queued in the PendingStateManager,
350
+ * either to be discarded or committed later (via the Stage Controls returned from enterStagingMode).
351
+ * @see {@link IContainerRuntimeBase.enterStagingMode}
352
+ */
353
+ readonly inStagingMode: boolean;
293
354
  }
294
355
 
295
356
  /**
@@ -310,6 +371,10 @@ export interface IFluidDataStorePolicies {
310
371
  * (e.g., `ConsensusRegisterCollection`, `ConsensusQueue`, `TaskManager`) won't resolve their promises until
311
372
  * staging mode exits. Set this to `true` for data stores that depend on consensus acknowledgments
312
373
  * to prevent modifications that would leave the data store in an unresponsive state.
374
+ *
375
+ * This provides a best-effort readonly appearance, but no strict enforcement.
376
+ *
377
+ * @see {@link IContainerRuntimeBase.enterStagingMode}
313
378
  */
314
379
  readonly readonlyInStagingMode: boolean;
315
380
  }
@@ -438,6 +503,19 @@ export interface IFluidDataStoreChannel extends IDisposable {
438
503
  setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void;
439
504
  }
440
505
 
506
+ /**
507
+ * Describes a staging mode transition on the container runtime.
508
+ * - `{ inStagingMode: true }` — the runtime has entered staging mode.
509
+ *
510
+ * - `{ inStagingMode: false, commit: boolean }` — the runtime has exited staging mode.
511
+ * `commit` is `true` when staged changes were committed (not discarded), or `false` when they were discarded.
512
+ *
513
+ * @legacy @beta
514
+ */
515
+ export type StagingModeChangedEvent =
516
+ | { readonly inStagingMode: true }
517
+ | { readonly inStagingMode: false; readonly commit: boolean };
518
+
441
519
  /**
442
520
  * @legacy @beta
443
521
  */
package/src/index.ts CHANGED
@@ -31,6 +31,8 @@ export type {
31
31
  IFluidDataStoreContextDetached,
32
32
  IPendingMessagesState,
33
33
  PackagePath,
34
+ StageControls,
35
+ StagingModeChangedEvent,
34
36
  } from "./dataStoreContext.js";
35
37
  export { FlushMode, VisibilityState } from "./dataStoreContext.js";
36
38
  export type { IProvideFluidDataStoreFactory } from "./dataStoreFactory.js";
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { IContainerRuntimeBase } from "./dataStoreContext.js";
6
+ import type { IContainerRuntimeBase, StageControls } from "./dataStoreContext.js";
7
7
 
8
8
  /**
9
9
  * Options for committing staged changes in experimental staging mode.
@@ -33,7 +33,7 @@ export interface CommitStagedChangesOptionsInternal {
33
33
  * Provides methods to either commit or discard changes made while in staging mode.
34
34
  * @internal
35
35
  */
36
- export interface StageControlsInternal extends StageControlsAlpha {
36
+ export interface StageControlsInternal extends StageControls {
37
37
  /**
38
38
  * Exit staging mode and commit to any changes made while in staging mode.
39
39
  * This will cause them to be sent to the ordering service, and subsequent changes
@@ -44,31 +44,11 @@ export interface StageControlsInternal extends StageControlsAlpha {
44
44
  }
45
45
 
46
46
  /**
47
- * Controls for managing staged changes in alpha staging mode.
48
- *
49
- * Provides methods to either commit or discard changes made while in staging mode.
50
- *
51
- * @legacy @alpha
52
- * @sealed
53
- */
54
- export interface StageControlsAlpha {
55
- /**
56
- * Exit staging mode and commit to any changes made while in staging mode.
57
- * This will cause them to be sent to the ordering service, and subsequent changes
58
- * made by this container will additionally flow freely to the ordering service.
59
- */
60
- readonly commitChanges: () => void;
61
- /**
62
- * Exit staging mode and discard any changes made while in staging mode.
63
- */
64
- readonly discardChanges: () => void;
65
- }
66
-
67
- /**
68
- * Experimental extension of {@link IContainerRuntimeBase} to support staging mode.
47
+ * Internal extension of {@link IContainerRuntimeBase} whose {@link IContainerRuntimeBaseInternal.enterStagingMode}
48
+ * returns {@link StageControlsInternal} (which exposes internal commit options such as squash)
69
49
  * @internal
70
50
  */
71
- export interface IContainerRuntimeBaseInternal extends ContainerRuntimeBaseAlpha {
51
+ export interface IContainerRuntimeBaseInternal extends IContainerRuntimeBase {
72
52
  /**
73
53
  * Enters staging mode, allowing changes to be staged before being committed or discarded.
74
54
  * @returns Controls for committing or discarding staged changes.
@@ -77,22 +57,25 @@ export interface IContainerRuntimeBaseInternal extends ContainerRuntimeBaseAlpha
77
57
  }
78
58
 
79
59
  /**
80
- * Alpha interface for container runtime base supporting staging mode.
60
+ * Controls for managing staged changes in alpha staging mode.
61
+ *
62
+ * Provides methods to either commit or discard changes made while in staging mode.
81
63
  *
64
+ * @deprecated Use {@link StageControls} (beta) instead.
82
65
  * @legacy @alpha
83
66
  * @sealed
84
67
  */
85
- export interface ContainerRuntimeBaseAlpha extends IContainerRuntimeBase {
86
- /**
87
- * Enters staging mode, allowing changes to be staged before being committed or discarded.
88
- * @returns Controls for committing or discarding staged changes.
89
- */
90
- enterStagingMode(): StageControlsAlpha;
91
- /**
92
- * Indicates whether the container is currently in staging mode.
93
- */
94
- readonly inStagingMode: boolean;
95
- }
68
+ export interface StageControlsAlpha extends StageControls {}
69
+
70
+ /**
71
+ * Alpha extension of {@link IContainerRuntimeBase} that exposes alpha-level APIs.
72
+ *
73
+ * @remarks Use {@link asLegacyAlpha} to obtain an instance from an {@link IContainerRuntimeBase}.
74
+ *
75
+ * @legacy @alpha
76
+ * @sealed
77
+ */
78
+ export interface ContainerRuntimeBaseAlpha extends IContainerRuntimeBase {}
96
79
 
97
80
  /**
98
81
  * Converts types to their alpha counterparts to expose alpha functionality.