@trust0/ridb-core 0.12.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.
@@ -0,0 +1,1002 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ */
5
+ export function main_js(): void;
6
+ /**
7
+ * @returns {boolean}
8
+ */
9
+ export function is_debug_mode(): boolean;
10
+ /**
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
+ * @param {Array<any>} args
18
+ */
19
+ export function __wbgtest_console_log(args: Array<any>): void;
20
+ /**
21
+ * Handler for `console.debug` invocations. See above.
22
+ * @param {Array<any>} args
23
+ */
24
+ export function __wbgtest_console_debug(args: Array<any>): void;
25
+ /**
26
+ * Handler for `console.info` invocations. See above.
27
+ * @param {Array<any>} args
28
+ */
29
+ export function __wbgtest_console_info(args: Array<any>): void;
30
+ /**
31
+ * Handler for `console.warn` invocations. See above.
32
+ * @param {Array<any>} args
33
+ */
34
+ export function __wbgtest_console_warn(args: Array<any>): void;
35
+ /**
36
+ * Handler for `console.error` invocations. See above.
37
+ * @param {Array<any>} args
38
+ */
39
+ export function __wbgtest_console_error(args: Array<any>): void;
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
+ /**
51
+ * Represents the type of operation to be performed on the collection.
52
+ */
53
+ export enum OpType {
54
+ /**
55
+ * Create operation.
56
+ */
57
+ CREATE = 0,
58
+ /**
59
+ * Update operation.
60
+ */
61
+ UPDATE = 1,
62
+ /**
63
+ * Delete operation.
64
+ */
65
+ DELETE = 2,
66
+ /**
67
+ * Query Operation.
68
+ */
69
+ QUERY = 3,
70
+ /**
71
+ * Count Operation.
72
+ */
73
+ COUNT = 4,
74
+ }
75
+
76
+ export type Operators<T> = {
77
+ $gte?: number,
78
+ $gt?: number
79
+ $lt?: number,
80
+ $lte?: number,
81
+ $eq?: T,
82
+ $ne?: T
83
+ };
84
+
85
+ export type InOperator<T> = { $in?: T[] };
86
+ export type NInOperator<T> = { $nin?: T[] };
87
+
88
+ export type OperatorOrType<T> = T extends number ?
89
+ T | Operators<T> | InOperator<T> | NInOperator<T> :
90
+ T | InOperator<T> | NInOperator<T>;
91
+
92
+ export type LogicalOperators<T extends SchemaType> = {
93
+ $and?: Partial<QueryType<T>>[];
94
+ $or?: Partial<QueryType<T>>[];
95
+ };
96
+
97
+ export type QueryType<T extends SchemaType> = Partial<{
98
+ [K in keyof T['properties']]: OperatorOrType<
99
+ ExtractType<
100
+ T['properties'][K]['type']
101
+ >
102
+ >
103
+ }> & LogicalOperators<T> | LogicalOperators<T>[];
104
+
105
+ export class Query<T extends SchemaType> {
106
+ constructor(query: QueryType<T>, schema:Schema<T>);
107
+ readonly query: QueryType<T>;
108
+ }
109
+
110
+
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
+
125
+ /**
126
+ * Represents an operation to be performed on a collection.
127
+ *
128
+ * @template T - The schema type of the collection.
129
+ */
130
+ export type Operation<T extends SchemaType = SchemaType> = {
131
+ /**
132
+ * The name of the collection on which the operation will be performed.
133
+ */
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
+ }
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> {
157
+ static create<SchemasCreate extends SchemaTypeRecord>(
158
+ dbName: string,
159
+ schemas: SchemasCreate,
160
+ options?: BaseStorageOptions
161
+ ): Promise<
162
+ BaseStorage<
163
+ SchemasCreate
164
+ >
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
185
+ }
186
+
187
+
188
+
189
+ /**
190
+ * Represents a database containing collections of documents.
191
+ * RIDB extends from this class and is used to expose collections.
192
+ *
193
+ * So if you specify:
194
+ * ```typescript
195
+ * const db = new RIDB(
196
+ * {
197
+ * schemas: {
198
+ * demo: {
199
+ * version: 0,
200
+ * primaryKey: 'id',
201
+ * type: SchemaFieldType.object,
202
+ * properties: {
203
+ * id: {
204
+ * type: SchemaFieldType.string,
205
+ * maxLength: 60
206
+ * }
207
+ * }
208
+ * }
209
+ * } as const
210
+ * }
211
+ * )
212
+ * ```
213
+ *
214
+ * 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.
215
+ *
216
+ * @template T - A record of schema types.
217
+ */
218
+ export class Database<T extends SchemaTypeRecord> {
219
+
220
+ /**
221
+ * Creates a new `Database` instance with the provided schemas and storage module.
222
+ *
223
+ * @template TS - A record of schema types.
224
+ * @param {TS} schemas - The schemas to use for the collections.
225
+ * @param migrations
226
+ * @param plugins
227
+ * @param options
228
+ * @param password
229
+ * @returns {Promise<Database<TS>>} A promise that resolves to the created `Database` instance.
230
+ */
231
+ static create<TS extends SchemaTypeRecord>(
232
+ db_name: string,
233
+ schemas: TS,
234
+ migrations: MigrationPathsForSchemas<TS> | MigrationPathsForSchema<TS[string]>,
235
+ plugins:Array<typeof BasePlugin>,
236
+ options: RIDBModule,
237
+ password?:string,
238
+ storage?: BaseStorage<TS>
239
+ ): Promise<Database<TS>>;
240
+
241
+ authenticate(password: string): Promise<boolean>;
242
+
243
+ /**
244
+ * The collections in the database.
245
+ *
246
+ * This is a read-only property where the key is the name of the collection and the value is a `Collection` instance.
247
+ */
248
+ readonly collections: {
249
+ [name in keyof T]: Collection<Schema<T[name]>>
250
+ }
251
+
252
+ readonly started: boolean;
253
+
254
+ /**
255
+ * Starts the database.
256
+ *
257
+ * @returns {Promise<void>} A promise that resolves when the database is started.
258
+ */
259
+ start(): Promise<void>;
260
+
261
+ /**
262
+ * Closes the database.
263
+ *
264
+ * @returns {Promise<void>} A promise that resolves when the database is closed.
265
+ */
266
+ close(): Promise<void>;
267
+ }
268
+
269
+ /**
270
+ * Represents a function type for creating storage with the provided schema type records.
271
+ *
272
+ * @template T - The schema type record.
273
+ * @param {T} records - The schema type records.
274
+ * @returns {Promise<InternalsRecord>} A promise that resolves to the created internals record.
275
+ */
276
+ export type CreateStorage = <T extends SchemaTypeRecord>(
277
+ records: T
278
+ ) => Promise<BaseStorage<T>>;
279
+
280
+ /**
281
+ * Represents a storage module with a method for creating storage.
282
+ */
283
+ export type RIDBModule = {
284
+
285
+ /**
286
+ * Plugin constructors array
287
+ */
288
+ apply: (plugins:Array<typeof BasePlugin>) => Array<BasePlugin>;
289
+ };
290
+
291
+
292
+
293
+ /**
294
+ * Represents an in-memory storage system extending the base storage functionality.
295
+ *
296
+ * @template T - The schema type.
297
+ */
298
+ export class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
299
+ /**
300
+ * Frees the resources used by the in-memory storage.
301
+ */
302
+ free(): void;
303
+
304
+ static create<SchemasCreate extends SchemaTypeRecord>(
305
+ dbName: string,
306
+ schemas: SchemasCreate,
307
+ ): Promise<
308
+ InMemory<
309
+ SchemasCreate
310
+ >
311
+ >;
312
+ }
313
+
314
+
315
+
316
+ /**
317
+ * Represents an IndexDB storage system extending the base storage functionality.
318
+ *
319
+ * @template T - The schema type.
320
+ */
321
+ export class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
322
+ /**
323
+ * Frees the resources used by the in-memory storage.
324
+ */
325
+ free(): void;
326
+
327
+ static create<SchemasCreate extends SchemaTypeRecord>(
328
+ dbName: string,
329
+ schemas: SchemasCreate,
330
+ ): Promise<
331
+ IndexDB<
332
+ SchemasCreate
333
+ >
334
+ >;
335
+ }
336
+
337
+
338
+
339
+ type Hook = (
340
+ schema: Schema<SchemaType>,
341
+ migration: MigrationPathsForSchema<SchemaType>,
342
+ doc: Doc<SchemaType>
343
+ ) => Doc<SchemaType>
344
+
345
+ type BasePluginOptions = {
346
+ docCreateHook?: Hook,
347
+ docRecoverHook?: Hook
348
+ }
349
+
350
+ export class BasePlugin implements BasePluginOptions {
351
+ docCreateHook?:Hook;
352
+ docRecoverHook?:Hook;
353
+ }
354
+
355
+
356
+
357
+ /**
358
+ * Represents the type definition for a schema.
359
+ */
360
+ export type SchemaType = {
361
+ /**
362
+ * The version of the schema.
363
+ */
364
+ version: number;
365
+
366
+ /**
367
+ * The primary key of the schema.
368
+ */
369
+ primaryKey: string;
370
+
371
+ /**
372
+ * The type of the schema.
373
+ */
374
+ type: string;
375
+ indexes?: string[];
376
+ encrypted?: string[];
377
+ /**
378
+ * The properties defined in the schema.
379
+ */
380
+ properties: {
381
+ [name: string]: Property;
382
+ };
383
+ };
384
+
385
+
386
+ /**
387
+ * Represents a schema, including its definition and related methods.
388
+ * You may be trying to build a storage, in any other can u won't need access tho this class.
389
+ * Check this example
390
+ *
391
+ * ```typescript
392
+ * class MyStorage extends <T extends SchemaTypeRecord> extends BaseStorage<T> {
393
+ * example() {
394
+ * const schema: Schema<any> = this.getSchema("mySchema")
395
+ * }
396
+ * }
397
+ * ```
398
+ * You alwayswill have access to getSchema through the Storage class.
399
+ *
400
+ * @template T - The schema type.
401
+ */
402
+ export class Schema<T extends SchemaType> {
403
+ /**
404
+ * The schema definition.
405
+ */
406
+ schema: Schema<T>;
407
+
408
+ /**
409
+ * Creates a new `Schema` instance from the provided definition.
410
+ *
411
+ * @template TS - The schema type.
412
+ * @param {TS} defi, Debugnition - The schema definition.
413
+ * @returns {Schema<TS>} The created `Schema` instance.
414
+ */
415
+ static create<TS extends SchemaType>(definition: TS): Schema<TS>;
416
+
417
+ /**
418
+ * The version of the schema.
419
+ */
420
+ readonly version: number;
421
+
422
+ /**
423
+ * The primary key of the schema.
424
+ */
425
+ readonly primaryKey: string;
426
+
427
+ /**
428
+ * The type of the schema.
429
+ */
430
+ readonly type: string;
431
+
432
+ /**
433
+ * An optional array of indexes.
434
+ */
435
+ /**
436
+ * An optional array of indexes.
437
+ */
438
+ readonly indexes?: (Extract<keyof T, string>)[];
439
+
440
+ /**
441
+ * An optional array of encrypted fields.
442
+ */
443
+ readonly encrypted?: (Extract<keyof T, string>)[];
444
+
445
+ /**
446
+ * The properties defined in the schema.
447
+ */
448
+ readonly properties: {
449
+ [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];
450
+ } & {
451
+ [K in keyof T['properties'] as T['properties'][K]['required'] extends false ? never : K]: T['properties'][K];
452
+ };
453
+ /**
454
+ * Converts the schema to a JSON representation.
455
+ *
456
+ * @returns {SchemaType} The JSON representation of the schema.
457
+ */
458
+ toJSON(): SchemaType;
459
+
460
+ validate(document: Doc<Schema<T>>): boolean;
461
+ }
462
+
463
+
464
+
465
+ export type InternalsRecord = {
466
+ [name: string]: BaseStorage<SchemaTypeRecord>
467
+ };
468
+ /**
469
+ * ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
470
+ *
471
+ * @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
472
+ *
473
+ * @example
474
+ * type StringType = ExtractType<'string'>; // StringType is string
475
+ * type NumberType = ExtractType<'number'>; // NumberType is number
476
+ * type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
477
+ * type ObjectType = ExtractType<'object'>; // ObjectType is object
478
+ * type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
479
+ */
480
+ export type ExtractType<T extends string> =
481
+ T extends "string" ? string :
482
+ T extends "number" ? number :
483
+ T extends "boolean" ? boolean :
484
+ T extends "object" ? object :
485
+ T extends "array" ? any[] :
486
+ never;
487
+
488
+ export type IsOptional<T> = T extends { required: false } ? true :
489
+ T extends { default: any } ? true : false;
490
+
491
+ /**
492
+ * Doc is a utility type that transforms a schema type into a document type where each property is mapped to its extracted type.
493
+ *
494
+ * @template T - A schema type with a 'properties' field where each property's type is represented as a string.
495
+ *
496
+ * type Document = Doc<Schema>; // Document is { name: string; age: number; }
497
+ */
498
+ export type Doc<T extends SchemaType> = {
499
+ [K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? K : never]?:
500
+ ExtractType<T["properties"][K]["type"]>
501
+ } & {
502
+ [K in keyof T["properties"] as IsOptional<T["properties"][K]> extends false ? K : never]:
503
+ ExtractType<T["properties"][K]["type"]>
504
+ } & {
505
+ __version?: number;
506
+ };
507
+
508
+ export type QueryOptions = {
509
+ limit?: number;
510
+ offset?: number;
511
+ }
512
+
513
+ /**
514
+ * Collection is a class that represents a collection of documents in a database.
515
+ * @template T - A schema type defining the structure of the documents in the collection.
516
+ */
517
+ export class Collection<T extends SchemaType> {
518
+ /**
519
+ * Finds all documents in the collection.
520
+ *
521
+ * @returns A promise that resolves to an array of documents.
522
+ */
523
+ find(query: QueryType<T>, options?: QueryOptions): Promise<Doc<T>[]>;
524
+ /**
525
+ * count all documents in the collection.
526
+ *
527
+ * @returns A promise that resolves to an array of documents.
528
+ */
529
+ count(query: QueryType<T>, options?: QueryOptions): Promise<number>;
530
+ /**
531
+ * Finds a single document in the collection by its ID.
532
+ *
533
+ * @param id - The ID of the document to find.
534
+ * @returns A promise that resolves to the found document.
535
+ */
536
+ findById(id: string): Promise<Doc<T>>;
537
+ /**
538
+ * Updates a document in the collection by its ID.
539
+ *
540
+ * @param id - The ID of the document to update.
541
+ * @param document - A partial document containing the fields to update.
542
+ * @returns A promise that resolves when the update is complete.
543
+ */
544
+ update(document: Partial<Doc<T>>): Promise<void>;
545
+ /**
546
+ * Creates a new document in the collection.
547
+ *
548
+ * @param document - The document to create.
549
+ * @returns A promise that resolves to the created document.
550
+ */
551
+ create(document: Doc<T>): Promise<Doc<T>>;
552
+ /**
553
+ * Deletes a document in the collection by its ID.
554
+ *
555
+ * @param id - The ID of the document to delete.
556
+ * @returns A promise that resolves when the deletion is complete.
557
+ */
558
+ delete(id: string): Promise<void>;
559
+ }
560
+
561
+
562
+
563
+
564
+ export type EnumerateUpTo<
565
+ N extends number,
566
+ Acc extends number[] = []
567
+ > = Acc['length'] extends N ?
568
+ Acc[number]:
569
+ EnumerateUpTo<N, [...Acc, Acc['length']]> ;
570
+
571
+ export type EnumerateFrom1To<
572
+ N extends number
573
+ > = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
574
+
575
+ export type IsVersionGreaterThan0<
576
+ V extends number
577
+ > = V extends 0 ? false : true;
578
+
579
+ export type AnyVersionGreaterThan1<
580
+ T extends Record<string, SchemaType>
581
+ > = true extends {
582
+ [K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
583
+ } [keyof T] ? true : false;
584
+
585
+ export type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
586
+
587
+ export type MigrationPathsForSchema<
588
+ T extends SchemaType
589
+ > = T['version'] extends 0 ? {}: // No migrations needed for version 1
590
+ {
591
+ [K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
592
+ };
593
+
594
+ export type MigrationPathsForSchemas<
595
+ T extends SchemaTypeRecord
596
+ > = {
597
+ [K in keyof T]: MigrationPathsForSchema<T[K]>;
598
+ };
599
+
600
+ export type MigrationsParameter<
601
+ T extends SchemaTypeRecord
602
+ > = AnyVersionGreaterThan1<T> extends true ?
603
+ {
604
+ migrations: MigrationPathsForSchemas<T>
605
+ }:
606
+ {
607
+ migrations?: never
608
+ };
609
+
610
+
611
+
612
+ /**
613
+ * Represents a property within a schema, including various constraints and nested properties.
614
+ */
615
+ export class Property {
616
+ /**
617
+ * The type of the property.
618
+ */
619
+ readonly type: string;
620
+
621
+ /**
622
+ * The version of the property, if applicable.
623
+ */
624
+ readonly version?: number;
625
+
626
+ /**
627
+ * The primary key of the property, if applicable.
628
+ */
629
+ readonly primaryKey?: string;
630
+
631
+ /**
632
+ * An optional array of nested properties for array-type properties.
633
+ */
634
+ readonly items?: Property;
635
+
636
+ /**
637
+ * The maximum number of items for array-type properties, if applicable.
638
+ */
639
+ readonly maxItems?: number;
640
+
641
+ /**
642
+ * The minimum number of items for array-type properties, if applicable.
643
+ */
644
+ readonly minItems?: number;
645
+
646
+ /**
647
+ * The maximum length for string-type properties, if applicable.
648
+ */
649
+ readonly maxLength?: number;
650
+
651
+ /**
652
+ * The minimum length for string-type properties, if applicable.
653
+ */
654
+ readonly minLength?: number;
655
+
656
+ /**
657
+ * An optional array of required fields for object-type properties.
658
+ */
659
+ readonly required?: boolean;
660
+
661
+ /**
662
+ * An optional default value for the property.
663
+ */
664
+ readonly default?: any;
665
+
666
+ /**
667
+ * An optional map of nested properties for object-type properties.
668
+ */
669
+ readonly properties?: {
670
+ [name: string]: Property;
671
+ };
672
+ }
673
+
674
+
675
+
676
+ /**
677
+ * Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
678
+ */
679
+ export type SchemaTypeRecord = {
680
+ [name: string]: SchemaType
681
+ };
682
+
683
+ export abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
684
+ constructor(
685
+ name: string,
686
+ schemas: Schemas
687
+ );
688
+ abstract start(): Promise<void>;
689
+ abstract close(): Promise<void>;
690
+ abstract count(
691
+ colectionName: keyof Schemas,
692
+ query: QueryType<Schemas[keyof Schemas]>,
693
+ options?: QueryOptions
694
+ ): Promise<number>;
695
+ abstract findDocumentById(
696
+ collectionName: keyof Schemas,
697
+ id: string
698
+ ): Promise<Doc<Schemas[keyof Schemas]> | null>;
699
+ abstract find(
700
+ collectionName: keyof Schemas,
701
+ query: QueryType<Schemas[keyof Schemas]>,
702
+ options?: QueryOptions
703
+ ): Promise<Doc<Schemas[keyof Schemas]>[]>;
704
+ abstract write(
705
+ op: Operation<Schemas[keyof Schemas]>
706
+ ): Promise<Doc<Schemas[keyof Schemas]>>;
707
+ }
708
+
709
+ /**
710
+ */
711
+ export class RIDBError {
712
+ /**
713
+ ** Return copy of self without private attributes.
714
+ */
715
+ toJSON(): Object;
716
+ /**
717
+ * Return stringified version of self.
718
+ */
719
+ toString(): string;
720
+ free(): void;
721
+ /**
722
+ * @param {string} err_type
723
+ * @param {string} message
724
+ * @param {number} code
725
+ */
726
+ constructor(err_type: string, message: string, code: number);
727
+ /**
728
+ * @param {any} err
729
+ * @returns {RIDBError}
730
+ */
731
+ static from(err: any): RIDBError;
732
+ /**
733
+ * @param {string} err
734
+ * @param {number} code
735
+ * @returns {RIDBError}
736
+ */
737
+ static error(err: string, code: number): RIDBError;
738
+ /**
739
+ * @param {string} err
740
+ * @param {number} code
741
+ * @returns {RIDBError}
742
+ */
743
+ static query(err: string, code: number): RIDBError;
744
+ /**
745
+ * @param {string} err
746
+ * @param {number} code
747
+ * @returns {RIDBError}
748
+ */
749
+ static authentication(err: string, code: number): RIDBError;
750
+ /**
751
+ * @param {string} err
752
+ * @param {number} code
753
+ * @returns {RIDBError}
754
+ */
755
+ static serialisation(err: string, code: number): RIDBError;
756
+ /**
757
+ * @param {string} err
758
+ * @param {number} code
759
+ * @returns {RIDBError}
760
+ */
761
+ static validation(err: string, code: number): RIDBError;
762
+ /**
763
+ * @param {string} err
764
+ * @param {number} code
765
+ * @returns {RIDBError}
766
+ */
767
+ static hook(err: string, code: number): RIDBError;
768
+ /**
769
+ */
770
+ readonly code: any;
771
+ /**
772
+ */
773
+ readonly message: string;
774
+ /**
775
+ */
776
+ readonly type: string;
777
+ }
778
+ /**
779
+ * Runtime test harness support instantiated in JS.
780
+ *
781
+ * The node.js entry script instantiates a `Context` here which is used to
782
+ * drive test execution.
783
+ */
784
+ export class WasmBindgenTestContext {
785
+ free(): void;
786
+ /**
787
+ * Creates a new context ready to run tests.
788
+ *
789
+ * A `Context` is the main structure through which test execution is
790
+ * coordinated, and this will collect output and results for all executed
791
+ * tests.
792
+ */
793
+ constructor();
794
+ /**
795
+ * Inform this context about runtime arguments passed to the test
796
+ * harness.
797
+ * @param {any[]} args
798
+ */
799
+ args(args: any[]): void;
800
+ /**
801
+ * Executes a list of tests, returning a promise representing their
802
+ * eventual completion.
803
+ *
804
+ * This is the main entry point for executing tests. All the tests passed
805
+ * in are the JS `Function` object that was plucked off the
806
+ * `WebAssembly.Instance` exports list.
807
+ *
808
+ * The promise returned resolves to either `true` if all tests passed or
809
+ * `false` if at least one test failed.
810
+ * @param {any[]} tests
811
+ * @returns {Promise<any>}
812
+ */
813
+ run(tests: any[]): Promise<any>;
814
+ }
815
+
816
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
817
+
818
+ export interface InitOutput {
819
+ readonly memory: WebAssembly.Memory;
820
+ readonly __wbg_query_free: (a: number) => void;
821
+ readonly query_new: (a: number, b: number, c: number) => void;
822
+ readonly query_query: (a: number, b: number) => void;
823
+ readonly query_get_properties: (a: number, b: number) => void;
824
+ readonly query_parse: (a: number, b: number) => void;
825
+ readonly query_process_query: (a: number, b: number, c: number) => void;
826
+ readonly query_get: (a: number, b: number, c: number, d: number) => void;
827
+ readonly __wbgt_test_get_properties_simple_fields_6: (a: number) => void;
828
+ readonly __wbgt_test_get_properties_with_operators_7: (a: number) => void;
829
+ readonly __wbgt_test_get_properties_with_logical_operators_8: (a: number) => void;
830
+ readonly __wbgt_test_get_properties_nested_operators_9: (a: number) => void;
831
+ readonly __wbgt_test_get_properties_array_values_10: (a: number) => void;
832
+ readonly __wbgt_test_get_properties_empty_query_11: (a: number) => void;
833
+ readonly __wbgt_test_get_properties_deeply_nested_12: (a: number) => void;
834
+ readonly __wbgt_test_get_properties_with_multiple_same_props_13: (a: number) => void;
835
+ readonly __wbgt_test_get_properties_with_array_at_top_level_14: (a: number) => void;
836
+ readonly __wbgt_test_query_parse_operator_wrong_type_15: (a: number) => void;
837
+ readonly __wbgt_test_query_parse_in_operator_16: (a: number) => void;
838
+ readonly __wbgt_test_query_parse_in_operator_wrong_type_17: (a: number) => void;
839
+ readonly __wbgt_test_query_get_query_normalization_simple_attributes_18: (a: number) => void;
840
+ readonly __wbgt_test_query_get_query_normalization_with_logical_operator_19: (a: number) => void;
841
+ readonly __wbgt_test_query_get_query_normalization_nested_logical_operators_20: (a: number) => void;
842
+ readonly __wbgt_test_query_get_query_normalization_only_logical_operator_21: (a: number) => void;
843
+ readonly __wbgt_test_query_get_query_normalization_complex_mixed_22: (a: number) => void;
844
+ readonly __wbgt_test_query_parse_empty_query_23: (a: number) => void;
845
+ readonly __wbgt_test_query_parse_age_query_24: (a: number) => void;
846
+ readonly __wbgt_test_query_parse_non_object_query_25: (a: number) => void;
847
+ readonly __wbgt_test_query_parse_multiple_operators_26: (a: number) => void;
848
+ readonly __wbgt_test_query_parse_invalid_in_operator_27: (a: number) => void;
849
+ readonly __wbgt_test_query_parse_empty_logical_operators_28: (a: number) => void;
850
+ readonly __wbgt_test_query_parse_nin_operator_29: (a: number) => void;
851
+ readonly __wbgt_test_query_parse_nin_operator_wrong_type_30: (a: number) => void;
852
+ readonly __wbgt_test_query_parse_eq_operator_31: (a: number) => void;
853
+ readonly __wbgt_test_query_parse_eq_operator_wrong_type_32: (a: number) => void;
854
+ readonly __wbgt_test_query_parse_ne_operator_33: (a: number) => void;
855
+ readonly __wbgt_test_query_parse_ne_operator_wrong_type_34: (a: number) => void;
856
+ readonly corestorage_new: () => number;
857
+ readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
858
+ readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
859
+ readonly corestorage_matchesQuery: (a: number, b: number, c: number, d: number) => void;
860
+ readonly __wbg_operation_free: (a: number) => void;
861
+ readonly operation_collection: (a: number, b: number) => void;
862
+ readonly operation_opType: (a: number) => number;
863
+ readonly operation_data: (a: number) => number;
864
+ readonly operation_primaryKeyField: (a: number) => number;
865
+ readonly operation_primaryKey: (a: number) => number;
866
+ readonly operation_primaryKeyIndex: (a: number, b: number) => void;
867
+ readonly main_js: () => void;
868
+ readonly is_debug_mode: () => number;
869
+ readonly __wbg_corestorage_free: (a: number) => void;
870
+ readonly __wbg_basestorage_free: (a: number) => void;
871
+ readonly basestorage_new: (a: number, b: number, c: number, d: number, e: number) => void;
872
+ readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
873
+ readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
874
+ readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
875
+ readonly basestorage_core: (a: number, b: number) => void;
876
+ readonly __wbg_ridberror_free: (a: number) => void;
877
+ readonly ridberror_new: (a: number, b: number, c: number, d: number, e: number) => number;
878
+ readonly ridberror_type: (a: number, b: number) => void;
879
+ readonly ridberror_code: (a: number) => number;
880
+ readonly ridberror_message: (a: number, b: number) => void;
881
+ readonly ridberror_from: (a: number) => number;
882
+ readonly ridberror_error: (a: number, b: number, c: number) => number;
883
+ readonly ridberror_query: (a: number, b: number, c: number) => number;
884
+ readonly ridberror_authentication: (a: number, b: number, c: number) => number;
885
+ readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
886
+ readonly ridberror_validation: (a: number, b: number, c: number) => number;
887
+ readonly ridberror_hook: (a: number, b: number, c: number) => number;
888
+ readonly __wbg_database_free: (a: number) => void;
889
+ readonly database_start: (a: number) => number;
890
+ readonly database_close: (a: number) => number;
891
+ readonly database_started: (a: number) => number;
892
+ readonly database_authenticate: (a: number, b: number, c: number) => number;
893
+ readonly database_collections: (a: number, b: number) => void;
894
+ readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
895
+ readonly __wbg_queryoptions_free: (a: number) => void;
896
+ readonly queryoptions_limit: (a: number, b: number) => void;
897
+ readonly queryoptions_offset: (a: number, b: number) => void;
898
+ readonly __wbg_inmemory_free: (a: number) => void;
899
+ readonly inmemory_create: (a: number, b: number, c: number) => number;
900
+ readonly inmemory_write: (a: number, b: number) => number;
901
+ readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
902
+ readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
903
+ readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
904
+ readonly inmemory_close: (a: number) => number;
905
+ readonly inmemory_start: (a: number) => number;
906
+ readonly __wbg_indexdb_free: (a: number) => void;
907
+ readonly indexdb_get_stores: (a: number, b: number) => void;
908
+ readonly indexdb_get_store: (a: number, b: number, c: number, d: number) => void;
909
+ readonly indexdb_create: (a: number, b: number, c: number) => number;
910
+ readonly indexdb_write: (a: number, b: number) => number;
911
+ readonly indexdb_find: (a: number, b: number, c: number, d: number, e: number) => number;
912
+ readonly indexdb_findDocumentById: (a: number, b: number, c: number, d: number) => number;
913
+ readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
914
+ readonly indexdb_close: (a: number) => number;
915
+ readonly indexdb_start: (a: number) => number;
916
+ readonly __wbg_baseplugin_free: (a: number) => void;
917
+ readonly baseplugin_new: (a: number, b: number, c: number) => void;
918
+ readonly baseplugin_name: (a: number) => number;
919
+ readonly baseplugin_get_doc_create_hook: (a: number) => number;
920
+ readonly baseplugin_get_doc_recover_hook: (a: number) => number;
921
+ readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
922
+ readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
923
+ readonly __wbg_schema_free: (a: number) => void;
924
+ readonly schema_validate: (a: number, b: number, c: number) => void;
925
+ readonly schema_is_valid: (a: number, b: number) => void;
926
+ readonly schema_create: (a: number, b: number) => void;
927
+ readonly schema_version: (a: number) => number;
928
+ readonly schema_primaryKey: (a: number, b: number) => void;
929
+ readonly schema_type: (a: number, b: number) => void;
930
+ readonly schema_indexes: (a: number, b: number) => void;
931
+ readonly schema_encrypted: (a: number, b: number) => void;
932
+ readonly schema_properties: (a: number, b: number) => void;
933
+ readonly __wbgt_test_schema_creation_3: (a: number) => void;
934
+ readonly __wbgt_test_schema_validation_4: (a: number) => void;
935
+ readonly __wbgt_test_invalid_schema_5: (a: number) => void;
936
+ readonly __wbg_collection_free: (a: number) => void;
937
+ readonly collection_name: (a: number, b: number) => void;
938
+ readonly collection_schema: (a: number, b: number) => void;
939
+ readonly collection_find: (a: number, b: number, c: number) => number;
940
+ readonly collection_parse_query_options: (a: number, b: number, c: number) => void;
941
+ readonly collection_count: (a: number, b: number, c: number) => number;
942
+ readonly collection_findById: (a: number, b: number) => number;
943
+ readonly collection_update: (a: number, b: number) => number;
944
+ readonly collection_create: (a: number, b: number) => number;
945
+ readonly collection_delete: (a: number, b: number) => number;
946
+ readonly __wbg_property_free: (a: number) => void;
947
+ readonly property_is_valid: (a: number, b: number) => void;
948
+ readonly property_type: (a: number) => number;
949
+ readonly property_items: (a: number, b: number) => void;
950
+ readonly property_maxItems: (a: number, b: number) => void;
951
+ readonly property_minItems: (a: number, b: number) => void;
952
+ readonly property_maxLength: (a: number, b: number) => void;
953
+ readonly property_minLength: (a: number, b: number) => void;
954
+ readonly property_properties: (a: number, b: number) => void;
955
+ readonly __wbgt_test_property_creation_0: (a: number) => void;
956
+ readonly __wbgt_test_property_validation_1: (a: number) => void;
957
+ readonly __wbgt_test_invalid_property_2: (a: number) => void;
958
+ readonly __wbg_wasmbindgentestcontext_free: (a: number) => void;
959
+ readonly wasmbindgentestcontext_new: () => number;
960
+ readonly wasmbindgentestcontext_args: (a: number, b: number, c: number) => void;
961
+ readonly wasmbindgentestcontext_run: (a: number, b: number, c: number) => number;
962
+ readonly __wbgtest_console_log: (a: number) => void;
963
+ readonly __wbgtest_console_debug: (a: number) => void;
964
+ readonly __wbgtest_console_info: (a: number) => void;
965
+ readonly __wbgtest_console_warn: (a: number) => void;
966
+ readonly __wbgtest_console_error: (a: number) => void;
967
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
968
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
969
+ readonly __wbindgen_export_2: WebAssembly.Table;
970
+ readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h231d9c59fed64ed4: (a: number, b: number, c: number) => void;
971
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
972
+ 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;
973
+ readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8d2923cd4e648893: (a: number, b: number, c: number) => number;
974
+ readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf066437ba5ed1b74: (a: number, b: number, c: number) => void;
975
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
976
+ readonly __wbindgen_exn_store: (a: number) => void;
977
+ readonly wasm_bindgen__convert__closures__invoke0_mut__hf4bced6426ca6f31: (a: number, b: number) => void;
978
+ readonly wasm_bindgen__convert__closures__invoke3_mut__h425269a7185d1f5b: (a: number, b: number, c: number, d: number, e: number) => void;
979
+ readonly wasm_bindgen__convert__closures__invoke2_mut__h1b9fff078715ef14: (a: number, b: number, c: number, d: number) => void;
980
+ readonly __wbindgen_start: () => void;
981
+ }
982
+
983
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
984
+ /**
985
+ * Instantiates the given `module`, which can either be bytes or
986
+ * a precompiled `WebAssembly.Module`.
987
+ *
988
+ * @param {SyncInitInput} module
989
+ *
990
+ * @returns {InitOutput}
991
+ */
992
+ export function initSync(module: SyncInitInput): InitOutput;
993
+
994
+ /**
995
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
996
+ * for everything else, calls `WebAssembly.instantiate` directly.
997
+ *
998
+ * @param {InitInput | Promise<InitInput>} module_or_path
999
+ *
1000
+ * @returns {Promise<InitOutput>}
1001
+ */
1002
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;