tinybase 9.1.0-beta.0 → 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.
- package/@types/_internal/store/with-schemas/index.d.ts +133 -2
- package/@types/common/index.d.ts +17 -2
- package/@types/common/with-schemas/index.d.ts +18 -2
- package/@types/indexes/index.d.ts +97 -0
- package/@types/indexes/with-schemas/index.d.ts +137 -0
- package/@types/store/index.d.ts +133 -25
- package/@types/store/with-schemas/index.d.ts +145 -51
- package/@types/ui-react/index.d.ts +48 -2
- package/@types/ui-react/with-schemas/index.d.ts +108 -34
- package/@types/ui-solid/index.d.ts +51 -2
- package/@types/ui-solid/with-schemas/index.d.ts +111 -34
- package/@types/ui-svelte/index.d.ts +84 -2
- package/@types/ui-svelte/with-schemas/index.d.ts +122 -25
- package/index.js +155 -38
- package/indexes/index.js +39 -0
- package/indexes/with-schemas/index.js +39 -0
- package/mergeable-store/index.js +116 -38
- package/mergeable-store/with-schemas/index.js +116 -38
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/indexes/index.js +1 -1
- package/min/indexes/index.js.gz +0 -0
- package/min/indexes/with-schemas/index.js +1 -1
- package/min/indexes/with-schemas/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/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/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/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom/index.js +1 -1
- package/min/ui-react-dom/index.js.gz +0 -0
- package/min/ui-react-dom/with-schemas/index.js +1 -1
- package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom-charts/index.js +1 -1
- package/min/ui-react-dom-charts/index.js.gz +0 -0
- package/min/ui-react-dom-charts/with-schemas/index.js +1 -1
- package/min/ui-react-dom-charts/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/index.js +1 -1
- package/min/ui-solid/index.js.gz +0 -0
- package/min/ui-solid/with-schemas/index.js +1 -1
- package/min/ui-solid/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-dom/index.js +1 -1
- package/min/ui-solid-dom/index.js.gz +0 -0
- package/min/ui-solid-dom/with-schemas/index.js +1 -1
- package/min/ui-solid-dom/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/index.js +1 -1
- package/min/ui-svelte/index.js.gz +0 -0
- package/min/ui-svelte/with-schemas/index.js +1 -1
- package/min/ui-svelte/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-dom/index.js +1 -1
- package/min/ui-svelte-dom/index.js.gz +0 -0
- package/min/ui-svelte-dom/with-schemas/index.js +1 -1
- package/min/ui-svelte-dom/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 +155 -38
- package/omni/with-schemas/index.js +155 -38
- package/package.json +3 -3
- package/readme.md +14 -14
- package/releases.md +101 -60
- package/store/index.js +116 -38
- package/store/with-schemas/index.js +116 -38
- package/ui-react/index.js +52 -6
- package/ui-react/with-schemas/index.js +52 -6
- package/ui-react-dom/index.js +24 -4
- package/ui-react-dom/with-schemas/index.js +24 -4
- package/ui-react-dom-charts/index.js +24 -4
- package/ui-react-dom-charts/with-schemas/index.js +24 -4
- package/ui-react-inspector/index.js +140 -42
- package/ui-react-inspector/with-schemas/index.js +140 -42
- package/ui-solid/index.js +48 -2
- package/ui-solid/with-schemas/index.js +48 -2
- package/ui-solid-dom/index.js +17 -1
- package/ui-solid-dom/with-schemas/index.js +17 -1
- package/ui-solid-inspector/index.js +133 -39
- package/ui-solid-inspector/with-schemas/index.js +133 -39
- package/ui-svelte/index.js +91 -31
- package/ui-svelte/with-schemas/index.js +91 -31
- package/ui-svelte-dom/index.js +35 -14
- package/ui-svelte-dom/with-schemas/index.js +35 -14
- package/ui-svelte-inspector/index.js +151 -52
- package/ui-svelte-inspector/with-schemas/index.js +151 -52
- package/with-schemas/index.js +155 -38
|
@@ -33,6 +33,53 @@ export type DefaultCellIdFromSchema<
|
|
|
33
33
|
}[CellIdFromSchema<Schema, TableId>]
|
|
34
34
|
>;
|
|
35
35
|
|
|
36
|
+
export type RequiredCellIdFromSchema<
|
|
37
|
+
Schema extends OptionalTablesSchema,
|
|
38
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
39
|
+
IsRequired extends boolean = true,
|
|
40
|
+
> = AsId<
|
|
41
|
+
{
|
|
42
|
+
[CellId in CellIdFromSchema<Schema, TableId>]: CellIsRequiredFromSchema<
|
|
43
|
+
Schema,
|
|
44
|
+
TableId,
|
|
45
|
+
CellId,
|
|
46
|
+
IsRequired extends true ? CellId : never,
|
|
47
|
+
IsRequired extends true ? never : CellId
|
|
48
|
+
>;
|
|
49
|
+
}[CellIdFromSchema<Schema, TableId>]
|
|
50
|
+
>;
|
|
51
|
+
|
|
52
|
+
export type PresentCellIdFromSchema<
|
|
53
|
+
Schema extends OptionalTablesSchema,
|
|
54
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
55
|
+
IsPresent extends boolean = true,
|
|
56
|
+
> = AsId<
|
|
57
|
+
{
|
|
58
|
+
[CellId in CellIdFromSchema<Schema, TableId>]: CellIsPresentFromSchema<
|
|
59
|
+
Schema,
|
|
60
|
+
TableId,
|
|
61
|
+
CellId,
|
|
62
|
+
IsPresent extends true ? CellId : never,
|
|
63
|
+
IsPresent extends true ? never : CellId
|
|
64
|
+
>;
|
|
65
|
+
}[CellIdFromSchema<Schema, TableId>]
|
|
66
|
+
>;
|
|
67
|
+
|
|
68
|
+
export type RequiredNonDefaultCellIdFromSchema<
|
|
69
|
+
Schema extends OptionalTablesSchema,
|
|
70
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
71
|
+
> = AsId<
|
|
72
|
+
{
|
|
73
|
+
[CellId in CellIdFromSchema<Schema, TableId>]: CellIsRequiredFromSchema<
|
|
74
|
+
Schema,
|
|
75
|
+
TableId,
|
|
76
|
+
CellId,
|
|
77
|
+
CellIsDefaultedFromSchema<Schema, TableId, CellId, never, CellId>,
|
|
78
|
+
never
|
|
79
|
+
>;
|
|
80
|
+
}[CellIdFromSchema<Schema, TableId>]
|
|
81
|
+
>;
|
|
82
|
+
|
|
36
83
|
export type AllCellIdFromSchema<
|
|
37
84
|
Schema extends OptionalTablesSchema,
|
|
38
85
|
TableId extends TableIdFromSchema<Schema> = TableIdFromSchema<Schema>,
|
|
@@ -53,13 +100,39 @@ export type CellIsDefaultedFromSchema<
|
|
|
53
100
|
? Then
|
|
54
101
|
: Else;
|
|
55
102
|
|
|
103
|
+
export type CellIsRequiredFromSchema<
|
|
104
|
+
Schema extends OptionalTablesSchema,
|
|
105
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
106
|
+
CellId extends CellIdFromSchema<Schema, TableId>,
|
|
107
|
+
Then,
|
|
108
|
+
Else,
|
|
109
|
+
> = Schema[TableId][CellId] extends {
|
|
110
|
+
required: true;
|
|
111
|
+
}
|
|
112
|
+
? Then
|
|
113
|
+
: Else;
|
|
114
|
+
|
|
115
|
+
export type CellIsPresentFromSchema<
|
|
116
|
+
Schema extends OptionalTablesSchema,
|
|
117
|
+
TableId extends TableIdFromSchema<Schema>,
|
|
118
|
+
CellId extends CellIdFromSchema<Schema, TableId>,
|
|
119
|
+
Then,
|
|
120
|
+
Else,
|
|
121
|
+
> = CellIsDefaultedFromSchema<
|
|
122
|
+
Schema,
|
|
123
|
+
TableId,
|
|
124
|
+
CellId,
|
|
125
|
+
Then,
|
|
126
|
+
CellIsRequiredFromSchema<Schema, TableId, CellId, Then, Else>
|
|
127
|
+
>;
|
|
128
|
+
|
|
56
129
|
export type DefaultedCellFromSchema<
|
|
57
130
|
Schema extends OptionalTablesSchema,
|
|
58
131
|
TableId extends TableIdFromSchema<Schema>,
|
|
59
132
|
CellId extends CellIdFromSchema<Schema, TableId>,
|
|
60
133
|
> =
|
|
61
134
|
| Cell<Schema, TableId, CellId>
|
|
62
|
-
|
|
|
135
|
+
| CellIsPresentFromSchema<Schema, TableId, CellId, never, undefined>;
|
|
63
136
|
|
|
64
137
|
export type ValueIdFromSchema<Schema extends OptionalValuesSchema> = AsId<
|
|
65
138
|
keyof Schema
|
|
@@ -77,6 +150,41 @@ export type DefaultValueIdFromSchema<
|
|
|
77
150
|
>;
|
|
78
151
|
}[ValueIdFromSchema<Schema>];
|
|
79
152
|
|
|
153
|
+
export type RequiredValueIdFromSchema<
|
|
154
|
+
Schema extends OptionalValuesSchema,
|
|
155
|
+
IsRequired extends boolean = true,
|
|
156
|
+
> = {
|
|
157
|
+
[ValueId in ValueIdFromSchema<Schema>]: ValueIsRequiredFromSchema<
|
|
158
|
+
Schema,
|
|
159
|
+
ValueId,
|
|
160
|
+
IsRequired extends true ? ValueId : never,
|
|
161
|
+
IsRequired extends true ? never : ValueId
|
|
162
|
+
>;
|
|
163
|
+
}[ValueIdFromSchema<Schema>];
|
|
164
|
+
|
|
165
|
+
export type PresentValueIdFromSchema<
|
|
166
|
+
Schema extends OptionalValuesSchema,
|
|
167
|
+
IsPresent extends boolean = true,
|
|
168
|
+
> = {
|
|
169
|
+
[ValueId in ValueIdFromSchema<Schema>]: ValueIsPresentFromSchema<
|
|
170
|
+
Schema,
|
|
171
|
+
ValueId,
|
|
172
|
+
IsPresent extends true ? ValueId : never,
|
|
173
|
+
IsPresent extends true ? never : ValueId
|
|
174
|
+
>;
|
|
175
|
+
}[ValueIdFromSchema<Schema>];
|
|
176
|
+
|
|
177
|
+
export type RequiredNonDefaultValueIdFromSchema<
|
|
178
|
+
Schema extends OptionalValuesSchema,
|
|
179
|
+
> = {
|
|
180
|
+
[ValueId in ValueIdFromSchema<Schema>]: ValueIsRequiredFromSchema<
|
|
181
|
+
Schema,
|
|
182
|
+
ValueId,
|
|
183
|
+
ValueIsDefaultedFromSchema<Schema, ValueId, never, ValueId>,
|
|
184
|
+
never
|
|
185
|
+
>;
|
|
186
|
+
}[ValueIdFromSchema<Schema>];
|
|
187
|
+
|
|
80
188
|
export type ValueIsDefaultedFromSchema<
|
|
81
189
|
Schema extends OptionalValuesSchema,
|
|
82
190
|
ValueId extends ValueIdFromSchema<Schema>,
|
|
@@ -88,12 +196,35 @@ export type ValueIsDefaultedFromSchema<
|
|
|
88
196
|
? Then
|
|
89
197
|
: Else;
|
|
90
198
|
|
|
199
|
+
export type ValueIsRequiredFromSchema<
|
|
200
|
+
Schema extends OptionalValuesSchema,
|
|
201
|
+
ValueId extends ValueIdFromSchema<Schema>,
|
|
202
|
+
Then,
|
|
203
|
+
Else,
|
|
204
|
+
> = Schema[ValueId] extends {
|
|
205
|
+
required: true;
|
|
206
|
+
}
|
|
207
|
+
? Then
|
|
208
|
+
: Else;
|
|
209
|
+
|
|
210
|
+
export type ValueIsPresentFromSchema<
|
|
211
|
+
Schema extends OptionalValuesSchema,
|
|
212
|
+
ValueId extends ValueIdFromSchema<Schema>,
|
|
213
|
+
Then,
|
|
214
|
+
Else,
|
|
215
|
+
> = ValueIsDefaultedFromSchema<
|
|
216
|
+
Schema,
|
|
217
|
+
ValueId,
|
|
218
|
+
Then,
|
|
219
|
+
ValueIsRequiredFromSchema<Schema, ValueId, Then, Else>
|
|
220
|
+
>;
|
|
221
|
+
|
|
91
222
|
export type DefaultedValueFromSchema<
|
|
92
223
|
Schema extends OptionalValuesSchema,
|
|
93
224
|
ValueId extends ValueIdFromSchema<Schema>,
|
|
94
225
|
> =
|
|
95
226
|
| Value<Schema, ValueId>
|
|
96
|
-
|
|
|
227
|
+
| ValueIsPresentFromSchema<Schema, ValueId, never, undefined>;
|
|
97
228
|
|
|
98
229
|
export type AsId<Key> = Exclude<Key & Id, number>;
|
|
99
230
|
|
package/@types/common/index.d.ts
CHANGED
|
@@ -83,11 +83,26 @@ export type ParameterizedCallback<Parameter> = (parameter?: Parameter) => void;
|
|
|
83
83
|
export type Callback = () => void;
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* The SortKey type represents a value that can be used by
|
|
86
|
+
* The SortKey type represents a Cell value, or `undefined`, that can be used by
|
|
87
|
+
* a sort function.
|
|
87
88
|
* @category Parameter
|
|
88
89
|
* @since v1.0.0
|
|
89
90
|
*/
|
|
90
|
-
export type SortKey =
|
|
91
|
+
export type SortKey = CellOrUndefined;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The Sorter type represents a function that compares two SortKey values.
|
|
95
|
+
*
|
|
96
|
+
* A Sorter is provided to methods that sort Row Ids when the default
|
|
97
|
+
* alphanumeric ordering is not appropriate. Return a positive or negative
|
|
98
|
+
* number to indicate which of the two SortKey values should be ordered first.
|
|
99
|
+
* @param sortKey1 The first item of the pair to compare.
|
|
100
|
+
* @param sortKey2 The second item of the pair to compare.
|
|
101
|
+
* @returns A number indicating how to sort the pair.
|
|
102
|
+
* @category Parameter
|
|
103
|
+
* @since v9.1.0
|
|
104
|
+
*/
|
|
105
|
+
export type Sorter = (sortKey1: SortKey, sortKey2: SortKey) => number;
|
|
91
106
|
|
|
92
107
|
/**
|
|
93
108
|
* The GetNow type is used to represent a function that returns the current time
|
|
@@ -95,11 +95,27 @@ export type ParameterizedCallback<Parameter> = (parameter?: Parameter) => void;
|
|
|
95
95
|
export type Callback = () => void;
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* The SortKey type represents a value that can be used by
|
|
98
|
+
* The SortKey type represents a Cell value, or `undefined`, that can be used by
|
|
99
|
+
* a sort function.
|
|
99
100
|
* @category Parameter
|
|
100
101
|
* @since v1.0.0
|
|
101
102
|
*/
|
|
102
|
-
export type SortKey =
|
|
103
|
+
export type SortKey =
|
|
104
|
+
string | number | boolean | null | AnyObject | AnyArray | undefined;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The Sorter type represents a function that compares two SortKey values.
|
|
108
|
+
*
|
|
109
|
+
* A Sorter is provided to methods that sort Row Ids when the default
|
|
110
|
+
* alphanumeric ordering is not appropriate. Return a positive or negative
|
|
111
|
+
* number to indicate which of the two SortKey values should be ordered first.
|
|
112
|
+
* @param sortKey1 The first item of the pair to compare.
|
|
113
|
+
* @param sortKey2 The second item of the pair to compare.
|
|
114
|
+
* @returns A number indicating how to sort the pair.
|
|
115
|
+
* @category Parameter
|
|
116
|
+
* @since v9.1.0
|
|
117
|
+
*/
|
|
118
|
+
export type Sorter = (sortKey1: SortKey, sortKey2: SortKey) => number;
|
|
103
119
|
|
|
104
120
|
/**
|
|
105
121
|
* The GetNow type is used to represent a function that returns the current time
|
|
@@ -92,6 +92,27 @@ export type SliceCallback = (
|
|
|
92
92
|
*/
|
|
93
93
|
export type IndexIdsListener = (indexes: Indexes) => void;
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* The HasIndexListener type describes a function that is used to listen to
|
|
97
|
+
* Index definitions being added or removed.
|
|
98
|
+
*
|
|
99
|
+
* A HasIndexListener is provided when using the addHasIndexListener method.
|
|
100
|
+
* See that method for specific examples.
|
|
101
|
+
*
|
|
102
|
+
* When called, a HasIndexListener is given a reference to the Indexes object,
|
|
103
|
+
* the Id of the Index that changed, and whether it now exists.
|
|
104
|
+
* @param indexes A reference to the Indexes object that changed.
|
|
105
|
+
* @param indexId The Id of the Index that changed.
|
|
106
|
+
* @param hasIndex Whether the Index now exists.
|
|
107
|
+
* @category Listener
|
|
108
|
+
* @since v9.1.0
|
|
109
|
+
*/
|
|
110
|
+
export type HasIndexListener = (
|
|
111
|
+
indexes: Indexes,
|
|
112
|
+
indexId: Id,
|
|
113
|
+
hasIndex: boolean,
|
|
114
|
+
) => void;
|
|
115
|
+
|
|
95
116
|
/**
|
|
96
117
|
* The SliceIdsListener type describes a function that is used to listen to
|
|
97
118
|
* changes to the Slice Ids in an Index.
|
|
@@ -108,6 +129,30 @@ export type IndexIdsListener = (indexes: Indexes) => void;
|
|
|
108
129
|
*/
|
|
109
130
|
export type SliceIdsListener = (indexes: Indexes, indexId: Id) => void;
|
|
110
131
|
|
|
132
|
+
/**
|
|
133
|
+
* The HasSliceListener type describes a function that is used to listen to
|
|
134
|
+
* Slices being added to or removed from an Index.
|
|
135
|
+
*
|
|
136
|
+
* A HasSliceListener is provided when using the addHasSliceListener method. See
|
|
137
|
+
* that method for specific examples.
|
|
138
|
+
*
|
|
139
|
+
* When called, a HasSliceListener is given a reference to the Indexes object,
|
|
140
|
+
* the Id of the Index that changed, the Id of the Slice that changed, and
|
|
141
|
+
* whether it now exists.
|
|
142
|
+
* @param indexes A reference to the Indexes object that changed.
|
|
143
|
+
* @param indexId The Id of the Index that changed.
|
|
144
|
+
* @param sliceId The Id of the Slice that changed.
|
|
145
|
+
* @param hasSlice Whether the Slice now exists.
|
|
146
|
+
* @category Listener
|
|
147
|
+
* @since v9.1.0
|
|
148
|
+
*/
|
|
149
|
+
export type HasSliceListener = (
|
|
150
|
+
indexes: Indexes,
|
|
151
|
+
indexId: Id,
|
|
152
|
+
sliceId: Id,
|
|
153
|
+
hasSlice: boolean,
|
|
154
|
+
) => void;
|
|
155
|
+
|
|
111
156
|
/**
|
|
112
157
|
* The SliceRowIdsListener type describes a function that is used to listen to
|
|
113
158
|
* changes to the Row Ids in a Slice.
|
|
@@ -812,6 +857,27 @@ export interface Indexes {
|
|
|
812
857
|
*/
|
|
813
858
|
addIndexIdsListener(listener: IndexIdsListener): Id;
|
|
814
859
|
|
|
860
|
+
/**
|
|
861
|
+
* The addHasIndexListener method registers a listener function with the
|
|
862
|
+
* Indexes object that will be called whenever an Index definition is added or
|
|
863
|
+
* removed.
|
|
864
|
+
*
|
|
865
|
+
* You can either listen to a single Index (by specifying the Index Id as the
|
|
866
|
+
* method's first parameter), or changes to any Index (by providing a `null`
|
|
867
|
+
* wildcard).
|
|
868
|
+
*
|
|
869
|
+
* The provided listener is a HasIndexListener function, and will be called
|
|
870
|
+
* with a reference to the Indexes object, the Id of the Index that changed,
|
|
871
|
+
* and whether it now exists.
|
|
872
|
+
* @param indexId The Id of the Index to listen to, or `null` as a wildcard.
|
|
873
|
+
* @param listener The function that will be called whenever the Index is
|
|
874
|
+
* added or removed.
|
|
875
|
+
* @returns A unique Id for the listener that can later be used to remove it.
|
|
876
|
+
* @category Listener
|
|
877
|
+
* @since v9.1.0
|
|
878
|
+
*/
|
|
879
|
+
addHasIndexListener(indexId: IdOrNull, listener: HasIndexListener): Id;
|
|
880
|
+
|
|
815
881
|
/**
|
|
816
882
|
* The addSliceRowIdsListener method registers a listener function with the
|
|
817
883
|
* Indexes object that will be called whenever the Row Ids in a Slice change.
|
|
@@ -909,6 +975,37 @@ export interface Indexes {
|
|
|
909
975
|
listener: SliceRowIdsListener,
|
|
910
976
|
): Id;
|
|
911
977
|
|
|
978
|
+
/**
|
|
979
|
+
* The addHasSliceListener method registers a listener function with the
|
|
980
|
+
* Indexes object that will be called whenever a Slice is added to or removed
|
|
981
|
+
* from an Index.
|
|
982
|
+
*
|
|
983
|
+
* You can either listen to a single Slice (by specifying the Index Id and
|
|
984
|
+
* Slice Id as the method's first two parameters), or changes to any Slice (by
|
|
985
|
+
* providing `null` wildcards).
|
|
986
|
+
*
|
|
987
|
+
* Both, either, or neither of the `indexId` and `sliceId` parameters can be
|
|
988
|
+
* wildcarded with `null`. You can listen to a specific Slice in a specific
|
|
989
|
+
* Index, any Slice in a specific Index, a specific Slice in any Index, or any
|
|
990
|
+
* Slice in any Index.
|
|
991
|
+
*
|
|
992
|
+
* The provided listener is a HasSliceListener function, and will be called
|
|
993
|
+
* with a reference to the Indexes object, the Id of the Index, the Id of the
|
|
994
|
+
* Slice that changed, and whether it now exists.
|
|
995
|
+
* @param indexId The Id of the Index to listen to, or `null` as a wildcard.
|
|
996
|
+
* @param sliceId The Id of the Slice to listen to, or `null` as a wildcard.
|
|
997
|
+
* @param listener The function that will be called whenever the Slice is
|
|
998
|
+
* added or removed.
|
|
999
|
+
* @returns A unique Id for the listener that can later be used to remove it.
|
|
1000
|
+
* @category Listener
|
|
1001
|
+
* @since v9.1.0
|
|
1002
|
+
*/
|
|
1003
|
+
addHasSliceListener(
|
|
1004
|
+
indexId: IdOrNull,
|
|
1005
|
+
sliceId: IdOrNull,
|
|
1006
|
+
listener: HasSliceListener,
|
|
1007
|
+
): Id;
|
|
1008
|
+
|
|
912
1009
|
/**
|
|
913
1010
|
* The delListener method removes a listener that was previously added to the
|
|
914
1011
|
* Indexes object.
|
|
@@ -133,6 +133,37 @@ export type IndexIdsListener<Schemas extends OptionalSchemas> = (
|
|
|
133
133
|
indexes: Indexes<Schemas>,
|
|
134
134
|
) => void;
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* The HasIndexListener type describes a function that is used to listen to
|
|
138
|
+
* Index definitions being added or removed.
|
|
139
|
+
*
|
|
140
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
141
|
+
*
|
|
142
|
+
* ```ts override
|
|
143
|
+
* (
|
|
144
|
+
* indexes: Indexes,
|
|
145
|
+
* indexId: Id,
|
|
146
|
+
* hasIndex: boolean,
|
|
147
|
+
* ) => void;
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* A HasIndexListener is provided when using the addHasIndexListener method.
|
|
151
|
+
* See that method for specific examples.
|
|
152
|
+
*
|
|
153
|
+
* When called, a HasIndexListener is given a reference to the Indexes object,
|
|
154
|
+
* the Id of the Index that changed, and whether it now exists.
|
|
155
|
+
* @param indexes A reference to the Indexes object that changed.
|
|
156
|
+
* @param indexId The Id of the Index that changed.
|
|
157
|
+
* @param hasIndex Whether the Index now exists.
|
|
158
|
+
* @category Listener
|
|
159
|
+
* @since v9.1.0
|
|
160
|
+
*/
|
|
161
|
+
export type HasIndexListener<Schemas extends OptionalSchemas> = (
|
|
162
|
+
indexes: Indexes<Schemas>,
|
|
163
|
+
indexId: Id,
|
|
164
|
+
hasIndex: boolean,
|
|
165
|
+
) => void;
|
|
166
|
+
|
|
136
167
|
/**
|
|
137
168
|
* The SliceIdsListener type describes a function that is used to listen to
|
|
138
169
|
* changes to the Slice Ids in an Index.
|
|
@@ -158,6 +189,41 @@ export type SliceIdsListener<Schemas extends OptionalSchemas> = (
|
|
|
158
189
|
indexId: Id,
|
|
159
190
|
) => void;
|
|
160
191
|
|
|
192
|
+
/**
|
|
193
|
+
* The HasSliceListener type describes a function that is used to listen to
|
|
194
|
+
* Slices being added to or removed from an Index.
|
|
195
|
+
*
|
|
196
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
197
|
+
*
|
|
198
|
+
* ```ts override
|
|
199
|
+
* (
|
|
200
|
+
* indexes: Indexes,
|
|
201
|
+
* indexId: Id,
|
|
202
|
+
* sliceId: Id,
|
|
203
|
+
* hasSlice: boolean,
|
|
204
|
+
* ) => void;
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* A HasSliceListener is provided when using the addHasSliceListener method. See
|
|
208
|
+
* that method for specific examples.
|
|
209
|
+
*
|
|
210
|
+
* When called, a HasSliceListener is given a reference to the Indexes object,
|
|
211
|
+
* the Id of the Index that changed, the Id of the Slice that changed, and
|
|
212
|
+
* whether it now exists.
|
|
213
|
+
* @param indexes A reference to the Indexes object that changed.
|
|
214
|
+
* @param indexId The Id of the Index that changed.
|
|
215
|
+
* @param sliceId The Id of the Slice that changed.
|
|
216
|
+
* @param hasSlice Whether the Slice now exists.
|
|
217
|
+
* @category Listener
|
|
218
|
+
* @since v9.1.0
|
|
219
|
+
*/
|
|
220
|
+
export type HasSliceListener<Schemas extends OptionalSchemas> = (
|
|
221
|
+
indexes: Indexes<Schemas>,
|
|
222
|
+
indexId: Id,
|
|
223
|
+
sliceId: Id,
|
|
224
|
+
hasSlice: boolean,
|
|
225
|
+
) => void;
|
|
226
|
+
|
|
161
227
|
/**
|
|
162
228
|
* The SliceRowIdsListener type describes a function that is used to listen to
|
|
163
229
|
* changes to the Row Ids in a Slice.
|
|
@@ -845,6 +911,36 @@ export interface Indexes<in out Schemas extends OptionalSchemas> {
|
|
|
845
911
|
*/
|
|
846
912
|
addIndexIdsListener(listener: IndexIdsListener<Schemas>): Id;
|
|
847
913
|
|
|
914
|
+
/**
|
|
915
|
+
* The addHasIndexListener method registers a listener function with the
|
|
916
|
+
* Indexes object that will be called whenever an Index definition is added or
|
|
917
|
+
* removed.
|
|
918
|
+
*
|
|
919
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
920
|
+
*
|
|
921
|
+
* ```ts override
|
|
922
|
+
* addHasIndexListener(indexId: IdOrNull, listener: HasIndexListener): Id;
|
|
923
|
+
* ```
|
|
924
|
+
*
|
|
925
|
+
* You can either listen to a single Index (by specifying the Index Id as the
|
|
926
|
+
* method's first parameter), or changes to any Index (by providing a `null`
|
|
927
|
+
* wildcard).
|
|
928
|
+
*
|
|
929
|
+
* The provided listener is a HasIndexListener function, and will be called
|
|
930
|
+
* with a reference to the Indexes object, the Id of the Index that changed,
|
|
931
|
+
* and whether it now exists.
|
|
932
|
+
* @param indexId The Id of the Index to listen to, or `null` as a wildcard.
|
|
933
|
+
* @param listener The function that will be called whenever the Index is
|
|
934
|
+
* added or removed.
|
|
935
|
+
* @returns A unique Id for the listener that can later be used to remove it.
|
|
936
|
+
* @category Listener
|
|
937
|
+
* @since v9.1.0
|
|
938
|
+
*/
|
|
939
|
+
addHasIndexListener(
|
|
940
|
+
indexId: IdOrNull,
|
|
941
|
+
listener: HasIndexListener<Schemas>,
|
|
942
|
+
): Id;
|
|
943
|
+
|
|
848
944
|
/**
|
|
849
945
|
* The addSliceIdsListener method registers a listener function with the
|
|
850
946
|
* Indexes object that will be called whenever the Slice Ids in an Index
|
|
@@ -1042,6 +1138,47 @@ export interface Indexes<in out Schemas extends OptionalSchemas> {
|
|
|
1042
1138
|
listener: SliceRowIdsListener<Schemas>,
|
|
1043
1139
|
): Id;
|
|
1044
1140
|
|
|
1141
|
+
/**
|
|
1142
|
+
* The addHasSliceListener method registers a listener function with the
|
|
1143
|
+
* Indexes object that will be called whenever a Slice is added to or removed
|
|
1144
|
+
* from an Index.
|
|
1145
|
+
*
|
|
1146
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
1147
|
+
*
|
|
1148
|
+
* ```ts override
|
|
1149
|
+
* addHasSliceListener(
|
|
1150
|
+
* indexId: IdOrNull,
|
|
1151
|
+
* sliceId: IdOrNull,
|
|
1152
|
+
* listener: HasSliceListener,
|
|
1153
|
+
* ): Id;
|
|
1154
|
+
* ```
|
|
1155
|
+
*
|
|
1156
|
+
* You can either listen to a single Slice (by specifying the Index Id and
|
|
1157
|
+
* Slice Id as the method's first two parameters), or changes to any Slice (by
|
|
1158
|
+
* providing `null` wildcards).
|
|
1159
|
+
*
|
|
1160
|
+
* Both, either, or neither of the `indexId` and `sliceId` parameters can be
|
|
1161
|
+
* wildcarded with `null`. You can listen to a specific Slice in a specific
|
|
1162
|
+
* Index, any Slice in a specific Index, a specific Slice in any Index, or any
|
|
1163
|
+
* Slice in any Index.
|
|
1164
|
+
*
|
|
1165
|
+
* The provided listener is a HasSliceListener function, and will be called
|
|
1166
|
+
* with a reference to the Indexes object, the Id of the Index, the Id of the
|
|
1167
|
+
* Slice that changed, and whether it now exists.
|
|
1168
|
+
* @param indexId The Id of the Index to listen to, or `null` as a wildcard.
|
|
1169
|
+
* @param sliceId The Id of the Slice to listen to, or `null` as a wildcard.
|
|
1170
|
+
* @param listener The function that will be called whenever the Slice is
|
|
1171
|
+
* added or removed.
|
|
1172
|
+
* @returns A unique Id for the listener that can later be used to remove it.
|
|
1173
|
+
* @category Listener
|
|
1174
|
+
* @since v9.1.0
|
|
1175
|
+
*/
|
|
1176
|
+
addHasSliceListener(
|
|
1177
|
+
indexId: IdOrNull,
|
|
1178
|
+
sliceId: IdOrNull,
|
|
1179
|
+
listener: HasSliceListener<Schemas>,
|
|
1180
|
+
): Id;
|
|
1181
|
+
|
|
1045
1182
|
/**
|
|
1046
1183
|
* The delListener method removes a listener that was previously added to the
|
|
1047
1184
|
* Indexes object.
|