@trust0/ridb-core 1.7.28 → 1.7.30

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.
@@ -73,70 +73,6 @@ declare enum Errors {
73
73
  AuthenticationError = 5,
74
74
  }
75
75
 
76
- /**
77
- * Represents a property within a schema, including various constraints and nested properties.
78
- */
79
- declare class Property {
80
- /**
81
- * The type of the property.
82
- */
83
- readonly type: SchemaFieldType;
84
-
85
- /**
86
- * The version of the property, if applicable.
87
- */
88
- readonly version?: number;
89
-
90
- /**
91
- * The primary key of the property, if applicable.
92
- */
93
- readonly primaryKey?: string;
94
-
95
- /**
96
- * An optional array of nested properties for array-type properties.
97
- */
98
- readonly items?: Property;
99
-
100
- /**
101
- * The maximum number of items for array-type properties, if applicable.
102
- */
103
- readonly maxItems?: number;
104
-
105
- /**
106
- * The minimum number of items for array-type properties, if applicable.
107
- */
108
- readonly minItems?: number;
109
-
110
- /**
111
- * The maximum length for string-type properties, if applicable.
112
- */
113
- readonly maxLength?: number;
114
-
115
- /**
116
- * The minimum length for string-type properties, if applicable.
117
- */
118
- readonly minLength?: number;
119
-
120
- /**
121
- * An optional array of required fields for object-type properties.
122
- */
123
- readonly required?: boolean;
124
-
125
- /**
126
- * An optional default value for the property.
127
- */
128
- readonly default?: any;
129
-
130
- /**
131
- * An optional map of nested properties for object-type properties.
132
- */
133
- readonly properties?: {
134
- [name: string]: Property;
135
- };
136
- }
137
-
138
-
139
-
140
76
  /**
141
77
  * Represents an IndexDB storage system extending the base storage functionality.
142
78
  *
@@ -201,6 +137,162 @@ declare class BasePlugin implements BasePluginOptions {
201
137
 
202
138
 
203
139
 
140
+ /**
141
+ * Represents the type definition for a schema.
142
+ */
143
+ type SchemaType = {
144
+ /**
145
+ * The version of the schema.
146
+ */
147
+ version: number;
148
+
149
+ /**
150
+ * The primary key of the schema.
151
+ */
152
+ primaryKey: string;
153
+
154
+ /**
155
+ * The type of the schema.
156
+ */
157
+ type: SchemaFieldType;
158
+ indexes?: string[];
159
+ encrypted?: string[];
160
+ /**
161
+ * The properties defined in the schema.
162
+ */
163
+ properties: {
164
+ [name: string]: Property;
165
+ };
166
+ };
167
+
168
+
169
+ /**
170
+ * Represents a schema, including its definition and related methods.
171
+ * You may be trying to build a storage, in any other can u won't need access tho this class.
172
+ * Check this example
173
+ *
174
+ * ```typescript
175
+ * class MyStorage extends <T extends SchemaTypeRecord> extends BaseStorage<T> {
176
+ * example() {
177
+ * const schema: Schema<any> = this.getSchema("mySchema")
178
+ * }
179
+ * }
180
+ * ```
181
+ * You alwayswill have access to getSchema through the Storage class.
182
+ *
183
+ * @template T - The schema type.
184
+ */
185
+ declare class Schema<T extends SchemaType> {
186
+ /**
187
+ * The schema definition.
188
+ */
189
+ schema: Schema<T>;
190
+
191
+ /**
192
+ * Creates a new `Schema` instance from the provided definition.
193
+ *
194
+ * @template TS - The schema type.
195
+ * @param {TS} defi, Debugnition - The schema definition.
196
+ * @returns {Schema<TS>} The created `Schema` instance.
197
+ */
198
+ static create<TS extends SchemaType>(definition: TS): Schema<TS>;
199
+
200
+ /**
201
+ * The version of the schema.
202
+ */
203
+ readonly version: number;
204
+
205
+ /**
206
+ * The primary key of the schema.
207
+ */
208
+ readonly primaryKey: string;
209
+
210
+ /**
211
+ * The type of the schema.
212
+ */
213
+ readonly type: SchemaFieldType;
214
+
215
+ /**
216
+ * An optional array of indexes.
217
+ */
218
+ /**
219
+ * An optional array of indexes.
220
+ */
221
+ readonly indexes?: (Extract<keyof T, string>)[];
222
+
223
+ /**
224
+ * An optional array of encrypted fields.
225
+ */
226
+ readonly encrypted?: (Extract<keyof T, string>)[];
227
+
228
+ /**
229
+ * The properties defined in the schema.
230
+ */
231
+ readonly properties: {
232
+ [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];
233
+ } & {
234
+ [K in keyof T['properties'] as T['properties'][K]['required'] extends false ? never : K]: T['properties'][K];
235
+ };
236
+ /**
237
+ * Converts the schema to a JSON representation.
238
+ *
239
+ * @returns {SchemaType} The JSON representation of the schema.
240
+ */
241
+ toJSON(): SchemaType;
242
+
243
+ validate(document: Doc<Schema<T>>): boolean;
244
+ }
245
+
246
+
247
+
248
+ type EnumerateUpTo<
249
+ N extends number,
250
+ Acc extends number[] = []
251
+ > = Acc['length'] extends N ?
252
+ Acc[number]:
253
+ EnumerateUpTo<N, [...Acc, Acc['length']]> ;
254
+
255
+ type EnumerateFrom1To<
256
+ N extends number
257
+ > = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
258
+
259
+ type IsVersionGreaterThan0<
260
+ V extends number
261
+ > = V extends 0 ? false : true;
262
+
263
+ type AnyVersionGreaterThan1<
264
+ T extends Record<string, SchemaType>
265
+ > = true extends {
266
+ [K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
267
+ } [keyof T] ? true : false;
268
+
269
+ type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
270
+
271
+ type MigrationPathsForSchema<
272
+ T extends SchemaType
273
+ > = T['version'] extends 0 ? {}: // No migrations needed for version 1
274
+ {
275
+ [K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
276
+ };
277
+
278
+ type MigrationPathsForSchemas<
279
+ T extends SchemaTypeRecord
280
+ > = {
281
+ [K in keyof T]: MigrationPathsForSchema<T[K]>;
282
+ };
283
+
284
+ type MigrationsParameter<
285
+ T extends SchemaTypeRecord
286
+ > = AnyVersionGreaterThan1<T> extends true ?
287
+ {
288
+ migrations: MigrationPathsForSchemas<T>
289
+ }:
290
+ {
291
+ migrations?: never
292
+ };
293
+
294
+
295
+
204
296
  type Operators<T> = {
205
297
  $gte?: number,
206
298
  $gt?: number
@@ -237,32 +329,67 @@ declare class Query<T extends SchemaType> {
237
329
 
238
330
 
239
331
 
240
- declare const SchemaFieldType = {
241
- /**
242
- * String type for text data
243
- */
244
- string: 'string' as const,
245
-
246
- /**
247
- * Number type for numeric data (integers and floats)
248
- */
249
- number: 'number' as const,
250
-
251
- /**
252
- * Boolean type for true/false values
253
- */
254
- boolean: 'boolean' as const,
255
-
256
- /**
257
- * Array type for ordered collections of items
258
- */
259
- array: 'array' as const,
260
-
261
- /**
262
- * Object type for nested document structures
263
- */
264
- object: 'object' as const,
265
- };
332
+ /**
333
+ * Represents a property within a schema, including various constraints and nested properties.
334
+ */
335
+ declare class Property {
336
+ /**
337
+ * The type of the property.
338
+ */
339
+ readonly type: SchemaFieldType;
340
+
341
+ /**
342
+ * The version of the property, if applicable.
343
+ */
344
+ readonly version?: number;
345
+
346
+ /**
347
+ * The primary key of the property, if applicable.
348
+ */
349
+ readonly primaryKey?: string;
350
+
351
+ /**
352
+ * An optional array of nested properties for array-type properties.
353
+ */
354
+ readonly items?: Property;
355
+
356
+ /**
357
+ * The maximum number of items for array-type properties, if applicable.
358
+ */
359
+ readonly maxItems?: number;
360
+
361
+ /**
362
+ * The minimum number of items for array-type properties, if applicable.
363
+ */
364
+ readonly minItems?: number;
365
+
366
+ /**
367
+ * The maximum length for string-type properties, if applicable.
368
+ */
369
+ readonly maxLength?: number;
370
+
371
+ /**
372
+ * The minimum length for string-type properties, if applicable.
373
+ */
374
+ readonly minLength?: number;
375
+
376
+ /**
377
+ * An optional array of required fields for object-type properties.
378
+ */
379
+ readonly required?: boolean;
380
+
381
+ /**
382
+ * An optional default value for the property.
383
+ */
384
+ readonly default?: any;
385
+
386
+ /**
387
+ * An optional map of nested properties for object-type properties.
388
+ */
389
+ readonly properties?: {
390
+ [name: string]: Property;
391
+ };
392
+ }
266
393
 
267
394
 
268
395
 
@@ -529,6 +656,35 @@ type RIDBModule = {
529
656
 
530
657
 
531
658
 
659
+ declare const SchemaFieldType = {
660
+ /**
661
+ * String type for text data
662
+ */
663
+ string: 'string' as const,
664
+
665
+ /**
666
+ * Number type for numeric data (integers and floats)
667
+ */
668
+ number: 'number' as const,
669
+
670
+ /**
671
+ * Boolean type for true/false values
672
+ */
673
+ boolean: 'boolean' as const,
674
+
675
+ /**
676
+ * Array type for ordered collections of items
677
+ */
678
+ array: 'array' as const,
679
+
680
+ /**
681
+ * Object type for nested document structures
682
+ */
683
+ object: 'object' as const,
684
+ };
685
+
686
+
687
+
532
688
  /**
533
689
  * Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
534
690
  * @internal
@@ -600,162 +756,6 @@ declare class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInter
600
756
  }
601
757
 
602
758
 
603
-
604
- /**
605
- * Represents the type definition for a schema.
606
- */
607
- type SchemaType = {
608
- /**
609
- * The version of the schema.
610
- */
611
- version: number;
612
-
613
- /**
614
- * The primary key of the schema.
615
- */
616
- primaryKey: string;
617
-
618
- /**
619
- * The type of the schema.
620
- */
621
- type: SchemaFieldType;
622
- indexes?: string[];
623
- encrypted?: string[];
624
- /**
625
- * The properties defined in the schema.
626
- */
627
- properties: {
628
- [name: string]: Property;
629
- };
630
- };
631
-
632
-
633
- /**
634
- * Represents a schema, including its definition and related methods.
635
- * You may be trying to build a storage, in any other can u won't need access tho this class.
636
- * Check this example
637
- *
638
- * ```typescript
639
- * class MyStorage extends <T extends SchemaTypeRecord> extends BaseStorage<T> {
640
- * example() {
641
- * const schema: Schema<any> = this.getSchema("mySchema")
642
- * }
643
- * }
644
- * ```
645
- * You alwayswill have access to getSchema through the Storage class.
646
- *
647
- * @template T - The schema type.
648
- */
649
- declare class Schema<T extends SchemaType> {
650
- /**
651
- * The schema definition.
652
- */
653
- schema: Schema<T>;
654
-
655
- /**
656
- * Creates a new `Schema` instance from the provided definition.
657
- *
658
- * @template TS - The schema type.
659
- * @param {TS} defi, Debugnition - The schema definition.
660
- * @returns {Schema<TS>} The created `Schema` instance.
661
- */
662
- static create<TS extends SchemaType>(definition: TS): Schema<TS>;
663
-
664
- /**
665
- * The version of the schema.
666
- */
667
- readonly version: number;
668
-
669
- /**
670
- * The primary key of the schema.
671
- */
672
- readonly primaryKey: string;
673
-
674
- /**
675
- * The type of the schema.
676
- */
677
- readonly type: SchemaFieldType;
678
-
679
- /**
680
- * An optional array of indexes.
681
- */
682
- /**
683
- * An optional array of indexes.
684
- */
685
- readonly indexes?: (Extract<keyof T, string>)[];
686
-
687
- /**
688
- * An optional array of encrypted fields.
689
- */
690
- readonly encrypted?: (Extract<keyof T, string>)[];
691
-
692
- /**
693
- * The properties defined in the schema.
694
- */
695
- readonly properties: {
696
- [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];
697
- } & {
698
- [K in keyof T['properties'] as T['properties'][K]['required'] extends false ? never : K]: T['properties'][K];
699
- };
700
- /**
701
- * Converts the schema to a JSON representation.
702
- *
703
- * @returns {SchemaType} The JSON representation of the schema.
704
- */
705
- toJSON(): SchemaType;
706
-
707
- validate(document: Doc<Schema<T>>): boolean;
708
- }
709
-
710
-
711
-
712
- type EnumerateUpTo<
713
- N extends number,
714
- Acc extends number[] = []
715
- > = Acc['length'] extends N ?
716
- Acc[number]:
717
- EnumerateUpTo<N, [...Acc, Acc['length']]> ;
718
-
719
- type EnumerateFrom1To<
720
- N extends number
721
- > = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
722
-
723
- type IsVersionGreaterThan0<
724
- V extends number
725
- > = V extends 0 ? false : true;
726
-
727
- type AnyVersionGreaterThan1<
728
- T extends Record<string, SchemaType>
729
- > = true extends {
730
- [K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
731
- } [keyof T] ? true : false;
732
-
733
- type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
734
-
735
- type MigrationPathsForSchema<
736
- T extends SchemaType
737
- > = T['version'] extends 0 ? {}: // No migrations needed for version 1
738
- {
739
- [K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
740
- };
741
-
742
- type MigrationPathsForSchemas<
743
- T extends SchemaTypeRecord
744
- > = {
745
- [K in keyof T]: MigrationPathsForSchema<T[K]>;
746
- };
747
-
748
- type MigrationsParameter<
749
- T extends SchemaTypeRecord
750
- > = AnyVersionGreaterThan1<T> extends true ?
751
- {
752
- migrations: MigrationPathsForSchemas<T>
753
- }:
754
- {
755
- migrations?: never
756
- };
757
-
758
-
759
759
  /**
760
760
  */
761
761
  declare class RIDBError {
@@ -867,18 +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_property_free: (a: number) => void;
871
- readonly property_is_valid: (a: number, b: number) => void;
872
- readonly property_type: (a: number) => number;
873
- readonly property_items: (a: number, b: number) => void;
874
- readonly property_maxItems: (a: number, b: number) => void;
875
- readonly property_minItems: (a: number, b: number) => void;
876
- readonly property_maxLength: (a: number, b: number) => void;
877
- readonly property_minLength: (a: number, b: number) => void;
878
- readonly property_properties: (a: number, b: number) => void;
879
- readonly __wbgt_test_property_creation_0: (a: number) => void;
880
- readonly __wbgt_test_property_validation_1: (a: number) => void;
881
- readonly __wbgt_test_invalid_property_2: (a: number) => void;
882
870
  readonly __wbg_ridberror_free: (a: number) => void;
883
871
  readonly ridberror_new: (a: number, b: number, c: number, d: number, e: number) => number;
884
872
  readonly ridberror_type: (a: number, b: number) => void;
@@ -916,6 +904,19 @@ interface InitOutput {
916
904
  readonly baseplugin_get_doc_recover_hook: (a: number) => number;
917
905
  readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
918
906
  readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
907
+ readonly __wbg_schema_free: (a: number) => void;
908
+ readonly schema_validate: (a: number, b: number, c: number) => void;
909
+ readonly schema_is_valid: (a: number, b: number) => void;
910
+ readonly schema_create: (a: number, b: number) => void;
911
+ readonly schema_version: (a: number) => number;
912
+ readonly schema_primaryKey: (a: number, b: number) => void;
913
+ readonly schema_type: (a: number, b: number) => void;
914
+ readonly schema_indexes: (a: number, b: number) => void;
915
+ readonly schema_encrypted: (a: number, b: number) => void;
916
+ readonly schema_properties: (a: number, b: number) => void;
917
+ readonly __wbgt_test_schema_creation_3: (a: number) => void;
918
+ readonly __wbgt_test_schema_validation_4: (a: number) => void;
919
+ readonly __wbgt_test_invalid_schema_5: (a: number) => void;
919
920
  readonly __wbg_query_free: (a: number) => void;
920
921
  readonly query_new: (a: number, b: number, c: number) => void;
921
922
  readonly query_query: (a: number, b: number) => void;
@@ -952,8 +953,18 @@ interface InitOutput {
952
953
  readonly __wbgt_test_query_parse_eq_operator_wrong_type_32: (a: number) => void;
953
954
  readonly __wbgt_test_query_parse_ne_operator_33: (a: number) => void;
954
955
  readonly __wbgt_test_query_parse_ne_operator_wrong_type_34: (a: number) => void;
955
- readonly main_js: () => void;
956
- readonly is_debug_mode: () => number;
956
+ readonly __wbg_property_free: (a: number) => void;
957
+ readonly property_is_valid: (a: number, b: number) => void;
958
+ readonly property_type: (a: number) => number;
959
+ readonly property_items: (a: number, b: number) => void;
960
+ readonly property_maxItems: (a: number, b: number) => void;
961
+ readonly property_minItems: (a: number, b: number) => void;
962
+ readonly property_maxLength: (a: number, b: number) => void;
963
+ readonly property_minLength: (a: number, b: number) => void;
964
+ readonly property_properties: (a: number, b: number) => void;
965
+ readonly __wbgt_test_property_creation_0: (a: number) => void;
966
+ readonly __wbgt_test_property_validation_1: (a: number) => void;
967
+ readonly __wbgt_test_invalid_property_2: (a: number) => void;
957
968
  readonly __wbg_collection_free: (a: number) => void;
958
969
  readonly collection_name: (a: number, b: number) => void;
959
970
  readonly collection_schema: (a: number, b: number) => void;
@@ -986,25 +997,14 @@ interface InitOutput {
986
997
  readonly database_authenticate: (a: number, b: number, c: number) => number;
987
998
  readonly database_collections: (a: number, b: number) => void;
988
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 main_js: () => void;
1001
+ readonly is_debug_mode: () => number;
989
1002
  readonly __wbg_basestorage_free: (a: number) => void;
990
1003
  readonly basestorage_new: (a: number, b: number, c: number, d: number, e: number) => void;
991
1004
  readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
992
1005
  readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
993
1006
  readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
994
1007
  readonly basestorage_core: (a: number, b: number) => void;
995
- readonly __wbg_schema_free: (a: number) => void;
996
- readonly schema_validate: (a: number, b: number, c: number) => void;
997
- readonly schema_is_valid: (a: number, b: number) => void;
998
- readonly schema_create: (a: number, b: number) => void;
999
- readonly schema_version: (a: number) => number;
1000
- readonly schema_primaryKey: (a: number, b: number) => void;
1001
- readonly schema_type: (a: number, b: number) => void;
1002
- readonly schema_indexes: (a: number, b: number) => void;
1003
- readonly schema_encrypted: (a: number, b: number) => void;
1004
- readonly schema_properties: (a: number, b: number) => void;
1005
- readonly __wbgt_test_schema_creation_3: (a: number) => void;
1006
- readonly __wbgt_test_schema_validation_4: (a: number) => void;
1007
- readonly __wbgt_test_invalid_schema_5: (a: number) => void;
1008
1008
  readonly __wbg_wasmbindgentestcontext_free: (a: number) => void;
1009
1009
  readonly wasmbindgentestcontext_new: () => number;
1010
1010
  readonly wasmbindgentestcontext_args: (a: number, b: number, c: number) => void;