@laboverwire/stitch-wasm 0.1.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.
@@ -0,0 +1,765 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class ConnectOptions {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ addBackupUrl(url: string): void;
8
+ addUserProperty(key: string, value: string): void;
9
+ clearBackupUrls(): void;
10
+ clearUserProperties(): void;
11
+ clearWill(): void;
12
+ getBackupUrls(): string[];
13
+ constructor();
14
+ setWill(will: WillMessage): void;
15
+ get authenticationMethod(): string | undefined;
16
+ set authenticationMethod(value: string | null | undefined);
17
+ cleanStart: boolean;
18
+ keepAlive: number;
19
+ get maximumPacketSize(): number | undefined;
20
+ set maximumPacketSize(value: number | null | undefined);
21
+ protocolVersion: number;
22
+ get receiveMaximum(): number | undefined;
23
+ set receiveMaximum(value: number | null | undefined);
24
+ get requestProblemInformation(): boolean | undefined;
25
+ set requestProblemInformation(value: boolean | null | undefined);
26
+ get requestResponseInformation(): boolean | undefined;
27
+ set requestResponseInformation(value: boolean | null | undefined);
28
+ get sessionExpiryInterval(): number | undefined;
29
+ set sessionExpiryInterval(value: number | null | undefined);
30
+ set authenticationData(value: Uint8Array);
31
+ set password(value: Uint8Array);
32
+ get topicAliasMaximum(): number | undefined;
33
+ set topicAliasMaximum(value: number | null | undefined);
34
+ get username(): string | undefined;
35
+ set username(value: string | null | undefined);
36
+ }
37
+
38
+ export class Cursor {
39
+ private constructor();
40
+ free(): void;
41
+ [Symbol.dispose](): void;
42
+ count(): number;
43
+ hasMore(): boolean;
44
+ /**
45
+ * Returns up to N items from the cursor as an array.
46
+ *
47
+ * # Errors
48
+ * Returns an error if serialization fails.
49
+ */
50
+ nextBatch(size: number): any;
51
+ /**
52
+ * Returns the next item from the cursor.
53
+ *
54
+ * # Errors
55
+ * Returns an error if serialization fails.
56
+ */
57
+ nextItem(): any;
58
+ position(): number;
59
+ reset(): void;
60
+ }
61
+
62
+ export class Database {
63
+ free(): void;
64
+ [Symbol.dispose](): void;
65
+ /**
66
+ * Adds a foreign key constraint.
67
+ *
68
+ * # Errors
69
+ * This function does not currently return errors but the signature allows for future validation.
70
+ */
71
+ addForeignKey(source_entity: string, source_field: string, target_entity: string, target_field: string, on_delete: string): void;
72
+ /**
73
+ * Adds a foreign key constraint and persists to storage.
74
+ *
75
+ * # Errors
76
+ * Returns an error if storage fails.
77
+ */
78
+ addForeignKeyAsync(source_entity: string, source_field: string, target_entity: string, target_field: string, on_delete: string): Promise<void>;
79
+ /**
80
+ * Adds an index on the specified fields and backfills from existing records (sync, memory only).
81
+ *
82
+ * # Errors
83
+ * Returns an error if the backend is not memory-based or backfill fails.
84
+ */
85
+ addIndex(entity: string, fields: string[]): void;
86
+ /**
87
+ * Adds an index on the specified fields and backfills from existing records (async).
88
+ *
89
+ * # Errors
90
+ * Returns an error if the storage operation fails during backfill.
91
+ */
92
+ addIndexAsync(entity: string, fields: string[]): Promise<void>;
93
+ /**
94
+ * Adds a NOT NULL constraint on the specified field.
95
+ *
96
+ * # Errors
97
+ * This function does not currently return errors but the signature allows for future validation.
98
+ */
99
+ addNotNull(entity: string, field: string): void;
100
+ /**
101
+ * Adds a NOT NULL constraint and persists to storage.
102
+ *
103
+ * # Errors
104
+ * Returns an error if storage fails.
105
+ */
106
+ addNotNullAsync(entity: string, field: string): Promise<void>;
107
+ /**
108
+ * Adds a relationship definition for eager loading.
109
+ *
110
+ * # Errors
111
+ * This function does not currently return errors but the signature allows for future validation.
112
+ */
113
+ addRelationship(source_entity: string, field: string, target_entity: string): void;
114
+ /**
115
+ * Adds a relationship definition and persists to storage.
116
+ *
117
+ * # Errors
118
+ * Returns an error if storage fails.
119
+ */
120
+ addRelationshipAsync(source_entity: string, field: string, target_entity: string): Promise<void>;
121
+ /**
122
+ * Adds a schema definition for an entity (sync, memory backend only).
123
+ *
124
+ * # Errors
125
+ * Returns an error if the schema definition is invalid.
126
+ */
127
+ addSchema(entity: string, schema_js: any): void;
128
+ /**
129
+ * Adds a schema definition for an entity and persists to storage.
130
+ *
131
+ * # Errors
132
+ * Returns an error if the schema definition is invalid or storage fails.
133
+ */
134
+ addSchemaAsync(entity: string, schema_js: any): Promise<void>;
135
+ /**
136
+ * Adds a unique constraint on the specified fields.
137
+ *
138
+ * # Errors
139
+ * This function does not currently return errors but the signature allows for future validation.
140
+ */
141
+ addUniqueConstraint(entity: string, fields: string[]): void;
142
+ /**
143
+ * Adds a unique constraint and persists to storage.
144
+ *
145
+ * # Errors
146
+ * Returns an error if storage fails.
147
+ */
148
+ addUniqueConstraintAsync(entity: string, fields: string[]): Promise<void>;
149
+ /**
150
+ * Counts records matching optional filters, using indexes when available.
151
+ *
152
+ * # Errors
153
+ * Returns an error if options are invalid or the storage operation fails.
154
+ */
155
+ count(entity: string, options: any): Promise<number>;
156
+ /**
157
+ * # Errors
158
+ * Returns an error if options are invalid or the backend is not memory-based.
159
+ */
160
+ countSync(entity: string, options: any): number;
161
+ /**
162
+ * Creates a new record in the specified entity.
163
+ *
164
+ * # Errors
165
+ * Returns an error if validation fails or the storage operation fails.
166
+ */
167
+ create(entity: string, data: any): Promise<any>;
168
+ /**
169
+ * # Errors
170
+ * Returns an error if validation fails or the backend is not memory-based.
171
+ */
172
+ createSync(entity: string, data: any): any;
173
+ /**
174
+ * Creates a cursor for streaming iteration over records.
175
+ *
176
+ * # Errors
177
+ * Returns an error if options are invalid or the storage operation fails.
178
+ */
179
+ cursor(entity: string, options: any): Promise<Cursor>;
180
+ /**
181
+ * Deletes a record by entity and ID.
182
+ *
183
+ * # Errors
184
+ * Returns an error if the record is not found or foreign key constraints prevent deletion.
185
+ */
186
+ delete(entity: string, id: string): Promise<void>;
187
+ /**
188
+ * # Errors
189
+ * Returns an error if the record is not found, foreign key constraints prevent deletion, or the backend is not memory-based.
190
+ */
191
+ deleteSync(entity: string, id: string): void;
192
+ /**
193
+ * Executes a database operation based on an MQTT-style topic.
194
+ *
195
+ * # Errors
196
+ * Returns an error if the topic is invalid or the operation fails.
197
+ */
198
+ execute(topic: string, payload: any): Promise<any>;
199
+ /**
200
+ * # Errors
201
+ * Returns `JsValue` if the database is currently borrowed.
202
+ */
203
+ getConsumerGroup(group_name: string): any;
204
+ /**
205
+ * Gets the schema definition for an entity.
206
+ *
207
+ * # Errors
208
+ * Returns an error if serialization fails.
209
+ */
210
+ getSchema(entity: string): any;
211
+ /**
212
+ * # Errors
213
+ * Returns `JsValue` if the database is currently borrowed.
214
+ */
215
+ getSubscriptionInfo(sub_id: string): any;
216
+ /**
217
+ * # Errors
218
+ * Returns `JsValue` if the database is currently borrowed.
219
+ */
220
+ heartbeat(sub_id: string): boolean;
221
+ isMemoryBackend(): boolean;
222
+ /**
223
+ * Lists records from an entity with optional filtering, sorting, and pagination.
224
+ *
225
+ * # Errors
226
+ * Returns an error if options are invalid or the storage operation fails.
227
+ */
228
+ list(entity: string, options: any): Promise<any>;
229
+ listConstraints(entity: string): any;
230
+ /**
231
+ * # Errors
232
+ * Returns `JsValue` if the database is currently borrowed.
233
+ */
234
+ listConsumerGroups(): any;
235
+ listRelationships(entity: string): any;
236
+ /**
237
+ * # Errors
238
+ * Returns an error if options are invalid or the backend is not memory-based.
239
+ */
240
+ listSync(entity: string, options: any): any;
241
+ constructor();
242
+ static openEncrypted(db_name: string, passphrase: string): Promise<Database>;
243
+ static openPersistent(db_name: string): Promise<Database>;
244
+ /**
245
+ * Reads a record by entity and ID.
246
+ *
247
+ * # Errors
248
+ * Returns an error if the record is not found or deserialization fails.
249
+ */
250
+ read(entity: string, id: string): Promise<any>;
251
+ /**
252
+ * # Errors
253
+ * Returns an error if the record is not found or the backend is not memory-based.
254
+ */
255
+ readSync(entity: string, id: string): any;
256
+ /**
257
+ * Reads a record with related entities eagerly loaded.
258
+ *
259
+ * # Errors
260
+ * Returns an error if the record is not found or includes cannot be loaded.
261
+ */
262
+ readWithIncludes(entity: string, id: string, includes: any): Promise<any>;
263
+ /**
264
+ * # Errors
265
+ * Returns `JsValue` if the database is currently borrowed.
266
+ */
267
+ subscribe(pattern: string, entity: string | null | undefined, callback: Function): string;
268
+ /**
269
+ * # Errors
270
+ * Returns `JsValue` if the database is currently borrowed.
271
+ */
272
+ subscribeShared(pattern: string, entity: string | null | undefined, group: string, mode: string, callback: Function): string;
273
+ /**
274
+ * # Errors
275
+ * Returns `JsValue` if the database is currently borrowed.
276
+ */
277
+ unsubscribe(sub_id: string): boolean;
278
+ /**
279
+ * Updates an existing record with new field values.
280
+ *
281
+ * # Errors
282
+ * Returns an error if the record is not found or validation fails.
283
+ */
284
+ update(entity: string, id: string, fields: any): Promise<any>;
285
+ /**
286
+ * # Errors
287
+ * Returns an error if the record is not found, validation fails, or the backend is not memory-based.
288
+ */
289
+ updateSync(entity: string, id: string, fields: any): any;
290
+ }
291
+
292
+ export class MessageProperties {
293
+ private constructor();
294
+ free(): void;
295
+ [Symbol.dispose](): void;
296
+ getUserProperties(): Array<any>;
297
+ readonly contentType: string | undefined;
298
+ readonly correlationData: Uint8Array | undefined;
299
+ readonly messageExpiryInterval: number | undefined;
300
+ readonly payloadFormatIndicator: boolean | undefined;
301
+ readonly responseTopic: string | undefined;
302
+ readonly subscriptionIdentifiers: Uint32Array;
303
+ }
304
+
305
+ export class MqttClient {
306
+ free(): void;
307
+ [Symbol.dispose](): void;
308
+ /**
309
+ * # Errors
310
+ * Returns an error if connection fails.
311
+ */
312
+ connect(url: string): Promise<void>;
313
+ /**
314
+ * # Errors
315
+ * Returns an error if connection fails.
316
+ */
317
+ connectBroadcastChannel(channelName: string): Promise<void>;
318
+ /**
319
+ * # Errors
320
+ * Returns an error if connection fails.
321
+ */
322
+ connectMessagePort(port: MessagePort): Promise<void>;
323
+ /**
324
+ * # Errors
325
+ * Returns an error if connection fails.
326
+ */
327
+ connectMessagePortWithOptions(port: MessagePort, config: ConnectOptions): Promise<void>;
328
+ /**
329
+ * # Errors
330
+ * Returns an error if connection fails.
331
+ */
332
+ connectWithOptions(url: string, config: ConnectOptions): Promise<void>;
333
+ destroy(): void;
334
+ /**
335
+ * # Errors
336
+ * Returns an error if disconnect fails.
337
+ */
338
+ disconnect(): Promise<void>;
339
+ enableAutoReconnect(enabled: boolean): void;
340
+ isBrowserOnline(): boolean;
341
+ isConnected(): boolean;
342
+ isReconnecting(): boolean;
343
+ constructor(clientId: string);
344
+ onAuthChallenge(callback: Function): void;
345
+ onConnect(callback: Function): void;
346
+ onConnectivityChange(callback: Function): void;
347
+ onDisconnect(callback: Function): void;
348
+ onError(callback: Function): void;
349
+ onReconnectFailed(callback: Function): void;
350
+ onReconnecting(callback: Function): void;
351
+ /**
352
+ * # Errors
353
+ * Returns an error if not connected or publish fails.
354
+ */
355
+ publish(topic: string, payload: Uint8Array): Promise<void>;
356
+ /**
357
+ * # Errors
358
+ * Returns an error if not connected or publish fails.
359
+ */
360
+ publishQos1(topic: string, payload: Uint8Array, callback: Function): Promise<number>;
361
+ /**
362
+ * # Errors
363
+ * Returns an error if not connected or publish fails.
364
+ */
365
+ publishQos2(topic: string, payload: Uint8Array, callback: Function): Promise<number>;
366
+ /**
367
+ * # Errors
368
+ * Returns an error if not connected or publish fails.
369
+ */
370
+ publishWithOptions(topic: string, payload: Uint8Array, options: PublishOptions): Promise<void>;
371
+ /**
372
+ * # Errors
373
+ * Returns an error if no auth method is set or send fails.
374
+ */
375
+ respondAuth(authData: Uint8Array): void;
376
+ setReconnectOptions(options: ReconnectOptions): void;
377
+ /**
378
+ * # Errors
379
+ * Returns an error if not connected or subscribe fails.
380
+ */
381
+ subscribe(topic: string): Promise<number>;
382
+ /**
383
+ * # Errors
384
+ * Returns an error if not connected or subscribe fails.
385
+ */
386
+ subscribeWithCallback(topic: string, callback: Function): Promise<number>;
387
+ /**
388
+ * # Errors
389
+ * Returns an error if not connected or subscribe fails.
390
+ */
391
+ subscribeWithOptions(topic: string, callback: Function, options: SubscribeOptions): Promise<number>;
392
+ /**
393
+ * # Errors
394
+ * Returns an error if not connected or unsubscribe fails.
395
+ */
396
+ unsubscribe(topic: string): Promise<number>;
397
+ }
398
+
399
+ export class PublishOptions {
400
+ free(): void;
401
+ [Symbol.dispose](): void;
402
+ addUserProperty(key: string, value: string): void;
403
+ clearUserProperties(): void;
404
+ constructor();
405
+ get contentType(): string | undefined;
406
+ set contentType(value: string | null | undefined);
407
+ get messageExpiryInterval(): number | undefined;
408
+ set messageExpiryInterval(value: number | null | undefined);
409
+ get payloadFormatIndicator(): boolean | undefined;
410
+ set payloadFormatIndicator(value: boolean | null | undefined);
411
+ qos: number;
412
+ get responseTopic(): string | undefined;
413
+ set responseTopic(value: string | null | undefined);
414
+ retain: boolean;
415
+ set correlationData(value: Uint8Array);
416
+ get topicAlias(): number | undefined;
417
+ set topicAlias(value: number | null | undefined);
418
+ }
419
+
420
+ export class ReconnectOptions {
421
+ free(): void;
422
+ [Symbol.dispose](): void;
423
+ static disabled(): ReconnectOptions;
424
+ constructor();
425
+ backoffFactor: number;
426
+ enabled: boolean;
427
+ initialDelayMs: number;
428
+ get maxAttempts(): number | undefined;
429
+ set maxAttempts(value: number | null | undefined);
430
+ maxDelayMs: number;
431
+ }
432
+
433
+ /**
434
+ * Reactive state-sync store, browser flavour. Construct with [`create_store`],
435
+ * call [`Store::initialize`] once, then issue CRUD calls.
436
+ */
437
+ export class Store {
438
+ private constructor();
439
+ free(): void;
440
+ [Symbol.dispose](): void;
441
+ /**
442
+ * Defer memory-bus notifications until [`Store::end_batch`]; rapid bursts
443
+ * collapse to one event per `(scope, entity)`.
444
+ *
445
+ * # Errors
446
+ * Returns an error if the store is not initialized.
447
+ */
448
+ beginBatch(): void;
449
+ /**
450
+ * Clear a scope from the in-memory cache. Equivalent to TS `clearScope`.
451
+ *
452
+ * # Errors
453
+ * Returns an error if the operation fails.
454
+ */
455
+ clearScope(scope_id: string): Promise<void>;
456
+ /**
457
+ * Unsubscribe from a scope's remote topics and clear it from the active
458
+ * scope if it was current.
459
+ *
460
+ * # Errors
461
+ * Returns an error if the operation fails.
462
+ */
463
+ closeScope(scope_id: string): Promise<void>;
464
+ /**
465
+ * Current remote connection status as a string (`"Offline"`,
466
+ * `"Connecting"`, `"Connected"`, `"Disconnected"`, `"Error"`). `"Offline"`
467
+ * when no remote is configured.
468
+ *
469
+ * # Errors
470
+ * Returns an error if the store is not initialized.
471
+ */
472
+ connectionStatus(): string;
473
+ /**
474
+ * Insert a row into `entity` under `scopeId`. Returns the new row's id.
475
+ *
476
+ * # Errors
477
+ * Returns an error if the write fails.
478
+ */
479
+ create(entity: string, scope_id: string, data: any, tag?: string | null): Promise<string>;
480
+ /**
481
+ * Delete a row. No-op if absent.
482
+ *
483
+ * # Errors
484
+ * Returns an error if the write fails.
485
+ */
486
+ delete(entity: string, id: string, tag?: string | null): Promise<void>;
487
+ /**
488
+ * Disconnect the remote, close persistence, and abort background tasks.
489
+ *
490
+ * # Errors
491
+ * Returns an error if the operation fails.
492
+ */
493
+ destroy(): Promise<void>;
494
+ /**
495
+ * Disconnect the remote client. Memory and persistence are unaffected.
496
+ *
497
+ * # Errors
498
+ * Returns an error if the disconnect fails.
499
+ */
500
+ disconnect(): Promise<void>;
501
+ /**
502
+ * Flush the batch opened by [`Store::begin_batch`].
503
+ *
504
+ * # Errors
505
+ * Returns an error if the store is not initialized.
506
+ */
507
+ endBatch(): void;
508
+ /**
509
+ * Count of rows of `entity` within `scopeId`.
510
+ *
511
+ * # Errors
512
+ * Returns an error if the read fails.
513
+ */
514
+ getChildCount(entity: string, scope_id: string): number;
515
+ /**
516
+ * Snapshot of all rows for `entity` within `scopeId`. Equivalent to TS
517
+ * `getSnapshot`.
518
+ *
519
+ * # Errors
520
+ * Returns an error if the read fails.
521
+ */
522
+ getSnapshot(entity: string, scope_id: string): any;
523
+ /**
524
+ * Snapshot of `entity` within `scopeId` as an object keyed by row id.
525
+ *
526
+ * # Errors
527
+ * Returns an error if the read fails.
528
+ */
529
+ getSnapshotAsMap(entity: string, scope_id: string): any;
530
+ /**
531
+ * Change token for `(scopeId, entity)`: increments on every mutation and on
532
+ * scope load, and resets to `0` when the scope is cleared or replaced by
533
+ * loading another scope. Top-level (global) entities are versioned under the
534
+ * empty scope. Lets the JS layer cache snapshots and re-fetch whenever this
535
+ * differs from the last seen value (referential stability for React).
536
+ *
537
+ * # Errors
538
+ * Returns an error if the store is not initialized.
539
+ */
540
+ getVersion(scope_id: string, entity: string): number;
541
+ /**
542
+ * `true` if durable IndexedDB persistence is configured.
543
+ *
544
+ * # Errors
545
+ * Returns an error if the store is not initialized.
546
+ */
547
+ hasPersistence(): boolean;
548
+ /**
549
+ * `true` if remote sync is configured.
550
+ *
551
+ * # Errors
552
+ * Returns an error if the store is not initialized.
553
+ */
554
+ hasRemote(): boolean;
555
+ /**
556
+ * Open the store (in-memory + persistence) and, when a remote is
557
+ * configured, connect to the broker. Idempotent.
558
+ *
559
+ * # Errors
560
+ * Returns an error if the underlying database fails to open.
561
+ */
562
+ initialize(): Promise<void>;
563
+ /**
564
+ * `true` while the remote client is between connections.
565
+ *
566
+ * # Errors
567
+ * Returns an error if the store is not initialized.
568
+ */
569
+ isReconnecting(): boolean;
570
+ /**
571
+ * List rows of `entity`, optionally filtered/sorted. `filter` is
572
+ * `{ scopeId?, sort?: [{ field, direction }], projection?: [string] }`.
573
+ *
574
+ * # Errors
575
+ * Returns an error if the read fails or `filter` is malformed.
576
+ */
577
+ list(entity: string, filter: any): Promise<any>;
578
+ /**
579
+ * List all root entities across scopes, optionally sorted (`[{ field,
580
+ * direction }]`).
581
+ *
582
+ * # Errors
583
+ * Returns an error if the read fails or `sort` is malformed.
584
+ */
585
+ listRootEntities(sort: any): Promise<any>;
586
+ /**
587
+ * Load a scope's rows into the in-memory cache from caller-supplied data,
588
+ * `{ entity: [records] }`, replacing any currently-loaded scope. Equivalent
589
+ * to TS `loadScope`.
590
+ *
591
+ * # Errors
592
+ * Returns an error if `data` is malformed or the load fails.
593
+ */
594
+ loadScope(scope_id: string, data: any): Promise<void>;
595
+ /**
596
+ * Number of offline-queued mutations buffered for `scopeId` (the
597
+ * authenticated user's pending writes). `0` when no remote/queue is
598
+ * configured.
599
+ *
600
+ * # Errors
601
+ * Returns an error if the store is not initialized.
602
+ */
603
+ pendingMutationCount(scope_id: string): Promise<number>;
604
+ /**
605
+ * Read a single row from the in-memory cache, or `null` if absent.
606
+ *
607
+ * # Errors
608
+ * Returns an error if the read fails.
609
+ */
610
+ read(entity: string, id: string): any;
611
+ /**
612
+ * Read a row straight from durable persistence, bypassing the in-memory
613
+ * cache. Returns `null` if absent. Falls back to memory when the store has
614
+ * no persistence configured.
615
+ *
616
+ * # Errors
617
+ * Returns an error if the read fails.
618
+ */
619
+ readLocalState(entity: string, id: string): Promise<any>;
620
+ /**
621
+ * `true` once [`Store::initialize`] has completed.
622
+ */
623
+ ready(): boolean;
624
+ /**
625
+ * Reconnect the remote client, optionally with a fresh JWT ticket or
626
+ * fresh username + password.
627
+ *
628
+ * # Errors
629
+ * Returns an error if no remote is configured or the reconnect fails.
630
+ */
631
+ reconnect(server_url: string, ticket?: string | null, username?: string | null, password?: string | null): Promise<void>;
632
+ /**
633
+ * Switch the active scope, loading its rows from persistence into the
634
+ * in-memory cache. Use after reopening a persistent store to rehydrate a
635
+ * scope's snapshot.
636
+ *
637
+ * # Errors
638
+ * Returns an error if the load fails.
639
+ */
640
+ replaceScope(scope_id: string): Promise<void>;
641
+ /**
642
+ * Send an arbitrary MQTT request and await the broker's response.
643
+ *
644
+ * # Errors
645
+ * Returns an error if no remote is configured or the request fails.
646
+ */
647
+ request(topic: string, payload: any): Promise<any>;
648
+ /**
649
+ * Disconnect, clear auth + sync state. Persistence and the offline queue
650
+ * stay alive; drop the store to fully reset.
651
+ *
652
+ * # Errors
653
+ * Returns an error if the operation fails.
654
+ */
655
+ resetForLogout(): Promise<void>;
656
+ /**
657
+ * Set (or clear, with `null`/`undefined`) the authenticated user. Offline
658
+ * writes are scoped to this user and are dropped while it is unset, so call
659
+ * this before issuing writes you want queued for replay.
660
+ *
661
+ * # Errors
662
+ * Returns an error if the store is not initialized.
663
+ */
664
+ setAuthenticatedUser(user_id?: string | null): void;
665
+ /**
666
+ * Register a callback fired when the broker rejects the session
667
+ * (`MQTT_DISCONNECT_AUTH_FAILURE`). Use it to clear cached auth and route
668
+ * the user to re-login. No-op if no remote is configured.
669
+ *
670
+ * # Errors
671
+ * Returns an error if the store is not initialized.
672
+ */
673
+ setSessionInvalidHandler(callback: Function): void;
674
+ /**
675
+ * Subscribe to remote connection-status changes; the callback receives the
676
+ * status string. Returns an unsubscribe function (a no-op when no remote is
677
+ * configured).
678
+ *
679
+ * # Errors
680
+ * Returns an error if the store is not initialized.
681
+ */
682
+ subscribeToConnectionStatus(callback: Function): any;
683
+ /**
684
+ * Subscribe to mutations for `entity`. The callback receives
685
+ * `(data | null, op)` where `op` is `"insert" | "update" | "delete"`.
686
+ * Returns an unsubscribe function.
687
+ *
688
+ * # Errors
689
+ * Returns an error if the store is not initialized.
690
+ */
691
+ subscribeToEntity(entity: string, callback: Function): any;
692
+ /**
693
+ * Subscribe to mutations for `(scopeId, entity)`. The callback takes no
694
+ * args (a "scope changed" signal). Returns an unsubscribe function.
695
+ *
696
+ * # Errors
697
+ * Returns an error if the store is not initialized.
698
+ */
699
+ subscribeToScope(scope_id: string, entity: string, callback: Function): any;
700
+ /**
701
+ * Partial-update a row.
702
+ *
703
+ * # Errors
704
+ * Returns an error if the write fails.
705
+ */
706
+ update(entity: string, id: string, fields: any, tag?: string | null): Promise<void>;
707
+ /**
708
+ * Upsert into persistence directly, bypassing memory and remote.
709
+ *
710
+ * # Errors
711
+ * Returns an error if the write fails.
712
+ */
713
+ updateLocalState(entity: string, id: string, fields: any): Promise<void>;
714
+ }
715
+
716
+ export class SubscribeOptions {
717
+ free(): void;
718
+ [Symbol.dispose](): void;
719
+ constructor();
720
+ noLocal: boolean;
721
+ qos: number;
722
+ retainAsPublished: boolean;
723
+ retainHandling: number;
724
+ get subscriptionIdentifier(): number | undefined;
725
+ set subscriptionIdentifier(value: number | null | undefined);
726
+ }
727
+
728
+ export class WillMessage {
729
+ free(): void;
730
+ [Symbol.dispose](): void;
731
+ constructor(topic: string, payload: Uint8Array);
732
+ get contentType(): string | undefined;
733
+ set contentType(value: string | null | undefined);
734
+ get messageExpiryInterval(): number | undefined;
735
+ set messageExpiryInterval(value: number | null | undefined);
736
+ qos: number;
737
+ get responseTopic(): string | undefined;
738
+ set responseTopic(value: string | null | undefined);
739
+ retain: boolean;
740
+ topic: string;
741
+ get willDelayInterval(): number | undefined;
742
+ set willDelayInterval(value: number | null | undefined);
743
+ }
744
+
745
+ /**
746
+ * Build an unopened [`Store`] from a config object
747
+ * (`{ entities, scope: { rootEntity, childEntities, scopeField } }`).
748
+ *
749
+ * Pass an optional second argument to enable durable IndexedDB persistence
750
+ * and/or remote MQTT-over-WebSocket sync:
751
+ * `{ persistence: { dbName, passphrase? }, remote: { url, clientId?, ticket?, username?, password? } }`.
752
+ * With a persistence `passphrase` the store is AES-GCM encrypted. `remote.url`
753
+ * must be a `ws://`/`wss://` endpoint; `remote.ticket` is a JWT used for MQTT v5
754
+ * enhanced auth, and `remote.username` + `remote.password` drive classic MQTT
755
+ * password auth when the broker isn't in JWT mode (ticket takes precedence).
756
+ * `initialize` then connects and live
757
+ * mutations flow through `subscribeToEntity`/`getSnapshot`. Omit the argument
758
+ * for an in-memory store.
759
+ *
760
+ * # Errors
761
+ * Returns an error if the config or options object is malformed.
762
+ */
763
+ export function createStore(config: any, options: any): Store;
764
+
765
+ export function init(): void;