@trust0/ridb-core 1.7.3 → 1.7.6
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 +327 -327
- package/build/ridb_core.js +58 -52
- package/package.json +9 -6
- package/build/ridb_core_bg.d.ts +0 -2
- package/build/ridb_core_bg.js +0 -29
package/build/ridb_core.d.ts
CHANGED
|
@@ -38,6 +38,16 @@ 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
|
+
/**
|
|
41
51
|
* Represents the type of operation to be performed on the collection.
|
|
42
52
|
*/
|
|
43
53
|
declare enum OpType {
|
|
@@ -62,189 +72,6 @@ declare enum OpType {
|
|
|
62
72
|
*/
|
|
63
73
|
COUNT = 4,
|
|
64
74
|
}
|
|
65
|
-
/**
|
|
66
|
-
*/
|
|
67
|
-
declare enum Errors {
|
|
68
|
-
Error = 0,
|
|
69
|
-
HookError = 1,
|
|
70
|
-
QueryError = 2,
|
|
71
|
-
SerializationError = 3,
|
|
72
|
-
ValidationError = 4,
|
|
73
|
-
AuthenticationError = 5,
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
type Operators<T> = {
|
|
77
|
-
$gte?: number,
|
|
78
|
-
$gt?: number
|
|
79
|
-
$lt?: number,
|
|
80
|
-
$lte?: number,
|
|
81
|
-
$eq?: T,
|
|
82
|
-
$ne?: T
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
type InOperator<T> = { $in?: T[] };
|
|
86
|
-
type NInOperator<T> = { $nin?: T[] };
|
|
87
|
-
|
|
88
|
-
type OperatorOrType<T> = T extends number ?
|
|
89
|
-
T | Operators<T> | InOperator<T> | NInOperator<T> :
|
|
90
|
-
T | InOperator<T> | NInOperator<T>;
|
|
91
|
-
|
|
92
|
-
type LogicalOperators<T extends SchemaType> = {
|
|
93
|
-
$and?: Partial<QueryType<T>>[];
|
|
94
|
-
$or?: Partial<QueryType<T>>[];
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
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
|
-
declare class Query<T extends SchemaType> {
|
|
106
|
-
constructor(query: QueryType<T>, schema:Schema<T>);
|
|
107
|
-
readonly query: QueryType<T>;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
type InternalsRecord = {
|
|
113
|
-
[name: string]: BaseStorage<SchemaTypeRecord>
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
|
|
117
|
-
*
|
|
118
|
-
* @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* type StringType = ExtractType<'string'>; // StringType is string
|
|
122
|
-
* type NumberType = ExtractType<'number'>; // NumberType is number
|
|
123
|
-
* type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
|
|
124
|
-
* type ObjectType = ExtractType<'object'>; // ObjectType is object
|
|
125
|
-
* type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
|
|
126
|
-
*/
|
|
127
|
-
type ExtractType<T extends string> =
|
|
128
|
-
T extends "string" ? string :
|
|
129
|
-
T extends "number" ? number :
|
|
130
|
-
T extends "boolean" ? boolean :
|
|
131
|
-
T extends "object" ? object :
|
|
132
|
-
T extends "array" ? any[] :
|
|
133
|
-
never;
|
|
134
|
-
|
|
135
|
-
type IsOptional<T> = T extends { required: false } ? true :
|
|
136
|
-
T extends { default: any } ? true : false;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Doc is a utility type that transforms a schema type into a document type where each property is mapped to its extracted type.
|
|
140
|
-
*
|
|
141
|
-
* @template T - A schema type with a 'properties' field where each property's type is represented as a string.
|
|
142
|
-
*
|
|
143
|
-
* type Document = Doc<Schema>; // Document is { name: string; age: number; }
|
|
144
|
-
*/
|
|
145
|
-
type Doc<T extends SchemaType> = {
|
|
146
|
-
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? K : never]?:
|
|
147
|
-
ExtractType<T["properties"][K]["type"]>
|
|
148
|
-
} & {
|
|
149
|
-
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends false ? K : never]:
|
|
150
|
-
ExtractType<T["properties"][K]["type"]>
|
|
151
|
-
} & {
|
|
152
|
-
__version?: number;
|
|
153
|
-
createdAt?: number;
|
|
154
|
-
updatedAt?: number;
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
type QueryOptions = {
|
|
158
|
-
limit?: number;
|
|
159
|
-
offset?: number;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Collection is a class that represents a collection of documents in a database.
|
|
164
|
-
* @template T - A schema type defining the structure of the documents in the collection.
|
|
165
|
-
*/
|
|
166
|
-
declare class Collection<T extends SchemaType> {
|
|
167
|
-
/**
|
|
168
|
-
* Finds all documents in the collection.
|
|
169
|
-
*
|
|
170
|
-
* @returns A promise that resolves to an array of documents.
|
|
171
|
-
*/
|
|
172
|
-
find(query: QueryType<T>, options?: QueryOptions): Promise<Doc<T>[]>;
|
|
173
|
-
/**
|
|
174
|
-
* count all documents in the collection.
|
|
175
|
-
*
|
|
176
|
-
* @returns A promise that resolves to an array of documents.
|
|
177
|
-
*/
|
|
178
|
-
count(query: QueryType<T>, options?: QueryOptions): Promise<number>;
|
|
179
|
-
/**
|
|
180
|
-
* Finds a single document in the collection by its ID.
|
|
181
|
-
*
|
|
182
|
-
* @param id - The ID of the document to find.
|
|
183
|
-
* @returns A promise that resolves to the found document.
|
|
184
|
-
*/
|
|
185
|
-
findById(id: string): Promise<Doc<T>>;
|
|
186
|
-
/**
|
|
187
|
-
* Updates a document in the collection by its ID.
|
|
188
|
-
*
|
|
189
|
-
* @param id - The ID of the document to update.
|
|
190
|
-
* @param document - A partial document containing the fields to update.
|
|
191
|
-
* @returns A promise that resolves when the update is complete.
|
|
192
|
-
*/
|
|
193
|
-
update(document: Partial<Doc<T>>): Promise<void>;
|
|
194
|
-
/**
|
|
195
|
-
* Creates a new document in the collection.
|
|
196
|
-
*
|
|
197
|
-
* @param document - The document to create.
|
|
198
|
-
* @returns A promise that resolves to the created document.
|
|
199
|
-
*/
|
|
200
|
-
create(document: Doc<T>): Promise<Doc<T>>;
|
|
201
|
-
/**
|
|
202
|
-
* Deletes a document in the collection by its ID.
|
|
203
|
-
*
|
|
204
|
-
* @param id - The ID of the document to delete.
|
|
205
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
206
|
-
*/
|
|
207
|
-
delete(id: string): Promise<void>;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Represents an in-memory storage system extending the base storage functionality.
|
|
215
|
-
*
|
|
216
|
-
* @template T - The schema type.
|
|
217
|
-
*/
|
|
218
|
-
declare class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
219
|
-
/**
|
|
220
|
-
* Frees the resources used by the in-memory storage.
|
|
221
|
-
*/
|
|
222
|
-
free(): void;
|
|
223
|
-
|
|
224
|
-
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
225
|
-
dbName: string,
|
|
226
|
-
schemas: SchemasCreate,
|
|
227
|
-
): Promise<
|
|
228
|
-
InMemory<
|
|
229
|
-
SchemasCreate
|
|
230
|
-
>
|
|
231
|
-
>;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
declare class CoreStorage {
|
|
237
|
-
/**
|
|
238
|
-
* @param {any} document
|
|
239
|
-
* @param {Query} query
|
|
240
|
-
* @returns {boolean}
|
|
241
|
-
*/
|
|
242
|
-
matchesQuery(document: any, query: Query<any>): boolean;
|
|
243
|
-
getPrimaryKeyTyped(value: any): string | number;
|
|
244
|
-
getIndexes(schema: Schema<any>, op: Operation): string[];
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
75
|
|
|
249
76
|
/**
|
|
250
77
|
* Represents a property within a schema, including various constraints and nested properties.
|
|
@@ -310,6 +137,42 @@ declare class Property {
|
|
|
310
137
|
|
|
311
138
|
|
|
312
139
|
|
|
140
|
+
type Operators<T> = {
|
|
141
|
+
$gte?: number,
|
|
142
|
+
$gt?: number
|
|
143
|
+
$lt?: number,
|
|
144
|
+
$lte?: number,
|
|
145
|
+
$eq?: T,
|
|
146
|
+
$ne?: T
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
type InOperator<T> = { $in?: T[] };
|
|
150
|
+
type NInOperator<T> = { $nin?: T[] };
|
|
151
|
+
|
|
152
|
+
type OperatorOrType<T> = T extends number ?
|
|
153
|
+
T | Operators<T> | InOperator<T> | NInOperator<T> :
|
|
154
|
+
T | InOperator<T> | NInOperator<T>;
|
|
155
|
+
|
|
156
|
+
type LogicalOperators<T extends SchemaType> = {
|
|
157
|
+
$and?: Partial<QueryType<T>>[];
|
|
158
|
+
$or?: Partial<QueryType<T>>[];
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
type QueryType<T extends SchemaType> = Partial<{
|
|
162
|
+
[K in keyof T['properties']]: OperatorOrType<
|
|
163
|
+
ExtractType<
|
|
164
|
+
T['properties'][K]['type']
|
|
165
|
+
>
|
|
166
|
+
>
|
|
167
|
+
}> & LogicalOperators<T> | LogicalOperators<T>[];
|
|
168
|
+
|
|
169
|
+
declare class Query<T extends SchemaType> {
|
|
170
|
+
constructor(query: QueryType<T>, schema:Schema<T>);
|
|
171
|
+
readonly query: QueryType<T>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
313
176
|
/**
|
|
314
177
|
* Represents the type definition for a schema.
|
|
315
178
|
*/
|
|
@@ -418,29 +281,6 @@ declare class Schema<T extends SchemaType> {
|
|
|
418
281
|
|
|
419
282
|
|
|
420
283
|
|
|
421
|
-
/**
|
|
422
|
-
* Represents an IndexDB storage system extending the base storage functionality.
|
|
423
|
-
*
|
|
424
|
-
* @template T - The schema type.
|
|
425
|
-
*/
|
|
426
|
-
declare class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
427
|
-
/**
|
|
428
|
-
* Frees the resources used by the in-memory storage.
|
|
429
|
-
*/
|
|
430
|
-
free(): void;
|
|
431
|
-
|
|
432
|
-
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
433
|
-
dbName: string,
|
|
434
|
-
schemas: SchemasCreate,
|
|
435
|
-
): Promise<
|
|
436
|
-
IndexDB<
|
|
437
|
-
SchemasCreate
|
|
438
|
-
>
|
|
439
|
-
>;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
284
|
type EnumerateUpTo<
|
|
445
285
|
N extends number,
|
|
446
286
|
Acc extends number[] = []
|
|
@@ -489,33 +329,6 @@ type MigrationsParameter<
|
|
|
489
329
|
|
|
490
330
|
|
|
491
331
|
|
|
492
|
-
/**
|
|
493
|
-
* Represents an operation to be performed on a collection.
|
|
494
|
-
*
|
|
495
|
-
* @template T - The schema type of the collection.
|
|
496
|
-
*/
|
|
497
|
-
type Operation<T extends SchemaType = SchemaType> = {
|
|
498
|
-
/**
|
|
499
|
-
* The name of the collection on which the operation will be performed.
|
|
500
|
-
*/
|
|
501
|
-
collection: string,
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
|
|
505
|
-
*/
|
|
506
|
-
opType: OpType,
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* The data involved in the operation, conforming to the schema type.
|
|
510
|
-
*/
|
|
511
|
-
data: Doc<T>,
|
|
512
|
-
|
|
513
|
-
primaryKeyField?: string,
|
|
514
|
-
primaryKey?: string
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
332
|
type Hook = (
|
|
520
333
|
schema: Schema<SchemaType>,
|
|
521
334
|
migration: MigrationPathsForSchema<SchemaType>,
|
|
@@ -534,40 +347,107 @@ declare class BasePlugin implements BasePluginOptions {
|
|
|
534
347
|
|
|
535
348
|
|
|
536
349
|
|
|
350
|
+
type InternalsRecord = {
|
|
351
|
+
[name: string]: BaseStorage<SchemaTypeRecord>
|
|
352
|
+
};
|
|
537
353
|
/**
|
|
538
|
-
*
|
|
354
|
+
* ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
|
|
355
|
+
*
|
|
356
|
+
* @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* type StringType = ExtractType<'string'>; // StringType is string
|
|
360
|
+
* type NumberType = ExtractType<'number'>; // NumberType is number
|
|
361
|
+
* type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
|
|
362
|
+
* type ObjectType = ExtractType<'object'>; // ObjectType is object
|
|
363
|
+
* type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
|
|
539
364
|
*/
|
|
540
|
-
type
|
|
541
|
-
|
|
365
|
+
type ExtractType<T extends string> =
|
|
366
|
+
T extends "string" ? string :
|
|
367
|
+
T extends "number" ? number :
|
|
368
|
+
T extends "boolean" ? boolean :
|
|
369
|
+
T extends "object" ? object :
|
|
370
|
+
T extends "array" ? any[] :
|
|
371
|
+
never;
|
|
372
|
+
|
|
373
|
+
type IsOptional<T> = T extends { required: false } ? true :
|
|
374
|
+
T extends { default: any } ? true : false;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Doc is a utility type that transforms a schema type into a document type where each property is mapped to its extracted type.
|
|
378
|
+
*
|
|
379
|
+
* @template T - A schema type with a 'properties' field where each property's type is represented as a string.
|
|
380
|
+
*
|
|
381
|
+
* type Document = Doc<Schema>; // Document is { name: string; age: number; }
|
|
382
|
+
*/
|
|
383
|
+
type Doc<T extends SchemaType> = {
|
|
384
|
+
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? K : never]?:
|
|
385
|
+
ExtractType<T["properties"][K]["type"]>
|
|
386
|
+
} & {
|
|
387
|
+
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends false ? K : never]:
|
|
388
|
+
ExtractType<T["properties"][K]["type"]>
|
|
389
|
+
} & {
|
|
390
|
+
__version?: number;
|
|
391
|
+
createdAt?: number;
|
|
392
|
+
updatedAt?: number;
|
|
542
393
|
};
|
|
543
394
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
395
|
+
type QueryOptions = {
|
|
396
|
+
limit?: number;
|
|
397
|
+
offset?: number;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Collection is a class that represents a collection of documents in a database.
|
|
402
|
+
* @template T - A schema type defining the structure of the documents in the collection.
|
|
403
|
+
*/
|
|
404
|
+
declare class Collection<T extends SchemaType> {
|
|
405
|
+
/**
|
|
406
|
+
* Finds all documents in the collection.
|
|
407
|
+
*
|
|
408
|
+
* @returns A promise that resolves to an array of documents.
|
|
409
|
+
*/
|
|
410
|
+
find(query: QueryType<T>, options?: QueryOptions): Promise<Doc<T>[]>;
|
|
411
|
+
/**
|
|
412
|
+
* count all documents in the collection.
|
|
413
|
+
*
|
|
414
|
+
* @returns A promise that resolves to an array of documents.
|
|
415
|
+
*/
|
|
416
|
+
count(query: QueryType<T>, options?: QueryOptions): Promise<number>;
|
|
417
|
+
/**
|
|
418
|
+
* Finds a single document in the collection by its ID.
|
|
419
|
+
*
|
|
420
|
+
* @param id - The ID of the document to find.
|
|
421
|
+
* @returns A promise that resolves to the found document.
|
|
422
|
+
*/
|
|
423
|
+
findById(id: string): Promise<Doc<T>>;
|
|
424
|
+
/**
|
|
425
|
+
* Updates a document in the collection by its ID.
|
|
426
|
+
*
|
|
427
|
+
* @param id - The ID of the document to update.
|
|
428
|
+
* @param document - A partial document containing the fields to update.
|
|
429
|
+
* @returns A promise that resolves when the update is complete.
|
|
430
|
+
*/
|
|
431
|
+
update(document: Partial<Doc<T>>): Promise<void>;
|
|
432
|
+
/**
|
|
433
|
+
* Creates a new document in the collection.
|
|
434
|
+
*
|
|
435
|
+
* @param document - The document to create.
|
|
436
|
+
* @returns A promise that resolves to the created document.
|
|
437
|
+
*/
|
|
438
|
+
create(document: Doc<T>): Promise<Doc<T>>;
|
|
439
|
+
/**
|
|
440
|
+
* Deletes a document in the collection by its ID.
|
|
441
|
+
*
|
|
442
|
+
* @param id - The ID of the document to delete.
|
|
443
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
444
|
+
*/
|
|
445
|
+
delete(id: string): Promise<void>;
|
|
568
446
|
}
|
|
569
447
|
|
|
570
448
|
|
|
449
|
+
|
|
450
|
+
|
|
571
451
|
type BaseStorageOptions = {
|
|
572
452
|
[name:string]:string | boolean | number
|
|
573
453
|
}
|
|
@@ -605,6 +485,65 @@ declare class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInter
|
|
|
605
485
|
|
|
606
486
|
|
|
607
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Represents an IndexDB storage system extending the base storage functionality.
|
|
490
|
+
*
|
|
491
|
+
* @template T - The schema type.
|
|
492
|
+
*/
|
|
493
|
+
declare class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
494
|
+
/**
|
|
495
|
+
* Frees the resources used by the in-memory storage.
|
|
496
|
+
*/
|
|
497
|
+
free(): void;
|
|
498
|
+
|
|
499
|
+
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
500
|
+
dbName: string,
|
|
501
|
+
schemas: SchemasCreate,
|
|
502
|
+
): Promise<
|
|
503
|
+
IndexDB<
|
|
504
|
+
SchemasCreate
|
|
505
|
+
>
|
|
506
|
+
>;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Represents an in-memory storage system extending the base storage functionality.
|
|
513
|
+
*
|
|
514
|
+
* @template T - The schema type.
|
|
515
|
+
*/
|
|
516
|
+
declare class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
517
|
+
/**
|
|
518
|
+
* Frees the resources used by the in-memory storage.
|
|
519
|
+
*/
|
|
520
|
+
free(): void;
|
|
521
|
+
|
|
522
|
+
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
523
|
+
dbName: string,
|
|
524
|
+
schemas: SchemasCreate,
|
|
525
|
+
): Promise<
|
|
526
|
+
InMemory<
|
|
527
|
+
SchemasCreate
|
|
528
|
+
>
|
|
529
|
+
>;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
declare class CoreStorage {
|
|
535
|
+
/**
|
|
536
|
+
* @param {any} document
|
|
537
|
+
* @param {Query} query
|
|
538
|
+
* @returns {boolean}
|
|
539
|
+
*/
|
|
540
|
+
matchesQuery(document: any, query: Query<any>): boolean;
|
|
541
|
+
getPrimaryKeyTyped(value: any): string | number;
|
|
542
|
+
getIndexes(schema: Schema<any>, op: Operation): string[];
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
608
547
|
/**
|
|
609
548
|
* Represents a database containing collections of documents.
|
|
610
549
|
* RIDB extends from this class and is used to expose collections.
|
|
@@ -708,6 +647,67 @@ type RIDBModule = {
|
|
|
708
647
|
};
|
|
709
648
|
|
|
710
649
|
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Represents an operation to be performed on a collection.
|
|
653
|
+
*
|
|
654
|
+
* @template T - The schema type of the collection.
|
|
655
|
+
*/
|
|
656
|
+
type Operation<T extends SchemaType = SchemaType> = {
|
|
657
|
+
/**
|
|
658
|
+
* The name of the collection on which the operation will be performed.
|
|
659
|
+
*/
|
|
660
|
+
collection: string,
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
|
|
664
|
+
*/
|
|
665
|
+
opType: OpType,
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* The data involved in the operation, conforming to the schema type.
|
|
669
|
+
*/
|
|
670
|
+
data: Doc<T>,
|
|
671
|
+
|
|
672
|
+
primaryKeyField?: string,
|
|
673
|
+
primaryKey?: string
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
|
|
680
|
+
*/
|
|
681
|
+
type SchemaTypeRecord = {
|
|
682
|
+
[name: string]: SchemaType
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
declare abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
|
|
686
|
+
constructor(
|
|
687
|
+
name: string,
|
|
688
|
+
schemas: Schemas
|
|
689
|
+
);
|
|
690
|
+
abstract start(): Promise<void>;
|
|
691
|
+
abstract close(): Promise<void>;
|
|
692
|
+
abstract count(
|
|
693
|
+
colectionName: keyof Schemas,
|
|
694
|
+
query: QueryType<Schemas[keyof Schemas]>,
|
|
695
|
+
options?: QueryOptions
|
|
696
|
+
): Promise<number>;
|
|
697
|
+
abstract findDocumentById(
|
|
698
|
+
collectionName: keyof Schemas,
|
|
699
|
+
id: string
|
|
700
|
+
): Promise<Doc<Schemas[keyof Schemas]> | null>;
|
|
701
|
+
abstract find(
|
|
702
|
+
collectionName: keyof Schemas,
|
|
703
|
+
query: QueryType<Schemas[keyof Schemas]>,
|
|
704
|
+
options?: QueryOptions
|
|
705
|
+
): Promise<Doc<Schemas[keyof Schemas]>[]>;
|
|
706
|
+
abstract write(
|
|
707
|
+
op: Operation<Schemas[keyof Schemas]>
|
|
708
|
+
): Promise<Doc<Schemas[keyof Schemas]>>;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
711
|
/**
|
|
712
712
|
*/
|
|
713
713
|
declare class RIDBError {
|
|
@@ -819,6 +819,18 @@ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Modul
|
|
|
819
819
|
|
|
820
820
|
interface InitOutput {
|
|
821
821
|
readonly memory: WebAssembly.Memory;
|
|
822
|
+
readonly __wbg_property_free: (a: number) => void;
|
|
823
|
+
readonly property_is_valid: (a: number, b: number) => void;
|
|
824
|
+
readonly property_type: (a: number) => number;
|
|
825
|
+
readonly property_items: (a: number, b: number) => void;
|
|
826
|
+
readonly property_maxItems: (a: number, b: number) => void;
|
|
827
|
+
readonly property_minItems: (a: number, b: number) => void;
|
|
828
|
+
readonly property_maxLength: (a: number, b: number) => void;
|
|
829
|
+
readonly property_minLength: (a: number, b: number) => void;
|
|
830
|
+
readonly property_properties: (a: number, b: number) => void;
|
|
831
|
+
readonly __wbgt_test_property_creation_0: (a: number) => void;
|
|
832
|
+
readonly __wbgt_test_property_validation_1: (a: number) => void;
|
|
833
|
+
readonly __wbgt_test_invalid_property_2: (a: number) => void;
|
|
822
834
|
readonly __wbg_query_free: (a: number) => void;
|
|
823
835
|
readonly query_new: (a: number, b: number, c: number) => void;
|
|
824
836
|
readonly query_query: (a: number, b: number) => void;
|
|
@@ -855,44 +867,6 @@ interface InitOutput {
|
|
|
855
867
|
readonly __wbgt_test_query_parse_eq_operator_wrong_type_32: (a: number) => void;
|
|
856
868
|
readonly __wbgt_test_query_parse_ne_operator_33: (a: number) => void;
|
|
857
869
|
readonly __wbgt_test_query_parse_ne_operator_wrong_type_34: (a: number) => void;
|
|
858
|
-
readonly __wbg_collection_free: (a: number) => void;
|
|
859
|
-
readonly collection_name: (a: number, b: number) => void;
|
|
860
|
-
readonly collection_schema: (a: number, b: number) => void;
|
|
861
|
-
readonly collection_find: (a: number, b: number, c: number) => number;
|
|
862
|
-
readonly collection_parse_query_options: (a: number, b: number, c: number) => void;
|
|
863
|
-
readonly collection_count: (a: number, b: number, c: number) => number;
|
|
864
|
-
readonly collection_findById: (a: number, b: number) => number;
|
|
865
|
-
readonly collection_update: (a: number, b: number) => number;
|
|
866
|
-
readonly collection_create: (a: number, b: number) => number;
|
|
867
|
-
readonly collection_delete: (a: number, b: number) => number;
|
|
868
|
-
readonly __wbg_inmemory_free: (a: number) => void;
|
|
869
|
-
readonly inmemory_create: (a: number, b: number, c: number) => number;
|
|
870
|
-
readonly inmemory_write: (a: number, b: number) => number;
|
|
871
|
-
readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
872
|
-
readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
873
|
-
readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
874
|
-
readonly inmemory_close: (a: number) => number;
|
|
875
|
-
readonly inmemory_start: (a: number) => number;
|
|
876
|
-
readonly corestorage_new: () => number;
|
|
877
|
-
readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
|
|
878
|
-
readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
|
|
879
|
-
readonly corestorage_matchesQuery: (a: number, b: number, c: number, d: number) => void;
|
|
880
|
-
readonly __wbg_queryoptions_free: (a: number) => void;
|
|
881
|
-
readonly queryoptions_limit: (a: number, b: number) => void;
|
|
882
|
-
readonly queryoptions_offset: (a: number, b: number) => void;
|
|
883
|
-
readonly __wbg_corestorage_free: (a: number) => void;
|
|
884
|
-
readonly __wbg_property_free: (a: number) => void;
|
|
885
|
-
readonly property_is_valid: (a: number, b: number) => void;
|
|
886
|
-
readonly property_type: (a: number) => number;
|
|
887
|
-
readonly property_items: (a: number, b: number) => void;
|
|
888
|
-
readonly property_maxItems: (a: number, b: number) => void;
|
|
889
|
-
readonly property_minItems: (a: number, b: number) => void;
|
|
890
|
-
readonly property_maxLength: (a: number, b: number) => void;
|
|
891
|
-
readonly property_minLength: (a: number, b: number) => void;
|
|
892
|
-
readonly property_properties: (a: number, b: number) => void;
|
|
893
|
-
readonly __wbgt_test_property_creation_0: (a: number) => void;
|
|
894
|
-
readonly __wbgt_test_property_validation_1: (a: number) => void;
|
|
895
|
-
readonly __wbgt_test_invalid_property_2: (a: number) => void;
|
|
896
870
|
readonly __wbg_schema_free: (a: number) => void;
|
|
897
871
|
readonly schema_validate: (a: number, b: number, c: number) => void;
|
|
898
872
|
readonly schema_is_valid: (a: number, b: number) => void;
|
|
@@ -906,35 +880,6 @@ interface InitOutput {
|
|
|
906
880
|
readonly __wbgt_test_schema_creation_3: (a: number) => void;
|
|
907
881
|
readonly __wbgt_test_schema_validation_4: (a: number) => void;
|
|
908
882
|
readonly __wbgt_test_invalid_schema_5: (a: number) => void;
|
|
909
|
-
readonly __wbg_indexdb_free: (a: number) => void;
|
|
910
|
-
readonly indexdb_get_stores: (a: number, b: number) => void;
|
|
911
|
-
readonly indexdb_get_store: (a: number, b: number, c: number, d: number) => void;
|
|
912
|
-
readonly indexdb_create: (a: number, b: number, c: number) => number;
|
|
913
|
-
readonly indexdb_write: (a: number, b: number) => number;
|
|
914
|
-
readonly indexdb_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
915
|
-
readonly indexdb_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
916
|
-
readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
917
|
-
readonly indexdb_close: (a: number) => number;
|
|
918
|
-
readonly indexdb_start: (a: number) => number;
|
|
919
|
-
readonly __wbg_ridberror_free: (a: number) => void;
|
|
920
|
-
readonly ridberror_new: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
921
|
-
readonly ridberror_type: (a: number, b: number) => void;
|
|
922
|
-
readonly ridberror_code: (a: number) => number;
|
|
923
|
-
readonly ridberror_message: (a: number, b: number) => void;
|
|
924
|
-
readonly ridberror_from: (a: number) => number;
|
|
925
|
-
readonly ridberror_error: (a: number, b: number, c: number) => number;
|
|
926
|
-
readonly ridberror_query: (a: number, b: number, c: number) => number;
|
|
927
|
-
readonly ridberror_authentication: (a: number, b: number, c: number) => number;
|
|
928
|
-
readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
|
|
929
|
-
readonly ridberror_validation: (a: number, b: number, c: number) => number;
|
|
930
|
-
readonly ridberror_hook: (a: number, b: number, c: number) => number;
|
|
931
|
-
readonly __wbg_operation_free: (a: number) => void;
|
|
932
|
-
readonly operation_collection: (a: number, b: number) => void;
|
|
933
|
-
readonly operation_opType: (a: number) => number;
|
|
934
|
-
readonly operation_data: (a: number) => number;
|
|
935
|
-
readonly operation_primaryKeyField: (a: number) => number;
|
|
936
|
-
readonly operation_primaryKey: (a: number) => number;
|
|
937
|
-
readonly operation_primaryKeyIndex: (a: number, b: number) => void;
|
|
938
883
|
readonly __wbg_baseplugin_free: (a: number) => void;
|
|
939
884
|
readonly baseplugin_new: (a: number, b: number, c: number) => void;
|
|
940
885
|
readonly baseplugin_name: (a: number) => number;
|
|
@@ -944,12 +889,59 @@ interface InitOutput {
|
|
|
944
889
|
readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
|
|
945
890
|
readonly main_js: () => void;
|
|
946
891
|
readonly is_debug_mode: () => number;
|
|
892
|
+
readonly __wbg_collection_free: (a: number) => void;
|
|
893
|
+
readonly collection_name: (a: number, b: number) => void;
|
|
894
|
+
readonly collection_schema: (a: number, b: number) => void;
|
|
895
|
+
readonly collection_find: (a: number, b: number, c: number) => number;
|
|
896
|
+
readonly collection_parse_query_options: (a: number, b: number, c: number) => void;
|
|
897
|
+
readonly collection_count: (a: number, b: number, c: number) => number;
|
|
898
|
+
readonly collection_findById: (a: number, b: number) => number;
|
|
899
|
+
readonly collection_update: (a: number, b: number) => number;
|
|
900
|
+
readonly collection_create: (a: number, b: number) => number;
|
|
901
|
+
readonly collection_delete: (a: number, b: number) => number;
|
|
947
902
|
readonly __wbg_basestorage_free: (a: number) => void;
|
|
948
903
|
readonly basestorage_new: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
949
904
|
readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
|
|
950
905
|
readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
|
|
951
906
|
readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
|
|
952
907
|
readonly basestorage_core: (a: number, b: number) => void;
|
|
908
|
+
readonly __wbg_queryoptions_free: (a: number) => void;
|
|
909
|
+
readonly queryoptions_limit: (a: number, b: number) => void;
|
|
910
|
+
readonly queryoptions_offset: (a: number, b: number) => void;
|
|
911
|
+
readonly __wbg_ridberror_free: (a: number) => void;
|
|
912
|
+
readonly ridberror_new: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
913
|
+
readonly ridberror_type: (a: number, b: number) => void;
|
|
914
|
+
readonly ridberror_code: (a: number) => number;
|
|
915
|
+
readonly ridberror_message: (a: number, b: number) => void;
|
|
916
|
+
readonly ridberror_from: (a: number) => number;
|
|
917
|
+
readonly ridberror_error: (a: number, b: number, c: number) => number;
|
|
918
|
+
readonly ridberror_query: (a: number, b: number, c: number) => number;
|
|
919
|
+
readonly ridberror_authentication: (a: number, b: number, c: number) => number;
|
|
920
|
+
readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
|
|
921
|
+
readonly ridberror_validation: (a: number, b: number, c: number) => number;
|
|
922
|
+
readonly ridberror_hook: (a: number, b: number, c: number) => number;
|
|
923
|
+
readonly __wbg_indexdb_free: (a: number) => void;
|
|
924
|
+
readonly indexdb_get_stores: (a: number, b: number) => void;
|
|
925
|
+
readonly indexdb_get_store: (a: number, b: number, c: number, d: number) => void;
|
|
926
|
+
readonly indexdb_create: (a: number, b: number, c: number) => number;
|
|
927
|
+
readonly indexdb_write: (a: number, b: number) => number;
|
|
928
|
+
readonly indexdb_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
929
|
+
readonly indexdb_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
930
|
+
readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
931
|
+
readonly indexdb_close: (a: number) => number;
|
|
932
|
+
readonly indexdb_start: (a: number) => number;
|
|
933
|
+
readonly __wbg_inmemory_free: (a: number) => void;
|
|
934
|
+
readonly inmemory_create: (a: number, b: number, c: number) => number;
|
|
935
|
+
readonly inmemory_write: (a: number, b: number) => number;
|
|
936
|
+
readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
937
|
+
readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
938
|
+
readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
939
|
+
readonly inmemory_close: (a: number) => number;
|
|
940
|
+
readonly inmemory_start: (a: number) => number;
|
|
941
|
+
readonly corestorage_new: () => number;
|
|
942
|
+
readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
|
|
943
|
+
readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
|
|
944
|
+
readonly corestorage_matchesQuery: (a: number, b: number, c: number, d: number) => void;
|
|
953
945
|
readonly __wbg_database_free: (a: number) => void;
|
|
954
946
|
readonly database_start: (a: number) => number;
|
|
955
947
|
readonly database_close: (a: number) => number;
|
|
@@ -957,6 +949,14 @@ interface InitOutput {
|
|
|
957
949
|
readonly database_authenticate: (a: number, b: number, c: number) => number;
|
|
958
950
|
readonly database_collections: (a: number, b: number) => void;
|
|
959
951
|
readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
952
|
+
readonly __wbg_operation_free: (a: number) => void;
|
|
953
|
+
readonly operation_collection: (a: number, b: number) => void;
|
|
954
|
+
readonly operation_opType: (a: number) => number;
|
|
955
|
+
readonly operation_data: (a: number) => number;
|
|
956
|
+
readonly operation_primaryKeyField: (a: number) => number;
|
|
957
|
+
readonly operation_primaryKey: (a: number) => number;
|
|
958
|
+
readonly operation_primaryKeyIndex: (a: number, b: number) => void;
|
|
959
|
+
readonly __wbg_corestorage_free: (a: number) => void;
|
|
960
960
|
readonly __wbg_wasmbindgentestcontext_free: (a: number) => void;
|
|
961
961
|
readonly wasmbindgentestcontext_new: () => number;
|
|
962
962
|
readonly wasmbindgentestcontext_args: (a: number, b: number, c: number) => void;
|