@trust0/ridb-core 1.7.33 → 1.7.34
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/build/ridb_core.d.ts +371 -371
- package/build/ridb_core.js +83 -55
- package/build/ridb_core.mjs +83 -55
- package/build/ridb_core_bg.mjs +1 -1
- package/package.json +1 -1
package/build/ridb_core.d.ts
CHANGED
|
@@ -38,16 +38,6 @@ declare function __wbgtest_console_warn(args: Array<any>): void;
|
|
|
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
|
-
/**
|
|
51
41
|
* Represents the type of operation to be performed on the collection.
|
|
52
42
|
*/
|
|
53
43
|
declare enum OpType {
|
|
@@ -72,6 +62,16 @@ declare enum OpType {
|
|
|
72
62
|
*/
|
|
73
63
|
COUNT = 4,
|
|
74
64
|
}
|
|
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
75
|
|
|
76
76
|
type InternalsRecord = {
|
|
77
77
|
[name: string]: BaseStorage<SchemaTypeRecord>
|
|
@@ -192,6 +192,46 @@ declare class Collection<T extends SchemaType> {
|
|
|
192
192
|
|
|
193
193
|
|
|
194
194
|
|
|
195
|
+
declare class CoreStorage {
|
|
196
|
+
/**
|
|
197
|
+
* @param {any} document
|
|
198
|
+
* @param {Query} query
|
|
199
|
+
* @returns {boolean}
|
|
200
|
+
*/
|
|
201
|
+
matchesQuery(document: any, query: Query<any>): boolean;
|
|
202
|
+
getPrimaryKeyTyped(value: any): string | number;
|
|
203
|
+
getIndexes(schema: Schema<any>, op: Operation): string[];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Represents an operation to be performed on a collection.
|
|
210
|
+
*
|
|
211
|
+
* @template T - The schema type of the collection.
|
|
212
|
+
*/
|
|
213
|
+
type Operation<T extends SchemaType = SchemaType> = {
|
|
214
|
+
/**
|
|
215
|
+
* The name of the collection on which the operation will be performed.
|
|
216
|
+
*/
|
|
217
|
+
collection: string,
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
|
|
221
|
+
*/
|
|
222
|
+
opType: OpType,
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* The data involved in the operation, conforming to the schema type.
|
|
226
|
+
*/
|
|
227
|
+
data: Doc<T>,
|
|
228
|
+
|
|
229
|
+
primaryKeyField?: string,
|
|
230
|
+
primaryKey?: string
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
195
235
|
type BaseStorageOptions = {
|
|
196
236
|
[name:string]:string | boolean | number
|
|
197
237
|
}
|
|
@@ -230,24 +270,123 @@ declare class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInter
|
|
|
230
270
|
|
|
231
271
|
|
|
232
272
|
/**
|
|
233
|
-
* Represents
|
|
273
|
+
* Represents a database containing collections of documents.
|
|
274
|
+
* RIDB extends from this class and is used to expose collections.
|
|
275
|
+
*
|
|
276
|
+
* So if you specify:
|
|
277
|
+
* ```typescript
|
|
278
|
+
* const db = new RIDB(
|
|
279
|
+
* {
|
|
280
|
+
* schemas: {
|
|
281
|
+
* demo: {
|
|
282
|
+
* version: 0,
|
|
283
|
+
* primaryKey: 'id',
|
|
284
|
+
* type: SchemaFieldType.object,
|
|
285
|
+
* properties: {
|
|
286
|
+
* id: {
|
|
287
|
+
* type: SchemaFieldType.string,
|
|
288
|
+
* maxLength: 60
|
|
289
|
+
* }
|
|
290
|
+
* }
|
|
291
|
+
* }
|
|
292
|
+
* } as const
|
|
293
|
+
* }
|
|
294
|
+
* )
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* 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.
|
|
234
298
|
*
|
|
235
|
-
* @template T -
|
|
299
|
+
* @template T - A record of schema types.
|
|
236
300
|
*/
|
|
237
|
-
declare class
|
|
301
|
+
declare class Database<T extends SchemaTypeRecord> {
|
|
302
|
+
|
|
238
303
|
/**
|
|
239
|
-
*
|
|
304
|
+
* Creates a new `Database` instance with the provided schemas and storage module.
|
|
305
|
+
*
|
|
306
|
+
* @template TS - A record of schema types.
|
|
307
|
+
* @param {TS} schemas - The schemas to use for the collections.
|
|
308
|
+
* @param migrations
|
|
309
|
+
* @param plugins
|
|
310
|
+
* @param options
|
|
311
|
+
* @param password
|
|
312
|
+
* @returns {Promise<Database<TS>>} A promise that resolves to the created `Database` instance.
|
|
240
313
|
*/
|
|
241
|
-
|
|
314
|
+
static create<TS extends SchemaTypeRecord>(
|
|
315
|
+
db_name: string,
|
|
316
|
+
schemas: TS,
|
|
317
|
+
migrations: MigrationPathsForSchemas<TS> | MigrationPathsForSchema<TS[string]>,
|
|
318
|
+
plugins:Array<typeof BasePlugin>,
|
|
319
|
+
options: RIDBModule,
|
|
320
|
+
password?:string,
|
|
321
|
+
storage?: BaseStorage<TS>
|
|
322
|
+
): Promise<Database<TS>>;
|
|
242
323
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
324
|
+
authenticate(password: string): Promise<boolean>;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* The collections in the database.
|
|
328
|
+
*
|
|
329
|
+
* This is a read-only property where the key is the name of the collection and the value is a `Collection` instance.
|
|
330
|
+
*/
|
|
331
|
+
readonly collections: {
|
|
332
|
+
[name in keyof T]: Collection<Schema<T[name]>>
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
readonly started: boolean;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Starts the database.
|
|
339
|
+
*
|
|
340
|
+
* @returns {Promise<void>} A promise that resolves when the database is started.
|
|
341
|
+
*/
|
|
342
|
+
start(): Promise<void>;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Closes the database.
|
|
346
|
+
*
|
|
347
|
+
* @returns {Promise<void>} A promise that resolves when the database is closed.
|
|
348
|
+
*/
|
|
349
|
+
close(): Promise<void>;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Represents a function type for creating storage with the provided schema type records.
|
|
354
|
+
*
|
|
355
|
+
* @template T - The schema type record.
|
|
356
|
+
* @param {T} records - The schema type records.
|
|
357
|
+
* @returns {Promise<InternalsRecord>} A promise that resolves to the created internals record.
|
|
358
|
+
*/
|
|
359
|
+
type CreateStorage = <T extends SchemaTypeRecord>(
|
|
360
|
+
records: T
|
|
361
|
+
) => Promise<BaseStorage<T>>;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Represents a storage module with a method for creating storage.
|
|
365
|
+
*/
|
|
366
|
+
type RIDBModule = {
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Plugin constructors array
|
|
370
|
+
*/
|
|
371
|
+
apply: (plugins:Array<typeof BasePlugin>) => Array<BasePlugin>;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
type Hook = (
|
|
377
|
+
schema: Schema<SchemaType>,
|
|
378
|
+
migration: MigrationPathsForSchema<SchemaType>,
|
|
379
|
+
doc: Doc<SchemaType>
|
|
380
|
+
) => Doc<SchemaType>
|
|
381
|
+
|
|
382
|
+
type BasePluginOptions = {
|
|
383
|
+
docCreateHook?: Hook,
|
|
384
|
+
docRecoverHook?: Hook
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
declare class BasePlugin implements BasePluginOptions {
|
|
388
|
+
docCreateHook?:Hook;
|
|
389
|
+
docRecoverHook?:Hook;
|
|
251
390
|
}
|
|
252
391
|
|
|
253
392
|
|
|
@@ -289,66 +428,73 @@ declare class Query<T extends SchemaType> {
|
|
|
289
428
|
|
|
290
429
|
|
|
291
430
|
/**
|
|
292
|
-
* Represents
|
|
431
|
+
* Represents an in-memory storage system extending the base storage functionality.
|
|
432
|
+
*
|
|
433
|
+
* @template T - The schema type.
|
|
293
434
|
*/
|
|
294
|
-
declare class
|
|
435
|
+
declare class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
295
436
|
/**
|
|
296
|
-
*
|
|
437
|
+
* Frees the resources used by the in-memory storage.
|
|
297
438
|
*/
|
|
298
|
-
|
|
439
|
+
free(): void;
|
|
299
440
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
441
|
+
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
442
|
+
dbName: string,
|
|
443
|
+
schemas: SchemasCreate,
|
|
444
|
+
): Promise<
|
|
445
|
+
InMemory<
|
|
446
|
+
SchemasCreate
|
|
447
|
+
>
|
|
448
|
+
>;
|
|
449
|
+
}
|
|
304
450
|
|
|
305
|
-
/**
|
|
306
|
-
* The primary key of the property, if applicable.
|
|
307
|
-
*/
|
|
308
|
-
readonly primaryKey?: string;
|
|
309
451
|
|
|
310
|
-
/**
|
|
311
|
-
* An optional array of nested properties for array-type properties.
|
|
312
|
-
*/
|
|
313
|
-
readonly items?: Property;
|
|
314
452
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
453
|
+
type EnumerateUpTo<
|
|
454
|
+
N extends number,
|
|
455
|
+
Acc extends number[] = []
|
|
456
|
+
> = Acc['length'] extends N ?
|
|
457
|
+
Acc[number]:
|
|
458
|
+
EnumerateUpTo<N, [...Acc, Acc['length']]> ;
|
|
319
459
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
readonly minItems?: number;
|
|
460
|
+
type EnumerateFrom1To<
|
|
461
|
+
N extends number
|
|
462
|
+
> = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
|
|
324
463
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
readonly maxLength?: number;
|
|
464
|
+
type IsVersionGreaterThan0<
|
|
465
|
+
V extends number
|
|
466
|
+
> = V extends 0 ? false : true;
|
|
329
467
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
468
|
+
type AnyVersionGreaterThan1<
|
|
469
|
+
T extends Record<string, SchemaType>
|
|
470
|
+
> = true extends {
|
|
471
|
+
[K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
|
|
472
|
+
} [keyof T] ? true : false;
|
|
334
473
|
|
|
335
|
-
|
|
336
|
-
* An optional array of required fields for object-type properties.
|
|
337
|
-
*/
|
|
338
|
-
readonly required?: boolean;
|
|
474
|
+
type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
|
|
339
475
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
476
|
+
type MigrationPathsForSchema<
|
|
477
|
+
T extends SchemaType
|
|
478
|
+
> = T['version'] extends 0 ? {}: // No migrations needed for version 1
|
|
479
|
+
{
|
|
480
|
+
[K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
|
|
481
|
+
};
|
|
344
482
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
483
|
+
type MigrationPathsForSchemas<
|
|
484
|
+
T extends SchemaTypeRecord
|
|
485
|
+
> = {
|
|
486
|
+
[K in keyof T]: MigrationPathsForSchema<T[K]>;
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
type MigrationsParameter<
|
|
490
|
+
T extends SchemaTypeRecord
|
|
491
|
+
> = AnyVersionGreaterThan1<T> extends true ?
|
|
492
|
+
{
|
|
493
|
+
migrations: MigrationPathsForSchemas<T>
|
|
494
|
+
}:
|
|
495
|
+
{
|
|
496
|
+
migrations?: never
|
|
350
497
|
};
|
|
351
|
-
}
|
|
352
498
|
|
|
353
499
|
|
|
354
500
|
|
|
@@ -460,120 +606,66 @@ declare class Schema<T extends SchemaType> {
|
|
|
460
606
|
|
|
461
607
|
|
|
462
608
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
type
|
|
471
|
-
N extends number
|
|
472
|
-
> = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
|
|
473
|
-
|
|
474
|
-
type IsVersionGreaterThan0<
|
|
475
|
-
V extends number
|
|
476
|
-
> = V extends 0 ? false : true;
|
|
477
|
-
|
|
478
|
-
type AnyVersionGreaterThan1<
|
|
479
|
-
T extends Record<string, SchemaType>
|
|
480
|
-
> = true extends {
|
|
481
|
-
[K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
|
|
482
|
-
} [keyof T] ? true : false;
|
|
483
|
-
|
|
484
|
-
type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
|
|
485
|
-
|
|
486
|
-
type MigrationPathsForSchema<
|
|
487
|
-
T extends SchemaType
|
|
488
|
-
> = T['version'] extends 0 ? {}: // No migrations needed for version 1
|
|
489
|
-
{
|
|
490
|
-
[K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
type MigrationPathsForSchemas<
|
|
494
|
-
T extends SchemaTypeRecord
|
|
495
|
-
> = {
|
|
496
|
-
[K in keyof T]: MigrationPathsForSchema<T[K]>;
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
type MigrationsParameter<
|
|
500
|
-
T extends SchemaTypeRecord
|
|
501
|
-
> = AnyVersionGreaterThan1<T> extends true ?
|
|
502
|
-
{
|
|
503
|
-
migrations: MigrationPathsForSchemas<T>
|
|
504
|
-
}:
|
|
505
|
-
{
|
|
506
|
-
migrations?: never
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
|
|
609
|
+
/**
|
|
610
|
+
* Represents a property within a schema, including various constraints and nested properties.
|
|
611
|
+
*/
|
|
612
|
+
declare class Property {
|
|
613
|
+
/**
|
|
614
|
+
* The type of the property.
|
|
615
|
+
*/
|
|
616
|
+
readonly type: SchemaFieldType;
|
|
510
617
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
) => Doc<SchemaType>
|
|
618
|
+
/**
|
|
619
|
+
* The version of the property, if applicable.
|
|
620
|
+
*/
|
|
621
|
+
readonly version?: number;
|
|
516
622
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
623
|
+
/**
|
|
624
|
+
* The primary key of the property, if applicable.
|
|
625
|
+
*/
|
|
626
|
+
readonly primaryKey?: string;
|
|
521
627
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
628
|
+
/**
|
|
629
|
+
* An optional array of nested properties for array-type properties.
|
|
630
|
+
*/
|
|
631
|
+
readonly items?: Property;
|
|
526
632
|
|
|
633
|
+
/**
|
|
634
|
+
* The maximum number of items for array-type properties, if applicable.
|
|
635
|
+
*/
|
|
636
|
+
readonly maxItems?: number;
|
|
527
637
|
|
|
638
|
+
/**
|
|
639
|
+
* The minimum number of items for array-type properties, if applicable.
|
|
640
|
+
*/
|
|
641
|
+
readonly minItems?: number;
|
|
528
642
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
string: 'string' as const,
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* Number type for numeric data (integers and floats)
|
|
537
|
-
*/
|
|
538
|
-
number: 'number' as const,
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Boolean type for true/false values
|
|
542
|
-
*/
|
|
543
|
-
boolean: 'boolean' as const,
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Array type for ordered collections of items
|
|
547
|
-
*/
|
|
548
|
-
array: 'array' as const,
|
|
549
|
-
|
|
550
|
-
/**
|
|
551
|
-
* Object type for nested document structures
|
|
552
|
-
*/
|
|
553
|
-
object: 'object' as const,
|
|
554
|
-
};
|
|
643
|
+
/**
|
|
644
|
+
* The maximum length for string-type properties, if applicable.
|
|
645
|
+
*/
|
|
646
|
+
readonly maxLength?: number;
|
|
555
647
|
|
|
648
|
+
/**
|
|
649
|
+
* The minimum length for string-type properties, if applicable.
|
|
650
|
+
*/
|
|
651
|
+
readonly minLength?: number;
|
|
556
652
|
|
|
653
|
+
/**
|
|
654
|
+
* An optional array of required fields for object-type properties.
|
|
655
|
+
*/
|
|
656
|
+
readonly required?: boolean;
|
|
557
657
|
|
|
558
|
-
/**
|
|
559
|
-
* Represents an in-memory storage system extending the base storage functionality.
|
|
560
|
-
*
|
|
561
|
-
* @template T - The schema type.
|
|
562
|
-
*/
|
|
563
|
-
declare class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
564
658
|
/**
|
|
565
|
-
*
|
|
659
|
+
* An optional default value for the property.
|
|
566
660
|
*/
|
|
567
|
-
|
|
661
|
+
readonly default?: any;
|
|
568
662
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
>
|
|
576
|
-
>;
|
|
663
|
+
/**
|
|
664
|
+
* An optional map of nested properties for object-type properties.
|
|
665
|
+
*/
|
|
666
|
+
readonly properties?: {
|
|
667
|
+
[name: string]: Property;
|
|
668
|
+
};
|
|
577
669
|
}
|
|
578
670
|
|
|
579
671
|
|
|
@@ -613,146 +705,54 @@ declare abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
|
|
|
613
705
|
}
|
|
614
706
|
|
|
615
707
|
|
|
616
|
-
declare
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
* type: SchemaFieldType.object,
|
|
642
|
-
* properties: {
|
|
643
|
-
* id: {
|
|
644
|
-
* type: SchemaFieldType.string,
|
|
645
|
-
* maxLength: 60
|
|
646
|
-
* }
|
|
647
|
-
* }
|
|
648
|
-
* }
|
|
649
|
-
* } as const
|
|
650
|
-
* }
|
|
651
|
-
* )
|
|
652
|
-
* ```
|
|
653
|
-
*
|
|
654
|
-
* 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.
|
|
655
|
-
*
|
|
656
|
-
* @template T - A record of schema types.
|
|
657
|
-
*/
|
|
658
|
-
declare class Database<T extends SchemaTypeRecord> {
|
|
659
|
-
|
|
660
|
-
/**
|
|
661
|
-
* Creates a new `Database` instance with the provided schemas and storage module.
|
|
662
|
-
*
|
|
663
|
-
* @template TS - A record of schema types.
|
|
664
|
-
* @param {TS} schemas - The schemas to use for the collections.
|
|
665
|
-
* @param migrations
|
|
666
|
-
* @param plugins
|
|
667
|
-
* @param options
|
|
668
|
-
* @param password
|
|
669
|
-
* @returns {Promise<Database<TS>>} A promise that resolves to the created `Database` instance.
|
|
670
|
-
*/
|
|
671
|
-
static create<TS extends SchemaTypeRecord>(
|
|
672
|
-
db_name: string,
|
|
673
|
-
schemas: TS,
|
|
674
|
-
migrations: MigrationPathsForSchemas<TS> | MigrationPathsForSchema<TS[string]>,
|
|
675
|
-
plugins:Array<typeof BasePlugin>,
|
|
676
|
-
options: RIDBModule,
|
|
677
|
-
password?:string,
|
|
678
|
-
storage?: BaseStorage<TS>
|
|
679
|
-
): Promise<Database<TS>>;
|
|
680
|
-
|
|
681
|
-
authenticate(password: string): Promise<boolean>;
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* The collections in the database.
|
|
685
|
-
*
|
|
686
|
-
* This is a read-only property where the key is the name of the collection and the value is a `Collection` instance.
|
|
687
|
-
*/
|
|
688
|
-
readonly collections: {
|
|
689
|
-
[name in keyof T]: Collection<Schema<T[name]>>
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
readonly started: boolean;
|
|
693
|
-
|
|
694
|
-
/**
|
|
695
|
-
* Starts the database.
|
|
696
|
-
*
|
|
697
|
-
* @returns {Promise<void>} A promise that resolves when the database is started.
|
|
698
|
-
*/
|
|
699
|
-
start(): Promise<void>;
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Closes the database.
|
|
703
|
-
*
|
|
704
|
-
* @returns {Promise<void>} A promise that resolves when the database is closed.
|
|
705
|
-
*/
|
|
706
|
-
close(): Promise<void>;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* Represents a function type for creating storage with the provided schema type records.
|
|
711
|
-
*
|
|
712
|
-
* @template T - The schema type record.
|
|
713
|
-
* @param {T} records - The schema type records.
|
|
714
|
-
* @returns {Promise<InternalsRecord>} A promise that resolves to the created internals record.
|
|
715
|
-
*/
|
|
716
|
-
type CreateStorage = <T extends SchemaTypeRecord>(
|
|
717
|
-
records: T
|
|
718
|
-
) => Promise<BaseStorage<T>>;
|
|
719
|
-
|
|
720
|
-
/**
|
|
721
|
-
* Represents a storage module with a method for creating storage.
|
|
722
|
-
*/
|
|
723
|
-
type RIDBModule = {
|
|
724
|
-
|
|
725
|
-
/**
|
|
726
|
-
* Plugin constructors array
|
|
727
|
-
*/
|
|
728
|
-
apply: (plugins:Array<typeof BasePlugin>) => Array<BasePlugin>;
|
|
708
|
+
declare const SchemaFieldType = {
|
|
709
|
+
/**
|
|
710
|
+
* String type for text data
|
|
711
|
+
*/
|
|
712
|
+
string: 'string' as const,
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Number type for numeric data (integers and floats)
|
|
716
|
+
*/
|
|
717
|
+
number: 'number' as const,
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Boolean type for true/false values
|
|
721
|
+
*/
|
|
722
|
+
boolean: 'boolean' as const,
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Array type for ordered collections of items
|
|
726
|
+
*/
|
|
727
|
+
array: 'array' as const,
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Object type for nested document structures
|
|
731
|
+
*/
|
|
732
|
+
object: 'object' as const,
|
|
729
733
|
};
|
|
730
734
|
|
|
731
735
|
|
|
732
736
|
|
|
733
737
|
/**
|
|
734
|
-
* Represents an
|
|
738
|
+
* Represents an IndexDB storage system extending the base storage functionality.
|
|
735
739
|
*
|
|
736
|
-
* @template T - The schema type
|
|
740
|
+
* @template T - The schema type.
|
|
737
741
|
*/
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
* The name of the collection on which the operation will be performed.
|
|
741
|
-
*/
|
|
742
|
-
collection: string,
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
|
|
746
|
-
*/
|
|
747
|
-
opType: OpType,
|
|
748
|
-
|
|
742
|
+
declare class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
749
743
|
/**
|
|
750
|
-
*
|
|
744
|
+
* Frees the resources used by the in-memory storage.
|
|
751
745
|
*/
|
|
752
|
-
|
|
746
|
+
free(): void;
|
|
753
747
|
|
|
754
|
-
|
|
755
|
-
|
|
748
|
+
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
749
|
+
dbName: string,
|
|
750
|
+
schemas: SchemasCreate,
|
|
751
|
+
): Promise<
|
|
752
|
+
IndexDB<
|
|
753
|
+
SchemasCreate
|
|
754
|
+
>
|
|
755
|
+
>;
|
|
756
756
|
}
|
|
757
757
|
|
|
758
758
|
|
|
@@ -877,39 +877,41 @@ interface InitOutput {
|
|
|
877
877
|
readonly collection_update: (a: number, b: number) => number;
|
|
878
878
|
readonly collection_create: (a: number, b: number) => number;
|
|
879
879
|
readonly collection_delete: (a: number, b: number) => number;
|
|
880
|
+
readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
|
|
881
|
+
readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
|
|
882
|
+
readonly corestorage_matchesQuery: (a: number, b: number, c: number, d: number) => void;
|
|
883
|
+
readonly __wbg_operation_free: (a: number) => void;
|
|
884
|
+
readonly operation_collection: (a: number, b: number) => void;
|
|
885
|
+
readonly operation_opType: (a: number) => number;
|
|
886
|
+
readonly operation_data: (a: number) => number;
|
|
887
|
+
readonly operation_primaryKeyField: (a: number) => number;
|
|
888
|
+
readonly operation_primaryKey: (a: number) => number;
|
|
889
|
+
readonly operation_primaryKeyIndex: (a: number, b: number) => void;
|
|
890
|
+
readonly corestorage_new: () => number;
|
|
891
|
+
readonly __wbg_corestorage_free: (a: number) => void;
|
|
880
892
|
readonly __wbg_basestorage_free: (a: number) => void;
|
|
881
893
|
readonly basestorage_new: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
882
894
|
readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
|
|
883
895
|
readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
|
|
884
896
|
readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
|
|
885
897
|
readonly basestorage_core: (a: number, b: number) => void;
|
|
886
|
-
readonly
|
|
887
|
-
readonly
|
|
888
|
-
readonly
|
|
889
|
-
readonly
|
|
890
|
-
readonly
|
|
891
|
-
readonly
|
|
892
|
-
readonly
|
|
893
|
-
readonly ridberror_from: (a: number) => number;
|
|
894
|
-
readonly ridberror_error: (a: number, b: number, c: number) => number;
|
|
895
|
-
readonly ridberror_query: (a: number, b: number, c: number) => number;
|
|
896
|
-
readonly ridberror_authentication: (a: number, b: number, c: number) => number;
|
|
897
|
-
readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
|
|
898
|
-
readonly ridberror_validation: (a: number, b: number, c: number) => number;
|
|
899
|
-
readonly ridberror_hook: (a: number, b: number, c: number) => number;
|
|
900
|
-
readonly __wbg_indexdb_free: (a: number) => void;
|
|
901
|
-
readonly indexdb_get_stores: (a: number, b: number) => void;
|
|
902
|
-
readonly indexdb_get_store: (a: number, b: number, c: number, d: number) => void;
|
|
903
|
-
readonly indexdb_create: (a: number, b: number, c: number) => number;
|
|
904
|
-
readonly indexdb_write: (a: number, b: number) => number;
|
|
905
|
-
readonly indexdb_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
906
|
-
readonly indexdb_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
907
|
-
readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
908
|
-
readonly indexdb_close: (a: number) => number;
|
|
909
|
-
readonly indexdb_start: (a: number) => number;
|
|
898
|
+
readonly __wbg_database_free: (a: number) => void;
|
|
899
|
+
readonly database_start: (a: number) => number;
|
|
900
|
+
readonly database_close: (a: number) => number;
|
|
901
|
+
readonly database_started: (a: number) => number;
|
|
902
|
+
readonly database_authenticate: (a: number, b: number, c: number) => number;
|
|
903
|
+
readonly database_collections: (a: number, b: number) => void;
|
|
904
|
+
readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
910
905
|
readonly __wbg_queryoptions_free: (a: number) => void;
|
|
911
906
|
readonly queryoptions_limit: (a: number, b: number) => void;
|
|
912
907
|
readonly queryoptions_offset: (a: number, b: number) => void;
|
|
908
|
+
readonly __wbg_baseplugin_free: (a: number) => void;
|
|
909
|
+
readonly baseplugin_new: (a: number, b: number, c: number) => void;
|
|
910
|
+
readonly baseplugin_name: (a: number) => number;
|
|
911
|
+
readonly baseplugin_get_doc_create_hook: (a: number) => number;
|
|
912
|
+
readonly baseplugin_get_doc_recover_hook: (a: number) => number;
|
|
913
|
+
readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
|
|
914
|
+
readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
|
|
913
915
|
readonly __wbg_query_free: (a: number) => void;
|
|
914
916
|
readonly query_new: (a: number, b: number, c: number) => void;
|
|
915
917
|
readonly query_query: (a: number, b: number) => void;
|
|
@@ -947,18 +949,28 @@ interface InitOutput {
|
|
|
947
949
|
readonly __wbgt_test_query_parse_eq_operator_wrong_type_32: (a: number) => void;
|
|
948
950
|
readonly __wbgt_test_query_parse_ne_operator_33: (a: number) => void;
|
|
949
951
|
readonly __wbgt_test_query_parse_ne_operator_wrong_type_34: (a: number) => void;
|
|
950
|
-
readonly
|
|
951
|
-
readonly
|
|
952
|
-
readonly
|
|
953
|
-
readonly
|
|
954
|
-
readonly
|
|
955
|
-
readonly
|
|
956
|
-
readonly
|
|
957
|
-
readonly
|
|
958
|
-
readonly
|
|
959
|
-
readonly
|
|
960
|
-
readonly
|
|
961
|
-
readonly
|
|
952
|
+
readonly __wbg_inmemory_free: (a: number) => void;
|
|
953
|
+
readonly inmemory_create: (a: number, b: number, c: number) => number;
|
|
954
|
+
readonly inmemory_write: (a: number, b: number) => number;
|
|
955
|
+
readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
956
|
+
readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
957
|
+
readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
958
|
+
readonly inmemory_close: (a: number) => number;
|
|
959
|
+
readonly inmemory_start: (a: number) => number;
|
|
960
|
+
readonly main_js: () => void;
|
|
961
|
+
readonly is_debug_mode: () => number;
|
|
962
|
+
readonly __wbg_ridberror_free: (a: number) => void;
|
|
963
|
+
readonly ridberror_new: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
964
|
+
readonly ridberror_type: (a: number, b: number) => void;
|
|
965
|
+
readonly ridberror_code: (a: number) => number;
|
|
966
|
+
readonly ridberror_message: (a: number, b: number) => void;
|
|
967
|
+
readonly ridberror_from: (a: number) => number;
|
|
968
|
+
readonly ridberror_error: (a: number, b: number, c: number) => number;
|
|
969
|
+
readonly ridberror_query: (a: number, b: number, c: number) => number;
|
|
970
|
+
readonly ridberror_authentication: (a: number, b: number, c: number) => number;
|
|
971
|
+
readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
|
|
972
|
+
readonly ridberror_validation: (a: number, b: number, c: number) => number;
|
|
973
|
+
readonly ridberror_hook: (a: number, b: number, c: number) => number;
|
|
962
974
|
readonly __wbg_schema_free: (a: number) => void;
|
|
963
975
|
readonly schema_validate: (a: number, b: number, c: number) => void;
|
|
964
976
|
readonly schema_is_valid: (a: number, b: number) => void;
|
|
@@ -972,40 +984,28 @@ interface InitOutput {
|
|
|
972
984
|
readonly __wbgt_test_schema_creation_3: (a: number) => void;
|
|
973
985
|
readonly __wbgt_test_schema_validation_4: (a: number) => void;
|
|
974
986
|
readonly __wbgt_test_invalid_schema_5: (a: number) => void;
|
|
975
|
-
readonly
|
|
976
|
-
readonly
|
|
977
|
-
readonly
|
|
978
|
-
readonly
|
|
979
|
-
readonly
|
|
980
|
-
readonly
|
|
981
|
-
readonly
|
|
982
|
-
readonly
|
|
983
|
-
readonly
|
|
984
|
-
readonly
|
|
985
|
-
readonly
|
|
986
|
-
readonly
|
|
987
|
-
readonly
|
|
988
|
-
readonly
|
|
989
|
-
readonly
|
|
990
|
-
readonly
|
|
991
|
-
readonly
|
|
992
|
-
readonly
|
|
993
|
-
readonly
|
|
994
|
-
readonly
|
|
995
|
-
readonly
|
|
996
|
-
readonly
|
|
997
|
-
readonly database_authenticate: (a: number, b: number, c: number) => number;
|
|
998
|
-
readonly database_collections: (a: number, b: number) => void;
|
|
999
|
-
readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
1000
|
-
readonly __wbg_operation_free: (a: number) => void;
|
|
1001
|
-
readonly operation_collection: (a: number, b: number) => void;
|
|
1002
|
-
readonly operation_opType: (a: number) => number;
|
|
1003
|
-
readonly operation_data: (a: number) => number;
|
|
1004
|
-
readonly operation_primaryKeyField: (a: number) => number;
|
|
1005
|
-
readonly operation_primaryKey: (a: number) => number;
|
|
1006
|
-
readonly operation_primaryKeyIndex: (a: number, b: number) => void;
|
|
1007
|
-
readonly corestorage_new: () => number;
|
|
1008
|
-
readonly __wbg_corestorage_free: (a: number) => void;
|
|
987
|
+
readonly __wbg_property_free: (a: number) => void;
|
|
988
|
+
readonly property_is_valid: (a: number, b: number) => void;
|
|
989
|
+
readonly property_type: (a: number) => number;
|
|
990
|
+
readonly property_items: (a: number, b: number) => void;
|
|
991
|
+
readonly property_maxItems: (a: number, b: number) => void;
|
|
992
|
+
readonly property_minItems: (a: number, b: number) => void;
|
|
993
|
+
readonly property_maxLength: (a: number, b: number) => void;
|
|
994
|
+
readonly property_minLength: (a: number, b: number) => void;
|
|
995
|
+
readonly property_properties: (a: number, b: number) => void;
|
|
996
|
+
readonly __wbgt_test_property_creation_0: (a: number) => void;
|
|
997
|
+
readonly __wbgt_test_property_validation_1: (a: number) => void;
|
|
998
|
+
readonly __wbgt_test_invalid_property_2: (a: number) => void;
|
|
999
|
+
readonly __wbg_indexdb_free: (a: number) => void;
|
|
1000
|
+
readonly indexdb_get_stores: (a: number, b: number) => void;
|
|
1001
|
+
readonly indexdb_get_store: (a: number, b: number, c: number, d: number) => void;
|
|
1002
|
+
readonly indexdb_create: (a: number, b: number, c: number) => number;
|
|
1003
|
+
readonly indexdb_write: (a: number, b: number) => number;
|
|
1004
|
+
readonly indexdb_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
1005
|
+
readonly indexdb_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
1006
|
+
readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
1007
|
+
readonly indexdb_close: (a: number) => number;
|
|
1008
|
+
readonly indexdb_start: (a: number) => number;
|
|
1009
1009
|
readonly __wbg_wasmbindgentestcontext_free: (a: number) => void;
|
|
1010
1010
|
readonly wasmbindgentestcontext_new: () => number;
|
|
1011
1011
|
readonly wasmbindgentestcontext_args: (a: number, b: number, c: number) => void;
|