tinybase 8.0.0-beta.2 → 8.0.0-beta.3
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/@types/_internal/store/with-schemas/index.d.ts +2 -2
- package/@types/common/index.d.ts +22 -0
- package/@types/common/with-schemas/index.d.ts +22 -0
- package/@types/middleware/index.d.ts +11 -6
- package/@types/middleware/with-schemas/index.d.ts +11 -6
- package/@types/store/index.d.ts +132 -79
- package/@types/store/with-schemas/index.d.ts +137 -81
- package/checkpoints/index.js +2 -8
- package/checkpoints/with-schemas/index.js +2 -8
- package/index.js +211 -140
- package/mergeable-store/index.js +231 -153
- package/mergeable-store/with-schemas/index.js +231 -153
- package/middleware/index.js +1 -1
- package/middleware/with-schemas/index.js +1 -1
- package/min/checkpoints/index.js +1 -1
- package/min/checkpoints/index.js.gz +0 -0
- package/min/checkpoints/with-schemas/index.js +1 -1
- package/min/checkpoints/with-schemas/index.js.gz +0 -0
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/middleware/index.js +1 -1
- package/min/middleware/index.js.gz +0 -0
- package/min/middleware/with-schemas/index.js +1 -1
- package/min/middleware/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/persisters/index.js +1 -1
- package/min/persisters/index.js.gz +0 -0
- package/min/persisters/persister-automerge/index.js +1 -1
- package/min/persisters/persister-automerge/index.js.gz +0 -0
- package/min/persisters/persister-automerge/with-schemas/index.js +1 -1
- package/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-browser/index.js +1 -1
- package/min/persisters/persister-browser/index.js.gz +0 -0
- package/min/persisters/persister-browser/with-schemas/index.js +1 -1
- package/min/persisters/persister-browser/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/index.js.gz +0 -0
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js +1 -1
- package/min/persisters/persister-durable-object-storage/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/index.js +1 -1
- package/min/persisters/persister-electric-sql/index.js.gz +0 -0
- package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
- package/min/persisters/persister-electric-sql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-file/index.js +1 -1
- package/min/persisters/persister-file/index.js.gz +0 -0
- package/min/persisters/persister-file/with-schemas/index.js +1 -1
- package/min/persisters/persister-file/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/index.js +1 -1
- package/min/persisters/persister-indexed-db/index.js.gz +0 -0
- package/min/persisters/persister-indexed-db/with-schemas/index.js +1 -1
- package/min/persisters/persister-indexed-db/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-libsql/index.js +1 -1
- package/min/persisters/persister-libsql/index.js.gz +0 -0
- package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
- package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-partykit-client/index.js +1 -1
- package/min/persisters/persister-partykit-client/index.js.gz +0 -0
- package/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
- package/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-pglite/index.js +1 -1
- package/min/persisters/persister-pglite/index.js.gz +0 -0
- package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
- package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-postgres/index.js +1 -1
- package/min/persisters/persister-postgres/index.js.gz +0 -0
- package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
- package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-powersync/index.js +1 -1
- package/min/persisters/persister-powersync/index.js.gz +0 -0
- package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
- package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/index.js +1 -1
- package/min/persisters/persister-react-native-mmkv/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js +1 -1
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-remote/index.js +1 -1
- package/min/persisters/persister-remote/index.js.gz +0 -0
- package/min/persisters/persister-remote/with-schemas/index.js +1 -1
- package/min/persisters/persister-remote/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/index.js +1 -1
- package/min/persisters/persister-sqlite3/index.js.gz +0 -0
- package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
- package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-yjs/index.js +1 -1
- package/min/persisters/persister-yjs/index.js.gz +0 -0
- package/min/persisters/persister-yjs/with-schemas/index.js +1 -1
- package/min/persisters/persister-yjs/with-schemas/index.js.gz +0 -0
- package/min/persisters/with-schemas/index.js +1 -1
- package/min/persisters/with-schemas/index.js.gz +0 -0
- package/min/queries/index.js +1 -1
- package/min/queries/index.js.gz +0 -0
- package/min/queries/with-schemas/index.js +1 -1
- package/min/queries/with-schemas/index.js.gz +0 -0
- package/min/schematizers/index.js +1 -1
- package/min/schematizers/index.js.gz +0 -0
- package/min/schematizers/schematizer-arktype/index.js +1 -1
- package/min/schematizers/schematizer-arktype/index.js.gz +0 -0
- package/min/schematizers/schematizer-arktype/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-arktype/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-effect/index.js +1 -1
- package/min/schematizers/schematizer-effect/index.js.gz +0 -0
- package/min/schematizers/schematizer-effect/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-effect/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-typebox/index.js +1 -1
- package/min/schematizers/schematizer-typebox/index.js.gz +0 -0
- package/min/schematizers/schematizer-typebox/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-typebox/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-valibot/index.js +1 -1
- package/min/schematizers/schematizer-valibot/index.js.gz +0 -0
- package/min/schematizers/schematizer-valibot/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-valibot/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-yup/index.js +1 -1
- package/min/schematizers/schematizer-yup/index.js.gz +0 -0
- package/min/schematizers/schematizer-yup/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-yup/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-zod/index.js +1 -1
- package/min/schematizers/schematizer-zod/index.js.gz +0 -0
- package/min/schematizers/schematizer-zod/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-zod/with-schemas/index.js.gz +0 -0
- package/min/schematizers/with-schemas/index.js +1 -1
- package/min/schematizers/with-schemas/index.js.gz +0 -0
- package/min/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/index.js +1 -1
- package/min/synchronizers/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/index.js +1 -1
- package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/with-schemas/index.js +1 -1
- package/min/synchronizers/with-schemas/index.js.gz +0 -0
- package/min/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom/index.js +1 -1
- package/min/ui-react-dom/index.js.gz +0 -0
- package/min/ui-react-dom/with-schemas/index.js +1 -1
- package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +296 -151
- package/omni/with-schemas/index.js +296 -151
- package/package.json +7 -7
- package/persisters/index.js +5 -5
- package/persisters/persister-automerge/index.js +5 -5
- package/persisters/persister-automerge/with-schemas/index.js +5 -5
- package/persisters/persister-browser/index.js +5 -5
- package/persisters/persister-browser/with-schemas/index.js +5 -5
- package/persisters/persister-cr-sqlite-wasm/index.js +5 -5
- package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +5 -5
- package/persisters/persister-durable-object-sql-storage/index.js +5 -5
- package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +5 -5
- package/persisters/persister-durable-object-storage/index.js +5 -5
- package/persisters/persister-durable-object-storage/with-schemas/index.js +5 -5
- package/persisters/persister-electric-sql/index.js +5 -5
- package/persisters/persister-electric-sql/with-schemas/index.js +5 -5
- package/persisters/persister-expo-sqlite/index.js +5 -5
- package/persisters/persister-expo-sqlite/with-schemas/index.js +5 -5
- package/persisters/persister-file/index.js +5 -5
- package/persisters/persister-file/with-schemas/index.js +5 -5
- package/persisters/persister-indexed-db/index.js +5 -5
- package/persisters/persister-indexed-db/with-schemas/index.js +5 -5
- package/persisters/persister-libsql/index.js +5 -5
- package/persisters/persister-libsql/with-schemas/index.js +5 -5
- package/persisters/persister-partykit-client/index.js +5 -5
- package/persisters/persister-partykit-client/with-schemas/index.js +5 -5
- package/persisters/persister-pglite/index.js +5 -5
- package/persisters/persister-pglite/with-schemas/index.js +5 -5
- package/persisters/persister-postgres/index.js +5 -5
- package/persisters/persister-postgres/with-schemas/index.js +5 -5
- package/persisters/persister-powersync/index.js +5 -5
- package/persisters/persister-powersync/with-schemas/index.js +5 -5
- package/persisters/persister-react-native-mmkv/index.js +5 -5
- package/persisters/persister-react-native-mmkv/with-schemas/index.js +5 -5
- package/persisters/persister-react-native-sqlite/index.js +5 -5
- package/persisters/persister-react-native-sqlite/with-schemas/index.js +5 -5
- package/persisters/persister-remote/index.js +5 -5
- package/persisters/persister-remote/with-schemas/index.js +5 -5
- package/persisters/persister-sqlite-bun/index.js +5 -5
- package/persisters/persister-sqlite-bun/with-schemas/index.js +5 -5
- package/persisters/persister-sqlite-wasm/index.js +5 -5
- package/persisters/persister-sqlite-wasm/with-schemas/index.js +5 -5
- package/persisters/persister-sqlite3/index.js +5 -5
- package/persisters/persister-sqlite3/with-schemas/index.js +5 -5
- package/persisters/persister-yjs/index.js +5 -5
- package/persisters/persister-yjs/with-schemas/index.js +5 -5
- package/persisters/with-schemas/index.js +5 -5
- package/queries/index.js +11 -4
- package/queries/with-schemas/index.js +11 -4
- package/readme.md +3 -3
- package/releases.md +1 -1
- package/schematizers/index.js +9 -1
- package/schematizers/schematizer-arktype/index.js +16 -1
- package/schematizers/schematizer-arktype/with-schemas/index.js +16 -1
- package/schematizers/schematizer-effect/index.js +15 -2
- package/schematizers/schematizer-effect/with-schemas/index.js +15 -2
- package/schematizers/schematizer-typebox/index.js +9 -1
- package/schematizers/schematizer-typebox/with-schemas/index.js +9 -1
- package/schematizers/schematizer-valibot/index.js +17 -2
- package/schematizers/schematizer-valibot/with-schemas/index.js +17 -2
- package/schematizers/schematizer-yup/index.js +9 -1
- package/schematizers/schematizer-yup/with-schemas/index.js +9 -1
- package/schematizers/schematizer-zod/index.js +13 -2
- package/schematizers/schematizer-zod/with-schemas/index.js +13 -2
- package/schematizers/with-schemas/index.js +9 -1
- package/store/index.js +155 -101
- package/store/with-schemas/index.js +155 -101
- package/synchronizers/index.js +5 -5
- package/synchronizers/synchronizer-broadcast-channel/index.js +5 -5
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +5 -5
- package/synchronizers/synchronizer-local/index.js +5 -5
- package/synchronizers/synchronizer-local/with-schemas/index.js +5 -5
- package/synchronizers/synchronizer-ws-client/index.js +5 -5
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +5 -5
- package/synchronizers/synchronizer-ws-server/index.js +5 -5
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +5 -5
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +5 -5
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +5 -5
- package/synchronizers/with-schemas/index.js +5 -5
- package/ui-react/index.js +6 -0
- package/ui-react/with-schemas/index.js +6 -0
- package/ui-react-dom/index.js +91 -6
- package/ui-react-dom/with-schemas/index.js +91 -6
- package/ui-react-inspector/index.js +208 -81
- package/ui-react-inspector/with-schemas/index.js +208 -81
- package/with-schemas/index.js +211 -140
|
@@ -48,7 +48,7 @@ export type CellIsDefaultedFromSchema<
|
|
|
48
48
|
Then,
|
|
49
49
|
Else,
|
|
50
50
|
> = Schema[TableId][CellId] extends {
|
|
51
|
-
default:
|
|
51
|
+
default: infer _;
|
|
52
52
|
}
|
|
53
53
|
? Then
|
|
54
54
|
: Else;
|
|
@@ -83,7 +83,7 @@ export type ValueIsDefaultedFromSchema<
|
|
|
83
83
|
Then,
|
|
84
84
|
Else,
|
|
85
85
|
> = Schema[ValueId] extends {
|
|
86
|
-
default:
|
|
86
|
+
default: infer _;
|
|
87
87
|
}
|
|
88
88
|
? Then
|
|
89
89
|
: Else;
|
package/@types/common/index.d.ts
CHANGED
|
@@ -16,6 +16,28 @@ import type {CellOrUndefined, ValueOrUndefined} from '../store/index.d.ts';
|
|
|
16
16
|
*/
|
|
17
17
|
export type Json = string;
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* The AnyObject type is a simple alias for a plain object with string keys and
|
|
21
|
+
* unknown values.
|
|
22
|
+
*
|
|
23
|
+
* It is used to indicate that the value should be considered to be a plain
|
|
24
|
+
* JavaScript object, as can be stored in a Cell or Value with the `object`
|
|
25
|
+
* schema type.
|
|
26
|
+
* @category General
|
|
27
|
+
* @since v8.0.0
|
|
28
|
+
*/
|
|
29
|
+
export type AnyObject = {[key: string]: unknown};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The AnyArray type is a simple alias for an array with unknown values.
|
|
33
|
+
*
|
|
34
|
+
* It is used to indicate that the value should be considered to be a JavaScript
|
|
35
|
+
* array, as can be stored in a Cell or Value with the `array` schema type.
|
|
36
|
+
* @category General
|
|
37
|
+
* @since v8.0.0
|
|
38
|
+
*/
|
|
39
|
+
export type AnyArray = unknown[] | readonly unknown[];
|
|
40
|
+
|
|
19
41
|
/**
|
|
20
42
|
* The Ids type is a simple alias for an array of strings, but is used to
|
|
21
43
|
* indicate that the strings should be considered to be the keys of objects
|
|
@@ -28,6 +28,28 @@ import type {
|
|
|
28
28
|
*/
|
|
29
29
|
export type Json = string;
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* The AnyObject type is a simple alias for a plain object with string keys and
|
|
33
|
+
* unknown values.
|
|
34
|
+
*
|
|
35
|
+
* It is used to indicate that the value should be considered to be a plain
|
|
36
|
+
* JavaScript object, as can be stored in a Cell or Value with the `object`
|
|
37
|
+
* schema type.
|
|
38
|
+
* @category General
|
|
39
|
+
* @since v8.0.0
|
|
40
|
+
*/
|
|
41
|
+
export type AnyObject = {[key: string]: unknown};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The AnyArray type is a simple alias for an array with unknown values.
|
|
45
|
+
*
|
|
46
|
+
* It is used to indicate that the value should be considered to be a JavaScript
|
|
47
|
+
* array, as can be stored in a Cell or Value with the `array` schema type.
|
|
48
|
+
* @category General
|
|
49
|
+
* @since v8.0.0
|
|
50
|
+
*/
|
|
51
|
+
export type AnyArray = unknown[] | readonly unknown[];
|
|
52
|
+
|
|
31
53
|
/**
|
|
32
54
|
* The Ids type is a simple alias for an array of strings, but is used to
|
|
33
55
|
* indicate that the strings should be considered to be the keys of objects
|
|
@@ -1072,8 +1072,10 @@ export interface Middleware {
|
|
|
1072
1072
|
* const store = createStore();
|
|
1073
1073
|
* const middleware = createMiddleware(store);
|
|
1074
1074
|
*
|
|
1075
|
-
* middleware.addDidSetRowCallback(
|
|
1076
|
-
* '
|
|
1075
|
+
* middleware.addDidSetRowCallback(
|
|
1076
|
+
* 'pets',
|
|
1077
|
+
* (_tableId, _rowId, oldRow, newRow) =>
|
|
1078
|
+
* 'species' in newRow ? newRow : oldRow,
|
|
1077
1079
|
* );
|
|
1078
1080
|
*
|
|
1079
1081
|
* store.setRow('pets', 'fido', {species: 'dog', name: 'Fido'});
|
|
@@ -1097,10 +1099,13 @@ export interface Middleware {
|
|
|
1097
1099
|
* const middleware = createMiddleware(store);
|
|
1098
1100
|
*
|
|
1099
1101
|
* const seen = [];
|
|
1100
|
-
* middleware.addDidSetRowCallback(
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
* });
|
|
1102
|
+
* middleware.addDidSetRowCallback(
|
|
1103
|
+
* 'pets',
|
|
1104
|
+
* (_tableId, rowId, oldRow, newRow) => {
|
|
1105
|
+
* seen.push({rowId, oldRow: {...oldRow}, newRow: {...newRow}});
|
|
1106
|
+
* return newRow;
|
|
1107
|
+
* },
|
|
1108
|
+
* );
|
|
1104
1109
|
*
|
|
1105
1110
|
* store.transaction(() => {
|
|
1106
1111
|
* store.setCell('pets', 'fido', 'name', 'Fido');
|
|
@@ -1375,8 +1375,10 @@ export interface Middleware<in out Schemas extends OptionalSchemas> {
|
|
|
1375
1375
|
* const store = createStore();
|
|
1376
1376
|
* const middleware = createMiddleware(store);
|
|
1377
1377
|
*
|
|
1378
|
-
* middleware.addDidSetRowCallback(
|
|
1379
|
-
* '
|
|
1378
|
+
* middleware.addDidSetRowCallback(
|
|
1379
|
+
* 'pets',
|
|
1380
|
+
* (_tableId, _rowId, oldRow, newRow) =>
|
|
1381
|
+
* 'species' in newRow ? newRow : oldRow,
|
|
1380
1382
|
* );
|
|
1381
1383
|
*
|
|
1382
1384
|
* store.setRow('pets', 'fido', {species: 'dog', name: 'Fido'});
|
|
@@ -1400,10 +1402,13 @@ export interface Middleware<in out Schemas extends OptionalSchemas> {
|
|
|
1400
1402
|
* const middleware = createMiddleware(store);
|
|
1401
1403
|
*
|
|
1402
1404
|
* const seen = [];
|
|
1403
|
-
* middleware.addDidSetRowCallback(
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1406
|
-
* });
|
|
1405
|
+
* middleware.addDidSetRowCallback(
|
|
1406
|
+
* 'pets',
|
|
1407
|
+
* (_tableId, rowId, oldRow, newRow) => {
|
|
1408
|
+
* seen.push({rowId, oldRow: {...oldRow}, newRow: {...newRow}});
|
|
1409
|
+
* return newRow;
|
|
1410
|
+
* },
|
|
1411
|
+
* );
|
|
1407
1412
|
*
|
|
1408
1413
|
* store.transaction(() => {
|
|
1409
1414
|
* store.setCell('pets', 'fido', 'name', 'Fido');
|
package/@types/store/index.d.ts
CHANGED
|
@@ -11,7 +11,14 @@
|
|
|
11
11
|
* @since v1.0.0
|
|
12
12
|
*/
|
|
13
13
|
import type {StoreAlias} from '../_internal/store/index.d.ts';
|
|
14
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
AnyArray,
|
|
16
|
+
AnyObject,
|
|
17
|
+
Id,
|
|
18
|
+
IdOrNull,
|
|
19
|
+
Ids,
|
|
20
|
+
Json,
|
|
21
|
+
} from '../common/index.d.ts';
|
|
15
22
|
|
|
16
23
|
/**
|
|
17
24
|
* The TablesSchema type describes the tabular structure of a Store in terms of
|
|
@@ -44,9 +51,13 @@ export type TablesSchema = {[tableId: Id]: {[cellId: Id]: CellSchema}};
|
|
|
44
51
|
* The CellSchema type describes what values are allowed for each Cell in a
|
|
45
52
|
* Table.
|
|
46
53
|
*
|
|
47
|
-
* A CellSchema specifies the type of the Cell (`string`, `boolean`, `number
|
|
48
|
-
*
|
|
49
|
-
* value is not specified.
|
|
54
|
+
* A CellSchema specifies the type of the Cell (`string`, `boolean`, `number`,
|
|
55
|
+
* `null` since v7.0, or `object` or `array` since v8.0), and what the default
|
|
56
|
+
* value can be when an explicit value is not specified.
|
|
57
|
+
*
|
|
58
|
+
* For `object` and `array` types, TinyBase automatically serializes values to
|
|
59
|
+
* and from JSON when storing and retrieving them. This means you can set an
|
|
60
|
+
* object or array Cell directly, and get back the same structure.
|
|
50
61
|
*
|
|
51
62
|
* If a default value is provided (and its type is correct), you can be certain
|
|
52
63
|
* that that Cell will always be present in a Row.
|
|
@@ -66,13 +77,27 @@ export type TablesSchema = {[tableId: Id]: {[cellId: Id]: CellSchema}};
|
|
|
66
77
|
* default: false,
|
|
67
78
|
* };
|
|
68
79
|
* ```
|
|
80
|
+
* @example
|
|
81
|
+
* When applied to a Store, this CellSchema allows an object Cell containing
|
|
82
|
+
* arbitrary data, defaulting to an empty object.
|
|
83
|
+
*
|
|
84
|
+
* ```js
|
|
85
|
+
* import type {CellSchema} from 'tinybase';
|
|
86
|
+
*
|
|
87
|
+
* export const tagsCell: CellSchema = {
|
|
88
|
+
* type: 'object',
|
|
89
|
+
* default: {},
|
|
90
|
+
* };
|
|
91
|
+
* ```
|
|
69
92
|
* @category Schema
|
|
70
93
|
* @since v1.0.0
|
|
71
94
|
*/
|
|
72
95
|
export type CellSchema =
|
|
73
96
|
| {type: 'string'; default?: string | null; allowNull?: boolean}
|
|
74
97
|
| {type: 'number'; default?: number | null; allowNull?: boolean}
|
|
75
|
-
| {type: 'boolean'; default?: boolean | null; allowNull?: boolean}
|
|
98
|
+
| {type: 'boolean'; default?: boolean | null; allowNull?: boolean}
|
|
99
|
+
| {type: 'object'; default?: AnyObject; allowNull?: boolean}
|
|
100
|
+
| {type: 'array'; default?: AnyArray; allowNull?: boolean};
|
|
76
101
|
|
|
77
102
|
/**
|
|
78
103
|
* The ValuesSchema type describes the keyed Values that can be set in a Store
|
|
@@ -100,9 +125,12 @@ export type ValuesSchema = {[valueId: Id]: ValueSchema};
|
|
|
100
125
|
* The ValueSchema type describes what values are allowed for keyed Values in a
|
|
101
126
|
* Store.
|
|
102
127
|
*
|
|
103
|
-
* A ValueSchema specifies the type of the Value (`string`, `boolean`, `number
|
|
104
|
-
*
|
|
105
|
-
* value is not specified.
|
|
128
|
+
* A ValueSchema specifies the type of the Value (`string`, `boolean`, `number`,
|
|
129
|
+
* `null` since v7.0, or `object` or `array` since v8.0), and what the default
|
|
130
|
+
* value can be when an explicit value is not specified.
|
|
131
|
+
*
|
|
132
|
+
* For `object` and `array` types, TinyBase automatically serializes values to
|
|
133
|
+
* and from JSON when storing and retrieving them.
|
|
106
134
|
*
|
|
107
135
|
* If a default value is provided (and its type is correct), you can be certain
|
|
108
136
|
* that the Value will always be present in a Store.
|
|
@@ -122,13 +150,27 @@ export type ValuesSchema = {[valueId: Id]: ValueSchema};
|
|
|
122
150
|
* default: false,
|
|
123
151
|
* };
|
|
124
152
|
* ```
|
|
153
|
+
* @example
|
|
154
|
+
* When applied to a Store, this ValueSchema allows an array Value containing
|
|
155
|
+
* a list of items, defaulting to an empty array.
|
|
156
|
+
*
|
|
157
|
+
* ```js
|
|
158
|
+
* import type {ValueSchema} from 'tinybase';
|
|
159
|
+
*
|
|
160
|
+
* export const cartItems: ValueSchema = {
|
|
161
|
+
* type: 'array',
|
|
162
|
+
* default: [],
|
|
163
|
+
* };
|
|
164
|
+
* ```
|
|
125
165
|
* @category Schema
|
|
126
166
|
* @since v3.0.0
|
|
127
167
|
*/
|
|
128
168
|
export type ValueSchema =
|
|
129
169
|
| {type: 'string'; default?: string | null; allowNull?: boolean}
|
|
130
170
|
| {type: 'number'; default?: number | null; allowNull?: boolean}
|
|
131
|
-
| {type: 'boolean'; default?: boolean | null; allowNull?: boolean}
|
|
171
|
+
| {type: 'boolean'; default?: boolean | null; allowNull?: boolean}
|
|
172
|
+
| {type: 'object'; default?: AnyObject; allowNull?: boolean}
|
|
173
|
+
| {type: 'array'; default?: AnyArray; allowNull?: boolean};
|
|
132
174
|
|
|
133
175
|
/**
|
|
134
176
|
* The NoTablesSchema type is a TablesSchema-like type for when one has not been
|
|
@@ -280,7 +322,8 @@ export type Row = {[cellId: Id]: Cell};
|
|
|
280
322
|
*
|
|
281
323
|
* A Cell is used when setting a cell with the setCell method, and when getting
|
|
282
324
|
* it back out again with the getCell method. A Cell is a JavaScript string,
|
|
283
|
-
* number, boolean
|
|
325
|
+
* number, boolean, or null (since v7.0), or a plain JavaScript object or array
|
|
326
|
+
* (since v8.0).
|
|
284
327
|
* @example
|
|
285
328
|
* ```js
|
|
286
329
|
* import type {Cell} from 'tinybase';
|
|
@@ -290,7 +333,7 @@ export type Row = {[cellId: Id]: Cell};
|
|
|
290
333
|
* @category Store
|
|
291
334
|
* @since v1.0.0
|
|
292
335
|
*/
|
|
293
|
-
export type Cell = string | number | boolean | null;
|
|
336
|
+
export type Cell = string | number | boolean | null | AnyObject | AnyArray;
|
|
294
337
|
|
|
295
338
|
/**
|
|
296
339
|
* The CellOrUndefined type is a data structure representing the data in a
|
|
@@ -329,7 +372,8 @@ export type Values = {[valueId: Id]: Value};
|
|
|
329
372
|
*
|
|
330
373
|
* A Value is used when setting a value with the setValue method, and when
|
|
331
374
|
* getting it back out again with the getValue method. A Value is a JavaScript
|
|
332
|
-
* string, number, boolean
|
|
375
|
+
* string, number, boolean, or null (since v7.0), or a plain JavaScript object
|
|
376
|
+
* or array (since v8.0).
|
|
333
377
|
* @example
|
|
334
378
|
* ```js
|
|
335
379
|
* import type {Value} from 'tinybase';
|
|
@@ -339,7 +383,7 @@ export type Values = {[valueId: Id]: Value};
|
|
|
339
383
|
* @category Store
|
|
340
384
|
* @since v3.0.0
|
|
341
385
|
*/
|
|
342
|
-
export type Value = string | number | boolean | null;
|
|
386
|
+
export type Value = string | number | boolean | null | AnyObject | AnyArray;
|
|
343
387
|
|
|
344
388
|
/**
|
|
345
389
|
* The ValueOrUndefined type is a data structure representing the data in a
|
|
@@ -1389,8 +1433,8 @@ export type ChangedValues = {
|
|
|
1389
1433
|
* transaction, primarily used so that you can indicate whether the transaction
|
|
1390
1434
|
* should be rolled back.
|
|
1391
1435
|
*
|
|
1392
|
-
* It provides both the old and new Values in a two-part array. These
|
|
1393
|
-
*
|
|
1436
|
+
* It provides both the old and new Values in a two-part array. These describe
|
|
1437
|
+
* the state of the changed Value in the Store at the _start_ of the
|
|
1394
1438
|
* transaction, and by the _end_ of the transaction.
|
|
1395
1439
|
*
|
|
1396
1440
|
* Hence, an `undefined` value for the first item in the array means that the
|
|
@@ -1704,14 +1748,17 @@ export type StoreListenerStats = {
|
|
|
1704
1748
|
*
|
|
1705
1749
|
* The keyed value support is best thought of as a flat JavaScript object. The
|
|
1706
1750
|
* Store contains a number of Value objects, each with a unique ID, and which is
|
|
1707
|
-
* a string, boolean, number
|
|
1751
|
+
* a string, boolean, number, null (since v7.0), or a plain JavaScript object or
|
|
1752
|
+
* array (since v8.0).
|
|
1708
1753
|
*
|
|
1709
1754
|
* ```json
|
|
1710
|
-
* {
|
|
1711
|
-
* "value1": "one",
|
|
1712
|
-
* "value2": true,
|
|
1713
|
-
* "value3": 3,
|
|
1714
|
-
* "value4": null,
|
|
1755
|
+
* { // Store
|
|
1756
|
+
* "value1": "one", // Value (string)
|
|
1757
|
+
* "value2": true, // Value (boolean)
|
|
1758
|
+
* "value3": 3, // Value (number)
|
|
1759
|
+
* "value4": null, // Value (null since v7.0)
|
|
1760
|
+
* "value5": {"x": 1}, // Value (object since v8.0)
|
|
1761
|
+
* "value6": [1, 2, 3], // Value (array since v8.0)
|
|
1715
1762
|
* ...
|
|
1716
1763
|
* }
|
|
1717
1764
|
* ```
|
|
@@ -1728,7 +1775,8 @@ export type StoreListenerStats = {
|
|
|
1728
1775
|
* - Each Table contains a number of Row objects.
|
|
1729
1776
|
* - Each Row contains a number of Cell objects.
|
|
1730
1777
|
*
|
|
1731
|
-
* A Cell is a string, boolean, number
|
|
1778
|
+
* A Cell is a string, boolean, number, null (since v7.0), or a plain JavaScript
|
|
1779
|
+
* object or array (since v8.0).
|
|
1732
1780
|
*
|
|
1733
1781
|
* The members of each level of this hierarchy are identified with a unique Id
|
|
1734
1782
|
* (which is a string). In other words you can naively think of a Store as a
|
|
@@ -1742,6 +1790,8 @@ export type StoreListenerStats = {
|
|
|
1742
1790
|
* "cell2": true, // Cell (boolean)
|
|
1743
1791
|
* "cell3": 3, // Cell (number)
|
|
1744
1792
|
* "cell4": null, // Cell (null since v7.0)
|
|
1793
|
+
* "cell5": {"x": 1}, // Cell (object since v8.0)
|
|
1794
|
+
* "cell6": [1, 2, 3], // Cell (array since v8.0)
|
|
1745
1795
|
* ...
|
|
1746
1796
|
* },
|
|
1747
1797
|
* ...
|
|
@@ -2988,7 +3038,10 @@ export interface Store {
|
|
|
2988
3038
|
* {open: true, employees: 3},
|
|
2989
3039
|
* ]);
|
|
2990
3040
|
*
|
|
2991
|
-
* store.setContent([
|
|
3041
|
+
* store.setContent([
|
|
3042
|
+
* {pets: {felix: {species: 'cat', bug: new Date(0)}}},
|
|
3043
|
+
* '',
|
|
3044
|
+
* ]);
|
|
2992
3045
|
* console.log(store.getTables());
|
|
2993
3046
|
* // -> {pets: {felix: {species: 'cat'}}}
|
|
2994
3047
|
* console.log(store.getValues());
|
|
@@ -3044,7 +3097,7 @@ export interface Store {
|
|
|
3044
3097
|
*
|
|
3045
3098
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
3046
3099
|
*
|
|
3047
|
-
* store.setTables({pets: {felix: {species: 'cat', bug:
|
|
3100
|
+
* store.setTables({pets: {felix: {species: 'cat', bug: new Date(0)}}});
|
|
3048
3101
|
* console.log(store.getTables());
|
|
3049
3102
|
* // -> {pets: {felix: {species: 'cat'}}}
|
|
3050
3103
|
*
|
|
@@ -3100,7 +3153,7 @@ export interface Store {
|
|
|
3100
3153
|
*
|
|
3101
3154
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
3102
3155
|
*
|
|
3103
|
-
* store.setTable('pets', {felix: {species: 'cat', bug:
|
|
3156
|
+
* store.setTable('pets', {felix: {species: 'cat', bug: new Date(0)}});
|
|
3104
3157
|
* console.log(store.getTables());
|
|
3105
3158
|
* // -> {pets: {felix: {species: 'cat'}}}
|
|
3106
3159
|
*
|
|
@@ -3154,7 +3207,7 @@ export interface Store {
|
|
|
3154
3207
|
*
|
|
3155
3208
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
3156
3209
|
*
|
|
3157
|
-
* store.setRow('pets', 'fido', {color: 'brown', bug:
|
|
3210
|
+
* store.setRow('pets', 'fido', {color: 'brown', bug: new Date(0)});
|
|
3158
3211
|
* console.log(store.getTables());
|
|
3159
3212
|
* // -> {pets: {fido: {color: 'brown'}}}
|
|
3160
3213
|
*
|
|
@@ -3219,7 +3272,7 @@ export interface Store {
|
|
|
3219
3272
|
*
|
|
3220
3273
|
* const store = createStore().setTables({pets: {'0': {species: 'dog'}}});
|
|
3221
3274
|
*
|
|
3222
|
-
* console.log(store.addRow('pets', {species: 'cat', bug:
|
|
3275
|
+
* console.log(store.addRow('pets', {species: 'cat', bug: new Date(0)}));
|
|
3223
3276
|
* // -> '1'
|
|
3224
3277
|
* console.log(store.getTables());
|
|
3225
3278
|
* // -> {pets: {'0': {species: 'dog'}, '1': {species: 'cat'}}}
|
|
@@ -3278,7 +3331,7 @@ export interface Store {
|
|
|
3278
3331
|
*
|
|
3279
3332
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
3280
3333
|
*
|
|
3281
|
-
* store.setPartialRow('pets', 'fido', {color: 'brown', bug:
|
|
3334
|
+
* store.setPartialRow('pets', 'fido', {color: 'brown', bug: new Date(0)});
|
|
3282
3335
|
* console.log(store.getTables());
|
|
3283
3336
|
* // -> {pets: {fido: {species: 'dog', color: 'brown'}}}
|
|
3284
3337
|
*
|
|
@@ -3301,10 +3354,10 @@ export interface Store {
|
|
|
3301
3354
|
* does not match a TablesSchema associated with the Store), will be ignored
|
|
3302
3355
|
* silently.
|
|
3303
3356
|
*
|
|
3304
|
-
* As well as string, number,
|
|
3305
|
-
* a MapCell function that takes the current Cell
|
|
3306
|
-
* maps it. This is useful if you want to efficiently
|
|
3307
|
-
* without fetching it first, for example.
|
|
3357
|
+
* As well as string, number, boolean, null, object, and array Cell types,
|
|
3358
|
+
* this method can also take a MapCell function that takes the current Cell
|
|
3359
|
+
* value as a parameter and maps it. This is useful if you want to efficiently
|
|
3360
|
+
* increment a value without fetching it first, for example.
|
|
3308
3361
|
*
|
|
3309
3362
|
* The method returns a reference to the Store so that subsequent operations
|
|
3310
3363
|
* can be chained in a fluent style.
|
|
@@ -3346,7 +3399,7 @@ export interface Store {
|
|
|
3346
3399
|
*
|
|
3347
3400
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
3348
3401
|
*
|
|
3349
|
-
* store.setCell('pets', 'fido', 'bug',
|
|
3402
|
+
* store.setCell('pets', 'fido', 'bug', new Date(0));
|
|
3350
3403
|
* console.log(store.getTables());
|
|
3351
3404
|
* // -> {pets: {fido: {species: 'dog'}}}
|
|
3352
3405
|
* ```
|
|
@@ -3394,7 +3447,7 @@ export interface Store {
|
|
|
3394
3447
|
*
|
|
3395
3448
|
* const store = createStore().setValues({open: true});
|
|
3396
3449
|
*
|
|
3397
|
-
* store.setValues({employees: 3, bug:
|
|
3450
|
+
* store.setValues({employees: 3, bug: new Date(0)});
|
|
3398
3451
|
* console.log(store.getValues());
|
|
3399
3452
|
* // -> {employees: 3}
|
|
3400
3453
|
*
|
|
@@ -3447,7 +3500,7 @@ export interface Store {
|
|
|
3447
3500
|
*
|
|
3448
3501
|
* const store = createStore().setValues({open: true});
|
|
3449
3502
|
*
|
|
3450
|
-
* store.setPartialValues({employees: 3, bug:
|
|
3503
|
+
* store.setPartialValues({employees: 3, bug: new Date(0)});
|
|
3451
3504
|
* console.log(store.getValues());
|
|
3452
3505
|
* // -> {open: true, employees: 3}
|
|
3453
3506
|
*
|
|
@@ -3469,10 +3522,10 @@ export interface Store {
|
|
|
3469
3522
|
* If the Value is invalid (either because of its type, or because it does not
|
|
3470
3523
|
* match a ValuesSchema associated with the Store), will be ignored silently.
|
|
3471
3524
|
*
|
|
3472
|
-
* As well as string, number,
|
|
3473
|
-
* take a MapValue function that takes the current Value
|
|
3474
|
-
* maps it. This is useful if you want to efficiently
|
|
3475
|
-
* without fetching it first, for example.
|
|
3525
|
+
* As well as string, number, boolean, null, object, and array Value types,
|
|
3526
|
+
* this method can also take a MapValue function that takes the current Value
|
|
3527
|
+
* as a parameter and maps it. This is useful if you want to efficiently
|
|
3528
|
+
* increment a value without fetching it first, for example.
|
|
3476
3529
|
*
|
|
3477
3530
|
* The method returns a reference to the Store so that subsequent operations
|
|
3478
3531
|
* can be chained in a fluent style.
|
|
@@ -3510,7 +3563,7 @@ export interface Store {
|
|
|
3510
3563
|
*
|
|
3511
3564
|
* const store = createStore().setValues({employees: 3});
|
|
3512
3565
|
*
|
|
3513
|
-
* store.setValue('bug',
|
|
3566
|
+
* store.setValue('bug', new Date(0));
|
|
3514
3567
|
* console.log(store.getValues());
|
|
3515
3568
|
* // -> {employees: 3}
|
|
3516
3569
|
* ```
|
|
@@ -4246,10 +4299,10 @@ export interface Store {
|
|
|
4246
4299
|
* () =>
|
|
4247
4300
|
* store
|
|
4248
4301
|
* .setCell('pets', 'fido', 'color', 'black')
|
|
4249
|
-
* .setCell('pets', 'fido', '
|
|
4250
|
-
* .setCell('pets', 'fido', '
|
|
4302
|
+
* .setCell('pets', 'fido', 'date0', new Date(0))
|
|
4303
|
+
* .setCell('pets', 'fido', 'date1', new Date(1))
|
|
4251
4304
|
* .setValue('open', false)
|
|
4252
|
-
* .setValue('
|
|
4305
|
+
* .setValue('date2', new Date(2)),
|
|
4253
4306
|
* () => {
|
|
4254
4307
|
* const [, , changedCells, invalidCells, changedValues, invalidValues] =
|
|
4255
4308
|
* store.getTransactionLog();
|
|
@@ -4263,9 +4316,9 @@ export interface Store {
|
|
|
4263
4316
|
* );
|
|
4264
4317
|
* // -> {pets: {fido: {species: 'dog', color: 'black'}}}
|
|
4265
4318
|
* // -> {pets: {fido: {color: ['brown', 'black']}}}
|
|
4266
|
-
* // -> {pets: {fido: {
|
|
4319
|
+
* // -> {pets: {fido: {date0: [new Date(0)], date1: [new Date(1)]}}}
|
|
4267
4320
|
* // -> {open: [true, false]}
|
|
4268
|
-
* // -> {
|
|
4321
|
+
* // -> {date2: [new Date(2)]}
|
|
4269
4322
|
*
|
|
4270
4323
|
* console.log(store.getTables());
|
|
4271
4324
|
* // -> {pets: {fido: {species: 'dog', color: 'brown'}}}
|
|
@@ -4389,10 +4442,10 @@ export interface Store {
|
|
|
4389
4442
|
* store
|
|
4390
4443
|
* .startTransaction()
|
|
4391
4444
|
* .setCell('pets', 'fido', 'color', 'black')
|
|
4392
|
-
* .setCell('pets', 'fido', '
|
|
4393
|
-
* .setCell('pets', 'fido', '
|
|
4445
|
+
* .setCell('pets', 'fido', 'date0', new Date(0))
|
|
4446
|
+
* .setCell('pets', 'fido', 'date1', new Date(1))
|
|
4394
4447
|
* .setValue('open', false)
|
|
4395
|
-
* .setValue('
|
|
4448
|
+
* .setValue('date2', new Date(2))
|
|
4396
4449
|
* .finishTransaction(() => {
|
|
4397
4450
|
* const [, , changedCells, invalidCells, changedValues, invalidValues] =
|
|
4398
4451
|
* store.getTransactionLog();
|
|
@@ -4402,9 +4455,9 @@ export interface Store {
|
|
|
4402
4455
|
* console.log(invalidValues);
|
|
4403
4456
|
* });
|
|
4404
4457
|
* // -> {pets: {fido: {color: ['brown', 'black']}}}
|
|
4405
|
-
* // -> {pets: {fido: {
|
|
4458
|
+
* // -> {pets: {fido: {date0: [new Date(0)], date1: [new Date(1)]}}}
|
|
4406
4459
|
* // -> {open: [true, false]}
|
|
4407
|
-
* // -> {
|
|
4460
|
+
* // -> {date2: [new Date(2)]}
|
|
4408
4461
|
* ```
|
|
4409
4462
|
* @category Transaction
|
|
4410
4463
|
* @since v5.0.0
|
|
@@ -4482,10 +4535,10 @@ export interface Store {
|
|
|
4482
4535
|
* store
|
|
4483
4536
|
* .startTransaction()
|
|
4484
4537
|
* .setCell('pets', 'fido', 'color', 'black')
|
|
4485
|
-
* .setCell('pets', 'fido', '
|
|
4486
|
-
* .setCell('pets', 'fido', '
|
|
4538
|
+
* .setCell('pets', 'fido', 'date0', new Date(0))
|
|
4539
|
+
* .setCell('pets', 'fido', 'date1', new Date(1))
|
|
4487
4540
|
* .setValue('open', false)
|
|
4488
|
-
* .setValue('
|
|
4541
|
+
* .setValue('date2', new Date(2))
|
|
4489
4542
|
* .finishTransaction(() => {
|
|
4490
4543
|
* const [, , changedCells, invalidCells, changedValues, invalidValues] =
|
|
4491
4544
|
* store.getTransactionLog();
|
|
@@ -4498,9 +4551,9 @@ export interface Store {
|
|
|
4498
4551
|
* });
|
|
4499
4552
|
* // -> {pets: {fido: {species: 'dog', color: 'black'}}}
|
|
4500
4553
|
* // -> {pets: {fido: {color: ['brown', 'black']}}}
|
|
4501
|
-
* // -> {pets: {fido: {
|
|
4554
|
+
* // -> {pets: {fido: {date0: [new Date(0)], date1: [new Date(1)]}}}
|
|
4502
4555
|
* // -> {open: [true, false]}
|
|
4503
|
-
* // -> {
|
|
4556
|
+
* // -> {date2: [new Date(2)]}
|
|
4504
4557
|
*
|
|
4505
4558
|
* console.log(store.getTables());
|
|
4506
4559
|
* // -> {pets: {fido: {species: 'dog', color: 'brown'}}}
|
|
@@ -6883,16 +6936,16 @@ export interface Store {
|
|
|
6883
6936
|
* const listenerId = store.addInvalidCellListener(
|
|
6884
6937
|
* 'pets',
|
|
6885
6938
|
* 'fido',
|
|
6886
|
-
* '
|
|
6939
|
+
* 'birth',
|
|
6887
6940
|
* (store, tableId, rowId, cellId, invalidCells) => {
|
|
6888
|
-
* console.log('Invalid
|
|
6941
|
+
* console.log('Invalid birth cell in fido row in pets table');
|
|
6889
6942
|
* console.log(invalidCells);
|
|
6890
6943
|
* },
|
|
6891
6944
|
* );
|
|
6892
6945
|
*
|
|
6893
|
-
* store.setCell('pets', 'fido', '
|
|
6894
|
-
* // -> 'Invalid
|
|
6895
|
-
* // -> [
|
|
6946
|
+
* store.setCell('pets', 'fido', 'birth', new Date(0));
|
|
6947
|
+
* // -> 'Invalid birth cell in fido row in pets table'
|
|
6948
|
+
* // -> [new Date(0)]
|
|
6896
6949
|
*
|
|
6897
6950
|
* store.delListener(listenerId);
|
|
6898
6951
|
* ```
|
|
@@ -6919,10 +6972,10 @@ export interface Store {
|
|
|
6919
6972
|
* },
|
|
6920
6973
|
* );
|
|
6921
6974
|
*
|
|
6922
|
-
* store.setCell('pets', 'fido', '
|
|
6923
|
-
* // -> 'Invalid
|
|
6924
|
-
* store.setTable('sales', {fido: {
|
|
6925
|
-
* // -> 'Invalid
|
|
6975
|
+
* store.setCell('pets', 'fido', 'birth', new Date(0));
|
|
6976
|
+
* // -> 'Invalid birth cell in fido row in pets table'
|
|
6977
|
+
* store.setTable('sales', {fido: {birth: new Date()}});
|
|
6978
|
+
* // -> 'Invalid birth cell in fido row in sales table'
|
|
6926
6979
|
*
|
|
6927
6980
|
* store.setRow('pets', 'felix', {});
|
|
6928
6981
|
* // -> 'Invalid undefined cell in felix row in pets table'
|
|
@@ -7026,7 +7079,7 @@ export interface Store {
|
|
|
7026
7079
|
* const listenerId = store.addInvalidCellListener(
|
|
7027
7080
|
* 'pets',
|
|
7028
7081
|
* 'fido',
|
|
7029
|
-
* '
|
|
7082
|
+
* 'birth',
|
|
7030
7083
|
* (store, tableId, rowId, cellId, invalidCells) =>
|
|
7031
7084
|
* store.setCell(
|
|
7032
7085
|
* 'meta',
|
|
@@ -7037,9 +7090,9 @@ export interface Store {
|
|
|
7037
7090
|
* true,
|
|
7038
7091
|
* );
|
|
7039
7092
|
*
|
|
7040
|
-
* store.setCell('pets', 'fido', '
|
|
7093
|
+
* store.setCell('pets', 'fido', 'birth', new Date(0));
|
|
7041
7094
|
* console.log(store.getRow('meta', 'invalid_updates'));
|
|
7042
|
-
* // -> {'
|
|
7095
|
+
* // -> {'pets_fido_birth': '"1970-01-01T00:00:00.000Z"'}
|
|
7043
7096
|
*
|
|
7044
7097
|
* store.delListener(listenerId);
|
|
7045
7098
|
* ```
|
|
@@ -7108,16 +7161,16 @@ export interface Store {
|
|
|
7108
7161
|
*
|
|
7109
7162
|
* const store = createStore().setValues({open: true});
|
|
7110
7163
|
* const listenerId = store.addInvalidValueListener(
|
|
7111
|
-
* '
|
|
7164
|
+
* 'openDate',
|
|
7112
7165
|
* (store, valueId, invalidValues) => {
|
|
7113
|
-
* console.log('Invalid
|
|
7166
|
+
* console.log('Invalid openDate value');
|
|
7114
7167
|
* console.log(invalidValues);
|
|
7115
7168
|
* },
|
|
7116
7169
|
* );
|
|
7117
7170
|
*
|
|
7118
|
-
* store.setValue('
|
|
7119
|
-
* // -> 'Invalid
|
|
7120
|
-
* // -> [
|
|
7171
|
+
* store.setValue('openDate', new Date(0));
|
|
7172
|
+
* // -> 'Invalid openDate value'
|
|
7173
|
+
* // -> [new Date(0)]
|
|
7121
7174
|
*
|
|
7122
7175
|
* store.delListener(listenerId);
|
|
7123
7176
|
* ```
|
|
@@ -7137,10 +7190,10 @@ export interface Store {
|
|
|
7137
7190
|
* },
|
|
7138
7191
|
* );
|
|
7139
7192
|
*
|
|
7140
|
-
* store.setValue('
|
|
7141
|
-
* // -> 'Invalid
|
|
7142
|
-
* store.setValue('
|
|
7143
|
-
* // -> 'Invalid
|
|
7193
|
+
* store.setValue('openDate', new Date(0));
|
|
7194
|
+
* // -> 'Invalid openDate value'
|
|
7195
|
+
* store.setValue('closeDate', new Date(1));
|
|
7196
|
+
* // -> 'Invalid closeDate value'
|
|
7144
7197
|
*
|
|
7145
7198
|
* store.setValues('pets', 'felix', {});
|
|
7146
7199
|
* // -> 'Invalid undefined value'
|
|
@@ -7216,15 +7269,15 @@ export interface Store {
|
|
|
7216
7269
|
*
|
|
7217
7270
|
* const store = createStore().setValues({open: true});
|
|
7218
7271
|
* const listenerId = store.addInvalidValueListener(
|
|
7219
|
-
* '
|
|
7272
|
+
* 'openDate',
|
|
7220
7273
|
* (store, valueId, invalidValues) =>
|
|
7221
7274
|
* store.setValue('invalid_updates', JSON.stringify(invalidValues[0])),
|
|
7222
7275
|
* true,
|
|
7223
7276
|
* );
|
|
7224
7277
|
*
|
|
7225
|
-
* store.setValue('
|
|
7278
|
+
* store.setValue('openDate', new Date(0));
|
|
7226
7279
|
* console.log(store.getValue('invalid_updates'));
|
|
7227
|
-
* // -> '
|
|
7280
|
+
* // -> '"1970-01-01T00:00:00.000Z"'
|
|
7228
7281
|
*
|
|
7229
7282
|
* store.delListener(listenerId);
|
|
7230
7283
|
* ```
|