@trust0/ridb-core 1.4.2 → 1.4.3-rc.1

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "1.4.2",
8
+ "version": "1.4.3-rc.1",
9
9
  "main": "./pkg/ridb_core.js",
10
10
  "types": "./pkg/ridb_core.d.ts",
11
11
  "sideEffects": [
@@ -38,6 +38,16 @@ export function __wbgtest_console_warn(args: Array<any>): void;
38
38
  */
39
39
  export function __wbgtest_console_error(args: Array<any>): void;
40
40
  /**
41
+ */
42
+ export 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
  export enum OpType {
@@ -99,25 +109,79 @@ export class Query<T extends SchemaType> {
99
109
 
100
110
 
101
111
 
112
+ export class CoreStorage {
113
+ /**
114
+ * @param {any} document
115
+ * @param {Query} query
116
+ * @returns {boolean}
117
+ */
118
+ matchesQuery(document: any, query: Query<any>): boolean;
119
+ getPrimaryKeyTyped(value: any): string | number;
120
+ getIndexes(schema: Schema<any>, op: Operation): string[];
121
+ }
122
+
123
+
124
+
102
125
  /**
103
- * Represents an IndexDB storage system extending the base storage functionality.
126
+ * Represents an operation to be performed on a collection.
104
127
  *
105
- * @template T - The schema type.
128
+ * @template T - The schema type of the collection.
106
129
  */
107
- export class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
130
+ export type Operation<T extends SchemaType> = {
108
131
  /**
109
- * Frees the resources used by the in-memory storage.
132
+ * The name of the collection on which the operation will be performed.
110
133
  */
111
- free(): void;
134
+ collection: string,
135
+
136
+ /**
137
+ * The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
138
+ */
139
+ opType: OpType,
140
+
141
+ /**
142
+ * The data involved in the operation, conforming to the schema type.
143
+ */
144
+ data: Doc<T>,
145
+
146
+ primaryKeyField?: string,
147
+ primaryKey?: string
148
+ }
112
149
 
150
+
151
+
152
+ export type BaseStorageOptions = {
153
+ [name:string]:string | boolean | number
154
+ }
155
+
156
+ export class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInternal<Schemas> {
113
157
  static create<SchemasCreate extends SchemaTypeRecord>(
114
158
  dbName: string,
115
159
  schemas: SchemasCreate,
160
+ options?: BaseStorageOptions
116
161
  ): Promise<
117
- IndexDB<
162
+ BaseStorage<
118
163
  SchemasCreate
119
164
  >
120
165
  >;
166
+ constructor(
167
+ dbName: string,
168
+ schemas: Schemas,
169
+ options?: BaseStorageOptions
170
+ );
171
+ readonly dbName: string;
172
+ readonly schemas: Record<keyof Schemas, Schema<Schemas[keyof Schemas]>>;
173
+ readonly options: BaseStorageOptions;
174
+ readonly core: CoreStorage;
175
+ start(): Promise<void>;
176
+ close(): Promise<void>;
177
+ count(colectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<number>;
178
+ findDocumentById(collectionName: keyof Schemas, id: string): Promise<Doc<Schemas[keyof Schemas]> | null>;
179
+ find(collectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<Doc<Schemas[keyof Schemas]>[]>;
180
+ write(op: Operation<Schemas[keyof Schemas]>): Promise<Doc<Schemas[keyof Schemas]>>;
181
+ getOption(name: string): string | boolean | number | undefined;
182
+ getSchema(name: string): Schema<any>;
183
+ //Call addIndexSchemas if you need extra indexing schemas for your database
184
+ addIndexSchemas(): null
121
185
  }
122
186
 
123
187
 
@@ -145,138 +209,25 @@ export class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
145
209
 
146
210
 
147
211
 
148
- export type InternalsRecord = {
149
- [name: string]: BaseStorage<SchemaTypeRecord>
150
- };
151
- /**
152
- * ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
153
- *
154
- * @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
155
- *
156
- * @example
157
- * type StringType = ExtractType<'string'>; // StringType is string
158
- * type NumberType = ExtractType<'number'>; // NumberType is number
159
- * type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
160
- * type ObjectType = ExtractType<'object'>; // ObjectType is object
161
- * type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
162
- */
163
- export type ExtractType<T extends string> =
164
- T extends "string" ? string :
165
- T extends "number" ? number :
166
- T extends "boolean" ? boolean :
167
- T extends "object" ? object :
168
- T extends "array" ? any[] :
169
- never;
170
-
171
- export type IsOptional<T> = T extends { required: false } ? true :
172
- T extends { default: any } ? true : false;
173
-
174
212
  /**
175
- * Doc is a utility type that transforms a schema type into a document type where each property is mapped to its extracted type.
176
- *
177
- * @template T - A schema type with a 'properties' field where each property's type is represented as a string.
213
+ * Represents an IndexDB storage system extending the base storage functionality.
178
214
  *
179
- * type Document = Doc<Schema>; // Document is { name: string; age: number; }
180
- */
181
- export type Doc<T extends SchemaType> = {
182
- [K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? K : never]?:
183
- ExtractType<T["properties"][K]["type"]>
184
- } & {
185
- [K in keyof T["properties"] as IsOptional<T["properties"][K]> extends false ? K : never]:
186
- ExtractType<T["properties"][K]["type"]>
187
- } & {
188
- __version?: number;
189
- };
190
-
191
- export type QueryOptions = {
192
- limit?: number;
193
- offset?: number;
194
- }
195
-
196
- /**
197
- * Collection is a class that represents a collection of documents in a database.
198
- * @template T - A schema type defining the structure of the documents in the collection.
215
+ * @template T - The schema type.
199
216
  */
200
- export class Collection<T extends SchemaType> {
201
- /**
202
- * Finds all documents in the collection.
203
- *
204
- * @returns A promise that resolves to an array of documents.
205
- */
206
- find(query: QueryType<T>, options?: QueryOptions): Promise<Doc<T>[]>;
207
- /**
208
- * count all documents in the collection.
209
- *
210
- * @returns A promise that resolves to an array of documents.
211
- */
212
- count(query: QueryType<T>, options?: QueryOptions): Promise<number>;
213
- /**
214
- * Finds a single document in the collection by its ID.
215
- *
216
- * @param id - The ID of the document to find.
217
- * @returns A promise that resolves to the found document.
218
- */
219
- findById(id: string): Promise<Doc<T>>;
220
- /**
221
- * Updates a document in the collection by its ID.
222
- *
223
- * @param id - The ID of the document to update.
224
- * @param document - A partial document containing the fields to update.
225
- * @returns A promise that resolves when the update is complete.
226
- */
227
- update(document: Partial<Doc<T>>): Promise<void>;
228
- /**
229
- * Creates a new document in the collection.
230
- *
231
- * @param document - The document to create.
232
- * @returns A promise that resolves to the created document.
233
- */
234
- create(document: Doc<T>): Promise<Doc<T>>;
235
- /**
236
- * Deletes a document in the collection by its ID.
237
- *
238
- * @param id - The ID of the document to delete.
239
- * @returns A promise that resolves when the deletion is complete.
240
- */
241
- delete(id: string): Promise<void>;
242
- }
243
-
244
-
245
-
246
-
247
- export type BaseStorageOptions = {
248
- [name:string]:string | boolean | number
249
- }
217
+ export class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
218
+ /**
219
+ * Frees the resources used by the in-memory storage.
220
+ */
221
+ free(): void;
250
222
 
251
- export class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInternal<Schemas> {
252
223
  static create<SchemasCreate extends SchemaTypeRecord>(
253
224
  dbName: string,
254
225
  schemas: SchemasCreate,
255
- options?: BaseStorageOptions
256
226
  ): Promise<
257
- BaseStorage<
227
+ IndexDB<
258
228
  SchemasCreate
259
229
  >
260
230
  >;
261
- constructor(
262
- dbName: string,
263
- schemas: Schemas,
264
- options?: BaseStorageOptions
265
- );
266
- readonly dbName: string;
267
- readonly schemas: Record<keyof Schemas, Schema<Schemas[keyof Schemas]>>;
268
- readonly options: BaseStorageOptions;
269
- readonly core: CoreStorage;
270
- start(): Promise<void>;
271
- close(): Promise<void>;
272
- count(colectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<number>;
273
- findDocumentById(collectionName: keyof Schemas, id: string): Promise<Doc<Schemas[keyof Schemas]> | null>;
274
- find(collectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<Doc<Schemas[keyof Schemas]>[]>;
275
- write(op: Operation<Schemas[keyof Schemas]>): Promise<Doc<Schemas[keyof Schemas]>>;
276
- getOption(name: string): string | boolean | number | undefined;
277
- getSchema(name: string): Schema<any>;
278
- //Call addIndexSchemas if you need extra indexing schemas for your database
279
- addIndexSchemas(): null
280
231
  }
281
232
 
282
233
 
@@ -300,67 +251,139 @@ export class BasePlugin implements BasePluginOptions {
300
251
 
301
252
 
302
253
  /**
303
- * Represents a property within a schema, including various constraints and nested properties.
254
+ * Represents a database containing collections of documents.
255
+ * RIDB extends from this class and is used to expose collections.
256
+ *
257
+ * So if you specify:
258
+ * ```typescript
259
+ * const db = new RIDB(
260
+ * {
261
+ * schemas: {
262
+ * demo: {
263
+ * version: 0,
264
+ * primaryKey: 'id',
265
+ * type: SchemaFieldType.object,
266
+ * properties: {
267
+ * id: {
268
+ * type: SchemaFieldType.string,
269
+ * maxLength: 60
270
+ * }
271
+ * }
272
+ * }
273
+ * } as const
274
+ * }
275
+ * )
276
+ * ```
277
+ *
278
+ * The collection will be available as `db.collections.demo` and all the methods for the collection (find, count, findById, update, create, delete) will be available.
279
+ *
280
+ * @template T - A record of schema types.
304
281
  */
305
- export class Property {
306
- /**
307
- * The type of the property.
308
- */
309
- readonly type: string;
282
+ export class Database<T extends SchemaTypeRecord> {
310
283
 
311
284
  /**
312
- * The version of the property, if applicable.
285
+ * Creates a new `Database` instance with the provided schemas and storage module.
286
+ *
287
+ * @template TS - A record of schema types.
288
+ * @param {TS} schemas - The schemas to use for the collections.
289
+ * @param migrations
290
+ * @param plugins
291
+ * @param options
292
+ * @param password
293
+ * @returns {Promise<Database<TS>>} A promise that resolves to the created `Database` instance.
313
294
  */
314
- readonly version?: number;
295
+ static create<TS extends SchemaTypeRecord>(
296
+ db_name: string,
297
+ schemas: TS,
298
+ migrations: MigrationPathsForSchemas<TS> | MigrationPathsForSchema<TS[string]>,
299
+ plugins:Array<typeof BasePlugin>,
300
+ options: RIDBModule,
301
+ password?:string,
302
+ storage?: BaseStorage<TS>
303
+ ): Promise<Database<TS>>;
315
304
 
316
305
  /**
317
- * The primary key of the property, if applicable.
306
+ * The collections in the database.
307
+ *
308
+ * This is a read-only property where the key is the name of the collection and the value is a `Collection` instance.
318
309
  */
319
- readonly primaryKey?: string;
310
+ readonly collections: {
311
+ [name in keyof T]: Collection<Schema<T[name]>>
312
+ }
320
313
 
321
- /**
322
- * An optional array of nested properties for array-type properties.
323
- */
324
- readonly items?: Property;
314
+ readonly started: boolean;
325
315
 
326
316
  /**
327
- * The maximum number of items for array-type properties, if applicable.
317
+ * Starts the database.
318
+ *
319
+ * @returns {Promise<void>} A promise that resolves when the database is started.
328
320
  */
329
- readonly maxItems?: number;
321
+ start(): Promise<void>;
330
322
 
331
323
  /**
332
- * The minimum number of items for array-type properties, if applicable.
324
+ * Closes the database.
325
+ *
326
+ * @returns {Promise<void>} A promise that resolves when the database is closed.
333
327
  */
334
- readonly minItems?: number;
328
+ close(): Promise<void>;
329
+ }
335
330
 
336
- /**
337
- * The maximum length for string-type properties, if applicable.
338
- */
339
- readonly maxLength?: number;
331
+ /**
332
+ * Represents a function type for creating storage with the provided schema type records.
333
+ *
334
+ * @template T - The schema type record.
335
+ * @param {T} records - The schema type records.
336
+ * @returns {Promise<InternalsRecord>} A promise that resolves to the created internals record.
337
+ */
338
+ export type CreateStorage = <T extends SchemaTypeRecord>(
339
+ records: T
340
+ ) => Promise<BaseStorage<T>>;
340
341
 
341
- /**
342
- * The minimum length for string-type properties, if applicable.
343
- */
344
- readonly minLength?: number;
342
+ /**
343
+ * Represents a storage module with a method for creating storage.
344
+ */
345
+ export type RIDBModule = {
345
346
 
346
347
  /**
347
- * An optional array of required fields for object-type properties.
348
+ * Plugin constructors array
348
349
  */
349
- readonly required?: boolean;
350
+ apply: (plugins:Array<typeof BasePlugin>) => Array<BasePlugin>;
351
+ };
350
352
 
351
- /**
352
- * An optional default value for the property.
353
- */
354
- readonly default?: any;
355
353
 
356
- /**
357
- * An optional map of nested properties for object-type properties.
358
- */
359
- readonly properties?: {
360
- [name: string]: Property;
361
- };
362
- }
363
354
 
355
+ /**
356
+ * Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
357
+ */
358
+ export type SchemaTypeRecord = {
359
+ [name: string]: SchemaType
360
+ };
361
+
362
+ export abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
363
+ constructor(
364
+ name: string,
365
+ schemas: Schemas
366
+ );
367
+ abstract start(): Promise<void>;
368
+ abstract close(): Promise<void>;
369
+ abstract count(
370
+ colectionName: keyof Schemas,
371
+ query: QueryType<Schemas[keyof Schemas]>,
372
+ options?: QueryOptions
373
+ ): Promise<number>;
374
+ abstract findDocumentById(
375
+ collectionName: keyof Schemas,
376
+ id: string
377
+ ): Promise<Doc<Schemas[keyof Schemas]> | null>;
378
+ abstract find(
379
+ collectionName: keyof Schemas,
380
+ query: QueryType<Schemas[keyof Schemas]>,
381
+ options?: QueryOptions
382
+ ): Promise<Doc<Schemas[keyof Schemas]>[]>;
383
+ abstract write(
384
+ op: Operation<Schemas[keyof Schemas]>
385
+ ): Promise<Doc<Schemas[keyof Schemas]>>;
386
+ }
364
387
 
365
388
 
366
389
  /**
@@ -471,33 +494,105 @@ export class Schema<T extends SchemaType> {
471
494
 
472
495
 
473
496
 
497
+ export type InternalsRecord = {
498
+ [name: string]: BaseStorage<SchemaTypeRecord>
499
+ };
474
500
  /**
475
- * Represents an operation to be performed on a collection.
501
+ * ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
476
502
  *
477
- * @template T - The schema type of the collection.
503
+ * @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
504
+ *
505
+ * @example
506
+ * type StringType = ExtractType<'string'>; // StringType is string
507
+ * type NumberType = ExtractType<'number'>; // NumberType is number
508
+ * type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
509
+ * type ObjectType = ExtractType<'object'>; // ObjectType is object
510
+ * type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
478
511
  */
479
- export type Operation<T extends SchemaType> = {
480
- /**
481
- * The name of the collection on which the operation will be performed.
482
- */
483
- collection: string,
512
+ export type ExtractType<T extends string> =
513
+ T extends "string" ? string :
514
+ T extends "number" ? number :
515
+ T extends "boolean" ? boolean :
516
+ T extends "object" ? object :
517
+ T extends "array" ? any[] :
518
+ never;
484
519
 
485
- /**
486
- * The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
487
- */
488
- opType: OpType,
520
+ export type IsOptional<T> = T extends { required: false } ? true :
521
+ T extends { default: any } ? true : false;
489
522
 
490
- /**
491
- * The data involved in the operation, conforming to the schema type.
492
- */
493
- data: Doc<T>,
523
+ /**
524
+ * Doc is a utility type that transforms a schema type into a document type where each property is mapped to its extracted type.
525
+ *
526
+ * @template T - A schema type with a 'properties' field where each property's type is represented as a string.
527
+ *
528
+ * type Document = Doc<Schema>; // Document is { name: string; age: number; }
529
+ */
530
+ export type Doc<T extends SchemaType> = {
531
+ [K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? K : never]?:
532
+ ExtractType<T["properties"][K]["type"]>
533
+ } & {
534
+ [K in keyof T["properties"] as IsOptional<T["properties"][K]> extends false ? K : never]:
535
+ ExtractType<T["properties"][K]["type"]>
536
+ } & {
537
+ __version?: number;
538
+ };
494
539
 
495
- primaryKeyField?: string,
496
- primaryKey?: string
540
+ export type QueryOptions = {
541
+ limit?: number;
542
+ offset?: number;
543
+ }
544
+
545
+ /**
546
+ * Collection is a class that represents a collection of documents in a database.
547
+ * @template T - A schema type defining the structure of the documents in the collection.
548
+ */
549
+ export class Collection<T extends SchemaType> {
550
+ /**
551
+ * Finds all documents in the collection.
552
+ *
553
+ * @returns A promise that resolves to an array of documents.
554
+ */
555
+ find(query: QueryType<T>, options?: QueryOptions): Promise<Doc<T>[]>;
556
+ /**
557
+ * count all documents in the collection.
558
+ *
559
+ * @returns A promise that resolves to an array of documents.
560
+ */
561
+ count(query: QueryType<T>, options?: QueryOptions): Promise<number>;
562
+ /**
563
+ * Finds a single document in the collection by its ID.
564
+ *
565
+ * @param id - The ID of the document to find.
566
+ * @returns A promise that resolves to the found document.
567
+ */
568
+ findById(id: string): Promise<Doc<T>>;
569
+ /**
570
+ * Updates a document in the collection by its ID.
571
+ *
572
+ * @param id - The ID of the document to update.
573
+ * @param document - A partial document containing the fields to update.
574
+ * @returns A promise that resolves when the update is complete.
575
+ */
576
+ update(document: Partial<Doc<T>>): Promise<void>;
577
+ /**
578
+ * Creates a new document in the collection.
579
+ *
580
+ * @param document - The document to create.
581
+ * @returns A promise that resolves to the created document.
582
+ */
583
+ create(document: Doc<T>): Promise<Doc<T>>;
584
+ /**
585
+ * Deletes a document in the collection by its ID.
586
+ *
587
+ * @param id - The ID of the document to delete.
588
+ * @returns A promise that resolves when the deletion is complete.
589
+ */
590
+ delete(id: string): Promise<void>;
497
591
  }
498
592
 
499
593
 
500
594
 
595
+
501
596
  export type EnumerateUpTo<
502
597
  N extends number,
503
598
  Acc extends number[] = []
@@ -547,153 +642,123 @@ export type MigrationsParameter<
547
642
 
548
643
 
549
644
  /**
550
- * Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
645
+ * Represents a property within a schema, including various constraints and nested properties.
551
646
  */
552
- export type SchemaTypeRecord = {
553
- [name: string]: SchemaType
554
- };
555
-
556
- export abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
557
- constructor(
558
- name: string,
559
- schemas: Schemas
560
- );
561
- abstract start(): Promise<void>;
562
- abstract close(): Promise<void>;
563
- abstract count(
564
- colectionName: keyof Schemas,
565
- query: QueryType<Schemas[keyof Schemas]>,
566
- options?: QueryOptions
567
- ): Promise<number>;
568
- abstract findDocumentById(
569
- collectionName: keyof Schemas,
570
- id: string
571
- ): Promise<Doc<Schemas[keyof Schemas]> | null>;
572
- abstract find(
573
- collectionName: keyof Schemas,
574
- query: QueryType<Schemas[keyof Schemas]>,
575
- options?: QueryOptions
576
- ): Promise<Doc<Schemas[keyof Schemas]>[]>;
577
- abstract write(
578
- op: Operation<Schemas[keyof Schemas]>
579
- ): Promise<Doc<Schemas[keyof Schemas]>>;
580
- }
581
-
582
-
583
- export class CoreStorage {
647
+ export class Property {
584
648
  /**
585
- * @param {any} document
586
- * @param {Query} query
587
- * @returns {boolean}
588
- */
589
- matchesQuery(document: any, query: Query<any>): boolean;
590
- getPrimaryKeyTyped(value: any): string | number;
591
- getIndexes(schema: Schema<any>, op: Operation): string[];
592
- }
593
-
649
+ * The type of the property.
650
+ */
651
+ readonly type: string;
594
652
 
653
+ /**
654
+ * The version of the property, if applicable.
655
+ */
656
+ readonly version?: number;
595
657
 
596
- /**
597
- * Represents a database containing collections of documents.
598
- * RIDB extends from this class and is used to expose collections.
599
- *
600
- * So if you specify:
601
- * ```typescript
602
- * const db = new RIDB(
603
- * {
604
- * schemas: {
605
- * demo: {
606
- * version: 0,
607
- * primaryKey: 'id',
608
- * type: SchemaFieldType.object,
609
- * properties: {
610
- * id: {
611
- * type: SchemaFieldType.string,
612
- * maxLength: 60
613
- * }
614
- * }
615
- * }
616
- * } as const
617
- * }
618
- * )
619
- * ```
620
- *
621
- * The collection will be available as `db.collections.demo` and all the methods for the collection (find, count, findById, update, create, delete) will be available.
622
- *
623
- * @template T - A record of schema types.
624
- */
625
- export class Database<T extends SchemaTypeRecord> {
658
+ /**
659
+ * The primary key of the property, if applicable.
660
+ */
661
+ readonly primaryKey?: string;
626
662
 
627
663
  /**
628
- * Creates a new `Database` instance with the provided schemas and storage module.
629
- *
630
- * @template TS - A record of schema types.
631
- * @param {TS} schemas - The schemas to use for the collections.
632
- * @param migrations
633
- * @param plugins
634
- * @param options
635
- * @param password
636
- * @returns {Promise<Database<TS>>} A promise that resolves to the created `Database` instance.
664
+ * An optional array of nested properties for array-type properties.
637
665
  */
638
- static create<TS extends SchemaTypeRecord>(
639
- db_name: string,
640
- schemas: TS,
641
- migrations: MigrationPathsForSchemas<TS> | MigrationPathsForSchema<TS[string]>,
642
- plugins:Array<typeof BasePlugin>,
643
- options: RIDBModule,
644
- password?:string,
645
- storage?: BaseStorage<TS>
646
- ): Promise<Database<TS>>;
666
+ readonly items?: Property;
647
667
 
648
668
  /**
649
- * The collections in the database.
650
- *
651
- * This is a read-only property where the key is the name of the collection and the value is a `Collection` instance.
669
+ * The maximum number of items for array-type properties, if applicable.
652
670
  */
653
- readonly collections: {
654
- [name in keyof T]: Collection<Schema<T[name]>>
655
- }
671
+ readonly maxItems?: number;
656
672
 
657
- readonly started: boolean;
673
+ /**
674
+ * The minimum number of items for array-type properties, if applicable.
675
+ */
676
+ readonly minItems?: number;
658
677
 
659
678
  /**
660
- * Starts the database.
661
- *
662
- * @returns {Promise<void>} A promise that resolves when the database is started.
679
+ * The maximum length for string-type properties, if applicable.
663
680
  */
664
- start(): Promise<void>;
681
+ readonly maxLength?: number;
665
682
 
666
683
  /**
667
- * Closes the database.
668
- *
669
- * @returns {Promise<void>} A promise that resolves when the database is closed.
684
+ * The minimum length for string-type properties, if applicable.
670
685
  */
671
- close(): Promise<void>;
672
- }
686
+ readonly minLength?: number;
673
687
 
674
- /**
675
- * Represents a function type for creating storage with the provided schema type records.
676
- *
677
- * @template T - The schema type record.
678
- * @param {T} records - The schema type records.
679
- * @returns {Promise<InternalsRecord>} A promise that resolves to the created internals record.
680
- */
681
- export type CreateStorage = <T extends SchemaTypeRecord>(
682
- records: T
683
- ) => Promise<BaseStorage<T>>;
688
+ /**
689
+ * An optional array of required fields for object-type properties.
690
+ */
691
+ readonly required?: boolean;
684
692
 
685
- /**
686
- * Represents a storage module with a method for creating storage.
687
- */
688
- export type RIDBModule = {
693
+ /**
694
+ * An optional default value for the property.
695
+ */
696
+ readonly default?: any;
689
697
 
690
698
  /**
691
- * Plugin constructors array
699
+ * An optional map of nested properties for object-type properties.
692
700
  */
693
- apply: (plugins:Array<typeof BasePlugin>) => Array<BasePlugin>;
694
- };
701
+ readonly properties?: {
702
+ [name: string]: Property;
703
+ };
704
+ }
695
705
 
696
706
 
707
+ /**
708
+ */
709
+ export class RIDBError {
710
+ free(): void;
711
+ /**
712
+ * @param {any} err
713
+ * @returns {RIDBError}
714
+ */
715
+ static from(err: any): RIDBError;
716
+ /**
717
+ * @param {string} err
718
+ * @param {number} code
719
+ * @returns {RIDBError}
720
+ */
721
+ static error(err: string, code: number): RIDBError;
722
+ /**
723
+ * @param {string} err
724
+ * @param {number} code
725
+ * @returns {RIDBError}
726
+ */
727
+ static query(err: string, code: number): RIDBError;
728
+ /**
729
+ * @param {string} err
730
+ * @param {number} code
731
+ * @returns {RIDBError}
732
+ */
733
+ static authentication(err: string, code: number): RIDBError;
734
+ /**
735
+ * @param {string} err
736
+ * @param {number} code
737
+ * @returns {RIDBError}
738
+ */
739
+ static serialisation(err: string, code: number): RIDBError;
740
+ /**
741
+ * @param {string} err
742
+ * @param {number} code
743
+ * @returns {RIDBError}
744
+ */
745
+ static validation(err: string, code: number): RIDBError;
746
+ /**
747
+ * @param {string} err
748
+ * @param {number} code
749
+ * @returns {RIDBError}
750
+ */
751
+ static hook(err: string, code: number): RIDBError;
752
+ /**
753
+ */
754
+ readonly code: any;
755
+ /**
756
+ */
757
+ readonly message: string;
758
+ /**
759
+ */
760
+ readonly type: string;
761
+ }
697
762
  /**
698
763
  * Runtime test harness support instantiated in JS.
699
764
  *
@@ -772,6 +837,34 @@ export interface InitOutput {
772
837
  readonly __wbgt_test_query_parse_eq_operator_wrong_type_32: (a: number) => void;
773
838
  readonly __wbgt_test_query_parse_ne_operator_33: (a: number) => void;
774
839
  readonly __wbgt_test_query_parse_ne_operator_wrong_type_34: (a: number) => void;
840
+ readonly corestorage_new: () => number;
841
+ readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
842
+ readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
843
+ readonly corestorage_matchesQuery: (a: number, b: number, c: number, d: number) => void;
844
+ readonly __wbg_operation_free: (a: number) => void;
845
+ readonly operation_collection: (a: number, b: number) => void;
846
+ readonly operation_opType: (a: number) => number;
847
+ readonly operation_data: (a: number) => number;
848
+ readonly operation_primaryKeyField: (a: number) => number;
849
+ readonly operation_primaryKey: (a: number) => number;
850
+ readonly operation_primaryKeyIndex: (a: number, b: number) => void;
851
+ readonly main_js: () => void;
852
+ readonly is_debug_mode: () => number;
853
+ readonly __wbg_corestorage_free: (a: number) => void;
854
+ readonly __wbg_basestorage_free: (a: number) => void;
855
+ readonly basestorage_new: (a: number, b: number, c: number, d: number, e: number) => void;
856
+ readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
857
+ readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
858
+ readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
859
+ readonly basestorage_core: (a: number, b: number) => void;
860
+ readonly __wbg_inmemory_free: (a: number) => void;
861
+ readonly inmemory_create: (a: number, b: number, c: number) => number;
862
+ readonly inmemory_write: (a: number, b: number) => number;
863
+ readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
864
+ readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
865
+ readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
866
+ readonly inmemory_close: (a: number) => number;
867
+ readonly inmemory_start: (a: number) => number;
775
868
  readonly __wbg_indexdb_free: (a: number) => void;
776
869
  readonly indexdb_get_stores: (a: number, b: number) => void;
777
870
  readonly indexdb_get_store: (a: number, b: number, c: number, d: number) => void;
@@ -782,17 +875,46 @@ export interface InitOutput {
782
875
  readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
783
876
  readonly indexdb_close: (a: number) => number;
784
877
  readonly indexdb_start: (a: number) => number;
785
- readonly __wbg_inmemory_free: (a: number) => void;
786
- readonly inmemory_create: (a: number, b: number, c: number) => number;
787
- readonly inmemory_write: (a: number, b: number) => number;
788
- readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
789
- readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
790
- readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
791
- readonly inmemory_close: (a: number) => number;
792
- readonly inmemory_start: (a: number) => number;
878
+ readonly __wbg_baseplugin_free: (a: number) => void;
879
+ readonly baseplugin_new: (a: number, b: number, c: number) => void;
880
+ readonly baseplugin_name: (a: number) => number;
881
+ readonly baseplugin_get_doc_create_hook: (a: number) => number;
882
+ readonly baseplugin_get_doc_recover_hook: (a: number) => number;
883
+ readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
884
+ readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
885
+ readonly __wbg_ridberror_free: (a: number) => void;
886
+ readonly ridberror_type: (a: number, b: number) => void;
887
+ readonly ridberror_code: (a: number) => number;
888
+ readonly ridberror_message: (a: number, b: number) => void;
889
+ readonly ridberror_from: (a: number) => number;
890
+ readonly ridberror_error: (a: number, b: number, c: number) => number;
891
+ readonly ridberror_query: (a: number, b: number, c: number) => number;
892
+ readonly ridberror_authentication: (a: number, b: number, c: number) => number;
893
+ readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
894
+ readonly ridberror_validation: (a: number, b: number, c: number) => number;
895
+ readonly ridberror_hook: (a: number, b: number, c: number) => number;
896
+ readonly __wbg_database_free: (a: number) => void;
897
+ readonly database_start: (a: number) => number;
898
+ readonly database_close: (a: number) => number;
899
+ readonly database_started: (a: number) => number;
900
+ readonly database_collections: (a: number, b: number) => void;
901
+ readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
793
902
  readonly __wbg_queryoptions_free: (a: number) => void;
794
903
  readonly queryoptions_limit: (a: number, b: number) => void;
795
904
  readonly queryoptions_offset: (a: number, b: number) => void;
905
+ readonly __wbg_schema_free: (a: number) => void;
906
+ readonly schema_validate: (a: number, b: number, c: number) => void;
907
+ readonly schema_is_valid: (a: number, b: number) => void;
908
+ readonly schema_create: (a: number, b: number) => void;
909
+ readonly schema_version: (a: number) => number;
910
+ readonly schema_primaryKey: (a: number, b: number) => void;
911
+ readonly schema_type: (a: number, b: number) => void;
912
+ readonly schema_indexes: (a: number, b: number) => void;
913
+ readonly schema_encrypted: (a: number, b: number) => void;
914
+ readonly schema_properties: (a: number, b: number) => void;
915
+ readonly __wbgt_test_schema_creation_3: (a: number) => void;
916
+ readonly __wbgt_test_schema_validation_4: (a: number) => void;
917
+ readonly __wbgt_test_invalid_schema_5: (a: number) => void;
796
918
  readonly __wbg_collection_free: (a: number) => void;
797
919
  readonly collection_name: (a: number, b: number) => void;
798
920
  readonly collection_schema: (a: number, b: number) => void;
@@ -803,21 +925,6 @@ export interface InitOutput {
803
925
  readonly collection_update: (a: number, b: number) => number;
804
926
  readonly collection_create: (a: number, b: number) => number;
805
927
  readonly collection_delete: (a: number, b: number) => number;
806
- readonly __wbg_basestorage_free: (a: number) => void;
807
- readonly basestorage_new: (a: number, b: number, c: number, d: number, e: number) => void;
808
- readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
809
- readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
810
- readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
811
- readonly basestorage_core: (a: number, b: number) => void;
812
- readonly __wbg_baseplugin_free: (a: number) => void;
813
- readonly baseplugin_new: (a: number, b: number, c: number) => void;
814
- readonly baseplugin_name: (a: number) => number;
815
- readonly baseplugin_get_doc_create_hook: (a: number) => number;
816
- readonly baseplugin_get_doc_recover_hook: (a: number) => number;
817
- readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
818
- readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
819
- readonly main_js: () => void;
820
- readonly is_debug_mode: () => number;
821
928
  readonly __wbg_property_free: (a: number) => void;
822
929
  readonly property_is_valid: (a: number, b: number) => void;
823
930
  readonly property_type: (a: number) => number;
@@ -830,37 +937,6 @@ export interface InitOutput {
830
937
  readonly __wbgt_test_property_creation_0: (a: number) => void;
831
938
  readonly __wbgt_test_property_validation_1: (a: number) => void;
832
939
  readonly __wbgt_test_invalid_property_2: (a: number) => void;
833
- readonly __wbg_schema_free: (a: number) => void;
834
- readonly schema_validate: (a: number, b: number, c: number) => void;
835
- readonly schema_is_valid: (a: number, b: number) => void;
836
- readonly schema_create: (a: number, b: number) => void;
837
- readonly schema_version: (a: number) => number;
838
- readonly schema_primaryKey: (a: number, b: number) => void;
839
- readonly schema_type: (a: number, b: number) => void;
840
- readonly schema_indexes: (a: number, b: number) => void;
841
- readonly schema_encrypted: (a: number, b: number) => void;
842
- readonly schema_properties: (a: number, b: number) => void;
843
- readonly __wbgt_test_schema_creation_3: (a: number) => void;
844
- readonly __wbgt_test_schema_validation_4: (a: number) => void;
845
- readonly __wbgt_test_invalid_schema_5: (a: number) => void;
846
- readonly __wbg_operation_free: (a: number) => void;
847
- readonly operation_collection: (a: number, b: number) => void;
848
- readonly operation_opType: (a: number) => number;
849
- readonly operation_data: (a: number) => number;
850
- readonly operation_primaryKeyField: (a: number) => number;
851
- readonly operation_primaryKey: (a: number) => number;
852
- readonly operation_primaryKeyIndex: (a: number, b: number) => void;
853
- readonly corestorage_new: () => number;
854
- readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
855
- readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
856
- readonly corestorage_matchesQuery: (a: number, b: number, c: number, d: number) => void;
857
- readonly __wbg_database_free: (a: number) => void;
858
- readonly database_start: (a: number) => number;
859
- readonly database_close: (a: number) => number;
860
- readonly database_started: (a: number) => number;
861
- readonly database_collections: (a: number, b: number) => void;
862
- readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
863
- readonly __wbg_corestorage_free: (a: number) => void;
864
940
  readonly __wbg_wasmbindgentestcontext_free: (a: number) => void;
865
941
  readonly wasmbindgentestcontext_new: () => number;
866
942
  readonly wasmbindgentestcontext_args: (a: number, b: number, c: number) => void;
@@ -875,7 +951,7 @@ export interface InitOutput {
875
951
  readonly __wbindgen_export_2: WebAssembly.Table;
876
952
  readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h231d9c59fed64ed4: (a: number, b: number, c: number) => void;
877
953
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
878
- readonly _dyn_core__ops__function__Fn__A_B_C___Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb4a5dccdae894074: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
954
+ readonly _dyn_core__ops__function__Fn__A_B_C___Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h33ba438d7169a89a: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
879
955
  readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8d2923cd4e648893: (a: number, b: number, c: number) => number;
880
956
  readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf066437ba5ed1b74: (a: number, b: number, c: number) => void;
881
957
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
package/pkg/ridb_core.js CHANGED
@@ -257,7 +257,7 @@ function makeClosure(arg0, arg1, dtor, f) {
257
257
  function __wbg_adapter_59(arg0, arg1, arg2, arg3, arg4) {
258
258
  try {
259
259
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
260
- wasm._dyn_core__ops__function__Fn__A_B_C___Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb4a5dccdae894074(retptr, arg0, arg1, addHeapObject(arg2), addHeapObject(arg3), addHeapObject(arg4));
260
+ wasm._dyn_core__ops__function__Fn__A_B_C___Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h33ba438d7169a89a(retptr, arg0, arg1, addHeapObject(arg2), addHeapObject(arg3), addHeapObject(arg4));
261
261
  var r0 = getInt32Memory0()[retptr / 4 + 0];
262
262
  var r1 = getInt32Memory0()[retptr / 4 + 1];
263
263
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -327,14 +327,6 @@ export function is_debug_mode() {
327
327
  return ret !== 0;
328
328
  }
329
329
 
330
- function handleError(f, args) {
331
- try {
332
- return f.apply(this, args);
333
- } catch (e) {
334
- wasm.__wbindgen_exn_store(addHeapObject(e));
335
- }
336
- }
337
-
338
330
  function passArrayJsValueToWasm0(array, malloc) {
339
331
  const ptr = malloc(array.length * 4, 4) >>> 0;
340
332
  const mem = getUint32Memory0();
@@ -344,6 +336,14 @@ function passArrayJsValueToWasm0(array, malloc) {
344
336
  WASM_VECTOR_LEN = array.length;
345
337
  return ptr;
346
338
  }
339
+
340
+ function handleError(f, args) {
341
+ try {
342
+ return f.apply(this, args);
343
+ } catch (e) {
344
+ wasm.__wbindgen_exn_store(addHeapObject(e));
345
+ }
346
+ }
347
347
  /**
348
348
  * Handler for `console.log` invocations.
349
349
  *
@@ -409,18 +409,21 @@ export function __wbgtest_console_error(args) {
409
409
  }
410
410
  }
411
411
 
412
- function __wbg_adapter_282(arg0, arg1) {
412
+ function __wbg_adapter_294(arg0, arg1) {
413
413
  wasm.wasm_bindgen__convert__closures__invoke0_mut__hf4bced6426ca6f31(arg0, arg1);
414
414
  }
415
415
 
416
- function __wbg_adapter_325(arg0, arg1, arg2, arg3, arg4) {
416
+ function __wbg_adapter_337(arg0, arg1, arg2, arg3, arg4) {
417
417
  wasm.wasm_bindgen__convert__closures__invoke3_mut__h425269a7185d1f5b(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
418
418
  }
419
419
 
420
- function __wbg_adapter_378(arg0, arg1, arg2, arg3) {
420
+ function __wbg_adapter_388(arg0, arg1, arg2, arg3) {
421
421
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h1b9fff078715ef14(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
422
422
  }
423
423
 
424
+ /**
425
+ */
426
+ export const Errors = Object.freeze({ Error:0,"0":"Error",HookError:1,"1":"HookError",QueryError:2,"2":"QueryError",SerializationError:3,"3":"SerializationError",ValidationError:4,"4":"ValidationError",AuthenticationError:5,"5":"AuthenticationError", });
424
427
  /**
425
428
  * Represents the type of operation to be performed on the collection.
426
429
  */
@@ -1790,6 +1793,153 @@ export class QueryOptions {
1790
1793
  }
1791
1794
  }
1792
1795
 
1796
+ const RIDBErrorFinalization = (typeof FinalizationRegistry === 'undefined')
1797
+ ? { register: () => {}, unregister: () => {} }
1798
+ : new FinalizationRegistry(ptr => wasm.__wbg_ridberror_free(ptr >>> 0));
1799
+ /**
1800
+ */
1801
+ export class RIDBError {
1802
+
1803
+ static __wrap(ptr) {
1804
+ ptr = ptr >>> 0;
1805
+ const obj = Object.create(RIDBError.prototype);
1806
+ obj.__wbg_ptr = ptr;
1807
+ RIDBErrorFinalization.register(obj, obj.__wbg_ptr, obj);
1808
+ return obj;
1809
+ }
1810
+
1811
+ __destroy_into_raw() {
1812
+ const ptr = this.__wbg_ptr;
1813
+ this.__wbg_ptr = 0;
1814
+ RIDBErrorFinalization.unregister(this);
1815
+ return ptr;
1816
+ }
1817
+
1818
+ free() {
1819
+ const ptr = this.__destroy_into_raw();
1820
+ wasm.__wbg_ridberror_free(ptr);
1821
+ }
1822
+ /**
1823
+ * @returns {string}
1824
+ */
1825
+ get type() {
1826
+ let deferred1_0;
1827
+ let deferred1_1;
1828
+ try {
1829
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1830
+ wasm.ridberror_type(retptr, this.__wbg_ptr);
1831
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1832
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1833
+ deferred1_0 = r0;
1834
+ deferred1_1 = r1;
1835
+ return getStringFromWasm0(r0, r1);
1836
+ } finally {
1837
+ wasm.__wbindgen_add_to_stack_pointer(16);
1838
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1839
+ }
1840
+ }
1841
+ /**
1842
+ * @returns {any}
1843
+ */
1844
+ get code() {
1845
+ const ret = wasm.ridberror_code(this.__wbg_ptr);
1846
+ return takeObject(ret);
1847
+ }
1848
+ /**
1849
+ * @returns {string}
1850
+ */
1851
+ get message() {
1852
+ let deferred1_0;
1853
+ let deferred1_1;
1854
+ try {
1855
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1856
+ wasm.ridberror_message(retptr, this.__wbg_ptr);
1857
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1858
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1859
+ deferred1_0 = r0;
1860
+ deferred1_1 = r1;
1861
+ return getStringFromWasm0(r0, r1);
1862
+ } finally {
1863
+ wasm.__wbindgen_add_to_stack_pointer(16);
1864
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1865
+ }
1866
+ }
1867
+ /**
1868
+ * @param {any} err
1869
+ * @returns {RIDBError}
1870
+ */
1871
+ static from(err) {
1872
+ const ret = wasm.ridberror_from(addHeapObject(err));
1873
+ return RIDBError.__wrap(ret);
1874
+ }
1875
+ /**
1876
+ * @param {string} err
1877
+ * @param {number} code
1878
+ * @returns {RIDBError}
1879
+ */
1880
+ static error(err, code) {
1881
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1882
+ const len0 = WASM_VECTOR_LEN;
1883
+ const ret = wasm.ridberror_error(ptr0, len0, code);
1884
+ return RIDBError.__wrap(ret);
1885
+ }
1886
+ /**
1887
+ * @param {string} err
1888
+ * @param {number} code
1889
+ * @returns {RIDBError}
1890
+ */
1891
+ static query(err, code) {
1892
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1893
+ const len0 = WASM_VECTOR_LEN;
1894
+ const ret = wasm.ridberror_query(ptr0, len0, code);
1895
+ return RIDBError.__wrap(ret);
1896
+ }
1897
+ /**
1898
+ * @param {string} err
1899
+ * @param {number} code
1900
+ * @returns {RIDBError}
1901
+ */
1902
+ static authentication(err, code) {
1903
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1904
+ const len0 = WASM_VECTOR_LEN;
1905
+ const ret = wasm.ridberror_authentication(ptr0, len0, code);
1906
+ return RIDBError.__wrap(ret);
1907
+ }
1908
+ /**
1909
+ * @param {string} err
1910
+ * @param {number} code
1911
+ * @returns {RIDBError}
1912
+ */
1913
+ static serialisation(err, code) {
1914
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1915
+ const len0 = WASM_VECTOR_LEN;
1916
+ const ret = wasm.ridberror_serialisation(ptr0, len0, code);
1917
+ return RIDBError.__wrap(ret);
1918
+ }
1919
+ /**
1920
+ * @param {string} err
1921
+ * @param {number} code
1922
+ * @returns {RIDBError}
1923
+ */
1924
+ static validation(err, code) {
1925
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1926
+ const len0 = WASM_VECTOR_LEN;
1927
+ const ret = wasm.ridberror_validation(ptr0, len0, code);
1928
+ return RIDBError.__wrap(ret);
1929
+ }
1930
+ /**
1931
+ * @param {string} err
1932
+ * @param {number} code
1933
+ * @returns {RIDBError}
1934
+ */
1935
+ static hook(err, code) {
1936
+ const ptr0 = passStringToWasm0(err, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1937
+ const len0 = WASM_VECTOR_LEN;
1938
+ const ret = wasm.ridberror_hook(ptr0, len0, code);
1939
+ return RIDBError.__wrap(ret);
1940
+ }
1941
+ }
1942
+
1793
1943
  const SchemaFinalization = (typeof FinalizationRegistry === 'undefined')
1794
1944
  ? { register: () => {}, unregister: () => {} }
1795
1945
  : new FinalizationRegistry(ptr => wasm.__wbg_schema_free(ptr >>> 0));
@@ -2117,6 +2267,10 @@ function __wbg_get_imports() {
2117
2267
  const ret = getObject(arg0);
2118
2268
  return addHeapObject(ret);
2119
2269
  };
2270
+ imports.wbg.__wbg_ridberror_new = function(arg0) {
2271
+ const ret = RIDBError.__wrap(arg0);
2272
+ return addHeapObject(ret);
2273
+ };
2120
2274
  imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
2121
2275
  const obj = getObject(arg1);
2122
2276
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -2148,10 +2302,6 @@ function __wbg_get_imports() {
2148
2302
  const ret = getObject(arg0).start();
2149
2303
  return addHeapObject(ret);
2150
2304
  }, arguments) };
2151
- imports.wbg.__wbg_database_new = function(arg0) {
2152
- const ret = Database.__wrap(arg0);
2153
- return addHeapObject(ret);
2154
- };
2155
2305
  imports.wbg.__wbg_close_6384ed3c27ef25c1 = function() { return handleError(function (arg0) {
2156
2306
  const ret = getObject(arg0).close();
2157
2307
  return addHeapObject(ret);
@@ -2168,10 +2318,6 @@ function __wbg_get_imports() {
2168
2318
  const ret = getObject(arg0).find(getStringFromWasm0(arg1, arg2), takeObject(arg3), QueryOptions.__wrap(arg4));
2169
2319
  return addHeapObject(ret);
2170
2320
  }, arguments) };
2171
- imports.wbg.__wbg_indexdb_new = function(arg0) {
2172
- const ret = IndexDB.__wrap(arg0);
2173
- return addHeapObject(ret);
2174
- };
2175
2321
  imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
2176
2322
  const obj = getObject(arg1);
2177
2323
  const ret = typeof(obj) === 'number' ? obj : undefined;
@@ -2212,16 +2358,16 @@ function __wbg_get_imports() {
2212
2358
  const ret = !getObject(arg0);
2213
2359
  return ret;
2214
2360
  };
2215
- imports.wbg.__wbindgen_is_function = function(arg0) {
2216
- const ret = typeof(getObject(arg0)) === 'function';
2217
- return ret;
2361
+ imports.wbg.__wbg_collection_new = function(arg0) {
2362
+ const ret = Collection.__wrap(arg0);
2363
+ return addHeapObject(ret);
2218
2364
  };
2219
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
2220
- const ret = new Error(getStringFromWasm0(arg0, arg1));
2365
+ imports.wbg.__wbg_database_new = function(arg0) {
2366
+ const ret = Database.__wrap(arg0);
2221
2367
  return addHeapObject(ret);
2222
2368
  };
2223
- imports.wbg.__wbg_collection_new = function(arg0) {
2224
- const ret = Collection.__wrap(arg0);
2369
+ imports.wbg.__wbg_indexdb_new = function(arg0) {
2370
+ const ret = IndexDB.__wrap(arg0);
2225
2371
  return addHeapObject(ret);
2226
2372
  };
2227
2373
  imports.wbg.__wbindgen_boolean_get = function(arg0) {
@@ -2229,6 +2375,14 @@ function __wbg_get_imports() {
2229
2375
  const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
2230
2376
  return ret;
2231
2377
  };
2378
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
2379
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
2380
+ return addHeapObject(ret);
2381
+ };
2382
+ imports.wbg.__wbindgen_is_function = function(arg0) {
2383
+ const ret = typeof(getObject(arg0)) === 'function';
2384
+ return ret;
2385
+ };
2232
2386
  imports.wbg.__wbindgen_is_bigint = function(arg0) {
2233
2387
  const ret = typeof(getObject(arg0)) === 'bigint';
2234
2388
  return ret;
@@ -2523,7 +2677,7 @@ function __wbg_get_imports() {
2523
2677
  const a = state0.a;
2524
2678
  state0.a = 0;
2525
2679
  try {
2526
- return __wbg_adapter_282(a, state0.b, );
2680
+ return __wbg_adapter_294(a, state0.b, );
2527
2681
  } finally {
2528
2682
  state0.a = a;
2529
2683
  }
@@ -2688,7 +2842,7 @@ function __wbg_get_imports() {
2688
2842
  const a = state0.a;
2689
2843
  state0.a = 0;
2690
2844
  try {
2691
- return __wbg_adapter_325(a, state0.b, arg0, arg1, arg2);
2845
+ return __wbg_adapter_337(a, state0.b, arg0, arg1, arg2);
2692
2846
  } finally {
2693
2847
  state0.a = a;
2694
2848
  }
@@ -2720,10 +2874,6 @@ function __wbg_get_imports() {
2720
2874
  const ret = result;
2721
2875
  return ret;
2722
2876
  };
2723
- imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) {
2724
- const ret = new Error(getStringFromWasm0(arg0, arg1));
2725
- return addHeapObject(ret);
2726
- };
2727
2877
  imports.wbg.__wbg_message_5bf28016c2b49cfb = function(arg0) {
2728
2878
  const ret = getObject(arg0).message;
2729
2879
  return addHeapObject(ret);
@@ -2771,7 +2921,7 @@ function __wbg_get_imports() {
2771
2921
  const a = state0.a;
2772
2922
  state0.a = 0;
2773
2923
  try {
2774
- return __wbg_adapter_378(a, state0.b, arg0, arg1);
2924
+ return __wbg_adapter_388(a, state0.b, arg0, arg1);
2775
2925
  } finally {
2776
2926
  state0.a = a;
2777
2927
  }
@@ -2871,20 +3021,20 @@ function __wbg_get_imports() {
2871
3021
  const ret = wasm.memory;
2872
3022
  return addHeapObject(ret);
2873
3023
  };
2874
- imports.wbg.__wbindgen_closure_wrapper483 = function(arg0, arg1, arg2) {
2875
- const ret = makeMutClosure(arg0, arg1, 170, __wbg_adapter_56);
3024
+ imports.wbg.__wbindgen_closure_wrapper495 = function(arg0, arg1, arg2) {
3025
+ const ret = makeMutClosure(arg0, arg1, 177, __wbg_adapter_56);
2876
3026
  return addHeapObject(ret);
2877
3027
  };
2878
- imports.wbg.__wbindgen_closure_wrapper485 = function(arg0, arg1, arg2) {
2879
- const ret = makeClosure(arg0, arg1, 170, __wbg_adapter_59);
3028
+ imports.wbg.__wbindgen_closure_wrapper497 = function(arg0, arg1, arg2) {
3029
+ const ret = makeClosure(arg0, arg1, 177, __wbg_adapter_59);
2880
3030
  return addHeapObject(ret);
2881
3031
  };
2882
- imports.wbg.__wbindgen_closure_wrapper487 = function(arg0, arg1, arg2) {
2883
- const ret = makeMutClosure(arg0, arg1, 170, __wbg_adapter_62);
3032
+ imports.wbg.__wbindgen_closure_wrapper499 = function(arg0, arg1, arg2) {
3033
+ const ret = makeMutClosure(arg0, arg1, 177, __wbg_adapter_62);
2884
3034
  return addHeapObject(ret);
2885
3035
  };
2886
- imports.wbg.__wbindgen_closure_wrapper1581 = function(arg0, arg1, arg2) {
2887
- const ret = makeMutClosure(arg0, arg1, 432, __wbg_adapter_65);
3036
+ imports.wbg.__wbindgen_closure_wrapper1617 = function(arg0, arg1, arg2) {
3037
+ const ret = makeMutClosure(arg0, arg1, 449, __wbg_adapter_65);
2888
3038
  return addHeapObject(ret);
2889
3039
  };
2890
3040
 
Binary file