@trust0/ridb-core 1.7.41 → 1.8.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.
@@ -1,43 +1,53 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @returns {boolean}
5
- */
6
- declare function is_debug_mode(): boolean;
7
- /**
8
4
  */
9
5
  declare function main_js(): void;
10
6
  /**
11
- * Handler for `console.info` invocations. See above.
12
- * @param {Array<any>} args
7
+ * @returns {boolean}
13
8
  */
14
- declare function __wbgtest_console_info(args: Array<any>): void;
9
+ declare function is_debug_mode(): boolean;
15
10
  /**
16
- * Handler for `console.warn` invocations. See above.
11
+ * Handler for `console.log` invocations.
12
+ *
13
+ * If a test is currently running it takes the `args` array and stringifies
14
+ * it and appends it to the current output of the test. Otherwise it passes
15
+ * the arguments to the original `console.log` function, psased as
16
+ * `original`.
17
17
  * @param {Array<any>} args
18
18
  */
19
- declare function __wbgtest_console_warn(args: Array<any>): void;
19
+ declare function __wbgtest_console_log(args: Array<any>): void;
20
20
  /**
21
21
  * Handler for `console.debug` invocations. See above.
22
22
  * @param {Array<any>} args
23
23
  */
24
24
  declare function __wbgtest_console_debug(args: Array<any>): void;
25
25
  /**
26
- * Handler for `console.log` invocations.
27
- *
28
- * If a test is currently running it takes the `args` array and stringifies
29
- * it and appends it to the current output of the test. Otherwise it passes
30
- * the arguments to the original `console.log` function, psased as
31
- * `original`.
26
+ * Handler for `console.info` invocations. See above.
32
27
  * @param {Array<any>} args
33
28
  */
34
- declare function __wbgtest_console_log(args: Array<any>): void;
29
+ declare function __wbgtest_console_info(args: Array<any>): void;
30
+ /**
31
+ * Handler for `console.warn` invocations. See above.
32
+ * @param {Array<any>} args
33
+ */
34
+ declare function __wbgtest_console_warn(args: Array<any>): void;
35
35
  /**
36
36
  * Handler for `console.error` invocations. See above.
37
37
  * @param {Array<any>} args
38
38
  */
39
39
  declare function __wbgtest_console_error(args: Array<any>): void;
40
40
  /**
41
+ */
42
+ declare enum Errors {
43
+ Error = 0,
44
+ HookError = 1,
45
+ QueryError = 2,
46
+ SerializationError = 3,
47
+ ValidationError = 4,
48
+ AuthenticationError = 5,
49
+ }
50
+ /**
41
51
  * Represents the type of operation to be performed on the collection.
42
52
  */
43
53
  declare enum OpType {
@@ -62,49 +72,26 @@ declare enum OpType {
62
72
  */
63
73
  COUNT = 4,
64
74
  }
65
- /**
66
- */
67
- declare enum Errors {
68
- Error = 0,
69
- HookError = 1,
70
- QueryError = 2,
71
- SerializationError = 3,
72
- ValidationError = 4,
73
- AuthenticationError = 5,
74
- }
75
-
76
- type Operators<T> = {
77
- $gte?: number,
78
- $gt?: number
79
- $lt?: number,
80
- $lte?: number,
81
- $eq?: T,
82
- $ne?: T
83
- };
84
-
85
- type InOperator<T> = { $in?: T[] };
86
- type NInOperator<T> = { $nin?: T[] };
87
75
 
88
- type OperatorOrType<T> = T extends number ?
89
- T | Operators<T> | InOperator<T> | NInOperator<T> :
90
- T | InOperator<T> | NInOperator<T>;
91
-
92
- type LogicalOperators<T extends SchemaType> = {
93
- $and?: Partial<QueryType<T>>[];
94
- $or?: Partial<QueryType<T>>[];
95
- };
76
+ /**
77
+ * Represents an in-memory storage system extending the base storage functionality.
78
+ *
79
+ * @template T - The schema type.
80
+ */
81
+ declare class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
82
+ /**
83
+ * Frees the resources used by the in-memory storage.
84
+ */
85
+ free(): void;
96
86
 
97
- type QueryType<T extends SchemaType> = ({
98
- [K in keyof T['properties']as ExtractType<T['properties'][K]['type']> extends undefined ? never : K]?: OperatorOrType<
99
- ExtractType<
100
- T['properties'][K]['type']
87
+ static create<SchemasCreate extends SchemaTypeRecord>(
88
+ dbName: string,
89
+ schemas: SchemasCreate,
90
+ ): Promise<
91
+ InMemory<
92
+ SchemasCreate
101
93
  >
102
- >
103
- } & LogicalOperators<T>) | LogicalOperators<T>[];
104
-
105
- declare class Query<T extends SchemaType> {
106
- constructor(query: QueryType<T>, schema:Schema<T>);
107
- readonly query: QueryType<T>;
94
+ >;
108
95
  }
109
96
 
110
97
 
@@ -138,6 +125,263 @@ declare const SchemaFieldType = {
138
125
 
139
126
 
140
127
 
128
+ type InternalsRecord = {
129
+ [name: string]: BaseStorage<SchemaTypeRecord>
130
+ };
131
+ /**
132
+ * ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
133
+ *
134
+ * @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
135
+ *
136
+ * @example
137
+ * type StringType = ExtractType<'string'>; // StringType is string
138
+ * type NumberType = ExtractType<'number'>; // NumberType is number
139
+ * type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
140
+ * type ObjectType = ExtractType<'object'>; // ObjectType is object
141
+ * type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
142
+ */
143
+ type ExtractType<T extends string> =
144
+ T extends "string" ? string :
145
+ T extends "number" ? number :
146
+ T extends "boolean" ? boolean :
147
+ T extends "object" ? object :
148
+ T extends "array" ? any[] :
149
+ undefined;
150
+
151
+ /**
152
+ * ExtractProperty maps a full Property definition to its document type. Unlike
153
+ * {@link ExtractType} (which only looks at the `type` string), it recurses into
154
+ * `items` for arrays and `properties` for objects, producing precise nested types.
155
+ *
156
+ * @example
157
+ * type Tags = ExtractProperty<{ type: "array"; items: { type: "string" } }>; // string[]
158
+ * type Obj = ExtractProperty<{ type: "object"; properties: { id: { type: "string" } } }>; // { id: string }
159
+ */
160
+ type ExtractProperty<P> =
161
+ P extends { type: "string" } ? string :
162
+ P extends { type: "number" } ? number :
163
+ P extends { type: "boolean" } ? boolean :
164
+ P extends { type: "array" } ? (P extends { items: infer I } ? ExtractProperty<I>[] : any[]) :
165
+ P extends { type: "object" } ? (P extends { properties: infer PR } ? ExtractObject<PR, NestedRequiredNames<P>> : object) :
166
+ unknown;
167
+
168
+ /**
169
+ * NestedRequiredNames extracts the union of nested property names listed in an object
170
+ * property's `required` array (JSON Schema semantics), or `never` when no array is
171
+ * present. Note it only matches the array form; a boolean `required` flag yields `never`.
172
+ */
173
+ type NestedRequiredNames<P> =
174
+ P extends { required: infer R }
175
+ ? (R extends readonly string[] ? R[number] : never)
176
+ : never;
177
+
178
+ /**
179
+ * FlagRequiredness interprets a property's `required` declaration when it is used as a
180
+ * legacy boolean flag. Because `Property.required` is typed `boolean | string[]`, a
181
+ * schema literal written without `as const` widens `true`/`false` to `boolean`; the
182
+ * tuple-wrapped checks below classify each case:
183
+ * - a literal `false` -> `"optional"`;
184
+ * - a literal `true`, or a widened `boolean` (whose literal was lost) -> `"required"`.
185
+ * Treating the ambiguous `boolean` as required matches the Rust validator and turns a
186
+ * would-be runtime "missing required property" error into a compile-time one instead;
187
+ * - the array form, or no `required` key -> `"defer"` to the container `required` array.
188
+ */
189
+ type FlagRequiredness<P> =
190
+ P extends { required: infer F }
191
+ ? ([F] extends [readonly string[]] ? "defer"
192
+ : [F] extends [false] ? "optional"
193
+ : [true] extends [F] ? "required"
194
+ : "defer")
195
+ : "defer";
196
+
197
+ /**
198
+ * IsNestedOptional decides whether a nested property `K` (within an object property's
199
+ * `properties` map `PR`, given that object's required-name union `R`) may be omitted.
200
+ * Precedence mirrors the runtime validator and {@link IsCreateOptional}:
201
+ * 1. a declared `default` makes the field optional;
202
+ * 2. a boolean `required` flag wins (`false` -> optional, `true`/`boolean` -> required);
203
+ * 3. otherwise it is required iff listed in the object's `required` array;
204
+ * 4. otherwise it is optional.
205
+ */
206
+ type IsNestedOptional<PR, K extends keyof PR, R> =
207
+ PR[K] extends { default: unknown } ? true
208
+ : FlagRequiredness<PR[K]> extends "optional" ? true
209
+ : FlagRequiredness<PR[K]> extends "required" ? false
210
+ : K extends R ? false
211
+ : true;
212
+
213
+ /**
214
+ * ExtractObject builds an object document type from a `properties` map `PR` and the
215
+ * owning object's required-name union `R`, applying the correct optional/required
216
+ * modifier to each nested property (see {@link IsNestedOptional}). This keeps `Doc` and
217
+ * `CreateDoc` in step with the runtime validator, which only enforces nested keys named
218
+ * in that object's `required` array.
219
+ */
220
+ type ExtractObject<PR, R> = {
221
+ [K in keyof PR as IsNestedOptional<PR, K, R> extends true ? never : K]:
222
+ ExtractProperty<PR[K]>
223
+ } & {
224
+ [K in keyof PR as IsNestedOptional<PR, K, R> extends true ? K : never]?:
225
+ ExtractProperty<PR[K]>
226
+ };
227
+
228
+ /**
229
+ * The union of property names marked required at the schema level (JSON Schema
230
+ * `required` array). Resolves to `never` when no `required` array is present.
231
+ */
232
+ type RequiredFieldNames<T extends SchemaType> =
233
+ T extends { required: infer R }
234
+ ? (R extends readonly string[] ? R[number] : never)
235
+ : never;
236
+
237
+ /**
238
+ * IsCreateOptional decides whether a property may be omitted when creating a document.
239
+ * Precedence (mirrors the runtime validator):
240
+ * 1. a declared `default` makes the field optional;
241
+ * 2. a boolean `required` flag wins (`false` -> optional, `true`/`boolean` -> required;
242
+ * see {@link FlagRequiredness});
243
+ * 3. otherwise it is required iff listed in the schema-level `required` array;
244
+ * 4. otherwise it is optional.
245
+ */
246
+ type IsCreateOptional<T extends SchemaType, K extends keyof T["properties"]> =
247
+ T["properties"][K] extends { default: unknown } ? true
248
+ : FlagRequiredness<T["properties"][K]> extends "optional" ? true
249
+ : FlagRequiredness<T["properties"][K]> extends "required" ? false
250
+ : K extends RequiredFieldNames<T> ? false
251
+ : true;
252
+
253
+ /**
254
+ * Doc is a utility type that transforms a schema type into a stored-document type. A
255
+ * property is mandatory only when the validator guarantees its presence; properties that
256
+ * are optional at creation (not listed in `required`, flagged `required: false`, or
257
+ * carrying a `default`) may be absent on a stored document, so they are optional here
258
+ * too. This keeps `find`/`findById`/`create` return types from claiming keys that may not
259
+ * exist. Optionality uses the same {@link IsCreateOptional} rules as {@link CreateDoc}.
260
+ *
261
+ * @template T - A schema type with a 'properties' field where each property's type is represented as a string.
262
+ *
263
+ * type Document = Doc<Schema>; // Document is { name: string; age: number; }
264
+ */
265
+ type Doc<T extends SchemaType> = {
266
+ [K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? never : K]:
267
+ ExtractProperty<T['properties'][K]>
268
+ } & {
269
+ [K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? K : never]?:
270
+ ExtractProperty<T['properties'][K]>
271
+ } & {
272
+ __version?: number;
273
+ /**
274
+ * Unix timestamp (in seconds) set automatically when the document is created.
275
+ * Managed internally by RIDB — it cannot be set or changed by the caller.
276
+ */
277
+ createdAt: number;
278
+ /**
279
+ * Unix timestamp (in seconds) refreshed automatically on every create/update.
280
+ * Managed internally by RIDB — it cannot be set or changed by the caller.
281
+ */
282
+ updatedAt: number;
283
+ };
284
+
285
+ /**
286
+ * CreateDoc is a utility type for document creation that properly handles required vs optional fields
287
+ * during the creation process. Fields with default values, or fields not listed in the schema-level
288
+ * `required` array, become optional.
289
+ *
290
+ * @template T - A schema type with a 'properties' field where each property's type is represented as a string.
291
+ */
292
+ type CreateDoc<T extends SchemaType> = {
293
+ [K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? K : never]?:
294
+ ExtractProperty<T['properties'][K]>
295
+ } & {
296
+ [K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? never : K]:
297
+ ExtractProperty<T['properties'][K]>
298
+ } & {
299
+ __version?: number;
300
+ };
301
+
302
+ /**
303
+ * UpdateDoc is the accepted input shape for `Collection.update`. It is a partial
304
+ * document keyed by the schema properties. The internally-managed timestamp fields
305
+ * (`createdAt`/`updatedAt`) are intentionally excluded — they are set and refreshed
306
+ * by RIDB and cannot be provided by the caller.
307
+ */
308
+ type UpdateDoc<T extends SchemaType> = Partial<Omit<Doc<T>, "createdAt" | "updatedAt">>;
309
+
310
+ /**
311
+ * The direction used when sorting query results by a given field.
312
+ */
313
+ type SortDirection = 'asc' | 'desc';
314
+
315
+ /**
316
+ * A single sort instruction: which field to sort by and in which direction.
317
+ * `field` is constrained to the schema's property names, and `direction`
318
+ * defaults to `'asc'` when omitted.
319
+ */
320
+ type SortSpec<T extends SchemaType = SchemaType> = {
321
+ field: (keyof T['properties'] & string) | 'createdAt' | 'updatedAt';
322
+ direction?: SortDirection;
323
+ };
324
+
325
+ type QueryOptions<T extends SchemaType = SchemaType> = {
326
+ limit?: number;
327
+ offset?: number;
328
+ /**
329
+ * Sorts the results by one or more fields. Accepts a single sort specification
330
+ * or an array of them (applied in order, the first field being the primary sort key).
331
+ */
332
+ sort?: SortSpec<T> | SortSpec<T>[];
333
+ }
334
+
335
+ /**
336
+ * Collection is a class that represents a collection of documents in a database.
337
+ * @template T - A schema type defining the structure of the documents in the collection.
338
+ */
339
+ declare class Collection<T extends SchemaType> {
340
+ /**
341
+ * Finds all documents in the collection.
342
+ *
343
+ * @returns A promise that resolves to an array of documents.
344
+ */
345
+ find(query: QueryType<T>, options?: QueryOptions<T>): Promise<Doc<T>[]>;
346
+ /**
347
+ * count all documents in the collection.
348
+ *
349
+ * @returns A promise that resolves to an array of documents.
350
+ */
351
+ count(query: QueryType<T>, options?: QueryOptions<T>): Promise<number>;
352
+ /**
353
+ * Finds a single document in the collection by its ID.
354
+ *
355
+ * @param id - The ID of the document to find.
356
+ * @returns A promise that resolves to the found document.
357
+ */
358
+ findById(id: string): Promise<Doc<T>>;
359
+ /**
360
+ * Updates a document in the collection by its ID.
361
+ *
362
+ * @param document - A partial document containing the fields to update.
363
+ * @returns A promise that resolves when the update is complete.
364
+ */
365
+ update(document: UpdateDoc<T>): Promise<void>;
366
+ /**
367
+ * Creates a new document in the collection.
368
+ *
369
+ * @param document - The document to create.
370
+ * @returns A promise that resolves to the created document.
371
+ */
372
+ create(document: CreateDoc<T>): Promise<Doc<T>>;
373
+ /**
374
+ * Deletes a document in the collection by its ID.
375
+ *
376
+ * @param id - The ID of the document to delete.
377
+ * @returns A promise that resolves when the deletion is complete.
378
+ */
379
+ delete(id: string): Promise<void>;
380
+ }
381
+
382
+
383
+
384
+
141
385
  /**
142
386
  * Represents the type definition for a schema.
143
387
  */
@@ -158,6 +402,11 @@ type SchemaType = {
158
402
  type: SchemaFieldType;
159
403
  indexes?: string[];
160
404
  encrypted?: string[];
405
+ /**
406
+ * The names of the required top-level properties. Follows JSON Schema
407
+ * semantics: only the listed properties are required.
408
+ */
409
+ required?: string[];
161
410
  /**
162
411
  * The properties defined in the schema.
163
412
  */
@@ -230,10 +479,13 @@ declare class Schema<T extends SchemaType> {
230
479
  * The properties defined in the schema.
231
480
  */
232
481
  readonly properties: {
233
- [K in keyof T['properties'] as T['properties'][K]['required'] extends false | (T['properties'][K]['default'] extends undefined ? true: false) ? K : never]?: T['properties'][K];
234
- } & {
235
- [K in keyof T['properties'] as T['properties'][K]['required'] extends false ? never : K]: T['properties'][K];
482
+ [K in keyof T['properties']]: T['properties'][K];
236
483
  };
484
+
485
+ /**
486
+ * The names of the required top-level properties.
487
+ */
488
+ readonly required?: (Extract<keyof T['properties'], string>)[];
237
489
  /**
238
490
  * Converts the schema to a JSON representation.
239
491
  *
@@ -241,57 +493,76 @@ declare class Schema<T extends SchemaType> {
241
493
  */
242
494
  toJSON(): SchemaType;
243
495
 
244
- validate(document: Doc<Schema<T>>): boolean;
245
- }
246
-
247
-
248
-
249
- declare class CoreStorage {
250
496
  /**
251
- * @param {any} document
252
- * @param {Query} query
253
- * @returns {boolean}
254
- */
255
- matchesQuery(document: any, query: Query<any>): boolean;
256
- getPrimaryKeyTyped(value: any): string | number;
257
- getIndexes(schema: Schema<any>, op: Operation): string[];
497
+ * Validates a document against the schema. The runtime applies the same
498
+ * optional/required rules as creation (only `required` fields, without a `default`,
499
+ * must be present), so the accepted shape is `CreateDoc<T>` rather than a fully-keyed
500
+ * `Doc<T>`.
501
+ */
502
+ validate(document: CreateDoc<T>): boolean;
258
503
  }
259
504
 
260
505
 
261
506
 
262
- type BaseStorageOptions = {
263
- [name:string]:string | boolean | number
264
- }
265
-
266
- declare class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInternal<Schemas> {
267
- static create<SchemasCreate extends SchemaTypeRecord>(
268
- dbName: string,
269
- schemas: SchemasCreate,
270
- options?: BaseStorageOptions
271
- ): Promise<
272
- BaseStorage<
273
- SchemasCreate
507
+ type Operators<T> = {
508
+ $gte?: number,
509
+ $gt?: number
510
+ $lt?: number,
511
+ $lte?: number,
512
+ $eq?: T,
513
+ $ne?: T
514
+ };
515
+
516
+ type InOperator<T> = { $in?: T[] };
517
+ type NInOperator<T> = { $nin?: T[] };
518
+
519
+ type OperatorOrType<T> = T extends number ?
520
+ T | Operators<T> | InOperator<T> | NInOperator<T> :
521
+ T | InOperator<T> | NInOperator<T>;
522
+
523
+ type LogicalOperators<T extends SchemaType> = {
524
+ $and?: Partial<QueryType<T>>[];
525
+ $or?: Partial<QueryType<T>>[];
526
+ };
527
+
528
+ /**
529
+ * The internally-managed timestamp fields available for querying on every collection.
530
+ * They cannot be written by the caller but can be filtered (and sorted) like numbers.
531
+ */
532
+ type ManagedTimestampsQuery = {
533
+ createdAt?: OperatorOrType<number>;
534
+ updatedAt?: OperatorOrType<number>;
535
+ };
536
+
537
+ type QueryType<T extends SchemaType> = ({
538
+ [K in keyof T['properties']as ExtractType<T['properties'][K]['type']> extends undefined ? never : K]?: OperatorOrType<
539
+ ExtractType<
540
+ T['properties'][K]['type']
274
541
  >
275
- >;
276
- constructor(
277
- dbName: string,
278
- schemas: Schemas,
279
- options?: BaseStorageOptions
280
- );
281
- readonly dbName: string;
282
- readonly schemas: Record<keyof Schemas, Schema<Schemas[keyof Schemas]>>;
283
- readonly options: BaseStorageOptions;
284
- readonly core: CoreStorage;
285
- start(): Promise<void>;
286
- close(): Promise<void>;
287
- count(colectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<number>;
288
- findDocumentById(collectionName: keyof Schemas, id: string): Promise<Doc<Schemas[keyof Schemas]> | null>;
289
- find(collectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<Doc<Schemas[keyof Schemas]>[]>;
290
- write(op: Operation<Schemas[keyof Schemas]>): Promise<Doc<Schemas[keyof Schemas]>>;
291
- getOption(name: string): string | boolean | number | undefined;
292
- getSchema(name: string): Schema<any>;
293
- //Call addIndexSchemas if you need extra indexing schemas for your database
294
- addIndexSchemas(): null
542
+ >
543
+ } & ManagedTimestampsQuery & LogicalOperators<T>) | LogicalOperators<T>[];
544
+
545
+ declare class Query<T extends SchemaType> {
546
+ constructor(query: QueryType<T>, schema:Schema<T>);
547
+ readonly query: QueryType<T>;
548
+ }
549
+
550
+
551
+
552
+ type Hook = (
553
+ schema: Schema<SchemaType>,
554
+ migration: MigrationPathsForSchema<SchemaType>,
555
+ doc: Doc<SchemaType>
556
+ ) => Doc<SchemaType>
557
+
558
+ type BasePluginOptions = {
559
+ docCreateHook?: Hook,
560
+ docRecoverHook?: Hook
561
+ }
562
+
563
+ declare class BasePlugin implements BasePluginOptions {
564
+ docCreateHook?:Hook;
565
+ docRecoverHook?:Hook;
295
566
  }
296
567
 
297
568
 
@@ -400,66 +671,39 @@ type RIDBModule = {
400
671
 
401
672
 
402
673
 
403
- /**
404
- * Represents a property within a schema, including various constraints and nested properties.
405
- */
406
- declare class Property {
407
- /**
408
- * The type of the property.
409
- */
410
- readonly type: SchemaFieldType;
411
-
412
- /**
413
- * The version of the property, if applicable.
414
- */
415
- readonly version?: number;
416
-
417
- /**
418
- * The primary key of the property, if applicable.
419
- */
420
- readonly primaryKey?: string;
421
-
422
- /**
423
- * An optional array of nested properties for array-type properties.
424
- */
425
- readonly items?: Property;
426
-
427
- /**
428
- * The maximum number of items for array-type properties, if applicable.
429
- */
430
- readonly maxItems?: number;
431
-
432
- /**
433
- * The minimum number of items for array-type properties, if applicable.
434
- */
435
- readonly minItems?: number;
436
-
437
- /**
438
- * The maximum length for string-type properties, if applicable.
439
- */
440
- readonly maxLength?: number;
441
-
442
- /**
443
- * The minimum length for string-type properties, if applicable.
444
- */
445
- readonly minLength?: number;
446
-
447
- /**
448
- * An optional array of required fields for object-type properties.
449
- */
450
- readonly required?: boolean;
451
-
452
- /**
453
- * An optional default value for the property.
454
- */
455
- readonly default?: any;
674
+ type BaseStorageOptions = {
675
+ [name:string]:string | boolean | number
676
+ }
456
677
 
457
- /**
458
- * An optional map of nested properties for object-type properties.
459
- */
460
- readonly properties?: {
461
- [name: string]: Property;
462
- };
678
+ declare class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInternal<Schemas> {
679
+ static create<SchemasCreate extends SchemaTypeRecord>(
680
+ dbName: string,
681
+ schemas: SchemasCreate,
682
+ options?: BaseStorageOptions
683
+ ): Promise<
684
+ BaseStorage<
685
+ SchemasCreate
686
+ >
687
+ >;
688
+ constructor(
689
+ dbName: string,
690
+ schemas: Schemas,
691
+ options?: BaseStorageOptions
692
+ );
693
+ readonly dbName: string;
694
+ readonly schemas: Record<keyof Schemas, Schema<Schemas[keyof Schemas]>>;
695
+ readonly options: BaseStorageOptions;
696
+ readonly core: CoreStorage;
697
+ start(): Promise<void>;
698
+ close(): Promise<void>;
699
+ count(colectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions<Schemas[keyof Schemas]>): Promise<number>;
700
+ findDocumentById(collectionName: keyof Schemas, id: string): Promise<Doc<Schemas[keyof Schemas]> | null>;
701
+ find(collectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions<Schemas[keyof Schemas]>): Promise<Doc<Schemas[keyof Schemas]>[]>;
702
+ write(op: Operation<Schemas[keyof Schemas]>): Promise<Doc<Schemas[keyof Schemas]>>;
703
+ getOption(name: string): string | boolean | number | undefined;
704
+ getSchema(name: string): Schema<any>;
705
+ //Call addIndexSchemas if you need extra indexing schemas for your database
706
+ addIndexSchemas(): null
463
707
  }
464
708
 
465
709
 
@@ -485,217 +729,30 @@ type AnyVersionGreaterThan1<
485
729
  [K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
486
730
  } [keyof T] ? true : false;
487
731
 
488
- type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
489
-
490
- type MigrationPathsForSchema<
491
- T extends SchemaType
492
- > = T['version'] extends 0 ? {}: // No migrations needed for version 1
493
- {
494
- [K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
495
- };
496
-
497
- type MigrationPathsForSchemas<
498
- T extends SchemaTypeRecord
499
- > = {
500
- [K in keyof T]: MigrationPathsForSchema<T[K]>;
501
- };
502
-
503
- type MigrationsParameter<
504
- T extends SchemaTypeRecord
505
- > = AnyVersionGreaterThan1<T> extends true ?
506
- {
507
- migrations: MigrationPathsForSchemas<T>
508
- }:
509
- {
510
- migrations?: never
511
- };
512
-
513
-
514
-
515
- type Hook = (
516
- schema: Schema<SchemaType>,
517
- migration: MigrationPathsForSchema<SchemaType>,
518
- doc: Doc<SchemaType>
519
- ) => Doc<SchemaType>
520
-
521
- type BasePluginOptions = {
522
- docCreateHook?: Hook,
523
- docRecoverHook?: Hook
524
- }
525
-
526
- declare class BasePlugin implements BasePluginOptions {
527
- docCreateHook?:Hook;
528
- docRecoverHook?:Hook;
529
- }
530
-
531
-
532
-
533
- type InternalsRecord = {
534
- [name: string]: BaseStorage<SchemaTypeRecord>
535
- };
536
- /**
537
- * ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
538
- *
539
- * @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
540
- *
541
- * @example
542
- * type StringType = ExtractType<'string'>; // StringType is string
543
- * type NumberType = ExtractType<'number'>; // NumberType is number
544
- * type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
545
- * type ObjectType = ExtractType<'object'>; // ObjectType is object
546
- * type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
547
- */
548
- type ExtractType<T extends string> =
549
- T extends "string" ? string :
550
- T extends "number" ? number :
551
- T extends "boolean" ? boolean :
552
- T extends "object" ? object :
553
- T extends "array" ? any[] :
554
- undefined;
555
-
556
- type IsOptional<T> =
557
- T extends { required: true }
558
- ? T extends { default: never }
559
- ? false
560
- : true
561
- : true;
562
-
563
- /**
564
- * Doc is a utility type that transforms a schema type into a document type where each property is mapped to its extracted type.
565
- *
566
- * @template T - A schema type with a 'properties' field where each property's type is represented as a string.
567
- *
568
- * type Document = Doc<Schema>; // Document is { name: string; age: number; }
569
- */
570
- type Doc<T extends SchemaType> = {
571
- [K in keyof T["properties"]]:
572
- ExtractType<T['properties'][K]['type']>
573
- } & {
574
- __version?: number;
575
- createdAt?: number;
576
- updatedAt?: number;
577
- };
578
-
579
- /**
580
- * CreateDoc is a utility type for document creation that properly handles required vs optional fields
581
- * during the creation process. Fields with default values or required: false become optional.
582
- *
583
- * @template T - A schema type with a 'properties' field where each property's type is represented as a string.
584
- */
585
- type CreateDoc<T extends SchemaType> = {
586
- [K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? K : never]?:
587
- ExtractType<T['properties'][K]['type']>
588
- } & {
589
- [K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? never : K]:
590
- ExtractType<T['properties'][K]['type']>
591
- } & {
592
- __version?: number;
593
- createdAt?: number;
594
- updatedAt?: number;
595
- };
596
-
597
- type QueryOptions = {
598
- limit?: number;
599
- offset?: number;
600
- }
601
-
602
- /**
603
- * Collection is a class that represents a collection of documents in a database.
604
- * @template T - A schema type defining the structure of the documents in the collection.
605
- */
606
- declare class Collection<T extends SchemaType> {
607
- /**
608
- * Finds all documents in the collection.
609
- *
610
- * @returns A promise that resolves to an array of documents.
611
- */
612
- find(query: QueryType<T>, options?: QueryOptions): Promise<Doc<T>[]>;
613
- /**
614
- * count all documents in the collection.
615
- *
616
- * @returns A promise that resolves to an array of documents.
617
- */
618
- count(query: QueryType<T>, options?: QueryOptions): Promise<number>;
619
- /**
620
- * Finds a single document in the collection by its ID.
621
- *
622
- * @param id - The ID of the document to find.
623
- * @returns A promise that resolves to the found document.
624
- */
625
- findById(id: string): Promise<Doc<T>>;
626
- /**
627
- * Updates a document in the collection by its ID.
628
- *
629
- * @param document - A partial document containing the fields to update.
630
- * @returns A promise that resolves when the update is complete.
631
- */
632
- update(document: Partial<Doc<T>>): Promise<void>;
633
- /**
634
- * Creates a new document in the collection.
635
- *
636
- * @param document - The document to create.
637
- * @returns A promise that resolves to the created document.
638
- */
639
- create(document: CreateDoc<T>): Promise<Doc<T>>;
640
- /**
641
- * Deletes a document in the collection by its ID.
642
- *
643
- * @param id - The ID of the document to delete.
644
- * @returns A promise that resolves when the deletion is complete.
645
- */
646
- delete(id: string): Promise<void>;
647
- }
648
-
649
-
650
-
651
-
652
- /**
653
- * Represents an in-memory storage system extending the base storage functionality.
654
- *
655
- * @template T - The schema type.
656
- */
657
- declare class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
658
- /**
659
- * Frees the resources used by the in-memory storage.
660
- */
661
- free(): void;
662
-
663
- static create<SchemasCreate extends SchemaTypeRecord>(
664
- dbName: string,
665
- schemas: SchemasCreate,
666
- ): Promise<
667
- InMemory<
668
- SchemasCreate
669
- >
670
- >;
671
- }
672
-
673
-
674
-
675
- /**
676
- * Represents an operation to be performed on a collection.
677
- *
678
- * @template T - The schema type of the collection.
679
- */
680
- type Operation<T extends SchemaType = SchemaType> = {
681
- /**
682
- * The name of the collection on which the operation will be performed.
683
- */
684
- collection: string,
685
-
686
- /**
687
- * The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
688
- */
689
- opType: OpType,
690
-
691
- /**
692
- * The data involved in the operation, conforming to the schema type.
693
- */
694
- data: Doc<T>,
732
+ type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
695
733
 
696
- primaryKeyField?: string,
697
- primaryKey?: string
698
- }
734
+ type MigrationPathsForSchema<
735
+ T extends SchemaType
736
+ > = T['version'] extends 0 ? {}: // No migrations needed for version 1
737
+ {
738
+ [K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
739
+ };
740
+
741
+ type MigrationPathsForSchemas<
742
+ T extends SchemaTypeRecord
743
+ > = {
744
+ [K in keyof T]: MigrationPathsForSchema<T[K]>;
745
+ };
746
+
747
+ type MigrationsParameter<
748
+ T extends SchemaTypeRecord
749
+ > = AnyVersionGreaterThan1<T> extends true ?
750
+ {
751
+ migrations: MigrationPathsForSchemas<T>
752
+ }:
753
+ {
754
+ migrations?: never
755
+ };
699
756
 
700
757
 
701
758
 
@@ -717,7 +774,7 @@ declare abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
717
774
  abstract count(
718
775
  colectionName: keyof Schemas,
719
776
  query: QueryType<Schemas[keyof Schemas]>,
720
- options?: QueryOptions
777
+ options?: QueryOptions<Schemas[keyof Schemas]>
721
778
  ): Promise<number>;
722
779
  abstract findDocumentById(
723
780
  collectionName: keyof Schemas,
@@ -726,7 +783,7 @@ declare abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
726
783
  abstract find(
727
784
  collectionName: keyof Schemas,
728
785
  query: QueryType<Schemas[keyof Schemas]>,
729
- options?: QueryOptions
786
+ options?: QueryOptions<Schemas[keyof Schemas]>
730
787
  ): Promise<Doc<Schemas[keyof Schemas]>[]>;
731
788
  abstract write(
732
789
  op: Operation<Schemas[keyof Schemas]>
@@ -734,6 +791,74 @@ declare abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
734
791
  }
735
792
 
736
793
 
794
+ /**
795
+ * Represents a property within a schema, including various constraints and nested properties.
796
+ */
797
+ declare class Property {
798
+ /**
799
+ * The type of the property.
800
+ */
801
+ readonly type: SchemaFieldType;
802
+
803
+ /**
804
+ * The version of the property, if applicable.
805
+ */
806
+ readonly version?: number;
807
+
808
+ /**
809
+ * The primary key of the property, if applicable.
810
+ */
811
+ readonly primaryKey?: string;
812
+
813
+ /**
814
+ * An optional array of nested properties for array-type properties.
815
+ */
816
+ readonly items?: Property;
817
+
818
+ /**
819
+ * The maximum number of items for array-type properties, if applicable.
820
+ */
821
+ readonly maxItems?: number;
822
+
823
+ /**
824
+ * The minimum number of items for array-type properties, if applicable.
825
+ */
826
+ readonly minItems?: number;
827
+
828
+ /**
829
+ * The maximum length for string-type properties, if applicable.
830
+ */
831
+ readonly maxLength?: number;
832
+
833
+ /**
834
+ * The minimum length for string-type properties, if applicable.
835
+ */
836
+ readonly minLength?: number;
837
+
838
+ /**
839
+ * Controls requiredness. Two forms are supported and interoperate:
840
+ * - `boolean`: a per-property flag (legacy). `false` forces the property optional,
841
+ * `true` forces it required, overriding any container-level `required` array.
842
+ * - `string[]`: for object-type properties, the JSON Schema list of required
843
+ * nested properties.
844
+ */
845
+ readonly required?: boolean | string[];
846
+
847
+ /**
848
+ * An optional default value for the property.
849
+ */
850
+ readonly default?: any;
851
+
852
+ /**
853
+ * An optional map of nested properties for object-type properties.
854
+ */
855
+ readonly properties?: {
856
+ [name: string]: Property;
857
+ };
858
+ }
859
+
860
+
861
+
737
862
  /**
738
863
  * Represents an IndexDB storage system extending the base storage functionality.
739
864
  *
@@ -756,6 +881,52 @@ declare class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
756
881
  }
757
882
 
758
883
 
884
+
885
+ /**
886
+ * Represents an operation to be performed on a collection.
887
+ *
888
+ * @template T - The schema type of the collection.
889
+ */
890
+ type Operation<T extends SchemaType = SchemaType> = {
891
+ /**
892
+ * The name of the collection on which the operation will be performed.
893
+ */
894
+ collection: string,
895
+
896
+ /**
897
+ * The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
898
+ */
899
+ opType: OpType,
900
+
901
+ /**
902
+ * The data involved in the operation, conforming to the schema type.
903
+ */
904
+ data: Doc<T>,
905
+
906
+ primaryKeyField?: string,
907
+ primaryKey?: string
908
+ }
909
+
910
+
911
+
912
+ declare class CoreStorage {
913
+ /**
914
+ * @param {any} document
915
+ * @param {Query} query
916
+ * @returns {boolean}
917
+ */
918
+ matchesQuery(document: any, query: Query<any>): boolean;
919
+ getPrimaryKeyTyped(value: any): string | number;
920
+ getIndexes(schema: Schema<any>, op: Operation): string[];
921
+ /**
922
+ * Sorts a list of documents according to the provided sort specification, using the
923
+ * same comparison semantics as the built-in storages. Intended for custom storage
924
+ * adapters that cannot rely on a native sort. Returns a new sorted array.
925
+ */
926
+ sortDocuments(documents: any[], sort: SortSpec[]): any[];
927
+ }
928
+
929
+
759
930
  /**
760
931
  */
761
932
  declare class RIDBError {
@@ -867,66 +1038,96 @@ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Modul
867
1038
 
868
1039
  interface InitOutput {
869
1040
  readonly memory: WebAssembly.Memory;
870
- readonly __wbg_query_free: (a: number) => void;
871
- readonly __wbgt_test_get_properties_array_values_10: (a: number) => void;
872
- readonly __wbgt_test_get_properties_deeply_nested_12: (a: number) => void;
873
- readonly __wbgt_test_get_properties_empty_query_11: (a: number) => void;
874
- readonly __wbgt_test_get_properties_nested_operators_9: (a: number) => void;
875
- readonly __wbgt_test_get_properties_simple_fields_6: (a: number) => void;
876
- readonly __wbgt_test_get_properties_with_array_at_top_level_14: (a: number) => void;
877
- readonly __wbgt_test_get_properties_with_logical_operators_8: (a: number) => void;
878
- readonly __wbgt_test_get_properties_with_multiple_same_props_13: (a: number) => void;
879
- readonly __wbgt_test_get_properties_with_operators_7: (a: number) => void;
880
- readonly __wbgt_test_query_get_query_normalization_complex_mixed_22: (a: number) => void;
881
- readonly __wbgt_test_query_get_query_normalization_nested_logical_operators_20: (a: number) => void;
882
- readonly __wbgt_test_query_get_query_normalization_only_logical_operator_21: (a: number) => void;
883
- readonly __wbgt_test_query_get_query_normalization_simple_attributes_18: (a: number) => void;
884
- readonly __wbgt_test_query_get_query_normalization_with_logical_operator_19: (a: number) => void;
885
- readonly __wbgt_test_query_parse_age_query_24: (a: number) => void;
886
- readonly __wbgt_test_query_parse_empty_logical_operators_28: (a: number) => void;
887
- readonly __wbgt_test_query_parse_empty_query_23: (a: number) => void;
888
- readonly __wbgt_test_query_parse_eq_operator_31: (a: number) => void;
889
- readonly __wbgt_test_query_parse_eq_operator_wrong_type_32: (a: number) => void;
890
- readonly __wbgt_test_query_parse_in_operator_16: (a: number) => void;
891
- readonly __wbgt_test_query_parse_in_operator_wrong_type_17: (a: number) => void;
892
- readonly __wbgt_test_query_parse_invalid_in_operator_27: (a: number) => void;
893
- readonly __wbgt_test_query_parse_multiple_operators_26: (a: number) => void;
894
- readonly __wbgt_test_query_parse_ne_operator_33: (a: number) => void;
895
- readonly __wbgt_test_query_parse_ne_operator_wrong_type_34: (a: number) => void;
896
- readonly __wbgt_test_query_parse_nin_operator_29: (a: number) => void;
897
- readonly __wbgt_test_query_parse_nin_operator_wrong_type_30: (a: number) => void;
898
- readonly __wbgt_test_query_parse_non_object_query_25: (a: number) => void;
899
- readonly __wbgt_test_query_parse_operator_wrong_type_15: (a: number) => void;
900
- readonly query_get: (a: number, b: number, c: number, d: number) => void;
901
- readonly query_get_properties: (a: number, b: number) => void;
902
- readonly query_has_or_operator: (a: number) => number;
903
- readonly query_new: (a: number, b: number, c: number) => void;
904
- readonly query_parse: (a: number, b: number) => void;
905
- readonly query_process_query: (a: number, b: number, c: number) => void;
906
- readonly query_query: (a: number, b: number) => void;
907
- readonly __wbg_queryoptions_free: (a: number) => void;
1041
+ readonly __wbg_inmemory_free: (a: number) => void;
1042
+ readonly inmemory_close: (a: number) => number;
1043
+ readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
1044
+ readonly inmemory_create: (a: number, b: number, c: number) => number;
1045
+ readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
1046
+ readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
1047
+ readonly inmemory_start: (a: number) => number;
1048
+ readonly inmemory_write: (a: number, b: number) => number;
1049
+ readonly __wbg_collection_free: (a: number) => void;
908
1050
  readonly __wbg_schema_free: (a: number) => void;
909
1051
  readonly __wbgt_test_invalid_schema_5: (a: number) => void;
910
1052
  readonly __wbgt_test_schema_creation_3: (a: number) => void;
1053
+ readonly __wbgt_test_schema_required_subset_of_properties_6: (a: number) => void;
911
1054
  readonly __wbgt_test_schema_validation_4: (a: number) => void;
912
- readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
913
- readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
914
- readonly corestorage_matchesQuery: (a: number, b: number, c: number, d: number) => void;
915
- readonly queryoptions_limit: (a: number, b: number) => void;
916
- readonly queryoptions_offset: (a: number, b: number) => void;
1055
+ readonly __wbgt_test_validate_document_default_makes_required_optional_15: (a: number) => void;
1056
+ readonly __wbgt_test_validate_document_flag_overrides_array_12: (a: number) => void;
1057
+ readonly __wbgt_test_validate_document_legacy_required_false_11: (a: number) => void;
1058
+ readonly __wbgt_test_validate_document_nested_required_13: (a: number) => void;
1059
+ readonly __wbgt_test_validate_document_no_array_all_optional_9: (a: number) => void;
1060
+ readonly __wbgt_test_validate_document_null_is_type_checked_14: (a: number) => void;
1061
+ readonly __wbgt_test_validate_document_omitted_nested_required_equals_empty_10: (a: number) => void;
1062
+ readonly __wbgt_test_validate_document_required_missing_8: (a: number) => void;
1063
+ readonly __wbgt_test_validate_document_required_present_7: (a: number) => void;
1064
+ readonly collection_count: (a: number, b: number, c: number) => number;
1065
+ readonly collection_create: (a: number, b: number) => number;
1066
+ readonly collection_delete: (a: number, b: number) => number;
1067
+ readonly collection_find: (a: number, b: number, c: number) => number;
1068
+ readonly collection_findById: (a: number, b: number) => number;
1069
+ readonly collection_name: (a: number, b: number) => void;
1070
+ readonly collection_parse_query_options: (a: number, b: number, c: number) => void;
1071
+ readonly collection_schema: (a: number, b: number) => void;
1072
+ readonly collection_update: (a: number, b: number) => number;
1073
+ readonly is_debug_mode: () => number;
1074
+ readonly main_js: () => void;
917
1075
  readonly schema_create: (a: number, b: number) => void;
918
1076
  readonly schema_encrypted: (a: number, b: number) => void;
919
1077
  readonly schema_indexes: (a: number, b: number) => void;
920
1078
  readonly schema_is_valid: (a: number, b: number) => void;
921
1079
  readonly schema_primaryKey: (a: number, b: number) => void;
922
1080
  readonly schema_properties: (a: number, b: number) => void;
1081
+ readonly schema_required: (a: number, b: number) => void;
923
1082
  readonly schema_type: (a: number, b: number) => void;
924
1083
  readonly schema_validate: (a: number, b: number, c: number) => void;
925
1084
  readonly schema_version: (a: number) => number;
926
- readonly corestorage_new: () => number;
927
- readonly __wbg_corestorage_free: (a: number) => void;
1085
+ readonly __wbg_query_free: (a: number) => void;
1086
+ readonly __wbgt_test_get_properties_array_values_20: (a: number) => void;
1087
+ readonly __wbgt_test_get_properties_deeply_nested_22: (a: number) => void;
1088
+ readonly __wbgt_test_get_properties_empty_query_21: (a: number) => void;
1089
+ readonly __wbgt_test_get_properties_nested_operators_19: (a: number) => void;
1090
+ readonly __wbgt_test_get_properties_simple_fields_16: (a: number) => void;
1091
+ readonly __wbgt_test_get_properties_with_array_at_top_level_24: (a: number) => void;
1092
+ readonly __wbgt_test_get_properties_with_logical_operators_18: (a: number) => void;
1093
+ readonly __wbgt_test_get_properties_with_multiple_same_props_23: (a: number) => void;
1094
+ readonly __wbgt_test_get_properties_with_operators_17: (a: number) => void;
1095
+ readonly __wbgt_test_query_get_query_normalization_complex_mixed_32: (a: number) => void;
1096
+ readonly __wbgt_test_query_get_query_normalization_nested_logical_operators_30: (a: number) => void;
1097
+ readonly __wbgt_test_query_get_query_normalization_only_logical_operator_31: (a: number) => void;
1098
+ readonly __wbgt_test_query_get_query_normalization_simple_attributes_28: (a: number) => void;
1099
+ readonly __wbgt_test_query_get_query_normalization_with_logical_operator_29: (a: number) => void;
1100
+ readonly __wbgt_test_query_parse_age_query_34: (a: number) => void;
1101
+ readonly __wbgt_test_query_parse_empty_logical_operators_38: (a: number) => void;
1102
+ readonly __wbgt_test_query_parse_empty_query_33: (a: number) => void;
1103
+ readonly __wbgt_test_query_parse_eq_operator_41: (a: number) => void;
1104
+ readonly __wbgt_test_query_parse_eq_operator_wrong_type_42: (a: number) => void;
1105
+ readonly __wbgt_test_query_parse_in_operator_26: (a: number) => void;
1106
+ readonly __wbgt_test_query_parse_in_operator_wrong_type_27: (a: number) => void;
1107
+ readonly __wbgt_test_query_parse_invalid_in_operator_37: (a: number) => void;
1108
+ readonly __wbgt_test_query_parse_multiple_operators_36: (a: number) => void;
1109
+ readonly __wbgt_test_query_parse_ne_operator_43: (a: number) => void;
1110
+ readonly __wbgt_test_query_parse_ne_operator_wrong_type_44: (a: number) => void;
1111
+ readonly __wbgt_test_query_parse_nin_operator_39: (a: number) => void;
1112
+ readonly __wbgt_test_query_parse_nin_operator_wrong_type_40: (a: number) => void;
1113
+ readonly __wbgt_test_query_parse_non_object_query_35: (a: number) => void;
1114
+ readonly __wbgt_test_query_parse_operator_wrong_type_25: (a: number) => void;
1115
+ readonly query_get: (a: number, b: number, c: number, d: number) => void;
1116
+ readonly query_get_properties: (a: number, b: number) => void;
1117
+ readonly query_has_or_operator: (a: number) => number;
1118
+ readonly query_new: (a: number, b: number, c: number) => void;
1119
+ readonly query_parse: (a: number, b: number) => void;
1120
+ readonly query_process_query: (a: number, b: number, c: number) => void;
1121
+ readonly query_query: (a: number, b: number) => void;
1122
+ readonly __wbg_baseplugin_free: (a: number) => void;
928
1123
  readonly __wbg_basestorage_free: (a: number) => void;
929
1124
  readonly __wbg_database_free: (a: number) => void;
1125
+ readonly baseplugin_get_doc_create_hook: (a: number) => number;
1126
+ readonly baseplugin_get_doc_recover_hook: (a: number) => number;
1127
+ readonly baseplugin_name: (a: number) => number;
1128
+ readonly baseplugin_new: (a: number, b: number, c: number) => void;
1129
+ readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
1130
+ readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
930
1131
  readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
931
1132
  readonly basestorage_core: (a: number, b: number) => void;
932
1133
  readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
@@ -938,9 +1139,8 @@ interface InitOutput {
938
1139
  readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
939
1140
  readonly database_start: (a: number) => number;
940
1141
  readonly database_started: (a: number) => number;
941
- readonly is_debug_mode: () => number;
942
- readonly main_js: () => void;
943
1142
  readonly __wbg_property_free: (a: number) => void;
1143
+ readonly __wbg_queryoptions_free: (a: number) => void;
944
1144
  readonly __wbgt_test_invalid_property_2: (a: number) => void;
945
1145
  readonly __wbgt_test_property_creation_0: (a: number) => void;
946
1146
  readonly __wbgt_test_property_validation_1: (a: number) => void;
@@ -952,39 +1152,21 @@ interface InitOutput {
952
1152
  readonly property_minLength: (a: number, b: number) => void;
953
1153
  readonly property_properties: (a: number, b: number) => void;
954
1154
  readonly property_type: (a: number) => number;
955
- readonly __wbg_baseplugin_free: (a: number) => void;
956
- readonly baseplugin_get_doc_create_hook: (a: number) => number;
957
- readonly baseplugin_get_doc_recover_hook: (a: number) => number;
958
- readonly baseplugin_name: (a: number) => number;
959
- readonly baseplugin_new: (a: number, b: number, c: number) => void;
960
- readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
961
- readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
962
- readonly __wbg_collection_free: (a: number) => void;
963
- readonly __wbg_inmemory_free: (a: number) => void;
964
- readonly __wbg_operation_free: (a: number) => void;
1155
+ readonly queryoptions_limit: (a: number, b: number) => void;
1156
+ readonly queryoptions_offset: (a: number, b: number) => void;
1157
+ readonly queryoptions_sort: (a: number, b: number) => void;
1158
+ readonly __wbg_indexdb_free: (a: number) => void;
965
1159
  readonly __wbg_ridberror_free: (a: number) => void;
966
- readonly collection_count: (a: number, b: number, c: number) => number;
967
- readonly collection_create: (a: number, b: number) => number;
968
- readonly collection_delete: (a: number, b: number) => number;
969
- readonly collection_find: (a: number, b: number, c: number) => number;
970
- readonly collection_findById: (a: number, b: number) => number;
971
- readonly collection_name: (a: number, b: number) => void;
972
- readonly collection_parse_query_options: (a: number, b: number, c: number) => void;
973
- readonly collection_schema: (a: number, b: number) => void;
974
- readonly collection_update: (a: number, b: number) => number;
975
- readonly inmemory_close: (a: number) => number;
976
- readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
977
- readonly inmemory_create: (a: number, b: number, c: number) => number;
978
- readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
979
- readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
980
- readonly inmemory_start: (a: number) => number;
981
- readonly inmemory_write: (a: number, b: number) => number;
982
- readonly operation_collection: (a: number, b: number) => void;
983
- readonly operation_data: (a: number) => number;
984
- readonly operation_opType: (a: number) => number;
985
- readonly operation_primaryKey: (a: number) => number;
986
- readonly operation_primaryKeyField: (a: number) => number;
987
- readonly operation_primaryKeyIndex: (a: number, b: number) => void;
1160
+ readonly indexdb_close: (a: number) => number;
1161
+ readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
1162
+ readonly indexdb_create: (a: number, b: number, c: number) => number;
1163
+ readonly indexdb_find: (a: number, b: number, c: number, d: number, e: number) => number;
1164
+ readonly indexdb_findDocumentById: (a: number, b: number, c: number, d: number) => number;
1165
+ readonly indexdb_get_store: (a: number, b: number, c: number, d: number) => void;
1166
+ readonly indexdb_get_store_readonly: (a: number, b: number, c: number, d: number) => void;
1167
+ readonly indexdb_get_stores: (a: number, b: number) => void;
1168
+ readonly indexdb_start: (a: number) => number;
1169
+ readonly indexdb_write: (a: number, b: number) => number;
988
1170
  readonly ridberror_authentication: (a: number, b: number, c: number) => number;
989
1171
  readonly ridberror_code: (a: number) => number;
990
1172
  readonly ridberror_error: (a: number, b: number, c: number) => number;
@@ -996,17 +1178,19 @@ interface InitOutput {
996
1178
  readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
997
1179
  readonly ridberror_type: (a: number, b: number) => void;
998
1180
  readonly ridberror_validation: (a: number, b: number, c: number) => number;
999
- readonly __wbg_indexdb_free: (a: number) => void;
1000
- readonly indexdb_close: (a: number) => number;
1001
- readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
1002
- readonly indexdb_create: (a: number, b: number, c: number) => number;
1003
- readonly indexdb_find: (a: number, b: number, c: number, d: number, e: number) => number;
1004
- readonly indexdb_findDocumentById: (a: number, b: number, c: number, d: number) => number;
1005
- readonly indexdb_get_store: (a: number, b: number, c: number, d: number) => void;
1006
- readonly indexdb_get_store_readonly: (a: number, b: number, c: number, d: number) => void;
1007
- readonly indexdb_get_stores: (a: number, b: number) => void;
1008
- readonly indexdb_start: (a: number) => number;
1009
- readonly indexdb_write: (a: number, b: number) => number;
1181
+ readonly __wbg_operation_free: (a: number) => void;
1182
+ readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
1183
+ readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
1184
+ readonly corestorage_matchesQuery: (a: number, b: number, c: number, d: number) => void;
1185
+ readonly corestorage_sortDocuments: (a: number, b: number, c: number, d: number) => void;
1186
+ readonly operation_collection: (a: number, b: number) => void;
1187
+ readonly operation_data: (a: number) => number;
1188
+ readonly operation_opType: (a: number) => number;
1189
+ readonly operation_primaryKey: (a: number) => number;
1190
+ readonly operation_primaryKeyField: (a: number) => number;
1191
+ readonly operation_primaryKeyIndex: (a: number, b: number) => void;
1192
+ readonly corestorage_new: () => number;
1193
+ readonly __wbg_corestorage_free: (a: number) => void;
1010
1194
  readonly __wbg_wasmbindgentestcontext_free: (a: number) => void;
1011
1195
  readonly __wbgtest_console_debug: (a: number) => void;
1012
1196
  readonly __wbgtest_console_error: (a: number) => void;
@@ -1019,15 +1203,15 @@ interface InitOutput {
1019
1203
  readonly __wbindgen_malloc: (a: number, b: number) => number;
1020
1204
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
1021
1205
  readonly __wbindgen_export_2: WebAssembly.Table;
1022
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha7bc4bff3dafa2ad: (a: number, b: number, c: number) => void;
1023
1206
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
1024
- readonly _dyn_core__ops__function__Fn__A_B_C___Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h804a1f09b692c771: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1025
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hd4647cb021495324: (a: number, b: number, c: number) => void;
1207
+ readonly _dyn_core_7d5f0a2ba6a62c33___ops__function__Fn____________Output______as_wasm_bindgen_96f4c656f19e5a04___closure__WasmClosure___describe__invoke___wasm_bindgen_96f4c656f19e5a04___JsValue__wasm_bindgen_96f4c656f19e5a04___JsValue__wasm_bindgen_96f4c656f19e5a04___JsValue__core_7d5f0a2ba6a62c33___result__Result_wasm_bindgen_96f4c656f19e5a04___JsValue__ridb_core_aad11e700d7ae026___error__RIDBError__: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1208
+ readonly _dyn_core_7d5f0a2ba6a62c33___ops__function__FnMut_______Output______as_wasm_bindgen_96f4c656f19e5a04___closure__WasmClosure___describe__invoke___web_sys_42441b50243cf0a5___features__gen_Event__Event_____: (a: number, b: number, c: number) => void;
1209
+ readonly _dyn_core_7d5f0a2ba6a62c33___ops__function__FnMut_______Output______as_wasm_bindgen_96f4c656f19e5a04___closure__WasmClosure___describe__invoke___wasm_bindgen_96f4c656f19e5a04___JsValue_____: (a: number, b: number, c: number) => void;
1026
1210
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
1027
1211
  readonly __wbindgen_exn_store: (a: number) => void;
1028
- readonly wasm_bindgen__convert__closures__invoke0_mut__hc6452fdbb8c4addc: (a: number, b: number) => void;
1029
- readonly wasm_bindgen__convert__closures__invoke3_mut__h2f203dbfa61ca113: (a: number, b: number, c: number, d: number, e: number) => void;
1030
- readonly wasm_bindgen__convert__closures__invoke2_mut__h42aa995f02b6fdcb: (a: number, b: number, c: number, d: number) => void;
1212
+ readonly wasm_bindgen_96f4c656f19e5a04___convert__closures__invoke0_mut______: (a: number, b: number) => void;
1213
+ readonly wasm_bindgen_96f4c656f19e5a04___convert__closures__invoke2_mut___wasm_bindgen_96f4c656f19e5a04___JsValue__wasm_bindgen_96f4c656f19e5a04___JsValue_____: (a: number, b: number, c: number, d: number) => void;
1214
+ readonly wasm_bindgen_96f4c656f19e5a04___convert__closures__invoke3_mut___wasm_bindgen_96f4c656f19e5a04___JsValue__wasm_bindgen_96f4c656f19e5a04___JsValue__js_sys_cda727aa608b7f1b___Set_____: (a: number, b: number, c: number, d: number, e: number) => void;
1031
1215
  readonly __wbindgen_start: () => void;
1032
1216
  }
1033
1217
 
@@ -1052,4 +1236,4 @@ declare function initSync(module: SyncInitInput): InitOutput;
1052
1236
  */
1053
1237
  declare function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
1054
1238
 
1055
- export { type AnyVersionGreaterThan1, BasePlugin, BaseStorage, type BaseStorageOptions, Collection, CoreStorage, type CreateDoc, type CreateStorage, Database, type Doc, type EnumerateFrom1To, type EnumerateUpTo, Errors, type ExtractType, InMemory, type InOperator, IndexDB, type InitInput, type InitOutput, type InternalsRecord, type IsOptional, type IsVersionGreaterThan0, type LogicalOperators, type MigrationFunction, type MigrationPathsForSchema, type MigrationPathsForSchemas, type MigrationsParameter, type NInOperator, OpType, type Operation, type OperatorOrType, type Operators, Property, Query, type QueryOptions, type QueryType, RIDBError, type RIDBModule, Schema, SchemaFieldType, type SchemaType, type SchemaTypeRecord, StorageInternal, type SyncInitInput, WasmBindgenTestContext, __wbgtest_console_debug, __wbgtest_console_error, __wbgtest_console_info, __wbgtest_console_log, __wbgtest_console_warn, __wbg_init as default, initSync, is_debug_mode, main_js };
1239
+ export { type AnyVersionGreaterThan1, BasePlugin, BaseStorage, type BaseStorageOptions, Collection, CoreStorage, type CreateDoc, type CreateStorage, Database, type Doc, type EnumerateFrom1To, type EnumerateUpTo, Errors, type ExtractObject, type ExtractProperty, type ExtractType, type FlagRequiredness, InMemory, type InOperator, IndexDB, type InitInput, type InitOutput, type InternalsRecord, type IsCreateOptional, type IsNestedOptional, type IsVersionGreaterThan0, type LogicalOperators, type ManagedTimestampsQuery, type MigrationFunction, type MigrationPathsForSchema, type MigrationPathsForSchemas, type MigrationsParameter, type NInOperator, type NestedRequiredNames, OpType, type Operation, type OperatorOrType, type Operators, Property, Query, type QueryOptions, type QueryType, RIDBError, type RIDBModule, type RequiredFieldNames, Schema, SchemaFieldType, type SchemaType, type SchemaTypeRecord, type SortDirection, type SortSpec, StorageInternal, type SyncInitInput, type UpdateDoc, WasmBindgenTestContext, __wbgtest_console_debug, __wbgtest_console_error, __wbgtest_console_info, __wbgtest_console_log, __wbgtest_console_warn, __wbg_init as default, initSync, is_debug_mode, main_js };