@trust0/ridb-core 1.7.42 → 1.8.0
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 +696 -645
- package/build/ridb_core.js +616 -573
- package/build/ridb_core.mjs +616 -573
- package/build/ridb_core_bg.mjs +1 -1
- package/package.json +2 -2
package/build/ridb_core.d.ts
CHANGED
|
@@ -28,15 +28,25 @@ declare function __wbgtest_console_debug(args: Array<any>): void;
|
|
|
28
28
|
*/
|
|
29
29
|
declare function __wbgtest_console_info(args: Array<any>): void;
|
|
30
30
|
/**
|
|
31
|
+
* Handler for `console.warn` invocations. See above.
|
|
32
|
+
* @param {Array<any>} args
|
|
33
|
+
*/
|
|
34
|
+
declare function __wbgtest_console_warn(args: Array<any>): void;
|
|
35
|
+
/**
|
|
31
36
|
* Handler for `console.error` invocations. See above.
|
|
32
37
|
* @param {Array<any>} args
|
|
33
38
|
*/
|
|
34
39
|
declare function __wbgtest_console_error(args: Array<any>): void;
|
|
35
40
|
/**
|
|
36
|
-
* Handler for `console.warn` invocations. See above.
|
|
37
|
-
* @param {Array<any>} args
|
|
38
41
|
*/
|
|
39
|
-
declare
|
|
42
|
+
declare enum Errors {
|
|
43
|
+
Error = 0,
|
|
44
|
+
HookError = 1,
|
|
45
|
+
QueryError = 2,
|
|
46
|
+
SerializationError = 3,
|
|
47
|
+
ValidationError = 4,
|
|
48
|
+
AuthenticationError = 5,
|
|
49
|
+
}
|
|
40
50
|
/**
|
|
41
51
|
* Represents the type of operation to be performed on the collection.
|
|
42
52
|
*/
|
|
@@ -62,49 +72,26 @@ 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
75
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Represents an in-memory storage system extending the base storage functionality.
|
|
78
|
+
*
|
|
79
|
+
* @template T - The schema type.
|
|
80
|
+
*/
|
|
81
|
+
declare class InMemory<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
82
|
+
/**
|
|
83
|
+
* Frees the resources used by the in-memory storage.
|
|
84
|
+
*/
|
|
85
|
+
free(): void;
|
|
96
86
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
88
|
+
dbName: string,
|
|
89
|
+
schemas: SchemasCreate,
|
|
90
|
+
): Promise<
|
|
91
|
+
InMemory<
|
|
92
|
+
SchemasCreate
|
|
101
93
|
>
|
|
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>;
|
|
94
|
+
>;
|
|
108
95
|
}
|
|
109
96
|
|
|
110
97
|
|
|
@@ -138,243 +125,430 @@ declare const SchemaFieldType = {
|
|
|
138
125
|
|
|
139
126
|
|
|
140
127
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
* @param {Query} query
|
|
145
|
-
* @returns {boolean}
|
|
146
|
-
*/
|
|
147
|
-
matchesQuery(document: any, query: Query<any>): boolean;
|
|
148
|
-
getPrimaryKeyTyped(value: any): string | number;
|
|
149
|
-
getIndexes(schema: Schema<any>, op: Operation): string[];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
128
|
+
type InternalsRecord = {
|
|
129
|
+
[name: string]: BaseStorage<SchemaTypeRecord>
|
|
130
|
+
};
|
|
154
131
|
/**
|
|
155
|
-
*
|
|
132
|
+
* ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
|
|
156
133
|
*
|
|
157
|
-
* @template T -
|
|
134
|
+
* @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* type StringType = ExtractType<'string'>; // StringType is string
|
|
138
|
+
* type NumberType = ExtractType<'number'>; // NumberType is number
|
|
139
|
+
* type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
|
|
140
|
+
* type ObjectType = ExtractType<'object'>; // ObjectType is object
|
|
141
|
+
* type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
|
|
158
142
|
*/
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
dbName: string,
|
|
167
|
-
schemas: SchemasCreate,
|
|
168
|
-
): Promise<
|
|
169
|
-
IndexDB<
|
|
170
|
-
SchemasCreate
|
|
171
|
-
>
|
|
172
|
-
>;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
type EnumerateUpTo<
|
|
178
|
-
N extends number,
|
|
179
|
-
Acc extends number[] = []
|
|
180
|
-
> = Acc['length'] extends N ?
|
|
181
|
-
Acc[number]:
|
|
182
|
-
EnumerateUpTo<N, [...Acc, Acc['length']]> ;
|
|
183
|
-
|
|
184
|
-
type EnumerateFrom1To<
|
|
185
|
-
N extends number
|
|
186
|
-
> = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
|
|
187
|
-
|
|
188
|
-
type IsVersionGreaterThan0<
|
|
189
|
-
V extends number
|
|
190
|
-
> = V extends 0 ? false : true;
|
|
191
|
-
|
|
192
|
-
type AnyVersionGreaterThan1<
|
|
193
|
-
T extends Record<string, SchemaType>
|
|
194
|
-
> = true extends {
|
|
195
|
-
[K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
|
|
196
|
-
} [keyof T] ? true : false;
|
|
197
|
-
|
|
198
|
-
type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
|
|
199
|
-
|
|
200
|
-
type MigrationPathsForSchema<
|
|
201
|
-
T extends SchemaType
|
|
202
|
-
> = T['version'] extends 0 ? {}: // No migrations needed for version 1
|
|
203
|
-
{
|
|
204
|
-
[K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
type MigrationPathsForSchemas<
|
|
208
|
-
T extends SchemaTypeRecord
|
|
209
|
-
> = {
|
|
210
|
-
[K in keyof T]: MigrationPathsForSchema<T[K]>;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
type MigrationsParameter<
|
|
214
|
-
T extends SchemaTypeRecord
|
|
215
|
-
> = AnyVersionGreaterThan1<T> extends true ?
|
|
216
|
-
{
|
|
217
|
-
migrations: MigrationPathsForSchemas<T>
|
|
218
|
-
}:
|
|
219
|
-
{
|
|
220
|
-
migrations?: never
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
|
|
143
|
+
type ExtractType<T extends string> =
|
|
144
|
+
T extends "string" ? string :
|
|
145
|
+
T extends "number" ? number :
|
|
146
|
+
T extends "boolean" ? boolean :
|
|
147
|
+
T extends "object" ? object :
|
|
148
|
+
T extends "array" ? any[] :
|
|
149
|
+
undefined;
|
|
224
150
|
|
|
225
151
|
/**
|
|
226
|
-
*
|
|
152
|
+
* ExtractProperty maps a full Property definition to its document type. Unlike
|
|
153
|
+
* {@link ExtractType} (which only looks at the `type` string), it recurses into
|
|
154
|
+
* `items` for arrays and `properties` for objects, producing precise nested types.
|
|
227
155
|
*
|
|
228
|
-
* @
|
|
156
|
+
* @example
|
|
157
|
+
* type Tags = ExtractProperty<{ type: "array"; items: { type: "string" } }>; // string[]
|
|
158
|
+
* type Obj = ExtractProperty<{ type: "object"; properties: { id: { type: "string" } } }>; // { id: string }
|
|
229
159
|
*/
|
|
230
|
-
type
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
* The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
|
|
238
|
-
*/
|
|
239
|
-
opType: OpType,
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* The data involved in the operation, conforming to the schema type.
|
|
243
|
-
*/
|
|
244
|
-
data: Doc<T>,
|
|
245
|
-
|
|
246
|
-
primaryKeyField?: string,
|
|
247
|
-
primaryKey?: string
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
160
|
+
type ExtractProperty<P> =
|
|
161
|
+
P extends { type: "string" } ? string :
|
|
162
|
+
P extends { type: "number" } ? number :
|
|
163
|
+
P extends { type: "boolean" } ? boolean :
|
|
164
|
+
P extends { type: "array" } ? (P extends { items: infer I } ? ExtractProperty<I>[] : any[]) :
|
|
165
|
+
P extends { type: "object" } ? (P extends { properties: infer PR } ? ExtractObject<PR, NestedRequiredNames<P>> : object) :
|
|
166
|
+
unknown;
|
|
251
167
|
|
|
252
168
|
/**
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
169
|
+
* NestedRequiredNames extracts the union of nested property names listed in an object
|
|
170
|
+
* property's `required` array (JSON Schema semantics), or `never` when no array is
|
|
171
|
+
* present. Note it only matches the array form; a boolean `required` flag yields `never`.
|
|
256
172
|
*/
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
free(): void;
|
|
262
|
-
|
|
263
|
-
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
264
|
-
dbName: string,
|
|
265
|
-
schemas: SchemasCreate,
|
|
266
|
-
): Promise<
|
|
267
|
-
InMemory<
|
|
268
|
-
SchemasCreate
|
|
269
|
-
>
|
|
270
|
-
>;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
173
|
+
type NestedRequiredNames<P> =
|
|
174
|
+
P extends { required: infer R }
|
|
175
|
+
? (R extends readonly string[] ? R[number] : never)
|
|
176
|
+
: never;
|
|
274
177
|
|
|
275
178
|
/**
|
|
276
|
-
*
|
|
179
|
+
* FlagRequiredness interprets a property's `required` declaration when it is used as a
|
|
180
|
+
* legacy boolean flag. Because `Property.required` is typed `boolean | string[]`, a
|
|
181
|
+
* schema literal written without `as const` widens `true`/`false` to `boolean`; the
|
|
182
|
+
* tuple-wrapped checks below classify each case:
|
|
183
|
+
* - a literal `false` -> `"optional"`;
|
|
184
|
+
* - a literal `true`, or a widened `boolean` (whose literal was lost) -> `"required"`.
|
|
185
|
+
* Treating the ambiguous `boolean` as required matches the Rust validator and turns a
|
|
186
|
+
* would-be runtime "missing required property" error into a compile-time one instead;
|
|
187
|
+
* - the array form, or no `required` key -> `"defer"` to the container `required` array.
|
|
277
188
|
*/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
189
|
+
type FlagRequiredness<P> =
|
|
190
|
+
P extends { required: infer F }
|
|
191
|
+
? ([F] extends [readonly string[]] ? "defer"
|
|
192
|
+
: [F] extends [false] ? "optional"
|
|
193
|
+
: [true] extends [F] ? "required"
|
|
194
|
+
: "defer")
|
|
195
|
+
: "defer";
|
|
283
196
|
|
|
197
|
+
/**
|
|
198
|
+
* IsNestedOptional decides whether a nested property `K` (within an object property's
|
|
199
|
+
* `properties` map `PR`, given that object's required-name union `R`) may be omitted.
|
|
200
|
+
* Precedence mirrors the runtime validator and {@link IsCreateOptional}:
|
|
201
|
+
* 1. a declared `default` makes the field optional;
|
|
202
|
+
* 2. a boolean `required` flag wins (`false` -> optional, `true`/`boolean` -> required);
|
|
203
|
+
* 3. otherwise it is required iff listed in the object's `required` array;
|
|
204
|
+
* 4. otherwise it is optional.
|
|
205
|
+
*/
|
|
206
|
+
type IsNestedOptional<PR, K extends keyof PR, R> =
|
|
207
|
+
PR[K] extends { default: unknown } ? true
|
|
208
|
+
: FlagRequiredness<PR[K]> extends "optional" ? true
|
|
209
|
+
: FlagRequiredness<PR[K]> extends "required" ? false
|
|
210
|
+
: K extends R ? false
|
|
211
|
+
: true;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* ExtractObject builds an object document type from a `properties` map `PR` and the
|
|
215
|
+
* owning object's required-name union `R`, applying the correct optional/required
|
|
216
|
+
* modifier to each nested property (see {@link IsNestedOptional}). This keeps `Doc` and
|
|
217
|
+
* `CreateDoc` in step with the runtime validator, which only enforces nested keys named
|
|
218
|
+
* in that object's `required` array.
|
|
219
|
+
*/
|
|
220
|
+
type ExtractObject<PR, R> = {
|
|
221
|
+
[K in keyof PR as IsNestedOptional<PR, K, R> extends true ? never : K]:
|
|
222
|
+
ExtractProperty<PR[K]>
|
|
223
|
+
} & {
|
|
224
|
+
[K in keyof PR as IsNestedOptional<PR, K, R> extends true ? K : never]?:
|
|
225
|
+
ExtractProperty<PR[K]>
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The union of property names marked required at the schema level (JSON Schema
|
|
230
|
+
* `required` array). Resolves to `never` when no `required` array is present.
|
|
231
|
+
*/
|
|
232
|
+
type RequiredFieldNames<T extends SchemaType> =
|
|
233
|
+
T extends { required: infer R }
|
|
234
|
+
? (R extends readonly string[] ? R[number] : never)
|
|
235
|
+
: never;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* IsCreateOptional decides whether a property may be omitted when creating a document.
|
|
239
|
+
* Precedence (mirrors the runtime validator):
|
|
240
|
+
* 1. a declared `default` makes the field optional;
|
|
241
|
+
* 2. a boolean `required` flag wins (`false` -> optional, `true`/`boolean` -> required;
|
|
242
|
+
* see {@link FlagRequiredness});
|
|
243
|
+
* 3. otherwise it is required iff listed in the schema-level `required` array;
|
|
244
|
+
* 4. otherwise it is optional.
|
|
245
|
+
*/
|
|
246
|
+
type IsCreateOptional<T extends SchemaType, K extends keyof T["properties"]> =
|
|
247
|
+
T["properties"][K] extends { default: unknown } ? true
|
|
248
|
+
: FlagRequiredness<T["properties"][K]> extends "optional" ? true
|
|
249
|
+
: FlagRequiredness<T["properties"][K]> extends "required" ? false
|
|
250
|
+
: K extends RequiredFieldNames<T> ? false
|
|
251
|
+
: true;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Doc is a utility type that transforms a schema type into a stored-document type. A
|
|
255
|
+
* property is mandatory only when the validator guarantees its presence; properties that
|
|
256
|
+
* are optional at creation (not listed in `required`, flagged `required: false`, or
|
|
257
|
+
* carrying a `default`) may be absent on a stored document, so they are optional here
|
|
258
|
+
* too. This keeps `find`/`findById`/`create` return types from claiming keys that may not
|
|
259
|
+
* exist. Optionality uses the same {@link IsCreateOptional} rules as {@link CreateDoc}.
|
|
260
|
+
*
|
|
261
|
+
* @template T - A schema type with a 'properties' field where each property's type is represented as a string.
|
|
262
|
+
*
|
|
263
|
+
* type Document = Doc<Schema>; // Document is { name: string; age: number; }
|
|
264
|
+
*/
|
|
265
|
+
type Doc<T extends SchemaType> = {
|
|
266
|
+
[K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? never : K]:
|
|
267
|
+
ExtractProperty<T['properties'][K]>
|
|
268
|
+
} & {
|
|
269
|
+
[K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? K : never]?:
|
|
270
|
+
ExtractProperty<T['properties'][K]>
|
|
271
|
+
} & {
|
|
272
|
+
__version?: number;
|
|
273
|
+
/**
|
|
274
|
+
* Unix timestamp (in seconds) set automatically when the document is created.
|
|
275
|
+
* Managed internally by RIDB — it cannot be set or changed by the caller.
|
|
276
|
+
*/
|
|
277
|
+
createdAt: number;
|
|
278
|
+
/**
|
|
279
|
+
* Unix timestamp (in seconds) refreshed automatically on every create/update.
|
|
280
|
+
* Managed internally by RIDB — it cannot be set or changed by the caller.
|
|
281
|
+
*/
|
|
282
|
+
updatedAt: number;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* CreateDoc is a utility type for document creation that properly handles required vs optional fields
|
|
287
|
+
* during the creation process. Fields with default values, or fields not listed in the schema-level
|
|
288
|
+
* `required` array, become optional.
|
|
289
|
+
*
|
|
290
|
+
* @template T - A schema type with a 'properties' field where each property's type is represented as a string.
|
|
291
|
+
*/
|
|
292
|
+
type CreateDoc<T extends SchemaType> = {
|
|
293
|
+
[K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? K : never]?:
|
|
294
|
+
ExtractProperty<T['properties'][K]>
|
|
295
|
+
} & {
|
|
296
|
+
[K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? never : K]:
|
|
297
|
+
ExtractProperty<T['properties'][K]>
|
|
298
|
+
} & {
|
|
299
|
+
__version?: number;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* UpdateDoc is the accepted input shape for `Collection.update`. It is a partial
|
|
304
|
+
* document keyed by the schema properties. The internally-managed timestamp fields
|
|
305
|
+
* (`createdAt`/`updatedAt`) are intentionally excluded — they are set and refreshed
|
|
306
|
+
* by RIDB and cannot be provided by the caller.
|
|
307
|
+
*/
|
|
308
|
+
type UpdateDoc<T extends SchemaType> = Partial<Omit<Doc<T>, "createdAt" | "updatedAt">>;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* The direction used when sorting query results by a given field.
|
|
312
|
+
*/
|
|
313
|
+
type SortDirection = 'asc' | 'desc';
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* A single sort instruction: which field to sort by and in which direction.
|
|
317
|
+
* `field` is constrained to the schema's property names, and `direction`
|
|
318
|
+
* defaults to `'asc'` when omitted.
|
|
319
|
+
*/
|
|
320
|
+
type SortSpec<T extends SchemaType = SchemaType> = {
|
|
321
|
+
field: (keyof T['properties'] & string) | 'createdAt' | 'updatedAt';
|
|
322
|
+
direction?: SortDirection;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
type QueryOptions<T extends SchemaType = SchemaType> = {
|
|
326
|
+
limit?: number;
|
|
327
|
+
offset?: number;
|
|
284
328
|
/**
|
|
285
|
-
*
|
|
329
|
+
* Sorts the results by one or more fields. Accepts a single sort specification
|
|
330
|
+
* or an array of them (applied in order, the first field being the primary sort key).
|
|
286
331
|
*/
|
|
287
|
-
|
|
332
|
+
sort?: SortSpec<T> | SortSpec<T>[];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Collection is a class that represents a collection of documents in a database.
|
|
337
|
+
* @template T - A schema type defining the structure of the documents in the collection.
|
|
338
|
+
*/
|
|
339
|
+
declare class Collection<T extends SchemaType> {
|
|
340
|
+
/**
|
|
341
|
+
* Finds all documents in the collection.
|
|
342
|
+
*
|
|
343
|
+
* @returns A promise that resolves to an array of documents.
|
|
344
|
+
*/
|
|
345
|
+
find(query: QueryType<T>, options?: QueryOptions<T>): Promise<Doc<T>[]>;
|
|
346
|
+
/**
|
|
347
|
+
* count all documents in the collection.
|
|
348
|
+
*
|
|
349
|
+
* @returns A promise that resolves to an array of documents.
|
|
350
|
+
*/
|
|
351
|
+
count(query: QueryType<T>, options?: QueryOptions<T>): Promise<number>;
|
|
352
|
+
/**
|
|
353
|
+
* Finds a single document in the collection by its ID.
|
|
354
|
+
*
|
|
355
|
+
* @param id - The ID of the document to find.
|
|
356
|
+
* @returns A promise that resolves to the found document.
|
|
357
|
+
*/
|
|
358
|
+
findById(id: string): Promise<Doc<T>>;
|
|
359
|
+
/**
|
|
360
|
+
* Updates a document in the collection by its ID.
|
|
361
|
+
*
|
|
362
|
+
* @param document - A partial document containing the fields to update.
|
|
363
|
+
* @returns A promise that resolves when the update is complete.
|
|
364
|
+
*/
|
|
365
|
+
update(document: UpdateDoc<T>): Promise<void>;
|
|
366
|
+
/**
|
|
367
|
+
* Creates a new document in the collection.
|
|
368
|
+
*
|
|
369
|
+
* @param document - The document to create.
|
|
370
|
+
* @returns A promise that resolves to the created document.
|
|
371
|
+
*/
|
|
372
|
+
create(document: CreateDoc<T>): Promise<Doc<T>>;
|
|
373
|
+
/**
|
|
374
|
+
* Deletes a document in the collection by its ID.
|
|
375
|
+
*
|
|
376
|
+
* @param id - The ID of the document to delete.
|
|
377
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
378
|
+
*/
|
|
379
|
+
delete(id: string): Promise<void>;
|
|
380
|
+
}
|
|
288
381
|
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Represents the type definition for a schema.
|
|
387
|
+
*/
|
|
388
|
+
type SchemaType = {
|
|
289
389
|
/**
|
|
290
|
-
* The
|
|
390
|
+
* The version of the schema.
|
|
291
391
|
*/
|
|
292
|
-
|
|
392
|
+
version: number;
|
|
293
393
|
|
|
294
394
|
/**
|
|
295
|
-
*
|
|
395
|
+
* The primary key of the schema.
|
|
296
396
|
*/
|
|
297
|
-
|
|
397
|
+
primaryKey: string;
|
|
298
398
|
|
|
299
399
|
/**
|
|
300
|
-
* The
|
|
400
|
+
* The type of the schema.
|
|
301
401
|
*/
|
|
302
|
-
|
|
402
|
+
type: SchemaFieldType;
|
|
403
|
+
indexes?: string[];
|
|
404
|
+
encrypted?: string[];
|
|
405
|
+
/**
|
|
406
|
+
* The names of the required top-level properties. Follows JSON Schema
|
|
407
|
+
* semantics: only the listed properties are required.
|
|
408
|
+
*/
|
|
409
|
+
required?: string[];
|
|
410
|
+
/**
|
|
411
|
+
* The properties defined in the schema.
|
|
412
|
+
*/
|
|
413
|
+
properties: {
|
|
414
|
+
[name: string]: Property;
|
|
415
|
+
};
|
|
416
|
+
};
|
|
303
417
|
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Represents a schema, including its definition and related methods.
|
|
421
|
+
* You may be trying to build a storage, in any other can u won't need access tho this class.
|
|
422
|
+
* Check this example
|
|
423
|
+
*
|
|
424
|
+
* ```typescript
|
|
425
|
+
* class MyStorage extends <T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
426
|
+
* example() {
|
|
427
|
+
* const schema: Schema<any> = this.getSchema("mySchema")
|
|
428
|
+
* }
|
|
429
|
+
* }
|
|
430
|
+
* ```
|
|
431
|
+
* You alwayswill have access to getSchema through the Storage class.
|
|
432
|
+
*
|
|
433
|
+
* @template T - The schema type.
|
|
434
|
+
*/
|
|
435
|
+
declare class Schema<T extends SchemaType> {
|
|
304
436
|
/**
|
|
305
|
-
* The
|
|
437
|
+
* The schema definition.
|
|
306
438
|
*/
|
|
307
|
-
|
|
439
|
+
schema: Schema<T>;
|
|
308
440
|
|
|
309
441
|
/**
|
|
310
|
-
*
|
|
442
|
+
* Creates a new `Schema` instance from the provided definition.
|
|
443
|
+
*
|
|
444
|
+
* @template TS - The schema type.
|
|
445
|
+
* @param {TS} defi, Debugnition - The schema definition.
|
|
446
|
+
* @returns {Schema<TS>} The created `Schema` instance.
|
|
311
447
|
*/
|
|
312
|
-
|
|
448
|
+
static create<TS extends SchemaType>(definition: TS): Schema<TS>;
|
|
313
449
|
|
|
314
450
|
/**
|
|
315
|
-
* The
|
|
451
|
+
* The version of the schema.
|
|
316
452
|
*/
|
|
317
|
-
readonly
|
|
453
|
+
readonly version: number;
|
|
318
454
|
|
|
319
455
|
/**
|
|
320
|
-
*
|
|
321
|
-
* - `boolean`: a per-property flag (legacy). `false` forces the property optional,
|
|
322
|
-
* `true` forces it required, overriding any container-level `required` array.
|
|
323
|
-
* - `string[]`: for object-type properties, the JSON Schema list of required
|
|
324
|
-
* nested properties.
|
|
456
|
+
* The primary key of the schema.
|
|
325
457
|
*/
|
|
326
|
-
readonly
|
|
458
|
+
readonly primaryKey: string;
|
|
327
459
|
|
|
328
460
|
/**
|
|
329
|
-
*
|
|
461
|
+
* The type of the schema.
|
|
330
462
|
*/
|
|
331
|
-
readonly
|
|
463
|
+
readonly type: SchemaFieldType;
|
|
332
464
|
|
|
333
465
|
/**
|
|
334
|
-
* An optional
|
|
466
|
+
* An optional array of indexes.
|
|
335
467
|
*/
|
|
336
|
-
|
|
337
|
-
|
|
468
|
+
/**
|
|
469
|
+
* An optional array of indexes.
|
|
470
|
+
*/
|
|
471
|
+
readonly indexes?: (Extract<keyof T, string>)[];
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* An optional array of encrypted fields.
|
|
475
|
+
*/
|
|
476
|
+
readonly encrypted?: (Extract<keyof T, string>)[];
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* The properties defined in the schema.
|
|
480
|
+
*/
|
|
481
|
+
readonly properties: {
|
|
482
|
+
[K in keyof T['properties']]: T['properties'][K];
|
|
338
483
|
};
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* The names of the required top-level properties.
|
|
487
|
+
*/
|
|
488
|
+
readonly required?: (Extract<keyof T['properties'], string>)[];
|
|
489
|
+
/**
|
|
490
|
+
* Converts the schema to a JSON representation.
|
|
491
|
+
*
|
|
492
|
+
* @returns {SchemaType} The JSON representation of the schema.
|
|
493
|
+
*/
|
|
494
|
+
toJSON(): SchemaType;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Validates a document against the schema. The runtime applies the same
|
|
498
|
+
* optional/required rules as creation (only `required` fields, without a `default`,
|
|
499
|
+
* must be present), so the accepted shape is `CreateDoc<T>` rather than a fully-keyed
|
|
500
|
+
* `Doc<T>`.
|
|
501
|
+
*/
|
|
502
|
+
validate(document: CreateDoc<T>): boolean;
|
|
339
503
|
}
|
|
340
504
|
|
|
341
505
|
|
|
342
506
|
|
|
507
|
+
type Operators<T> = {
|
|
508
|
+
$gte?: number,
|
|
509
|
+
$gt?: number
|
|
510
|
+
$lt?: number,
|
|
511
|
+
$lte?: number,
|
|
512
|
+
$eq?: T,
|
|
513
|
+
$ne?: T
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
type InOperator<T> = { $in?: T[] };
|
|
517
|
+
type NInOperator<T> = { $nin?: T[] };
|
|
518
|
+
|
|
519
|
+
type OperatorOrType<T> = T extends number ?
|
|
520
|
+
T | Operators<T> | InOperator<T> | NInOperator<T> :
|
|
521
|
+
T | InOperator<T> | NInOperator<T>;
|
|
522
|
+
|
|
523
|
+
type LogicalOperators<T extends SchemaType> = {
|
|
524
|
+
$and?: Partial<QueryType<T>>[];
|
|
525
|
+
$or?: Partial<QueryType<T>>[];
|
|
526
|
+
};
|
|
527
|
+
|
|
343
528
|
/**
|
|
344
|
-
*
|
|
345
|
-
*
|
|
529
|
+
* The internally-managed timestamp fields available for querying on every collection.
|
|
530
|
+
* They cannot be written by the caller but can be filtered (and sorted) like numbers.
|
|
346
531
|
*/
|
|
347
|
-
type
|
|
348
|
-
|
|
532
|
+
type ManagedTimestampsQuery = {
|
|
533
|
+
createdAt?: OperatorOrType<number>;
|
|
534
|
+
updatedAt?: OperatorOrType<number>;
|
|
349
535
|
};
|
|
350
536
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
): Promise<number>;
|
|
363
|
-
abstract findDocumentById(
|
|
364
|
-
collectionName: keyof Schemas,
|
|
365
|
-
id: string
|
|
366
|
-
): Promise<Doc<Schemas[keyof Schemas]> | null>;
|
|
367
|
-
abstract find(
|
|
368
|
-
collectionName: keyof Schemas,
|
|
369
|
-
query: QueryType<Schemas[keyof Schemas]>,
|
|
370
|
-
options?: QueryOptions
|
|
371
|
-
): Promise<Doc<Schemas[keyof Schemas]>[]>;
|
|
372
|
-
abstract write(
|
|
373
|
-
op: Operation<Schemas[keyof Schemas]>
|
|
374
|
-
): Promise<Doc<Schemas[keyof Schemas]>>;
|
|
537
|
+
type QueryType<T extends SchemaType> = ({
|
|
538
|
+
[K in keyof T['properties']as ExtractType<T['properties'][K]['type']> extends undefined ? never : K]?: OperatorOrType<
|
|
539
|
+
ExtractType<
|
|
540
|
+
T['properties'][K]['type']
|
|
541
|
+
>
|
|
542
|
+
>
|
|
543
|
+
} & ManagedTimestampsQuery & LogicalOperators<T>) | LogicalOperators<T>[];
|
|
544
|
+
|
|
545
|
+
declare class Query<T extends SchemaType> {
|
|
546
|
+
constructor(query: QueryType<T>, schema:Schema<T>);
|
|
547
|
+
readonly query: QueryType<T>;
|
|
375
548
|
}
|
|
376
549
|
|
|
377
550
|
|
|
551
|
+
|
|
378
552
|
type Hook = (
|
|
379
553
|
schema: Schema<SchemaType>,
|
|
380
554
|
migration: MigrationPathsForSchema<SchemaType>,
|
|
@@ -393,43 +567,6 @@ declare class BasePlugin implements BasePluginOptions {
|
|
|
393
567
|
|
|
394
568
|
|
|
395
569
|
|
|
396
|
-
type BaseStorageOptions = {
|
|
397
|
-
[name:string]:string | boolean | number
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
declare class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInternal<Schemas> {
|
|
401
|
-
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
402
|
-
dbName: string,
|
|
403
|
-
schemas: SchemasCreate,
|
|
404
|
-
options?: BaseStorageOptions
|
|
405
|
-
): Promise<
|
|
406
|
-
BaseStorage<
|
|
407
|
-
SchemasCreate
|
|
408
|
-
>
|
|
409
|
-
>;
|
|
410
|
-
constructor(
|
|
411
|
-
dbName: string,
|
|
412
|
-
schemas: Schemas,
|
|
413
|
-
options?: BaseStorageOptions
|
|
414
|
-
);
|
|
415
|
-
readonly dbName: string;
|
|
416
|
-
readonly schemas: Record<keyof Schemas, Schema<Schemas[keyof Schemas]>>;
|
|
417
|
-
readonly options: BaseStorageOptions;
|
|
418
|
-
readonly core: CoreStorage;
|
|
419
|
-
start(): Promise<void>;
|
|
420
|
-
close(): Promise<void>;
|
|
421
|
-
count(colectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<number>;
|
|
422
|
-
findDocumentById(collectionName: keyof Schemas, id: string): Promise<Doc<Schemas[keyof Schemas]> | null>;
|
|
423
|
-
find(collectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions): Promise<Doc<Schemas[keyof Schemas]>[]>;
|
|
424
|
-
write(op: Operation<Schemas[keyof Schemas]>): Promise<Doc<Schemas[keyof Schemas]>>;
|
|
425
|
-
getOption(name: string): string | boolean | number | undefined;
|
|
426
|
-
getSchema(name: string): Schema<any>;
|
|
427
|
-
//Call addIndexSchemas if you need extra indexing schemas for your database
|
|
428
|
-
addIndexSchemas(): null
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
570
|
/**
|
|
434
571
|
* Represents a database containing collections of documents.
|
|
435
572
|
* RIDB extends from this class and is used to expose collections.
|
|
@@ -534,347 +671,259 @@ type RIDBModule = {
|
|
|
534
671
|
|
|
535
672
|
|
|
536
673
|
|
|
537
|
-
type
|
|
538
|
-
[name:
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* ExtractType is a utility type that maps a string representing a basic data type to the actual TypeScript type.
|
|
542
|
-
*
|
|
543
|
-
* @template T - A string literal type representing the basic data type ('string', 'number', 'boolean', 'object', 'array').
|
|
544
|
-
*
|
|
545
|
-
* @example
|
|
546
|
-
* type StringType = ExtractType<'string'>; // StringType is string
|
|
547
|
-
* type NumberType = ExtractType<'number'>; // NumberType is number
|
|
548
|
-
* type BooleanType = ExtractType<'boolean'>; // BooleanType is boolean
|
|
549
|
-
* type ObjectType = ExtractType<'object'>; // ObjectType is object
|
|
550
|
-
* type ArrayType = ExtractType<'array'>; // ArrayType is Array<any>
|
|
551
|
-
*/
|
|
552
|
-
type ExtractType<T extends string> =
|
|
553
|
-
T extends "string" ? string :
|
|
554
|
-
T extends "number" ? number :
|
|
555
|
-
T extends "boolean" ? boolean :
|
|
556
|
-
T extends "object" ? object :
|
|
557
|
-
T extends "array" ? any[] :
|
|
558
|
-
undefined;
|
|
674
|
+
type BaseStorageOptions = {
|
|
675
|
+
[name:string]:string | boolean | number
|
|
676
|
+
}
|
|
559
677
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
678
|
+
declare class BaseStorage<Schemas extends SchemaTypeRecord> extends StorageInternal<Schemas> {
|
|
679
|
+
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
680
|
+
dbName: string,
|
|
681
|
+
schemas: SchemasCreate,
|
|
682
|
+
options?: BaseStorageOptions
|
|
683
|
+
): Promise<
|
|
684
|
+
BaseStorage<
|
|
685
|
+
SchemasCreate
|
|
686
|
+
>
|
|
687
|
+
>;
|
|
688
|
+
constructor(
|
|
689
|
+
dbName: string,
|
|
690
|
+
schemas: Schemas,
|
|
691
|
+
options?: BaseStorageOptions
|
|
692
|
+
);
|
|
693
|
+
readonly dbName: string;
|
|
694
|
+
readonly schemas: Record<keyof Schemas, Schema<Schemas[keyof Schemas]>>;
|
|
695
|
+
readonly options: BaseStorageOptions;
|
|
696
|
+
readonly core: CoreStorage;
|
|
697
|
+
start(): Promise<void>;
|
|
698
|
+
close(): Promise<void>;
|
|
699
|
+
count(colectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions<Schemas[keyof Schemas]>): Promise<number>;
|
|
700
|
+
findDocumentById(collectionName: keyof Schemas, id: string): Promise<Doc<Schemas[keyof Schemas]> | null>;
|
|
701
|
+
find(collectionName: keyof Schemas, query: QueryType<Schemas[keyof Schemas]>, options?: QueryOptions<Schemas[keyof Schemas]>): Promise<Doc<Schemas[keyof Schemas]>[]>;
|
|
702
|
+
write(op: Operation<Schemas[keyof Schemas]>): Promise<Doc<Schemas[keyof Schemas]>>;
|
|
703
|
+
getOption(name: string): string | boolean | number | undefined;
|
|
704
|
+
getSchema(name: string): Schema<any>;
|
|
705
|
+
//Call addIndexSchemas if you need extra indexing schemas for your database
|
|
706
|
+
addIndexSchemas(): null
|
|
707
|
+
}
|
|
576
708
|
|
|
577
|
-
/**
|
|
578
|
-
* NestedRequiredNames extracts the union of nested property names listed in an object
|
|
579
|
-
* property's `required` array (JSON Schema semantics), or `never` when no array is
|
|
580
|
-
* present. Note it only matches the array form; a boolean `required` flag yields `never`.
|
|
581
|
-
*/
|
|
582
|
-
type NestedRequiredNames<P> =
|
|
583
|
-
P extends { required: infer R }
|
|
584
|
-
? (R extends readonly string[] ? R[number] : never)
|
|
585
|
-
: never;
|
|
586
709
|
|
|
587
|
-
/**
|
|
588
|
-
* FlagRequiredness interprets a property's `required` declaration when it is used as a
|
|
589
|
-
* legacy boolean flag. Because `Property.required` is typed `boolean | string[]`, a
|
|
590
|
-
* schema literal written without `as const` widens `true`/`false` to `boolean`; the
|
|
591
|
-
* tuple-wrapped checks below classify each case:
|
|
592
|
-
* - a literal `false` -> `"optional"`;
|
|
593
|
-
* - a literal `true`, or a widened `boolean` (whose literal was lost) -> `"required"`.
|
|
594
|
-
* Treating the ambiguous `boolean` as required matches the Rust validator and turns a
|
|
595
|
-
* would-be runtime "missing required property" error into a compile-time one instead;
|
|
596
|
-
* - the array form, or no `required` key -> `"defer"` to the container `required` array.
|
|
597
|
-
*/
|
|
598
|
-
type FlagRequiredness<P> =
|
|
599
|
-
P extends { required: infer F }
|
|
600
|
-
? ([F] extends [readonly string[]] ? "defer"
|
|
601
|
-
: [F] extends [false] ? "optional"
|
|
602
|
-
: [true] extends [F] ? "required"
|
|
603
|
-
: "defer")
|
|
604
|
-
: "defer";
|
|
605
710
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
711
|
+
type EnumerateUpTo<
|
|
712
|
+
N extends number,
|
|
713
|
+
Acc extends number[] = []
|
|
714
|
+
> = Acc['length'] extends N ?
|
|
715
|
+
Acc[number]:
|
|
716
|
+
EnumerateUpTo<N, [...Acc, Acc['length']]> ;
|
|
717
|
+
|
|
718
|
+
type EnumerateFrom1To<
|
|
719
|
+
N extends number
|
|
720
|
+
> = Exclude<EnumerateUpTo<N>,0> | (N extends 0 ? never : N);
|
|
721
|
+
|
|
722
|
+
type IsVersionGreaterThan0<
|
|
723
|
+
V extends number
|
|
724
|
+
> = V extends 0 ? false : true;
|
|
725
|
+
|
|
726
|
+
type AnyVersionGreaterThan1<
|
|
727
|
+
T extends Record<string, SchemaType>
|
|
728
|
+
> = true extends {
|
|
729
|
+
[K in keyof T]: IsVersionGreaterThan0<T[K]['version']>;
|
|
730
|
+
} [keyof T] ? true : false;
|
|
731
|
+
|
|
732
|
+
type MigrationFunction<T extends SchemaType> = (doc: Doc <T> ) => Doc <T>
|
|
733
|
+
|
|
734
|
+
type MigrationPathsForSchema<
|
|
735
|
+
T extends SchemaType
|
|
736
|
+
> = T['version'] extends 0 ? {}: // No migrations needed for version 1
|
|
737
|
+
{
|
|
738
|
+
[K in EnumerateFrom1To < T['version'] > ]: MigrationFunction<T> ;
|
|
739
|
+
};
|
|
621
740
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
* `CreateDoc` in step with the runtime validator, which only enforces nested keys named
|
|
627
|
-
* in that object's `required` array.
|
|
628
|
-
*/
|
|
629
|
-
type ExtractObject<PR, R> = {
|
|
630
|
-
[K in keyof PR as IsNestedOptional<PR, K, R> extends true ? never : K]:
|
|
631
|
-
ExtractProperty<PR[K]>
|
|
632
|
-
} & {
|
|
633
|
-
[K in keyof PR as IsNestedOptional<PR, K, R> extends true ? K : never]?:
|
|
634
|
-
ExtractProperty<PR[K]>
|
|
741
|
+
type MigrationPathsForSchemas<
|
|
742
|
+
T extends SchemaTypeRecord
|
|
743
|
+
> = {
|
|
744
|
+
[K in keyof T]: MigrationPathsForSchema<T[K]>;
|
|
635
745
|
};
|
|
636
746
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
747
|
+
type MigrationsParameter<
|
|
748
|
+
T extends SchemaTypeRecord
|
|
749
|
+
> = AnyVersionGreaterThan1<T> extends true ?
|
|
750
|
+
{
|
|
751
|
+
migrations: MigrationPathsForSchemas<T>
|
|
752
|
+
}:
|
|
753
|
+
{
|
|
754
|
+
migrations?: never
|
|
755
|
+
};
|
|
645
756
|
|
|
646
|
-
/**
|
|
647
|
-
* IsCreateOptional decides whether a property may be omitted when creating a document.
|
|
648
|
-
* Precedence (mirrors the runtime validator):
|
|
649
|
-
* 1. a declared `default` makes the field optional;
|
|
650
|
-
* 2. a boolean `required` flag wins (`false` -> optional, `true`/`boolean` -> required;
|
|
651
|
-
* see {@link FlagRequiredness});
|
|
652
|
-
* 3. otherwise it is required iff listed in the schema-level `required` array;
|
|
653
|
-
* 4. otherwise it is optional.
|
|
654
|
-
*/
|
|
655
|
-
type IsCreateOptional<T extends SchemaType, K extends keyof T["properties"]> =
|
|
656
|
-
T["properties"][K] extends { default: unknown } ? true
|
|
657
|
-
: FlagRequiredness<T["properties"][K]> extends "optional" ? true
|
|
658
|
-
: FlagRequiredness<T["properties"][K]> extends "required" ? false
|
|
659
|
-
: K extends RequiredFieldNames<T> ? false
|
|
660
|
-
: true;
|
|
661
757
|
|
|
662
|
-
/**
|
|
663
|
-
* Doc is a utility type that transforms a schema type into a stored-document type. A
|
|
664
|
-
* property is mandatory only when the validator guarantees its presence; properties that
|
|
665
|
-
* are optional at creation (not listed in `required`, flagged `required: false`, or
|
|
666
|
-
* carrying a `default`) may be absent on a stored document, so they are optional here
|
|
667
|
-
* too. This keeps `find`/`findById`/`create` return types from claiming keys that may not
|
|
668
|
-
* exist. Optionality uses the same {@link IsCreateOptional} rules as {@link CreateDoc}.
|
|
669
|
-
*
|
|
670
|
-
* @template T - A schema type with a 'properties' field where each property's type is represented as a string.
|
|
671
|
-
*
|
|
672
|
-
* type Document = Doc<Schema>; // Document is { name: string; age: number; }
|
|
673
|
-
*/
|
|
674
|
-
type Doc<T extends SchemaType> = {
|
|
675
|
-
[K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? never : K]:
|
|
676
|
-
ExtractProperty<T['properties'][K]>
|
|
677
|
-
} & {
|
|
678
|
-
[K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? K : never]?:
|
|
679
|
-
ExtractProperty<T['properties'][K]>
|
|
680
|
-
} & {
|
|
681
|
-
__version?: number;
|
|
682
|
-
createdAt?: number;
|
|
683
|
-
updatedAt?: number;
|
|
684
|
-
};
|
|
685
758
|
|
|
686
759
|
/**
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
* `required` array, become optional.
|
|
690
|
-
*
|
|
691
|
-
* @template T - A schema type with a 'properties' field where each property's type is represented as a string.
|
|
760
|
+
* Represents a record of schema types, where each key is a string and the value is a `SchemaType`.
|
|
761
|
+
* @internal
|
|
692
762
|
*/
|
|
693
|
-
type
|
|
694
|
-
|
|
695
|
-
ExtractProperty<T['properties'][K]>
|
|
696
|
-
} & {
|
|
697
|
-
[K in keyof T["properties"] as IsCreateOptional<T, K> extends true ? never : K]:
|
|
698
|
-
ExtractProperty<T['properties'][K]>
|
|
699
|
-
} & {
|
|
700
|
-
__version?: number;
|
|
701
|
-
createdAt?: number;
|
|
702
|
-
updatedAt?: number;
|
|
763
|
+
type SchemaTypeRecord = {
|
|
764
|
+
[name: string]: SchemaType
|
|
703
765
|
};
|
|
704
766
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
767
|
+
declare abstract class StorageInternal<Schemas extends SchemaTypeRecord> {
|
|
768
|
+
constructor(
|
|
769
|
+
name: string,
|
|
770
|
+
schemas: Schemas
|
|
771
|
+
);
|
|
772
|
+
abstract start(): Promise<void>;
|
|
773
|
+
abstract close(): Promise<void>;
|
|
774
|
+
abstract count(
|
|
775
|
+
colectionName: keyof Schemas,
|
|
776
|
+
query: QueryType<Schemas[keyof Schemas]>,
|
|
777
|
+
options?: QueryOptions<Schemas[keyof Schemas]>
|
|
778
|
+
): Promise<number>;
|
|
779
|
+
abstract findDocumentById(
|
|
780
|
+
collectionName: keyof Schemas,
|
|
781
|
+
id: string
|
|
782
|
+
): Promise<Doc<Schemas[keyof Schemas]> | null>;
|
|
783
|
+
abstract find(
|
|
784
|
+
collectionName: keyof Schemas,
|
|
785
|
+
query: QueryType<Schemas[keyof Schemas]>,
|
|
786
|
+
options?: QueryOptions<Schemas[keyof Schemas]>
|
|
787
|
+
): Promise<Doc<Schemas[keyof Schemas]>[]>;
|
|
788
|
+
abstract write(
|
|
789
|
+
op: Operation<Schemas[keyof Schemas]>
|
|
790
|
+
): Promise<Doc<Schemas[keyof Schemas]>>;
|
|
708
791
|
}
|
|
709
792
|
|
|
793
|
+
|
|
710
794
|
/**
|
|
711
|
-
*
|
|
712
|
-
* @template T - A schema type defining the structure of the documents in the collection.
|
|
795
|
+
* Represents a property within a schema, including various constraints and nested properties.
|
|
713
796
|
*/
|
|
714
|
-
declare class
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
*/
|
|
720
|
-
find(query: QueryType<T>, options?: QueryOptions): Promise<Doc<T>[]>;
|
|
721
|
-
/**
|
|
722
|
-
* count all documents in the collection.
|
|
723
|
-
*
|
|
724
|
-
* @returns A promise that resolves to an array of documents.
|
|
725
|
-
*/
|
|
726
|
-
count(query: QueryType<T>, options?: QueryOptions): Promise<number>;
|
|
727
|
-
/**
|
|
728
|
-
* Finds a single document in the collection by its ID.
|
|
729
|
-
*
|
|
730
|
-
* @param id - The ID of the document to find.
|
|
731
|
-
* @returns A promise that resolves to the found document.
|
|
732
|
-
*/
|
|
733
|
-
findById(id: string): Promise<Doc<T>>;
|
|
734
|
-
/**
|
|
735
|
-
* Updates a document in the collection by its ID.
|
|
736
|
-
*
|
|
737
|
-
* @param document - A partial document containing the fields to update.
|
|
738
|
-
* @returns A promise that resolves when the update is complete.
|
|
739
|
-
*/
|
|
740
|
-
update(document: Partial<Doc<T>>): Promise<void>;
|
|
741
|
-
/**
|
|
742
|
-
* Creates a new document in the collection.
|
|
743
|
-
*
|
|
744
|
-
* @param document - The document to create.
|
|
745
|
-
* @returns A promise that resolves to the created document.
|
|
746
|
-
*/
|
|
747
|
-
create(document: CreateDoc<T>): Promise<Doc<T>>;
|
|
748
|
-
/**
|
|
749
|
-
* Deletes a document in the collection by its ID.
|
|
750
|
-
*
|
|
751
|
-
* @param id - The ID of the document to delete.
|
|
752
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
753
|
-
*/
|
|
754
|
-
delete(id: string): Promise<void>;
|
|
755
|
-
}
|
|
797
|
+
declare class Property {
|
|
798
|
+
/**
|
|
799
|
+
* The type of the property.
|
|
800
|
+
*/
|
|
801
|
+
readonly type: SchemaFieldType;
|
|
756
802
|
|
|
803
|
+
/**
|
|
804
|
+
* The version of the property, if applicable.
|
|
805
|
+
*/
|
|
806
|
+
readonly version?: number;
|
|
757
807
|
|
|
808
|
+
/**
|
|
809
|
+
* The primary key of the property, if applicable.
|
|
810
|
+
*/
|
|
811
|
+
readonly primaryKey?: string;
|
|
758
812
|
|
|
813
|
+
/**
|
|
814
|
+
* An optional array of nested properties for array-type properties.
|
|
815
|
+
*/
|
|
816
|
+
readonly items?: Property;
|
|
759
817
|
|
|
760
|
-
/**
|
|
761
|
-
* Represents the type definition for a schema.
|
|
762
|
-
*/
|
|
763
|
-
type SchemaType = {
|
|
764
818
|
/**
|
|
765
|
-
* The
|
|
819
|
+
* The maximum number of items for array-type properties, if applicable.
|
|
766
820
|
*/
|
|
767
|
-
|
|
821
|
+
readonly maxItems?: number;
|
|
768
822
|
|
|
769
823
|
/**
|
|
770
|
-
* The
|
|
824
|
+
* The minimum number of items for array-type properties, if applicable.
|
|
771
825
|
*/
|
|
772
|
-
|
|
826
|
+
readonly minItems?: number;
|
|
773
827
|
|
|
774
828
|
/**
|
|
775
|
-
* The type
|
|
829
|
+
* The maximum length for string-type properties, if applicable.
|
|
776
830
|
*/
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
encrypted?: string[];
|
|
780
|
-
/**
|
|
781
|
-
* The names of the required top-level properties. Follows JSON Schema
|
|
782
|
-
* semantics: only the listed properties are required.
|
|
783
|
-
*/
|
|
784
|
-
required?: string[];
|
|
831
|
+
readonly maxLength?: number;
|
|
832
|
+
|
|
785
833
|
/**
|
|
786
|
-
* The
|
|
834
|
+
* The minimum length for string-type properties, if applicable.
|
|
787
835
|
*/
|
|
788
|
-
|
|
836
|
+
readonly minLength?: number;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Controls requiredness. Two forms are supported and interoperate:
|
|
840
|
+
* - `boolean`: a per-property flag (legacy). `false` forces the property optional,
|
|
841
|
+
* `true` forces it required, overriding any container-level `required` array.
|
|
842
|
+
* - `string[]`: for object-type properties, the JSON Schema list of required
|
|
843
|
+
* nested properties.
|
|
844
|
+
*/
|
|
845
|
+
readonly required?: boolean | string[];
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* An optional default value for the property.
|
|
849
|
+
*/
|
|
850
|
+
readonly default?: any;
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* An optional map of nested properties for object-type properties.
|
|
854
|
+
*/
|
|
855
|
+
readonly properties?: {
|
|
789
856
|
[name: string]: Property;
|
|
790
857
|
};
|
|
791
|
-
}
|
|
858
|
+
}
|
|
859
|
+
|
|
792
860
|
|
|
793
861
|
|
|
794
862
|
/**
|
|
795
|
-
* Represents
|
|
796
|
-
*
|
|
797
|
-
* Check this example
|
|
798
|
-
*
|
|
799
|
-
* ```typescript
|
|
800
|
-
* class MyStorage extends <T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
801
|
-
* example() {
|
|
802
|
-
* const schema: Schema<any> = this.getSchema("mySchema")
|
|
803
|
-
* }
|
|
804
|
-
* }
|
|
805
|
-
* ```
|
|
806
|
-
* You alwayswill have access to getSchema through the Storage class.
|
|
807
|
-
*
|
|
863
|
+
* Represents an IndexDB storage system extending the base storage functionality.
|
|
864
|
+
*
|
|
808
865
|
* @template T - The schema type.
|
|
809
866
|
*/
|
|
810
|
-
declare class
|
|
867
|
+
declare class IndexDB<T extends SchemaTypeRecord> extends BaseStorage<T> {
|
|
811
868
|
/**
|
|
812
|
-
*
|
|
869
|
+
* Frees the resources used by the in-memory storage.
|
|
813
870
|
*/
|
|
814
|
-
|
|
871
|
+
free(): void;
|
|
872
|
+
|
|
873
|
+
static create<SchemasCreate extends SchemaTypeRecord>(
|
|
874
|
+
dbName: string,
|
|
875
|
+
schemas: SchemasCreate,
|
|
876
|
+
): Promise<
|
|
877
|
+
IndexDB<
|
|
878
|
+
SchemasCreate
|
|
879
|
+
>
|
|
880
|
+
>;
|
|
881
|
+
}
|
|
815
882
|
|
|
816
|
-
/**
|
|
817
|
-
* Creates a new `Schema` instance from the provided definition.
|
|
818
|
-
*
|
|
819
|
-
* @template TS - The schema type.
|
|
820
|
-
* @param {TS} defi, Debugnition - The schema definition.
|
|
821
|
-
* @returns {Schema<TS>} The created `Schema` instance.
|
|
822
|
-
*/
|
|
823
|
-
static create<TS extends SchemaType>(definition: TS): Schema<TS>;
|
|
824
883
|
|
|
825
|
-
/**
|
|
826
|
-
* The version of the schema.
|
|
827
|
-
*/
|
|
828
|
-
readonly version: number;
|
|
829
884
|
|
|
885
|
+
/**
|
|
886
|
+
* Represents an operation to be performed on a collection.
|
|
887
|
+
*
|
|
888
|
+
* @template T - The schema type of the collection.
|
|
889
|
+
*/
|
|
890
|
+
type Operation<T extends SchemaType = SchemaType> = {
|
|
830
891
|
/**
|
|
831
|
-
* The
|
|
892
|
+
* The name of the collection on which the operation will be performed.
|
|
832
893
|
*/
|
|
833
|
-
|
|
894
|
+
collection: string,
|
|
834
895
|
|
|
835
896
|
/**
|
|
836
|
-
* The type of
|
|
897
|
+
* The type of operation to be performed (e.g., CREATE, UPDATE, DELETE).
|
|
837
898
|
*/
|
|
838
|
-
|
|
899
|
+
opType: OpType,
|
|
839
900
|
|
|
840
901
|
/**
|
|
841
|
-
*
|
|
842
|
-
*/
|
|
843
|
-
/**
|
|
844
|
-
* An optional array of indexes.
|
|
902
|
+
* The data involved in the operation, conforming to the schema type.
|
|
845
903
|
*/
|
|
846
|
-
|
|
904
|
+
data: Doc<T>,
|
|
847
905
|
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
readonly encrypted?: (Extract<keyof T, string>)[];
|
|
906
|
+
primaryKeyField?: string,
|
|
907
|
+
primaryKey?: string
|
|
908
|
+
}
|
|
852
909
|
|
|
853
|
-
/**
|
|
854
|
-
* The properties defined in the schema.
|
|
855
|
-
*/
|
|
856
|
-
readonly properties: {
|
|
857
|
-
[K in keyof T['properties']]: T['properties'][K];
|
|
858
|
-
};
|
|
859
910
|
|
|
860
|
-
/**
|
|
861
|
-
* The names of the required top-level properties.
|
|
862
|
-
*/
|
|
863
|
-
readonly required?: (Extract<keyof T['properties'], string>)[];
|
|
864
|
-
/**
|
|
865
|
-
* Converts the schema to a JSON representation.
|
|
866
|
-
*
|
|
867
|
-
* @returns {SchemaType} The JSON representation of the schema.
|
|
868
|
-
*/
|
|
869
|
-
toJSON(): SchemaType;
|
|
870
911
|
|
|
912
|
+
declare class CoreStorage {
|
|
871
913
|
/**
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
914
|
+
* @param {any} document
|
|
915
|
+
* @param {Query} query
|
|
916
|
+
* @returns {boolean}
|
|
917
|
+
*/
|
|
918
|
+
matchesQuery(document: any, query: Query<any>): boolean;
|
|
919
|
+
getPrimaryKeyTyped(value: any): string | number;
|
|
920
|
+
getIndexes(schema: Schema<any>, op: Operation): string[];
|
|
921
|
+
/**
|
|
922
|
+
* Sorts a list of documents according to the provided sort specification, using the
|
|
923
|
+
* same comparison semantics as the built-in storages. Intended for custom storage
|
|
924
|
+
* adapters that cannot rely on a native sort. Returns a new sorted array.
|
|
925
|
+
*/
|
|
926
|
+
sortDocuments(documents: any[], sort: SortSpec[]): any[];
|
|
878
927
|
}
|
|
879
928
|
|
|
880
929
|
|
|
@@ -989,6 +1038,50 @@ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Modul
|
|
|
989
1038
|
|
|
990
1039
|
interface InitOutput {
|
|
991
1040
|
readonly memory: WebAssembly.Memory;
|
|
1041
|
+
readonly __wbg_inmemory_free: (a: number) => void;
|
|
1042
|
+
readonly inmemory_close: (a: number) => number;
|
|
1043
|
+
readonly inmemory_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
1044
|
+
readonly inmemory_create: (a: number, b: number, c: number) => number;
|
|
1045
|
+
readonly inmemory_find: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
1046
|
+
readonly inmemory_findDocumentById: (a: number, b: number, c: number, d: number) => number;
|
|
1047
|
+
readonly inmemory_start: (a: number) => number;
|
|
1048
|
+
readonly inmemory_write: (a: number, b: number) => number;
|
|
1049
|
+
readonly __wbg_collection_free: (a: number) => void;
|
|
1050
|
+
readonly __wbg_schema_free: (a: number) => void;
|
|
1051
|
+
readonly __wbgt_test_invalid_schema_5: (a: number) => void;
|
|
1052
|
+
readonly __wbgt_test_schema_creation_3: (a: number) => void;
|
|
1053
|
+
readonly __wbgt_test_schema_required_subset_of_properties_6: (a: number) => void;
|
|
1054
|
+
readonly __wbgt_test_schema_validation_4: (a: number) => void;
|
|
1055
|
+
readonly __wbgt_test_validate_document_default_makes_required_optional_15: (a: number) => void;
|
|
1056
|
+
readonly __wbgt_test_validate_document_flag_overrides_array_12: (a: number) => void;
|
|
1057
|
+
readonly __wbgt_test_validate_document_legacy_required_false_11: (a: number) => void;
|
|
1058
|
+
readonly __wbgt_test_validate_document_nested_required_13: (a: number) => void;
|
|
1059
|
+
readonly __wbgt_test_validate_document_no_array_all_optional_9: (a: number) => void;
|
|
1060
|
+
readonly __wbgt_test_validate_document_null_is_type_checked_14: (a: number) => void;
|
|
1061
|
+
readonly __wbgt_test_validate_document_omitted_nested_required_equals_empty_10: (a: number) => void;
|
|
1062
|
+
readonly __wbgt_test_validate_document_required_missing_8: (a: number) => void;
|
|
1063
|
+
readonly __wbgt_test_validate_document_required_present_7: (a: number) => void;
|
|
1064
|
+
readonly collection_count: (a: number, b: number, c: number) => number;
|
|
1065
|
+
readonly collection_create: (a: number, b: number) => number;
|
|
1066
|
+
readonly collection_delete: (a: number, b: number) => number;
|
|
1067
|
+
readonly collection_find: (a: number, b: number, c: number) => number;
|
|
1068
|
+
readonly collection_findById: (a: number, b: number) => number;
|
|
1069
|
+
readonly collection_name: (a: number, b: number) => void;
|
|
1070
|
+
readonly collection_parse_query_options: (a: number, b: number, c: number) => void;
|
|
1071
|
+
readonly collection_schema: (a: number, b: number) => void;
|
|
1072
|
+
readonly collection_update: (a: number, b: number) => number;
|
|
1073
|
+
readonly is_debug_mode: () => number;
|
|
1074
|
+
readonly main_js: () => void;
|
|
1075
|
+
readonly schema_create: (a: number, b: number) => void;
|
|
1076
|
+
readonly schema_encrypted: (a: number, b: number) => void;
|
|
1077
|
+
readonly schema_indexes: (a: number, b: number) => void;
|
|
1078
|
+
readonly schema_is_valid: (a: number, b: number) => void;
|
|
1079
|
+
readonly schema_primaryKey: (a: number, b: number) => void;
|
|
1080
|
+
readonly schema_properties: (a: number, b: number) => void;
|
|
1081
|
+
readonly schema_required: (a: number, b: number) => void;
|
|
1082
|
+
readonly schema_type: (a: number, b: number) => void;
|
|
1083
|
+
readonly schema_validate: (a: number, b: number, c: number) => void;
|
|
1084
|
+
readonly schema_version: (a: number) => number;
|
|
992
1085
|
readonly __wbg_query_free: (a: number) => void;
|
|
993
1086
|
readonly __wbgt_test_get_properties_array_values_20: (a: number) => void;
|
|
994
1087
|
readonly __wbgt_test_get_properties_deeply_nested_22: (a: number) => void;
|
|
@@ -1026,11 +1119,44 @@ interface InitOutput {
|
|
|
1026
1119
|
readonly query_parse: (a: number, b: number) => void;
|
|
1027
1120
|
readonly query_process_query: (a: number, b: number, c: number) => void;
|
|
1028
1121
|
readonly query_query: (a: number, b: number) => void;
|
|
1029
|
-
readonly
|
|
1122
|
+
readonly __wbg_baseplugin_free: (a: number) => void;
|
|
1123
|
+
readonly __wbg_basestorage_free: (a: number) => void;
|
|
1124
|
+
readonly __wbg_database_free: (a: number) => void;
|
|
1125
|
+
readonly baseplugin_get_doc_create_hook: (a: number) => number;
|
|
1126
|
+
readonly baseplugin_get_doc_recover_hook: (a: number) => number;
|
|
1127
|
+
readonly baseplugin_name: (a: number) => number;
|
|
1128
|
+
readonly baseplugin_new: (a: number, b: number, c: number) => void;
|
|
1129
|
+
readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
|
|
1130
|
+
readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
|
|
1131
|
+
readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
|
|
1132
|
+
readonly basestorage_core: (a: number, b: number) => void;
|
|
1133
|
+
readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
|
|
1134
|
+
readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
|
|
1135
|
+
readonly basestorage_new: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
1136
|
+
readonly database_authenticate: (a: number, b: number, c: number) => number;
|
|
1137
|
+
readonly database_close: (a: number) => number;
|
|
1138
|
+
readonly database_collections: (a: number, b: number) => void;
|
|
1139
|
+
readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
1140
|
+
readonly database_start: (a: number) => number;
|
|
1141
|
+
readonly database_started: (a: number) => number;
|
|
1142
|
+
readonly __wbg_property_free: (a: number) => void;
|
|
1030
1143
|
readonly __wbg_queryoptions_free: (a: number) => void;
|
|
1031
|
-
readonly
|
|
1032
|
-
readonly
|
|
1033
|
-
readonly
|
|
1144
|
+
readonly __wbgt_test_invalid_property_2: (a: number) => void;
|
|
1145
|
+
readonly __wbgt_test_property_creation_0: (a: number) => void;
|
|
1146
|
+
readonly __wbgt_test_property_validation_1: (a: number) => void;
|
|
1147
|
+
readonly property_is_valid: (a: number, b: number) => void;
|
|
1148
|
+
readonly property_items: (a: number, b: number) => void;
|
|
1149
|
+
readonly property_maxItems: (a: number, b: number) => void;
|
|
1150
|
+
readonly property_maxLength: (a: number, b: number) => void;
|
|
1151
|
+
readonly property_minItems: (a: number, b: number) => void;
|
|
1152
|
+
readonly property_minLength: (a: number, b: number) => void;
|
|
1153
|
+
readonly property_properties: (a: number, b: number) => void;
|
|
1154
|
+
readonly property_type: (a: number) => number;
|
|
1155
|
+
readonly queryoptions_limit: (a: number, b: number) => void;
|
|
1156
|
+
readonly queryoptions_offset: (a: number, b: number) => void;
|
|
1157
|
+
readonly queryoptions_sort: (a: number, b: number) => void;
|
|
1158
|
+
readonly __wbg_indexdb_free: (a: number) => void;
|
|
1159
|
+
readonly __wbg_ridberror_free: (a: number) => void;
|
|
1034
1160
|
readonly indexdb_close: (a: number) => number;
|
|
1035
1161
|
readonly indexdb_count: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
1036
1162
|
readonly indexdb_create: (a: number, b: number, c: number) => number;
|
|
@@ -1041,18 +1167,6 @@ interface InitOutput {
|
|
|
1041
1167
|
readonly indexdb_get_stores: (a: number, b: number) => void;
|
|
1042
1168
|
readonly indexdb_start: (a: number) => number;
|
|
1043
1169
|
readonly indexdb_write: (a: number, b: number) => number;
|
|
1044
|
-
readonly queryoptions_limit: (a: number, b: number) => void;
|
|
1045
|
-
readonly queryoptions_offset: (a: number, b: number) => void;
|
|
1046
|
-
readonly corestorage_new: () => number;
|
|
1047
|
-
readonly __wbg_corestorage_free: (a: number) => void;
|
|
1048
|
-
readonly __wbg_operation_free: (a: number) => void;
|
|
1049
|
-
readonly __wbg_ridberror_free: (a: number) => void;
|
|
1050
|
-
readonly operation_collection: (a: number, b: number) => void;
|
|
1051
|
-
readonly operation_data: (a: number) => number;
|
|
1052
|
-
readonly operation_opType: (a: number) => number;
|
|
1053
|
-
readonly operation_primaryKey: (a: number) => number;
|
|
1054
|
-
readonly operation_primaryKeyField: (a: number) => number;
|
|
1055
|
-
readonly operation_primaryKeyIndex: (a: number, b: number) => void;
|
|
1056
1170
|
readonly ridberror_authentication: (a: number, b: number, c: number) => number;
|
|
1057
1171
|
readonly ridberror_code: (a: number) => number;
|
|
1058
1172
|
readonly ridberror_error: (a: number, b: number, c: number) => number;
|
|
@@ -1064,82 +1178,19 @@ interface InitOutput {
|
|
|
1064
1178
|
readonly ridberror_serialisation: (a: number, b: number, c: number) => number;
|
|
1065
1179
|
readonly ridberror_type: (a: number, b: number) => void;
|
|
1066
1180
|
readonly ridberror_validation: (a: number, b: number, c: number) => number;
|
|
1067
|
-
readonly
|
|
1068
|
-
readonly
|
|
1069
|
-
readonly
|
|
1070
|
-
readonly
|
|
1071
|
-
readonly
|
|
1072
|
-
readonly
|
|
1073
|
-
readonly
|
|
1074
|
-
readonly
|
|
1075
|
-
readonly
|
|
1076
|
-
readonly
|
|
1077
|
-
readonly
|
|
1078
|
-
readonly
|
|
1079
|
-
readonly
|
|
1080
|
-
readonly property_items: (a: number, b: number) => void;
|
|
1081
|
-
readonly property_maxItems: (a: number, b: number) => void;
|
|
1082
|
-
readonly property_maxLength: (a: number, b: number) => void;
|
|
1083
|
-
readonly property_minItems: (a: number, b: number) => void;
|
|
1084
|
-
readonly property_minLength: (a: number, b: number) => void;
|
|
1085
|
-
readonly property_properties: (a: number, b: number) => void;
|
|
1086
|
-
readonly property_type: (a: number) => number;
|
|
1087
|
-
readonly __wbg_baseplugin_free: (a: number) => void;
|
|
1088
|
-
readonly __wbg_basestorage_free: (a: number) => void;
|
|
1089
|
-
readonly __wbg_database_free: (a: number) => void;
|
|
1090
|
-
readonly baseplugin_get_doc_create_hook: (a: number) => number;
|
|
1091
|
-
readonly baseplugin_get_doc_recover_hook: (a: number) => number;
|
|
1092
|
-
readonly baseplugin_name: (a: number) => number;
|
|
1093
|
-
readonly baseplugin_new: (a: number, b: number, c: number) => void;
|
|
1094
|
-
readonly baseplugin_set_doc_create_hook: (a: number, b: number) => void;
|
|
1095
|
-
readonly baseplugin_set_doc_recover_hook: (a: number, b: number) => void;
|
|
1096
|
-
readonly basestorage_addIndexSchemas: (a: number, b: number) => void;
|
|
1097
|
-
readonly basestorage_core: (a: number, b: number) => void;
|
|
1098
|
-
readonly basestorage_getOption: (a: number, b: number, c: number, d: number) => void;
|
|
1099
|
-
readonly basestorage_getSchema: (a: number, b: number, c: number, d: number) => void;
|
|
1100
|
-
readonly basestorage_new: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
1101
|
-
readonly database_authenticate: (a: number, b: number, c: number) => number;
|
|
1102
|
-
readonly database_close: (a: number) => number;
|
|
1103
|
-
readonly database_collections: (a: number, b: number) => void;
|
|
1104
|
-
readonly database_create: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
1105
|
-
readonly database_start: (a: number) => number;
|
|
1106
|
-
readonly database_started: (a: number) => number;
|
|
1107
|
-
readonly __wbg_collection_free: (a: number) => void;
|
|
1108
|
-
readonly __wbg_schema_free: (a: number) => void;
|
|
1109
|
-
readonly __wbgt_test_invalid_schema_5: (a: number) => void;
|
|
1110
|
-
readonly __wbgt_test_schema_creation_3: (a: number) => void;
|
|
1111
|
-
readonly __wbgt_test_schema_required_subset_of_properties_6: (a: number) => void;
|
|
1112
|
-
readonly __wbgt_test_schema_validation_4: (a: number) => void;
|
|
1113
|
-
readonly __wbgt_test_validate_document_default_makes_required_optional_15: (a: number) => void;
|
|
1114
|
-
readonly __wbgt_test_validate_document_flag_overrides_array_12: (a: number) => void;
|
|
1115
|
-
readonly __wbgt_test_validate_document_legacy_required_false_11: (a: number) => void;
|
|
1116
|
-
readonly __wbgt_test_validate_document_nested_required_13: (a: number) => void;
|
|
1117
|
-
readonly __wbgt_test_validate_document_no_array_all_optional_9: (a: number) => void;
|
|
1118
|
-
readonly __wbgt_test_validate_document_null_is_type_checked_14: (a: number) => void;
|
|
1119
|
-
readonly __wbgt_test_validate_document_omitted_nested_required_equals_empty_10: (a: number) => void;
|
|
1120
|
-
readonly __wbgt_test_validate_document_required_missing_8: (a: number) => void;
|
|
1121
|
-
readonly __wbgt_test_validate_document_required_present_7: (a: number) => void;
|
|
1122
|
-
readonly collection_count: (a: number, b: number, c: number) => number;
|
|
1123
|
-
readonly collection_create: (a: number, b: number) => number;
|
|
1124
|
-
readonly collection_delete: (a: number, b: number) => number;
|
|
1125
|
-
readonly collection_find: (a: number, b: number, c: number) => number;
|
|
1126
|
-
readonly collection_findById: (a: number, b: number) => number;
|
|
1127
|
-
readonly collection_name: (a: number, b: number) => void;
|
|
1128
|
-
readonly collection_parse_query_options: (a: number, b: number, c: number) => void;
|
|
1129
|
-
readonly collection_schema: (a: number, b: number) => void;
|
|
1130
|
-
readonly collection_update: (a: number, b: number) => number;
|
|
1131
|
-
readonly schema_create: (a: number, b: number) => void;
|
|
1132
|
-
readonly schema_encrypted: (a: number, b: number) => void;
|
|
1133
|
-
readonly schema_indexes: (a: number, b: number) => void;
|
|
1134
|
-
readonly schema_is_valid: (a: number, b: number) => void;
|
|
1135
|
-
readonly schema_primaryKey: (a: number, b: number) => void;
|
|
1136
|
-
readonly schema_properties: (a: number, b: number) => void;
|
|
1137
|
-
readonly schema_required: (a: number, b: number) => void;
|
|
1138
|
-
readonly schema_type: (a: number, b: number) => void;
|
|
1139
|
-
readonly schema_validate: (a: number, b: number, c: number) => void;
|
|
1140
|
-
readonly schema_version: (a: number) => number;
|
|
1141
|
-
readonly is_debug_mode: () => number;
|
|
1142
|
-
readonly main_js: () => void;
|
|
1181
|
+
readonly __wbg_operation_free: (a: number) => void;
|
|
1182
|
+
readonly corestorage_getIndexes: (a: number, b: number, c: number, d: number) => void;
|
|
1183
|
+
readonly corestorage_getPrimaryKeyTyped: (a: number, b: number, c: number) => void;
|
|
1184
|
+
readonly corestorage_matchesQuery: (a: number, b: number, c: number, d: number) => void;
|
|
1185
|
+
readonly corestorage_sortDocuments: (a: number, b: number, c: number, d: number) => void;
|
|
1186
|
+
readonly operation_collection: (a: number, b: number) => void;
|
|
1187
|
+
readonly operation_data: (a: number) => number;
|
|
1188
|
+
readonly operation_opType: (a: number) => number;
|
|
1189
|
+
readonly operation_primaryKey: (a: number) => number;
|
|
1190
|
+
readonly operation_primaryKeyField: (a: number) => number;
|
|
1191
|
+
readonly operation_primaryKeyIndex: (a: number, b: number) => void;
|
|
1192
|
+
readonly corestorage_new: () => number;
|
|
1193
|
+
readonly __wbg_corestorage_free: (a: number) => void;
|
|
1143
1194
|
readonly __wbg_wasmbindgentestcontext_free: (a: number) => void;
|
|
1144
1195
|
readonly __wbgtest_console_debug: (a: number) => void;
|
|
1145
1196
|
readonly __wbgtest_console_error: (a: number) => void;
|
|
@@ -1153,14 +1204,14 @@ interface InitOutput {
|
|
|
1153
1204
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
1154
1205
|
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
1155
1206
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
1156
|
-
readonly
|
|
1157
|
-
readonly
|
|
1158
|
-
readonly
|
|
1207
|
+
readonly _dyn_core_7d5f0a2ba6a62c33___ops__function__Fn____________Output______as_wasm_bindgen_96f4c656f19e5a04___closure__WasmClosure___describe__invoke___wasm_bindgen_96f4c656f19e5a04___JsValue__wasm_bindgen_96f4c656f19e5a04___JsValue__wasm_bindgen_96f4c656f19e5a04___JsValue__core_7d5f0a2ba6a62c33___result__Result_wasm_bindgen_96f4c656f19e5a04___JsValue__ridb_core_aad11e700d7ae026___error__RIDBError__: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1208
|
+
readonly _dyn_core_7d5f0a2ba6a62c33___ops__function__FnMut_______Output______as_wasm_bindgen_96f4c656f19e5a04___closure__WasmClosure___describe__invoke___web_sys_42441b50243cf0a5___features__gen_Event__Event_____: (a: number, b: number, c: number) => void;
|
|
1209
|
+
readonly _dyn_core_7d5f0a2ba6a62c33___ops__function__FnMut_______Output______as_wasm_bindgen_96f4c656f19e5a04___closure__WasmClosure___describe__invoke___wasm_bindgen_96f4c656f19e5a04___JsValue_____: (a: number, b: number, c: number) => void;
|
|
1159
1210
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
1160
1211
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
1161
|
-
readonly
|
|
1162
|
-
readonly
|
|
1163
|
-
readonly
|
|
1212
|
+
readonly wasm_bindgen_96f4c656f19e5a04___convert__closures__invoke0_mut______: (a: number, b: number) => void;
|
|
1213
|
+
readonly wasm_bindgen_96f4c656f19e5a04___convert__closures__invoke2_mut___wasm_bindgen_96f4c656f19e5a04___JsValue__wasm_bindgen_96f4c656f19e5a04___JsValue_____: (a: number, b: number, c: number, d: number) => void;
|
|
1214
|
+
readonly wasm_bindgen_96f4c656f19e5a04___convert__closures__invoke3_mut___wasm_bindgen_96f4c656f19e5a04___JsValue__wasm_bindgen_96f4c656f19e5a04___JsValue__js_sys_cda727aa608b7f1b___Set_____: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
1164
1215
|
readonly __wbindgen_start: () => void;
|
|
1165
1216
|
}
|
|
1166
1217
|
|
|
@@ -1185,4 +1236,4 @@ declare function initSync(module: SyncInitInput): InitOutput;
|
|
|
1185
1236
|
*/
|
|
1186
1237
|
declare function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
1187
1238
|
|
|
1188
|
-
export { type AnyVersionGreaterThan1, BasePlugin, BaseStorage, type BaseStorageOptions, Collection, CoreStorage, type CreateDoc, type CreateStorage, Database, type Doc, type EnumerateFrom1To, type EnumerateUpTo, Errors, type ExtractObject, type ExtractProperty, type ExtractType, type FlagRequiredness, InMemory, type InOperator, IndexDB, type InitInput, type InitOutput, type InternalsRecord, type IsCreateOptional, type IsNestedOptional, type IsVersionGreaterThan0, type LogicalOperators, type MigrationFunction, type MigrationPathsForSchema, type MigrationPathsForSchemas, type MigrationsParameter, type NInOperator, type NestedRequiredNames, OpType, type Operation, type OperatorOrType, type Operators, Property, Query, type QueryOptions, type QueryType, RIDBError, type RIDBModule, type RequiredFieldNames, 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 };
|
|
1239
|
+
export { type AnyVersionGreaterThan1, BasePlugin, BaseStorage, type BaseStorageOptions, Collection, CoreStorage, type CreateDoc, type CreateStorage, Database, type Doc, type EnumerateFrom1To, type EnumerateUpTo, Errors, type ExtractObject, type ExtractProperty, type ExtractType, type FlagRequiredness, InMemory, type InOperator, IndexDB, type InitInput, type InitOutput, type InternalsRecord, type IsCreateOptional, type IsNestedOptional, type IsVersionGreaterThan0, type LogicalOperators, type ManagedTimestampsQuery, type MigrationFunction, type MigrationPathsForSchema, type MigrationPathsForSchemas, type MigrationsParameter, type NInOperator, type NestedRequiredNames, OpType, type Operation, type OperatorOrType, type Operators, Property, Query, type QueryOptions, type QueryType, RIDBError, type RIDBModule, type RequiredFieldNames, Schema, SchemaFieldType, type SchemaType, type SchemaTypeRecord, type SortDirection, type SortSpec, StorageInternal, type SyncInitInput, type UpdateDoc, 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 };
|