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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "1.4.3",
8
+ "version": "1.4.4-rc.1",
9
9
  "main": "./pkg/ridb_core.js",
10
10
  "types": "./pkg/ridb_core.d.ts",
11
11
  "sideEffects": [
@@ -186,70 +186,6 @@ export class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageIntern
186
186
 
187
187
 
188
188
 
189
- /**
190
- * Represents an in-memory storage system extending the base storage functionality.
191
- *
192
- * @template T - The schema type.
193
- */
194
- export class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
195
- /**
196
- * Frees the resources used by the in-memory storage.
197
- */
198
- free(): void;
199
-
200
- static create<SchemasCreate extends SchemaTypeRecord>(
201
- dbName: string,
202
- schemas: SchemasCreate,
203
- ): Promise<
204
- InMemory<
205
- SchemasCreate
206
- >
207
- >;
208
- }
209
-
210
-
211
-
212
- /**
213
- * Represents an IndexDB storage system extending the base storage functionality.
214
- *
215
- * @template T - The schema type.
216
- */
217
- export class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
218
- /**
219
- * Frees the resources used by the in-memory storage.
220
- */
221
- free(): void;
222
-
223
- static create<SchemasCreate extends SchemaTypeRecord>(
224
- dbName: string,
225
- schemas: SchemasCreate,
226
- ): Promise<
227
- IndexDB<
228
- SchemasCreate
229
- >
230
- >;
231
- }
232
-
233
-
234
-
235
- type Hook = (
236
- schema: Schema<SchemaType>,
237
- migration: MigrationPathsForSchema<SchemaType>,
238
- doc: Doc<SchemaType>
239
- ) => Doc<SchemaType>
240
-
241
- type BasePluginOptions = {
242
- docCreateHook?: Hook,
243
- docRecoverHook?: Hook
244
- }
245
-
246
- export class BasePlugin implements BasePluginOptions {
247
- docCreateHook?:Hook;
248
- docRecoverHook?:Hook;
249
- }
250
-
251
-
252
-
253
189
  /**
254
190
  * Represents a database containing collections of documents.
255
191
  * RIDB extends from this class and is used to expose collections.
@@ -353,38 +289,132 @@ export type RIDBModule = {
353
289
 
354
290
 
355
291
  /**
356
- * Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
292
+ * Represents an in-memory storage system extending the base storage functionality.
293
+ *
294
+ * @template T - The schema type.
357
295
  */
358
- export type SchemaTypeRecord = {
359
- [name: string]: SchemaType
360
- };
296
+ export class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
297
+ /**
298
+ * Frees the resources used by the in-memory storage.
299
+ */
300
+ free(): void;
361
301
 
362
- export abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
363
- constructor(
364
- name: string,
365
- schemas: Schemas
366
- );
367
- abstract start(): Promise<void>;
368
- abstract close(): Promise<void>;
369
- abstract count(
370
- colectionName: keyof Schemas,
371
- query: QueryType<Schemas[keyof Schemas]>,
372
- options?: QueryOptions
373
- ): Promise<number>;
374
- abstract findDocumentById(
375
- collectionName: keyof Schemas,
376
- id: string
377
- ): Promise<Doc<Schemas[keyof Schemas]> | null>;
378
- abstract find(
379
- collectionName: keyof Schemas,
380
- query: QueryType<Schemas[keyof Schemas]>,
381
- options?: QueryOptions
382
- ): Promise<Doc<Schemas[keyof Schemas]>[]>;
383
- abstract write(
384
- op: Operation<Schemas[keyof Schemas]>
385
- ): Promise<Doc<Schemas[keyof Schemas]>>;
302
+ static create<SchemasCreate extends SchemaTypeRecord>(
303
+ dbName: string,
304
+ schemas: SchemasCreate,
305
+ ): Promise<
306
+ InMemory<
307
+ SchemasCreate
308
+ >
309
+ >;
310
+ }
311
+
312
+
313
+
314
+ /**
315
+ * Represents an IndexDB storage system extending the base storage functionality.
316
+ *
317
+ * @template T - The schema type.
318
+ */
319
+ export class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
320
+ /**
321
+ * Frees the resources used by the in-memory storage.
322
+ */
323
+ free(): void;
324
+
325
+ static create<SchemasCreate extends SchemaTypeRecord>(
326
+ dbName: string,
327
+ schemas: SchemasCreate,
328
+ ): Promise<
329
+ IndexDB<
330
+ SchemasCreate
331
+ >
332
+ >;
333
+ }
334
+
335
+
336
+
337
+ type Hook = (
338
+ schema: Schema<SchemaType>,
339
+ migration: MigrationPathsForSchema<SchemaType>,
340
+ doc: Doc<SchemaType>
341
+ ) => Doc<SchemaType>
342
+
343
+ type BasePluginOptions = {
344
+ docCreateHook?: Hook,
345
+ docRecoverHook?: Hook
386
346
  }
387
347
 
348
+ export class BasePlugin implements BasePluginOptions {
349
+ docCreateHook?:Hook;
350
+ docRecoverHook?:Hook;
351
+ }
352
+
353
+
354
+
355
+ /**
356
+ * Represents a property within a schema, including various constraints and nested properties.
357
+ */
358
+ export class Property {
359
+ /**
360
+ * The type of the property.
361
+ */
362
+ readonly type: string;
363
+
364
+ /**
365
+ * The version of the property, if applicable.
366
+ */
367
+ readonly version?: number;
368
+
369
+ /**
370
+ * The primary key of the property, if applicable.
371
+ */
372
+ readonly primaryKey?: string;
373
+
374
+ /**
375
+ * An optional array of nested properties for array-type properties.
376
+ */
377
+ readonly items?: Property;
378
+
379
+ /**
380
+ * The maximum number of items for array-type properties, if applicable.
381
+ */
382
+ readonly maxItems?: number;
383
+
384
+ /**
385
+ * The minimum number of items for array-type properties, if applicable.
386
+ */
387
+ readonly minItems?: number;
388
+
389
+ /**
390
+ * The maximum length for string-type properties, if applicable.
391
+ */
392
+ readonly maxLength?: number;
393
+
394
+ /**
395
+ * The minimum length for string-type properties, if applicable.
396
+ */
397
+ readonly minLength?: number;
398
+
399
+ /**
400
+ * An optional array of required fields for object-type properties.
401
+ */
402
+ readonly required?: boolean;
403
+
404
+ /**
405
+ * An optional default value for the property.
406
+ */
407
+ readonly default?: any;
408
+
409
+ /**
410
+ * An optional map of nested properties for object-type properties.
411
+ */
412
+ readonly properties?: {
413
+ [name: string]: Property;
414
+ };
415
+ }
416
+
417
+
388
418
 
389
419
  /**
390
420
  * Represents the type definition for a schema.
@@ -593,6 +623,40 @@ export class Collection<T extends SchemaType> {
593
623
 
594
624
 
595
625
 
626
+ /**
627
+ * Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
628
+ */
629
+ export type SchemaTypeRecord = {
630
+ [name: string]: SchemaType
631
+ };
632
+
633
+ export abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
634
+ constructor(
635
+ name: string,
636
+ schemas: Schemas
637
+ );
638
+ abstract start(): Promise<void>;
639
+ abstract close(): Promise<void>;
640
+ abstract count(
641
+ colectionName: keyof Schemas,
642
+ query: QueryType<Schemas[keyof Schemas]>,
643
+ options?: QueryOptions
644
+ ): Promise<number>;
645
+ abstract findDocumentById(
646
+ collectionName: keyof Schemas,
647
+ id: string
648
+ ): Promise<Doc<Schemas[keyof Schemas]> | null>;
649
+ abstract find(
650
+ collectionName: keyof Schemas,
651
+ query: QueryType<Schemas[keyof Schemas]>,
652
+ options?: QueryOptions
653
+ ): Promise<Doc<Schemas[keyof Schemas]>[]>;
654
+ abstract write(
655
+ op: Operation<Schemas[keyof Schemas]>
656
+ ): Promise<Doc<Schemas[keyof Schemas]>>;
657
+ }
658
+
659
+
596
660
  export type EnumerateUpTo<
597
661
  N extends number,
598
662
  Acc extends number[] = []
@@ -640,75 +704,25 @@ export type MigrationsParameter<
640
704
  };
641
705
 
642
706
 
643
-
644
- /**
645
- * Represents a property within a schema, including various constraints and nested properties.
646
- */
647
- export class Property {
648
- /**
649
- * The type of the property.
650
- */
651
- readonly type: string;
652
-
653
- /**
654
- * The version of the property, if applicable.
655
- */
656
- readonly version?: number;
657
-
658
- /**
659
- * The primary key of the property, if applicable.
660
- */
661
- readonly primaryKey?: string;
662
-
663
- /**
664
- * An optional array of nested properties for array-type properties.
665
- */
666
- readonly items?: Property;
667
-
668
- /**
669
- * The maximum number of items for array-type properties, if applicable.
670
- */
671
- readonly maxItems?: number;
672
-
673
- /**
674
- * The minimum number of items for array-type properties, if applicable.
675
- */
676
- readonly minItems?: number;
677
-
678
- /**
679
- * The maximum length for string-type properties, if applicable.
680
- */
681
- readonly maxLength?: number;
682
-
683
- /**
684
- * The minimum length for string-type properties, if applicable.
685
- */
686
- readonly minLength?: number;
687
-
688
- /**
689
- * An optional array of required fields for object-type properties.
690
- */
691
- readonly required?: boolean;
692
-
693
- /**
694
- * An optional default value for the property.
695
- */
696
- readonly default?: any;
697
-
698
- /**
699
- * An optional map of nested properties for object-type properties.
700
- */
701
- readonly properties?: {
702
- [name: string]: Property;
703
- };
704
- }
705
-
706
-
707
707
  /**
708
708
  */
709
709
  export class RIDBError {
710
+ /**
711
+ ** Return copy of self without private attributes.
712
+ */
713
+ toJSON(): Object;
714
+ /**
715
+ * Return stringified version of self.
716
+ */
717
+ toString(): string;
710
718
  free(): void;
711
719
  /**
720
+ * @param {string} err_type
721
+ * @param {string} message
722
+ * @param {number} code
723
+ */
724
+ constructor(err_type: string, message: string, code: number);
725
+ /**
712
726
  * @param {any} err
713
727
  * @returns {RIDBError}
714
728
  */
@@ -857,6 +871,27 @@ export interface InitOutput {
857
871
  readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
858
872
  readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
859
873
  readonly basestorage_core: (a: number, b: number) => void;
874
+ readonly __wbg_ridberror_free: (a: number) => void;
875
+ readonly ridberror_new: (a: number, b: number, c: number, d: number, e: number) => number;
876
+ readonly ridberror_type: (a: number, b: number) => void;
877
+ readonly ridberror_code: (a: number) => number;
878
+ readonly ridberror_message: (a: number, b: number) => void;
879
+ readonly ridberror_from: (a: number) => number;
880
+ readonly ridberror_error: (a: number, b: number, c: number) => number;
881
+ readonly ridberror_query: (a: number, b: number, c: number) => number;
882
+ readonly ridberror_authentication: (a: number, b: number, c: number) => number;
883
+ readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
884
+ readonly ridberror_validation: (a: number, b: number, c: number) => number;
885
+ readonly ridberror_hook: (a: number, b: number, c: number) => number;
886
+ readonly __wbg_database_free: (a: number) => void;
887
+ readonly database_start: (a: number) => number;
888
+ readonly database_close: (a: number) => number;
889
+ readonly database_started: (a: number) => number;
890
+ readonly database_collections: (a: number, b: number) => void;
891
+ readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
892
+ readonly __wbg_queryoptions_free: (a: number) => void;
893
+ readonly queryoptions_limit: (a: number, b: number) => void;
894
+ readonly queryoptions_offset: (a: number, b: number) => void;
860
895
  readonly __wbg_inmemory_free: (a: number) => void;
861
896
  readonly inmemory_create: (a: number, b: number, c: number) => number;
862
897
  readonly inmemory_write: (a: number, b: number) => number;
@@ -882,26 +917,18 @@ export interface InitOutput {
882
917
  readonly baseplugin_get_doc_recover_hook: (a: number) => number;
883
918
  readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
884
919
  readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
885
- readonly __wbg_ridberror_free: (a: number) => void;
886
- readonly ridberror_type: (a: number, b: number) => void;
887
- readonly ridberror_code: (a: number) => number;
888
- readonly ridberror_message: (a: number, b: number) => void;
889
- readonly ridberror_from: (a: number) => number;
890
- readonly ridberror_error: (a: number, b: number, c: number) => number;
891
- readonly ridberror_query: (a: number, b: number, c: number) => number;
892
- readonly ridberror_authentication: (a: number, b: number, c: number) => number;
893
- readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
894
- readonly ridberror_validation: (a: number, b: number, c: number) => number;
895
- readonly ridberror_hook: (a: number, b: number, c: number) => number;
896
- readonly __wbg_database_free: (a: number) => void;
897
- readonly database_start: (a: number) => number;
898
- readonly database_close: (a: number) => number;
899
- readonly database_started: (a: number) => number;
900
- readonly database_collections: (a: number, b: number) => void;
901
- readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
902
- readonly __wbg_queryoptions_free: (a: number) => void;
903
- readonly queryoptions_limit: (a: number, b: number) => void;
904
- readonly queryoptions_offset: (a: number, b: number) => void;
920
+ readonly __wbg_property_free: (a: number) => void;
921
+ readonly property_is_valid: (a: number, b: number) => void;
922
+ readonly property_type: (a: number) => number;
923
+ readonly property_items: (a: number, b: number) => void;
924
+ readonly property_maxItems: (a: number, b: number) => void;
925
+ readonly property_minItems: (a: number, b: number) => void;
926
+ readonly property_maxLength: (a: number, b: number) => void;
927
+ readonly property_minLength: (a: number, b: number) => void;
928
+ readonly property_properties: (a: number, b: number) => void;
929
+ readonly __wbgt_test_property_creation_0: (a: number) => void;
930
+ readonly __wbgt_test_property_validation_1: (a: number) => void;
931
+ readonly __wbgt_test_invalid_property_2: (a: number) => void;
905
932
  readonly __wbg_schema_free: (a: number) => void;
906
933
  readonly schema_validate: (a: number, b: number, c: number) => void;
907
934
  readonly schema_is_valid: (a: number, b: number) => void;
@@ -925,18 +952,6 @@ export interface InitOutput {
925
952
  readonly collection_update: (a: number, b: number) => number;
926
953
  readonly collection_create: (a: number, b: number) => number;
927
954
  readonly collection_delete: (a: number, b: number) => number;
928
- readonly __wbg_property_free: (a: number) => void;
929
- readonly property_is_valid: (a: number, b: number) => void;
930
- readonly property_type: (a: number) => number;
931
- readonly property_items: (a: number, b: number) => void;
932
- readonly property_maxItems: (a: number, b: number) => void;
933
- readonly property_minItems: (a: number, b: number) => void;
934
- readonly property_maxLength: (a: number, b: number) => void;
935
- readonly property_minLength: (a: number, b: number) => void;
936
- readonly property_properties: (a: number, b: number) => void;
937
- readonly __wbgt_test_property_creation_0: (a: number) => void;
938
- readonly __wbgt_test_property_validation_1: (a: number) => void;
939
- readonly __wbgt_test_invalid_property_2: (a: number) => void;
940
955
  readonly __wbg_wasmbindgentestcontext_free: (a: number) => void;
941
956
  readonly wasmbindgentestcontext_new: () => number;
942
957
  readonly wasmbindgentestcontext_args: (a: number, b: number, c: number) => void;
package/pkg/ridb_core.js CHANGED
@@ -409,15 +409,15 @@ export function __wbgtest_console_error(args) {
409
409
  }
410
410
  }
411
411
 
412
- function __wbg_adapter_294(arg0, arg1) {
412
+ function __wbg_adapter_295(arg0, arg1) {
413
413
  wasm.wasm_bindgen__convert__closures__invoke0_mut__hf4bced6426ca6f31(arg0, arg1);
414
414
  }
415
415
 
416
- function __wbg_adapter_337(arg0, arg1, arg2, arg3, arg4) {
416
+ function __wbg_adapter_338(arg0, arg1, arg2, arg3, arg4) {
417
417
  wasm.wasm_bindgen__convert__closures__invoke3_mut__h425269a7185d1f5b(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
418
418
  }
419
419
 
420
- function __wbg_adapter_388(arg0, arg1, arg2, arg3) {
420
+ function __wbg_adapter_389(arg0, arg1, arg2, arg3) {
421
421
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h1b9fff078715ef14(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
422
422
  }
423
423
 
@@ -1808,6 +1808,18 @@ export class RIDBError {
1808
1808
  return obj;
1809
1809
  }
1810
1810
 
1811
+ toJSON() {
1812
+ return {
1813
+ type: this.type,
1814
+ code: this.code,
1815
+ message: this.message,
1816
+ };
1817
+ }
1818
+
1819
+ toString() {
1820
+ return JSON.stringify(this);
1821
+ }
1822
+
1811
1823
  __destroy_into_raw() {
1812
1824
  const ptr = this.__wbg_ptr;
1813
1825
  this.__wbg_ptr = 0;
@@ -1820,6 +1832,20 @@ export class RIDBError {
1820
1832
  wasm.__wbg_ridberror_free(ptr);
1821
1833
  }
1822
1834
  /**
1835
+ * @param {string} err_type
1836
+ * @param {string} message
1837
+ * @param {number} code
1838
+ */
1839
+ constructor(err_type, message, code) {
1840
+ const ptr0 = passStringToWasm0(err_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1841
+ const len0 = WASM_VECTOR_LEN;
1842
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1843
+ const len1 = WASM_VECTOR_LEN;
1844
+ const ret = wasm.ridberror_new(ptr0, len0, ptr1, len1, code);
1845
+ this.__wbg_ptr = ret >>> 0;
1846
+ return this;
1847
+ }
1848
+ /**
1823
1849
  * @returns {string}
1824
1850
  */
1825
1851
  get type() {
@@ -2677,7 +2703,7 @@ function __wbg_get_imports() {
2677
2703
  const a = state0.a;
2678
2704
  state0.a = 0;
2679
2705
  try {
2680
- return __wbg_adapter_294(a, state0.b, );
2706
+ return __wbg_adapter_295(a, state0.b, );
2681
2707
  } finally {
2682
2708
  state0.a = a;
2683
2709
  }
@@ -2842,7 +2868,7 @@ function __wbg_get_imports() {
2842
2868
  const a = state0.a;
2843
2869
  state0.a = 0;
2844
2870
  try {
2845
- return __wbg_adapter_337(a, state0.b, arg0, arg1, arg2);
2871
+ return __wbg_adapter_338(a, state0.b, arg0, arg1, arg2);
2846
2872
  } finally {
2847
2873
  state0.a = a;
2848
2874
  }
@@ -2921,7 +2947,7 @@ function __wbg_get_imports() {
2921
2947
  const a = state0.a;
2922
2948
  state0.a = 0;
2923
2949
  try {
2924
- return __wbg_adapter_388(a, state0.b, arg0, arg1);
2950
+ return __wbg_adapter_389(a, state0.b, arg0, arg1);
2925
2951
  } finally {
2926
2952
  state0.a = a;
2927
2953
  }
@@ -3033,7 +3059,7 @@ function __wbg_get_imports() {
3033
3059
  const ret = makeMutClosure(arg0, arg1, 177, __wbg_adapter_62);
3034
3060
  return addHeapObject(ret);
3035
3061
  };
3036
- imports.wbg.__wbindgen_closure_wrapper1617 = function(arg0, arg1, arg2) {
3062
+ imports.wbg.__wbindgen_closure_wrapper1619 = function(arg0, arg1, arg2) {
3037
3063
  const ret = makeMutClosure(arg0, arg1, 449, __wbg_adapter_65);
3038
3064
  return addHeapObject(ret);
3039
3065
  };
Binary file