tinybase 9.5.0-beta.0 → 9.5.0
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 +5 -5
- package/readme.md +3 -3
- package/releases.md +32 -2
- 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/index.js +1 -1
- package/ui-svelte/with-schemas/index.js +1 -1
- package/ui-svelte-dom/index.js +2 -2
- package/ui-svelte-dom/with-schemas/index.js +2 -2
- package/ui-svelte-inspector/index.js +78 -24
- package/ui-svelte-inspector/with-schemas/index.js +78 -24
- package/with-schemas/index.js +76 -22
|
@@ -22,6 +22,8 @@ import type {
|
|
|
22
22
|
StoreAlias,
|
|
23
23
|
TableIdFromSchema,
|
|
24
24
|
Truncate,
|
|
25
|
+
ValidTablesSchema,
|
|
26
|
+
ValidValuesSchema,
|
|
25
27
|
ValueIdFromSchema,
|
|
26
28
|
} from '../../_internal/store/with-schemas/index.d.ts';
|
|
27
29
|
import type {
|
|
@@ -34,6 +36,24 @@ import type {
|
|
|
34
36
|
Sorter,
|
|
35
37
|
} from '../../common/with-schemas/index.d.ts';
|
|
36
38
|
|
|
39
|
+
type SchemaType = 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
40
|
+
|
|
41
|
+
type SchemaTypeArray = readonly [SchemaType, ...SchemaType[]];
|
|
42
|
+
|
|
43
|
+
type CellOrValueFromSchemaType<Type> = Type extends readonly (infer Type)[]
|
|
44
|
+
? CellOrValueFromSchemaType<Type>
|
|
45
|
+
: Type extends 'string'
|
|
46
|
+
? string
|
|
47
|
+
: Type extends 'number'
|
|
48
|
+
? number
|
|
49
|
+
: Type extends 'boolean'
|
|
50
|
+
? boolean
|
|
51
|
+
: Type extends 'object'
|
|
52
|
+
? AnyObject
|
|
53
|
+
: Type extends 'array'
|
|
54
|
+
? AnyArray
|
|
55
|
+
: string | number | boolean | AnyObject | AnyArray;
|
|
56
|
+
|
|
37
57
|
/**
|
|
38
58
|
* The TablesSchema type describes the tabular structure of a Store in terms of
|
|
39
59
|
* valid Table Ids and the types of Cell that can exist within them.
|
|
@@ -65,17 +85,25 @@ export type TablesSchema = {[tableId: Id]: {[cellId: Id]: CellSchema}};
|
|
|
65
85
|
* The CellSchema type describes what values are allowed for each Cell in a
|
|
66
86
|
* Table.
|
|
67
87
|
*
|
|
68
|
-
* A CellSchema specifies the type of the Cell (`string`, `boolean`,
|
|
69
|
-
* `
|
|
70
|
-
*
|
|
88
|
+
* A CellSchema specifies either the type of the Cell (`string`, `boolean`,
|
|
89
|
+
* `number`, `object`, or `array`), a non-empty array of those types, or a
|
|
90
|
+
* non-empty `enum` of exact primitive values that are allowed. Multiple type
|
|
91
|
+
* names form a union, such as `type: ['string', 'number']`, and repeated names
|
|
92
|
+
* have no additional effect. The `type` and `enum` properties are mutually
|
|
93
|
+
* exclusive, and enum members can be strings, finite numbers, or booleans,
|
|
94
|
+
* including a mixture of those types.
|
|
71
95
|
*
|
|
72
96
|
* For `object` and `array` types, TinyBase automatically serializes values to
|
|
73
97
|
* and from JSON when storing and retrieving them. Their contents should
|
|
74
98
|
* recursively be strings, finite numbers, booleans, `null`, plain objects, or
|
|
75
99
|
* arrays to ensure they are preserved.
|
|
76
100
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
101
|
+
* Set `allowNull` to `true` to also allow `null`, whether the schema uses
|
|
102
|
+
* `type` or `enum`. A default value is used only when it has the correct type,
|
|
103
|
+
* matches any member of a type union, is an enum member when applicable, or is
|
|
104
|
+
* `null` when allowed. Literal schemas passed to Store schema setters are
|
|
105
|
+
* checked against these default rules by TypeScript. A valid default means
|
|
106
|
+
* that the Cell will always be present in a Row. You can also set `required`
|
|
79
107
|
* to `true` to indicate to schema-based typing that the Cell should be present
|
|
80
108
|
* even if it does not have a default.
|
|
81
109
|
*
|
|
@@ -118,15 +146,86 @@ export type TablesSchema = {[tableId: Id]: {[cellId: Id]: CellSchema}};
|
|
|
118
146
|
* default: {},
|
|
119
147
|
* };
|
|
120
148
|
* ```
|
|
149
|
+
* @example
|
|
150
|
+
* When applied to a Store, this CellSchema allows either a string or numeric
|
|
151
|
+
* Cell.
|
|
152
|
+
*
|
|
153
|
+
* ```js
|
|
154
|
+
* import type {CellSchema} from 'tinybase';
|
|
155
|
+
*
|
|
156
|
+
* export const referenceCell: CellSchema = {
|
|
157
|
+
* type: ['string', 'number'],
|
|
158
|
+
* };
|
|
159
|
+
* ```
|
|
160
|
+
* @example
|
|
161
|
+
* When applied to a Store, this CellSchema allows one of three exact primitive
|
|
162
|
+
* values, or `null`.
|
|
163
|
+
*
|
|
164
|
+
* ```js
|
|
165
|
+
* import type {CellSchema} from 'tinybase';
|
|
166
|
+
*
|
|
167
|
+
* export const ratingCell: CellSchema = {
|
|
168
|
+
* enum: ['good', 5, true],
|
|
169
|
+
* allowNull: true,
|
|
170
|
+
* default: 'good',
|
|
171
|
+
* };
|
|
172
|
+
* ```
|
|
121
173
|
* @category Schema
|
|
122
174
|
* @since v1.0.0
|
|
123
175
|
*/
|
|
124
176
|
export type CellSchema =
|
|
125
|
-
| {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
177
|
+
| {
|
|
178
|
+
type: 'string';
|
|
179
|
+
default?: string | null;
|
|
180
|
+
allowNull?: boolean;
|
|
181
|
+
required?: boolean;
|
|
182
|
+
enum?: never;
|
|
183
|
+
}
|
|
184
|
+
| {
|
|
185
|
+
type: 'number';
|
|
186
|
+
default?: number | null;
|
|
187
|
+
allowNull?: boolean;
|
|
188
|
+
required?: boolean;
|
|
189
|
+
enum?: never;
|
|
190
|
+
}
|
|
191
|
+
| {
|
|
192
|
+
type: 'boolean';
|
|
193
|
+
default?: boolean | null;
|
|
194
|
+
allowNull?: boolean;
|
|
195
|
+
required?: boolean;
|
|
196
|
+
enum?: never;
|
|
197
|
+
}
|
|
198
|
+
| {
|
|
199
|
+
type: 'object';
|
|
200
|
+
default?: AnyObject | null;
|
|
201
|
+
allowNull?: boolean;
|
|
202
|
+
required?: boolean;
|
|
203
|
+
enum?: never;
|
|
204
|
+
}
|
|
205
|
+
| {
|
|
206
|
+
type: 'array';
|
|
207
|
+
default?: AnyArray | null;
|
|
208
|
+
allowNull?: boolean;
|
|
209
|
+
required?: boolean;
|
|
210
|
+
enum?: never;
|
|
211
|
+
}
|
|
212
|
+
| {
|
|
213
|
+
type: SchemaTypeArray;
|
|
214
|
+
default?: string | number | boolean | AnyObject | AnyArray | null;
|
|
215
|
+
allowNull?: boolean;
|
|
216
|
+
required?: boolean;
|
|
217
|
+
enum?: never;
|
|
218
|
+
}
|
|
219
|
+
| {
|
|
220
|
+
enum: readonly [
|
|
221
|
+
string | number | boolean,
|
|
222
|
+
...(string | number | boolean)[],
|
|
223
|
+
];
|
|
224
|
+
type?: never;
|
|
225
|
+
default?: string | number | boolean | null;
|
|
226
|
+
allowNull?: boolean;
|
|
227
|
+
required?: boolean;
|
|
228
|
+
};
|
|
130
229
|
|
|
131
230
|
/**
|
|
132
231
|
* The ValuesSchema type describes the keyed Values that can be set in a Store
|
|
@@ -154,16 +253,24 @@ export type ValuesSchema = {[valueId: Id]: ValueSchema};
|
|
|
154
253
|
* The ValueSchema type describes what values are allowed for keyed Values in a
|
|
155
254
|
* Store.
|
|
156
255
|
*
|
|
157
|
-
* A ValueSchema specifies the type of the Value (`string`, `boolean`,
|
|
158
|
-
* `
|
|
159
|
-
*
|
|
256
|
+
* A ValueSchema specifies either the type of the Value (`string`, `boolean`,
|
|
257
|
+
* `number`, `object`, or `array`), a non-empty array of those types, or a
|
|
258
|
+
* non-empty `enum` of exact primitive values that are allowed. Multiple type
|
|
259
|
+
* names form a union, such as `type: ['string', 'number']`, and repeated names
|
|
260
|
+
* have no additional effect. The `type` and `enum` properties are mutually
|
|
261
|
+
* exclusive, and enum members can be strings, finite numbers, or booleans,
|
|
262
|
+
* including a mixture of those types.
|
|
160
263
|
*
|
|
161
264
|
* For `object` and `array` types, TinyBase automatically serializes values to
|
|
162
265
|
* and from JSON when storing and retrieving them. Their contents should
|
|
163
266
|
* recursively be strings, finite numbers, booleans, `null`, plain objects, or
|
|
164
267
|
* arrays to ensure they are preserved.
|
|
165
268
|
*
|
|
166
|
-
*
|
|
269
|
+
* Set `allowNull` to `true` to also allow `null`, whether the schema uses
|
|
270
|
+
* `type` or `enum`. A default value is used only when it has the correct type,
|
|
271
|
+
* matches any member of a type union, is an enum member when applicable, or is
|
|
272
|
+
* `null` when allowed. Literal schemas passed to Store schema setters are
|
|
273
|
+
* checked against these default rules by TypeScript. A valid default means
|
|
167
274
|
* that the Value will always be present in a Store. You can also set `required`
|
|
168
275
|
* to `true` to indicate to schema-based typing that the Value should be present
|
|
169
276
|
* even if it does not have a default.
|
|
@@ -207,15 +314,86 @@ export type ValuesSchema = {[valueId: Id]: ValueSchema};
|
|
|
207
314
|
* default: [],
|
|
208
315
|
* };
|
|
209
316
|
* ```
|
|
317
|
+
* @example
|
|
318
|
+
* When applied to a Store, this ValueSchema allows either a string or numeric
|
|
319
|
+
* Value.
|
|
320
|
+
*
|
|
321
|
+
* ```js
|
|
322
|
+
* import type {ValueSchema} from 'tinybase';
|
|
323
|
+
*
|
|
324
|
+
* export const referenceValue: ValueSchema = {
|
|
325
|
+
* type: ['string', 'number'],
|
|
326
|
+
* };
|
|
327
|
+
* ```
|
|
328
|
+
* @example
|
|
329
|
+
* When applied to a Store, this ValueSchema allows one of three exact primitive
|
|
330
|
+
* values, or `null`.
|
|
331
|
+
*
|
|
332
|
+
* ```js
|
|
333
|
+
* import type {ValueSchema} from 'tinybase';
|
|
334
|
+
*
|
|
335
|
+
* export const ratingValue: ValueSchema = {
|
|
336
|
+
* enum: ['good', 5, true],
|
|
337
|
+
* allowNull: true,
|
|
338
|
+
* default: 'good',
|
|
339
|
+
* };
|
|
340
|
+
* ```
|
|
210
341
|
* @category Schema
|
|
211
342
|
* @since v3.0.0
|
|
212
343
|
*/
|
|
213
344
|
export type ValueSchema =
|
|
214
|
-
| {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
345
|
+
| {
|
|
346
|
+
type: 'string';
|
|
347
|
+
default?: string | null;
|
|
348
|
+
allowNull?: boolean;
|
|
349
|
+
required?: boolean;
|
|
350
|
+
enum?: never;
|
|
351
|
+
}
|
|
352
|
+
| {
|
|
353
|
+
type: 'number';
|
|
354
|
+
default?: number | null;
|
|
355
|
+
allowNull?: boolean;
|
|
356
|
+
required?: boolean;
|
|
357
|
+
enum?: never;
|
|
358
|
+
}
|
|
359
|
+
| {
|
|
360
|
+
type: 'boolean';
|
|
361
|
+
default?: boolean | null;
|
|
362
|
+
allowNull?: boolean;
|
|
363
|
+
required?: boolean;
|
|
364
|
+
enum?: never;
|
|
365
|
+
}
|
|
366
|
+
| {
|
|
367
|
+
type: 'object';
|
|
368
|
+
default?: AnyObject | null;
|
|
369
|
+
allowNull?: boolean;
|
|
370
|
+
required?: boolean;
|
|
371
|
+
enum?: never;
|
|
372
|
+
}
|
|
373
|
+
| {
|
|
374
|
+
type: 'array';
|
|
375
|
+
default?: AnyArray | null;
|
|
376
|
+
allowNull?: boolean;
|
|
377
|
+
required?: boolean;
|
|
378
|
+
enum?: never;
|
|
379
|
+
}
|
|
380
|
+
| {
|
|
381
|
+
type: SchemaTypeArray;
|
|
382
|
+
default?: string | number | boolean | AnyObject | AnyArray | null;
|
|
383
|
+
allowNull?: boolean;
|
|
384
|
+
required?: boolean;
|
|
385
|
+
enum?: never;
|
|
386
|
+
}
|
|
387
|
+
| {
|
|
388
|
+
enum: readonly [
|
|
389
|
+
string | number | boolean,
|
|
390
|
+
...(string | number | boolean)[],
|
|
391
|
+
];
|
|
392
|
+
type?: never;
|
|
393
|
+
default?: string | number | boolean | null;
|
|
394
|
+
allowNull?: boolean;
|
|
395
|
+
required?: boolean;
|
|
396
|
+
};
|
|
219
397
|
|
|
220
398
|
/**
|
|
221
399
|
* The NoTablesSchema type is a TablesSchema-like type for when one has not been
|
|
@@ -482,17 +660,17 @@ export type Cell<
|
|
|
482
660
|
TableId extends TableIdFromSchema<Schema>,
|
|
483
661
|
CellId extends CellIdFromSchema<Schema, TableId>,
|
|
484
662
|
CellType = Schema[TableId][CellId]['type'],
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
?
|
|
489
|
-
:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
663
|
+
CellEnum = Schema[TableId][CellId] extends {
|
|
664
|
+
enum: readonly (infer Enum)[];
|
|
665
|
+
}
|
|
666
|
+
? Enum
|
|
667
|
+
: never,
|
|
668
|
+
CellNull = Schema[TableId][CellId] extends {allowNull: true} ? null : never,
|
|
669
|
+
> =
|
|
670
|
+
| ([CellEnum] extends [never]
|
|
671
|
+
? CellOrValueFromSchemaType<CellType>
|
|
672
|
+
: CellEnum)
|
|
673
|
+
| CellNull;
|
|
496
674
|
|
|
497
675
|
/**
|
|
498
676
|
* The CellOrUndefined type is a data structure representing the data in a
|
|
@@ -614,17 +792,15 @@ export type Value<
|
|
|
614
792
|
Schema extends OptionalValuesSchema,
|
|
615
793
|
ValueId extends ValueIdFromSchema<Schema>,
|
|
616
794
|
ValueType = Schema[ValueId]['type'],
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
? AnyArray
|
|
627
|
-
: string | number | boolean | AnyObject | AnyArray;
|
|
795
|
+
ValueEnum = Schema[ValueId] extends {enum: readonly (infer Enum)[]}
|
|
796
|
+
? Enum
|
|
797
|
+
: never,
|
|
798
|
+
ValueNull = Schema[ValueId] extends {allowNull: true} ? null : never,
|
|
799
|
+
> =
|
|
800
|
+
| ([ValueEnum] extends [never]
|
|
801
|
+
? CellOrValueFromSchemaType<ValueType>
|
|
802
|
+
: ValueEnum)
|
|
803
|
+
| ValueNull;
|
|
628
804
|
|
|
629
805
|
/**
|
|
630
806
|
* The ValueOrUndefined type is a data structure representing the data in a
|
|
@@ -5093,7 +5269,9 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
5093
5269
|
* This has schema-based typing. The following is a simplified representation:
|
|
5094
5270
|
*
|
|
5095
5271
|
* ```ts override
|
|
5096
|
-
* setTablesSchema
|
|
5272
|
+
* setTablesSchema<const TS extends TablesSchema>(
|
|
5273
|
+
* tablesSchema: TS & ValidTablesSchema<TS>,
|
|
5274
|
+
* ): this;
|
|
5097
5275
|
* ```
|
|
5098
5276
|
*
|
|
5099
5277
|
* Note that this may result in a change to data in the Store, as defaults are
|
|
@@ -5124,9 +5302,9 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
5124
5302
|
* @category Setter
|
|
5125
5303
|
* @since v3.0.0
|
|
5126
5304
|
*/
|
|
5127
|
-
setTablesSchema<TS extends TablesSchema>(
|
|
5128
|
-
tablesSchema: TS
|
|
5129
|
-
): Store<[
|
|
5305
|
+
setTablesSchema<const TS extends TablesSchema>(
|
|
5306
|
+
tablesSchema: TS & ValidTablesSchema<TS>,
|
|
5307
|
+
): Store<[TS, Schemas[1]]>;
|
|
5130
5308
|
|
|
5131
5309
|
/**
|
|
5132
5310
|
* The setValuesSchema method lets you specify the ValuesSchema of the keyed
|
|
@@ -5135,7 +5313,9 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
5135
5313
|
* This has schema-based typing. The following is a simplified representation:
|
|
5136
5314
|
*
|
|
5137
5315
|
* ```ts override
|
|
5138
|
-
* setValuesSchema
|
|
5316
|
+
* setValuesSchema<const VS extends ValuesSchema>(
|
|
5317
|
+
* valuesSchema: VS & ValidValuesSchema<VS>,
|
|
5318
|
+
* ): this;
|
|
5139
5319
|
* ```
|
|
5140
5320
|
*
|
|
5141
5321
|
* Note that this may result in a change to data in the Store, as defaults are
|
|
@@ -5163,9 +5343,9 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
5163
5343
|
* @category Setter
|
|
5164
5344
|
* @since v3.0.0
|
|
5165
5345
|
*/
|
|
5166
|
-
setValuesSchema<VS extends ValuesSchema>(
|
|
5167
|
-
valuesSchema: VS
|
|
5168
|
-
): Store<[Schemas[0],
|
|
5346
|
+
setValuesSchema<const VS extends ValuesSchema>(
|
|
5347
|
+
valuesSchema: VS & ValidValuesSchema<VS>,
|
|
5348
|
+
): Store<[Schemas[0], VS]>;
|
|
5169
5349
|
|
|
5170
5350
|
/**
|
|
5171
5351
|
* The setSchema method lets you specify the TablesSchema and ValuesSchema of
|
|
@@ -5174,7 +5354,10 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
5174
5354
|
* This has schema-based typing. The following is a simplified representation:
|
|
5175
5355
|
*
|
|
5176
5356
|
* ```ts override
|
|
5177
|
-
* setSchema
|
|
5357
|
+
* setSchema<const TS extends TablesSchema, const VS extends ValuesSchema>(
|
|
5358
|
+
* tablesSchema: TS & ValidTablesSchema<TS>,
|
|
5359
|
+
* valuesSchema?: VS & ValidValuesSchema<VS>,
|
|
5360
|
+
* ): this;
|
|
5178
5361
|
* ```
|
|
5179
5362
|
*
|
|
5180
5363
|
* Note that this may result in a change to data in the Store, as defaults are
|
|
@@ -5234,15 +5417,15 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
5234
5417
|
* @category Setter
|
|
5235
5418
|
* @since v1.0.0
|
|
5236
5419
|
*/
|
|
5237
|
-
setSchema<TS extends TablesSchema, VS extends ValuesSchema>(
|
|
5238
|
-
tablesSchema: TS
|
|
5239
|
-
valuesSchema?: VS
|
|
5420
|
+
setSchema<const TS extends TablesSchema, const VS extends ValuesSchema>(
|
|
5421
|
+
tablesSchema: TS & ValidTablesSchema<TS>,
|
|
5422
|
+
valuesSchema?: VS & ValidValuesSchema<VS>,
|
|
5240
5423
|
): Store<
|
|
5241
5424
|
[
|
|
5242
|
-
|
|
5425
|
+
TS,
|
|
5243
5426
|
Exclude<ValuesSchema, typeof valuesSchema> extends never
|
|
5244
5427
|
? NoValuesSchema
|
|
5245
|
-
:
|
|
5428
|
+
: VS,
|
|
5246
5429
|
]
|
|
5247
5430
|
>;
|
|
5248
5431
|
|
|
@@ -98,7 +98,7 @@ export const enum Message {
|
|
|
98
98
|
*/
|
|
99
99
|
export type Send = (
|
|
100
100
|
toClientId: IdOrNull,
|
|
101
|
-
requestId:
|
|
101
|
+
requestId: IdOrNull,
|
|
102
102
|
message: Message,
|
|
103
103
|
body: any,
|
|
104
104
|
) => void;
|
|
@@ -123,7 +123,7 @@ export type Send = (
|
|
|
123
123
|
*/
|
|
124
124
|
export type Receive = (
|
|
125
125
|
fromClientId: Id,
|
|
126
|
-
requestId:
|
|
126
|
+
requestId: IdOrNull,
|
|
127
127
|
message: Message,
|
|
128
128
|
body: any,
|
|
129
129
|
) => void;
|
|
@@ -137,7 +137,17 @@ export type Receive = (
|
|
|
137
137
|
* @since v5.0.0
|
|
138
138
|
*/
|
|
139
139
|
export type SynchronizerStats = {
|
|
140
|
+
/**
|
|
141
|
+
* The number of times messages have been sent.
|
|
142
|
+
* @category Stat
|
|
143
|
+
* @since v5.0.0
|
|
144
|
+
*/
|
|
140
145
|
sends: number;
|
|
146
|
+
/**
|
|
147
|
+
* The number of times messages has been received.
|
|
148
|
+
* @category Stat
|
|
149
|
+
* @since v5.0.0
|
|
150
|
+
*/
|
|
141
151
|
receives: number;
|
|
142
152
|
};
|
|
143
153
|
|