tinybase 9.1.0-beta.1 → 9.1.0-beta.2

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 (80) hide show
  1. package/@types/_internal/store/with-schemas/index.d.ts +133 -2
  2. package/@types/indexes/index.d.ts +97 -0
  3. package/@types/indexes/with-schemas/index.d.ts +137 -0
  4. package/@types/store/index.d.ts +96 -18
  5. package/@types/store/with-schemas/index.d.ts +107 -44
  6. package/@types/ui-react/index.d.ts +42 -0
  7. package/@types/ui-react/with-schemas/index.d.ts +101 -32
  8. package/@types/ui-solid/index.d.ts +42 -0
  9. package/@types/ui-solid/with-schemas/index.d.ts +101 -32
  10. package/@types/ui-svelte/index.d.ts +34 -0
  11. package/@types/ui-svelte/with-schemas/index.d.ts +34 -0
  12. package/index.js +121 -32
  13. package/indexes/index.js +39 -0
  14. package/indexes/with-schemas/index.js +39 -0
  15. package/mergeable-store/index.js +82 -32
  16. package/mergeable-store/with-schemas/index.js +82 -32
  17. package/min/index.js +1 -1
  18. package/min/index.js.gz +0 -0
  19. package/min/indexes/index.js +1 -1
  20. package/min/indexes/index.js.gz +0 -0
  21. package/min/indexes/with-schemas/index.js +1 -1
  22. package/min/indexes/with-schemas/index.js.gz +0 -0
  23. package/min/mergeable-store/index.js +1 -1
  24. package/min/mergeable-store/index.js.gz +0 -0
  25. package/min/mergeable-store/with-schemas/index.js +1 -1
  26. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  27. package/min/omni/index.js +1 -1
  28. package/min/omni/index.js.gz +0 -0
  29. package/min/omni/with-schemas/index.js +1 -1
  30. package/min/omni/with-schemas/index.js.gz +0 -0
  31. package/min/store/index.js +1 -1
  32. package/min/store/index.js.gz +0 -0
  33. package/min/store/with-schemas/index.js +1 -1
  34. package/min/store/with-schemas/index.js.gz +0 -0
  35. package/min/ui-react/index.js +1 -1
  36. package/min/ui-react/index.js.gz +0 -0
  37. package/min/ui-react/with-schemas/index.js +1 -1
  38. package/min/ui-react/with-schemas/index.js.gz +0 -0
  39. package/min/ui-react-inspector/index.js +1 -1
  40. package/min/ui-react-inspector/index.js.gz +0 -0
  41. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  42. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  43. package/min/ui-solid/index.js +1 -1
  44. package/min/ui-solid/index.js.gz +0 -0
  45. package/min/ui-solid/with-schemas/index.js +1 -1
  46. package/min/ui-solid/with-schemas/index.js.gz +0 -0
  47. package/min/ui-solid-inspector/index.js +1 -1
  48. package/min/ui-solid-inspector/index.js.gz +0 -0
  49. package/min/ui-solid-inspector/with-schemas/index.js +1 -1
  50. package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
  51. package/min/ui-svelte/index.js +1 -1
  52. package/min/ui-svelte/index.js.gz +0 -0
  53. package/min/ui-svelte/with-schemas/index.js +1 -1
  54. package/min/ui-svelte/with-schemas/index.js.gz +0 -0
  55. package/min/ui-svelte-inspector/index.js +1 -1
  56. package/min/ui-svelte-inspector/index.js.gz +0 -0
  57. package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
  58. package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
  59. package/min/with-schemas/index.js +1 -1
  60. package/min/with-schemas/index.js.gz +0 -0
  61. package/omni/index.js +121 -32
  62. package/omni/with-schemas/index.js +121 -32
  63. package/package.json +2 -2
  64. package/readme.md +14 -14
  65. package/releases.md +101 -60
  66. package/store/index.js +82 -32
  67. package/store/with-schemas/index.js +82 -32
  68. package/ui-react/index.js +16 -0
  69. package/ui-react/with-schemas/index.js +16 -0
  70. package/ui-react-inspector/index.js +82 -32
  71. package/ui-react-inspector/with-schemas/index.js +82 -32
  72. package/ui-solid/index.js +16 -0
  73. package/ui-solid/with-schemas/index.js +16 -0
  74. package/ui-solid-inspector/index.js +82 -32
  75. package/ui-solid-inspector/with-schemas/index.js +82 -32
  76. package/ui-svelte/index.js +18 -0
  77. package/ui-svelte/with-schemas/index.js +18 -0
  78. package/ui-svelte-inspector/index.js +82 -32
  79. package/ui-svelte-inspector/with-schemas/index.js +82 -32
  80. package/with-schemas/index.js +121 -32
@@ -13,10 +13,12 @@
13
13
  import type {
14
14
  AllCellIdFromSchema,
15
15
  CellIdFromSchema,
16
- DefaultCellIdFromSchema,
17
- DefaultValueIdFromSchema,
18
16
  DefaultedCellFromSchema,
19
17
  DefaultedValueFromSchema,
18
+ PresentCellIdFromSchema,
19
+ PresentValueIdFromSchema,
20
+ RequiredNonDefaultCellIdFromSchema,
21
+ RequiredNonDefaultValueIdFromSchema,
20
22
  StoreAlias,
21
23
  TableIdFromSchema,
22
24
  Truncate,
@@ -72,11 +74,13 @@ export type TablesSchema = {[tableId: Id]: {[cellId: Id]: CellSchema}};
72
74
  * object or array Cell directly, and get back the same structure.
73
75
  *
74
76
  * If a default value is provided (and its type is correct), you can be certain
75
- * that that Cell will always be present in a Row.
77
+ * that that Cell will always be present in a Row. You can also set `required`
78
+ * to `true` to indicate to schema-based typing that the Cell should be present
79
+ * even if it does not have a default.
76
80
  *
77
- * If the default value is _not_ provided (or its type is incorrect), the Cell
78
- * may be missing from the Row, but when present you can be guaranteed it is of
79
- * the correct type.
81
+ * If neither a default value nor `required: true` is provided, the Cell may be
82
+ * missing from the Row, but when present you can be guaranteed it is of the
83
+ * correct type.
80
84
  * @example
81
85
  * When applied to a Store, this CellSchema ensures a boolean Cell is always
82
86
  * present, and defaults it to `false`.
@@ -90,6 +94,18 @@ export type TablesSchema = {[tableId: Id]: {[cellId: Id]: CellSchema}};
90
94
  * };
91
95
  * ```
92
96
  * @example
97
+ * When applied to a Store, this CellSchema expects a string Cell to be present
98
+ * without providing a default value.
99
+ *
100
+ * ```js
101
+ * import type {CellSchema} from 'tinybase';
102
+ *
103
+ * export const requiredString: CellSchema = {
104
+ * type: 'string',
105
+ * required: true,
106
+ * };
107
+ * ```
108
+ * @example
93
109
  * When applied to a Store, this CellSchema allows an object Cell containing
94
110
  * arbitrary data, defaulting to an empty object.
95
111
  *
@@ -105,11 +121,11 @@ export type TablesSchema = {[tableId: Id]: {[cellId: Id]: CellSchema}};
105
121
  * @since v1.0.0
106
122
  */
107
123
  export type CellSchema =
108
- | {type: 'string'; default?: string}
109
- | {type: 'number'; default?: number}
110
- | {type: 'boolean'; default?: boolean}
111
- | {type: 'object'; default?: AnyObject}
112
- | {type: 'array'; default?: AnyArray};
124
+ | {type: 'string'; default?: string; required?: boolean}
125
+ | {type: 'number'; default?: number; required?: boolean}
126
+ | {type: 'boolean'; default?: boolean; required?: boolean}
127
+ | {type: 'object'; default?: AnyObject; required?: boolean}
128
+ | {type: 'array'; default?: AnyArray; required?: boolean};
113
129
 
114
130
  /**
115
131
  * The ValuesSchema type describes the keyed Values that can be set in a Store
@@ -145,11 +161,13 @@ export type ValuesSchema = {[valueId: Id]: ValueSchema};
145
161
  * and from JSON when storing and retrieving them.
146
162
  *
147
163
  * If a default value is provided (and its type is correct), you can be certain
148
- * that the Value will always be present in a Store.
164
+ * that the Value will always be present in a Store. You can also set `required`
165
+ * to `true` to indicate to schema-based typing that the Value should be
166
+ * present even if it does not have a default.
149
167
  *
150
- * If the default value is _not_ provided (or its type is incorrect), the Value
151
- * may not be present in the Store, but when present you can be guaranteed it is
152
- * of the correct type.
168
+ * If neither a default value nor `required: true` is provided, the Value may
169
+ * not be present in the Store, but when present you can be guaranteed it is of
170
+ * the correct type.
153
171
  * @example
154
172
  * When applied to a Store, this ValueSchema ensures a boolean Value is always
155
173
  * present, and defaults it to `false`.
@@ -163,6 +181,18 @@ export type ValuesSchema = {[valueId: Id]: ValueSchema};
163
181
  * };
164
182
  * ```
165
183
  * @example
184
+ * When applied to a Store, this ValueSchema expects a string Value to be
185
+ * present without providing a default value.
186
+ *
187
+ * ```js
188
+ * import type {ValueSchema} from 'tinybase';
189
+ *
190
+ * export const requiredString: ValueSchema = {
191
+ * type: 'string',
192
+ * required: true,
193
+ * };
194
+ * ```
195
+ * @example
166
196
  * When applied to a Store, this ValueSchema allows an array Value containing
167
197
  * a list of items, defaulting to an empty array.
168
198
  *
@@ -178,11 +208,11 @@ export type ValuesSchema = {[valueId: Id]: ValueSchema};
178
208
  * @since v3.0.0
179
209
  */
180
210
  export type ValueSchema =
181
- | {type: 'string'; default?: string}
182
- | {type: 'number'; default?: number}
183
- | {type: 'boolean'; default?: boolean}
184
- | {type: 'object'; default?: AnyObject}
185
- | {type: 'array'; default?: AnyArray};
211
+ | {type: 'string'; default?: string; required?: boolean}
212
+ | {type: 'number'; default?: number; required?: boolean}
213
+ | {type: 'boolean'; default?: boolean; required?: boolean}
214
+ | {type: 'object'; default?: AnyObject; required?: boolean}
215
+ | {type: 'array'; default?: AnyArray; required?: boolean};
186
216
 
187
217
  /**
188
218
  * The NoTablesSchema type is a TablesSchema-like type for when one has not been
@@ -371,22 +401,40 @@ export type Row<
371
401
  Schema extends OptionalTablesSchema,
372
402
  TableId extends TableIdFromSchema<Schema>,
373
403
  WhenSet extends boolean = false,
374
- > = (WhenSet extends true
375
- ? {
376
- -readonly [CellId in DefaultCellIdFromSchema<Schema, TableId>]?: Cell<
377
- Schema,
378
- TableId,
379
- CellId
380
- >;
381
- }
404
+ > = WhenSet extends true
405
+ ? RequiredNonDefaultCellIdFromSchema<Schema, TableId> extends never
406
+ ? PartialRow<Schema, TableId>
407
+ : {
408
+ -readonly [
409
+ CellId in RequiredNonDefaultCellIdFromSchema<Schema, TableId>
410
+ ]: Cell<Schema, TableId, CellId>;
411
+ } & PartialRow<Schema, TableId>
382
412
  : {
383
- -readonly [CellId in DefaultCellIdFromSchema<Schema, TableId>]: Cell<
413
+ -readonly [CellId in PresentCellIdFromSchema<Schema, TableId>]: Cell<
384
414
  Schema,
385
415
  TableId,
386
416
  CellId
387
417
  >;
388
- }) & {
389
- -readonly [CellId in DefaultCellIdFromSchema<Schema, TableId, false>]?: Cell<
418
+ } & {
419
+ -readonly [
420
+ CellId in PresentCellIdFromSchema<Schema, TableId, false>
421
+ ]?: Cell<Schema, TableId, CellId>;
422
+ };
423
+
424
+ /**
425
+ * The PartialRow type is a Row-like type used when setting part of a row.
426
+ *
427
+ * In schema-based typing, a PartialRow allows any known Cell to be omitted,
428
+ * including Cells marked with `required: true`, while still preventing unknown
429
+ * Cell Ids from being used.
430
+ * @category Store
431
+ * @since v9.1.0
432
+ */
433
+ export type PartialRow<
434
+ Schema extends OptionalTablesSchema,
435
+ TableId extends TableIdFromSchema<Schema>,
436
+ > = {
437
+ -readonly [CellId in CellIdFromSchema<Schema, TableId>]?: Cell<
390
438
  Schema,
391
439
  TableId,
392
440
  CellId
@@ -480,23 +528,38 @@ export type CellOrUndefined<
480
528
  export type Values<
481
529
  Schema extends OptionalValuesSchema,
482
530
  WhenSet extends boolean = false,
483
- > = (WhenSet extends true
484
- ? {
485
- -readonly [ValueId in DefaultValueIdFromSchema<Schema>]?: Value<
531
+ > = WhenSet extends true
532
+ ? RequiredNonDefaultValueIdFromSchema<Schema> extends never
533
+ ? PartialValues<Schema>
534
+ : {
535
+ -readonly [
536
+ ValueId in RequiredNonDefaultValueIdFromSchema<Schema>
537
+ ]: Value<Schema, ValueId>;
538
+ } & PartialValues<Schema>
539
+ : {
540
+ -readonly [ValueId in PresentValueIdFromSchema<Schema>]: Value<
486
541
  Schema,
487
542
  ValueId
488
543
  >;
489
- }
490
- : {
491
- -readonly [ValueId in DefaultValueIdFromSchema<Schema>]: Value<
544
+ } & {
545
+ -readonly [ValueId in PresentValueIdFromSchema<Schema, false>]?: Value<
492
546
  Schema,
493
547
  ValueId
494
548
  >;
495
- }) & {
496
- -readonly [ValueId in DefaultValueIdFromSchema<Schema, false>]?: Value<
497
- Schema,
498
- ValueId
499
- >;
549
+ };
550
+
551
+ /**
552
+ * The PartialValues type is a Values-like type used when setting some keyed
553
+ * values.
554
+ *
555
+ * In schema-based typing, PartialValues allows any known Value to be omitted,
556
+ * including Values marked with `required: true`, while still preventing unknown
557
+ * Value Ids from being used.
558
+ * @category Store
559
+ * @since v9.1.0
560
+ */
561
+ export type PartialValues<Schema extends OptionalValuesSchema> = {
562
+ -readonly [ValueId in ValueIdFromSchema<Schema>]?: Value<Schema, ValueId>;
500
563
  };
501
564
 
502
565
  /**
@@ -4543,7 +4606,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
4543
4606
  setPartialRow<TableId extends TableIdFromSchema<Schemas[0]>>(
4544
4607
  tableId: TableId,
4545
4608
  rowId: Id,
4546
- partialRow: Row<Schemas[0], TableId, true>,
4609
+ partialRow: PartialRow<Schemas[0], TableId>,
4547
4610
  ): this;
4548
4611
 
4549
4612
  /**
@@ -4740,7 +4803,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
4740
4803
  * @category Setter
4741
4804
  * @since v3.0.0
4742
4805
  */
4743
- setPartialValues(partialValues: Values<Schemas[1], true>): this;
4806
+ setPartialValues(partialValues: PartialValues<Schemas[1]>): this;
4744
4807
 
4745
4808
  /**
4746
4809
  * The setValue method sets a single keyed Value in the Store.
@@ -7255,6 +7255,26 @@ export function useProvideIndexes(indexesId: Id, indexes: Indexes): void;
7255
7255
  */
7256
7256
  export function useIndexIds(indexesOrIndexesId?: IndexesOrIndexesId): Ids;
7257
7257
 
7258
+ /**
7259
+ * The useHasIndex hook returns a boolean indicating whether a given Index
7260
+ * exists in the Indexes object, and registers a listener so that any changes to
7261
+ * that result will cause a re-render.
7262
+ *
7263
+ * This hook follows the same Indexes object resolution rules as the useIndexIds
7264
+ * hook.
7265
+ * @param indexId The Id of a possible Index in the Indexes object.
7266
+ * @param indexesOrIndexesId The Indexes object to be accessed: omit for the
7267
+ * default context Indexes object, provide an Id for a named context Indexes
7268
+ * object, or provide an explicit reference.
7269
+ * @returns Whether an Index with that Id exists.
7270
+ * @category Indexes hooks
7271
+ * @since v9.1.0
7272
+ */
7273
+ export function useHasIndex(
7274
+ indexId: Id,
7275
+ indexesOrIndexesId?: IndexesOrIndexesId,
7276
+ ): boolean;
7277
+
7258
7278
  /**
7259
7279
  * The useSliceIds hook gets the list of Slice Ids in an Index, and registers a
7260
7280
  * listener so that any changes to that result will cause a re-render.
@@ -7375,6 +7395,28 @@ export function useSliceIds(
7375
7395
  indexesOrIndexesId?: IndexesOrIndexesId,
7376
7396
  ): Ids;
7377
7397
 
7398
+ /**
7399
+ * The useHasSlice hook returns a boolean indicating whether a given Slice
7400
+ * exists in an Index, and registers a listener so that any changes to that
7401
+ * result will cause a re-render.
7402
+ *
7403
+ * This hook follows the same Indexes object resolution rules as the useSliceIds
7404
+ * hook.
7405
+ * @param indexId The Id of a possible Index in the Indexes object.
7406
+ * @param sliceId The Id of a possible Slice in the Index.
7407
+ * @param indexesOrIndexesId The Indexes object to be accessed: omit for the
7408
+ * default context Indexes object, provide an Id for a named context Indexes
7409
+ * object, or provide an explicit reference.
7410
+ * @returns Whether a Slice with that Id exists.
7411
+ * @category Indexes hooks
7412
+ * @since v9.1.0
7413
+ */
7414
+ export function useHasSlice(
7415
+ indexId: Id,
7416
+ sliceId: Id,
7417
+ indexesOrIndexesId?: IndexesOrIndexesId,
7418
+ ): boolean;
7419
+
7378
7420
  /**
7379
7421
  * The useSliceRowIds hook gets the list of Row Ids in a given Slice, and
7380
7422
  * registers a listener so that any changes to that result will cause a
@@ -141,6 +141,8 @@ import type {
141
141
  MapCell,
142
142
  MapValue,
143
143
  OptionalSchemas,
144
+ PartialRow,
145
+ PartialValues,
144
146
  Row,
145
147
  RowCountListener,
146
148
  RowIdsListener,
@@ -3577,14 +3579,14 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3577
3579
  * @category Store hooks
3578
3580
  * @since v1.0.0
3579
3581
  */
3580
- useSetTablesCallback: <Parameter, SetTables = Tables<Schemas[0], true>>(
3582
+ useSetTablesCallback: <Parameter>(
3581
3583
  getTables: (
3582
3584
  parameter: Parameter,
3583
3585
  store: Store<Schemas>,
3584
- ) => NoInfer<SetTables>,
3586
+ ) => Tables<Schemas[0], true>,
3585
3587
  getTablesDeps?: React.DependencyList,
3586
3588
  storeOrStoreId?: StoreOrStoreId<Schemas>,
3587
- then?: (store: Store<Schemas>, tables: SetTables) => void,
3589
+ then?: (store: Store<Schemas>, tables: Tables<Schemas[0], true>) => void,
3588
3590
  thenDeps?: React.DependencyList,
3589
3591
  ) => ParameterizedCallback<Parameter>;
3590
3592
 
@@ -3688,16 +3690,18 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3688
3690
  useSetTableCallback: <
3689
3691
  Parameter,
3690
3692
  TableId extends TableIdFromSchema<Schemas[0]>,
3691
- SetTable = Table<Schemas[0], TableId, true>,
3692
3693
  >(
3693
3694
  tableId: TableId | GetId<Schemas, Parameter, TableId>,
3694
3695
  getTable: (
3695
3696
  parameter: Parameter,
3696
3697
  store: Store<Schemas>,
3697
- ) => NoInfer<SetTable>,
3698
+ ) => Table<Schemas[0], TableId, true>,
3698
3699
  getTableDeps?: React.DependencyList,
3699
3700
  storeOrStoreId?: StoreOrStoreId<Schemas>,
3700
- then?: (store: Store<Schemas>, table: SetTable) => void,
3701
+ then?: (
3702
+ store: Store<Schemas>,
3703
+ table: Table<Schemas[0], TableId, true>,
3704
+ ) => void,
3701
3705
  thenDeps?: React.DependencyList,
3702
3706
  ) => ParameterizedCallback<Parameter>;
3703
3707
 
@@ -3803,17 +3807,16 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3803
3807
  * @category Store hooks
3804
3808
  * @since v1.0.0
3805
3809
  */
3806
- useSetRowCallback: <
3807
- Parameter,
3808
- TableId extends TableIdFromSchema<Schemas[0]>,
3809
- SetRow = Row<Schemas[0], TableId, true>,
3810
- >(
3810
+ useSetRowCallback: <Parameter, TableId extends TableIdFromSchema<Schemas[0]>>(
3811
3811
  tableId: TableId | GetId<Schemas, Parameter, TableId>,
3812
3812
  rowId: Id | GetId<Schemas, Parameter, Id>,
3813
- getRow: (parameter: Parameter, store: Store<Schemas>) => NoInfer<SetRow>,
3813
+ getRow: (
3814
+ parameter: Parameter,
3815
+ store: Store<Schemas>,
3816
+ ) => Row<Schemas[0], TableId, true>,
3814
3817
  getRowDeps?: React.DependencyList,
3815
3818
  storeOrStoreId?: StoreOrStoreId<Schemas>,
3816
- then?: (store: Store<Schemas>, row: SetRow) => void,
3819
+ then?: (store: Store<Schemas>, row: Row<Schemas[0], TableId, true>) => void,
3817
3820
  thenDeps?: React.DependencyList,
3818
3821
  ) => ParameterizedCallback<Parameter>;
3819
3822
 
@@ -3924,16 +3927,19 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
3924
3927
  * @category Store hooks
3925
3928
  * @since v1.0.0
3926
3929
  */
3927
- useAddRowCallback: <
3928
- Parameter,
3929
- TableId extends TableIdFromSchema<Schemas[0]>,
3930
- AddRow = Row<Schemas[0], TableId, true>,
3931
- >(
3930
+ useAddRowCallback: <Parameter, TableId extends TableIdFromSchema<Schemas[0]>>(
3932
3931
  tableId: TableId | GetId<Schemas, Parameter, TableId>,
3933
- getRow: (parameter: Parameter, store: Store<Schemas>) => NoInfer<AddRow>,
3932
+ getRow: (
3933
+ parameter: Parameter,
3934
+ store: Store<Schemas>,
3935
+ ) => Row<Schemas[0], TableId, true>,
3934
3936
  getRowDeps?: React.DependencyList,
3935
3937
  storeOrStoreId?: StoreOrStoreId<Schemas>,
3936
- then?: (rowId: Id | undefined, store: Store<Schemas>, row: AddRow) => void,
3938
+ then?: (
3939
+ rowId: Id | undefined,
3940
+ store: Store<Schemas>,
3941
+ row: Row<Schemas[0], TableId, true>,
3942
+ ) => void,
3937
3943
  thenDeps?: React.DependencyList,
3938
3944
  reuseRowIds?: boolean,
3939
3945
  ) => ParameterizedCallback<Parameter>;
@@ -4045,17 +4051,19 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
4045
4051
  useSetPartialRowCallback: <
4046
4052
  Parameter,
4047
4053
  TableId extends TableIdFromSchema<Schemas[0]>,
4048
- SetPartialRow = Row<Schemas[0], TableId, true>,
4049
4054
  >(
4050
4055
  tableId: TableId | GetId<Schemas, Parameter, TableId>,
4051
4056
  rowId: Id | GetId<Schemas, Parameter, Id>,
4052
4057
  getPartialRow: (
4053
4058
  parameter: Parameter,
4054
4059
  store: Store<Schemas>,
4055
- ) => NoInfer<SetPartialRow>,
4060
+ ) => PartialRow<Schemas[0], TableId>,
4056
4061
  getPartialRowDeps?: React.DependencyList,
4057
4062
  storeOrStoreId?: StoreOrStoreId<Schemas>,
4058
- then?: (store: Store<Schemas>, partialRow: SetPartialRow) => void,
4063
+ then?: (
4064
+ store: Store<Schemas>,
4065
+ partialRow: PartialRow<Schemas[0], TableId>,
4066
+ ) => void,
4059
4067
  thenDeps?: React.DependencyList,
4060
4068
  ) => ParameterizedCallback<Parameter>;
4061
4069
 
@@ -4319,14 +4327,14 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
4319
4327
  * @category Store hooks
4320
4328
  * @since v3.0.0
4321
4329
  */
4322
- useSetValuesCallback: <Parameter, SetValues = Values<Schemas[1], true>>(
4330
+ useSetValuesCallback: <Parameter>(
4323
4331
  getValues: (
4324
4332
  parameter: Parameter,
4325
4333
  store: Store<Schemas>,
4326
- ) => NoInfer<SetValues>,
4334
+ ) => Values<Schemas[1], true>,
4327
4335
  getValuesDeps?: React.DependencyList,
4328
4336
  storeOrStoreId?: StoreOrStoreId<Schemas>,
4329
- then?: (store: Store<Schemas>, values: SetValues) => void,
4337
+ then?: (store: Store<Schemas>, values: Values<Schemas[1], true>) => void,
4330
4338
  thenDeps?: React.DependencyList,
4331
4339
  ) => ParameterizedCallback<Parameter>;
4332
4340
 
@@ -4424,17 +4432,17 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
4424
4432
  * @category Store hooks
4425
4433
  * @since v3.0.0
4426
4434
  */
4427
- useSetPartialValuesCallback: <
4428
- Parameter,
4429
- SetPartialValues = Values<Schemas[1], true>,
4430
- >(
4435
+ useSetPartialValuesCallback: <Parameter>(
4431
4436
  getPartialValues: (
4432
4437
  parameter: Parameter,
4433
4438
  store: Store<Schemas>,
4434
- ) => NoInfer<SetPartialValues>,
4439
+ ) => PartialValues<Schemas[1]>,
4435
4440
  getPartialValuesDeps?: React.DependencyList,
4436
4441
  storeOrStoreId?: StoreOrStoreId<Schemas>,
4437
- then?: (store: Store<Schemas>, partialValues: SetPartialValues) => void,
4442
+ then?: (
4443
+ store: Store<Schemas>,
4444
+ partialValues: PartialValues<Schemas[1]>,
4445
+ ) => void,
4438
4446
  thenDeps?: React.DependencyList,
4439
4447
  ) => ParameterizedCallback<Parameter>;
4440
4448
 
@@ -8179,6 +8187,35 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
8179
8187
  */
8180
8188
  useIndexIds(indexesOrIndexesId?: IndexesOrIndexesId<Schemas>): Ids;
8181
8189
 
8190
+ /**
8191
+ * The useHasIndex hook returns a boolean indicating whether a given Index
8192
+ * exists in the Indexes object, and registers a listener so that any changes to
8193
+ * that result will cause a re-render.
8194
+ *
8195
+ * This has schema-based typing. The following is a simplified representation:
8196
+ *
8197
+ * ```ts override
8198
+ * useHasIndex(
8199
+ * indexId: Id,
8200
+ * indexesOrIndexesId?: IndexesOrIndexesId,
8201
+ * ): boolean;
8202
+ * ```
8203
+ *
8204
+ * This hook follows the same Indexes object resolution rules as the useIndexIds
8205
+ * hook.
8206
+ * @param indexId The Id of a possible Index in the Indexes object.
8207
+ * @param indexesOrIndexesId The Indexes object to be accessed: omit for the
8208
+ * default context Indexes object, provide an Id for a named context Indexes
8209
+ * object, or provide an explicit reference.
8210
+ * @returns Whether an Index with that Id exists.
8211
+ * @category Indexes hooks
8212
+ * @since v9.1.0
8213
+ */
8214
+ useHasIndex: (
8215
+ indexId: Id,
8216
+ indexesOrIndexesId?: IndexesOrIndexesId<Schemas>,
8217
+ ) => boolean;
8218
+
8182
8219
  /**
8183
8220
  * The useSliceIds hook gets the list of Slice Ids in an Index, and registers a
8184
8221
  * listener so that any changes to that result will cause a re-render.
@@ -8308,6 +8345,38 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
8308
8345
  indexesOrIndexesId?: IndexesOrIndexesId<Schemas>,
8309
8346
  ) => Ids;
8310
8347
 
8348
+ /**
8349
+ * The useHasSlice hook returns a boolean indicating whether a given Slice
8350
+ * exists in an Index, and registers a listener so that any changes to that
8351
+ * result will cause a re-render.
8352
+ *
8353
+ * This has schema-based typing. The following is a simplified representation:
8354
+ *
8355
+ * ```ts override
8356
+ * useHasSlice(
8357
+ * indexId: Id,
8358
+ * sliceId: Id,
8359
+ * indexesOrIndexesId?: IndexesOrIndexesId,
8360
+ * ): boolean;
8361
+ * ```
8362
+ *
8363
+ * This hook follows the same Indexes object resolution rules as the useSliceIds
8364
+ * hook.
8365
+ * @param indexId The Id of a possible Index in the Indexes object.
8366
+ * @param sliceId The Id of a possible Slice in the Index.
8367
+ * @param indexesOrIndexesId The Indexes object to be accessed: omit for the
8368
+ * default context Indexes object, provide an Id for a named context Indexes
8369
+ * object, or provide an explicit reference.
8370
+ * @returns Whether a Slice with that Id exists.
8371
+ * @category Indexes hooks
8372
+ * @since v9.1.0
8373
+ */
8374
+ useHasSlice: (
8375
+ indexId: Id,
8376
+ sliceId: Id,
8377
+ indexesOrIndexesId?: IndexesOrIndexesId<Schemas>,
8378
+ ) => boolean;
8379
+
8311
8380
  /**
8312
8381
  * The useSliceRowIds hook gets the list of Row Ids in a given Slice, and
8313
8382
  * registers a listener so that any changes to that result will cause a
@@ -6871,6 +6871,26 @@ export function useIndexIds(
6871
6871
  indexesOrIndexesId?: MaybeAccessor<IndexesOrIndexesId | undefined>,
6872
6872
  ): Accessor<Ids>;
6873
6873
 
6874
+ /**
6875
+ * The useHasIndex primitive returns a boolean indicating whether a given Index
6876
+ * exists in the Indexes object, and registers a listener so that any changes to
6877
+ * that result will cause an update.
6878
+ *
6879
+ * This primitive follows the same Indexes object resolution rules as the
6880
+ * useIndexIds primitive.
6881
+ * @param indexId The Id of a possible Index in the Indexes object.
6882
+ * @param indexesOrIndexesId The Indexes object to be accessed: omit for the
6883
+ * default context Indexes object, provide an Id for a named context Indexes
6884
+ * object, or provide an explicit reference.
6885
+ * @returns Whether an Index with that Id exists.
6886
+ * @category Indexes primitives
6887
+ * @since v9.1.0
6888
+ */
6889
+ export function useHasIndex(
6890
+ indexId: MaybeAccessor<Id>,
6891
+ indexesOrIndexesId?: MaybeAccessor<IndexesOrIndexesId | undefined>,
6892
+ ): Accessor<boolean>;
6893
+
6874
6894
  /**
6875
6895
  * The useSliceIds primitive gets the list of Slice Ids in an Index, and
6876
6896
  * registers a listener so that any changes to that result will cause an update.
@@ -6958,6 +6978,28 @@ export function useSliceIds(
6958
6978
  indexesOrIndexesId?: MaybeAccessor<IndexesOrIndexesId | undefined>,
6959
6979
  ): Accessor<Ids>;
6960
6980
 
6981
+ /**
6982
+ * The useHasSlice primitive returns a boolean indicating whether a given Slice
6983
+ * exists in an Index, and registers a listener so that any changes to that
6984
+ * result will cause an update.
6985
+ *
6986
+ * This primitive follows the same Indexes object resolution rules as the
6987
+ * useSliceIds primitive.
6988
+ * @param indexId The Id of a possible Index in the Indexes object.
6989
+ * @param sliceId The Id of a possible Slice in the Index.
6990
+ * @param indexesOrIndexesId The Indexes object to be accessed: omit for the
6991
+ * default context Indexes object, provide an Id for a named context Indexes
6992
+ * object, or provide an explicit reference.
6993
+ * @returns Whether a Slice with that Id exists.
6994
+ * @category Indexes primitives
6995
+ * @since v9.1.0
6996
+ */
6997
+ export function useHasSlice(
6998
+ indexId: MaybeAccessor<Id>,
6999
+ sliceId: MaybeAccessor<Id>,
7000
+ indexesOrIndexesId?: MaybeAccessor<IndexesOrIndexesId | undefined>,
7001
+ ): Accessor<boolean>;
7002
+
6961
7003
  /**
6962
7004
  * The useSliceRowIds primitive gets the list of Row Ids in a given Slice, and
6963
7005
  * registers a listener so that any changes to that result will cause an update.