@fluidframework/datastore-definitions 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419
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.
- package/.eslintrc.cjs +11 -0
- package/CHANGELOG.md +215 -0
- package/README.md +45 -7
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/datastore-definitions.api.md +156 -0
- package/dist/channel.d.ts +71 -16
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts +28 -7
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js.map +1 -1
- package/dist/datastore-definitions-alpha.d.ts +480 -0
- package/dist/datastore-definitions-beta.d.ts +395 -0
- package/dist/datastore-definitions-public.d.ts +395 -0
- package/dist/datastore-definitions-untrimmed.d.ts +480 -0
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +1 -1
- package/dist/jsonable.d.ts +46 -14
- package/dist/jsonable.d.ts.map +1 -1
- package/dist/jsonable.js.map +1 -1
- package/dist/serializable.d.ts +5 -4
- package/dist/serializable.d.ts.map +1 -1
- package/dist/serializable.js.map +1 -1
- package/dist/storage.d.ts +1 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/package.json +64 -42
- package/prettier.config.cjs +8 -0
- package/src/channel.ts +256 -200
- package/src/dataStoreRuntime.ts +117 -96
- package/src/index.ts +17 -10
- package/src/jsonable.ts +80 -23
- package/src/serializable.ts +5 -4
- package/src/storage.ts +14 -13
- package/tsconfig.json +10 -12
- package/.eslintrc.js +0 -13
package/src/dataStoreRuntime.ts
CHANGED
|
@@ -3,113 +3,134 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IDisposable, IEvent, IEventProvider, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
6
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
IEvent,
|
|
8
|
+
IEventProvider,
|
|
9
|
+
ITelemetryLogger,
|
|
10
|
+
IDisposable,
|
|
11
|
+
IFluidHandleContext,
|
|
12
|
+
IFluidHandle,
|
|
13
|
+
FluidObject,
|
|
11
14
|
} from "@fluidframework/core-interfaces";
|
|
12
15
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
IAudience,
|
|
17
|
+
IDeltaManager,
|
|
18
|
+
AttachState,
|
|
19
|
+
ILoaderOptions,
|
|
17
20
|
} from "@fluidframework/container-definitions";
|
|
18
21
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
IDocumentMessage,
|
|
23
|
+
IQuorumClients,
|
|
24
|
+
ISequencedDocumentMessage,
|
|
22
25
|
} from "@fluidframework/protocol-definitions";
|
|
23
|
-
import { IInboundSignalMessage
|
|
24
|
-
import {
|
|
26
|
+
import { IInboundSignalMessage } from "@fluidframework/runtime-definitions";
|
|
27
|
+
import { IIdCompressor } from "@fluidframework/id-compressor";
|
|
28
|
+
import { IChannel } from "./channel";
|
|
25
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Events emitted by {@link IFluidDataStoreRuntime}.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
26
34
|
export interface IFluidDataStoreRuntimeEvents extends IEvent {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
32
|
-
(event: "op", listener: (message: ISequencedDocumentMessage) => void);
|
|
33
|
-
(event: "signal", listener: (message: IInboundSignalMessage, local: boolean) => void);
|
|
34
|
-
(event: "connected", listener: (clientId: string) => void);
|
|
35
|
+
(event: "disconnected" | "dispose" | "attaching" | "attached", listener: () => void);
|
|
36
|
+
(event: "op", listener: (message: ISequencedDocumentMessage) => void);
|
|
37
|
+
(event: "signal", listener: (message: IInboundSignalMessage, local: boolean) => void);
|
|
38
|
+
(event: "connected", listener: (clientId: string) => void);
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
42
|
* Represents the runtime for the data store. Contains helper functions/state of the data store.
|
|
43
|
+
* @public
|
|
39
44
|
*/
|
|
40
|
-
export interface IFluidDataStoreRuntime
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
45
|
+
export interface IFluidDataStoreRuntime
|
|
46
|
+
extends IEventProvider<IFluidDataStoreRuntimeEvents>,
|
|
47
|
+
IDisposable {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
|
|
50
|
+
readonly IFluidHandleContext: IFluidHandleContext;
|
|
51
|
+
|
|
52
|
+
readonly rootRoutingContext: IFluidHandleContext;
|
|
53
|
+
readonly channelsRoutingContext: IFluidHandleContext;
|
|
54
|
+
readonly objectsRoutingContext: IFluidHandleContext;
|
|
55
|
+
|
|
56
|
+
readonly options: ILoaderOptions;
|
|
57
|
+
|
|
58
|
+
readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
|
|
59
|
+
|
|
60
|
+
readonly clientId: string | undefined;
|
|
61
|
+
|
|
62
|
+
readonly connected: boolean;
|
|
63
|
+
|
|
64
|
+
readonly logger: ITelemetryLogger;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Indicates the attachment state of the data store to a host service.
|
|
68
|
+
*/
|
|
69
|
+
readonly attachState: AttachState;
|
|
70
|
+
|
|
71
|
+
readonly idCompressor?: IIdCompressor;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Returns the channel with the given id
|
|
75
|
+
*/
|
|
76
|
+
getChannel(id: string): Promise<IChannel>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Invokes the given callback and expects that no ops are submitted
|
|
80
|
+
* until execution finishes. If an op is submitted, an error will be raised.
|
|
81
|
+
*
|
|
82
|
+
* Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`
|
|
83
|
+
*
|
|
84
|
+
* @param callback - the callback to be invoked
|
|
85
|
+
*/
|
|
86
|
+
ensureNoDataModelChanges<T>(callback: () => T): T;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Creates a new channel of the given type.
|
|
90
|
+
* @param id - ID of the channel to be created. A unique ID will be generated if left undefined.
|
|
91
|
+
* @param type - Type of the channel.
|
|
92
|
+
*/
|
|
93
|
+
createChannel(id: string | undefined, type: string): IChannel;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Bind the channel with the data store runtime. If the runtime
|
|
97
|
+
* is attached then we attach the channel to make it live.
|
|
98
|
+
*/
|
|
99
|
+
bindChannel(channel: IChannel): void;
|
|
100
|
+
|
|
101
|
+
// Blob related calls
|
|
102
|
+
/**
|
|
103
|
+
* Api to upload a blob of data.
|
|
104
|
+
* @param blob - blob to be uploaded.
|
|
105
|
+
*/
|
|
106
|
+
uploadBlob(blob: ArrayBufferLike, signal?: AbortSignal): Promise<IFluidHandle<ArrayBufferLike>>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Submits the signal to be sent to other clients.
|
|
110
|
+
* @param type - Type of the signal.
|
|
111
|
+
* @param content - Content of the signal.
|
|
112
|
+
* @param targetClientId - When specified, the signal is only sent to the provided client id.
|
|
113
|
+
*/
|
|
114
|
+
submitSignal(type: string, content: any, targetClientId?: string): void;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Returns the current quorum.
|
|
118
|
+
*/
|
|
119
|
+
getQuorum(): IQuorumClients;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Returns the current audience.
|
|
123
|
+
*/
|
|
124
|
+
getAudience(): IAudience;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Resolves when a local data store is attached.
|
|
128
|
+
*/
|
|
129
|
+
waitAttached(): Promise<void>;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Exposes a handle to the root object / entryPoint of the data store. Use this as the primary way of interacting
|
|
133
|
+
* with it.
|
|
134
|
+
*/
|
|
135
|
+
readonly entryPoint: IFluidHandle<FluidObject>;
|
|
115
136
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,14 +4,21 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* This
|
|
8
|
-
* with a data store.
|
|
9
|
-
*
|
|
10
|
-
* @packageDocumentation
|
|
11
|
-
*/
|
|
7
|
+
* This library defines the interfaces required to implement and/or communicate
|
|
8
|
+
* with a data store.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
export {
|
|
14
|
+
IChannel,
|
|
15
|
+
IChannelFactory,
|
|
16
|
+
IChannelServices,
|
|
17
|
+
IChannelStorageService,
|
|
18
|
+
IDeltaConnection,
|
|
19
|
+
IDeltaHandler,
|
|
20
|
+
} from "./channel";
|
|
21
|
+
export { IFluidDataStoreRuntime, IFluidDataStoreRuntimeEvents } from "./dataStoreRuntime";
|
|
22
|
+
export type { Jsonable, JsonableTypeWith, Internal_InterfaceOfJsonableTypesWith } from "./jsonable";
|
|
23
|
+
export { Serializable } from "./serializable";
|
|
24
|
+
export { IChannelAttributes } from "./storage";
|
package/src/jsonable.ts
CHANGED
|
@@ -3,6 +3,43 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Type constraint for types that are likely serializable as JSON or have a custom
|
|
8
|
+
* alternate type.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use `JsonableTypeWith<never>` for just JSON serializable types.
|
|
12
|
+
* See {@link Jsonable} for serialization pitfalls.
|
|
13
|
+
*
|
|
14
|
+
* @privateRemarks
|
|
15
|
+
* Perfer using `Jsonable<unknown>` over this type that is an implementation detail.
|
|
16
|
+
* @alpha
|
|
17
|
+
*/
|
|
18
|
+
export type JsonableTypeWith<T> =
|
|
19
|
+
| undefined
|
|
20
|
+
| null
|
|
21
|
+
| boolean
|
|
22
|
+
| number
|
|
23
|
+
| string
|
|
24
|
+
| T
|
|
25
|
+
| Internal_InterfaceOfJsonableTypesWith<T>
|
|
26
|
+
| ArrayLike<JsonableTypeWith<T>>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @remarks
|
|
30
|
+
* This type is a kludge and not intended for general use.
|
|
31
|
+
*
|
|
32
|
+
* @privateRemarks
|
|
33
|
+
* Internal type testing for compatibility uses TypeOnly filter which cannot handle recursive "pure" types.
|
|
34
|
+
* This interface along with ArrayLike above avoids pure type recursion issues, but introduces a limitation on
|
|
35
|
+
* the ability of {@link Jsonable} to detect array-like types that are not handled naively ({@link JSON.stringify}).
|
|
36
|
+
* The TypeOnly filter is not useful for {@link JsonableTypeWith}; so, if type testing improves, this can be removed.
|
|
37
|
+
* @alpha
|
|
38
|
+
*/
|
|
39
|
+
export interface Internal_InterfaceOfJsonableTypesWith<T> {
|
|
40
|
+
[index: string | number]: JsonableTypeWith<T>;
|
|
41
|
+
}
|
|
42
|
+
|
|
6
43
|
/**
|
|
7
44
|
* Used to constrain a type `T` to types that are serializable as JSON.
|
|
8
45
|
* Produces a compile-time error if `T` contains non-Jsonable members.
|
|
@@ -10,42 +47,62 @@
|
|
|
10
47
|
* @remarks
|
|
11
48
|
* Note that this does NOT prevent using of values with non-json compatible data,
|
|
12
49
|
* it only prevents using values with types that include non-json compatible data.
|
|
13
|
-
* This means that one can, for example, pass
|
|
50
|
+
* This means that one can, for example, pass in a value typed with json compatible
|
|
14
51
|
* interface into this function,
|
|
15
52
|
* that could actually be a class with lots on non-json compatible fields and methods.
|
|
16
53
|
*
|
|
17
54
|
* Important: `T extends Jsonable<T>` is incorrect (does not even compile).
|
|
18
|
-
* `T extends Jsonable` is also incorrect since `Jsonable` is just `any` and thus applies no constraint at all.
|
|
19
55
|
*
|
|
20
56
|
* The optional 'TReplaced' parameter may be used to permit additional leaf types to support
|
|
21
57
|
* situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).
|
|
22
58
|
*
|
|
23
59
|
* Note that `Jsonable<T>` does not protect against the following pitfalls when serializing with JSON.stringify():
|
|
24
60
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
61
|
+
* - `undefined` properties on objects are omitted (i.e., properties become undefined instead of equal to undefined).
|
|
62
|
+
*
|
|
63
|
+
* - When `undefined` appears as the root object or as an array element it is coerced to `null`.
|
|
64
|
+
*
|
|
65
|
+
* - Non-finite numbers (`NaN`, `+/-Infinity`) are also coerced to `null`.
|
|
66
|
+
*
|
|
67
|
+
* - prototypes and non-enumerable properties are lost.
|
|
68
|
+
*
|
|
69
|
+
* - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.
|
|
29
70
|
*
|
|
30
71
|
* Also, `Jsonable<T>` does not prevent the construction of circular references.
|
|
31
72
|
*
|
|
32
|
-
* Using `Jsonable
|
|
33
|
-
* and should not be used if type safety is desired.
|
|
73
|
+
* Using `Jsonable<unknown>` or `Jsonable<any>` is a type alias for
|
|
74
|
+
* {@link JsonableTypeWith}`<never>` and should not be used if precise type safety is desired.
|
|
75
|
+
*
|
|
76
|
+
* @example Typical usage
|
|
34
77
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* ```ts
|
|
38
|
-
* function foo<T>(value: Jsonable<T>) { ... }
|
|
78
|
+
* ```typescript
|
|
79
|
+
* function foo<T>(value: Jsonable<T>) { ... }
|
|
39
80
|
* ```
|
|
81
|
+
* @alpha
|
|
40
82
|
*/
|
|
41
|
-
export type Jsonable<T
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
83
|
+
export type Jsonable<T, TReplaced = never> = /* test for 'any' */ boolean extends (
|
|
84
|
+
T extends never ? true : false
|
|
85
|
+
)
|
|
86
|
+
? /* 'any' => */ JsonableTypeWith<TReplaced>
|
|
87
|
+
: /* test for 'unknown' */ unknown extends T
|
|
88
|
+
? /* 'unknown' => */ JsonableTypeWith<TReplaced>
|
|
89
|
+
: /* test for Jsonable primitive types */ T extends
|
|
90
|
+
| undefined /* is not serialized */
|
|
91
|
+
| null
|
|
92
|
+
| boolean
|
|
93
|
+
| number
|
|
94
|
+
| string
|
|
95
|
+
| TReplaced
|
|
96
|
+
? /* primitive types => */ T
|
|
97
|
+
: // eslint-disable-next-line @typescript-eslint/ban-types
|
|
98
|
+
/* test for not a function */ Extract<T, Function> extends never
|
|
99
|
+
? /* not a function => => test for object */ T extends object
|
|
100
|
+
? /* object => test for array */ T extends (infer U)[] // prefer ArrayLike test to catch non-array array-like types
|
|
101
|
+
? /* array => */ Jsonable<U, TReplaced>[]
|
|
102
|
+
: /* property bag => */ {
|
|
103
|
+
[K in keyof T]: Extract<K, symbol> extends never
|
|
104
|
+
? Jsonable<T[K], TReplaced>
|
|
105
|
+
: never;
|
|
106
|
+
}
|
|
107
|
+
: /* not an object => */ never
|
|
108
|
+
: /* function => */ never;
|
package/src/serializable.ts
CHANGED
|
@@ -17,10 +17,11 @@ import { Jsonable } from "./jsonable";
|
|
|
17
17
|
* Important: `T extends Serializable<T>` is generally incorrect.
|
|
18
18
|
* (Any value of `T` extends the serializable subset of itself.)
|
|
19
19
|
*
|
|
20
|
-
* @example
|
|
21
|
-
*
|
|
20
|
+
* @example Typical usage
|
|
21
|
+
*
|
|
22
22
|
* ```typescript
|
|
23
|
-
*
|
|
23
|
+
* function serialize<T>(value: Serializable<T>) { ... }
|
|
24
24
|
* ```
|
|
25
|
+
* @alpha
|
|
25
26
|
*/
|
|
26
|
-
export type Serializable<T
|
|
27
|
+
export type Serializable<T> = Jsonable<T, IFluidHandle>;
|
package/src/storage.ts
CHANGED
|
@@ -5,21 +5,22 @@
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Represents the attributes of a channel/DDS.
|
|
8
|
+
* @public
|
|
8
9
|
*/
|
|
9
10
|
export interface IChannelAttributes {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Type name of the DDS for factory look up with ISharedObjectRegistry
|
|
13
|
+
*/
|
|
14
|
+
readonly type: string;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Format version of the snapshot
|
|
18
|
+
* Currently, only use to display a debug message if the version is incompatible
|
|
19
|
+
*/
|
|
20
|
+
readonly snapshotFormatVersion: string;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The package version of the code of the DDS, for debug only
|
|
24
|
+
*/
|
|
25
|
+
readonly packageVersion?: string;
|
|
25
26
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"src/**/*"
|
|
13
|
-
]
|
|
2
|
+
"extends": [
|
|
3
|
+
"../../../common/build/build-common/tsconfig.base.json",
|
|
4
|
+
"../../../common/build/build-common/tsconfig.esm-only.json",
|
|
5
|
+
],
|
|
6
|
+
"include": ["src/**/*"],
|
|
7
|
+
"exclude": ["src/test/**/*"],
|
|
8
|
+
"compilerOptions": {
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
},
|
|
14
12
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
"parserOptions": {
|
|
8
|
-
"project": ["./tsconfig.json", "./src/test/tsconfig.json"]
|
|
9
|
-
},
|
|
10
|
-
"extends": [
|
|
11
|
-
"@fluidframework/eslint-config-fluid"
|
|
12
|
-
]
|
|
13
|
-
}
|