@laboverwire/stitch-wasm 0.5.1 → 0.6.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/package.json +1 -1
- package/stitch_wasm.d.ts +103 -83
- package/stitch_wasm_bg.js +497 -454
- package/stitch_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/stitch_wasm.d.ts
CHANGED
|
@@ -78,6 +78,13 @@ export class Cursor {
|
|
|
78
78
|
export class Database {
|
|
79
79
|
free(): void;
|
|
80
80
|
[Symbol.dispose](): void;
|
|
81
|
+
/**
|
|
82
|
+
* Adds a foreign key constraint and persists to storage.
|
|
83
|
+
*
|
|
84
|
+
* # Errors
|
|
85
|
+
* Returns an error if storage fails.
|
|
86
|
+
*/
|
|
87
|
+
addForeignKeyAsync(source_entity: string, source_field: string, target_entity: string, target_field: string, on_delete: string): Promise<void>;
|
|
81
88
|
/**
|
|
82
89
|
* Adds a foreign key constraint.
|
|
83
90
|
*
|
|
@@ -86,12 +93,12 @@ export class Database {
|
|
|
86
93
|
*/
|
|
87
94
|
addForeignKey(source_entity: string, source_field: string, target_entity: string, target_field: string, on_delete: string): void;
|
|
88
95
|
/**
|
|
89
|
-
* Adds
|
|
96
|
+
* Adds an index on the specified fields and backfills from existing records (async).
|
|
90
97
|
*
|
|
91
98
|
* # Errors
|
|
92
|
-
* Returns an error if storage fails.
|
|
99
|
+
* Returns an error if the storage operation fails during backfill.
|
|
93
100
|
*/
|
|
94
|
-
|
|
101
|
+
addIndexAsync(entity: string, fields: string[]): Promise<void>;
|
|
95
102
|
/**
|
|
96
103
|
* Adds an index on the specified fields and backfills from existing records (sync, memory only).
|
|
97
104
|
*
|
|
@@ -100,12 +107,12 @@ export class Database {
|
|
|
100
107
|
*/
|
|
101
108
|
addIndex(entity: string, fields: string[]): void;
|
|
102
109
|
/**
|
|
103
|
-
* Adds
|
|
110
|
+
* Adds a NOT NULL constraint and persists to storage.
|
|
104
111
|
*
|
|
105
112
|
* # Errors
|
|
106
|
-
* Returns an error if
|
|
113
|
+
* Returns an error if storage fails.
|
|
107
114
|
*/
|
|
108
|
-
|
|
115
|
+
addNotNullAsync(entity: string, field: string): Promise<void>;
|
|
109
116
|
/**
|
|
110
117
|
* Adds a NOT NULL constraint on the specified field.
|
|
111
118
|
*
|
|
@@ -114,12 +121,12 @@ export class Database {
|
|
|
114
121
|
*/
|
|
115
122
|
addNotNull(entity: string, field: string): void;
|
|
116
123
|
/**
|
|
117
|
-
* Adds a
|
|
124
|
+
* Adds a relationship definition and persists to storage.
|
|
118
125
|
*
|
|
119
126
|
* # Errors
|
|
120
127
|
* Returns an error if storage fails.
|
|
121
128
|
*/
|
|
122
|
-
|
|
129
|
+
addRelationshipAsync(source_entity: string, field: string, target_entity: string): Promise<void>;
|
|
123
130
|
/**
|
|
124
131
|
* Adds a relationship definition for eager loading.
|
|
125
132
|
*
|
|
@@ -128,12 +135,12 @@ export class Database {
|
|
|
128
135
|
*/
|
|
129
136
|
addRelationship(source_entity: string, field: string, target_entity: string): void;
|
|
130
137
|
/**
|
|
131
|
-
* Adds a
|
|
138
|
+
* Adds a schema definition for an entity and persists to storage.
|
|
132
139
|
*
|
|
133
140
|
* # Errors
|
|
134
|
-
* Returns an error if storage fails.
|
|
141
|
+
* Returns an error if the schema definition is invalid or storage fails.
|
|
135
142
|
*/
|
|
136
|
-
|
|
143
|
+
addSchemaAsync(entity: string, schema_js: any): Promise<void>;
|
|
137
144
|
/**
|
|
138
145
|
* Adds a schema definition for an entity (sync, memory backend only).
|
|
139
146
|
*
|
|
@@ -142,12 +149,12 @@ export class Database {
|
|
|
142
149
|
*/
|
|
143
150
|
addSchema(entity: string, schema_js: any): void;
|
|
144
151
|
/**
|
|
145
|
-
* Adds a
|
|
152
|
+
* Adds a unique constraint and persists to storage.
|
|
146
153
|
*
|
|
147
154
|
* # Errors
|
|
148
|
-
* Returns an error if
|
|
155
|
+
* Returns an error if storage fails.
|
|
149
156
|
*/
|
|
150
|
-
|
|
157
|
+
addUniqueConstraintAsync(entity: string, fields: string[]): Promise<void>;
|
|
151
158
|
/**
|
|
152
159
|
* Adds a unique constraint on the specified fields.
|
|
153
160
|
*
|
|
@@ -156,12 +163,10 @@ export class Database {
|
|
|
156
163
|
*/
|
|
157
164
|
addUniqueConstraint(entity: string, fields: string[]): void;
|
|
158
165
|
/**
|
|
159
|
-
* Adds a unique constraint and persists to storage.
|
|
160
|
-
*
|
|
161
166
|
* # Errors
|
|
162
|
-
* Returns an error if
|
|
167
|
+
* Returns an error if options are invalid or the backend is not memory-based.
|
|
163
168
|
*/
|
|
164
|
-
|
|
169
|
+
countSync(entity: string, options: any): number;
|
|
165
170
|
/**
|
|
166
171
|
* Counts records matching optional filters, using indexes when available.
|
|
167
172
|
*
|
|
@@ -171,9 +176,9 @@ export class Database {
|
|
|
171
176
|
count(entity: string, options: any): Promise<number>;
|
|
172
177
|
/**
|
|
173
178
|
* # Errors
|
|
174
|
-
* Returns an error if
|
|
179
|
+
* Returns an error if validation fails or the backend is not memory-based.
|
|
175
180
|
*/
|
|
176
|
-
|
|
181
|
+
createSync(entity: string, data: any): any;
|
|
177
182
|
/**
|
|
178
183
|
* Creates a new record in the specified entity.
|
|
179
184
|
*
|
|
@@ -181,11 +186,6 @@ export class Database {
|
|
|
181
186
|
* Returns an error if validation fails or the storage operation fails.
|
|
182
187
|
*/
|
|
183
188
|
create(entity: string, data: any): Promise<any>;
|
|
184
|
-
/**
|
|
185
|
-
* # Errors
|
|
186
|
-
* Returns an error if validation fails or the backend is not memory-based.
|
|
187
|
-
*/
|
|
188
|
-
createSync(entity: string, data: any): any;
|
|
189
189
|
/**
|
|
190
190
|
* Creates a cursor for streaming iteration over records.
|
|
191
191
|
*
|
|
@@ -193,6 +193,11 @@ export class Database {
|
|
|
193
193
|
* Returns an error if options are invalid or the storage operation fails.
|
|
194
194
|
*/
|
|
195
195
|
cursor(entity: string, options: any): Promise<Cursor>;
|
|
196
|
+
/**
|
|
197
|
+
* # Errors
|
|
198
|
+
* Returns an error if the record is not found, foreign key constraints prevent deletion, or the backend is not memory-based.
|
|
199
|
+
*/
|
|
200
|
+
deleteSync(entity: string, id: string): void;
|
|
196
201
|
/**
|
|
197
202
|
* Deletes a record by entity and ID.
|
|
198
203
|
*
|
|
@@ -200,11 +205,6 @@ export class Database {
|
|
|
200
205
|
* Returns an error if the record is not found or foreign key constraints prevent deletion.
|
|
201
206
|
*/
|
|
202
207
|
delete(entity: string, id: string): Promise<void>;
|
|
203
|
-
/**
|
|
204
|
-
* # Errors
|
|
205
|
-
* Returns an error if the record is not found, foreign key constraints prevent deletion, or the backend is not memory-based.
|
|
206
|
-
*/
|
|
207
|
-
deleteSync(entity: string, id: string): void;
|
|
208
208
|
/**
|
|
209
209
|
* Executes a database operation based on an MQTT-style topic.
|
|
210
210
|
*
|
|
@@ -235,13 +235,6 @@ export class Database {
|
|
|
235
235
|
*/
|
|
236
236
|
heartbeat(sub_id: string): boolean;
|
|
237
237
|
isMemoryBackend(): boolean;
|
|
238
|
-
/**
|
|
239
|
-
* Lists records from an entity with optional filtering, sorting, and pagination.
|
|
240
|
-
*
|
|
241
|
-
* # Errors
|
|
242
|
-
* Returns an error if options are invalid or the storage operation fails.
|
|
243
|
-
*/
|
|
244
|
-
list(entity: string, options: any): Promise<any>;
|
|
245
238
|
listConstraints(entity: string): any;
|
|
246
239
|
/**
|
|
247
240
|
* # Errors
|
|
@@ -254,16 +247,16 @@ export class Database {
|
|
|
254
247
|
* Returns an error if options are invalid or the backend is not memory-based.
|
|
255
248
|
*/
|
|
256
249
|
listSync(entity: string, options: any): any;
|
|
257
|
-
constructor();
|
|
258
|
-
static openEncrypted(db_name: string, passphrase: string): Promise<Database>;
|
|
259
|
-
static openPersistent(db_name: string): Promise<Database>;
|
|
260
250
|
/**
|
|
261
|
-
*
|
|
251
|
+
* Lists records from an entity with optional filtering, sorting, and pagination.
|
|
262
252
|
*
|
|
263
253
|
* # Errors
|
|
264
|
-
* Returns an error if
|
|
254
|
+
* Returns an error if options are invalid or the storage operation fails.
|
|
265
255
|
*/
|
|
266
|
-
|
|
256
|
+
list(entity: string, options: any): Promise<any>;
|
|
257
|
+
constructor();
|
|
258
|
+
static openEncrypted(db_name: string, passphrase: string): Promise<Database>;
|
|
259
|
+
static openPersistent(db_name: string): Promise<Database>;
|
|
267
260
|
/**
|
|
268
261
|
* # Errors
|
|
269
262
|
* Returns an error if the record is not found or the backend is not memory-based.
|
|
@@ -277,10 +270,12 @@ export class Database {
|
|
|
277
270
|
*/
|
|
278
271
|
readWithIncludes(entity: string, id: string, includes: any): Promise<any>;
|
|
279
272
|
/**
|
|
273
|
+
* Reads a record by entity and ID.
|
|
274
|
+
*
|
|
280
275
|
* # Errors
|
|
281
|
-
* Returns
|
|
276
|
+
* Returns an error if the record is not found or deserialization fails.
|
|
282
277
|
*/
|
|
283
|
-
|
|
278
|
+
read(entity: string, id: string): Promise<any>;
|
|
284
279
|
/**
|
|
285
280
|
* # Errors
|
|
286
281
|
* Returns `JsValue` if the database is currently borrowed.
|
|
@@ -290,19 +285,24 @@ export class Database {
|
|
|
290
285
|
* # Errors
|
|
291
286
|
* Returns `JsValue` if the database is currently borrowed.
|
|
292
287
|
*/
|
|
293
|
-
|
|
288
|
+
subscribe(pattern: string, entity: string | null | undefined, callback: Function): string;
|
|
294
289
|
/**
|
|
295
|
-
* Updates an existing record with new field values.
|
|
296
|
-
*
|
|
297
290
|
* # Errors
|
|
298
|
-
* Returns
|
|
291
|
+
* Returns `JsValue` if the database is currently borrowed.
|
|
299
292
|
*/
|
|
300
|
-
|
|
293
|
+
unsubscribe(sub_id: string): boolean;
|
|
301
294
|
/**
|
|
302
295
|
* # Errors
|
|
303
296
|
* Returns an error if the record is not found, validation fails, or the backend is not memory-based.
|
|
304
297
|
*/
|
|
305
298
|
updateSync(entity: string, id: string, fields: any): any;
|
|
299
|
+
/**
|
|
300
|
+
* Updates an existing record with new field values.
|
|
301
|
+
*
|
|
302
|
+
* # Errors
|
|
303
|
+
* Returns an error if the record is not found or validation fails.
|
|
304
|
+
*/
|
|
305
|
+
update(entity: string, id: string, fields: any): Promise<any>;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
export class MessageProperties {
|
|
@@ -325,12 +325,12 @@ export class MqttClient {
|
|
|
325
325
|
* # Errors
|
|
326
326
|
* Returns an error if connection fails.
|
|
327
327
|
*/
|
|
328
|
-
|
|
328
|
+
connectBroadcastChannel(channelName: string): Promise<void>;
|
|
329
329
|
/**
|
|
330
330
|
* # Errors
|
|
331
331
|
* Returns an error if connection fails.
|
|
332
332
|
*/
|
|
333
|
-
|
|
333
|
+
connectMessagePortWithOptions(port: MessagePort, config: ConnectOptions): Promise<void>;
|
|
334
334
|
/**
|
|
335
335
|
* # Errors
|
|
336
336
|
* Returns an error if connection fails.
|
|
@@ -340,12 +340,12 @@ export class MqttClient {
|
|
|
340
340
|
* # Errors
|
|
341
341
|
* Returns an error if connection fails.
|
|
342
342
|
*/
|
|
343
|
-
|
|
343
|
+
connectWithOptions(url: string, config: ConnectOptions): Promise<void>;
|
|
344
344
|
/**
|
|
345
345
|
* # Errors
|
|
346
346
|
* Returns an error if connection fails.
|
|
347
347
|
*/
|
|
348
|
-
|
|
348
|
+
connect(url: string): Promise<void>;
|
|
349
349
|
destroy(): void;
|
|
350
350
|
/**
|
|
351
351
|
* # Errors
|
|
@@ -368,22 +368,22 @@ export class MqttClient {
|
|
|
368
368
|
* # Errors
|
|
369
369
|
* Returns an error if not connected or publish fails.
|
|
370
370
|
*/
|
|
371
|
-
|
|
371
|
+
publishQos1(topic: string, payload: Uint8Array, callback: Function): Promise<number>;
|
|
372
372
|
/**
|
|
373
373
|
* # Errors
|
|
374
374
|
* Returns an error if not connected or publish fails.
|
|
375
375
|
*/
|
|
376
|
-
|
|
376
|
+
publishQos2(topic: string, payload: Uint8Array, callback: Function): Promise<number>;
|
|
377
377
|
/**
|
|
378
378
|
* # Errors
|
|
379
379
|
* Returns an error if not connected or publish fails.
|
|
380
380
|
*/
|
|
381
|
-
|
|
381
|
+
publishWithOptions(topic: string, payload: Uint8Array, options: PublishOptions): Promise<number>;
|
|
382
382
|
/**
|
|
383
383
|
* # Errors
|
|
384
384
|
* Returns an error if not connected or publish fails.
|
|
385
385
|
*/
|
|
386
|
-
|
|
386
|
+
publish(topic: string, payload: Uint8Array): Promise<void>;
|
|
387
387
|
/**
|
|
388
388
|
* # Errors
|
|
389
389
|
* Returns an error if no auth method is set or send fails.
|
|
@@ -394,17 +394,17 @@ export class MqttClient {
|
|
|
394
394
|
* # Errors
|
|
395
395
|
* Returns an error if not connected or subscribe fails.
|
|
396
396
|
*/
|
|
397
|
-
|
|
397
|
+
subscribeWithCallback(topic: string, callback: Function): Promise<number>;
|
|
398
398
|
/**
|
|
399
399
|
* # Errors
|
|
400
400
|
* Returns an error if not connected or subscribe fails.
|
|
401
401
|
*/
|
|
402
|
-
|
|
402
|
+
subscribeWithOptions(topic: string, callback: Function, options: SubscribeOptions): Promise<number>;
|
|
403
403
|
/**
|
|
404
404
|
* # Errors
|
|
405
405
|
* Returns an error if not connected or subscribe fails.
|
|
406
406
|
*/
|
|
407
|
-
|
|
407
|
+
subscribe(topic: string): Promise<number>;
|
|
408
408
|
/**
|
|
409
409
|
* # Errors
|
|
410
410
|
* Returns an error if not connected or unsubscribe fails.
|
|
@@ -493,6 +493,15 @@ export class Store {
|
|
|
493
493
|
* Returns an error if the write fails.
|
|
494
494
|
*/
|
|
495
495
|
create(entity: string, scope_id: string, data: any, tag?: string | null): Promise<string>;
|
|
496
|
+
/**
|
|
497
|
+
* Compare-and-set delete: remove the row only if its server version still
|
|
498
|
+
* equals `expectedVersion`. Same semantics as `updateIf`.
|
|
499
|
+
*
|
|
500
|
+
* # Errors
|
|
501
|
+
* Returns an error if the argument is malformed, there is no connected
|
|
502
|
+
* remote, or the broker rejects the write (including version mismatch).
|
|
503
|
+
*/
|
|
504
|
+
deleteIf(entity: string, id: string, expected_version: number): Promise<void>;
|
|
496
505
|
/**
|
|
497
506
|
* Delete a row. No-op if absent.
|
|
498
507
|
*
|
|
@@ -529,20 +538,20 @@ export class Store {
|
|
|
529
538
|
*/
|
|
530
539
|
getChildCount(entity: string, scope_id: string): number;
|
|
531
540
|
/**
|
|
532
|
-
* Snapshot of
|
|
533
|
-
* `getSnapshot`.
|
|
541
|
+
* Snapshot of `entity` within `scopeId` as an object keyed by row id.
|
|
534
542
|
*
|
|
535
543
|
* # Errors
|
|
536
544
|
* Returns an error if the read fails.
|
|
537
545
|
*/
|
|
538
|
-
|
|
546
|
+
getSnapshotAsMap(entity: string, scope_id: string): any;
|
|
539
547
|
/**
|
|
540
|
-
* Snapshot of `entity` within `scopeId
|
|
548
|
+
* Snapshot of all rows for `entity` within `scopeId`. Equivalent to TS
|
|
549
|
+
* `getSnapshot`.
|
|
541
550
|
*
|
|
542
551
|
* # Errors
|
|
543
552
|
* Returns an error if the read fails.
|
|
544
553
|
*/
|
|
545
|
-
|
|
554
|
+
getSnapshot(entity: string, scope_id: string): any;
|
|
546
555
|
/**
|
|
547
556
|
* Change token for `(scopeId, entity)`: increments on every mutation and on
|
|
548
557
|
* scope load, and resets to `0` when the scope is cleared or replaced by
|
|
@@ -586,14 +595,6 @@ export class Store {
|
|
|
586
595
|
* Returns an error if the store is not initialized.
|
|
587
596
|
*/
|
|
588
597
|
isReconnecting(): boolean;
|
|
589
|
-
/**
|
|
590
|
-
* List rows of `entity`, optionally filtered/sorted. `filter` is
|
|
591
|
-
* `{ scopeId?, sort?: [{ field, direction }], projection?: [string] }`.
|
|
592
|
-
*
|
|
593
|
-
* # Errors
|
|
594
|
-
* Returns an error if the read fails or `filter` is malformed.
|
|
595
|
-
*/
|
|
596
|
-
list(entity: string, filter: any): Promise<any>;
|
|
597
598
|
/**
|
|
598
599
|
* List all root entities across scopes, optionally sorted (`[{ field,
|
|
599
600
|
* direction }]`).
|
|
@@ -602,6 +603,14 @@ export class Store {
|
|
|
602
603
|
* Returns an error if the read fails or `sort` is malformed.
|
|
603
604
|
*/
|
|
604
605
|
listRootEntities(sort: any): Promise<any>;
|
|
606
|
+
/**
|
|
607
|
+
* List rows of `entity`, optionally filtered/sorted. `filter` is
|
|
608
|
+
* `{ scopeId?, sort?: [{ field, direction }], projection?: [string] }`.
|
|
609
|
+
*
|
|
610
|
+
* # Errors
|
|
611
|
+
* Returns an error if the read fails or `filter` is malformed.
|
|
612
|
+
*/
|
|
613
|
+
list(entity: string, filter: any): Promise<any>;
|
|
605
614
|
/**
|
|
606
615
|
* Load a scope's rows into the in-memory cache from caller-supplied data,
|
|
607
616
|
* `{ entity: [records] }`, replacing any currently-loaded scope. Equivalent
|
|
@@ -621,21 +630,21 @@ export class Store {
|
|
|
621
630
|
*/
|
|
622
631
|
pendingMutationCount(scope_id: string): Promise<number>;
|
|
623
632
|
/**
|
|
624
|
-
* Read a
|
|
633
|
+
* Read a row straight from durable persistence, bypassing the in-memory
|
|
634
|
+
* cache. Returns `null` if absent. Falls back to memory when the store has
|
|
635
|
+
* no persistence configured.
|
|
625
636
|
*
|
|
626
637
|
* # Errors
|
|
627
638
|
* Returns an error if the read fails.
|
|
628
639
|
*/
|
|
629
|
-
|
|
640
|
+
readLocalState(entity: string, id: string): Promise<any>;
|
|
630
641
|
/**
|
|
631
|
-
* Read a row
|
|
632
|
-
* cache. Returns `null` if absent. Falls back to memory when the store has
|
|
633
|
-
* no persistence configured.
|
|
642
|
+
* Read a single row from the in-memory cache, or `null` if absent.
|
|
634
643
|
*
|
|
635
644
|
* # Errors
|
|
636
645
|
* Returns an error if the read fails.
|
|
637
646
|
*/
|
|
638
|
-
|
|
647
|
+
read(entity: string, id: string): any;
|
|
639
648
|
/**
|
|
640
649
|
* `true` once [`Store::initialize`] has completed.
|
|
641
650
|
*/
|
|
@@ -717,12 +726,16 @@ export class Store {
|
|
|
717
726
|
*/
|
|
718
727
|
subscribeToScope(scope_id: string, entity: string, callback: Function): any;
|
|
719
728
|
/**
|
|
720
|
-
*
|
|
729
|
+
* Compare-and-set update: apply `fields` only if the row's server version
|
|
730
|
+
* still equals `expectedVersion` (from a prior row's `_version`). Returns
|
|
731
|
+
* the new version. Requires a live remote; rejects with a
|
|
732
|
+
* `preconditionFailed` error on a stale version.
|
|
721
733
|
*
|
|
722
734
|
* # Errors
|
|
723
|
-
* Returns an error if the
|
|
735
|
+
* Returns an error if the argument is malformed, there is no connected
|
|
736
|
+
* remote, or the broker rejects the write (including version mismatch).
|
|
724
737
|
*/
|
|
725
|
-
|
|
738
|
+
updateIf(entity: string, id: string, fields: any, expected_version: number): Promise<number>;
|
|
726
739
|
/**
|
|
727
740
|
* Upsert into persistence directly, bypassing memory and remote.
|
|
728
741
|
*
|
|
@@ -730,6 +743,13 @@ export class Store {
|
|
|
730
743
|
* Returns an error if the write fails.
|
|
731
744
|
*/
|
|
732
745
|
updateLocalState(entity: string, id: string, fields: any): Promise<void>;
|
|
746
|
+
/**
|
|
747
|
+
* Partial-update a row.
|
|
748
|
+
*
|
|
749
|
+
* # Errors
|
|
750
|
+
* Returns an error if the write fails.
|
|
751
|
+
*/
|
|
752
|
+
update(entity: string, id: string, fields: any, tag?: string | null): Promise<void>;
|
|
733
753
|
}
|
|
734
754
|
|
|
735
755
|
export class SubscribeOptions {
|