tinybase 7.1.0-beta.2 → 7.1.0-beta.4
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/schematizers/index.d.ts +57 -0
- package/@types/schematizers/schematizer-arktype/index.d.ts +114 -0
- package/@types/schematizers/schematizer-arktype/with-schemas/index.d.ts +8 -0
- package/@types/schematizers/schematizer-effect/index.d.ts +118 -0
- package/@types/schematizers/schematizer-effect/with-schemas/index.d.ts +8 -0
- package/@types/schematizers/schematizer-valibot/index.d.ts +114 -0
- package/@types/schematizers/schematizer-valibot/with-schemas/index.d.ts +8 -0
- package/@types/schematizers/schematizer-yup/index.d.ts +112 -0
- package/@types/schematizers/schematizer-yup/with-schemas/index.d.ts +7 -0
- package/checkpoints/index.js +2 -2
- package/checkpoints/with-schemas/index.js +2 -2
- package/index.js +6 -4
- package/indexes/index.js +2 -2
- package/indexes/with-schemas/index.js +2 -2
- package/mergeable-store/index.js +2 -2
- package/mergeable-store/with-schemas/index.js +2 -2
- package/metrics/index.js +6 -4
- package/metrics/with-schemas/index.js +6 -4
- 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/indexes/index.js +1 -1
- package/min/indexes/index.js.gz +0 -0
- package/min/indexes/with-schemas/index.js +1 -1
- package/min/indexes/with-schemas/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/metrics/index.js +1 -1
- package/min/metrics/index.js.gz +0 -0
- package/min/metrics/with-schemas/index.js +1 -1
- package/min/metrics/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/relationships/index.js +1 -1
- package/min/relationships/index.js.gz +0 -0
- package/min/relationships/with-schemas/index.js +1 -1
- package/min/relationships/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 -0
- package/min/schematizers/schematizer-arktype/index.js.gz +0 -0
- package/min/schematizers/schematizer-arktype/with-schemas/index.js +1 -0
- package/min/schematizers/schematizer-arktype/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-effect/index.js +1 -0
- package/min/schematizers/schematizer-effect/index.js.gz +0 -0
- package/min/schematizers/schematizer-effect/with-schemas/index.js +1 -0
- 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 -0
- package/min/schematizers/schematizer-valibot/index.js.gz +0 -0
- package/min/schematizers/schematizer-valibot/with-schemas/index.js +1 -0
- package/min/schematizers/schematizer-valibot/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-yup/index.js +1 -0
- package/min/schematizers/schematizer-yup/index.js.gz +0 -0
- package/min/schematizers/schematizer-yup/with-schemas/index.js +1 -0
- 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/synchronizer-ws-server-simple/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server-simple/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-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 +19 -16
- package/omni/with-schemas/index.js +19 -16
- package/package.json +158 -2
- package/persisters/index.js +6 -4
- package/persisters/persister-automerge/index.js +2 -2
- package/persisters/persister-automerge/with-schemas/index.js +2 -2
- package/persisters/persister-browser/index.js +3 -3
- package/persisters/persister-browser/with-schemas/index.js +3 -3
- package/persisters/persister-cr-sqlite-wasm/index.js +6 -4
- package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +6 -4
- package/persisters/persister-durable-object-sql-storage/index.js +6 -4
- package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +6 -4
- package/persisters/persister-durable-object-storage/index.js +3 -3
- package/persisters/persister-durable-object-storage/with-schemas/index.js +3 -3
- package/persisters/persister-electric-sql/index.js +6 -4
- package/persisters/persister-electric-sql/with-schemas/index.js +6 -4
- package/persisters/persister-expo-sqlite/index.js +6 -4
- package/persisters/persister-expo-sqlite/with-schemas/index.js +6 -4
- package/persisters/persister-file/index.js +3 -3
- package/persisters/persister-file/with-schemas/index.js +3 -3
- package/persisters/persister-indexed-db/index.js +2 -2
- package/persisters/persister-indexed-db/with-schemas/index.js +2 -2
- package/persisters/persister-libsql/index.js +6 -4
- package/persisters/persister-libsql/with-schemas/index.js +6 -4
- package/persisters/persister-partykit-client/index.js +2 -2
- package/persisters/persister-partykit-client/with-schemas/index.js +2 -2
- package/persisters/persister-pglite/index.js +3 -3
- package/persisters/persister-pglite/with-schemas/index.js +3 -3
- package/persisters/persister-postgres/index.js +3 -3
- package/persisters/persister-postgres/with-schemas/index.js +3 -3
- package/persisters/persister-powersync/index.js +6 -4
- package/persisters/persister-powersync/with-schemas/index.js +6 -4
- package/persisters/persister-react-native-mmkv/index.js +4 -4
- package/persisters/persister-react-native-mmkv/with-schemas/index.js +4 -4
- package/persisters/persister-react-native-sqlite/index.js +6 -4
- package/persisters/persister-react-native-sqlite/with-schemas/index.js +6 -4
- package/persisters/persister-remote/index.js +2 -2
- package/persisters/persister-remote/with-schemas/index.js +2 -2
- package/persisters/persister-sqlite-bun/index.js +6 -4
- package/persisters/persister-sqlite-bun/with-schemas/index.js +6 -4
- package/persisters/persister-sqlite-wasm/index.js +6 -4
- package/persisters/persister-sqlite-wasm/with-schemas/index.js +6 -4
- package/persisters/persister-sqlite3/index.js +6 -4
- package/persisters/persister-sqlite3/with-schemas/index.js +6 -4
- package/persisters/persister-yjs/index.js +2 -2
- package/persisters/persister-yjs/with-schemas/index.js +2 -2
- package/persisters/with-schemas/index.js +6 -4
- package/queries/index.js +1 -1
- package/queries/with-schemas/index.js +1 -1
- package/readme.md +3 -3
- package/relationships/index.js +2 -2
- package/relationships/with-schemas/index.js +2 -2
- package/releases.md +2 -2
- package/schematizers/index.js +89 -0
- package/schematizers/schematizer-arktype/index.js +163 -0
- package/schematizers/schematizer-arktype/with-schemas/index.js +163 -0
- package/schematizers/schematizer-effect/index.js +137 -0
- package/schematizers/schematizer-effect/with-schemas/index.js +137 -0
- package/schematizers/schematizer-typebox/index.js +40 -38
- package/schematizers/schematizer-typebox/with-schemas/index.js +40 -38
- package/schematizers/schematizer-valibot/index.js +106 -0
- package/schematizers/schematizer-valibot/with-schemas/index.js +106 -0
- package/schematizers/schematizer-yup/index.js +100 -0
- package/schematizers/schematizer-yup/with-schemas/index.js +100 -0
- package/schematizers/schematizer-zod/index.js +39 -35
- package/schematizers/schematizer-zod/with-schemas/index.js +39 -35
- package/schematizers/with-schemas/index.js +89 -0
- package/store/index.js +2 -2
- package/store/with-schemas/index.js +2 -2
- package/synchronizers/index.js +2 -2
- package/synchronizers/synchronizer-broadcast-channel/index.js +2 -2
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +2 -2
- package/synchronizers/synchronizer-local/index.js +2 -2
- package/synchronizers/synchronizer-local/with-schemas/index.js +2 -2
- package/synchronizers/synchronizer-ws-client/index.js +3 -3
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +3 -3
- package/synchronizers/synchronizer-ws-server/index.js +3 -3
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +3 -3
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +3 -3
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +3 -3
- package/synchronizers/synchronizer-ws-server-simple/index.js +1 -1
- package/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +1 -1
- package/synchronizers/with-schemas/index.js +2 -2
- package/ui-react-dom/index.js +11 -8
- package/ui-react-dom/with-schemas/index.js +11 -8
- package/ui-react-inspector/index.js +14 -11
- package/ui-react-inspector/with-schemas/index.js +14 -11
- package/with-schemas/index.js +6 -4
|
@@ -39,3 +39,60 @@ export interface Schematizer {
|
|
|
39
39
|
*/
|
|
40
40
|
toValuesSchema(schemas: any): ValuesSchema;
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The createCustomSchematizer function creates a custom Schematizer that can
|
|
45
|
+
* convert schemas from any validation library into TinyBase schemas.
|
|
46
|
+
*
|
|
47
|
+
* This function allows you to build schematizers for validation libraries not
|
|
48
|
+
* natively supported by TinyBase. You provide two functions: one to unwrap
|
|
49
|
+
* optional/nullable/default wrappers from your library's schemas, and one to
|
|
50
|
+
* extract object properties.
|
|
51
|
+
* @param unwrapSchema - A function that unwraps a schema to extract the base
|
|
52
|
+
* type, default value, and nullable flag. It should recursively unwrap
|
|
53
|
+
* optional/nullable wrappers and return a tuple of [schema, defaultValue,
|
|
54
|
+
* allowNull].
|
|
55
|
+
* @param getProperties - A function that extracts the properties/entries/shape
|
|
56
|
+
* from an object schema. Returns undefined if the schema is not an object.
|
|
57
|
+
* @returns A new Schematizer instance.
|
|
58
|
+
* @example
|
|
59
|
+
* This example creates a custom schematizer for a hypothetical validation
|
|
60
|
+
* library.
|
|
61
|
+
*
|
|
62
|
+
* ```js
|
|
63
|
+
* import {createCustomSchematizer} from 'tinybase/schematizers';
|
|
64
|
+
*
|
|
65
|
+
* // Hypothetical library has schemas like:
|
|
66
|
+
* // {type: 'string'}, {type: 'optional', inner: ...}, etc.
|
|
67
|
+
*
|
|
68
|
+
* const unwrapSchema = (schema, defaultValue, allowNull) => {
|
|
69
|
+
* if (schema.type === 'optional') {
|
|
70
|
+
* return unwrapSchema(schema.inner, defaultValue, allowNull);
|
|
71
|
+
* }
|
|
72
|
+
* if (schema.type === 'nullable') {
|
|
73
|
+
* return unwrapSchema(schema.inner, defaultValue, true);
|
|
74
|
+
* }
|
|
75
|
+
* return [schema, defaultValue ?? schema.default, allowNull ?? false];
|
|
76
|
+
* };
|
|
77
|
+
*
|
|
78
|
+
* const getProperties = (schema) => schema.fields;
|
|
79
|
+
*
|
|
80
|
+
* const schematizer = createCustomSchematizer(unwrapSchema, getProperties);
|
|
81
|
+
*
|
|
82
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
83
|
+
* pets: {type: 'object', fields: {name: {type: 'string'}}},
|
|
84
|
+
* });
|
|
85
|
+
* console.log(tablesSchema);
|
|
86
|
+
* // -> {pets: {name: {type: 'string'}}}
|
|
87
|
+
* ```
|
|
88
|
+
* @category Creation
|
|
89
|
+
* @since v7.1.0
|
|
90
|
+
*/
|
|
91
|
+
export function createCustomSchematizer(
|
|
92
|
+
unwrapSchema: (
|
|
93
|
+
schema: any,
|
|
94
|
+
defaultValue?: any,
|
|
95
|
+
allowNull?: boolean,
|
|
96
|
+
) => [any, any, boolean],
|
|
97
|
+
getProperties: (schema: any) => any | undefined,
|
|
98
|
+
): Schematizer;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schematizer-arktype module provides conversion utilities for ArkType
|
|
3
|
+
* schemas.
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module schematizer-arktype
|
|
6
|
+
* @since v7.1.0
|
|
7
|
+
*/
|
|
8
|
+
import type {TablesSchema, ValuesSchema} from '../../store/index.d.ts';
|
|
9
|
+
import type {Schematizer} from '../index.d.ts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The ArkTypeSchematizer interface represents a schematizer specifically for
|
|
13
|
+
* converting ArkType schemas into TinyBase schemas.
|
|
14
|
+
* @category Schematizer
|
|
15
|
+
* @since v7.1.0
|
|
16
|
+
*/
|
|
17
|
+
export interface ArkTypeSchematizer extends Schematizer {
|
|
18
|
+
/**
|
|
19
|
+
* The toTablesSchema method converts a mapping of ArkType object schemas into a
|
|
20
|
+
* TinyBase TablesSchema.
|
|
21
|
+
*
|
|
22
|
+
* This method extracts basic type information (string, number, boolean),
|
|
23
|
+
* default values, and nullable flags from ArkType schemas. Complex validation
|
|
24
|
+
* rules like min/max, regex patterns, refinements, and transforms are ignored.
|
|
25
|
+
* @param schemas - A mapping of table IDs to ArkType object schemas.
|
|
26
|
+
* @returns A TinyBase TablesSchema.
|
|
27
|
+
* @example
|
|
28
|
+
* This example converts ArkType schemas to TinyBase format.
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* import {type} from 'arktype';
|
|
32
|
+
* import {createStore} from 'tinybase';
|
|
33
|
+
* import {createArkTypeSchematizer} from 'tinybase/schematizers/schematizer-arktype';
|
|
34
|
+
*
|
|
35
|
+
* const schematizer = createArkTypeSchematizer();
|
|
36
|
+
*
|
|
37
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
38
|
+
* pets: type({
|
|
39
|
+
* species: 'string',
|
|
40
|
+
* age: 'number',
|
|
41
|
+
* sold: type('boolean').default(false),
|
|
42
|
+
* }),
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* const store = createStore().setTablesSchema(tablesSchema);
|
|
46
|
+
* store.setRow('pets', 'fido', {species: 'dog', age: 3});
|
|
47
|
+
* console.log(store.getRow('pets', 'fido'));
|
|
48
|
+
* // -> {species: 'dog', age: 3, sold: false}
|
|
49
|
+
* ```
|
|
50
|
+
* @category Conversion
|
|
51
|
+
* @since v7.1.0
|
|
52
|
+
*/
|
|
53
|
+
toTablesSchema(schemas: {[tableId: string]: any}): TablesSchema;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The toValuesSchema method converts a mapping of ArkType schemas into a
|
|
57
|
+
* TinyBase ValuesSchema.
|
|
58
|
+
*
|
|
59
|
+
* This method extracts basic type information and default values from ArkType
|
|
60
|
+
* schemas.
|
|
61
|
+
* @param schemas - A mapping of value IDs to ArkType schemas.
|
|
62
|
+
* @returns A TinyBase ValuesSchema.
|
|
63
|
+
* @example
|
|
64
|
+
* This example converts ArkType value schemas.
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* import {type} from 'arktype';
|
|
68
|
+
* import {createStore} from 'tinybase';
|
|
69
|
+
* import {createArkTypeSchematizer} from 'tinybase/schematizers/schematizer-arktype';
|
|
70
|
+
*
|
|
71
|
+
* const schematizer = createArkTypeSchematizer();
|
|
72
|
+
*
|
|
73
|
+
* const valuesSchema = schematizer.toValuesSchema({
|
|
74
|
+
* theme: type('string').default('light'),
|
|
75
|
+
* count: 'number',
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* const store = createStore().setValuesSchema(valuesSchema);
|
|
79
|
+
* console.log(store.getValues());
|
|
80
|
+
* // -> {theme: 'light'}
|
|
81
|
+
* ```
|
|
82
|
+
* @category Conversion
|
|
83
|
+
* @since v7.1.0
|
|
84
|
+
*/
|
|
85
|
+
toValuesSchema(schemas: {[valueId: string]: any}): ValuesSchema;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The createArkTypeSchematizer function creates an ArkTypeSchematizer object
|
|
90
|
+
* that can convert ArkType schemas into TinyBase schemas.
|
|
91
|
+
*
|
|
92
|
+
* The schematizer is stateless and can be reused for multiple conversions.
|
|
93
|
+
* @returns A new ArkTypeSchematizer instance.
|
|
94
|
+
* @example
|
|
95
|
+
* This example creates an ArkType schematizer and uses it to convert schemas.
|
|
96
|
+
*
|
|
97
|
+
* ```js
|
|
98
|
+
* import {type} from 'arktype';
|
|
99
|
+
* import {createArkTypeSchematizer} from 'tinybase/schematizers/schematizer-arktype';
|
|
100
|
+
*
|
|
101
|
+
* const schematizer = createArkTypeSchematizer();
|
|
102
|
+
*
|
|
103
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
104
|
+
* pets: type({
|
|
105
|
+
* species: 'string',
|
|
106
|
+
* }),
|
|
107
|
+
* });
|
|
108
|
+
* console.log(tablesSchema);
|
|
109
|
+
* // -> {pets: {species: {type: 'string'}}}
|
|
110
|
+
* ```
|
|
111
|
+
* @category Creation
|
|
112
|
+
* @since v7.1.0
|
|
113
|
+
*/
|
|
114
|
+
export function createArkTypeSchematizer(): ArkTypeSchematizer;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schematizer-effect module provides conversion utilities for Effect
|
|
3
|
+
* Schema schemas.
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module schematizer-effect
|
|
6
|
+
* @since v7.1.0
|
|
7
|
+
*/
|
|
8
|
+
import type {TablesSchema, ValuesSchema} from '../../store/index.d.ts';
|
|
9
|
+
import type {Schematizer} from '../index.d.ts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The EffectSchematizer interface represents a schematizer specifically for
|
|
13
|
+
* converting Effect Schema schemas into TinyBase schemas.
|
|
14
|
+
* @category Schematizer
|
|
15
|
+
* @since v7.1.0
|
|
16
|
+
*/
|
|
17
|
+
export interface EffectSchematizer extends Schematizer {
|
|
18
|
+
/**
|
|
19
|
+
* The toTablesSchema method converts a mapping of Effect Schema struct schemas
|
|
20
|
+
* into a TinyBase TablesSchema.
|
|
21
|
+
*
|
|
22
|
+
* This method extracts basic type information (string, number, boolean),
|
|
23
|
+
* nullable flags, and optional flags from Effect schemas. Default values are
|
|
24
|
+
* not supported as they exist in Effect's runtime transformations, not in the
|
|
25
|
+
* schema AST. Complex validation rules, transformations, and refinements are
|
|
26
|
+
* ignored.
|
|
27
|
+
* @param schemas - A mapping of table IDs to Effect Schema struct schemas.
|
|
28
|
+
* @returns A TinyBase TablesSchema.
|
|
29
|
+
* @example
|
|
30
|
+
* This example converts Effect Schema schemas to TinyBase format.
|
|
31
|
+
*
|
|
32
|
+
* ```js
|
|
33
|
+
* import {Boolean, Number, String, Struct} from 'effect/Schema';
|
|
34
|
+
* import {createStore} from 'tinybase';
|
|
35
|
+
* import {createEffectSchematizer} from 'tinybase/schematizers/schematizer-effect';
|
|
36
|
+
*
|
|
37
|
+
* const schematizer = createEffectSchematizer();
|
|
38
|
+
*
|
|
39
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
40
|
+
* pets: Struct({
|
|
41
|
+
* species: String,
|
|
42
|
+
* age: Number,
|
|
43
|
+
* sold: Boolean,
|
|
44
|
+
* }),
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* const store = createStore().setTablesSchema(tablesSchema);
|
|
48
|
+
* store.setRow('pets', 'fido', {species: 'dog', age: 3, sold: false});
|
|
49
|
+
* console.log(store.getRow('pets', 'fido'));
|
|
50
|
+
* // -> {species: 'dog', age: 3, sold: false}
|
|
51
|
+
* ```
|
|
52
|
+
* @category Conversion
|
|
53
|
+
* @since v7.1.0
|
|
54
|
+
*/
|
|
55
|
+
toTablesSchema(schemas: {[tableId: string]: any}): TablesSchema;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The toValuesSchema method converts a mapping of Effect Schema schemas into a
|
|
59
|
+
* TinyBase ValuesSchema.
|
|
60
|
+
*
|
|
61
|
+
* This method extracts basic type information (string, number, boolean),
|
|
62
|
+
* nullable flags, and optional flags from Effect schemas. Default values are
|
|
63
|
+
* not supported as they exist in Effect's runtime transformations, not in the
|
|
64
|
+
* schema AST.
|
|
65
|
+
* @param schemas - A mapping of value IDs to Effect Schema schemas.
|
|
66
|
+
* @returns A TinyBase ValuesSchema.
|
|
67
|
+
* @example
|
|
68
|
+
* This example converts Effect Schema schemas to TinyBase values.
|
|
69
|
+
*
|
|
70
|
+
* ```js
|
|
71
|
+
* import {Boolean, Number} from 'effect/Schema';
|
|
72
|
+
* import {createStore} from 'tinybase';
|
|
73
|
+
* import {createEffectSchematizer} from 'tinybase/schematizers/schematizer-effect';
|
|
74
|
+
*
|
|
75
|
+
* const schematizer = createEffectSchematizer();
|
|
76
|
+
*
|
|
77
|
+
* const valuesSchema = schematizer.toValuesSchema({
|
|
78
|
+
* open: Boolean,
|
|
79
|
+
* employees: Number,
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* const store = createStore().setValuesSchema(valuesSchema);
|
|
83
|
+
* store.setValues({open: true, employees: 3});
|
|
84
|
+
* console.log(store.getValues());
|
|
85
|
+
* // -> {open: true, employees: 3}
|
|
86
|
+
* ```
|
|
87
|
+
* @category Conversion
|
|
88
|
+
* @since v7.1.0
|
|
89
|
+
*/
|
|
90
|
+
toValuesSchema(schemas: {[valueId: string]: any}): ValuesSchema;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The createEffectSchematizer function creates an EffectSchematizer instance
|
|
95
|
+
* for converting Effect Schema schemas to TinyBase schemas.
|
|
96
|
+
* @returns A new EffectSchematizer instance.
|
|
97
|
+
* @example
|
|
98
|
+
* This example creates an Effect Schema schematizer.
|
|
99
|
+
*
|
|
100
|
+
* ```js
|
|
101
|
+
* import {String, Struct} from 'effect/Schema';
|
|
102
|
+
* import {createEffectSchematizer} from 'tinybase/schematizers/schematizer-effect';
|
|
103
|
+
*
|
|
104
|
+
* const schematizer = createEffectSchematizer();
|
|
105
|
+
*
|
|
106
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
107
|
+
* pets: Struct({
|
|
108
|
+
* species: String,
|
|
109
|
+
* }),
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* console.log(tablesSchema);
|
|
113
|
+
* // -> {pets: {species: {type: 'string'}}}
|
|
114
|
+
* ```
|
|
115
|
+
* @category Creation
|
|
116
|
+
* @since v7.1.0
|
|
117
|
+
*/
|
|
118
|
+
export function createEffectSchematizer(): EffectSchematizer;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schematizer-valibot module provides conversion utilities for Valibot
|
|
3
|
+
* schemas.
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module schematizer-valibot
|
|
6
|
+
* @since v7.1.0
|
|
7
|
+
*/
|
|
8
|
+
import type {TablesSchema, ValuesSchema} from '../../store/index.d.ts';
|
|
9
|
+
import type {Schematizer} from '../index.d.ts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The ValibotSchematizer interface represents a schematizer specifically for
|
|
13
|
+
* converting Valibot schemas into TinyBase schemas.
|
|
14
|
+
* @category Schematizer
|
|
15
|
+
* @since v7.1.0
|
|
16
|
+
*/
|
|
17
|
+
export interface ValibotSchematizer extends Schematizer {
|
|
18
|
+
/**
|
|
19
|
+
* The toTablesSchema method converts a mapping of Valibot object schemas into a
|
|
20
|
+
* TinyBase TablesSchema.
|
|
21
|
+
*
|
|
22
|
+
* This method extracts basic type information (string, number, boolean),
|
|
23
|
+
* fallback values, and nullable flags from Valibot schemas. Complex validation
|
|
24
|
+
* rules like min/max, regex patterns, refinements, and transforms are ignored.
|
|
25
|
+
* @param schemas - A mapping of table IDs to Valibot object schemas.
|
|
26
|
+
* @returns A TinyBase TablesSchema.
|
|
27
|
+
* @example
|
|
28
|
+
* This example converts Valibot schemas to TinyBase format.
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* import {createStore} from 'tinybase';
|
|
32
|
+
* import {createValibotSchematizer} from 'tinybase/schematizers/schematizer-valibot';
|
|
33
|
+
* import {boolean, fallback, number, object, string} from 'valibot';
|
|
34
|
+
*
|
|
35
|
+
* const schematizer = createValibotSchematizer();
|
|
36
|
+
*
|
|
37
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
38
|
+
* pets: object({
|
|
39
|
+
* species: string(),
|
|
40
|
+
* age: number(),
|
|
41
|
+
* sold: fallback(boolean(), false),
|
|
42
|
+
* }),
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* const store = createStore().setTablesSchema(tablesSchema);
|
|
46
|
+
* store.setRow('pets', 'fido', {species: 'dog', age: 3});
|
|
47
|
+
* console.log(store.getRow('pets', 'fido'));
|
|
48
|
+
* // -> {species: 'dog', age: 3, sold: false}
|
|
49
|
+
* ```
|
|
50
|
+
* @category Conversion
|
|
51
|
+
* @since v7.1.0
|
|
52
|
+
*/
|
|
53
|
+
toTablesSchema(schemas: {[tableId: string]: any}): TablesSchema;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The toValuesSchema method converts a mapping of Valibot schemas into a
|
|
57
|
+
* TinyBase ValuesSchema.
|
|
58
|
+
*
|
|
59
|
+
* This method extracts basic type information and fallback values from Valibot
|
|
60
|
+
* schemas.
|
|
61
|
+
* @param schemas - A mapping of value IDs to Valibot schemas.
|
|
62
|
+
* @returns A TinyBase ValuesSchema.
|
|
63
|
+
* @example
|
|
64
|
+
* This example converts Valibot value schemas.
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* import {createStore} from 'tinybase';
|
|
68
|
+
* import {createValibotSchematizer} from 'tinybase/schematizers/schematizer-valibot';
|
|
69
|
+
* import {fallback, number, string} from 'valibot';
|
|
70
|
+
*
|
|
71
|
+
* const schematizer = createValibotSchematizer();
|
|
72
|
+
*
|
|
73
|
+
* const valuesSchema = schematizer.toValuesSchema({
|
|
74
|
+
* theme: fallback(string(), 'light'),
|
|
75
|
+
* count: number(),
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* const store = createStore().setValuesSchema(valuesSchema);
|
|
79
|
+
* console.log(store.getValues());
|
|
80
|
+
* // -> {theme: 'light'}
|
|
81
|
+
* ```
|
|
82
|
+
* @category Conversion
|
|
83
|
+
* @since v7.1.0
|
|
84
|
+
*/
|
|
85
|
+
toValuesSchema(schemas: {[valueId: string]: any}): ValuesSchema;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The createValibotSchematizer function creates a ValibotSchematizer object
|
|
90
|
+
* that can convert Valibot schemas into TinyBase schemas.
|
|
91
|
+
*
|
|
92
|
+
* The schematizer is stateless and can be reused for multiple conversions.
|
|
93
|
+
* @returns A new ValibotSchematizer instance.
|
|
94
|
+
* @example
|
|
95
|
+
* This example creates a Valibot schematizer and uses it to convert schemas.
|
|
96
|
+
*
|
|
97
|
+
* ```js
|
|
98
|
+
* import {createValibotSchematizer} from 'tinybase/schematizers/schematizer-valibot';
|
|
99
|
+
* import {object, string} from 'valibot';
|
|
100
|
+
*
|
|
101
|
+
* const schematizer = createValibotSchematizer();
|
|
102
|
+
*
|
|
103
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
104
|
+
* pets: object({
|
|
105
|
+
* species: string(),
|
|
106
|
+
* }),
|
|
107
|
+
* });
|
|
108
|
+
* console.log(tablesSchema);
|
|
109
|
+
* // -> {pets: {species: {type: 'string'}}}
|
|
110
|
+
* ```
|
|
111
|
+
* @category Creation
|
|
112
|
+
* @since v7.1.0
|
|
113
|
+
*/
|
|
114
|
+
export function createValibotSchematizer(): ValibotSchematizer;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schematizer-yup module provides conversion utilities for Yup schemas.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
* @module schematizer-yup
|
|
5
|
+
* @since v7.1.0
|
|
6
|
+
*/
|
|
7
|
+
import type {TablesSchema, ValuesSchema} from '../../store/index.d.ts';
|
|
8
|
+
import type {Schematizer} from '../index.d.ts';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The YupSchematizer interface represents a schematizer specifically for
|
|
12
|
+
* converting Yup schemas into TinyBase schemas.
|
|
13
|
+
* @category Schematizer
|
|
14
|
+
* @since v7.1.0
|
|
15
|
+
*/
|
|
16
|
+
export interface YupSchematizer extends Schematizer {
|
|
17
|
+
/**
|
|
18
|
+
* The toTablesSchema method converts a mapping of Yup object schemas into a
|
|
19
|
+
* TinyBase TablesSchema.
|
|
20
|
+
*
|
|
21
|
+
* This method extracts basic type information (string, number, boolean),
|
|
22
|
+
* default values, and nullable flags from Yup schemas. Complex validation
|
|
23
|
+
* rules like min/max, regex patterns, tests, and transforms are ignored.
|
|
24
|
+
* @param schemas - A mapping of table IDs to Yup object schemas.
|
|
25
|
+
* @returns A TinyBase TablesSchema.
|
|
26
|
+
* @example
|
|
27
|
+
* This example converts Yup schemas to TinyBase format.
|
|
28
|
+
*
|
|
29
|
+
* ```js
|
|
30
|
+
* import {createStore} from 'tinybase';
|
|
31
|
+
* import {createYupSchematizer} from 'tinybase/schematizers/schematizer-yup';
|
|
32
|
+
* import {boolean, number, object, string} from 'yup';
|
|
33
|
+
*
|
|
34
|
+
* const schematizer = createYupSchematizer();
|
|
35
|
+
*
|
|
36
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
37
|
+
* pets: object({
|
|
38
|
+
* species: string(),
|
|
39
|
+
* age: number(),
|
|
40
|
+
* sold: boolean().default(false),
|
|
41
|
+
* }),
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* const store = createStore().setTablesSchema(tablesSchema);
|
|
45
|
+
* store.setRow('pets', 'fido', {species: 'dog', age: 3});
|
|
46
|
+
* console.log(store.getRow('pets', 'fido'));
|
|
47
|
+
* // -> {species: 'dog', age: 3, sold: false}
|
|
48
|
+
* ```
|
|
49
|
+
* @category Conversion
|
|
50
|
+
* @since v7.1.0
|
|
51
|
+
*/
|
|
52
|
+
toTablesSchema(schemas: {[tableId: string]: any}): TablesSchema;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The toValuesSchema method converts a mapping of Yup schemas into a TinyBase
|
|
56
|
+
* ValuesSchema.
|
|
57
|
+
*
|
|
58
|
+
* This method extracts basic type information (string, number, boolean),
|
|
59
|
+
* default values, and nullable flags from Yup schemas.
|
|
60
|
+
* @param schemas - A mapping of value IDs to Yup schemas.
|
|
61
|
+
* @returns A TinyBase ValuesSchema.
|
|
62
|
+
* @example
|
|
63
|
+
* This example converts Yup schemas to TinyBase values.
|
|
64
|
+
*
|
|
65
|
+
* ```js
|
|
66
|
+
* import {createStore} from 'tinybase';
|
|
67
|
+
* import {createYupSchematizer} from 'tinybase/schematizers/schematizer-yup';
|
|
68
|
+
* import {boolean, number} from 'yup';
|
|
69
|
+
*
|
|
70
|
+
* const schematizer = createYupSchematizer();
|
|
71
|
+
*
|
|
72
|
+
* const valuesSchema = schematizer.toValuesSchema({
|
|
73
|
+
* open: boolean().default(true),
|
|
74
|
+
* employees: number(),
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* const store = createStore().setValuesSchema(valuesSchema);
|
|
78
|
+
* console.log(store.getValues());
|
|
79
|
+
* // -> {open: true}
|
|
80
|
+
* ```
|
|
81
|
+
* @category Conversion
|
|
82
|
+
* @since v7.1.0
|
|
83
|
+
*/
|
|
84
|
+
toValuesSchema(schemas: {[valueId: string]: any}): ValuesSchema;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The createYupSchematizer function creates a YupSchematizer instance for
|
|
89
|
+
* converting Yup schemas to TinyBase schemas.
|
|
90
|
+
* @returns A new YupSchematizer instance.
|
|
91
|
+
* @example
|
|
92
|
+
* This example creates a Yup schematizer.
|
|
93
|
+
*
|
|
94
|
+
* ```js
|
|
95
|
+
* import {createYupSchematizer} from 'tinybase/schematizers/schematizer-yup';
|
|
96
|
+
* import {object, string} from 'yup';
|
|
97
|
+
*
|
|
98
|
+
* const schematizer = createYupSchematizer();
|
|
99
|
+
*
|
|
100
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
101
|
+
* pets: object({
|
|
102
|
+
* species: string(),
|
|
103
|
+
* }),
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* console.log(tablesSchema);
|
|
107
|
+
* // -> {pets: {species: {type: 'string'}}}
|
|
108
|
+
* ```
|
|
109
|
+
* @category Creation
|
|
110
|
+
* @since v7.1.0
|
|
111
|
+
*/
|
|
112
|
+
export function createYupSchematizer(): YupSchematizer;
|
package/checkpoints/index.js
CHANGED
|
@@ -44,7 +44,7 @@ const mapGet = (map, key) => map?.get(key);
|
|
|
44
44
|
const mapForEach = (map, cb) =>
|
|
45
45
|
collForEach(map, (value, key) => cb(key, value));
|
|
46
46
|
const mapSet = (map, key, value) =>
|
|
47
|
-
value
|
|
47
|
+
isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
|
|
48
48
|
const mapEnsure = (map, key, getDefaultValue, hadExistingValue) => {
|
|
49
49
|
if (!collHas(map, key)) {
|
|
50
50
|
mapSet(map, key, getDefaultValue());
|
|
@@ -114,7 +114,7 @@ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
|
|
|
114
114
|
const deep = (node, p) =>
|
|
115
115
|
p == size(path)
|
|
116
116
|
? arrayPush(leaves, node)
|
|
117
|
-
: path[p]
|
|
117
|
+
: isNull(path[p])
|
|
118
118
|
? collForEach(node, (node2) => deep(node2, p + 1))
|
|
119
119
|
: arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
|
|
120
120
|
deep(deepIdSet, 0);
|
|
@@ -44,7 +44,7 @@ const mapGet = (map, key) => map?.get(key);
|
|
|
44
44
|
const mapForEach = (map, cb) =>
|
|
45
45
|
collForEach(map, (value, key) => cb(key, value));
|
|
46
46
|
const mapSet = (map, key, value) =>
|
|
47
|
-
value
|
|
47
|
+
isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
|
|
48
48
|
const mapEnsure = (map, key, getDefaultValue, hadExistingValue) => {
|
|
49
49
|
if (!collHas(map, key)) {
|
|
50
50
|
mapSet(map, key, getDefaultValue());
|
|
@@ -114,7 +114,7 @@ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
|
|
|
114
114
|
const deep = (node, p) =>
|
|
115
115
|
p == size(path)
|
|
116
116
|
? arrayPush(leaves, node)
|
|
117
|
-
: path[p]
|
|
117
|
+
: isNull(path[p])
|
|
118
118
|
? collForEach(node, (node2) => deep(node2, p + 1))
|
|
119
119
|
: arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
|
|
120
120
|
deep(deepIdSet, 0);
|
package/index.js
CHANGED
|
@@ -51,6 +51,8 @@ const isInstanceOf = (thing, cls) => thing instanceof cls;
|
|
|
51
51
|
const isNullish = (thing) => thing == null;
|
|
52
52
|
const isUndefined = (thing) => thing === void 0;
|
|
53
53
|
const isNull = (thing) => thing === null;
|
|
54
|
+
const isTrue = (thing) => thing === true;
|
|
55
|
+
const isFalse = (thing) => thing === false;
|
|
54
56
|
const ifNotNullish = getIfNotFunction(isNullish);
|
|
55
57
|
const ifNotUndefined = getIfNotFunction(isUndefined);
|
|
56
58
|
const isTypeStringOrBoolean = (type) => type == STRING || type == BOOLEAN;
|
|
@@ -188,7 +190,7 @@ const mapForEach = (map, cb) =>
|
|
|
188
190
|
const mapMap = (coll, cb) =>
|
|
189
191
|
arrayMap([...(coll?.entries() ?? [])], ([key, value]) => cb(value, key));
|
|
190
192
|
const mapSet = (map, key, value) =>
|
|
191
|
-
value
|
|
193
|
+
isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
|
|
192
194
|
const mapEnsure = (map, key, getDefaultValue, hadExistingValue) => {
|
|
193
195
|
if (!collHas(map, key)) {
|
|
194
196
|
mapSet(map, key, getDefaultValue());
|
|
@@ -456,7 +458,7 @@ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
|
|
|
456
458
|
const deep = (node, p) =>
|
|
457
459
|
p == size(path)
|
|
458
460
|
? arrayPush(leaves, node)
|
|
459
|
-
: path[p]
|
|
461
|
+
: isNull(path[p])
|
|
460
462
|
? collForEach(node, (node2) => deep(node2, p + 1))
|
|
461
463
|
: arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
|
|
462
464
|
deep(deepIdSet, 0);
|
|
@@ -3133,8 +3135,8 @@ const createMetrics = getCreateFunction((store) => {
|
|
|
3133
3135
|
(value) =>
|
|
3134
3136
|
isNaN(value) ||
|
|
3135
3137
|
isUndefined(value) ||
|
|
3136
|
-
value
|
|
3137
|
-
value
|
|
3138
|
+
isTrue(value) ||
|
|
3139
|
+
isFalse(value) ||
|
|
3138
3140
|
value === EMPTY_STRING
|
|
3139
3141
|
? void 0
|
|
3140
3142
|
: value * 1,
|
package/indexes/index.js
CHANGED
|
@@ -51,7 +51,7 @@ const mapGet = (map, key) => map?.get(key);
|
|
|
51
51
|
const mapForEach = (map, cb) =>
|
|
52
52
|
collForEach(map, (value, key) => cb(key, value));
|
|
53
53
|
const mapSet = (map, key, value) =>
|
|
54
|
-
value
|
|
54
|
+
isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
|
|
55
55
|
const mapEnsure = (map, key, getDefaultValue, hadExistingValue) => {
|
|
56
56
|
if (!collHas(map, key)) {
|
|
57
57
|
mapSet(map, key, getDefaultValue());
|
|
@@ -283,7 +283,7 @@ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
|
|
|
283
283
|
const deep = (node, p) =>
|
|
284
284
|
p == size(path)
|
|
285
285
|
? arrayPush(leaves, node)
|
|
286
|
-
: path[p]
|
|
286
|
+
: isNull(path[p])
|
|
287
287
|
? collForEach(node, (node2) => deep(node2, p + 1))
|
|
288
288
|
: arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
|
|
289
289
|
deep(deepIdSet, 0);
|
|
@@ -51,7 +51,7 @@ const mapGet = (map, key) => map?.get(key);
|
|
|
51
51
|
const mapForEach = (map, cb) =>
|
|
52
52
|
collForEach(map, (value, key) => cb(key, value));
|
|
53
53
|
const mapSet = (map, key, value) =>
|
|
54
|
-
value
|
|
54
|
+
isUndefined(value) ? (collDel(map, key), map) : map?.set(key, value);
|
|
55
55
|
const mapEnsure = (map, key, getDefaultValue, hadExistingValue) => {
|
|
56
56
|
if (!collHas(map, key)) {
|
|
57
57
|
mapSet(map, key, getDefaultValue());
|
|
@@ -283,7 +283,7 @@ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
|
|
|
283
283
|
const deep = (node, p) =>
|
|
284
284
|
p == size(path)
|
|
285
285
|
? arrayPush(leaves, node)
|
|
286
|
-
: path[p]
|
|
286
|
+
: isNull(path[p])
|
|
287
287
|
? collForEach(node, (node2) => deep(node2, p + 1))
|
|
288
288
|
: arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
|
|
289
289
|
deep(deepIdSet, 0);
|