@fluidframework/datastore-definitions 1.2.0-77818 → 1.2.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/dist/jsonable.d.ts +21 -10
- package/dist/jsonable.d.ts.map +1 -1
- package/dist/jsonable.js.map +1 -1
- package/dist/serializable.d.ts +9 -7
- package/dist/serializable.d.ts.map +1 -1
- package/dist/serializable.js.map +1 -1
- package/package.json +6 -6
- package/src/jsonable.ts +21 -10
- package/src/serializable.ts +9 -7
package/dist/jsonable.d.ts
CHANGED
|
@@ -3,28 +3,39 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Used to constrain a type `T` to types that are serializable as JSON.
|
|
7
|
-
* compile-time error if `T` contains non-Jsonable members.
|
|
6
|
+
* Used to constrain a type `T` to types that are serializable as JSON.
|
|
7
|
+
* Produces a compile-time error if `T` contains non-Jsonable members.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Note that this does NOT prevent using of values with non-json compatible data,
|
|
11
|
+
* 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
|
|
13
|
+
* interface into this function,
|
|
14
|
+
* that could actually be a class with lots on non-json compatible fields and methods.
|
|
13
15
|
*
|
|
14
|
-
* Important: `T extends Jsonable<T>` is
|
|
15
|
-
*
|
|
16
|
+
* 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.
|
|
16
18
|
*
|
|
17
19
|
* The optional 'TReplaced' parameter may be used to permit additional leaf types to support
|
|
18
20
|
* situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).
|
|
19
21
|
*
|
|
20
|
-
* Note that `Jsonable<T>` does not protect against the following pitfalls when serializing
|
|
21
|
-
* `undefined` and non-finite numbers:
|
|
22
|
+
* Note that `Jsonable<T>` does not protect against the following pitfalls when serializing with JSON.stringify():
|
|
22
23
|
*
|
|
23
24
|
* - `undefined` properties on objects are omitted (i.e., properties become undefined instead of equal to undefined).
|
|
24
25
|
* - When `undefined` appears as the root object or as an array element it is coerced to `null`.
|
|
25
26
|
* - Non-finite numbers (`NaN`, `+/-Infinity`) are also coerced to `null`.
|
|
27
|
+
* - prototypes and non-enumerable properties are lost.
|
|
26
28
|
*
|
|
27
29
|
* Also, `Jsonable<T>` does not prevent the construction of circular references.
|
|
30
|
+
*
|
|
31
|
+
* Using `Jsonable` (with no type parameters) or `Jsonable<any>` is just a type alias for `any`
|
|
32
|
+
* and should not be used if type safety is desired.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* Typical usage:
|
|
36
|
+
* ```ts
|
|
37
|
+
* function foo<T>(value: Jsonable<T>) { ... }
|
|
38
|
+
* ```
|
|
28
39
|
*/
|
|
29
40
|
export declare type Jsonable<T = any, TReplaced = void> = T extends undefined | null | boolean | number | string | TReplaced ? T : Extract<T, Function> extends never ? {
|
|
30
41
|
[K in keyof T]: Extract<K, symbol> extends never ? Jsonable<T[K], TReplaced> : never;
|
package/dist/jsonable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonable.d.ts","sourceRoot":"","sources":["../src/jsonable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH
|
|
1
|
+
{"version":3,"file":"jsonable.d.ts","sourceRoot":"","sources":["../src/jsonable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,oBAAY,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,GAAG,IAAI,IAC1C,CAAC,SAAS,SAAS,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAC5D,CAAC,GAED,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,KAAK,GAC9B;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,KAAK,GAC1C,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GACzB,KAAK;CACd,GACC,KAAK,CAAC"}
|
package/dist/jsonable.js.map
CHANGED
|
@@ -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
|
|
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 * - When `undefined` appears as the root object or as an array element it is coerced to `null`.\n * - Non-finite numbers (`NaN`, `+/-Infinity`) are also coerced to `null`.\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\n * Typical usage:\n * ```ts\n * function foo<T>(value: Jsonable<T>) { ... }\n * ```\n */\nexport type Jsonable<T = any, TReplaced = void> =\n T extends undefined | null | boolean | number | string | TReplaced\n ? T\n // eslint-disable-next-line @typescript-eslint/ban-types\n : Extract<T, Function> extends never\n ? {\n [K in keyof T]: Extract<K, symbol> extends never\n ? Jsonable<T[K], TReplaced>\n : never\n }\n : never;\n"]}
|
package/dist/serializable.d.ts
CHANGED
|
@@ -8,16 +8,18 @@ import { Jsonable } from "./jsonable";
|
|
|
8
8
|
* Used to constrain a type 'T' to types that Fluid can intrinsically serialize. Produces a
|
|
9
9
|
* compile-time error if `T` contains non-serializable members.
|
|
10
10
|
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* See Jsonable for caveats regarding serialization of `undefined`, non-finite numbers,
|
|
13
|
+
* and circular references.
|
|
14
|
+
*
|
|
15
|
+
* Important: `T extends Serializable<T>` is generally incorrect.
|
|
16
|
+
* (Any value of `T` extends the serializable subset of itself.)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
11
19
|
* Typical usage:
|
|
12
|
-
* ```
|
|
20
|
+
* ```typescript
|
|
13
21
|
* function serialize<T>(value: Serializable<T>) { ... }
|
|
14
22
|
* ```
|
|
15
|
-
*
|
|
16
|
-
* Important: `T extends Serializable<T>` is generally incorrect. (Any value of `T`
|
|
17
|
-
* extends the serializable subset of itself.)
|
|
18
|
-
*
|
|
19
|
-
* See Jsonable for caveats regarding serialization of `undefined`, non-finite numbers,
|
|
20
|
-
* and circular references.
|
|
21
23
|
*/
|
|
22
24
|
export declare type Serializable<T = any> = Jsonable<T, IFluidHandle>;
|
|
23
25
|
//# 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
|
|
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;;;;;;;;;;;;;;;;GAgBG;AACH,oBAAY,YAAY,CAAC,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC"}
|
package/dist/serializable.js.map
CHANGED
|
@@ -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 *
|
|
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\n * Typical usage:\n * ```typescript\n * function serialize<T>(value: Serializable<T>) { ... }\n * ```\n */\nexport type Serializable<T = any> = Jsonable<T, IFluidHandle>;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/datastore-definitions",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Fluid data store definitions",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
36
36
|
"@fluidframework/common-utils": "^0.32.1",
|
|
37
|
-
"@fluidframework/container-definitions": "1.2.
|
|
38
|
-
"@fluidframework/core-interfaces": "1.2.
|
|
37
|
+
"@fluidframework/container-definitions": "^1.2.1",
|
|
38
|
+
"@fluidframework/core-interfaces": "^1.2.1",
|
|
39
39
|
"@fluidframework/protocol-definitions": "^0.1028.2000",
|
|
40
|
-
"@fluidframework/runtime-definitions": "1.2.
|
|
40
|
+
"@fluidframework/runtime-definitions": "^1.2.1",
|
|
41
41
|
"@types/node": "^14.18.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@fluidframework/build-common": "^0.24.0",
|
|
45
|
-
"@fluidframework/datastore-definitions-previous": "npm:@fluidframework/datastore-definitions@1.
|
|
45
|
+
"@fluidframework/datastore-definitions-previous": "npm:@fluidframework/datastore-definitions@1.2.0",
|
|
46
46
|
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
47
47
|
"@microsoft/api-extractor": "^7.22.2",
|
|
48
48
|
"@rushstack/eslint-config": "^2.5.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"typescript-formatter": "7.1.0"
|
|
55
55
|
},
|
|
56
56
|
"typeValidation": {
|
|
57
|
-
"version": "1.2.
|
|
57
|
+
"version": "1.2.1",
|
|
58
58
|
"broken": {}
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/jsonable.ts
CHANGED
|
@@ -4,28 +4,39 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Used to constrain a type `T` to types that are serializable as JSON.
|
|
8
|
-
* compile-time error if `T` contains non-Jsonable members.
|
|
7
|
+
* Used to constrain a type `T` to types that are serializable as JSON.
|
|
8
|
+
* Produces a compile-time error if `T` contains non-Jsonable members.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Note that this does NOT prevent using of values with non-json compatible data,
|
|
12
|
+
* 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
|
|
14
|
+
* interface into this function,
|
|
15
|
+
* that could actually be a class with lots on non-json compatible fields and methods.
|
|
14
16
|
*
|
|
15
|
-
* Important: `T extends Jsonable<T>` is
|
|
16
|
-
*
|
|
17
|
+
* 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.
|
|
17
19
|
*
|
|
18
20
|
* The optional 'TReplaced' parameter may be used to permit additional leaf types to support
|
|
19
21
|
* situations where a `replacer` is used to handle special values (e.g., `Jsonable<{ x: IFluidHandle }, IFluidHandle>`).
|
|
20
22
|
*
|
|
21
|
-
* Note that `Jsonable<T>` does not protect against the following pitfalls when serializing
|
|
22
|
-
* `undefined` and non-finite numbers:
|
|
23
|
+
* Note that `Jsonable<T>` does not protect against the following pitfalls when serializing with JSON.stringify():
|
|
23
24
|
*
|
|
24
25
|
* - `undefined` properties on objects are omitted (i.e., properties become undefined instead of equal to undefined).
|
|
25
26
|
* - When `undefined` appears as the root object or as an array element it is coerced to `null`.
|
|
26
27
|
* - Non-finite numbers (`NaN`, `+/-Infinity`) are also coerced to `null`.
|
|
28
|
+
* - prototypes and non-enumerable properties are lost.
|
|
27
29
|
*
|
|
28
30
|
* Also, `Jsonable<T>` does not prevent the construction of circular references.
|
|
31
|
+
*
|
|
32
|
+
* Using `Jsonable` (with no type parameters) or `Jsonable<any>` is just a type alias for `any`
|
|
33
|
+
* and should not be used if type safety is desired.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* Typical usage:
|
|
37
|
+
* ```ts
|
|
38
|
+
* function foo<T>(value: Jsonable<T>) { ... }
|
|
39
|
+
* ```
|
|
29
40
|
*/
|
|
30
41
|
export type Jsonable<T = any, TReplaced = void> =
|
|
31
42
|
T extends undefined | null | boolean | number | string | TReplaced
|
package/src/serializable.ts
CHANGED
|
@@ -10,15 +10,17 @@ import { Jsonable } from "./jsonable";
|
|
|
10
10
|
* Used to constrain a type 'T' to types that Fluid can intrinsically serialize. Produces a
|
|
11
11
|
* compile-time error if `T` contains non-serializable members.
|
|
12
12
|
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* See Jsonable for caveats regarding serialization of `undefined`, non-finite numbers,
|
|
15
|
+
* and circular references.
|
|
16
|
+
*
|
|
17
|
+
* Important: `T extends Serializable<T>` is generally incorrect.
|
|
18
|
+
* (Any value of `T` extends the serializable subset of itself.)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
13
21
|
* Typical usage:
|
|
14
|
-
* ```
|
|
22
|
+
* ```typescript
|
|
15
23
|
* function serialize<T>(value: Serializable<T>) { ... }
|
|
16
24
|
* ```
|
|
17
|
-
*
|
|
18
|
-
* Important: `T extends Serializable<T>` is generally incorrect. (Any value of `T`
|
|
19
|
-
* extends the serializable subset of itself.)
|
|
20
|
-
*
|
|
21
|
-
* See Jsonable for caveats regarding serialization of `undefined`, non-finite numbers,
|
|
22
|
-
* and circular references.
|
|
23
25
|
*/
|
|
24
26
|
export type Serializable<T = any> = Jsonable<T, IFluidHandle>;
|