@fluidframework/datastore 2.0.0-dev.1.4.6.106135 → 2.0.0-dev.2.2.0.111723

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 (62) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/channelContext.d.ts +1 -2
  3. package/dist/channelContext.d.ts.map +1 -1
  4. package/dist/channelContext.js.map +1 -1
  5. package/dist/dataStoreRuntime.d.ts +20 -5
  6. package/dist/dataStoreRuntime.d.ts.map +1 -1
  7. package/dist/dataStoreRuntime.js +23 -8
  8. package/dist/dataStoreRuntime.js.map +1 -1
  9. package/dist/fluidHandle.d.ts +27 -4
  10. package/dist/fluidHandle.d.ts.map +1 -1
  11. package/dist/fluidHandle.js +27 -5
  12. package/dist/fluidHandle.js.map +1 -1
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +8 -12
  16. package/dist/index.js.map +1 -1
  17. package/dist/localChannelContext.d.ts +1 -1
  18. package/dist/localChannelContext.d.ts.map +1 -1
  19. package/dist/localChannelContext.js +1 -1
  20. package/dist/localChannelContext.js.map +1 -1
  21. package/dist/packageVersion.d.ts +1 -1
  22. package/dist/packageVersion.js +1 -1
  23. package/dist/packageVersion.js.map +1 -1
  24. package/dist/remoteChannelContext.d.ts +1 -1
  25. package/dist/remoteChannelContext.d.ts.map +1 -1
  26. package/dist/remoteChannelContext.js +1 -1
  27. package/dist/remoteChannelContext.js.map +1 -1
  28. package/lib/channelContext.d.ts +1 -2
  29. package/lib/channelContext.d.ts.map +1 -1
  30. package/lib/channelContext.js.map +1 -1
  31. package/lib/dataStoreRuntime.d.ts +20 -5
  32. package/lib/dataStoreRuntime.d.ts.map +1 -1
  33. package/lib/dataStoreRuntime.js +24 -9
  34. package/lib/dataStoreRuntime.js.map +1 -1
  35. package/lib/fluidHandle.d.ts +27 -4
  36. package/lib/fluidHandle.d.ts.map +1 -1
  37. package/lib/fluidHandle.js +27 -5
  38. package/lib/fluidHandle.js.map +1 -1
  39. package/lib/index.d.ts +2 -2
  40. package/lib/index.d.ts.map +1 -1
  41. package/lib/index.js +2 -2
  42. package/lib/index.js.map +1 -1
  43. package/lib/localChannelContext.d.ts +1 -1
  44. package/lib/localChannelContext.d.ts.map +1 -1
  45. package/lib/localChannelContext.js +1 -1
  46. package/lib/localChannelContext.js.map +1 -1
  47. package/lib/packageVersion.d.ts +1 -1
  48. package/lib/packageVersion.js +1 -1
  49. package/lib/packageVersion.js.map +1 -1
  50. package/lib/remoteChannelContext.d.ts +1 -1
  51. package/lib/remoteChannelContext.d.ts.map +1 -1
  52. package/lib/remoteChannelContext.js +1 -1
  53. package/lib/remoteChannelContext.js.map +1 -1
  54. package/package.json +30 -25
  55. package/prettier.config.cjs +8 -0
  56. package/src/channelContext.ts +1 -2
  57. package/src/dataStoreRuntime.ts +35 -7
  58. package/src/fluidHandle.ts +31 -5
  59. package/src/index.ts +8 -2
  60. package/src/localChannelContext.ts +1 -1
  61. package/src/packageVersion.ts +1 -1
  62. package/src/remoteChannelContext.ts +1 -1
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
7
  import {
8
+ FluidObject,
8
9
  IFluidHandle,
9
10
  IFluidHandleContext,
10
11
  IRequest,
@@ -62,6 +63,7 @@ import {
62
63
  create404Response,
63
64
  createResponseError,
64
65
  exceptionToResponse,
66
+ requestFluidObject,
65
67
  } from "@fluidframework/runtime-utils";
66
68
  import {
67
69
  IChannel,
@@ -79,6 +81,7 @@ import { v4 as uuid } from "uuid";
79
81
  import { IChannelContext, summarizeChannel } from "./channelContext";
80
82
  import { LocalChannelContext, LocalChannelContextBase, RehydratedLocalChannelContext } from "./localChannelContext";
81
83
  import { RemoteChannelContext } from "./remoteChannelContext";
84
+ import { FluidObjectHandle } from "./fluidHandle";
82
85
 
83
86
  export enum DataStoreMessageType {
84
87
  // Creates a new channel
@@ -99,6 +102,8 @@ export class FluidDataStoreRuntime extends
99
102
  TypedEventEmitter<IFluidDataStoreRuntimeEvents> implements
100
103
  IFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext {
101
104
  /**
105
+ * @deprecated - Instantiate the class using its constructor instead.
106
+ *
102
107
  * Loads the data store runtime
103
108
  * @param context - The data store context
104
109
  * @param sharedObjectRegistry - The registry of shared objects used by this data store
@@ -109,9 +114,18 @@ IFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext {
109
114
  sharedObjectRegistry: ISharedObjectRegistry,
110
115
  existing: boolean,
111
116
  ): FluidDataStoreRuntime {
112
- return new FluidDataStoreRuntime(context, sharedObjectRegistry, existing);
117
+ return new FluidDataStoreRuntime(
118
+ context,
119
+ sharedObjectRegistry,
120
+ existing,
121
+ async (dataStoreRuntime) => requestFluidObject(dataStoreRuntime, "/"));
113
122
  }
114
123
 
124
+ /**
125
+ * {@inheritDoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.entryPoint}
126
+ */
127
+ public readonly entryPoint?: IFluidHandle<FluidObject>;
128
+
115
129
  public get IFluidRouter() { return this; }
116
130
 
117
131
  public get connected(): boolean {
@@ -176,10 +190,22 @@ IFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext {
176
190
  // channel contexts.
177
191
  private readonly channelsBaseGCDetails: LazyPromise<Map<string, IGarbageCollectionDetailsBase>>;
178
192
 
193
+ /**
194
+ * Create an instance of a DataStore runtime.
195
+ *
196
+ * @param dataStoreContext - Context object for the runtime.
197
+ * @param sharedObjectRegistry - The registry of shared objects that this data store will be able to instantiate.
198
+ * @param existing - Pass 'true' if loading this datastore from an existing file; pass 'false' otherwise.
199
+ * @param initializeEntryPoint - Function to initialize the entryPoint object for the data store runtime. The
200
+ * handle to this data store runtime will point to the object returned by this function. If this function is not
201
+ * provided, the handle will be left undefined. This is here so we can start making handles a first-class citizen
202
+ * and the primary way of interacting with some Fluid objects, and should be used if possible.
203
+ */
179
204
  public constructor(
180
205
  private readonly dataStoreContext: IFluidDataStoreContext,
181
206
  private readonly sharedObjectRegistry: ISharedObjectRegistry,
182
207
  existing: boolean,
208
+ initializeEntryPoint?: (runtime: IFluidDataStoreRuntime) => Promise<FluidObject>,
183
209
  ) {
184
210
  super();
185
211
 
@@ -201,8 +227,7 @@ IFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext {
201
227
  const tree = dataStoreContext.baseSnapshot;
202
228
 
203
229
  this.channelsBaseGCDetails = new LazyPromise(async () => {
204
- const baseGCDetails = await
205
- (this.dataStoreContext.getBaseGCDetails?.() ?? this.dataStoreContext.getInitialGCSummaryDetails());
230
+ const baseGCDetails = await this.dataStoreContext.getBaseGCDetails();
206
231
  return unpackChildNodesGCDetails(baseGCDetails);
207
232
  });
208
233
 
@@ -265,6 +290,11 @@ IFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext {
265
290
  });
266
291
  }
267
292
 
293
+ if (initializeEntryPoint) {
294
+ const promise = new LazyPromise(async () => initializeEntryPoint(this));
295
+ this.entryPoint = new FluidObjectHandle<FluidObject>(promise, "", this.objectsRoutingContext);
296
+ }
297
+
268
298
  this.attachListener();
269
299
  // If exists on storage or loaded from a snapshot, it should already be bound.
270
300
  this.bindState = existing ? BindState.Bound : BindState.NotBound;
@@ -658,10 +688,8 @@ IFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext {
658
688
  * After GC has run, called to notify this channel of routes that are used in it. It calls the child contexts to
659
689
  * update their used routes.
660
690
  * @param usedRoutes - The routes that are used in all contexts in this channel.
661
- * @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
662
- * as part of this GC run, this should be used to update the time when it happens.
663
691
  */
664
- public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {
692
+ public updateUsedRoutes(usedRoutes: string[]) {
665
693
  // Get a map of channel ids to routes used in it.
666
694
  const usedContextRoutes = unpackChildNodesUsedRoutes(usedRoutes);
667
695
 
@@ -672,7 +700,7 @@ IFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext {
672
700
 
673
701
  // Update the used routes in each context. Used routes is empty for unused context.
674
702
  for (const [contextId, context] of this.contexts) {
675
- context.updateUsedRoutes(usedContextRoutes.get(contextId) ?? [], gcTimestamp);
703
+ context.updateUsedRoutes(usedContextRoutes.get(contextId) ?? []);
676
704
  }
677
705
  }
678
706
 
@@ -10,12 +10,27 @@ import {
10
10
  } from "@fluidframework/core-interfaces";
11
11
  import { generateHandleContextPath } from "@fluidframework/runtime-utils";
12
12
 
13
+ /**
14
+ * Handle for a shared {@link @fluidframework/core-interfaces#FluidObject}.
15
+ */
13
16
  export class FluidObjectHandle<T extends FluidObject = FluidObject> implements IFluidHandle {
14
17
  private readonly pendingHandlesToMakeVisible: Set<IFluidHandle> = new Set();
18
+
19
+ /**
20
+ * {@inheritDoc @fluidframework/core-interfaces#IFluidHandle.absolutePath}
21
+ */
15
22
  public readonly absolutePath: string;
16
23
 
17
- public get IFluidHandle(): IFluidHandle { return this; }
24
+ /**
25
+ * {@inheritDoc @fluidframework/core-interfaces#IProvideFluidHandle.IFluidHandle}
26
+ */
27
+ public get IFluidHandle(): IFluidHandle {
28
+ return this;
29
+ }
18
30
 
31
+ /**
32
+ * {@inheritDoc @fluidframework/core-interfaces#IFluidHandle.isAttached}
33
+ */
19
34
  public get isAttached(): boolean {
20
35
  return this.routeContext.isAttached;
21
36
  }
@@ -45,10 +60,12 @@ export class FluidObjectHandle<T extends FluidObject = FluidObject> implements I
45
60
  private locallyVisible: boolean = false;
46
61
 
47
62
  /**
48
- * Creates a new FluidObjectHandle.
49
- * @param value - The FluidObject object this handle is for.
50
- * @param path - The path to this handle relative to the routeContext.
51
- * @param routeContext - The parent IFluidHandleContext that has a route to this handle.
63
+ * Creates a new `FluidObjectHandle`.
64
+ *
65
+ * @param value - The {@link @fluidframework/core-interfaces#FluidObject} object this handle is for.
66
+ * @param path - The path to this handle relative to the `routeContext`.
67
+ * @param routeContext - The parent {@link @fluidframework/core-interfaces#IFluidHandleContext} that has a route
68
+ * to this handle.
52
69
  */
53
70
  constructor(
54
71
  protected readonly value: T | Promise<T>,
@@ -58,11 +75,17 @@ export class FluidObjectHandle<T extends FluidObject = FluidObject> implements I
58
75
  this.absolutePath = generateHandleContextPath(path, this.routeContext);
59
76
  }
60
77
 
78
+ /**
79
+ * {@inheritDoc @fluidframework/core-interfaces#IFluidHandle.get}
80
+ */
61
81
  public async get(): Promise<any> {
62
82
  // Note that this return works whether we received a T or a Promise<T> for this.value in the constructor.
63
83
  return this.value;
64
84
  }
65
85
 
86
+ /**
87
+ * {@inheritDoc @fluidframework/core-interfaces#IFluidHandle.attachGraph }
88
+ */
66
89
  public attachGraph(): void {
67
90
  if (this.visible) {
68
91
  return;
@@ -76,6 +99,9 @@ export class FluidObjectHandle<T extends FluidObject = FluidObject> implements I
76
99
  this.routeContext.attachGraph();
77
100
  }
78
101
 
102
+ /**
103
+ * {@inheritDoc @fluidframework/core-interfaces#IFluidHandle.bind}
104
+ */
79
105
  public bind(handle: IFluidHandle) {
80
106
  // If this handle is visible, attach the graph of the incoming handle as well.
81
107
  if (this.visible) {
package/src/index.ts CHANGED
@@ -3,5 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export * from "./dataStoreRuntime";
7
- export * from "./fluidHandle";
6
+ export { FluidObjectHandle } from "./fluidHandle";
7
+ export {
8
+ DataStoreMessageType,
9
+ FluidDataStoreRuntime,
10
+ ISharedObjectRegistry,
11
+ mixinRequestHandler,
12
+ mixinSummaryHandler,
13
+ } from "./dataStoreRuntime";
@@ -143,7 +143,7 @@ export abstract class LocalChannelContextBase implements IChannelContext {
143
143
  return this.channel.getGCData(fullGC);
144
144
  }
145
145
 
146
- public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {
146
+ public updateUsedRoutes(usedRoutes: string[]) {
147
147
  /**
148
148
  * Currently, DDSes are always considered referenced and are not garbage collected.
149
149
  * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/datastore";
9
- export const pkgVersion = "2.0.0-dev.1.4.6.106135";
9
+ export const pkgVersion = "2.0.0-dev.2.2.0.111723";
@@ -303,7 +303,7 @@ export class RemoteChannelContext implements IChannelContext {
303
303
  return channel.getGCData(fullGC);
304
304
  }
305
305
 
306
- public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {
306
+ public updateUsedRoutes(usedRoutes: string[]) {
307
307
  /**
308
308
  * Currently, DDSes are always considered referenced and are not garbage collected. Update the summarizer node's
309
309
  * used routes to contain a route to this channel context.