@fluidframework/datastore-definitions 2.0.0-internal.7.4.0 → 2.0.0-internal.8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @fluidframework/datastore-definitions
2
2
 
3
+ ## 2.0.0-internal.8.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - datastore-definitions: Removed request and IFluidRouter from IFluidDataStoreRuntime [9a451d4946](https://github.com/microsoft/FluidFramework/commits/9a451d4946b5c51a52e4d1ab5bf51e7b285b0d74)
8
+
9
+ The `request` method and `IFluidRouter` property have been removed from `IFluidDataStoreRuntime`. Please migrate all
10
+ usage to the `IFluidDataStoreRuntime.entryPoint` API.
11
+
12
+ See
13
+ [Removing-IFluidRouter.md](https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-interfaces/Removing-IFluidRouter.md)
14
+ for more details.
15
+
16
+ - datastore-definitions: Jsonable and Serializable now require a generic parameter [9a451d4946](https://github.com/microsoft/FluidFramework/commits/9a451d4946b5c51a52e4d1ab5bf51e7b285b0d74)
17
+
18
+ The `Jsonable` and `Serializable` types from @fluidframework/datastore-definitions now require a generic parameter and
19
+ if that type is `any` or `unknown`will return a new result `JsonableTypeWith<>` that more accurately represents the
20
+ limitation of serialization.
21
+
22
+ Additional modifications:
23
+
24
+ - `Jsonable`'s `TReplacement` parameter default has also been changed from `void` to `never`, which now disallows
25
+ `void`.
26
+ - Unrecognized primitive types like `symbol` are now filtered to `never` instead of `{}`.
27
+ - Recursive types with arrays (`[]`) are now supported.
28
+
29
+ `Serializable` is commonly used for DDS values and now requires more precision when using them. For example SharedMatrix
30
+ (unqualified) has an `any` default that meant values were `Serializable<any>` (i.e. `any`), but now `Serializable<any>`
31
+ is `JsonableTypeWith<IFluidHandle>` which may be problematic for reading or writing. Preferred correction is to specify
32
+ the value type but casting through `any` may provide a quick fix.
33
+
3
34
  ## 2.0.0-internal.7.4.0
4
35
 
5
36
  Dependency updates only.
@@ -16,15 +16,12 @@ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-
16
16
  import { IFluidHandle } from '@fluidframework/core-interfaces';
17
17
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
18
18
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
19
- import { IFluidRouter } from '@fluidframework/core-interfaces';
20
19
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
21
20
  import { IIdCompressor } from '@fluidframework/id-compressor';
22
21
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
23
22
  import { ILoaderOptions } from '@fluidframework/container-definitions';
24
23
  import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
25
24
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
26
- import { IRequest } from '@fluidframework/core-interfaces';
27
- import { IResponse } from '@fluidframework/core-interfaces';
28
25
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
29
26
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
30
27
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
@@ -115,16 +112,12 @@ export interface IFluidDataStoreRuntime extends IEventProvider<IFluidDataStoreRu
115
112
  readonly idCompressor?: IIdCompressor;
116
113
  // (undocumented)
117
114
  readonly IFluidHandleContext: IFluidHandleContext;
118
- // @deprecated (undocumented)
119
- readonly IFluidRouter: IFluidRouter;
120
115
  // (undocumented)
121
116
  readonly logger: ITelemetryLogger;
122
117
  // (undocumented)
123
118
  readonly objectsRoutingContext: IFluidHandleContext;
124
119
  // (undocumented)
125
120
  readonly options: ILoaderOptions;
126
- // @deprecated (undocumented)
127
- request(request: IRequest): Promise<IResponse>;
128
121
  // (undocumented)
129
122
  readonly rootRoutingContext: IFluidHandleContext;
130
123
  submitSignal(type: string, content: any, targetClientId?: string): void;
@@ -144,12 +137,21 @@ export interface IFluidDataStoreRuntimeEvents extends IEvent {
144
137
  (event: "connected", listener: (clientId: string) => void): any;
145
138
  }
146
139
 
140
+ // @alpha (undocumented)
141
+ export interface Internal_InterfaceOfJsonableTypesWith<T> {
142
+ // (undocumented)
143
+ [index: string | number]: JsonableTypeWith<T>;
144
+ }
145
+
147
146
  // @alpha
148
- export type Jsonable<T = any, TReplaced = void> = T extends undefined | null | boolean | number | string | TReplaced ? T : Extract<T, Function> extends never ? {
147
+ export 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>[] : {
149
148
  [K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;
150
- } : never;
149
+ } : never : never;
150
+
151
+ // @alpha
152
+ export type JsonableTypeWith<T> = undefined | null | boolean | number | string | T | Internal_InterfaceOfJsonableTypesWith<T> | ArrayLike<JsonableTypeWith<T>>;
151
153
 
152
154
  // @alpha
153
- export type Serializable<T = any> = Jsonable<T, IFluidHandle>;
155
+ export type Serializable<T> = Jsonable<T, IFluidHandle>;
154
156
 
155
157
  ```
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IEvent, IEventProvider, ITelemetryLogger, IDisposable, IFluidHandleContext, IFluidRouter, IFluidHandle, FluidObject, IRequest, IResponse } from "@fluidframework/core-interfaces";
5
+ import { IEvent, IEventProvider, ITelemetryLogger, IDisposable, IFluidHandleContext, IFluidHandle, FluidObject } from "@fluidframework/core-interfaces";
6
6
  import { IAudience, IDeltaManager, AttachState, ILoaderOptions } from "@fluidframework/container-definitions";
7
7
  import { IDocumentMessage, IQuorumClients, ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
8
  import { IInboundSignalMessage, IProvideFluidDataStoreRegistry } from "@fluidframework/runtime-definitions";
@@ -91,13 +91,5 @@ export interface IFluidDataStoreRuntime extends IEventProvider<IFluidDataStoreRu
91
91
  * with it.
92
92
  */
93
93
  readonly entryPoint: IFluidHandle<FluidObject>;
94
- /**
95
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
96
- */
97
- request(request: IRequest): Promise<IResponse>;
98
- /**
99
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
100
- */
101
- readonly IFluidRouter: IFluidRouter;
102
94
  }
103
95
  //# sourceMappingURL=dataStoreRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dataStoreRuntime.d.ts","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"dataStoreRuntime.d.ts","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":"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"}
@@ -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 {\n\tIEvent,\n\tIEventProvider,\n\tITelemetryLogger,\n\tIDisposable,\n\tIFluidHandleContext,\n\t// eslint-disable-next-line import/no-deprecated\n\tIFluidRouter,\n\tIFluidHandle,\n\tFluidObject,\n\tIRequest,\n\tIResponse,\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 {\n\tIInboundSignalMessage,\n\tIProvideFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions\";\nimport { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { IChannel } from \".\";\n\n/**\n * Events emitted by {@link IFluidDataStoreRuntime}.\n * @alpha\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 * @alpha\n */\nexport interface IFluidDataStoreRuntime\n\textends IEventProvider<IFluidDataStoreRuntimeEvents>,\n\t\tIDisposable,\n\t\tPartial<IProvideFluidDataStoreRegistry> {\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\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\trequest(request: IRequest): Promise<IResponse>;\n\n\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\treadonly IFluidRouter: IFluidRouter;\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 {\n\tIInboundSignalMessage,\n\tIProvideFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions\";\nimport { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport { IChannel } from \".\";\n\n/**\n * Events emitted by {@link IFluidDataStoreRuntime}.\n * @alpha\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 * @alpha\n */\nexport interface IFluidDataStoreRuntime\n\textends IEventProvider<IFluidDataStoreRuntimeEvents>,\n\t\tIDisposable,\n\t\tPartial<IProvideFluidDataStoreRegistry> {\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"]}
@@ -17,15 +17,12 @@ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-
17
17
  import { IFluidHandle } from '@fluidframework/core-interfaces';
18
18
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
19
19
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
- import { IFluidRouter } from '@fluidframework/core-interfaces';
21
20
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
22
21
  import { IIdCompressor } from '@fluidframework/id-compressor';
23
22
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
24
23
  import { ILoaderOptions } from '@fluidframework/container-definitions';
25
24
  import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
26
25
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
27
- import { IRequest } from '@fluidframework/core-interfaces';
28
- import { IResponse } from '@fluidframework/core-interfaces';
29
26
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
30
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
31
28
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
@@ -375,14 +372,6 @@ export declare interface IFluidDataStoreRuntime extends IEventProvider<IFluidDat
375
372
  * with it.
376
373
  */
377
374
  readonly entryPoint: IFluidHandle<FluidObject>;
378
- /**
379
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
380
- */
381
- request(request: IRequest): Promise<IResponse>;
382
- /**
383
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
384
- */
385
- readonly IFluidRouter: IFluidRouter;
386
375
  }
387
376
 
388
377
  /**
@@ -396,6 +385,21 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
396
385
  (event: "connected", listener: (clientId: string) => void): any;
397
386
  }
398
387
 
388
+ /**
389
+ * @remarks
390
+ * This type is a kludge and not intended for general use.
391
+ *
392
+ * @privateRemarks
393
+ * Internal type testing for compatibility uses TypeOnly filter which cannot handle recursive "pure" types.
394
+ * This interface along with ArrayLike above avoids pure type recursion issues, but introduces a limitation on
395
+ * the ability of {@link Jsonable} to detect array-like types that are not handled naively ({@link JSON.stringify}).
396
+ * The TypeOnly filter is not useful for {@link JsonableTypeWith}; so, if type testing improves, this can be removed.
397
+ * @alpha
398
+ */
399
+ export declare interface Internal_InterfaceOfJsonableTypesWith<T> {
400
+ [index: string | number]: JsonableTypeWith<T>;
401
+ }
402
+
399
403
  /**
400
404
  * Used to constrain a type `T` to types that are serializable as JSON.
401
405
  * Produces a compile-time error if `T` contains non-Jsonable members.
@@ -403,12 +407,11 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
403
407
  * @remarks
404
408
  * Note that this does NOT prevent using of values with non-json compatible data,
405
409
  * it only prevents using values with types that include non-json compatible data.
406
- * This means that one can, for example, pass an a value typed with json compatible
410
+ * This means that one can, for example, pass in a value typed with json compatible
407
411
  * interface into this function,
408
412
  * that could actually be a class with lots on non-json compatible fields and methods.
409
413
  *
410
414
  * Important: `T extends Jsonable<T>` is incorrect (does not even compile).
411
- * `T extends Jsonable` is also incorrect since `Jsonable` is just `any` and thus applies no constraint at all.
412
415
  *
413
416
  * The optional 'TReplaced' parameter may be used to permit additional leaf types to support
414
417
  * situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).
@@ -423,10 +426,12 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
423
426
  *
424
427
  * - prototypes and non-enumerable properties are lost.
425
428
  *
429
+ * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.
430
+ *
426
431
  * Also, `Jsonable<T>` does not prevent the construction of circular references.
427
432
  *
428
- * Using `Jsonable` (with no type parameters) or `Jsonable<any>` is just a type alias for `any`
429
- * and should not be used if type safety is desired.
433
+ * Using `Jsonable<unknown>` or `Jsonable<any>` is a type alias for
434
+ * {@link JsonableTypeWith}`<never>` and should not be used if precise type safety is desired.
430
435
  *
431
436
  * @example Typical usage
432
437
  *
@@ -435,9 +440,23 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
435
440
  * ```
436
441
  * @alpha
437
442
  */
438
- export declare type Jsonable<T = any, TReplaced = void> = T extends undefined | null | boolean | number | string | TReplaced ? T : Extract<T, Function> extends never ? {
443
+ 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>[] : {
439
444
  [K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;
440
- } : never;
445
+ } : never : never;
446
+
447
+ /**
448
+ * Type constraint for types that are likely serializable as JSON or have a custom
449
+ * alternate type.
450
+ *
451
+ * @remarks
452
+ * Use `JsonableTypeWith<never>` for just JSON serializable types.
453
+ * See {@link Jsonable} for serialization pitfalls.
454
+ *
455
+ * @privateRemarks
456
+ * Perfer using `Jsonable<unknown>` over this type that is an implementation detail.
457
+ * @alpha
458
+ */
459
+ export declare type JsonableTypeWith<T> = undefined | null | boolean | number | string | T | Internal_InterfaceOfJsonableTypesWith<T> | ArrayLike<JsonableTypeWith<T>>;
441
460
 
442
461
  /**
443
462
  * Used to constrain a type 'T' to types that Fluid can intrinsically serialize. Produces a
@@ -457,6 +476,6 @@ export declare type Jsonable<T = any, TReplaced = void> = T extends undefined |
457
476
  * ```
458
477
  * @alpha
459
478
  */
460
- export declare type Serializable<T = any> = Jsonable<T, IFluidHandle>;
479
+ export declare type Serializable<T> = Jsonable<T, IFluidHandle>;
461
480
 
462
481
  export { }
@@ -17,15 +17,12 @@ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-
17
17
  import { IFluidHandle } from '@fluidframework/core-interfaces';
18
18
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
19
19
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
- import { IFluidRouter } from '@fluidframework/core-interfaces';
21
20
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
22
21
  import { IIdCompressor } from '@fluidframework/id-compressor';
23
22
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
24
23
  import { ILoaderOptions } from '@fluidframework/container-definitions';
25
24
  import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
26
25
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
27
- import { IRequest } from '@fluidframework/core-interfaces';
28
- import { IResponse } from '@fluidframework/core-interfaces';
29
26
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
30
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
31
28
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
@@ -71,8 +68,6 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
71
68
 
72
69
  /* Excluded from this release type: IFluidLoadable */
73
70
 
74
- /* Excluded from this release type: IFluidRouter */
75
-
76
71
  /* Excluded from this release type: IGarbageCollectionData */
77
72
 
78
73
  /* Excluded from this release type: IIdCompressor */
@@ -81,11 +76,9 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
81
76
 
82
77
  /* Excluded from this release type: ILoaderOptions */
83
78
 
84
- /* Excluded from this release type: IProvideFluidDataStoreRegistry */
85
-
86
- /* Excluded from this release type: IRequest */
79
+ /* Excluded from this release type: Internal_InterfaceOfJsonableTypesWith */
87
80
 
88
- /* Excluded from this release type: IResponse */
81
+ /* Excluded from this release type: IProvideFluidDataStoreRegistry */
89
82
 
90
83
  /* Excluded from this release type: ISummaryTreeWithStats */
91
84
 
@@ -95,6 +88,8 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
95
88
 
96
89
  /* Excluded from this release type: Jsonable */
97
90
 
91
+ /* Excluded from this release type: JsonableTypeWith */
92
+
98
93
  /* Excluded from this release type: Serializable */
99
94
 
100
95
  export { }
@@ -17,15 +17,12 @@ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-
17
17
  import { IFluidHandle } from '@fluidframework/core-interfaces';
18
18
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
19
19
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
- import { IFluidRouter } from '@fluidframework/core-interfaces';
21
20
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
22
21
  import { IIdCompressor } from '@fluidframework/id-compressor';
23
22
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
24
23
  import { ILoaderOptions } from '@fluidframework/container-definitions';
25
24
  import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
26
25
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
27
- import { IRequest } from '@fluidframework/core-interfaces';
28
- import { IResponse } from '@fluidframework/core-interfaces';
29
26
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
30
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
31
28
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
@@ -71,8 +68,6 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
71
68
 
72
69
  /* Excluded from this release type: IFluidLoadable */
73
70
 
74
- /* Excluded from this release type: IFluidRouter */
75
-
76
71
  /* Excluded from this release type: IGarbageCollectionData */
77
72
 
78
73
  /* Excluded from this release type: IIdCompressor */
@@ -81,11 +76,9 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
81
76
 
82
77
  /* Excluded from this release type: ILoaderOptions */
83
78
 
84
- /* Excluded from this release type: IProvideFluidDataStoreRegistry */
85
-
86
- /* Excluded from this release type: IRequest */
79
+ /* Excluded from this release type: Internal_InterfaceOfJsonableTypesWith */
87
80
 
88
- /* Excluded from this release type: IResponse */
81
+ /* Excluded from this release type: IProvideFluidDataStoreRegistry */
89
82
 
90
83
  /* Excluded from this release type: ISummaryTreeWithStats */
91
84
 
@@ -95,6 +88,8 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
95
88
 
96
89
  /* Excluded from this release type: Jsonable */
97
90
 
91
+ /* Excluded from this release type: JsonableTypeWith */
92
+
98
93
  /* Excluded from this release type: Serializable */
99
94
 
100
95
  export { }
@@ -17,15 +17,12 @@ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-
17
17
  import { IFluidHandle } from '@fluidframework/core-interfaces';
18
18
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
19
19
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
- import { IFluidRouter } from '@fluidframework/core-interfaces';
21
20
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
22
21
  import { IIdCompressor } from '@fluidframework/id-compressor';
23
22
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
24
23
  import { ILoaderOptions } from '@fluidframework/container-definitions';
25
24
  import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
26
25
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
27
- import { IRequest } from '@fluidframework/core-interfaces';
28
- import { IResponse } from '@fluidframework/core-interfaces';
29
26
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
30
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
31
28
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
@@ -375,14 +372,6 @@ export declare interface IFluidDataStoreRuntime extends IEventProvider<IFluidDat
375
372
  * with it.
376
373
  */
377
374
  readonly entryPoint: IFluidHandle<FluidObject>;
378
- /**
379
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
380
- */
381
- request(request: IRequest): Promise<IResponse>;
382
- /**
383
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
384
- */
385
- readonly IFluidRouter: IFluidRouter;
386
375
  }
387
376
 
388
377
  /**
@@ -396,6 +385,21 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
396
385
  (event: "connected", listener: (clientId: string) => void): any;
397
386
  }
398
387
 
388
+ /**
389
+ * @remarks
390
+ * This type is a kludge and not intended for general use.
391
+ *
392
+ * @privateRemarks
393
+ * Internal type testing for compatibility uses TypeOnly filter which cannot handle recursive "pure" types.
394
+ * This interface along with ArrayLike above avoids pure type recursion issues, but introduces a limitation on
395
+ * the ability of {@link Jsonable} to detect array-like types that are not handled naively ({@link JSON.stringify}).
396
+ * The TypeOnly filter is not useful for {@link JsonableTypeWith}; so, if type testing improves, this can be removed.
397
+ * @alpha
398
+ */
399
+ export declare interface Internal_InterfaceOfJsonableTypesWith<T> {
400
+ [index: string | number]: JsonableTypeWith<T>;
401
+ }
402
+
399
403
  /**
400
404
  * Used to constrain a type `T` to types that are serializable as JSON.
401
405
  * Produces a compile-time error if `T` contains non-Jsonable members.
@@ -403,12 +407,11 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
403
407
  * @remarks
404
408
  * Note that this does NOT prevent using of values with non-json compatible data,
405
409
  * it only prevents using values with types that include non-json compatible data.
406
- * This means that one can, for example, pass an a value typed with json compatible
410
+ * This means that one can, for example, pass in a value typed with json compatible
407
411
  * interface into this function,
408
412
  * that could actually be a class with lots on non-json compatible fields and methods.
409
413
  *
410
414
  * Important: `T extends Jsonable<T>` is incorrect (does not even compile).
411
- * `T extends Jsonable` is also incorrect since `Jsonable` is just `any` and thus applies no constraint at all.
412
415
  *
413
416
  * The optional 'TReplaced' parameter may be used to permit additional leaf types to support
414
417
  * situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).
@@ -423,10 +426,12 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
423
426
  *
424
427
  * - prototypes and non-enumerable properties are lost.
425
428
  *
429
+ * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.
430
+ *
426
431
  * Also, `Jsonable<T>` does not prevent the construction of circular references.
427
432
  *
428
- * Using `Jsonable` (with no type parameters) or `Jsonable<any>` is just a type alias for `any`
429
- * and should not be used if type safety is desired.
433
+ * Using `Jsonable<unknown>` or `Jsonable<any>` is a type alias for
434
+ * {@link JsonableTypeWith}`<never>` and should not be used if precise type safety is desired.
430
435
  *
431
436
  * @example Typical usage
432
437
  *
@@ -435,9 +440,23 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
435
440
  * ```
436
441
  * @alpha
437
442
  */
438
- export declare type Jsonable<T = any, TReplaced = void> = T extends undefined | null | boolean | number | string | TReplaced ? T : Extract<T, Function> extends never ? {
443
+ 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>[] : {
439
444
  [K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;
440
- } : never;
445
+ } : never : never;
446
+
447
+ /**
448
+ * Type constraint for types that are likely serializable as JSON or have a custom
449
+ * alternate type.
450
+ *
451
+ * @remarks
452
+ * Use `JsonableTypeWith<never>` for just JSON serializable types.
453
+ * See {@link Jsonable} for serialization pitfalls.
454
+ *
455
+ * @privateRemarks
456
+ * Perfer using `Jsonable<unknown>` over this type that is an implementation detail.
457
+ * @alpha
458
+ */
459
+ export declare type JsonableTypeWith<T> = undefined | null | boolean | number | string | T | Internal_InterfaceOfJsonableTypesWith<T> | ArrayLike<JsonableTypeWith<T>>;
441
460
 
442
461
  /**
443
462
  * Used to constrain a type 'T' to types that Fluid can intrinsically serialize. Produces a
@@ -457,6 +476,6 @@ export declare type Jsonable<T = any, TReplaced = void> = T extends undefined |
457
476
  * ```
458
477
  * @alpha
459
478
  */
460
- export declare type Serializable<T = any> = Jsonable<T, IFluidHandle>;
479
+ export declare type Serializable<T> = Jsonable<T, IFluidHandle>;
461
480
 
462
481
  export { }
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  */
11
11
  export { IChannel, IChannelFactory, IChannelServices, IChannelStorageService, IDeltaConnection, IDeltaHandler, } from "./channel";
12
12
  export { IFluidDataStoreRuntime, IFluidDataStoreRuntimeEvents } from "./dataStoreRuntime";
13
- export { Jsonable } from "./jsonable";
13
+ export type { Jsonable, JsonableTypeWith, Internal_InterfaceOfJsonableTypesWith } from "./jsonable";
14
14
  export { Serializable } from "./serializable";
15
15
  export { IChannelAttributes } from "./storage";
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EACN,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EACN,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAC1F,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,qCAAqC,EAAE,MAAM,YAAY,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This library defines the interfaces required to implement and/or communicate\n * with a data store.\n *\n * @packageDocumentation\n */\n\nexport {\n\tIChannel,\n\tIChannelFactory,\n\tIChannelServices,\n\tIChannelStorageService,\n\tIDeltaConnection,\n\tIDeltaHandler,\n} from \"./channel\";\nexport { IFluidDataStoreRuntime, IFluidDataStoreRuntimeEvents } from \"./dataStoreRuntime\";\nexport { Jsonable } from \"./jsonable\";\nexport { Serializable } from \"./serializable\";\nexport { IChannelAttributes } from \"./storage\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * This library defines the interfaces required to implement and/or communicate\n * with a data store.\n *\n * @packageDocumentation\n */\n\nexport {\n\tIChannel,\n\tIChannelFactory,\n\tIChannelServices,\n\tIChannelStorageService,\n\tIDeltaConnection,\n\tIDeltaHandler,\n} from \"./channel\";\nexport { IFluidDataStoreRuntime, IFluidDataStoreRuntimeEvents } from \"./dataStoreRuntime\";\nexport type { Jsonable, JsonableTypeWith, Internal_InterfaceOfJsonableTypesWith } from \"./jsonable\";\nexport { Serializable } from \"./serializable\";\nexport { IChannelAttributes } from \"./storage\";\n"]}
@@ -2,6 +2,33 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /**
6
+ * Type constraint for types that are likely serializable as JSON or have a custom
7
+ * alternate type.
8
+ *
9
+ * @remarks
10
+ * Use `JsonableTypeWith<never>` for just JSON serializable types.
11
+ * See {@link Jsonable} for serialization pitfalls.
12
+ *
13
+ * @privateRemarks
14
+ * Perfer using `Jsonable<unknown>` over this type that is an implementation detail.
15
+ * @alpha
16
+ */
17
+ export type JsonableTypeWith<T> = undefined | null | boolean | number | string | T | Internal_InterfaceOfJsonableTypesWith<T> | ArrayLike<JsonableTypeWith<T>>;
18
+ /**
19
+ * @remarks
20
+ * This type is a kludge and not intended for general use.
21
+ *
22
+ * @privateRemarks
23
+ * Internal type testing for compatibility uses TypeOnly filter which cannot handle recursive "pure" types.
24
+ * This interface along with ArrayLike above avoids pure type recursion issues, but introduces a limitation on
25
+ * the ability of {@link Jsonable} to detect array-like types that are not handled naively ({@link JSON.stringify}).
26
+ * The TypeOnly filter is not useful for {@link JsonableTypeWith}; so, if type testing improves, this can be removed.
27
+ * @alpha
28
+ */
29
+ export interface Internal_InterfaceOfJsonableTypesWith<T> {
30
+ [index: string | number]: JsonableTypeWith<T>;
31
+ }
5
32
  /**
6
33
  * Used to constrain a type `T` to types that are serializable as JSON.
7
34
  * Produces a compile-time error if `T` contains non-Jsonable members.
@@ -9,12 +36,11 @@
9
36
  * @remarks
10
37
  * Note that this does NOT prevent using of values with non-json compatible data,
11
38
  * it only prevents using values with types that include non-json compatible data.
12
- * This means that one can, for example, pass an a value typed with json compatible
39
+ * This means that one can, for example, pass in a value typed with json compatible
13
40
  * interface into this function,
14
41
  * that could actually be a class with lots on non-json compatible fields and methods.
15
42
  *
16
43
  * Important: `T extends Jsonable<T>` is incorrect (does not even compile).
17
- * `T extends Jsonable` is also incorrect since `Jsonable` is just `any` and thus applies no constraint at all.
18
44
  *
19
45
  * The optional 'TReplaced' parameter may be used to permit additional leaf types to support
20
46
  * situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).
@@ -29,10 +55,12 @@
29
55
  *
30
56
  * - prototypes and non-enumerable properties are lost.
31
57
  *
58
+ * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.
59
+ *
32
60
  * Also, `Jsonable<T>` does not prevent the construction of circular references.
33
61
  *
34
- * Using `Jsonable` (with no type parameters) or `Jsonable<any>` is just a type alias for `any`
35
- * and should not be used if type safety is desired.
62
+ * Using `Jsonable<unknown>` or `Jsonable<any>` is a type alias for
63
+ * {@link JsonableTypeWith}`<never>` and should not be used if precise type safety is desired.
36
64
  *
37
65
  * @example Typical usage
38
66
  *
@@ -41,7 +69,7 @@
41
69
  * ```
42
70
  * @alpha
43
71
  */
44
- export type Jsonable<T = any, TReplaced = void> = T extends undefined | null | boolean | number | string | TReplaced ? T : Extract<T, Function> extends never ? {
72
+ export 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>[] : {
45
73
  [K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;
46
- } : never;
74
+ } : never : never;
47
75
  //# sourceMappingURL=jsonable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonable.d.ts","sourceRoot":"","sources":["../src/jsonable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,GAAG,IAAI,IAAI,CAAC,SAChD,SAAS,GACT,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,CAAC,GAEH,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,KAAK,GAChC;KACC,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK;CACnF,GACD,KAAK,CAAC"}
1
+ {"version":3,"file":"jsonable.d.ts","sourceRoot":"","sources":["../src/jsonable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC3B,SAAS,GACT,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,CAAC,GACD,qCAAqC,CAAC,CAAC,CAAC,GACxC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;AAElC;;;;;;;;;;GAUG;AACH,MAAM,WAAW,qCAAqC,CAAC,CAAC;IACvD,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,SAAS,GAAG,KAAK,IAAyB,OAAO,SAAS,CACjF,CAAC,SAAS,KAAK,GAAG,IAAI,GAAG,KAAK,CAC9B,GACiB,gBAAgB,CAAC,SAAS,CAAC,GACjB,OAAO,SAAS,CAAC,GACvB,gBAAgB,CAAC,SAAS,CAAC,GACN,CAAC,SACvC,SAAS,GACT,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACc,CAAC,GAEE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,KAAK,GAClB,CAAC,SAAS,MAAM,GAC5B,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACpC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,GACjB;KACrB,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,KAAK,GAC7C,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GACzB,KAAK;CACP,GACqB,KAAK,GACX,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsonable.js","sourceRoot":"","sources":["../src/jsonable.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Used to constrain a type `T` to types that are serializable as JSON.\n * Produces a compile-time error if `T` contains non-Jsonable members.\n *\n * @remarks\n * Note that this does NOT prevent using of values with non-json compatible data,\n * it only prevents using values with types that include non-json compatible data.\n * This means that one can, for example, pass an a value typed with json compatible\n * interface into this function,\n * that could actually be a class with lots on non-json compatible fields and methods.\n *\n * Important: `T extends Jsonable<T>` is incorrect (does not even compile).\n * `T extends Jsonable` is also incorrect since `Jsonable` is just `any` and thus applies no constraint at all.\n *\n * The optional 'TReplaced' parameter may be used to permit additional leaf types to support\n * situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).\n *\n * Note that `Jsonable<T>` does not protect against the following pitfalls when serializing with JSON.stringify():\n *\n * - `undefined` properties on objects are omitted (i.e., properties become undefined instead of equal to undefined).\n *\n * - When `undefined` appears as the root object or as an array element it is coerced to `null`.\n *\n * - Non-finite numbers (`NaN`, `+/-Infinity`) are also coerced to `null`.\n *\n * - prototypes and non-enumerable properties are lost.\n *\n * Also, `Jsonable<T>` does not prevent the construction of circular references.\n *\n * Using `Jsonable` (with no type parameters) or `Jsonable<any>` is just a type alias for `any`\n * and should not be used if type safety is desired.\n *\n * @example Typical usage\n *\n * ```typescript\n * function foo<T>(value: Jsonable<T>) { ... }\n * ```\n * @alpha\n */\nexport type Jsonable<T = any, TReplaced = void> = T extends\n\t| undefined\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| TReplaced\n\t? T\n\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\tExtract<T, Function> extends never\n\t? {\n\t\t\t[K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;\n\t }\n\t: never;\n"]}
1
+ {"version":3,"file":"jsonable.js","sourceRoot":"","sources":["../src/jsonable.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Type constraint for types that are likely serializable as JSON or have a custom\n * alternate type.\n *\n * @remarks\n * Use `JsonableTypeWith<never>` for just JSON serializable types.\n * See {@link Jsonable} for serialization pitfalls.\n *\n * @privateRemarks\n * Perfer using `Jsonable<unknown>` over this type that is an implementation detail.\n * @alpha\n */\nexport type JsonableTypeWith<T> =\n\t| undefined\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| T\n\t| Internal_InterfaceOfJsonableTypesWith<T>\n\t| ArrayLike<JsonableTypeWith<T>>;\n\n/**\n * @remarks\n * This type is a kludge and not intended for general use.\n *\n * @privateRemarks\n * Internal type testing for compatibility uses TypeOnly filter which cannot handle recursive \"pure\" types.\n * This interface along with ArrayLike above avoids pure type recursion issues, but introduces a limitation on\n * the ability of {@link Jsonable} to detect array-like types that are not handled naively ({@link JSON.stringify}).\n * The TypeOnly filter is not useful for {@link JsonableTypeWith}; so, if type testing improves, this can be removed.\n * @alpha\n */\nexport interface Internal_InterfaceOfJsonableTypesWith<T> {\n\t[index: string | number]: JsonableTypeWith<T>;\n}\n\n/**\n * Used to constrain a type `T` to types that are serializable as JSON.\n * Produces a compile-time error if `T` contains non-Jsonable members.\n *\n * @remarks\n * Note that this does NOT prevent using of values with non-json compatible data,\n * it only prevents using values with types that include non-json compatible data.\n * This means that one can, for example, pass in a value typed with json compatible\n * interface into this function,\n * that could actually be a class with lots on non-json compatible fields and methods.\n *\n * Important: `T extends Jsonable<T>` is incorrect (does not even compile).\n *\n * The optional 'TReplaced' parameter may be used to permit additional leaf types to support\n * situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).\n *\n * Note that `Jsonable<T>` does not protect against the following pitfalls when serializing with JSON.stringify():\n *\n * - `undefined` properties on objects are omitted (i.e., properties become undefined instead of equal to undefined).\n *\n * - When `undefined` appears as the root object or as an array element it is coerced to `null`.\n *\n * - Non-finite numbers (`NaN`, `+/-Infinity`) are also coerced to `null`.\n *\n * - prototypes and non-enumerable properties are lost.\n *\n * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.\n *\n * Also, `Jsonable<T>` does not prevent the construction of circular references.\n *\n * Using `Jsonable<unknown>` or `Jsonable<any>` is a type alias for\n * {@link JsonableTypeWith}`<never>` and should not be used if precise type safety is desired.\n *\n * @example Typical usage\n *\n * ```typescript\n * function foo<T>(value: Jsonable<T>) { ... }\n * ```\n * @alpha\n */\nexport type Jsonable<T, TReplaced = never> = /* test for 'any' */ boolean extends (\n\tT extends never ? true : false\n)\n\t? /* 'any' => */ JsonableTypeWith<TReplaced>\n\t: /* test for 'unknown' */ unknown extends T\n\t? /* 'unknown' => */ JsonableTypeWith<TReplaced>\n\t: /* test for Jsonable primitive types */ T extends\n\t\t\t| undefined /* is not serialized */\n\t\t\t| null\n\t\t\t| boolean\n\t\t\t| number\n\t\t\t| string\n\t\t\t| TReplaced\n\t? /* primitive types => */ T\n\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t/* test for not a function */ Extract<T, Function> extends never\n\t? /* not a function => => test for object */ T extends object\n\t\t? /* object => test for array */ T extends (infer U)[] // prefer ArrayLike test to catch non-array array-like types\n\t\t\t? /* array => */ Jsonable<U, TReplaced>[]\n\t\t\t: /* property bag => */ {\n\t\t\t\t\t[K in keyof T]: Extract<K, symbol> extends never\n\t\t\t\t\t\t? Jsonable<T[K], TReplaced>\n\t\t\t\t\t\t: never;\n\t\t\t }\n\t\t: /* not an object => */ never\n\t: /* function => */ never;\n"]}
@@ -22,5 +22,5 @@ import { Jsonable } from "./jsonable";
22
22
  * ```
23
23
  * @alpha
24
24
  */
25
- export type Serializable<T = any> = Jsonable<T, IFluidHandle>;
25
+ export type Serializable<T> = Jsonable<T, IFluidHandle>;
26
26
  //# sourceMappingURL=serializable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serializable.d.ts","sourceRoot":"","sources":["../src/serializable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC"}
1
+ {"version":3,"file":"serializable.d.ts","sourceRoot":"","sources":["../src/serializable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"serializable.js","sourceRoot":"","sources":["../src/serializable.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 } from \"@fluidframework/core-interfaces\";\nimport { Jsonable } from \"./jsonable\";\n\n/**\n * Used to constrain a type 'T' to types that Fluid can intrinsically serialize. Produces a\n * compile-time error if `T` contains non-serializable members.\n *\n * @remarks\n * See Jsonable for caveats regarding serialization of `undefined`, non-finite numbers,\n * and circular references.\n *\n * Important: `T extends Serializable<T>` is generally incorrect.\n * (Any value of `T` extends the serializable subset of itself.)\n *\n * @example Typical usage\n *\n * ```typescript\n * function serialize<T>(value: Serializable<T>) { ... }\n * ```\n * @alpha\n */\nexport type Serializable<T = any> = Jsonable<T, IFluidHandle>;\n"]}
1
+ {"version":3,"file":"serializable.js","sourceRoot":"","sources":["../src/serializable.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 } from \"@fluidframework/core-interfaces\";\nimport { Jsonable } from \"./jsonable\";\n\n/**\n * Used to constrain a type 'T' to types that Fluid can intrinsically serialize. Produces a\n * compile-time error if `T` contains non-serializable members.\n *\n * @remarks\n * See Jsonable for caveats regarding serialization of `undefined`, non-finite numbers,\n * and circular references.\n *\n * Important: `T extends Serializable<T>` is generally incorrect.\n * (Any value of `T` extends the serializable subset of itself.)\n *\n * @example Typical usage\n *\n * ```typescript\n * function serialize<T>(value: Serializable<T>) { ... }\n * ```\n * @alpha\n */\nexport type Serializable<T> = Jsonable<T, IFluidHandle>;\n"]}
@@ -17,15 +17,12 @@ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-
17
17
  import { IFluidHandle } from '@fluidframework/core-interfaces';
18
18
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
19
19
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
- import { IFluidRouter } from '@fluidframework/core-interfaces';
21
20
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
22
21
  import { IIdCompressor } from '@fluidframework/id-compressor';
23
22
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
24
23
  import { ILoaderOptions } from '@fluidframework/container-definitions';
25
24
  import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
26
25
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
27
- import { IRequest } from '@fluidframework/core-interfaces';
28
- import { IResponse } from '@fluidframework/core-interfaces';
29
26
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
30
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
31
28
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
@@ -375,14 +372,6 @@ export declare interface IFluidDataStoreRuntime extends IEventProvider<IFluidDat
375
372
  * with it.
376
373
  */
377
374
  readonly entryPoint: IFluidHandle<FluidObject>;
378
- /**
379
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
380
- */
381
- request(request: IRequest): Promise<IResponse>;
382
- /**
383
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
384
- */
385
- readonly IFluidRouter: IFluidRouter;
386
375
  }
387
376
 
388
377
  /**
@@ -396,6 +385,21 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
396
385
  (event: "connected", listener: (clientId: string) => void): any;
397
386
  }
398
387
 
388
+ /**
389
+ * @remarks
390
+ * This type is a kludge and not intended for general use.
391
+ *
392
+ * @privateRemarks
393
+ * Internal type testing for compatibility uses TypeOnly filter which cannot handle recursive "pure" types.
394
+ * This interface along with ArrayLike above avoids pure type recursion issues, but introduces a limitation on
395
+ * the ability of {@link Jsonable} to detect array-like types that are not handled naively ({@link JSON.stringify}).
396
+ * The TypeOnly filter is not useful for {@link JsonableTypeWith}; so, if type testing improves, this can be removed.
397
+ * @alpha
398
+ */
399
+ export declare interface Internal_InterfaceOfJsonableTypesWith<T> {
400
+ [index: string | number]: JsonableTypeWith<T>;
401
+ }
402
+
399
403
  /**
400
404
  * Used to constrain a type `T` to types that are serializable as JSON.
401
405
  * Produces a compile-time error if `T` contains non-Jsonable members.
@@ -403,12 +407,11 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
403
407
  * @remarks
404
408
  * Note that this does NOT prevent using of values with non-json compatible data,
405
409
  * it only prevents using values with types that include non-json compatible data.
406
- * This means that one can, for example, pass an a value typed with json compatible
410
+ * This means that one can, for example, pass in a value typed with json compatible
407
411
  * interface into this function,
408
412
  * that could actually be a class with lots on non-json compatible fields and methods.
409
413
  *
410
414
  * Important: `T extends Jsonable<T>` is incorrect (does not even compile).
411
- * `T extends Jsonable` is also incorrect since `Jsonable` is just `any` and thus applies no constraint at all.
412
415
  *
413
416
  * The optional 'TReplaced' parameter may be used to permit additional leaf types to support
414
417
  * situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).
@@ -423,10 +426,12 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
423
426
  *
424
427
  * - prototypes and non-enumerable properties are lost.
425
428
  *
429
+ * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.
430
+ *
426
431
  * Also, `Jsonable<T>` does not prevent the construction of circular references.
427
432
  *
428
- * Using `Jsonable` (with no type parameters) or `Jsonable<any>` is just a type alias for `any`
429
- * and should not be used if type safety is desired.
433
+ * Using `Jsonable<unknown>` or `Jsonable<any>` is a type alias for
434
+ * {@link JsonableTypeWith}`<never>` and should not be used if precise type safety is desired.
430
435
  *
431
436
  * @example Typical usage
432
437
  *
@@ -435,9 +440,23 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
435
440
  * ```
436
441
  * @alpha
437
442
  */
438
- export declare type Jsonable<T = any, TReplaced = void> = T extends undefined | null | boolean | number | string | TReplaced ? T : Extract<T, Function> extends never ? {
443
+ 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>[] : {
439
444
  [K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;
440
- } : never;
445
+ } : never : never;
446
+
447
+ /**
448
+ * Type constraint for types that are likely serializable as JSON or have a custom
449
+ * alternate type.
450
+ *
451
+ * @remarks
452
+ * Use `JsonableTypeWith<never>` for just JSON serializable types.
453
+ * See {@link Jsonable} for serialization pitfalls.
454
+ *
455
+ * @privateRemarks
456
+ * Perfer using `Jsonable<unknown>` over this type that is an implementation detail.
457
+ * @alpha
458
+ */
459
+ export declare type JsonableTypeWith<T> = undefined | null | boolean | number | string | T | Internal_InterfaceOfJsonableTypesWith<T> | ArrayLike<JsonableTypeWith<T>>;
441
460
 
442
461
  /**
443
462
  * Used to constrain a type 'T' to types that Fluid can intrinsically serialize. Produces a
@@ -457,6 +476,6 @@ export declare type Jsonable<T = any, TReplaced = void> = T extends undefined |
457
476
  * ```
458
477
  * @alpha
459
478
  */
460
- export declare type Serializable<T = any> = Jsonable<T, IFluidHandle>;
479
+ export declare type Serializable<T> = Jsonable<T, IFluidHandle>;
461
480
 
462
481
  export { }
@@ -17,15 +17,12 @@ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-
17
17
  import { IFluidHandle } from '@fluidframework/core-interfaces';
18
18
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
19
19
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
- import { IFluidRouter } from '@fluidframework/core-interfaces';
21
20
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
22
21
  import { IIdCompressor } from '@fluidframework/id-compressor';
23
22
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
24
23
  import { ILoaderOptions } from '@fluidframework/container-definitions';
25
24
  import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
26
25
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
27
- import { IRequest } from '@fluidframework/core-interfaces';
28
- import { IResponse } from '@fluidframework/core-interfaces';
29
26
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
30
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
31
28
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
@@ -71,8 +68,6 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
71
68
 
72
69
  /* Excluded from this release type: IFluidLoadable */
73
70
 
74
- /* Excluded from this release type: IFluidRouter */
75
-
76
71
  /* Excluded from this release type: IGarbageCollectionData */
77
72
 
78
73
  /* Excluded from this release type: IIdCompressor */
@@ -81,11 +76,9 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
81
76
 
82
77
  /* Excluded from this release type: ILoaderOptions */
83
78
 
84
- /* Excluded from this release type: IProvideFluidDataStoreRegistry */
85
-
86
- /* Excluded from this release type: IRequest */
79
+ /* Excluded from this release type: Internal_InterfaceOfJsonableTypesWith */
87
80
 
88
- /* Excluded from this release type: IResponse */
81
+ /* Excluded from this release type: IProvideFluidDataStoreRegistry */
89
82
 
90
83
  /* Excluded from this release type: ISummaryTreeWithStats */
91
84
 
@@ -95,6 +88,8 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
95
88
 
96
89
  /* Excluded from this release type: Jsonable */
97
90
 
91
+ /* Excluded from this release type: JsonableTypeWith */
92
+
98
93
  /* Excluded from this release type: Serializable */
99
94
 
100
95
  export { }
@@ -17,15 +17,12 @@ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-
17
17
  import { IFluidHandle } from '@fluidframework/core-interfaces';
18
18
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
19
19
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
- import { IFluidRouter } from '@fluidframework/core-interfaces';
21
20
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
22
21
  import { IIdCompressor } from '@fluidframework/id-compressor';
23
22
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
24
23
  import { ILoaderOptions } from '@fluidframework/container-definitions';
25
24
  import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
26
25
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
27
- import { IRequest } from '@fluidframework/core-interfaces';
28
- import { IResponse } from '@fluidframework/core-interfaces';
29
26
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
30
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
31
28
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
@@ -71,8 +68,6 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
71
68
 
72
69
  /* Excluded from this release type: IFluidLoadable */
73
70
 
74
- /* Excluded from this release type: IFluidRouter */
75
-
76
71
  /* Excluded from this release type: IGarbageCollectionData */
77
72
 
78
73
  /* Excluded from this release type: IIdCompressor */
@@ -81,11 +76,9 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
81
76
 
82
77
  /* Excluded from this release type: ILoaderOptions */
83
78
 
84
- /* Excluded from this release type: IProvideFluidDataStoreRegistry */
85
-
86
- /* Excluded from this release type: IRequest */
79
+ /* Excluded from this release type: Internal_InterfaceOfJsonableTypesWith */
87
80
 
88
- /* Excluded from this release type: IResponse */
81
+ /* Excluded from this release type: IProvideFluidDataStoreRegistry */
89
82
 
90
83
  /* Excluded from this release type: ISummaryTreeWithStats */
91
84
 
@@ -95,6 +88,8 @@ import { ITelemetryLogger } from '@fluidframework/core-interfaces';
95
88
 
96
89
  /* Excluded from this release type: Jsonable */
97
90
 
91
+ /* Excluded from this release type: JsonableTypeWith */
92
+
98
93
  /* Excluded from this release type: Serializable */
99
94
 
100
95
  export { }
@@ -17,15 +17,12 @@ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-
17
17
  import { IFluidHandle } from '@fluidframework/core-interfaces';
18
18
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
19
19
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
20
- import { IFluidRouter } from '@fluidframework/core-interfaces';
21
20
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
22
21
  import { IIdCompressor } from '@fluidframework/id-compressor';
23
22
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
24
23
  import { ILoaderOptions } from '@fluidframework/container-definitions';
25
24
  import { IProvideFluidDataStoreRegistry } from '@fluidframework/runtime-definitions';
26
25
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
27
- import { IRequest } from '@fluidframework/core-interfaces';
28
- import { IResponse } from '@fluidframework/core-interfaces';
29
26
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
30
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
31
28
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
@@ -375,14 +372,6 @@ export declare interface IFluidDataStoreRuntime extends IEventProvider<IFluidDat
375
372
  * with it.
376
373
  */
377
374
  readonly entryPoint: IFluidHandle<FluidObject>;
378
- /**
379
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
380
- */
381
- request(request: IRequest): Promise<IResponse>;
382
- /**
383
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
384
- */
385
- readonly IFluidRouter: IFluidRouter;
386
375
  }
387
376
 
388
377
  /**
@@ -396,6 +385,21 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
396
385
  (event: "connected", listener: (clientId: string) => void): any;
397
386
  }
398
387
 
388
+ /**
389
+ * @remarks
390
+ * This type is a kludge and not intended for general use.
391
+ *
392
+ * @privateRemarks
393
+ * Internal type testing for compatibility uses TypeOnly filter which cannot handle recursive "pure" types.
394
+ * This interface along with ArrayLike above avoids pure type recursion issues, but introduces a limitation on
395
+ * the ability of {@link Jsonable} to detect array-like types that are not handled naively ({@link JSON.stringify}).
396
+ * The TypeOnly filter is not useful for {@link JsonableTypeWith}; so, if type testing improves, this can be removed.
397
+ * @alpha
398
+ */
399
+ export declare interface Internal_InterfaceOfJsonableTypesWith<T> {
400
+ [index: string | number]: JsonableTypeWith<T>;
401
+ }
402
+
399
403
  /**
400
404
  * Used to constrain a type `T` to types that are serializable as JSON.
401
405
  * Produces a compile-time error if `T` contains non-Jsonable members.
@@ -403,12 +407,11 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
403
407
  * @remarks
404
408
  * Note that this does NOT prevent using of values with non-json compatible data,
405
409
  * it only prevents using values with types that include non-json compatible data.
406
- * This means that one can, for example, pass an a value typed with json compatible
410
+ * This means that one can, for example, pass in a value typed with json compatible
407
411
  * interface into this function,
408
412
  * that could actually be a class with lots on non-json compatible fields and methods.
409
413
  *
410
414
  * Important: `T extends Jsonable<T>` is incorrect (does not even compile).
411
- * `T extends Jsonable` is also incorrect since `Jsonable` is just `any` and thus applies no constraint at all.
412
415
  *
413
416
  * The optional 'TReplaced' parameter may be used to permit additional leaf types to support
414
417
  * situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).
@@ -423,10 +426,12 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
423
426
  *
424
427
  * - prototypes and non-enumerable properties are lost.
425
428
  *
429
+ * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.
430
+ *
426
431
  * Also, `Jsonable<T>` does not prevent the construction of circular references.
427
432
  *
428
- * Using `Jsonable` (with no type parameters) or `Jsonable<any>` is just a type alias for `any`
429
- * and should not be used if type safety is desired.
433
+ * Using `Jsonable<unknown>` or `Jsonable<any>` is a type alias for
434
+ * {@link JsonableTypeWith}`<never>` and should not be used if precise type safety is desired.
430
435
  *
431
436
  * @example Typical usage
432
437
  *
@@ -435,9 +440,23 @@ export declare interface IFluidDataStoreRuntimeEvents extends IEvent {
435
440
  * ```
436
441
  * @alpha
437
442
  */
438
- export declare type Jsonable<T = any, TReplaced = void> = T extends undefined | null | boolean | number | string | TReplaced ? T : Extract<T, Function> extends never ? {
443
+ 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>[] : {
439
444
  [K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;
440
- } : never;
445
+ } : never : never;
446
+
447
+ /**
448
+ * Type constraint for types that are likely serializable as JSON or have a custom
449
+ * alternate type.
450
+ *
451
+ * @remarks
452
+ * Use `JsonableTypeWith<never>` for just JSON serializable types.
453
+ * See {@link Jsonable} for serialization pitfalls.
454
+ *
455
+ * @privateRemarks
456
+ * Perfer using `Jsonable<unknown>` over this type that is an implementation detail.
457
+ * @alpha
458
+ */
459
+ export declare type JsonableTypeWith<T> = undefined | null | boolean | number | string | T | Internal_InterfaceOfJsonableTypesWith<T> | ArrayLike<JsonableTypeWith<T>>;
441
460
 
442
461
  /**
443
462
  * Used to constrain a type 'T' to types that Fluid can intrinsically serialize. Produces a
@@ -457,6 +476,6 @@ export declare type Jsonable<T = any, TReplaced = void> = T extends undefined |
457
476
  * ```
458
477
  * @alpha
459
478
  */
460
- export declare type Serializable<T = any> = Jsonable<T, IFluidHandle>;
479
+ export declare type Serializable<T> = Jsonable<T, IFluidHandle>;
461
480
 
462
481
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/datastore-definitions",
3
- "version": "2.0.0-internal.7.4.0",
3
+ "version": "2.0.0-internal.8.0.1",
4
4
  "description": "Fluid data store definitions",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -14,11 +14,11 @@
14
14
  "main": "dist/index.js",
15
15
  "types": "dist/index.d.ts",
16
16
  "dependencies": {
17
- "@fluidframework/container-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
18
- "@fluidframework/core-interfaces": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
19
- "@fluidframework/id-compressor": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
17
+ "@fluidframework/container-definitions": ">=2.0.0-internal.8.0.1 <2.0.0-internal.8.1.0",
18
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.8.0.1 <2.0.0-internal.8.1.0",
19
+ "@fluidframework/id-compressor": ">=2.0.0-internal.8.0.1 <2.0.0-internal.8.1.0",
20
20
  "@fluidframework/protocol-definitions": "^3.0.0",
21
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0"
21
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.8.0.1 <2.0.0-internal.8.1.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@arethetypeswrong/cli": "^0.13.3",
@@ -47,7 +47,11 @@
47
47
  }
48
48
  },
49
49
  "typeValidation": {
50
- "broken": {}
50
+ "broken": {
51
+ "InterfaceDeclaration_IFluidDataStoreRuntime": {
52
+ "backCompat": false
53
+ }
54
+ }
51
55
  },
52
56
  "scripts": {
53
57
  "api": "fluid-build . --task api",
@@ -9,12 +9,8 @@ import {
9
9
  ITelemetryLogger,
10
10
  IDisposable,
11
11
  IFluidHandleContext,
12
- // eslint-disable-next-line import/no-deprecated
13
- IFluidRouter,
14
12
  IFluidHandle,
15
13
  FluidObject,
16
- IRequest,
17
- IResponse,
18
14
  } from "@fluidframework/core-interfaces";
19
15
  import {
20
16
  IAudience,
@@ -141,15 +137,4 @@ export interface IFluidDataStoreRuntime
141
137
  * with it.
142
138
  */
143
139
  readonly entryPoint: IFluidHandle<FluidObject>;
144
-
145
- /**
146
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
147
- */
148
- request(request: IRequest): Promise<IResponse>;
149
-
150
- /**
151
- * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
152
- */
153
- // eslint-disable-next-line import/no-deprecated
154
- readonly IFluidRouter: IFluidRouter;
155
140
  }
package/src/index.ts CHANGED
@@ -19,6 +19,6 @@ export {
19
19
  IDeltaHandler,
20
20
  } from "./channel";
21
21
  export { IFluidDataStoreRuntime, IFluidDataStoreRuntimeEvents } from "./dataStoreRuntime";
22
- export { Jsonable } from "./jsonable";
22
+ export type { Jsonable, JsonableTypeWith, Internal_InterfaceOfJsonableTypesWith } from "./jsonable";
23
23
  export { Serializable } from "./serializable";
24
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,12 +47,11 @@
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 an a value typed with json compatible
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>`).
@@ -30,10 +66,12 @@
30
66
  *
31
67
  * - prototypes and non-enumerable properties are lost.
32
68
  *
69
+ * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.
70
+ *
33
71
  * Also, `Jsonable<T>` does not prevent the construction of circular references.
34
72
  *
35
- * Using `Jsonable` (with no type parameters) or `Jsonable<any>` is just a type alias for `any`
36
- * 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.
37
75
  *
38
76
  * @example Typical usage
39
77
  *
@@ -42,17 +80,29 @@
42
80
  * ```
43
81
  * @alpha
44
82
  */
45
- export type Jsonable<T = any, TReplaced = void> = T extends
46
- | undefined
47
- | null
48
- | boolean
49
- | number
50
- | string
51
- | TReplaced
52
- ? T
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
53
97
  : // eslint-disable-next-line @typescript-eslint/ban-types
54
- Extract<T, Function> extends never
55
- ? {
56
- [K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;
57
- }
58
- : never;
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;
@@ -24,4 +24,4 @@ import { Jsonable } from "./jsonable";
24
24
  * ```
25
25
  * @alpha
26
26
  */
27
- export type Serializable<T = any> = Jsonable<T, IFluidHandle>;
27
+ export type Serializable<T> = Jsonable<T, IFluidHandle>;