@trust0/ridb-core 1.7.20 → 1.7.22
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 +58 -12
- package/build/ridb_core.js +30 -4
- package/build/ridb_core.mjs +31 -4
- package/build/ridb_core_bg.mjs +1 -1
- package/package.json +1 -1
package/build/ridb_core.d.ts
CHANGED
|
@@ -113,6 +113,35 @@ type Operation<T extends SchemaType = SchemaType> = {
|
|
|
113
113
|
|
|
114
114
|
|
|
115
115
|
|
|
116
|
+
declare const SchemaFieldType = {
|
|
117
|
+
/**
|
|
118
|
+
* String type for text data
|
|
119
|
+
*/
|
|
120
|
+
string: 'string' as const,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Number type for numeric data (integers and floats)
|
|
124
|
+
*/
|
|
125
|
+
number: 'number' as const,
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Boolean type for true/false values
|
|
129
|
+
*/
|
|
130
|
+
boolean: 'boolean' as const,
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Array type for ordered collections of items
|
|
134
|
+
*/
|
|
135
|
+
array: 'array' as const,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Object type for nested document structures
|
|
139
|
+
*/
|
|
140
|
+
object: 'object' as const,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
116
145
|
/**
|
|
117
146
|
* Represents a property within a schema, including various constraints and nested properties.
|
|
118
147
|
*/
|
|
@@ -120,7 +149,7 @@ declare class Property {
|
|
|
120
149
|
/**
|
|
121
150
|
* The type of the property.
|
|
122
151
|
*/
|
|
123
|
-
readonly type:
|
|
152
|
+
readonly type: SchemaFieldType;
|
|
124
153
|
|
|
125
154
|
/**
|
|
126
155
|
* The version of the property, if applicable.
|
|
@@ -234,10 +263,14 @@ type ExtractType<T extends string> =
|
|
|
234
263
|
T extends "boolean" ? boolean :
|
|
235
264
|
T extends "object" ? object :
|
|
236
265
|
T extends "array" ? any[] :
|
|
237
|
-
|
|
266
|
+
undefined;
|
|
238
267
|
|
|
239
268
|
type IsOptional<T> =
|
|
240
|
-
T extends { required:
|
|
269
|
+
T extends { required: true }
|
|
270
|
+
? T extends { default: never }
|
|
271
|
+
? false
|
|
272
|
+
: true
|
|
273
|
+
: true;
|
|
241
274
|
|
|
242
275
|
/**
|
|
243
276
|
* Doc is a utility type that transforms a schema type into a document type where each property is mapped to its extracted type.
|
|
@@ -247,14 +280,27 @@ type IsOptional<T> =
|
|
|
247
280
|
* type Document = Doc<Schema>; // Document is { name: string; age: number; }
|
|
248
281
|
*/
|
|
249
282
|
type Doc<T extends SchemaType> = {
|
|
250
|
-
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? K : never]?:
|
|
251
|
-
ExtractType<T['properties'][K]['type']> extends undefined ? `${T['properties'][K]['type']}` : ExtractType<T['properties'][K]['type']>
|
|
252
|
-
|
|
253
|
-
} & {
|
|
254
283
|
[K in keyof T["properties"]]:
|
|
255
|
-
|
|
284
|
+
ExtractType<T['properties'][K]['type']>
|
|
285
|
+
} & {
|
|
286
|
+
__version?: number;
|
|
287
|
+
createdAt?: number;
|
|
288
|
+
updatedAt?: number;
|
|
289
|
+
};
|
|
256
290
|
|
|
291
|
+
/**
|
|
292
|
+
* CreateDoc is a utility type for document creation that properly handles required vs optional fields
|
|
293
|
+
* during the creation process. Fields with default values or required: false become optional.
|
|
294
|
+
*
|
|
295
|
+
* @template T - A schema type with a 'properties' field where each property's type is represented as a string.
|
|
296
|
+
*/
|
|
297
|
+
type CreateDoc<T extends SchemaType> = {
|
|
298
|
+
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? K : never]?:
|
|
299
|
+
ExtractType<T['properties'][K]['type']>
|
|
257
300
|
} & {
|
|
301
|
+
[K in keyof T["properties"] as IsOptional<T["properties"][K]> extends true ? never : K]:
|
|
302
|
+
ExtractType<T['properties'][K]['type']>
|
|
303
|
+
} & {
|
|
258
304
|
__version?: number;
|
|
259
305
|
createdAt?: number;
|
|
260
306
|
updatedAt?: number;
|
|
@@ -303,7 +349,7 @@ declare class Collection<T extends SchemaType> {
|
|
|
303
349
|
* @param document - The document to create.
|
|
304
350
|
* @returns A promise that resolves to the created document.
|
|
305
351
|
*/
|
|
306
|
-
create(document:
|
|
352
|
+
create(document: CreateDoc<T>): Promise<Doc<T>>;
|
|
307
353
|
/**
|
|
308
354
|
* Deletes a document in the collection by its ID.
|
|
309
355
|
*
|
|
@@ -434,7 +480,7 @@ type SchemaType = {
|
|
|
434
480
|
/**
|
|
435
481
|
* The type of the schema.
|
|
436
482
|
*/
|
|
437
|
-
type:
|
|
483
|
+
type: SchemaFieldType;
|
|
438
484
|
indexes?: string[];
|
|
439
485
|
encrypted?: string[];
|
|
440
486
|
/**
|
|
@@ -490,7 +536,7 @@ declare class Schema<T extends SchemaType> {
|
|
|
490
536
|
/**
|
|
491
537
|
* The type of the schema.
|
|
492
538
|
*/
|
|
493
|
-
readonly type:
|
|
539
|
+
readonly type: SchemaFieldType;
|
|
494
540
|
|
|
495
541
|
/**
|
|
496
542
|
* An optional array of indexes.
|
|
@@ -1005,4 +1051,4 @@ declare function initSync(module: SyncInitInput): InitOutput;
|
|
|
1005
1051
|
*/
|
|
1006
1052
|
declare function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
1007
1053
|
|
|
1008
|
-
export { type AnyVersionGreaterThan1, BasePlugin, BaseStorage, type BaseStorageOptions, Collection, CoreStorage, type CreateStorage, Database, type Doc, type EnumerateFrom1To, type EnumerateUpTo, Errors, type ExtractType, InMemory, type InOperator, IndexDB, type InitInput, type InitOutput, type InternalsRecord, type IsOptional, type IsVersionGreaterThan0, type LogicalOperators, type MigrationFunction, type MigrationPathsForSchema, type MigrationPathsForSchemas, type MigrationsParameter, type NInOperator, OpType, type Operation, type OperatorOrType, type Operators, Property, Query, type QueryOptions, type QueryType, RIDBError, type RIDBModule, Schema, type SchemaType, type SchemaTypeRecord, StorageInternal, type SyncInitInput, WasmBindgenTestContext, __wbgtest_console_debug, __wbgtest_console_error, __wbgtest_console_info, __wbgtest_console_log, __wbgtest_console_warn, __wbg_init as default, initSync, is_debug_mode, main_js };
|
|
1054
|
+
export { type AnyVersionGreaterThan1, BasePlugin, BaseStorage, type BaseStorageOptions, Collection, CoreStorage, type CreateDoc, type CreateStorage, Database, type Doc, type EnumerateFrom1To, type EnumerateUpTo, Errors, type ExtractType, InMemory, type InOperator, IndexDB, type InitInput, type InitOutput, type InternalsRecord, type IsOptional, type IsVersionGreaterThan0, type LogicalOperators, type MigrationFunction, type MigrationPathsForSchema, type MigrationPathsForSchemas, type MigrationsParameter, type NInOperator, OpType, type Operation, type OperatorOrType, type Operators, Property, Query, type QueryOptions, type QueryType, RIDBError, type RIDBModule, Schema, SchemaFieldType, type SchemaType, type SchemaTypeRecord, StorageInternal, type SyncInitInput, WasmBindgenTestContext, __wbgtest_console_debug, __wbgtest_console_error, __wbgtest_console_info, __wbgtest_console_log, __wbgtest_console_warn, __wbg_init as default, initSync, is_debug_mode, main_js };
|
package/build/ridb_core.js
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
module.exports.SchemaFieldType = {
|
|
2
|
+
/**
|
|
3
|
+
* String type for text data
|
|
4
|
+
*/
|
|
5
|
+
string: 'string',
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Number type for numeric data (integers and floats)
|
|
9
|
+
*/
|
|
10
|
+
number: 'number',
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Boolean type for true/false values
|
|
14
|
+
*/
|
|
15
|
+
boolean: 'boolean',
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Array type for ordered collections of items
|
|
19
|
+
*/
|
|
20
|
+
array: 'array',
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Object type for nested document structures
|
|
24
|
+
*/
|
|
25
|
+
object: 'object',
|
|
26
|
+
};
|
|
1
27
|
"use strict";
|
|
2
28
|
var __defProp = Object.defineProperty;
|
|
3
29
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -2287,10 +2313,6 @@ function __wbg_get_imports() {
|
|
|
2287
2313
|
const ret = Collection.__wrap(arg0);
|
|
2288
2314
|
return addHeapObject(ret);
|
|
2289
2315
|
};
|
|
2290
|
-
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
2291
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
2292
|
-
return addHeapObject(ret);
|
|
2293
|
-
};
|
|
2294
2316
|
imports.wbg.__wbindgen_is_array = function(arg0) {
|
|
2295
2317
|
const ret = Array.isArray(getObject(arg0));
|
|
2296
2318
|
return ret;
|
|
@@ -2315,6 +2337,10 @@ function __wbg_get_imports() {
|
|
|
2315
2337
|
const ret = BigInt.asUintN(64, arg0);
|
|
2316
2338
|
return addHeapObject(ret);
|
|
2317
2339
|
};
|
|
2340
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
2341
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
2342
|
+
return addHeapObject(ret);
|
|
2343
|
+
};
|
|
2318
2344
|
imports.wbg.__wbg_indexdb_new = function(arg0) {
|
|
2319
2345
|
const ret = IndexDB.__wrap(arg0);
|
|
2320
2346
|
return addHeapObject(ret);
|
package/build/ridb_core.mjs
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
export const SchemaFieldType = {
|
|
2
|
+
/**
|
|
3
|
+
* String type for text data
|
|
4
|
+
*/
|
|
5
|
+
string: 'string',
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Number type for numeric data (integers and floats)
|
|
9
|
+
*/
|
|
10
|
+
number: 'number',
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Boolean type for true/false values
|
|
14
|
+
*/
|
|
15
|
+
boolean: 'boolean',
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Array type for ordered collections of items
|
|
19
|
+
*/
|
|
20
|
+
array: 'array',
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Object type for nested document structures
|
|
24
|
+
*/
|
|
25
|
+
object: 'object',
|
|
26
|
+
};
|
|
27
|
+
|
|
1
28
|
// pkg/ridb_core.js
|
|
2
29
|
var wasm;
|
|
3
30
|
var heap = new Array(128).fill(void 0);
|
|
@@ -2239,10 +2266,6 @@ function __wbg_get_imports() {
|
|
|
2239
2266
|
const ret = Collection.__wrap(arg0);
|
|
2240
2267
|
return addHeapObject(ret);
|
|
2241
2268
|
};
|
|
2242
|
-
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
2243
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
2244
|
-
return addHeapObject(ret);
|
|
2245
|
-
};
|
|
2246
2269
|
imports.wbg.__wbindgen_is_array = function(arg0) {
|
|
2247
2270
|
const ret = Array.isArray(getObject(arg0));
|
|
2248
2271
|
return ret;
|
|
@@ -2267,6 +2290,10 @@ function __wbg_get_imports() {
|
|
|
2267
2290
|
const ret = BigInt.asUintN(64, arg0);
|
|
2268
2291
|
return addHeapObject(ret);
|
|
2269
2292
|
};
|
|
2293
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
2294
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
2295
|
+
return addHeapObject(ret);
|
|
2296
|
+
};
|
|
2270
2297
|
imports.wbg.__wbg_indexdb_new = function(arg0) {
|
|
2271
2298
|
const ret = IndexDB.__wrap(arg0);
|
|
2272
2299
|
return addHeapObject(ret);
|