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.
Files changed (130) hide show
  1. package/@types/_internal/store/with-schemas/index.d.ts +43 -8
  2. package/@types/mergeable-store/with-schemas/index.d.ts +30 -11
  3. package/@types/queries/index.d.ts +11 -11
  4. package/@types/queries/with-schemas/index.d.ts +17 -3
  5. package/@types/schematizers/index.d.ts +6 -4
  6. package/@types/schematizers/schematizer-arktype/index.d.ts +6 -6
  7. package/@types/schematizers/schematizer-arktype/with-schemas/index.d.ts +112 -1
  8. package/@types/schematizers/schematizer-effect/index.d.ts +9 -11
  9. package/@types/schematizers/schematizer-effect/with-schemas/index.d.ts +114 -1
  10. package/@types/schematizers/schematizer-typebox/index.d.ts +7 -7
  11. package/@types/schematizers/schematizer-typebox/with-schemas/index.d.ts +114 -1
  12. package/@types/schematizers/schematizer-valibot/index.d.ts +6 -6
  13. package/@types/schematizers/schematizer-valibot/with-schemas/index.d.ts +112 -1
  14. package/@types/schematizers/schematizer-yup/index.d.ts +5 -4
  15. package/@types/schematizers/schematizer-yup/with-schemas/index.d.ts +112 -1
  16. package/@types/schematizers/schematizer-zod/index.d.ts +6 -6
  17. package/@types/schematizers/schematizer-zod/with-schemas/index.d.ts +112 -1
  18. package/@types/schematizers/with-schemas/index.d.ts +113 -4
  19. package/@types/store/index.d.ts +175 -16
  20. package/@types/store/with-schemas/index.d.ts +238 -55
  21. package/@types/synchronizers/with-schemas/index.d.ts +12 -2
  22. package/@types/ui-react/with-schemas/index.d.ts +576 -7
  23. package/@types/ui-react-dom/index.d.ts +10 -10
  24. package/@types/ui-react-dom/with-schemas/index.d.ts +94 -10
  25. package/@types/ui-react-dom-charts/index.d.ts +7 -7
  26. package/@types/ui-react-dom-charts/with-schemas/index.d.ts +7 -7
  27. package/@types/ui-react-inspector/index.d.ts +1 -1
  28. package/@types/ui-react-inspector/with-schemas/index.d.ts +1 -1
  29. package/@types/ui-solid/with-schemas/index.d.ts +340 -7
  30. package/@types/ui-solid-dom/index.d.ts +10 -10
  31. package/@types/ui-solid-dom/with-schemas/index.d.ts +94 -10
  32. package/@types/ui-solid-inspector/index.d.ts +1 -1
  33. package/@types/ui-solid-inspector/with-schemas/index.d.ts +1 -1
  34. package/@types/ui-svelte/with-schemas/index.d.ts +30 -0
  35. package/@types/ui-svelte-dom/index.d.ts +10 -10
  36. package/@types/ui-svelte-dom/with-schemas/index.d.ts +94 -10
  37. package/@types/ui-svelte-inspector/index.d.ts +1 -1
  38. package/@types/ui-svelte-inspector/with-schemas/index.d.ts +1 -1
  39. package/agents.md +4 -0
  40. package/index.js +76 -22
  41. package/mergeable-store/index.js +76 -22
  42. package/mergeable-store/with-schemas/index.js +76 -22
  43. package/min/index.js +1 -1
  44. package/min/index.js.gz +0 -0
  45. package/min/mergeable-store/index.js +1 -1
  46. package/min/mergeable-store/index.js.gz +0 -0
  47. package/min/mergeable-store/with-schemas/index.js +1 -1
  48. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  49. package/min/omni/index.js +1 -1
  50. package/min/omni/index.js.gz +0 -0
  51. package/min/omni/with-schemas/index.js +1 -1
  52. package/min/omni/with-schemas/index.js.gz +0 -0
  53. package/min/schematizers/index.js +1 -1
  54. package/min/schematizers/index.js.gz +0 -0
  55. package/min/schematizers/schematizer-arktype/index.js +1 -1
  56. package/min/schematizers/schematizer-arktype/index.js.gz +0 -0
  57. package/min/schematizers/schematizer-arktype/with-schemas/index.js +1 -1
  58. package/min/schematizers/schematizer-arktype/with-schemas/index.js.gz +0 -0
  59. package/min/schematizers/schematizer-effect/index.js +1 -1
  60. package/min/schematizers/schematizer-effect/index.js.gz +0 -0
  61. package/min/schematizers/schematizer-effect/with-schemas/index.js +1 -1
  62. package/min/schematizers/schematizer-effect/with-schemas/index.js.gz +0 -0
  63. package/min/schematizers/schematizer-typebox/index.js +1 -1
  64. package/min/schematizers/schematizer-typebox/index.js.gz +0 -0
  65. package/min/schematizers/schematizer-typebox/with-schemas/index.js +1 -1
  66. package/min/schematizers/schematizer-typebox/with-schemas/index.js.gz +0 -0
  67. package/min/schematizers/schematizer-valibot/index.js +1 -1
  68. package/min/schematizers/schematizer-valibot/index.js.gz +0 -0
  69. package/min/schematizers/schematizer-valibot/with-schemas/index.js +1 -1
  70. package/min/schematizers/schematizer-valibot/with-schemas/index.js.gz +0 -0
  71. package/min/schematizers/schematizer-yup/index.js +1 -1
  72. package/min/schematizers/schematizer-yup/index.js.gz +0 -0
  73. package/min/schematizers/schematizer-yup/with-schemas/index.js +1 -1
  74. package/min/schematizers/schematizer-yup/with-schemas/index.js.gz +0 -0
  75. package/min/schematizers/schematizer-zod/index.js +1 -1
  76. package/min/schematizers/schematizer-zod/index.js.gz +0 -0
  77. package/min/schematizers/schematizer-zod/with-schemas/index.js +1 -1
  78. package/min/schematizers/schematizer-zod/with-schemas/index.js.gz +0 -0
  79. package/min/schematizers/with-schemas/index.js +1 -1
  80. package/min/schematizers/with-schemas/index.js.gz +0 -0
  81. package/min/store/index.js +1 -1
  82. package/min/store/index.js.gz +0 -0
  83. package/min/store/with-schemas/index.js +1 -1
  84. package/min/store/with-schemas/index.js.gz +0 -0
  85. package/min/ui-react-inspector/index.js +1 -1
  86. package/min/ui-react-inspector/index.js.gz +0 -0
  87. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  88. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  89. package/min/ui-solid-inspector/index.js +1 -1
  90. package/min/ui-solid-inspector/index.js.gz +0 -0
  91. package/min/ui-solid-inspector/with-schemas/index.js +1 -1
  92. package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
  93. package/min/ui-svelte-inspector/index.js +1 -1
  94. package/min/ui-svelte-inspector/index.js.gz +0 -0
  95. package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
  96. package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
  97. package/min/with-schemas/index.js +1 -1
  98. package/min/with-schemas/index.js.gz +0 -0
  99. package/omni/index.js +76 -22
  100. package/omni/with-schemas/index.js +76 -22
  101. package/package.json +5 -5
  102. package/readme.md +3 -3
  103. package/releases.md +32 -2
  104. package/schematizers/index.js +54 -6
  105. package/schematizers/schematizer-arktype/index.js +99 -19
  106. package/schematizers/schematizer-arktype/with-schemas/index.js +99 -19
  107. package/schematizers/schematizer-effect/index.js +101 -11
  108. package/schematizers/schematizer-effect/with-schemas/index.js +101 -11
  109. package/schematizers/schematizer-typebox/index.js +87 -11
  110. package/schematizers/schematizer-typebox/with-schemas/index.js +87 -11
  111. package/schematizers/schematizer-valibot/index.js +125 -21
  112. package/schematizers/schematizer-valibot/with-schemas/index.js +125 -21
  113. package/schematizers/schematizer-yup/index.js +58 -14
  114. package/schematizers/schematizer-yup/with-schemas/index.js +58 -14
  115. package/schematizers/schematizer-zod/index.js +131 -12
  116. package/schematizers/schematizer-zod/with-schemas/index.js +131 -12
  117. package/schematizers/with-schemas/index.js +54 -6
  118. package/store/index.js +76 -22
  119. package/store/with-schemas/index.js +76 -22
  120. package/ui-react-inspector/index.js +76 -22
  121. package/ui-react-inspector/with-schemas/index.js +76 -22
  122. package/ui-solid-inspector/index.js +76 -22
  123. package/ui-solid-inspector/with-schemas/index.js +76 -22
  124. package/ui-svelte/index.js +1 -1
  125. package/ui-svelte/with-schemas/index.js +1 -1
  126. package/ui-svelte-dom/index.js +2 -2
  127. package/ui-svelte-dom/with-schemas/index.js +2 -2
  128. package/ui-svelte-inspector/index.js +78 -24
  129. package/ui-svelte-inspector/with-schemas/index.js +78 -24
  130. 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`, `number`,
69
- * `null` since v7.0, or `object` or `array` since v8.0), and what the default
70
- * value can be when an explicit value is not specified.
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
- * If a default value is provided (and its type is correct), you can be certain
78
- * that that Cell will always be present in a Row. You can also set `required`
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
- | {type: 'string'; default?: string; required?: boolean}
126
- | {type: 'number'; default?: number; required?: boolean}
127
- | {type: 'boolean'; default?: boolean; required?: boolean}
128
- | {type: 'object'; default?: AnyObject; required?: boolean}
129
- | {type: 'array'; default?: AnyArray; required?: boolean};
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`, `number`,
158
- * `null` since v7.0, or `object` or `array` since v8.0), and what the default
159
- * value can be when an explicit value is not specified.
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
- * If a default value is provided (and its type is correct), you can be certain
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
- | {type: 'string'; default?: string; required?: boolean}
215
- | {type: 'number'; default?: number; required?: boolean}
216
- | {type: 'boolean'; default?: boolean; required?: boolean}
217
- | {type: 'object'; default?: AnyObject; required?: boolean}
218
- | {type: 'array'; default?: AnyArray; required?: boolean};
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
- > = CellType extends 'string'
486
- ? string
487
- : CellType extends 'number'
488
- ? number
489
- : CellType extends 'boolean'
490
- ? boolean
491
- : CellType extends 'object'
492
- ? AnyObject
493
- : CellType extends 'array'
494
- ? AnyArray
495
- : string | number | boolean | AnyObject | AnyArray;
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
- > = ValueType extends 'string'
618
- ? string
619
- : ValueType extends 'number'
620
- ? number
621
- : ValueType extends 'boolean'
622
- ? boolean
623
- : ValueType extends 'object'
624
- ? AnyObject
625
- : ValueType extends 'array'
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(tablesSchema: TablesSchema): this;
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<[typeof tablesSchema, Schemas[1]]>;
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(valuesSchema: ValuesSchema): this;
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], typeof valuesSchema]>;
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(tablesSchema: TablesSchema, valuesSchema?: ValuesSchema): this;
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
- typeof tablesSchema,
5425
+ TS,
5243
5426
  Exclude<ValuesSchema, typeof valuesSchema> extends never
5244
5427
  ? NoValuesSchema
5245
- : NonNullable<typeof valuesSchema>,
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: Id,
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: Id,
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