@fluidframework/datastore 2.32.0 → 2.33.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.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.50.1"
8
+ "packageVersion": "7.52.5"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/datastore",
3
- "version": "2.32.0",
3
+ "version": "2.33.0",
4
4
  "description": "Fluid data store implementation",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -69,30 +69,30 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "~2.32.0",
73
- "@fluidframework/container-definitions": "~2.32.0",
74
- "@fluidframework/core-interfaces": "~2.32.0",
75
- "@fluidframework/core-utils": "~2.32.0",
76
- "@fluidframework/datastore-definitions": "~2.32.0",
77
- "@fluidframework/driver-definitions": "~2.32.0",
78
- "@fluidframework/driver-utils": "~2.32.0",
79
- "@fluidframework/id-compressor": "~2.32.0",
80
- "@fluidframework/runtime-definitions": "~2.32.0",
81
- "@fluidframework/runtime-utils": "~2.32.0",
82
- "@fluidframework/telemetry-utils": "~2.32.0",
72
+ "@fluid-internal/client-utils": "~2.33.0",
73
+ "@fluidframework/container-definitions": "~2.33.0",
74
+ "@fluidframework/core-interfaces": "~2.33.0",
75
+ "@fluidframework/core-utils": "~2.33.0",
76
+ "@fluidframework/datastore-definitions": "~2.33.0",
77
+ "@fluidframework/driver-definitions": "~2.33.0",
78
+ "@fluidframework/driver-utils": "~2.33.0",
79
+ "@fluidframework/id-compressor": "~2.33.0",
80
+ "@fluidframework/runtime-definitions": "~2.33.0",
81
+ "@fluidframework/runtime-utils": "~2.33.0",
82
+ "@fluidframework/telemetry-utils": "~2.33.0",
83
83
  "uuid": "^9.0.0"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@arethetypeswrong/cli": "^0.17.1",
87
87
  "@biomejs/biome": "~1.9.3",
88
- "@fluid-internal/mocha-test-setup": "~2.32.0",
88
+ "@fluid-internal/mocha-test-setup": "~2.33.0",
89
89
  "@fluid-tools/build-cli": "^0.55.0",
90
90
  "@fluidframework/build-common": "^2.0.3",
91
91
  "@fluidframework/build-tools": "^0.55.0",
92
- "@fluidframework/datastore-previous": "npm:@fluidframework/datastore@2.31.0",
92
+ "@fluidframework/datastore-previous": "npm:@fluidframework/datastore@2.32.0",
93
93
  "@fluidframework/eslint-config-fluid": "^5.7.3",
94
- "@fluidframework/test-runtime-utils": "~2.32.0",
95
- "@microsoft/api-extractor": "7.50.1",
94
+ "@fluidframework/test-runtime-utils": "~2.33.0",
95
+ "@microsoft/api-extractor": "7.52.5",
96
96
  "@types/lodash": "^4.14.118",
97
97
  "@types/mocha": "^10.0.10",
98
98
  "@types/node": "^18.19.0",
@@ -105,13 +105,16 @@
105
105
  "eslint": "~8.55.0",
106
106
  "mocha": "^10.8.2",
107
107
  "mocha-multi-reporters": "^1.5.1",
108
- "moment": "^2.21.0",
109
108
  "rimraf": "^4.4.0",
110
109
  "sinon": "^18.0.1",
111
110
  "typescript": "~5.4.5"
112
111
  },
113
112
  "typeValidation": {
114
- "broken": {},
113
+ "broken": {
114
+ "Class_FluidDataStoreRuntime": {
115
+ "forwardCompat": false
116
+ }
117
+ },
115
118
  "entrypoint": "legacy"
116
119
  },
117
120
  "scripts": {
@@ -16,6 +16,7 @@ import { IFluidHandleContext } from "@fluidframework/core-interfaces/internal";
16
16
  import type { IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
17
17
  import {
18
18
  assert,
19
+ debugAssert,
19
20
  Deferred,
20
21
  LazyPromise,
21
22
  unreachableCase,
@@ -56,6 +57,10 @@ import {
56
57
  IInboundSignalMessage,
57
58
  type IRuntimeMessageCollection,
58
59
  type IRuntimeMessagesContent,
60
+ // eslint-disable-next-line import/no-deprecated
61
+ type IContainerRuntimeBaseExperimental,
62
+ notifiesReadOnlyState,
63
+ encodeHandlesInContainerRuntime,
59
64
  } from "@fluidframework/runtime-definitions/internal";
60
65
  import {
61
66
  GCDataBuilder,
@@ -102,6 +107,22 @@ import {
102
107
  import { pkgVersion } from "./packageVersion.js";
103
108
  import { RemoteChannelContext } from "./remoteChannelContext.js";
104
109
 
110
+ type PickRequired<T extends Record<never, unknown>, K extends keyof T> = Omit<T, K> &
111
+ Required<Pick<T, K>>;
112
+
113
+ interface IFluidDataStoreContextFeaturesToTypes {
114
+ [encodeHandlesInContainerRuntime]: IFluidDataStoreContext; // No difference in typing with this feature
115
+ [notifiesReadOnlyState]: PickRequired<IFluidDataStoreContext, "isReadOnly">;
116
+ }
117
+
118
+ function contextSupportsFeature<K extends keyof IFluidDataStoreContextFeaturesToTypes>(
119
+ obj: IFluidDataStoreContext,
120
+ feature: K,
121
+ ): obj is IFluidDataStoreContextFeaturesToTypes[K] {
122
+ const { ILayerCompatDetails } = obj as FluidObject<ILayerCompatDetails>;
123
+ return ILayerCompatDetails?.supportedFeatures.has(feature) ?? false;
124
+ }
125
+
105
126
  /**
106
127
  * @legacy
107
128
  * @alpha
@@ -140,6 +161,11 @@ export class FluidDataStoreRuntime
140
161
  return this.dataStoreContext.connected;
141
162
  }
142
163
 
164
+ /**
165
+ * {@inheritDoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.isReadOnly}
166
+ */
167
+ public readonly isReadOnly = (): boolean => this._readonly;
168
+
143
169
  public get clientId(): string | undefined {
144
170
  return this.dataStoreContext.clientId;
145
171
  }
@@ -229,6 +255,15 @@ export class FluidDataStoreRuntime
229
255
  */
230
256
  public readonly ILayerCompatDetails?: unknown = dataStoreCompatDetailsForRuntime;
231
257
 
258
+ /**
259
+ * See IFluidDataStoreRuntimeInternalConfig.submitMessagesWithoutEncodingHandles
260
+ *
261
+ * Note: this class doesn't declare that it implements IFluidDataStoreRuntimeInternalConfig,
262
+ * and we keep this property as private, but consumers may optimistically cast
263
+ * to the internal interface to access this property.
264
+ */
265
+ private readonly submitMessagesWithoutEncodingHandles: boolean;
266
+
232
267
  /**
233
268
  * Create an instance of a DataStore runtime.
234
269
  *
@@ -254,11 +289,25 @@ export class FluidDataStoreRuntime
254
289
  );
255
290
 
256
291
  // Validate that the Runtime is compatible with this DataStore.
257
- const maybeRuntimeCompatDetails = dataStoreContext as FluidObject<ILayerCompatDetails>;
258
- validateRuntimeCompatibility(
259
- maybeRuntimeCompatDetails.ILayerCompatDetails,
260
- this.dispose.bind(this),
292
+ const { ILayerCompatDetails: runtimeCompatDetails } =
293
+ dataStoreContext as FluidObject<ILayerCompatDetails>;
294
+ validateRuntimeCompatibility(runtimeCompatDetails, this.dispose.bind(this));
295
+
296
+ if (contextSupportsFeature(dataStoreContext, notifiesReadOnlyState)) {
297
+ this._readonly = dataStoreContext.isReadOnly();
298
+ } else {
299
+ this._readonly = this.dataStoreContext.deltaManager.readOnlyInfo.readonly === true;
300
+ this.dataStoreContext.deltaManager.on("readonly", (readonly) =>
301
+ this.notifyReadOnlyState(readonly),
302
+ );
303
+ }
304
+
305
+ this.submitMessagesWithoutEncodingHandles = contextSupportsFeature(
306
+ dataStoreContext,
307
+ encodeHandlesInContainerRuntime,
261
308
  );
309
+ // We read this property here to avoid a compiler error (unused private member)
310
+ debugAssert(() => this.submitMessagesWithoutEncodingHandles !== undefined);
262
311
 
263
312
  this.mc = createChildMonitoringContext({
264
313
  logger: dataStoreContext.baseLogger,
@@ -356,6 +405,18 @@ export class FluidDataStoreRuntime
356
405
  // By default, a data store can log maximum 10 local changes telemetry in summarizer.
357
406
  this.localChangesTelemetryCount =
358
407
  this.mc.config.getNumber("Fluid.Telemetry.LocalChangesTelemetryCount") ?? 10;
408
+
409
+ // eslint-disable-next-line import/no-deprecated
410
+ const base: IContainerRuntimeBaseExperimental | undefined =
411
+ // eslint-disable-next-line import/no-deprecated
412
+ this.dataStoreContext.containerRuntime satisfies IContainerRuntimeBaseExperimental;
413
+ if (base !== undefined && "inStagingMode" in base) {
414
+ Object.defineProperty(this, "inStagingMode", {
415
+ get: () => {
416
+ return base.inStagingMode;
417
+ },
418
+ });
419
+ }
359
420
  }
360
421
 
361
422
  get deltaManager(): IDeltaManagerErased {
@@ -640,6 +701,20 @@ export class FluidDataStoreRuntime
640
701
  raiseConnectedEvent(this.logger, this, connected, clientId);
641
702
  }
642
703
 
704
+ private _readonly: boolean;
705
+ /**
706
+ * This function is used by the datastore context to configure the
707
+ * readonly state of this object. It should not be invoked by
708
+ * any other callers.
709
+ */
710
+ public notifyReadOnlyState(readonly: boolean): void {
711
+ this.verifyNotClosed();
712
+ if (readonly !== this._readonly) {
713
+ this._readonly = readonly;
714
+ this.emit("readonly", readonly);
715
+ }
716
+ }
717
+
643
718
  public getQuorum(): IQuorumClients {
644
719
  return this.quorum;
645
720
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/datastore";
9
- export const pkgVersion = "2.32.0";
9
+ export const pkgVersion = "2.33.0";