@fluidframework/datastore-definitions 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277

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 (40) hide show
  1. package/.eslintrc.cjs +11 -0
  2. package/CHANGELOG.md +215 -0
  3. package/README.md +45 -7
  4. package/api-extractor-lint.json +4 -0
  5. package/api-extractor.json +2 -2
  6. package/api-report/datastore-definitions.api.md +156 -0
  7. package/dist/channel.d.ts +71 -16
  8. package/dist/channel.d.ts.map +1 -1
  9. package/dist/channel.js.map +1 -1
  10. package/dist/dataStoreRuntime.d.ts +28 -7
  11. package/dist/dataStoreRuntime.d.ts.map +1 -1
  12. package/dist/dataStoreRuntime.js.map +1 -1
  13. package/dist/datastore-definitions-alpha.d.ts +480 -0
  14. package/dist/datastore-definitions-beta.d.ts +395 -0
  15. package/dist/datastore-definitions-public.d.ts +395 -0
  16. package/dist/datastore-definitions-untrimmed.d.ts +480 -0
  17. package/dist/index.d.ts +10 -10
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +0 -21
  20. package/dist/index.js.map +1 -1
  21. package/dist/jsonable.d.ts +46 -14
  22. package/dist/jsonable.d.ts.map +1 -1
  23. package/dist/jsonable.js.map +1 -1
  24. package/dist/serializable.d.ts +5 -4
  25. package/dist/serializable.d.ts.map +1 -1
  26. package/dist/serializable.js.map +1 -1
  27. package/dist/storage.d.ts +1 -0
  28. package/dist/storage.d.ts.map +1 -1
  29. package/dist/storage.js.map +1 -1
  30. package/dist/tsdoc-metadata.json +11 -0
  31. package/package.json +99 -40
  32. package/prettier.config.cjs +8 -0
  33. package/src/channel.ts +256 -200
  34. package/src/dataStoreRuntime.ts +117 -96
  35. package/src/index.ts +17 -10
  36. package/src/jsonable.ts +80 -23
  37. package/src/serializable.ts +5 -4
  38. package/src/storage.ts +14 -13
  39. package/tsconfig.json +10 -12
  40. package/.eslintrc.js +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"channel.js","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n IGarbageCollectionData,\n ISummaryTreeWithStats,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { IChannelAttributes } from \"./storage\";\nimport { IFluidDataStoreRuntime } from \"./dataStoreRuntime\";\n\nexport interface IChannel extends IFluidLoadable {\n /**\n * A readonly identifier for the channel\n */\n readonly id: string;\n\n readonly owner?: string;\n\n readonly attributes: IChannelAttributes;\n\n /**\n * Generates summary of the channel synchronously. It is called when an `attach message`\n * for a local channel is generated. In other words, when the channel is being attached\n * to make it visible to other clients.\n * Note: Since Attach Summary is generated for local channels when making them visible to\n * remote clients, they don't have any previous summaries to compare against. For this reason,\n * The attach summary cannot contain summary handles (paths to sub-trees or blobs).\n * It can, however, contain ISummaryAttachment (handles to blobs uploaded async via the blob manager).\n * @param fullTree - flag indicating whether the attempt should generate a full\n * summary tree without any handles for unchanged subtrees.\n * @param trackState - optimization for tracking state of objects across summaries. If the state\n * of an object did not change since last successful summary, an ISummaryHandle can be used\n * instead of re-summarizing it. If this is false, the expectation is that you should never\n * send an ISummaryHandle since you are not expected to track state.\n * Note: The goal is to remove the trackState and automatically decided whether the\n * handles will be used or not: https://github.com/microsoft/FluidFramework/issues/10455\n * @returns A summary capturing the current state of the channel.\n */\n getAttachSummary(\n fullTree?: boolean,\n trackState?: boolean,\n telemetryContext?: ITelemetryContext,\n ): ISummaryTreeWithStats;\n\n /**\n * Generates summary of the channel asynchronously.\n * This should not be called where the channel can be modified while summarization is in progress.\n * @param fullTree - flag indicating whether the attempt should generate a full\n * summary tree without any handles for unchanged subtrees. It is only set to true when generating\n * a summary from the entire container.\n * @param trackState - This tells whether we should track state from this summary.\n * @returns A summary capturing the current state of the channel.\n */\n summarize(\n fullTree?: boolean,\n trackState?: boolean,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummaryTreeWithStats>;\n\n /**\n * Checks if the channel is attached to storage.\n * @returns True iff the channel is attached.\n */\n isAttached(): boolean;\n\n /**\n * Enables the channel to send and receive ops.\n * @param services - Services to connect to\n */\n connect(services: IChannelServices): void;\n\n /**\n * Returns the GC data for this channel. It contains a list of GC nodes that contains references to\n * other GC nodes.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n getGCData(fullGC?: boolean): IGarbageCollectionData;\n}\n\n/**\n * Handler provided by shared data structure to process requests from the runtime.\n */\nexport interface IDeltaHandler {\n /**\n * Processes the op.\n * @param message - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n process: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => void;\n\n /**\n * State change events to indicate changes to the delta connection\n * @param connected - true if connected, false otherwise\n */\n setConnectionState(connected: boolean): void;\n\n /**\n * Called when the runtime asks the client to resubmit an op. This may be because the Container reconnected and\n * this op was not acked.\n * The client can choose to resubmit the same message, submit different / multiple messages or not submit anything\n * at all.\n * @param message - The original message that was submitted.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n reSubmit(message: any, localOpMetadata: unknown): void;\n\n /**\n * Apply changes from an op. Used when rehydrating an attached container\n * with pending changes. This prepares the SharedObject for seeing an ACK\n * for the op or resubmitting the op upon reconnection.\n * @param message - Contents of a stashed op.\n * @returns localMetadata of the op, to be passed to process() or resubmit()\n * when the op is ACKed or resubmitted, respectively\n */\n applyStashedOp(message: any): unknown;\n\n /**\n * Revert a local op.\n * @param message - The original message that was submitted.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n rollback?(message: any, localOpMetadata: unknown): void;\n}\n\n/**\n * Interface to represent a connection to a delta notification stream.\n */\nexport interface IDeltaConnection {\n connected: boolean;\n\n /**\n * Send new messages to the server.\n * @param messageContent - The content of the message to be sent.\n * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n * and not sent to the server. It will be provided back when this message is acknowledged by the server. It will\n * also be provided back when asked to resubmit the message.\n */\n submit(messageContent: any, localOpMetadata: unknown): void;\n\n /**\n * Attaches a message handler to the delta connection\n */\n attach(handler: IDeltaHandler): void;\n\n /**\n * Indicates that the channel is dirty and needs to be part of the summary. It is called by a SharedSummaryBlock\n * that needs to be part of the summary but does not generate ops.\n */\n dirty(): void;\n\n /**\n * Called when a new outbound reference is added to another node. This is used by garbage collection to identify\n * all references added in the system.\n * @param srcHandle - The handle of the node that added the reference.\n * @param outboundHandle - The handle of the outbound node that is referenced.\n */\n addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;\n}\n\n/**\n * Storage services to read the objects at a given path.\n */\nexport interface IChannelStorageService {\n /**\n * Reads the object contained at the given path. Returns a buffer representation for the object.\n */\n readBlob(path: string): Promise<ArrayBufferLike>;\n\n /**\n * Determines if there is an object contained at the given path.\n */\n contains(path: string): Promise<boolean>;\n\n /**\n * Lists the blobs that exist at a specific path.\n */\n list(path: string): Promise<string[]>;\n}\n\n/**\n * Storage services to read the objects at a given path using the given delta connection.\n */\nexport interface IChannelServices {\n deltaConnection: IDeltaConnection;\n\n objectStorage: IChannelStorageService;\n}\n\n/**\n * Definitions of a channel factory. Factories follow a common model but enable custom behavior.\n */\nexport interface IChannelFactory {\n /**\n * String representing the type of the factory.\n */\n readonly type: string;\n\n /**\n * Attributes of the channel.\n */\n readonly attributes: IChannelAttributes;\n\n /**\n * Loads the given channel. This call is only ever invoked internally as the only thing\n * that is ever directly loaded is the document itself. Load will then only be called on documents that\n * were created and added to a channel.\n * @param runtime - Data store runtime containing state/info/helper methods about the data store.\n * @param id - ID of the channel.\n * @param services - Services to read objects at a given path using the delta connection.\n * @param channelAttributes - The attributes for the the channel to be loaded.\n * @returns The loaded object\n *\n * @privateRemarks\n * Thought: should the storage object include the version information and limit access to just files\n * for the given object? The latter seems good in general. But both are probably good things. We then just\n * need a way to allow the document to provide later storage for the object.\n */\n load(\n runtime: IFluidDataStoreRuntime,\n id: string,\n services: IChannelServices,\n channelAttributes: Readonly<IChannelAttributes>,\n ): Promise<IChannel>;\n\n /**\n * Creates a local version of the channel.\n * Calling attach on the object later will insert it into the object stream.\n * @param runtime - The runtime the new object will be associated with\n * @param id - The unique ID of the new object\n * @returns The newly created object.\n *\n * @privateRemarks\n * NOTE here - When we attach we need to submit all the pending ops prior to actually doing the attach\n * for consistency.\n */\n create(runtime: IFluidDataStoreRuntime, id: string): IChannel;\n}\n"]}
1
+ {"version":3,"file":"channel.js","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIGarbageCollectionData,\n\tIExperimentalIncrementalSummaryContext,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { IChannelAttributes } from \"./storage\";\nimport { IFluidDataStoreRuntime } from \"./dataStoreRuntime\";\n\n/**\n * @public\n */\nexport interface IChannel extends IFluidLoadable {\n\t/**\n\t * A readonly identifier for the channel\n\t */\n\treadonly id: string;\n\n\treadonly attributes: IChannelAttributes;\n\n\t/**\n\t * Generates summary of the channel synchronously. It is called when an `attach message`\n\t * for a local channel is generated. In other words, when the channel is being attached\n\t * to make it visible to other clients.\n\t *\n\t * @remarks\n\t *\n\t * Note: Since the Attach Summary is generated for local channels when making them visible to\n\t * remote clients, they don't have any previous summaries to compare against. For this reason,\n\t * the attach summary cannot contain summary handles (paths to sub-trees or blobs).\n\t * It can, however, contain {@link @fluidframework/protocol-definitions#ISummaryAttachment}\n\t * (handles to blobs uploaded async via the blob manager).\n\t *\n\t * @param fullTree - A flag indicating whether the attempt should generate a full\n\t * summary tree without any handles for unchanged subtrees.\n\t *\n\t * Default: `false`\n\t *\n\t * @param trackState - An optimization for tracking state of objects across summaries. If the state\n\t * of an object did not change since last successful summary, an\n\t * {@link @fluidframework/protocol-definitions#ISummaryHandle} can be used\n\t * instead of re-summarizing it. If this is `false`, the expectation is that you should never\n\t * send an `ISummaryHandle`, since you are not expected to track state.\n\t *\n\t * Note: The goal is to remove the trackState and automatically decided whether the\n\t * handles will be used or not: {@link https://github.com/microsoft/FluidFramework/issues/10455}\n\t *\n\t * Default: `false`\n\t *\n\t * @param telemetryContext - See {@link @fluidframework/runtime-definitions#ITelemetryContext}.\n\t *\n\t * @returns A summary capturing the current state of the channel.\n\t */\n\tgetAttachSummary(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * Generates summary of the channel asynchronously.\n\t * This should not be called where the channel can be modified while summarization is in progress.\n\t *\n\t * @param fullTree - flag indicating whether the attempt should generate a full\n\t * summary tree without any handles for unchanged subtrees. It should only be set to true when generating\n\t * a summary from the entire container.\n\t *\n\t * Default: `false`\n\t *\n\t * @param trackState - An optimization for tracking state of objects across summaries. If the state\n\t * of an object did not change since last successful summary, an\n\t * {@link @fluidframework/protocol-definitions#ISummaryHandle} can be used\n\t * instead of re-summarizing it. If this is `false`, the expectation is that you should never\n\t * send an `ISummaryHandle`, since you are not expected to track state.\n\t *\n\t * Default: `false`\n\t *\n\t * Note: The goal is to remove the trackState and automatically decided whether the\n\t * handles will be used or not: {@link https://github.com/microsoft/FluidFramework/issues/10455}\n\t *\n\t * @param telemetryContext - See {@link @fluidframework/runtime-definitions#ITelemetryContext}.\n\t *\n\t * @returns A summary capturing the current state of the channel.\n\t */\n\tsummarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * Checks if the channel is attached to storage.\n\t * @returns True iff the channel is attached.\n\t */\n\tisAttached(): boolean;\n\n\t/**\n\t * Enables the channel to send and receive ops.\n\t * @param services - The services to connect to.\n\t */\n\tconnect(services: IChannelServices): void;\n\n\t/**\n\t * Returns the GC data for this channel. It contains a list of GC nodes that contains references to\n\t * other GC nodes.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tgetGCData(fullGC?: boolean): IGarbageCollectionData;\n}\n\n/**\n * Handler provided by shared data structure to process requests from the runtime.\n * @public\n */\nexport interface IDeltaHandler {\n\t/**\n\t * Processes the op.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprocess: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => void;\n\n\t/**\n\t * State change events to indicate changes to the delta connection\n\t * @param connected - true if connected, false otherwise\n\t */\n\tsetConnectionState(connected: boolean): void;\n\n\t/**\n\t * Called when the runtime asks the client to resubmit an op. This may be because the Container reconnected and\n\t * this op was not acked.\n\t * The client can choose to resubmit the same message, submit different / multiple messages or not submit anything\n\t * at all.\n\t * @param message - The original message that was submitted.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\treSubmit(message: any, localOpMetadata: unknown): void;\n\n\t/**\n\t * Apply changes from an op. Used when rehydrating an attached container\n\t * with pending changes. This prepares the SharedObject for seeing an ACK\n\t * for the op or resubmitting the op upon reconnection.\n\t * @param message - Contents of a stashed op.\n\t * @returns localMetadata of the op, to be passed to process() or resubmit()\n\t * when the op is ACKed or resubmitted, respectively\n\t */\n\tapplyStashedOp(message: any): unknown;\n\n\t/**\n\t * Revert a local op.\n\t * @param message - The original message that was submitted.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\trollback?(message: any, localOpMetadata: unknown): void;\n}\n\n/**\n * Interface to represent a connection to a delta notification stream.\n * @public\n */\nexport interface IDeltaConnection {\n\tconnected: boolean;\n\n\t/**\n\t * Send new messages to the server.\n\t * @param messageContent - The content of the message to be sent.\n\t * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n\t * and not sent to the server. It will be provided back when this message is acknowledged by the server. It will\n\t * also be provided back when asked to resubmit the message.\n\t */\n\tsubmit(messageContent: any, localOpMetadata: unknown): void;\n\n\t/**\n\t * Attaches a message handler to the delta connection\n\t */\n\tattach(handler: IDeltaHandler): void;\n\n\t/**\n\t * Indicates that the channel is dirty and needs to be part of the summary. It is called by a SharedSummaryBlock\n\t * that needs to be part of the summary but does not generate ops.\n\t */\n\tdirty(): void;\n\n\t/**\n\t * Called when a new outbound reference is added to another node. This is used by garbage collection to identify\n\t * all references added in the system.\n\t * @param srcHandle - The handle of the node that added the reference.\n\t * @param outboundHandle - The handle of the outbound node that is referenced.\n\t */\n\taddedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;\n}\n\n/**\n * Storage services to read the objects at a given path.\n * @public\n */\nexport interface IChannelStorageService {\n\t/**\n\t * Reads the object contained at the given path. Returns a buffer representation for the object.\n\t */\n\treadBlob(path: string): Promise<ArrayBufferLike>;\n\n\t/**\n\t * Determines if there is an object contained at the given path.\n\t */\n\tcontains(path: string): Promise<boolean>;\n\n\t/**\n\t * Lists the blobs that exist at a specific path.\n\t */\n\tlist(path: string): Promise<string[]>;\n}\n\n/**\n * Storage services to read the objects at a given path using the given delta connection.\n * @public\n */\nexport interface IChannelServices {\n\tdeltaConnection: IDeltaConnection;\n\n\tobjectStorage: IChannelStorageService;\n}\n\n/**\n * Definitions of a channel factory.\n *\n * @remarks\n *\n * The runtime must be able to produce \"channels\" of the correct in-memory object type for the collaborative session.\n * Here \"channels\" are typically distributed data structures (DDSs).\n *\n * The runtime will consult with a registry of such factories during\n * {@link https://fluidframework.com/docs/build/containers/ | Container} load and when receiving \"attach\" operations\n * (ops), which indicate a new instance of a channel being introduced to the collaboration session, to produce the\n * appropriate in-memory object.\n *\n * Factories follow a common model but enable custom behavior.\n *\n * @example\n *\n * If a collaboration includes a {@link https://fluidframework.com/docs/data-structures/map/ | SharedMap},\n * the collaborating clients will need to have access to a factory that can produce the `SharedMap` object.\n * @public\n */\nexport interface IChannelFactory {\n\t/**\n\t * String representing the type of the factory.\n\t */\n\treadonly type: string;\n\n\t/**\n\t * Attributes of the channel.\n\t */\n\treadonly attributes: IChannelAttributes;\n\n\t/**\n\t * Loads the given channel. This call is only ever invoked internally as the only thing\n\t * that is ever directly loaded is the document itself. Load will then only be called on documents that\n\t * were created and added to a channel.\n\t * @param runtime - Data store runtime containing state/info/helper methods about the data store.\n\t * @param id - ID of the channel.\n\t * @param services - Services to read objects at a given path using the delta connection.\n\t * @param channelAttributes - The attributes for the the channel to be loaded.\n\t * @returns The loaded object\n\t *\n\t * @privateRemarks\n\t * Thought: should the storage object include the version information and limit access to just files\n\t * for the given object? The latter seems good in general. But both are probably good things. We then just\n\t * need a way to allow the document to provide later storage for the object.\n\t */\n\tload(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid: string,\n\t\tservices: IChannelServices,\n\t\tchannelAttributes: Readonly<IChannelAttributes>,\n\t): Promise<IChannel>;\n\n\t/**\n\t * Creates a local version of the channel.\n\t * Calling attach on the object later will insert it into the object stream.\n\t * @param runtime - The runtime the new object will be associated with\n\t * @param id - The unique ID of the new object\n\t * @returns The newly created object.\n\t *\n\t * @privateRemarks\n\t * NOTE here - When we attach we need to submit all the pending ops prior to actually doing the attach\n\t * for consistency.\n\t */\n\tcreate(runtime: IFluidDataStoreRuntime, id: string): IChannel;\n}\n"]}
@@ -2,12 +2,16 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IDisposable, IEvent, IEventProvider, ITelemetryLogger } from "@fluidframework/common-definitions";
6
- import { IFluidHandleContext, IFluidRouter, IFluidHandle } from "@fluidframework/core-interfaces";
5
+ import { IEvent, IEventProvider, ITelemetryLogger, IDisposable, IFluidHandleContext, IFluidHandle, FluidObject } from "@fluidframework/core-interfaces";
7
6
  import { IAudience, IDeltaManager, AttachState, ILoaderOptions } from "@fluidframework/container-definitions";
8
7
  import { IDocumentMessage, IQuorumClients, ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
9
- import { IInboundSignalMessage, IProvideFluidDataStoreRegistry } from "@fluidframework/runtime-definitions";
10
- import { IChannel } from ".";
8
+ import { IInboundSignalMessage } from "@fluidframework/runtime-definitions";
9
+ import { IIdCompressor } from "@fluidframework/id-compressor";
10
+ import { IChannel } from "./channel";
11
+ /**
12
+ * Events emitted by {@link IFluidDataStoreRuntime}.
13
+ * @public
14
+ */
11
15
  export interface IFluidDataStoreRuntimeEvents extends IEvent {
12
16
  (event: "disconnected" | "dispose" | "attaching" | "attached", listener: () => void): any;
13
17
  (event: "op", listener: (message: ISequencedDocumentMessage) => void): any;
@@ -16,8 +20,9 @@ export interface IFluidDataStoreRuntimeEvents extends IEvent {
16
20
  }
17
21
  /**
18
22
  * Represents the runtime for the data store. Contains helper functions/state of the data store.
23
+ * @public
19
24
  */
20
- export interface IFluidDataStoreRuntime extends IFluidRouter, IEventProvider<IFluidDataStoreRuntimeEvents>, IDisposable, Partial<IProvideFluidDataStoreRegistry> {
25
+ export interface IFluidDataStoreRuntime extends IEventProvider<IFluidDataStoreRuntimeEvents>, IDisposable {
21
26
  readonly id: string;
22
27
  readonly IFluidHandleContext: IFluidHandleContext;
23
28
  readonly rootRoutingContext: IFluidHandleContext;
@@ -32,10 +37,20 @@ export interface IFluidDataStoreRuntime extends IFluidRouter, IEventProvider<IFl
32
37
  * Indicates the attachment state of the data store to a host service.
33
38
  */
34
39
  readonly attachState: AttachState;
40
+ readonly idCompressor?: IIdCompressor;
35
41
  /**
36
42
  * Returns the channel with the given id
37
43
  */
38
44
  getChannel(id: string): Promise<IChannel>;
45
+ /**
46
+ * Invokes the given callback and expects that no ops are submitted
47
+ * until execution finishes. If an op is submitted, an error will be raised.
48
+ *
49
+ * Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`
50
+ *
51
+ * @param callback - the callback to be invoked
52
+ */
53
+ ensureNoDataModelChanges<T>(callback: () => T): T;
39
54
  /**
40
55
  * Creates a new channel of the given type.
41
56
  * @param id - ID of the channel to be created. A unique ID will be generated if left undefined.
@@ -51,13 +66,14 @@ export interface IFluidDataStoreRuntime extends IFluidRouter, IEventProvider<IFl
51
66
  * Api to upload a blob of data.
52
67
  * @param blob - blob to be uploaded.
53
68
  */
54
- uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;
69
+ uploadBlob(blob: ArrayBufferLike, signal?: AbortSignal): Promise<IFluidHandle<ArrayBufferLike>>;
55
70
  /**
56
71
  * Submits the signal to be sent to other clients.
57
72
  * @param type - Type of the signal.
58
73
  * @param content - Content of the signal.
74
+ * @param targetClientId - When specified, the signal is only sent to the provided client id.
59
75
  */
60
- submitSignal(type: string, content: any): void;
76
+ submitSignal(type: string, content: any, targetClientId?: string): void;
61
77
  /**
62
78
  * Returns the current quorum.
63
79
  */
@@ -70,5 +86,10 @@ export interface IFluidDataStoreRuntime extends IFluidRouter, IEventProvider<IFl
70
86
  * Resolves when a local data store is attached.
71
87
  */
72
88
  waitAttached(): Promise<void>;
89
+ /**
90
+ * Exposes a handle to the root object / entryPoint of the data store. Use this as the primary way of interacting
91
+ * with it.
92
+ */
93
+ readonly entryPoint: IFluidHandle<FluidObject>;
73
94
  }
74
95
  //# sourceMappingURL=dataStoreRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dataStoreRuntime.d.ts","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAA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,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAElC,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC;IAEtC;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C;;;;;;;OAOG;IACH,wBAAwB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAElD;;;;OAIG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE9D;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAGrC;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC;IAEhG;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAExE;;OAEG;IACH,SAAS,IAAI,cAAc,CAAC;IAE5B;;OAEG;IACH,WAAW,IAAI,SAAS,CAAC;IAEzB;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"dataStoreRuntime.js","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, IEvent, IEventProvider, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IFluidHandleContext,\n IFluidRouter,\n IFluidHandle,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IAudience,\n IDeltaManager,\n AttachState,\n ILoaderOptions,\n} from \"@fluidframework/container-definitions\";\nimport {\n IDocumentMessage,\n IQuorumClients,\n ISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { IInboundSignalMessage, IProvideFluidDataStoreRegistry } from \"@fluidframework/runtime-definitions\";\nimport { IChannel } from \".\";\n\nexport interface IFluidDataStoreRuntimeEvents extends IEvent {\n (\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n event: \"disconnected\" | \"dispose\" | \"attaching\" | \"attached\",\n listener: () => void,\n );\n (event: \"op\", listener: (message: ISequencedDocumentMessage) => void);\n (event: \"signal\", listener: (message: IInboundSignalMessage, local: boolean) => void);\n (event: \"connected\", listener: (clientId: string) => void);\n}\n\n/**\n * Represents the runtime for the data store. Contains helper functions/state of the data store.\n */\nexport interface IFluidDataStoreRuntime extends\n IFluidRouter,\n IEventProvider<IFluidDataStoreRuntimeEvents>,\n IDisposable,\n Partial<IProvideFluidDataStoreRegistry> {\n\n readonly id: string;\n\n readonly IFluidHandleContext: IFluidHandleContext;\n\n readonly rootRoutingContext: IFluidHandleContext;\n readonly channelsRoutingContext: IFluidHandleContext;\n readonly objectsRoutingContext: IFluidHandleContext;\n\n readonly options: ILoaderOptions;\n\n readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;\n\n readonly clientId: string | undefined;\n\n readonly connected: boolean;\n\n readonly logger: ITelemetryLogger;\n\n /**\n * Indicates the attachment state of the data store to a host service.\n */\n readonly attachState: AttachState;\n\n /**\n * Returns the channel with the given id\n */\n getChannel(id: string): Promise<IChannel>;\n\n /**\n * Creates a new channel of the given type.\n * @param id - ID of the channel to be created. A unique ID will be generated if left undefined.\n * @param type - Type of the channel.\n */\n createChannel(id: string | undefined, type: string): IChannel;\n\n /**\n * Bind the channel with the data store runtime. If the runtime\n * is attached then we attach the channel to make it live.\n */\n bindChannel(channel: IChannel): void;\n\n // Blob related calls\n /**\n * Api to upload a blob of data.\n * @param blob - blob to be uploaded.\n */\n uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;\n\n /**\n * Submits the signal to be sent to other clients.\n * @param type - Type of the signal.\n * @param content - Content of the signal.\n */\n submitSignal(type: string, content: any): void;\n\n /**\n * Returns the current quorum.\n */\n getQuorum(): IQuorumClients;\n\n /**\n * Returns the current audience.\n */\n getAudience(): IAudience;\n\n /**\n * Resolves when a local data store is attached.\n */\n waitAttached(): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"dataStoreRuntime.js","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIEvent,\n\tIEventProvider,\n\tITelemetryLogger,\n\tIDisposable,\n\tIFluidHandleContext,\n\tIFluidHandle,\n\tFluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tIAudience,\n\tIDeltaManager,\n\tAttachState,\n\tILoaderOptions,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIDocumentMessage,\n\tIQuorumClients,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { IInboundSignalMessage } from \"@fluidframework/runtime-definitions\";\nimport { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { IChannel } from \"./channel\";\n\n/**\n * Events emitted by {@link IFluidDataStoreRuntime}.\n * @public\n */\nexport interface IFluidDataStoreRuntimeEvents extends IEvent {\n\t(event: \"disconnected\" | \"dispose\" | \"attaching\" | \"attached\", listener: () => void);\n\t(event: \"op\", listener: (message: ISequencedDocumentMessage) => void);\n\t(event: \"signal\", listener: (message: IInboundSignalMessage, local: boolean) => void);\n\t(event: \"connected\", listener: (clientId: string) => void);\n}\n\n/**\n * Represents the runtime for the data store. Contains helper functions/state of the data store.\n * @public\n */\nexport interface IFluidDataStoreRuntime\n\textends IEventProvider<IFluidDataStoreRuntimeEvents>,\n\t\tIDisposable {\n\treadonly id: string;\n\n\treadonly IFluidHandleContext: IFluidHandleContext;\n\n\treadonly rootRoutingContext: IFluidHandleContext;\n\treadonly channelsRoutingContext: IFluidHandleContext;\n\treadonly objectsRoutingContext: IFluidHandleContext;\n\n\treadonly options: ILoaderOptions;\n\n\treadonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;\n\n\treadonly clientId: string | undefined;\n\n\treadonly connected: boolean;\n\n\treadonly logger: ITelemetryLogger;\n\n\t/**\n\t * Indicates the attachment state of the data store to a host service.\n\t */\n\treadonly attachState: AttachState;\n\n\treadonly idCompressor?: IIdCompressor;\n\n\t/**\n\t * Returns the channel with the given id\n\t */\n\tgetChannel(id: string): Promise<IChannel>;\n\n\t/**\n\t * Invokes the given callback and expects that no ops are submitted\n\t * until execution finishes. If an op is submitted, an error will be raised.\n\t *\n\t * Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`\n\t *\n\t * @param callback - the callback to be invoked\n\t */\n\tensureNoDataModelChanges<T>(callback: () => T): T;\n\n\t/**\n\t * Creates a new channel of the given type.\n\t * @param id - ID of the channel to be created. A unique ID will be generated if left undefined.\n\t * @param type - Type of the channel.\n\t */\n\tcreateChannel(id: string | undefined, type: string): IChannel;\n\n\t/**\n\t * Bind the channel with the data store runtime. If the runtime\n\t * is attached then we attach the channel to make it live.\n\t */\n\tbindChannel(channel: IChannel): void;\n\n\t// Blob related calls\n\t/**\n\t * Api to upload a blob of data.\n\t * @param blob - blob to be uploaded.\n\t */\n\tuploadBlob(blob: ArrayBufferLike, signal?: AbortSignal): Promise<IFluidHandle<ArrayBufferLike>>;\n\n\t/**\n\t * Submits the signal to be sent to other clients.\n\t * @param type - Type of the signal.\n\t * @param content - Content of the signal.\n\t * @param targetClientId - When specified, the signal is only sent to the provided client id.\n\t */\n\tsubmitSignal(type: string, content: any, targetClientId?: string): void;\n\n\t/**\n\t * Returns the current quorum.\n\t */\n\tgetQuorum(): IQuorumClients;\n\n\t/**\n\t * Returns the current audience.\n\t */\n\tgetAudience(): IAudience;\n\n\t/**\n\t * Resolves when a local data store is attached.\n\t */\n\twaitAttached(): Promise<void>;\n\n\t/**\n\t * Exposes a handle to the root object / entryPoint of the data store. Use this as the primary way of interacting\n\t * with it.\n\t */\n\treadonly entryPoint: IFluidHandle<FluidObject>;\n}\n"]}
@@ -0,0 +1,480 @@
1
+ /**
2
+ * This library defines the interfaces required to implement and/or communicate
3
+ * with a data store.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ import { AttachState } from '@fluidframework/container-definitions';
9
+ import { FluidObject } from '@fluidframework/core-interfaces';
10
+ import { IAudience } from '@fluidframework/container-definitions';
11
+ import { IDeltaManager } from '@fluidframework/container-definitions';
12
+ import { IDisposable } from '@fluidframework/core-interfaces';
13
+ import { IDocumentMessage } from '@fluidframework/protocol-definitions';
14
+ import { IEvent } from '@fluidframework/core-interfaces';
15
+ import { IEventProvider } from '@fluidframework/core-interfaces';
16
+ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-definitions';
17
+ import { IFluidHandle } from '@fluidframework/core-interfaces';
18
+ import { IFluidHandleContext } from '@fluidframework/core-interfaces';
19
+ import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
+ import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
21
+ import { IIdCompressor } from '@fluidframework/id-compressor';
22
+ import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
23
+ import { ILoaderOptions } from '@fluidframework/container-definitions';
24
+ import { IQuorumClients } from '@fluidframework/protocol-definitions';
25
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
26
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
27
+ import { ITelemetryContext } from '@fluidframework/runtime-definitions';
28
+ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
29
+
30
+ /**
31
+ * @public
32
+ */
33
+ export declare interface IChannel extends IFluidLoadable {
34
+ /**
35
+ * A readonly identifier for the channel
36
+ */
37
+ readonly id: string;
38
+ readonly attributes: IChannelAttributes;
39
+ /**
40
+ * Generates summary of the channel synchronously. It is called when an `attach message`
41
+ * for a local channel is generated. In other words, when the channel is being attached
42
+ * to make it visible to other clients.
43
+ *
44
+ * @remarks
45
+ *
46
+ * Note: Since the Attach Summary is generated for local channels when making them visible to
47
+ * remote clients, they don't have any previous summaries to compare against. For this reason,
48
+ * the attach summary cannot contain summary handles (paths to sub-trees or blobs).
49
+ * It can, however, contain {@link @fluidframework/protocol-definitions#ISummaryAttachment}
50
+ * (handles to blobs uploaded async via the blob manager).
51
+ *
52
+ * @param fullTree - A flag indicating whether the attempt should generate a full
53
+ * summary tree without any handles for unchanged subtrees.
54
+ *
55
+ * Default: `false`
56
+ *
57
+ * @param trackState - An optimization for tracking state of objects across summaries. If the state
58
+ * of an object did not change since last successful summary, an
59
+ * {@link @fluidframework/protocol-definitions#ISummaryHandle} can be used
60
+ * instead of re-summarizing it. If this is `false`, the expectation is that you should never
61
+ * send an `ISummaryHandle`, since you are not expected to track state.
62
+ *
63
+ * Note: The goal is to remove the trackState and automatically decided whether the
64
+ * handles will be used or not: {@link https://github.com/microsoft/FluidFramework/issues/10455}
65
+ *
66
+ * Default: `false`
67
+ *
68
+ * @param telemetryContext - See {@link @fluidframework/runtime-definitions#ITelemetryContext}.
69
+ *
70
+ * @returns A summary capturing the current state of the channel.
71
+ */
72
+ getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
73
+ /**
74
+ * Generates summary of the channel asynchronously.
75
+ * This should not be called where the channel can be modified while summarization is in progress.
76
+ *
77
+ * @param fullTree - flag indicating whether the attempt should generate a full
78
+ * summary tree without any handles for unchanged subtrees. It should only be set to true when generating
79
+ * a summary from the entire container.
80
+ *
81
+ * Default: `false`
82
+ *
83
+ * @param trackState - An optimization for tracking state of objects across summaries. If the state
84
+ * of an object did not change since last successful summary, an
85
+ * {@link @fluidframework/protocol-definitions#ISummaryHandle} can be used
86
+ * instead of re-summarizing it. If this is `false`, the expectation is that you should never
87
+ * send an `ISummaryHandle`, since you are not expected to track state.
88
+ *
89
+ * Default: `false`
90
+ *
91
+ * Note: The goal is to remove the trackState and automatically decided whether the
92
+ * handles will be used or not: {@link https://github.com/microsoft/FluidFramework/issues/10455}
93
+ *
94
+ * @param telemetryContext - See {@link @fluidframework/runtime-definitions#ITelemetryContext}.
95
+ *
96
+ * @returns A summary capturing the current state of the channel.
97
+ */
98
+ summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): Promise<ISummaryTreeWithStats>;
99
+ /**
100
+ * Checks if the channel is attached to storage.
101
+ * @returns True iff the channel is attached.
102
+ */
103
+ isAttached(): boolean;
104
+ /**
105
+ * Enables the channel to send and receive ops.
106
+ * @param services - The services to connect to.
107
+ */
108
+ connect(services: IChannelServices): void;
109
+ /**
110
+ * Returns the GC data for this channel. It contains a list of GC nodes that contains references to
111
+ * other GC nodes.
112
+ * @param fullGC - true to bypass optimizations and force full generation of GC data.
113
+ */
114
+ getGCData(fullGC?: boolean): IGarbageCollectionData;
115
+ }
116
+
117
+ /**
118
+ * Represents the attributes of a channel/DDS.
119
+ * @public
120
+ */
121
+ export declare interface IChannelAttributes {
122
+ /**
123
+ * Type name of the DDS for factory look up with ISharedObjectRegistry
124
+ */
125
+ readonly type: string;
126
+ /**
127
+ * Format version of the snapshot
128
+ * Currently, only use to display a debug message if the version is incompatible
129
+ */
130
+ readonly snapshotFormatVersion: string;
131
+ /**
132
+ * The package version of the code of the DDS, for debug only
133
+ */
134
+ readonly packageVersion?: string;
135
+ }
136
+
137
+ /**
138
+ * Definitions of a channel factory.
139
+ *
140
+ * @remarks
141
+ *
142
+ * The runtime must be able to produce "channels" of the correct in-memory object type for the collaborative session.
143
+ * Here "channels" are typically distributed data structures (DDSs).
144
+ *
145
+ * The runtime will consult with a registry of such factories during
146
+ * {@link https://fluidframework.com/docs/build/containers/ | Container} load and when receiving "attach" operations
147
+ * (ops), which indicate a new instance of a channel being introduced to the collaboration session, to produce the
148
+ * appropriate in-memory object.
149
+ *
150
+ * Factories follow a common model but enable custom behavior.
151
+ *
152
+ * @example
153
+ *
154
+ * If a collaboration includes a {@link https://fluidframework.com/docs/data-structures/map/ | SharedMap},
155
+ * the collaborating clients will need to have access to a factory that can produce the `SharedMap` object.
156
+ * @public
157
+ */
158
+ export declare interface IChannelFactory {
159
+ /**
160
+ * String representing the type of the factory.
161
+ */
162
+ readonly type: string;
163
+ /**
164
+ * Attributes of the channel.
165
+ */
166
+ readonly attributes: IChannelAttributes;
167
+ /**
168
+ * Loads the given channel. This call is only ever invoked internally as the only thing
169
+ * that is ever directly loaded is the document itself. Load will then only be called on documents that
170
+ * were created and added to a channel.
171
+ * @param runtime - Data store runtime containing state/info/helper methods about the data store.
172
+ * @param id - ID of the channel.
173
+ * @param services - Services to read objects at a given path using the delta connection.
174
+ * @param channelAttributes - The attributes for the the channel to be loaded.
175
+ * @returns The loaded object
176
+ *
177
+ * @privateRemarks
178
+ * Thought: should the storage object include the version information and limit access to just files
179
+ * for the given object? The latter seems good in general. But both are probably good things. We then just
180
+ * need a way to allow the document to provide later storage for the object.
181
+ */
182
+ load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, channelAttributes: Readonly<IChannelAttributes>): Promise<IChannel>;
183
+ /**
184
+ * Creates a local version of the channel.
185
+ * Calling attach on the object later will insert it into the object stream.
186
+ * @param runtime - The runtime the new object will be associated with
187
+ * @param id - The unique ID of the new object
188
+ * @returns The newly created object.
189
+ *
190
+ * @privateRemarks
191
+ * NOTE here - When we attach we need to submit all the pending ops prior to actually doing the attach
192
+ * for consistency.
193
+ */
194
+ create(runtime: IFluidDataStoreRuntime, id: string): IChannel;
195
+ }
196
+
197
+ /**
198
+ * Storage services to read the objects at a given path using the given delta connection.
199
+ * @public
200
+ */
201
+ export declare interface IChannelServices {
202
+ deltaConnection: IDeltaConnection;
203
+ objectStorage: IChannelStorageService;
204
+ }
205
+
206
+ /**
207
+ * Storage services to read the objects at a given path.
208
+ * @public
209
+ */
210
+ export declare interface IChannelStorageService {
211
+ /**
212
+ * Reads the object contained at the given path. Returns a buffer representation for the object.
213
+ */
214
+ readBlob(path: string): Promise<ArrayBufferLike>;
215
+ /**
216
+ * Determines if there is an object contained at the given path.
217
+ */
218
+ contains(path: string): Promise<boolean>;
219
+ /**
220
+ * Lists the blobs that exist at a specific path.
221
+ */
222
+ list(path: string): Promise<string[]>;
223
+ }
224
+
225
+ /**
226
+ * Interface to represent a connection to a delta notification stream.
227
+ * @public
228
+ */
229
+ export declare interface IDeltaConnection {
230
+ connected: boolean;
231
+ /**
232
+ * Send new messages to the server.
233
+ * @param messageContent - The content of the message to be sent.
234
+ * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime
235
+ * and not sent to the server. It will be provided back when this message is acknowledged by the server. It will
236
+ * also be provided back when asked to resubmit the message.
237
+ */
238
+ submit(messageContent: any, localOpMetadata: unknown): void;
239
+ /**
240
+ * Attaches a message handler to the delta connection
241
+ */
242
+ attach(handler: IDeltaHandler): void;
243
+ /**
244
+ * Indicates that the channel is dirty and needs to be part of the summary. It is called by a SharedSummaryBlock
245
+ * that needs to be part of the summary but does not generate ops.
246
+ */
247
+ dirty(): void;
248
+ /**
249
+ * Called when a new outbound reference is added to another node. This is used by garbage collection to identify
250
+ * all references added in the system.
251
+ * @param srcHandle - The handle of the node that added the reference.
252
+ * @param outboundHandle - The handle of the outbound node that is referenced.
253
+ */
254
+ addedGCOutboundReference?(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;
255
+ }
256
+
257
+ /**
258
+ * Handler provided by shared data structure to process requests from the runtime.
259
+ * @public
260
+ */
261
+ export declare interface IDeltaHandler {
262
+ /**
263
+ * Processes the op.
264
+ * @param message - The message to process
265
+ * @param local - Whether the message originated from the local client
266
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
267
+ * For messages from a remote client, this will be undefined.
268
+ */
269
+ process: (message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) => void;
270
+ /**
271
+ * State change events to indicate changes to the delta connection
272
+ * @param connected - true if connected, false otherwise
273
+ */
274
+ setConnectionState(connected: boolean): void;
275
+ /**
276
+ * Called when the runtime asks the client to resubmit an op. This may be because the Container reconnected and
277
+ * this op was not acked.
278
+ * The client can choose to resubmit the same message, submit different / multiple messages or not submit anything
279
+ * at all.
280
+ * @param message - The original message that was submitted.
281
+ * @param localOpMetadata - The local metadata associated with the original message.
282
+ */
283
+ reSubmit(message: any, localOpMetadata: unknown): void;
284
+ /**
285
+ * Apply changes from an op. Used when rehydrating an attached container
286
+ * with pending changes. This prepares the SharedObject for seeing an ACK
287
+ * for the op or resubmitting the op upon reconnection.
288
+ * @param message - Contents of a stashed op.
289
+ * @returns localMetadata of the op, to be passed to process() or resubmit()
290
+ * when the op is ACKed or resubmitted, respectively
291
+ */
292
+ applyStashedOp(message: any): unknown;
293
+ /**
294
+ * Revert a local op.
295
+ * @param message - The original message that was submitted.
296
+ * @param localOpMetadata - The local metadata associated with the original message.
297
+ */
298
+ rollback?(message: any, localOpMetadata: unknown): void;
299
+ }
300
+
301
+ /**
302
+ * Represents the runtime for the data store. Contains helper functions/state of the data store.
303
+ * @public
304
+ */
305
+ export declare interface IFluidDataStoreRuntime extends IEventProvider<IFluidDataStoreRuntimeEvents>, IDisposable {
306
+ readonly id: string;
307
+ readonly IFluidHandleContext: IFluidHandleContext;
308
+ readonly rootRoutingContext: IFluidHandleContext;
309
+ readonly channelsRoutingContext: IFluidHandleContext;
310
+ readonly objectsRoutingContext: IFluidHandleContext;
311
+ readonly options: ILoaderOptions;
312
+ readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
313
+ readonly clientId: string | undefined;
314
+ readonly connected: boolean;
315
+ readonly logger: ITelemetryLogger;
316
+ /**
317
+ * Indicates the attachment state of the data store to a host service.
318
+ */
319
+ readonly attachState: AttachState;
320
+ readonly idCompressor?: IIdCompressor;
321
+ /**
322
+ * Returns the channel with the given id
323
+ */
324
+ getChannel(id: string): Promise<IChannel>;
325
+ /**
326
+ * Invokes the given callback and expects that no ops are submitted
327
+ * until execution finishes. If an op is submitted, an error will be raised.
328
+ *
329
+ * Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`
330
+ *
331
+ * @param callback - the callback to be invoked
332
+ */
333
+ ensureNoDataModelChanges<T>(callback: () => T): T;
334
+ /**
335
+ * Creates a new channel of the given type.
336
+ * @param id - ID of the channel to be created. A unique ID will be generated if left undefined.
337
+ * @param type - Type of the channel.
338
+ */
339
+ createChannel(id: string | undefined, type: string): IChannel;
340
+ /**
341
+ * Bind the channel with the data store runtime. If the runtime
342
+ * is attached then we attach the channel to make it live.
343
+ */
344
+ bindChannel(channel: IChannel): void;
345
+ /**
346
+ * Api to upload a blob of data.
347
+ * @param blob - blob to be uploaded.
348
+ */
349
+ uploadBlob(blob: ArrayBufferLike, signal?: AbortSignal): Promise<IFluidHandle<ArrayBufferLike>>;
350
+ /**
351
+ * Submits the signal to be sent to other clients.
352
+ * @param type - Type of the signal.
353
+ * @param content - Content of the signal.
354
+ * @param targetClientId - When specified, the signal is only sent to the provided client id.
355
+ */
356
+ submitSignal(type: string, content: any, targetClientId?: string): void;
357
+ /**
358
+ * Returns the current quorum.
359
+ */
360
+ getQuorum(): IQuorumClients;
361
+ /**
362
+ * Returns the current audience.
363
+ */
364
+ getAudience(): IAudience;
365
+ /**
366
+ * Resolves when a local data store is attached.
367
+ */
368
+ waitAttached(): Promise<void>;
369
+ /**
370
+ * Exposes a handle to the root object / entryPoint of the data store. Use this as the primary way of interacting
371
+ * with it.
372
+ */
373
+ readonly entryPoint: IFluidHandle<FluidObject>;
374
+ }
375
+
376
+ /**
377
+ * Events emitted by {@link IFluidDataStoreRuntime}.
378
+ * @public
379
+ */
380
+ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
381
+ (event: "disconnected" | "dispose" | "attaching" | "attached", listener: () => void): any;
382
+ (event: "op", listener: (message: ISequencedDocumentMessage) => void): any;
383
+ (event: "signal", listener: (message: IInboundSignalMessage, local: boolean) => void): any;
384
+ (event: "connected", listener: (clientId: string) => void): any;
385
+ }
386
+
387
+ /**
388
+ * @remarks
389
+ * This type is a kludge and not intended for general use.
390
+ *
391
+ * @privateRemarks
392
+ * Internal type testing for compatibility uses TypeOnly filter which cannot handle recursive "pure" types.
393
+ * This interface along with ArrayLike above avoids pure type recursion issues, but introduces a limitation on
394
+ * the ability of {@link Jsonable} to detect array-like types that are not handled naively ({@link JSON.stringify}).
395
+ * The TypeOnly filter is not useful for {@link JsonableTypeWith}; so, if type testing improves, this can be removed.
396
+ * @alpha
397
+ */
398
+ export declare interface Internal_InterfaceOfJsonableTypesWith<T> {
399
+ [index: string | number]: JsonableTypeWith<T>;
400
+ }
401
+
402
+ /**
403
+ * Used to constrain a type `T` to types that are serializable as JSON.
404
+ * Produces a compile-time error if `T` contains non-Jsonable members.
405
+ *
406
+ * @remarks
407
+ * Note that this does NOT prevent using of values with non-json compatible data,
408
+ * it only prevents using values with types that include non-json compatible data.
409
+ * This means that one can, for example, pass in a value typed with json compatible
410
+ * interface into this function,
411
+ * that could actually be a class with lots on non-json compatible fields and methods.
412
+ *
413
+ * Important: `T extends Jsonable<T>` is incorrect (does not even compile).
414
+ *
415
+ * The optional 'TReplaced' parameter may be used to permit additional leaf types to support
416
+ * situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).
417
+ *
418
+ * Note that `Jsonable<T>` does not protect against the following pitfalls when serializing with JSON.stringify():
419
+ *
420
+ * - `undefined` properties on objects are omitted (i.e., properties become undefined instead of equal to undefined).
421
+ *
422
+ * - When `undefined` appears as the root object or as an array element it is coerced to `null`.
423
+ *
424
+ * - Non-finite numbers (`NaN`, `+/-Infinity`) are also coerced to `null`.
425
+ *
426
+ * - prototypes and non-enumerable properties are lost.
427
+ *
428
+ * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.
429
+ *
430
+ * Also, `Jsonable<T>` does not prevent the construction of circular references.
431
+ *
432
+ * Using `Jsonable<unknown>` or `Jsonable<any>` is a type alias for
433
+ * {@link JsonableTypeWith}`<never>` and should not be used if precise type safety is desired.
434
+ *
435
+ * @example Typical usage
436
+ *
437
+ * ```typescript
438
+ * function foo<T>(value: Jsonable<T>) { ... }
439
+ * ```
440
+ * @alpha
441
+ */
442
+ export declare type Jsonable<T, TReplaced = never> = boolean extends (T extends never ? true : false) ? JsonableTypeWith<TReplaced> : unknown extends T ? JsonableTypeWith<TReplaced> : T extends undefined | null | boolean | number | string | TReplaced ? T : Extract<T, Function> extends never ? T extends object ? T extends (infer U)[] ? Jsonable<U, TReplaced>[] : {
443
+ [K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;
444
+ } : never : never;
445
+
446
+ /**
447
+ * Type constraint for types that are likely serializable as JSON or have a custom
448
+ * alternate type.
449
+ *
450
+ * @remarks
451
+ * Use `JsonableTypeWith<never>` for just JSON serializable types.
452
+ * See {@link Jsonable} for serialization pitfalls.
453
+ *
454
+ * @privateRemarks
455
+ * Perfer using `Jsonable<unknown>` over this type that is an implementation detail.
456
+ * @alpha
457
+ */
458
+ export declare type JsonableTypeWith<T> = undefined | null | boolean | number | string | T | Internal_InterfaceOfJsonableTypesWith<T> | ArrayLike<JsonableTypeWith<T>>;
459
+
460
+ /**
461
+ * Used to constrain a type 'T' to types that Fluid can intrinsically serialize. Produces a
462
+ * compile-time error if `T` contains non-serializable members.
463
+ *
464
+ * @remarks
465
+ * See Jsonable for caveats regarding serialization of `undefined`, non-finite numbers,
466
+ * and circular references.
467
+ *
468
+ * Important: `T extends Serializable<T>` is generally incorrect.
469
+ * (Any value of `T` extends the serializable subset of itself.)
470
+ *
471
+ * @example Typical usage
472
+ *
473
+ * ```typescript
474
+ * function serialize<T>(value: Serializable<T>) { ... }
475
+ * ```
476
+ * @alpha
477
+ */
478
+ export declare type Serializable<T> = Jsonable<T, IFluidHandle>;
479
+
480
+ export { }