tinybase 9.4.0 → 9.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/_internal/store/with-schemas/index.d.ts +43 -8
- package/@types/mergeable-store/with-schemas/index.d.ts +30 -11
- package/@types/queries/index.d.ts +11 -11
- package/@types/queries/with-schemas/index.d.ts +17 -3
- package/@types/schematizers/index.d.ts +6 -4
- package/@types/schematizers/schematizer-arktype/index.d.ts +6 -6
- package/@types/schematizers/schematizer-arktype/with-schemas/index.d.ts +112 -1
- package/@types/schematizers/schematizer-effect/index.d.ts +9 -11
- package/@types/schematizers/schematizer-effect/with-schemas/index.d.ts +114 -1
- package/@types/schematizers/schematizer-typebox/index.d.ts +7 -7
- package/@types/schematizers/schematizer-typebox/with-schemas/index.d.ts +114 -1
- package/@types/schematizers/schematizer-valibot/index.d.ts +6 -6
- package/@types/schematizers/schematizer-valibot/with-schemas/index.d.ts +112 -1
- package/@types/schematizers/schematizer-yup/index.d.ts +5 -4
- package/@types/schematizers/schematizer-yup/with-schemas/index.d.ts +112 -1
- package/@types/schematizers/schematizer-zod/index.d.ts +6 -6
- package/@types/schematizers/schematizer-zod/with-schemas/index.d.ts +112 -1
- package/@types/schematizers/with-schemas/index.d.ts +113 -4
- package/@types/store/index.d.ts +175 -16
- package/@types/store/with-schemas/index.d.ts +238 -55
- package/@types/synchronizers/with-schemas/index.d.ts +12 -2
- package/@types/ui-react/with-schemas/index.d.ts +576 -7
- package/@types/ui-react-dom/index.d.ts +10 -10
- package/@types/ui-react-dom/with-schemas/index.d.ts +94 -10
- package/@types/ui-react-dom-charts/index.d.ts +7 -7
- package/@types/ui-react-dom-charts/with-schemas/index.d.ts +7 -7
- package/@types/ui-react-inspector/index.d.ts +1 -1
- package/@types/ui-react-inspector/with-schemas/index.d.ts +1 -1
- package/@types/ui-solid/with-schemas/index.d.ts +340 -7
- package/@types/ui-solid-dom/index.d.ts +10 -10
- package/@types/ui-solid-dom/with-schemas/index.d.ts +94 -10
- package/@types/ui-solid-inspector/index.d.ts +1 -1
- package/@types/ui-solid-inspector/with-schemas/index.d.ts +1 -1
- package/@types/ui-svelte/with-schemas/index.d.ts +30 -0
- package/@types/ui-svelte-dom/index.d.ts +10 -10
- package/@types/ui-svelte-dom/with-schemas/index.d.ts +94 -10
- package/@types/ui-svelte-inspector/index.d.ts +1 -1
- package/@types/ui-svelte-inspector/with-schemas/index.d.ts +1 -1
- package/agents.md +4 -0
- package/index.js +76 -22
- package/mergeable-store/index.js +76 -22
- package/mergeable-store/with-schemas/index.js +76 -22
- 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/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/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/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/ui-solid-inspector/index.js +1 -1
- package/min/ui-solid-inspector/index.js.gz +0 -0
- package/min/ui-solid-inspector/with-schemas/index.js +1 -1
- package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-inspector/index.js +1 -1
- package/min/ui-svelte-inspector/index.js.gz +0 -0
- package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
- package/min/ui-svelte-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 +76 -22
- package/omni/with-schemas/index.js +76 -22
- package/package.json +2 -2
- package/readme.md +14 -14
- package/releases.md +95 -65
- package/schematizers/index.js +54 -6
- package/schematizers/schematizer-arktype/index.js +99 -19
- package/schematizers/schematizer-arktype/with-schemas/index.js +99 -19
- package/schematizers/schematizer-effect/index.js +101 -11
- package/schematizers/schematizer-effect/with-schemas/index.js +101 -11
- package/schematizers/schematizer-typebox/index.js +87 -11
- package/schematizers/schematizer-typebox/with-schemas/index.js +87 -11
- package/schematizers/schematizer-valibot/index.js +125 -21
- package/schematizers/schematizer-valibot/with-schemas/index.js +125 -21
- package/schematizers/schematizer-yup/index.js +58 -14
- package/schematizers/schematizer-yup/with-schemas/index.js +58 -14
- package/schematizers/schematizer-zod/index.js +131 -12
- package/schematizers/schematizer-zod/with-schemas/index.js +131 -12
- package/schematizers/with-schemas/index.js +54 -6
- package/store/index.js +76 -22
- package/store/with-schemas/index.js +76 -22
- package/ui-react-inspector/index.js +76 -22
- package/ui-react-inspector/with-schemas/index.js +76 -22
- package/ui-solid-inspector/index.js +76 -22
- package/ui-solid-inspector/with-schemas/index.js +76 -22
- package/ui-svelte-inspector/index.js +76 -22
- package/ui-svelte-inspector/with-schemas/index.js +76 -22
- package/with-schemas/index.js +76 -22
|
@@ -5,7 +5,9 @@ import type {
|
|
|
5
5
|
OptionalTablesSchema,
|
|
6
6
|
OptionalValuesSchema,
|
|
7
7
|
Store,
|
|
8
|
+
TablesSchema,
|
|
8
9
|
Value,
|
|
10
|
+
ValuesSchema,
|
|
9
11
|
} from '../../../store/with-schemas/index.d.ts';
|
|
10
12
|
|
|
11
13
|
export type TableIdFromSchema<Schema extends OptionalTablesSchema> = AsId<
|
|
@@ -94,10 +96,10 @@ export type CellIsDefaultedFromSchema<
|
|
|
94
96
|
CellId extends CellIdFromSchema<Schema, TableId>,
|
|
95
97
|
Then,
|
|
96
98
|
Else,
|
|
97
|
-
> = Schema[TableId][CellId] extends {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
> = Schema[TableId][CellId] extends {default: infer Default}
|
|
100
|
+
? [Default] extends [Cell<Schema, TableId, CellId>]
|
|
101
|
+
? Then
|
|
102
|
+
: Else
|
|
101
103
|
: Else;
|
|
102
104
|
|
|
103
105
|
export type CellIsRequiredFromSchema<
|
|
@@ -190,12 +192,45 @@ export type ValueIsDefaultedFromSchema<
|
|
|
190
192
|
ValueId extends ValueIdFromSchema<Schema>,
|
|
191
193
|
Then,
|
|
192
194
|
Else,
|
|
193
|
-
> = Schema[ValueId] extends {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
> = Schema[ValueId] extends {default: infer Default}
|
|
196
|
+
? [Default] extends [Value<Schema, ValueId>]
|
|
197
|
+
? Then
|
|
198
|
+
: Else
|
|
197
199
|
: Else;
|
|
198
200
|
|
|
201
|
+
type ValidCellDefault<
|
|
202
|
+
Schema extends TablesSchema,
|
|
203
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
204
|
+
CellId extends CellIdFromSchema<Schema, TableId>,
|
|
205
|
+
> = Schema[TableId][CellId] extends {default: infer Default}
|
|
206
|
+
? [Default] extends [Cell<Schema, TableId, CellId>]
|
|
207
|
+
? unknown
|
|
208
|
+
: never
|
|
209
|
+
: unknown;
|
|
210
|
+
|
|
211
|
+
export type ValidTablesSchema<Schema extends TablesSchema> = {
|
|
212
|
+
[TableId in TableIdFromSchema<Schema>]: {
|
|
213
|
+
[CellId in CellIdFromSchema<Schema, TableId>]: ValidCellDefault<
|
|
214
|
+
Schema,
|
|
215
|
+
TableId,
|
|
216
|
+
CellId
|
|
217
|
+
>;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
type ValidValueDefault<
|
|
222
|
+
Schema extends ValuesSchema,
|
|
223
|
+
ValueId extends ValueIdFromSchema<Schema>,
|
|
224
|
+
> = Schema[ValueId] extends {default: infer Default}
|
|
225
|
+
? [Default] extends [Value<Schema, ValueId>]
|
|
226
|
+
? unknown
|
|
227
|
+
: never
|
|
228
|
+
: unknown;
|
|
229
|
+
|
|
230
|
+
export type ValidValuesSchema<Schema extends ValuesSchema> = {
|
|
231
|
+
[ValueId in ValueIdFromSchema<Schema>]: ValidValueDefault<Schema, ValueId>;
|
|
232
|
+
};
|
|
233
|
+
|
|
199
234
|
export type ValueIsRequiredFromSchema<
|
|
200
235
|
Schema extends OptionalValuesSchema,
|
|
201
236
|
ValueId extends ValueIdFromSchema<Schema>,
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
import type {
|
|
23
23
|
CellIdFromSchema,
|
|
24
24
|
TableIdFromSchema,
|
|
25
|
+
ValidTablesSchema,
|
|
26
|
+
ValidValuesSchema,
|
|
25
27
|
ValueIdFromSchema,
|
|
26
28
|
} from '../../_internal/store/with-schemas/index.d.ts';
|
|
27
29
|
import type {GetNow, Hash, Hlc, Id} from '../../common/with-schemas/index.d.ts';
|
|
@@ -1327,9 +1329,12 @@ export interface MergeableStore<
|
|
|
1327
1329
|
* @category Setter
|
|
1328
1330
|
* @since v3.0.0
|
|
1329
1331
|
*/
|
|
1330
|
-
setTablesSchema<TS extends TablesSchema>(
|
|
1331
|
-
tablesSchema: TS
|
|
1332
|
-
): MergeableStore<[
|
|
1332
|
+
setTablesSchema<const TS extends TablesSchema>(
|
|
1333
|
+
tablesSchema: TS & ValidTablesSchema<TS>,
|
|
1334
|
+
): MergeableStore<[TS, Schemas[1]]>;
|
|
1335
|
+
setTablesSchema<const TS extends TablesSchema>(
|
|
1336
|
+
tablesSchema: TS & ValidTablesSchema<TS>,
|
|
1337
|
+
): Store<[TS, Schemas[1]]>;
|
|
1333
1338
|
|
|
1334
1339
|
/**
|
|
1335
1340
|
* The setValuesSchema method lets you specify the ValuesSchema of the keyed
|
|
@@ -1360,9 +1365,12 @@ export interface MergeableStore<
|
|
|
1360
1365
|
* @category Setter
|
|
1361
1366
|
* @since v3.0.0
|
|
1362
1367
|
*/
|
|
1363
|
-
setValuesSchema<VS extends ValuesSchema>(
|
|
1364
|
-
valuesSchema: VS
|
|
1365
|
-
): MergeableStore<[Schemas[0],
|
|
1368
|
+
setValuesSchema<const VS extends ValuesSchema>(
|
|
1369
|
+
valuesSchema: VS & ValidValuesSchema<VS>,
|
|
1370
|
+
): MergeableStore<[Schemas[0], VS]>;
|
|
1371
|
+
setValuesSchema<const VS extends ValuesSchema>(
|
|
1372
|
+
valuesSchema: VS & ValidValuesSchema<VS>,
|
|
1373
|
+
): Store<[Schemas[0], VS]>;
|
|
1366
1374
|
|
|
1367
1375
|
/**
|
|
1368
1376
|
* The setSchema method lets you specify the TablesSchema and ValuesSchema of
|
|
@@ -1425,15 +1433,26 @@ export interface MergeableStore<
|
|
|
1425
1433
|
* @category Setter
|
|
1426
1434
|
* @since v1.0.0
|
|
1427
1435
|
*/
|
|
1428
|
-
setSchema<TS extends TablesSchema, VS extends ValuesSchema>(
|
|
1429
|
-
tablesSchema: TS
|
|
1430
|
-
valuesSchema?: VS
|
|
1436
|
+
setSchema<const TS extends TablesSchema, const VS extends ValuesSchema>(
|
|
1437
|
+
tablesSchema: TS & ValidTablesSchema<TS>,
|
|
1438
|
+
valuesSchema?: VS & ValidValuesSchema<VS>,
|
|
1431
1439
|
): MergeableStore<
|
|
1432
1440
|
[
|
|
1433
|
-
|
|
1441
|
+
TS,
|
|
1434
1442
|
Exclude<ValuesSchema, typeof valuesSchema> extends never
|
|
1435
1443
|
? NoValuesSchema
|
|
1436
|
-
:
|
|
1444
|
+
: VS,
|
|
1445
|
+
]
|
|
1446
|
+
>;
|
|
1447
|
+
setSchema<const TS extends TablesSchema, const VS extends ValuesSchema>(
|
|
1448
|
+
tablesSchema: TS & ValidTablesSchema<TS>,
|
|
1449
|
+
valuesSchema?: VS & ValidValuesSchema<VS>,
|
|
1450
|
+
): Store<
|
|
1451
|
+
[
|
|
1452
|
+
TS,
|
|
1453
|
+
Exclude<ValuesSchema, typeof valuesSchema> extends never
|
|
1454
|
+
? NoValuesSchema
|
|
1455
|
+
: VS,
|
|
1437
1456
|
]
|
|
1438
1457
|
>;
|
|
1439
1458
|
|
|
@@ -113,7 +113,7 @@ export type ResultRow = {[cellId: Id]: ResultCell};
|
|
|
113
113
|
* A ResultCell is typically accessed with the getResultCell method or
|
|
114
114
|
* addResultCellListener method. It is similar to the Cell type in the store
|
|
115
115
|
* module, but without schema-specific typing, and is a JavaScript string,
|
|
116
|
-
* number, or
|
|
116
|
+
* number, boolean, null, object, or array.
|
|
117
117
|
* @example
|
|
118
118
|
* ```js
|
|
119
119
|
* import type {ResultCell} from 'tinybase';
|
|
@@ -123,7 +123,7 @@ export type ResultRow = {[cellId: Id]: ResultCell};
|
|
|
123
123
|
* @category Result
|
|
124
124
|
* @since v2.0.0
|
|
125
125
|
*/
|
|
126
|
-
export type ResultCell =
|
|
126
|
+
export type ResultCell = Cell;
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* The ResultCellOrUndefined type is the data structure representing a single
|
|
@@ -146,7 +146,7 @@ export type ResultCellOrUndefined = ResultCell | undefined;
|
|
|
146
146
|
* @category Aggregators
|
|
147
147
|
* @since v2.0.0
|
|
148
148
|
*/
|
|
149
|
-
export type Aggregate = (cells:
|
|
149
|
+
export type Aggregate = (cells: ResultCell[], length: number) => ResultCell;
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* The AggregateAdd type describes a function that can be used to optimize a
|
|
@@ -172,8 +172,8 @@ export type Aggregate = (cells: Cell[], length: number) => ResultCell;
|
|
|
172
172
|
* @since v2.0.0
|
|
173
173
|
*/
|
|
174
174
|
export type AggregateAdd = (
|
|
175
|
-
current:
|
|
176
|
-
add:
|
|
175
|
+
current: ResultCell,
|
|
176
|
+
add: ResultCell,
|
|
177
177
|
length: number,
|
|
178
178
|
) => ResultCellOrUndefined;
|
|
179
179
|
|
|
@@ -204,8 +204,8 @@ export type AggregateAdd = (
|
|
|
204
204
|
* @since v2.0.0
|
|
205
205
|
*/
|
|
206
206
|
export type AggregateRemove = (
|
|
207
|
-
current:
|
|
208
|
-
remove:
|
|
207
|
+
current: ResultCell,
|
|
208
|
+
remove: ResultCell,
|
|
209
209
|
length: number,
|
|
210
210
|
) => ResultCellOrUndefined;
|
|
211
211
|
|
|
@@ -235,9 +235,9 @@ export type AggregateRemove = (
|
|
|
235
235
|
* @since v2.0.0
|
|
236
236
|
*/
|
|
237
237
|
export type AggregateReplace = (
|
|
238
|
-
current:
|
|
239
|
-
add:
|
|
240
|
-
remove:
|
|
238
|
+
current: ResultCell,
|
|
239
|
+
add: ResultCell,
|
|
240
|
+
remove: ResultCell,
|
|
241
241
|
length: number,
|
|
242
242
|
) => ResultCellOrUndefined;
|
|
243
243
|
|
|
@@ -2055,7 +2055,7 @@ export type Having = {
|
|
|
2055
2055
|
* @category Definition
|
|
2056
2056
|
* @since v2.0.0
|
|
2057
2057
|
*/
|
|
2058
|
-
(selectedOrGroupedCellId: Id, equals:
|
|
2058
|
+
(selectedOrGroupedCellId: Id, equals: ResultCell): void;
|
|
2059
2059
|
/**
|
|
2060
2060
|
* Calling this function with one callback parameter is used to include only
|
|
2061
2061
|
* those Rows which meet a calculated boolean condition.
|
|
@@ -19,7 +19,7 @@ import type {
|
|
|
19
19
|
TableIdFromSchema,
|
|
20
20
|
} from '../../_internal/store/with-schemas/index.d.ts';
|
|
21
21
|
import type {Id, IdOrNull, Ids} from '../../common/with-schemas/index.d.ts';
|
|
22
|
-
import type {GetIdChanges} from '../../store/index.d.ts';
|
|
22
|
+
import type {Cell as BaseCell, GetIdChanges} from '../../store/index.d.ts';
|
|
23
23
|
import type {
|
|
24
24
|
Cell,
|
|
25
25
|
CellOrUndefined,
|
|
@@ -124,7 +124,7 @@ export type ResultRow = {[cellId: Id]: ResultCell};
|
|
|
124
124
|
* A ResultCell is typically accessed with the getResultCell method or
|
|
125
125
|
* addResultCellListener method. It is similar to the Cell type in the store
|
|
126
126
|
* module, but without schema-specific typing, and is a JavaScript string,
|
|
127
|
-
* number, or
|
|
127
|
+
* number, boolean, null, object, or array.
|
|
128
128
|
* @example
|
|
129
129
|
* ```js
|
|
130
130
|
* import type {ResultCell} from 'tinybase';
|
|
@@ -134,7 +134,7 @@ export type ResultRow = {[cellId: Id]: ResultCell};
|
|
|
134
134
|
* @category Result
|
|
135
135
|
* @since v2.0.0
|
|
136
136
|
*/
|
|
137
|
-
export type ResultCell =
|
|
137
|
+
export type ResultCell = BaseCell;
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* The ResultCellOrUndefined type is the data structure representing a single
|
|
@@ -833,6 +833,20 @@ export type QueriesListenerStats = {
|
|
|
833
833
|
* @since v2.0.0
|
|
834
834
|
*/
|
|
835
835
|
cell: number;
|
|
836
|
+
/**
|
|
837
|
+
* The number of ParamValuesListener functions registered with the Queries
|
|
838
|
+
* object.
|
|
839
|
+
* @category Stat
|
|
840
|
+
* @since v2.0.0
|
|
841
|
+
*/
|
|
842
|
+
paramValues: number;
|
|
843
|
+
/**
|
|
844
|
+
* The number of ParamValueListener functions registered with the Queries
|
|
845
|
+
* object.
|
|
846
|
+
* @category Stat
|
|
847
|
+
* @since v7.2.0
|
|
848
|
+
*/
|
|
849
|
+
paramValue: number;
|
|
836
850
|
};
|
|
837
851
|
|
|
838
852
|
/**
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* The schematizers module provides utilities for converting schemas from
|
|
3
3
|
* popular validation libraries into TinyBase's schema format.
|
|
4
4
|
*
|
|
5
|
-
* Schematizers perform "best-effort" conversion, extracting basic type
|
|
6
|
-
*
|
|
7
|
-
* complex validation rules that TinyBase doesn't support.
|
|
5
|
+
* Schematizers perform "best-effort" conversion, extracting basic type and
|
|
6
|
+
* type union, primitive enum and literal, and default information while
|
|
7
|
+
* discarding complex validation rules that TinyBase doesn't support.
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
* @module schematizers
|
|
10
10
|
* @since v7.1.0
|
|
@@ -51,7 +51,9 @@ export interface Schematizer {
|
|
|
51
51
|
* @param unwrapSchema - A function that unwraps a schema to extract the base
|
|
52
52
|
* type, default value, nullable flag, and optional required flag. It should
|
|
53
53
|
* recursively unwrap optional/nullable wrappers and return a tuple of
|
|
54
|
-
* [schema, defaultValue, allowNull, required].
|
|
54
|
+
* [schema, defaultValue, allowNull, required]. The unwrapped schema should have
|
|
55
|
+
* either a supported `type` property, a non-empty `type` array containing
|
|
56
|
+
* supported types, or a non-empty `enum` property containing primitive values.
|
|
55
57
|
* @param getProperties - A function that extracts the properties/entries/shape
|
|
56
58
|
* from an object schema. Returns undefined if the schema is not an object.
|
|
57
59
|
* @param getPropertyRequired - An optional function that extracts whether an
|
|
@@ -19,10 +19,10 @@ export interface ArkTypeSchematizer extends Schematizer {
|
|
|
19
19
|
* The toTablesSchema method converts a mapping of ArkType object schemas into a
|
|
20
20
|
* TinyBase TablesSchema.
|
|
21
21
|
*
|
|
22
|
-
* This method extracts basic type information (string, number, boolean),
|
|
23
|
-
*
|
|
24
|
-
* ArkType schemas. Complex validation rules like min/max,
|
|
25
|
-
* refinements, and transforms are ignored.
|
|
22
|
+
* This method extracts basic type information (string, number, boolean), basic
|
|
23
|
+
* type unions, primitive literal unions, default values, nullable flags, and
|
|
24
|
+
* required flags from ArkType schemas. Complex validation rules like min/max,
|
|
25
|
+
* regex patterns, refinements, and transforms are ignored.
|
|
26
26
|
* @param schemas - A mapping of table IDs to ArkType object schemas.
|
|
27
27
|
* @returns A TinyBase TablesSchema.
|
|
28
28
|
* @example
|
|
@@ -57,8 +57,8 @@ export interface ArkTypeSchematizer extends Schematizer {
|
|
|
57
57
|
* The toValuesSchema method converts a mapping of ArkType schemas into a
|
|
58
58
|
* TinyBase ValuesSchema.
|
|
59
59
|
*
|
|
60
|
-
* This method extracts basic type information
|
|
61
|
-
* values, and required flags from ArkType schemas.
|
|
60
|
+
* This method extracts basic type information and unions, primitive literal
|
|
61
|
+
* unions, default values, and required flags from ArkType schemas.
|
|
62
62
|
* @param schemas - A mapping of value IDs to ArkType schemas.
|
|
63
63
|
* @returns A TinyBase ValuesSchema.
|
|
64
64
|
* @example
|
|
@@ -5,4 +5,115 @@
|
|
|
5
5
|
* @module schematizer-arktype
|
|
6
6
|
* @since v7.1.0
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import type {
|
|
9
|
+
TablesSchema,
|
|
10
|
+
ValuesSchema,
|
|
11
|
+
} from '../../../store/with-schemas/index.d.ts';
|
|
12
|
+
import type {Schematizer} from '../../with-schemas/index.d.ts';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The ArkTypeSchematizer interface represents a schematizer specifically for
|
|
16
|
+
* converting ArkType schemas into TinyBase schemas.
|
|
17
|
+
* @category Schematizer
|
|
18
|
+
* @since v7.1.0
|
|
19
|
+
*/
|
|
20
|
+
export interface ArkTypeSchematizer extends Schematizer {
|
|
21
|
+
/**
|
|
22
|
+
* The toTablesSchema method converts a mapping of ArkType object schemas into a
|
|
23
|
+
* TinyBase TablesSchema.
|
|
24
|
+
*
|
|
25
|
+
* This method extracts basic type information (string, number, boolean), basic
|
|
26
|
+
* type unions, primitive literal unions, default values, nullable flags, and
|
|
27
|
+
* required flags from ArkType schemas. Complex validation rules like min/max,
|
|
28
|
+
* regex patterns, refinements, and transforms are ignored.
|
|
29
|
+
* @param schemas - A mapping of table IDs to ArkType object schemas.
|
|
30
|
+
* @returns A TinyBase TablesSchema.
|
|
31
|
+
* @example
|
|
32
|
+
* This example converts ArkType schemas to TinyBase format.
|
|
33
|
+
*
|
|
34
|
+
* ```js
|
|
35
|
+
* import {type} from 'arktype';
|
|
36
|
+
* import {createStore} from 'tinybase';
|
|
37
|
+
* import {createArkTypeSchematizer} from 'tinybase/schematizers/schematizer-arktype';
|
|
38
|
+
*
|
|
39
|
+
* const schematizer = createArkTypeSchematizer();
|
|
40
|
+
*
|
|
41
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
42
|
+
* pets: type({
|
|
43
|
+
* species: 'string',
|
|
44
|
+
* age: 'number',
|
|
45
|
+
* sold: type('boolean').default(false),
|
|
46
|
+
* }),
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* const store = createStore().setTablesSchema(tablesSchema);
|
|
50
|
+
* store.setRow('pets', 'fido', {species: 'dog', age: 3});
|
|
51
|
+
* console.log(store.getRow('pets', 'fido'));
|
|
52
|
+
* // -> {species: 'dog', age: 3, sold: false}
|
|
53
|
+
* ```
|
|
54
|
+
* @category Conversion
|
|
55
|
+
* @since v7.1.0
|
|
56
|
+
*/
|
|
57
|
+
toTablesSchema(schemas: {[tableId: string]: any}): TablesSchema;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The toValuesSchema method converts a mapping of ArkType schemas into a
|
|
61
|
+
* TinyBase ValuesSchema.
|
|
62
|
+
*
|
|
63
|
+
* This method extracts basic type information and unions, primitive literal
|
|
64
|
+
* unions, default values, and required flags from ArkType schemas.
|
|
65
|
+
* @param schemas - A mapping of value IDs to ArkType schemas.
|
|
66
|
+
* @returns A TinyBase ValuesSchema.
|
|
67
|
+
* @example
|
|
68
|
+
* This example converts ArkType value schemas.
|
|
69
|
+
*
|
|
70
|
+
* ```js
|
|
71
|
+
* import {type} from 'arktype';
|
|
72
|
+
* import {createStore} from 'tinybase';
|
|
73
|
+
* import {createArkTypeSchematizer} from 'tinybase/schematizers/schematizer-arktype';
|
|
74
|
+
*
|
|
75
|
+
* const schematizer = createArkTypeSchematizer();
|
|
76
|
+
*
|
|
77
|
+
* const valuesSchema = schematizer.toValuesSchema({
|
|
78
|
+
* theme: type('string').default('light'),
|
|
79
|
+
* count: 'number',
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* const store = createStore().setValuesSchema(valuesSchema);
|
|
83
|
+
* store.setValues({count: 1});
|
|
84
|
+
* console.log(store.getValues());
|
|
85
|
+
* // -> {theme: 'light', count: 1}
|
|
86
|
+
* ```
|
|
87
|
+
* @category Conversion
|
|
88
|
+
* @since v7.1.0
|
|
89
|
+
*/
|
|
90
|
+
toValuesSchema(schemas: {[valueId: string]: any}): ValuesSchema;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The createArkTypeSchematizer function creates an ArkTypeSchematizer object
|
|
95
|
+
* that can convert ArkType schemas into TinyBase schemas.
|
|
96
|
+
*
|
|
97
|
+
* The schematizer is stateless and can be reused for multiple conversions.
|
|
98
|
+
* @returns A new ArkTypeSchematizer instance.
|
|
99
|
+
* @example
|
|
100
|
+
* This example creates an ArkType schematizer and uses it to convert schemas.
|
|
101
|
+
*
|
|
102
|
+
* ```js
|
|
103
|
+
* import {type} from 'arktype';
|
|
104
|
+
* import {createArkTypeSchematizer} from 'tinybase/schematizers/schematizer-arktype';
|
|
105
|
+
*
|
|
106
|
+
* const schematizer = createArkTypeSchematizer();
|
|
107
|
+
*
|
|
108
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
109
|
+
* pets: type({
|
|
110
|
+
* species: 'string',
|
|
111
|
+
* }),
|
|
112
|
+
* });
|
|
113
|
+
* console.log(tablesSchema);
|
|
114
|
+
* // -> {pets: {species: {type: 'string', required: true}}}
|
|
115
|
+
* ```
|
|
116
|
+
* @category Creation
|
|
117
|
+
* @since v7.1.0
|
|
118
|
+
*/
|
|
119
|
+
export function createArkTypeSchematizer(): ArkTypeSchematizer;
|
|
@@ -19,12 +19,11 @@ export interface EffectSchematizer extends Schematizer {
|
|
|
19
19
|
* The toTablesSchema method converts a mapping of Effect Schema struct schemas
|
|
20
20
|
* into a TinyBase TablesSchema.
|
|
21
21
|
*
|
|
22
|
-
* This method extracts basic type information (string, number, boolean),
|
|
23
|
-
*
|
|
24
|
-
* Effect schemas. Default values are not supported as they
|
|
25
|
-
* runtime
|
|
26
|
-
* transformations,
|
|
27
|
-
* transformations, and refinements are ignored.
|
|
22
|
+
* This method extracts basic type information (string, number, boolean), basic
|
|
23
|
+
* type unions, primitive literal unions, nullable flags, optional flags, and
|
|
24
|
+
* required flags from Effect schemas. Default values are not supported as they
|
|
25
|
+
* exist in Effect's runtime transformations, not in the schema AST. Complex
|
|
26
|
+
* validation rules, transformations, and refinements are ignored.
|
|
28
27
|
* @param schemas - A mapping of table IDs to Effect Schema struct schemas.
|
|
29
28
|
* @returns A TinyBase TablesSchema.
|
|
30
29
|
* @example
|
|
@@ -59,11 +58,10 @@ export interface EffectSchematizer extends Schematizer {
|
|
|
59
58
|
* The toValuesSchema method converts a mapping of Effect Schema schemas into a
|
|
60
59
|
* TinyBase ValuesSchema.
|
|
61
60
|
*
|
|
62
|
-
* This method extracts basic type information (string, number, boolean),
|
|
63
|
-
*
|
|
64
|
-
* Effect schemas. Default values are not supported as they
|
|
65
|
-
* runtime
|
|
66
|
-
* transformations, not in the schema AST.
|
|
61
|
+
* This method extracts basic type information (string, number, boolean), basic
|
|
62
|
+
* type unions, primitive literal unions, nullable flags, optional flags, and
|
|
63
|
+
* required flags from Effect schemas. Default values are not supported as they
|
|
64
|
+
* exist in Effect's runtime transformations, not in the schema AST.
|
|
67
65
|
* @param schemas - A mapping of value IDs to Effect Schema schemas.
|
|
68
66
|
* @returns A TinyBase ValuesSchema.
|
|
69
67
|
* @example
|
|
@@ -5,4 +5,117 @@
|
|
|
5
5
|
* @module schematizer-effect
|
|
6
6
|
* @since v7.1.0
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import type {
|
|
9
|
+
TablesSchema,
|
|
10
|
+
ValuesSchema,
|
|
11
|
+
} from '../../../store/with-schemas/index.d.ts';
|
|
12
|
+
import type {Schematizer} from '../../with-schemas/index.d.ts';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The EffectSchematizer interface represents a schematizer specifically for
|
|
16
|
+
* converting Effect Schema schemas into TinyBase schemas.
|
|
17
|
+
* @category Schematizer
|
|
18
|
+
* @since v7.1.0
|
|
19
|
+
*/
|
|
20
|
+
export interface EffectSchematizer extends Schematizer {
|
|
21
|
+
/**
|
|
22
|
+
* The toTablesSchema method converts a mapping of Effect Schema struct schemas
|
|
23
|
+
* into a TinyBase TablesSchema.
|
|
24
|
+
*
|
|
25
|
+
* This method extracts basic type information (string, number, boolean), basic
|
|
26
|
+
* type unions, primitive literal unions, nullable flags, optional flags, and
|
|
27
|
+
* required flags from Effect schemas. Default values are not supported as they
|
|
28
|
+
* exist in Effect's runtime transformations, not in the schema AST. Complex
|
|
29
|
+
* validation rules, transformations, and refinements are ignored.
|
|
30
|
+
* @param schemas - A mapping of table IDs to Effect Schema struct schemas.
|
|
31
|
+
* @returns A TinyBase TablesSchema.
|
|
32
|
+
* @example
|
|
33
|
+
* This example converts Effect Schema schemas to TinyBase format.
|
|
34
|
+
*
|
|
35
|
+
* ```js
|
|
36
|
+
* import {Boolean, Number, String, Struct} from 'effect/Schema';
|
|
37
|
+
* import {createStore} from 'tinybase';
|
|
38
|
+
* import {createEffectSchematizer} from 'tinybase/schematizers/schematizer-effect';
|
|
39
|
+
*
|
|
40
|
+
* const schematizer = createEffectSchematizer();
|
|
41
|
+
*
|
|
42
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
43
|
+
* pets: Struct({
|
|
44
|
+
* species: String,
|
|
45
|
+
* age: Number,
|
|
46
|
+
* sold: Boolean,
|
|
47
|
+
* }),
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* const store = createStore().setTablesSchema(tablesSchema);
|
|
51
|
+
* store.setRow('pets', 'fido', {species: 'dog', age: 3, sold: false});
|
|
52
|
+
* console.log(store.getRow('pets', 'fido'));
|
|
53
|
+
* // -> {species: 'dog', age: 3, sold: false}
|
|
54
|
+
* ```
|
|
55
|
+
* @category Conversion
|
|
56
|
+
* @since v7.1.0
|
|
57
|
+
*/
|
|
58
|
+
toTablesSchema(schemas: {[tableId: string]: any}): TablesSchema;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The toValuesSchema method converts a mapping of Effect Schema schemas into a
|
|
62
|
+
* TinyBase ValuesSchema.
|
|
63
|
+
*
|
|
64
|
+
* This method extracts basic type information (string, number, boolean), basic
|
|
65
|
+
* type unions, primitive literal unions, nullable flags, optional flags, and
|
|
66
|
+
* required flags from Effect schemas. Default values are not supported as they
|
|
67
|
+
* exist in Effect's runtime transformations, not in the schema AST.
|
|
68
|
+
* @param schemas - A mapping of value IDs to Effect Schema schemas.
|
|
69
|
+
* @returns A TinyBase ValuesSchema.
|
|
70
|
+
* @example
|
|
71
|
+
* This example converts Effect Schema schemas to TinyBase values.
|
|
72
|
+
*
|
|
73
|
+
* ```js
|
|
74
|
+
* import {Boolean, Number} from 'effect/Schema';
|
|
75
|
+
* import {createStore} from 'tinybase';
|
|
76
|
+
* import {createEffectSchematizer} from 'tinybase/schematizers/schematizer-effect';
|
|
77
|
+
*
|
|
78
|
+
* const schematizer = createEffectSchematizer();
|
|
79
|
+
*
|
|
80
|
+
* const valuesSchema = schematizer.toValuesSchema({
|
|
81
|
+
* open: Boolean,
|
|
82
|
+
* employees: Number,
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* const store = createStore().setValuesSchema(valuesSchema);
|
|
86
|
+
* store.setValues({open: true, employees: 3});
|
|
87
|
+
* console.log(store.getValues());
|
|
88
|
+
* // -> {open: true, employees: 3}
|
|
89
|
+
* ```
|
|
90
|
+
* @category Conversion
|
|
91
|
+
* @since v7.1.0
|
|
92
|
+
*/
|
|
93
|
+
toValuesSchema(schemas: {[valueId: string]: any}): ValuesSchema;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The createEffectSchematizer function creates an EffectSchematizer instance
|
|
98
|
+
* for converting Effect Schema schemas to TinyBase schemas.
|
|
99
|
+
* @returns A new EffectSchematizer instance.
|
|
100
|
+
* @example
|
|
101
|
+
* This example creates an Effect Schema schematizer.
|
|
102
|
+
*
|
|
103
|
+
* ```js
|
|
104
|
+
* import {String, Struct} from 'effect/Schema';
|
|
105
|
+
* import {createEffectSchematizer} from 'tinybase/schematizers/schematizer-effect';
|
|
106
|
+
*
|
|
107
|
+
* const schematizer = createEffectSchematizer();
|
|
108
|
+
*
|
|
109
|
+
* const tablesSchema = schematizer.toTablesSchema({
|
|
110
|
+
* pets: Struct({
|
|
111
|
+
* species: String,
|
|
112
|
+
* }),
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* console.log(tablesSchema);
|
|
116
|
+
* // -> {pets: {species: {type: 'string', required: true}}}
|
|
117
|
+
* ```
|
|
118
|
+
* @category Creation
|
|
119
|
+
* @since v7.1.0
|
|
120
|
+
*/
|
|
121
|
+
export function createEffectSchematizer(): EffectSchematizer;
|
|
@@ -19,10 +19,10 @@ export interface TypeBoxSchematizer extends Schematizer {
|
|
|
19
19
|
* The toTablesSchema method converts a mapping of TypeBox object schemas into a
|
|
20
20
|
* TinyBase TablesSchema.
|
|
21
21
|
*
|
|
22
|
-
* This method extracts basic type information (string, number, boolean),
|
|
23
|
-
*
|
|
24
|
-
* schemas. Complex validation rules like
|
|
25
|
-
* custom validators are ignored.
|
|
22
|
+
* This method extracts basic type information (string, number, boolean), basic
|
|
23
|
+
* type unions, primitive enums and literals, default values, nullable flags,
|
|
24
|
+
* and required flags from TypeBox schemas. Complex validation rules like
|
|
25
|
+
* min/max, patterns, formats, and custom validators are ignored.
|
|
26
26
|
* @param schemas - A mapping of table IDs to TypeBox object schemas.
|
|
27
27
|
* @returns A TinyBase TablesSchema.
|
|
28
28
|
* @example
|
|
@@ -57,9 +57,9 @@ export interface TypeBoxSchematizer extends Schematizer {
|
|
|
57
57
|
* The toValuesSchema method converts a mapping of TypeBox schemas into a
|
|
58
58
|
* TinyBase ValuesSchema.
|
|
59
59
|
*
|
|
60
|
-
* This method extracts basic type information (string, number, boolean),
|
|
61
|
-
*
|
|
62
|
-
* schemas.
|
|
60
|
+
* This method extracts basic type information (string, number, boolean), basic
|
|
61
|
+
* type unions, primitive enums and literals, default values, nullable flags,
|
|
62
|
+
* and required flags from TypeBox schemas.
|
|
63
63
|
* @param schemas - A mapping of value IDs to TypeBox schemas.
|
|
64
64
|
* @returns A TinyBase ValuesSchema.
|
|
65
65
|
* @example
|