@trust0/ridb-core 1.7.32 → 1.7.33

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.
@@ -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,219 +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
- /**
77
- * Represents the type definition for a schema.
78
- */
79
- type SchemaType = {
80
- /**
81
- * The version of the schema.
82
- */
83
- version: number;
84
-
85
- /**
86
- * The primary key of the schema.
87
- */
88
- primaryKey: string;
89
-
90
- /**
91
- * The type of the schema.
92
- */
93
- type: SchemaFieldType;
94
- indexes?: string[];
95
- encrypted?: string[];
96
- /**
97
- * The properties defined in the schema.
98
- */
99
- properties: {
100
- [name: string]: Property;
101
- };
102
- };
103
-
104
-
105
- /**
106
- * Represents a schema, including its definition and related methods.
107
- * You may be trying to build a storage, in any other can u won't need access tho this class.
108
- * Check this example
109
- *
110
- * ```typescript
111
- * class MyStorage extends <T extends SchemaTypeRecord> extends BaseStorage<T> {
112
- * example() {
113
- * const schema: Schema<any> = this.getSchema("mySchema")
114
- * }
115
- * }
116
- * ```
117
- * You alwayswill have access to getSchema through the Storage class.
118
- *
119
- * @template T - The schema type.
120
- */
121
- declare class Schema<T extends SchemaType> {
122
- /**
123
- * The schema definition.
124
- */
125
- schema: Schema<T>;
126
-
127
- /**
128
- * Creates a new `Schema` instance from the provided definition.
129
- *
130
- * @template TS - The schema type.
131
- * @param {TS} defi, Debugnition - The schema definition.
132
- * @returns {Schema<TS>} The created `Schema` instance.
133
- */
134
- static create<TS extends SchemaType>(definition: TS): Schema<TS>;
135
-
136
- /**
137
- * The version of the schema.
138
- */
139
- readonly version: number;
140
-
141
- /**
142
- * The primary key of the schema.
143
- */
144
- readonly primaryKey: string;
145
-
146
- /**
147
- * The type of the schema.
148
- */
149
- readonly type: SchemaFieldType;
150
-
151
- /**
152
- * An optional array of indexes.
153
- */
154
- /**
155
- * An optional array of indexes.
156
- */
157
- readonly indexes?: (Extract<keyof T, string>)[];
158
-
159
- /**
160
- * An optional array of encrypted fields.
161
- */
162
- readonly encrypted?: (Extract<keyof T, string>)[];
163
-
164
- /**
165
- * The properties defined in the schema.
166
- */
167
- readonly properties: {
168
- [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];
169
- } & {
170
- [K in keyof T['properties'] as T['properties'][K]['required'] extends false ? never : K]: T['properties'][K];
171
- };
172
- /**
173
- * Converts the schema to a JSON representation.
174
- *
175
- * @returns {SchemaType} The JSON representation of the schema.
176
- */
177
- toJSON(): SchemaType;
178
-
179
- validate(document: Doc<Schema<T>>): boolean;
180
- }
181
-
182
-
183
-
184
- type EnumerateUpTo<
185
- N extends number,
186
- Acc extends number[] = []
187
- > = Acc['length'] extends N ?
188
- Acc[number]:
189
- EnumerateUpTo<N, [...Acc, Acc['length']]> ;
190
-
191
- type EnumerateFrom1To<
192
- N extends number
193
- > = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
194
-
195
- type IsVersionGreaterThan0<
196
- V extends number
197
- > = V extends 0 ? false : true;
198
-
199
- type AnyVersionGreaterThan1<
200
- T extends Record<string, SchemaType>
201
- > = true extends {
202
- [K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
203
- } [keyof T] ? true : false;
204
-
205
- type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
206
-
207
- type MigrationPathsForSchema<
208
- T extends SchemaType
209
- > = T['version'] extends 0 ? {}: // No migrations needed for version 1
210
- {
211
- [K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
212
- };
213
-
214
- type MigrationPathsForSchemas<
215
- T extends SchemaTypeRecord
216
- > = {
217
- [K in keyof T]: MigrationPathsForSchema<T[K]>;
218
- };
219
-
220
- type MigrationsParameter<
221
- T extends SchemaTypeRecord
222
- > = AnyVersionGreaterThan1<T> extends true ?
223
- {
224
- migrations: MigrationPathsForSchemas<T>
225
- }:
226
- {
227
- migrations?: never
228
- };
229
-
230
-
231
-
232
- type Hook = (
233
- schema: Schema<SchemaType>,
234
- migration: MigrationPathsForSchema<SchemaType>,
235
- doc: Doc<SchemaType>
236
- ) => Doc<SchemaType>
237
-
238
- type BasePluginOptions = {
239
- docCreateHook?: Hook,
240
- docRecoverHook?: Hook
241
- }
242
-
243
- declare class BasePlugin implements BasePluginOptions {
244
- docCreateHook?:Hook;
245
- docRecoverHook?:Hook;
246
- }
247
-
248
-
249
-
250
- declare const SchemaFieldType = {
251
- /**
252
- * String type for text data
253
- */
254
- string: 'string' as const,
255
-
256
- /**
257
- * Number type for numeric data (integers and floats)
258
- */
259
- number: 'number' as const,
260
-
261
- /**
262
- * Boolean type for true/false values
263
- */
264
- boolean: 'boolean' as const,
265
-
266
- /**
267
- * Array type for ordered collections of items
268
- */
269
- array: 'array' as const,
270
-
271
- /**
272
- * Object type for nested document structures
273
- */
274
- object: 'object' as const,
275
- };
276
-
277
-
278
75
 
279
76
  type InternalsRecord = {
280
77
  [name: string]: BaseStorage<SchemaTypeRecord>
@@ -503,56 +300,259 @@ declare class Property {
503
300
  /**
504
301
  * The version of the property, if applicable.
505
302
  */
506
- readonly version?: number;
303
+ readonly version?: number;
304
+
305
+ /**
306
+ * The primary key of the property, if applicable.
307
+ */
308
+ readonly primaryKey?: string;
309
+
310
+ /**
311
+ * An optional array of nested properties for array-type properties.
312
+ */
313
+ readonly items?: Property;
314
+
315
+ /**
316
+ * The maximum number of items for array-type properties, if applicable.
317
+ */
318
+ readonly maxItems?: number;
319
+
320
+ /**
321
+ * The minimum number of items for array-type properties, if applicable.
322
+ */
323
+ readonly minItems?: number;
324
+
325
+ /**
326
+ * The maximum length for string-type properties, if applicable.
327
+ */
328
+ readonly maxLength?: number;
329
+
330
+ /**
331
+ * The minimum length for string-type properties, if applicable.
332
+ */
333
+ readonly minLength?: number;
334
+
335
+ /**
336
+ * An optional array of required fields for object-type properties.
337
+ */
338
+ readonly required?: boolean;
339
+
340
+ /**
341
+ * An optional default value for the property.
342
+ */
343
+ readonly default?: any;
344
+
345
+ /**
346
+ * An optional map of nested properties for object-type properties.
347
+ */
348
+ readonly properties?: {
349
+ [name: string]: Property;
350
+ };
351
+ }
352
+
353
+
354
+
355
+ /**
356
+ * Represents the type definition for a schema.
357
+ */
358
+ type SchemaType = {
359
+ /**
360
+ * The version of the schema.
361
+ */
362
+ version: number;
363
+
364
+ /**
365
+ * The primary key of the schema.
366
+ */
367
+ primaryKey: string;
368
+
369
+ /**
370
+ * The type of the schema.
371
+ */
372
+ type: SchemaFieldType;
373
+ indexes?: string[];
374
+ encrypted?: string[];
375
+ /**
376
+ * The properties defined in the schema.
377
+ */
378
+ properties: {
379
+ [name: string]: Property;
380
+ };
381
+ };
382
+
383
+
384
+ /**
385
+ * Represents a schema, including its definition and related methods.
386
+ * You may be trying to build a storage, in any other can u won't need access tho this class.
387
+ * Check this example
388
+ *
389
+ * ```typescript
390
+ * class MyStorage extends <T extends SchemaTypeRecord> extends BaseStorage<T> {
391
+ * example() {
392
+ * const schema: Schema<any> = this.getSchema("mySchema")
393
+ * }
394
+ * }
395
+ * ```
396
+ * You alwayswill have access to getSchema through the Storage class.
397
+ *
398
+ * @template T - The schema type.
399
+ */
400
+ declare class Schema<T extends SchemaType> {
401
+ /**
402
+ * The schema definition.
403
+ */
404
+ schema: Schema<T>;
507
405
 
508
406
  /**
509
- * The primary key of the property, if applicable.
407
+ * Creates a new `Schema` instance from the provided definition.
408
+ *
409
+ * @template TS - The schema type.
410
+ * @param {TS} defi, Debugnition - The schema definition.
411
+ * @returns {Schema<TS>} The created `Schema` instance.
510
412
  */
511
- readonly primaryKey?: string;
413
+ static create<TS extends SchemaType>(definition: TS): Schema<TS>;
512
414
 
513
415
  /**
514
- * An optional array of nested properties for array-type properties.
416
+ * The version of the schema.
515
417
  */
516
- readonly items?: Property;
418
+ readonly version: number;
517
419
 
518
420
  /**
519
- * The maximum number of items for array-type properties, if applicable.
421
+ * The primary key of the schema.
520
422
  */
521
- readonly maxItems?: number;
423
+ readonly primaryKey: string;
522
424
 
523
425
  /**
524
- * The minimum number of items for array-type properties, if applicable.
426
+ * The type of the schema.
525
427
  */
526
- readonly minItems?: number;
428
+ readonly type: SchemaFieldType;
527
429
 
528
430
  /**
529
- * The maximum length for string-type properties, if applicable.
431
+ * An optional array of indexes.
530
432
  */
531
- readonly maxLength?: number;
532
-
533
433
  /**
534
- * The minimum length for string-type properties, if applicable.
434
+ * An optional array of indexes.
535
435
  */
536
- readonly minLength?: number;
436
+ readonly indexes?: (Extract<keyof T, string>)[];
537
437
 
538
438
  /**
539
- * An optional array of required fields for object-type properties.
439
+ * An optional array of encrypted fields.
540
440
  */
541
- readonly required?: boolean;
441
+ readonly encrypted?: (Extract<keyof T, string>)[];
542
442
 
543
443
  /**
544
- * An optional default value for the property.
444
+ * The properties defined in the schema.
545
445
  */
546
- readonly default?: any;
547
-
446
+ readonly properties: {
447
+ [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];
448
+ } & {
449
+ [K in keyof T['properties'] as T['properties'][K]['required'] extends false ? never : K]: T['properties'][K];
450
+ };
548
451
  /**
549
- * An optional map of nested properties for object-type properties.
452
+ * Converts the schema to a JSON representation.
453
+ *
454
+ * @returns {SchemaType} The JSON representation of the schema.
550
455
  */
551
- readonly properties?: {
552
- [name: string]: Property;
456
+ toJSON(): SchemaType;
457
+
458
+ validate(document: Doc<Schema<T>>): boolean;
459
+ }
460
+
461
+
462
+
463
+ type EnumerateUpTo<
464
+ N extends number,
465
+ Acc extends number[] = []
466
+ > = Acc['length'] extends N ?
467
+ Acc[number]:
468
+ EnumerateUpTo<N, [...Acc, Acc['length']]> ;
469
+
470
+ type EnumerateFrom1To<
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
553
507
  };
508
+
509
+
510
+
511
+ type Hook = (
512
+ schema: Schema<SchemaType>,
513
+ migration: MigrationPathsForSchema<SchemaType>,
514
+ doc: Doc<SchemaType>
515
+ ) => Doc<SchemaType>
516
+
517
+ type BasePluginOptions = {
518
+ docCreateHook?: Hook,
519
+ docRecoverHook?: Hook
554
520
  }
555
521
 
522
+ declare class BasePlugin implements BasePluginOptions {
523
+ docCreateHook?:Hook;
524
+ docRecoverHook?:Hook;
525
+ }
526
+
527
+
528
+
529
+ declare const SchemaFieldType = {
530
+ /**
531
+ * String type for text data
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
+ };
555
+
556
556
 
557
557
 
558
558
  /**
@@ -578,6 +578,41 @@ declare class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
578
578
 
579
579
 
580
580
 
581
+ /**
582
+ * Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
583
+ * @internal
584
+ */
585
+ type SchemaTypeRecord = {
586
+ [name: string]: SchemaType
587
+ };
588
+
589
+ declare abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
590
+ constructor(
591
+ name: string,
592
+ schemas: Schemas
593
+ );
594
+ abstract start(): Promise<void>;
595
+ abstract close(): Promise<void>;
596
+ abstract count(
597
+ colectionName: keyof Schemas,
598
+ query: QueryType<Schemas[keyof Schemas]>,
599
+ options?: QueryOptions
600
+ ): Promise<number>;
601
+ abstract findDocumentById(
602
+ collectionName: keyof Schemas,
603
+ id: string
604
+ ): Promise<Doc<Schemas[keyof Schemas]> | null>;
605
+ abstract find(
606
+ collectionName: keyof Schemas,
607
+ query: QueryType<Schemas[keyof Schemas]>,
608
+ options?: QueryOptions
609
+ ): Promise<Doc<Schemas[keyof Schemas]>[]>;
610
+ abstract write(
611
+ op: Operation<Schemas[keyof Schemas]>
612
+ ): Promise<Doc<Schemas[keyof Schemas]>>;
613
+ }
614
+
615
+
581
616
  declare class CoreStorage {
582
617
  /**
583
618
  * @param {any} document
@@ -721,41 +756,6 @@ type Operation<T extends SchemaType = SchemaType> = {
721
756
  }
722
757
 
723
758
 
724
-
725
- /**
726
- * Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
727
- * @internal
728
- */
729
- type SchemaTypeRecord = {
730
- [name: string]: SchemaType
731
- };
732
-
733
- declare abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
734
- constructor(
735
- name: string,
736
- schemas: Schemas
737
- );
738
- abstract start(): Promise<void>;
739
- abstract close(): Promise<void>;
740
- abstract count(
741
- colectionName: keyof Schemas,
742
- query: QueryType<Schemas[keyof Schemas]>,
743
- options?: QueryOptions
744
- ): Promise<number>;
745
- abstract findDocumentById(
746
- collectionName: keyof Schemas,
747
- id: string
748
- ): Promise<Doc<Schemas[keyof Schemas]> | null>;
749
- abstract find(
750
- collectionName: keyof Schemas,
751
- query: QueryType<Schemas[keyof Schemas]>,
752
- options?: QueryOptions
753
- ): Promise<Doc<Schemas[keyof Schemas]>[]>;
754
- abstract write(
755
- op: Operation<Schemas[keyof Schemas]>
756
- ): Promise<Doc<Schemas[keyof Schemas]>>;
757
- }
758
-
759
759
  /**
760
760
  */
761
761
  declare class RIDBError {
@@ -867,26 +867,6 @@ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Modul
867
867
 
868
868
  interface InitOutput {
869
869
  readonly memory: WebAssembly.Memory;
870
- readonly __wbg_schema_free: (a: number) => void;
871
- readonly schema_validate: (a: number, b: number, c: number) => void;
872
- readonly schema_is_valid: (a: number, b: number) => void;
873
- readonly schema_create: (a: number, b: number) => void;
874
- readonly schema_version: (a: number) => number;
875
- readonly schema_primaryKey: (a: number, b: number) => void;
876
- readonly schema_type: (a: number, b: number) => void;
877
- readonly schema_indexes: (a: number, b: number) => void;
878
- readonly schema_encrypted: (a: number, b: number) => void;
879
- readonly schema_properties: (a: number, b: number) => void;
880
- readonly __wbgt_test_schema_creation_3: (a: number) => void;
881
- readonly __wbgt_test_schema_validation_4: (a: number) => void;
882
- readonly __wbgt_test_invalid_schema_5: (a: number) => void;
883
- readonly __wbg_baseplugin_free: (a: number) => void;
884
- readonly baseplugin_new: (a: number, b: number, c: number) => void;
885
- readonly baseplugin_name: (a: number) => number;
886
- readonly baseplugin_get_doc_create_hook: (a: number) => number;
887
- readonly baseplugin_get_doc_recover_hook: (a: number) => number;
888
- readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
889
- readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
890
870
  readonly __wbg_collection_free: (a: number) => void;
891
871
  readonly collection_name: (a: number, b: number) => void;
892
872
  readonly collection_schema: (a: number, b: number) => void;
@@ -937,6 +917,7 @@ interface InitOutput {
937
917
  readonly query_parse: (a: number, b: number) => void;
938
918
  readonly query_process_query: (a: number, b: number, c: number) => void;
939
919
  readonly query_get: (a: number, b: number, c: number, d: number) => void;
920
+ readonly query_has_or_operator: (a: number) => number;
940
921
  readonly __wbgt_test_get_properties_simple_fields_6: (a: number) => void;
941
922
  readonly __wbgt_test_get_properties_with_operators_7: (a: number) => void;
942
923
  readonly __wbgt_test_get_properties_with_logical_operators_8: (a: number) => void;
@@ -978,6 +959,26 @@ interface InitOutput {
978
959
  readonly __wbgt_test_property_creation_0: (a: number) => void;
979
960
  readonly __wbgt_test_property_validation_1: (a: number) => void;
980
961
  readonly __wbgt_test_invalid_property_2: (a: number) => void;
962
+ readonly __wbg_schema_free: (a: number) => void;
963
+ readonly schema_validate: (a: number, b: number, c: number) => void;
964
+ readonly schema_is_valid: (a: number, b: number) => void;
965
+ readonly schema_create: (a: number, b: number) => void;
966
+ readonly schema_version: (a: number) => number;
967
+ readonly schema_primaryKey: (a: number, b: number) => void;
968
+ readonly schema_type: (a: number, b: number) => void;
969
+ readonly schema_indexes: (a: number, b: number) => void;
970
+ readonly schema_encrypted: (a: number, b: number) => void;
971
+ readonly schema_properties: (a: number, b: number) => void;
972
+ readonly __wbgt_test_schema_creation_3: (a: number) => void;
973
+ readonly __wbgt_test_schema_validation_4: (a: number) => void;
974
+ readonly __wbgt_test_invalid_schema_5: (a: number) => void;
975
+ readonly __wbg_baseplugin_free: (a: number) => void;
976
+ readonly baseplugin_new: (a: number, b: number, c: number) => void;
977
+ readonly baseplugin_name: (a: number) => number;
978
+ readonly baseplugin_get_doc_create_hook: (a: number) => number;
979
+ readonly baseplugin_get_doc_recover_hook: (a: number) => number;
980
+ readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
981
+ readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
981
982
  readonly __wbg_inmemory_free: (a: number) => void;
982
983
  readonly inmemory_create: (a: number, b: number, c: number) => number;
983
984
  readonly inmemory_write: (a: number, b: number) => number;