jazz-wasm 2.0.0-alpha.49 → 2.0.0-alpha.51

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jazz-wasm",
3
- "version": "2.0.0-alpha.49",
3
+ "version": "2.0.0-alpha.51",
4
4
  "description": "WebAssembly bindings for the Jazz database engine",
5
5
  "keywords": [
6
6
  "crdt",
@@ -107,27 +107,8 @@ export class WasmRuntime {
107
107
  * Debug helper: expose schema/lens state currently loaded in SchemaManager.
108
108
  */
109
109
  __debugSchemaState(): any;
110
- /**
111
- * Debug helper: seed a historical schema and persist schema/lens catalogue objects.
112
- */
113
- __debugSeedLiveSchema(schema_json: string): void;
114
- acknowledgeRejectedBatch(batch_id: string): boolean;
115
- /**
116
- * Add a client connection (for server-side use in tests).
117
- */
118
- addClient(): string;
119
- /**
120
- * Add a server connection.
121
- *
122
- * After adding the server, immediately flushes the outbox so that
123
- * catalogue sync messages (from queue_full_sync_to_server) are sent
124
- * before the call returns, rather than being deferred to a microtask.
125
- */
126
- addServer(server_catalogue_state_hash?: string | null, next_sync_seq?: number | null): void;
127
- /**
128
- * Drive the runtime's batched receive/apply/send loop immediately.
129
- */
130
- batchedTick(): void;
110
+ beginBatch(batch_mode: string): string;
111
+ commitBatch(batch_id: string): void;
131
112
  /**
132
113
  * Connect to a Jazz server over WebSocket.
133
114
  *
@@ -153,13 +134,8 @@ export class WasmRuntime {
153
134
  /**
154
135
  * Delete a row by ObjectId.
155
136
  */
156
- delete(object_id: string): any;
157
- /**
158
- * Delete a row by ObjectId as an explicit session principal.
159
- */
160
- deleteWithSession(object_id: string, write_context_json?: string | null): any;
137
+ delete(object_id: string, write_context_json?: string | null): any;
161
138
  static deriveUserId(seed_b64: string): string;
162
- discardLocalBatch(batch_id: string): boolean;
163
139
  /**
164
140
  * Disconnect from the Jazz server and drop the transport handle.
165
141
  */
@@ -171,15 +147,6 @@ export class WasmRuntime {
171
147
  * No-ops silently if the handle was already unsubscribed.
172
148
  */
173
149
  executeSubscription(handle: number, on_update: Function): void;
174
- /**
175
- * Flush all data to persistent storage (snapshot).
176
- */
177
- flush(): void;
178
- /**
179
- * Flush only the WAL buffer to OPFS (not the snapshot).
180
- */
181
- flushWal(): void;
182
- static getPublicKeyBase64url(seed_b64: string): string;
183
150
  /**
184
151
  * Get the current schema as JSON.
185
152
  */
@@ -188,22 +155,13 @@ export class WasmRuntime {
188
155
  * Get the canonical schema hash (64-char hex).
189
156
  */
190
157
  getSchemaHash(): string;
191
- hydrateLocalBatchRecordStorageRow(bytes: Uint8Array): void;
192
158
  /**
193
159
  * Insert a row into a table.
194
160
  *
195
161
  * # Returns
196
162
  * The inserted row as `{ id, values, batchId }`.
197
163
  */
198
- insert(table: string, values: any, object_id?: string | null): any;
199
- /**
200
- * Insert a row into a table as an explicit session principal.
201
- */
202
- insertWithSession(table: string, values: any, write_context_json?: string | null, object_id?: string | null): any;
203
- loadBatchFate(batch_id: string): any;
204
- loadLocalBatchRecord(batch_id: string): any;
205
- loadLocalBatchRecordStorageRow(batch_id: string): any;
206
- loadLocalBatchRecords(): any;
164
+ insert(table: string, values: any, write_context_json?: string | null, object_id?: string | null): any;
207
165
  static mintJazzSelfSignedToken(seed_b64: string, issuer: string, audience: string, ttl_seconds: bigint, now_seconds: bigint): string;
208
166
  /**
209
167
  * Create a new WasmRuntime.
@@ -219,8 +177,10 @@ export class WasmRuntime {
219
177
  * Set for server nodes to enable ack emission.
220
178
  * * `use_binary_encoding` - Optional outgoing sync payload encoding mode.
221
179
  * `Some(true)` emits postcard bytes (`Uint8Array`), otherwise JSON strings.
180
+ * * `non_durable_client` - Internal browser main-thread mode. When true,
181
+ * direct writes stay optimistic until a durable peer syncs `BatchFate`.
222
182
  */
223
- constructor(schema_json: string, app_id: string, env: string, user_branch: string, tier?: string | null, use_binary_encoding?: boolean | null);
183
+ constructor(schema_json: string, app_id: string, env: string, user_branch: string, tier?: string | null, use_binary_encoding?: boolean | null, non_durable_client?: boolean | null);
224
184
  /**
225
185
  * Register a JS callback that fires when the Rust transport receives an
226
186
  * auth failure (Unauthorized) from the server during the WS handshake.
@@ -232,72 +192,17 @@ export class WasmRuntime {
232
192
  * Register a callback for unhandled mutation errors.
233
193
  */
234
194
  onMutationError(callback: Function): void;
235
- /**
236
- * Called by JS when a sync message arrives from the server.
237
- *
238
- * # Arguments
239
- * * `payload` - Either postcard-encoded SyncPayload bytes (`Uint8Array`)
240
- * or JSON-encoded SyncPayload (`string`)
241
- */
242
- onSyncMessageReceived(payload: any, sequence?: number | null): void;
243
- /**
244
- * Called by JS when a sync message arrives from a client (not a server).
245
- *
246
- * # Arguments
247
- * * `client_id` - UUID string of the sending client
248
- * * `payload` - Postcard-encoded SyncPayload bytes
249
- */
250
- onSyncMessageReceivedFromClient(client_id: string, payload: any): void;
251
- /**
252
- * Create an ephemeral WasmRuntime backed by in-memory storage.
253
- *
254
- * Data is not persisted across page loads. Used as a fallback when OPFS
255
- * is unavailable (e.g. Firefox private browsing mode).
256
- */
257
- static openEphemeral(schema_json: string, app_id: string, env: string, user_branch: string, db_name: string, tier: string | null | undefined, use_binary_encoding: boolean): WasmRuntime;
258
- /**
259
- * Create a persistent WasmRuntime backed by OPFS.
260
- *
261
- * Opens a single OPFS file namespace and restores state from the latest
262
- * durable checkpoint.
263
- */
264
- static openPersistent(schema_json: string, app_id: string, env: string, user_branch: string, db_name: string, tier: string | null | undefined, use_binary_encoding: boolean): Promise<WasmRuntime>;
265
195
  /**
266
196
  * Execute a query and return results as a Promise.
267
197
  *
268
198
  * Optional durability tier controls remote settlement behavior.
269
199
  */
270
200
  query(query_json: string, session_json?: string | null, settled_tier?: string | null, options_json?: string | null): Promise<any>;
271
- reconcileLocalBatchWithServer(batch_id: string): void;
272
201
  /**
273
- * Remove the current upstream server connection.
202
+ * Restore a soft-deleted row by ObjectId.
274
203
  */
275
- removeServer(): void;
276
- replayBatchRejection(batch_id: string, code: string, reason: string): void;
277
- replayLocalBatchPayloads(batch_id: string): Array<any>;
278
- retransmitLocalBatch(batch_id: string): void;
279
- sealBatch(batch_id: string): void;
280
- /**
281
- * Set a client's role.
282
- *
283
- * # Arguments
284
- * * `client_id` - UUID string of the client
285
- * * `role` - One of "user", "admin", "peer"
286
- */
287
- setClientRole(client_id: string, role: string): void;
288
- /**
289
- * Subscribe to a query with a callback.
290
- *
291
- * Default behavior matches RuntimeCore:
292
- * - with upstream server: first callback waits for protocol QuerySettled convergence
293
- * - without upstream server: first callback is local-immediate
294
- *
295
- * Pass durability options to override this default.
296
- *
297
- * # Returns
298
- * Subscription handle (f64) for later unsubscription.
299
- */
300
- subscribe(query_json: string, on_update: Function, session_json?: string | null, settled_tier?: string | null, options_json?: string | null): number;
204
+ restore(table: string, object_id: string, values: any, write_context_json?: string | null): any;
205
+ rollbackBatch(batch_id: string): boolean;
301
206
  /**
302
207
  * Unsubscribe from a query.
303
208
  */
@@ -305,20 +210,15 @@ export class WasmRuntime {
305
210
  /**
306
211
  * Update a row by ObjectId.
307
212
  */
308
- update(object_id: string, values: any): any;
213
+ update(object_id: string, values: any, write_context_json?: string | null): any;
309
214
  /**
310
215
  * Push updated auth credentials into the live transport.
311
216
  */
312
217
  updateAuth(auth_json: string): void;
313
218
  /**
314
- * Update a row by ObjectId as an explicit session principal.
315
- *
316
- * # Arguments
317
- * * `object_id` - UUID string of target object
318
- * * `values` - Partial update map (`{ columnName: Value }`)
319
- * * `session_json` - Optional JSON-encoded Session used for policy checks
219
+ * Create or update a row using a caller-supplied ObjectId.
320
220
  */
321
- updateWithSession(object_id: string, values: any, write_context_json?: string | null): any;
221
+ upsert(table: string, object_id: string, values: any, write_context_json?: string | null): any;
322
222
  /**
323
223
  * Wait for a batch to settle at the requested durability tier.
324
224
  */
@@ -329,7 +229,6 @@ export class WasmWorkerBridge {
329
229
  private constructor();
330
230
  free(): void;
331
231
  [Symbol.dispose](): void;
332
- acknowledgeRejectedBatch(batch_id: string): void;
333
232
  applyIncomingServerPayload(payload: Uint8Array): void;
334
233
  /**
335
234
  * Attach a Rust bridge to an externally-constructed Worker.
@@ -377,13 +276,6 @@ export class WasmWorkerBridge {
377
276
  */
378
277
  simulateCrash(): Promise<any>;
379
278
  updateAuth(jwt_token?: string | null): void;
380
- /**
381
- * Mirror of the TS-side `waitForLocalSyncFlush(batchId?)` from main: drive
382
- * the main runtime's outbox to the worker, await a `SyncAck`, optionally
383
- * retry while the batch is still reconciling. Returns once the worker
384
- * confirms reconciliation, the 2s budget expires, or any ack times out.
385
- */
386
- waitForLocalSyncFlush(batch_id?: string | null): Promise<any>;
387
279
  waitForUpstreamServerConnection(): Promise<void>;
388
280
  }
389
281
 
@@ -488,64 +380,65 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
488
380
 
489
381
  export interface InitOutput {
490
382
  readonly memory: WebAssembly.Memory;
383
+ readonly runAsWorker: (a: any, b: any) => [number, number];
384
+ readonly __wbg_wasmquerybuilder_free: (a: number, b: number) => void;
385
+ readonly wasmquerybuilder_alias: (a: number, b: number, c: number) => number;
386
+ readonly wasmquerybuilder_branch: (a: number, b: number, c: number) => number;
387
+ readonly wasmquerybuilder_branches: (a: number, b: number, c: number) => number;
388
+ readonly wasmquerybuilder_build: (a: number) => [number, number, number, number];
389
+ readonly wasmquerybuilder_buildJs: (a: number) => [number, number, number];
390
+ readonly wasmquerybuilder_filterEq: (a: number, b: number, c: number, d: any) => [number, number, number];
391
+ readonly wasmquerybuilder_filterGe: (a: number, b: number, c: number, d: any) => [number, number, number];
392
+ readonly wasmquerybuilder_filterGt: (a: number, b: number, c: number, d: any) => [number, number, number];
393
+ readonly wasmquerybuilder_filterLe: (a: number, b: number, c: number, d: any) => [number, number, number];
394
+ readonly wasmquerybuilder_filterLt: (a: number, b: number, c: number, d: any) => [number, number, number];
395
+ readonly wasmquerybuilder_filterNe: (a: number, b: number, c: number, d: any) => [number, number, number];
396
+ readonly wasmquerybuilder_includeDeleted: (a: number) => number;
397
+ readonly wasmquerybuilder_join: (a: number, b: number, c: number) => number;
398
+ readonly wasmquerybuilder_limit: (a: number, b: number) => number;
399
+ readonly wasmquerybuilder_new: (a: number, b: number) => number;
400
+ readonly wasmquerybuilder_offset: (a: number, b: number) => number;
401
+ readonly wasmquerybuilder_on: (a: number, b: number, c: number, d: number, e: number) => number;
402
+ readonly wasmquerybuilder_or: (a: number) => number;
403
+ readonly wasmquerybuilder_orderBy: (a: number, b: number, c: number) => number;
404
+ readonly wasmquerybuilder_orderByDesc: (a: number, b: number, c: number) => number;
405
+ readonly wasmquerybuilder_select: (a: number, b: number, c: number) => number;
406
+ readonly decodeMainToWorkerJs: (a: any) => [number, number, number];
407
+ readonly decodeWorkerToMainJs: (a: any) => [number, number, number];
408
+ readonly encodeMainToWorkerJs: (a: any) => [number, number, number];
409
+ readonly encodeWorkerToMainJs: (a: any) => [number, number, number];
491
410
  readonly currentTimestamp: () => bigint;
492
411
  readonly generateId: () => [number, number];
493
412
  readonly parseSchema: (a: number, b: number) => [number, number, number];
494
- readonly runAsWorker: (a: any, b: any) => [number, number];
495
413
  readonly init: () => void;
496
414
  readonly __wbg_wasmruntime_free: (a: number, b: number) => void;
497
415
  readonly __wbg_wasmworkerbridge_free: (a: number, b: number) => void;
498
416
  readonly setTraceEntryCollectionEnabled: (a: number) => void;
499
417
  readonly wasmruntime___debugSchemaState: (a: number) => [number, number, number];
500
- readonly wasmruntime___debugSeedLiveSchema: (a: number, b: number, c: number) => [number, number];
501
- readonly wasmruntime_acknowledgeRejectedBatch: (a: number, b: number, c: number) => [number, number, number];
502
- readonly wasmruntime_addClient: (a: number) => [number, number];
503
- readonly wasmruntime_addServer: (a: number, b: number, c: number, d: number, e: number) => [number, number];
504
- readonly wasmruntime_batchedTick: (a: number) => void;
418
+ readonly wasmruntime_beginBatch: (a: number, b: number, c: number) => [number, number, number, number];
419
+ readonly wasmruntime_commitBatch: (a: number, b: number, c: number) => [number, number];
505
420
  readonly wasmruntime_connect: (a: number, b: number, c: number, d: number, e: number) => [number, number];
506
421
  readonly wasmruntime_createSubscription: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
507
422
  readonly wasmruntime_createWorkerBridge: (a: number, b: any, c: any) => [number, number, number];
508
- readonly wasmruntime_delete: (a: number, b: number, c: number) => [number, number, number];
509
- readonly wasmruntime_deleteWithSession: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
423
+ readonly wasmruntime_delete: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
510
424
  readonly wasmruntime_deriveUserId: (a: number, b: number) => [number, number, number, number];
511
- readonly wasmruntime_discardLocalBatch: (a: number, b: number, c: number) => [number, number, number];
512
425
  readonly wasmruntime_disconnect: (a: number) => void;
513
426
  readonly wasmruntime_executeSubscription: (a: number, b: number, c: any) => [number, number];
514
- readonly wasmruntime_flush: (a: number) => void;
515
- readonly wasmruntime_flushWal: (a: number) => void;
516
- readonly wasmruntime_getPublicKeyBase64url: (a: number, b: number) => [number, number, number, number];
517
427
  readonly wasmruntime_getSchema: (a: number) => [number, number, number];
518
428
  readonly wasmruntime_getSchemaHash: (a: number) => [number, number];
519
- readonly wasmruntime_hydrateLocalBatchRecordStorageRow: (a: number, b: any) => [number, number];
520
- readonly wasmruntime_insert: (a: number, b: number, c: number, d: any, e: number, f: number) => [number, number, number];
521
- readonly wasmruntime_insertWithSession: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number) => [number, number, number];
522
- readonly wasmruntime_loadBatchFate: (a: number, b: number, c: number) => [number, number, number];
523
- readonly wasmruntime_loadLocalBatchRecord: (a: number, b: number, c: number) => [number, number, number];
524
- readonly wasmruntime_loadLocalBatchRecordStorageRow: (a: number, b: number, c: number) => [number, number, number];
525
- readonly wasmruntime_loadLocalBatchRecords: (a: number) => [number, number, number];
429
+ readonly wasmruntime_insert: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number) => [number, number, number];
526
430
  readonly wasmruntime_mintJazzSelfSignedToken: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: bigint) => [number, number, number, number];
527
- readonly wasmruntime_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number];
431
+ readonly wasmruntime_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number];
528
432
  readonly wasmruntime_onAuthFailure: (a: number, b: any) => void;
529
433
  readonly wasmruntime_onMutationError: (a: number, b: any) => void;
530
- readonly wasmruntime_onSyncMessageReceived: (a: number, b: any, c: number, d: number) => [number, number];
531
- readonly wasmruntime_onSyncMessageReceivedFromClient: (a: number, b: number, c: number, d: any) => [number, number];
532
- readonly wasmruntime_openEphemeral: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number, number];
533
- readonly wasmruntime_openPersistent: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => any;
534
434
  readonly wasmruntime_query: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
535
- readonly wasmruntime_reconcileLocalBatchWithServer: (a: number, b: number, c: number) => [number, number];
536
- readonly wasmruntime_removeServer: (a: number) => void;
537
- readonly wasmruntime_replayBatchRejection: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
538
- readonly wasmruntime_replayLocalBatchPayloads: (a: number, b: number, c: number) => [number, number, number];
539
- readonly wasmruntime_retransmitLocalBatch: (a: number, b: number, c: number) => [number, number];
540
- readonly wasmruntime_sealBatch: (a: number, b: number, c: number) => [number, number];
541
- readonly wasmruntime_setClientRole: (a: number, b: number, c: number, d: number, e: number) => [number, number];
542
- readonly wasmruntime_subscribe: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number];
435
+ readonly wasmruntime_restore: (a: number, b: number, c: number, d: number, e: number, f: any, g: number, h: number) => [number, number, number];
436
+ readonly wasmruntime_rollbackBatch: (a: number, b: number, c: number) => [number, number, number];
543
437
  readonly wasmruntime_unsubscribe: (a: number, b: number) => void;
544
- readonly wasmruntime_update: (a: number, b: number, c: number, d: any) => [number, number, number];
438
+ readonly wasmruntime_update: (a: number, b: number, c: number, d: any, e: number, f: number) => [number, number, number];
545
439
  readonly wasmruntime_updateAuth: (a: number, b: number, c: number) => [number, number];
546
- readonly wasmruntime_updateWithSession: (a: number, b: number, c: number, d: any, e: number, f: number) => [number, number, number];
440
+ readonly wasmruntime_upsert: (a: number, b: number, c: number, d: number, e: number, f: any, g: number, h: number) => [number, number, number];
547
441
  readonly wasmruntime_waitForBatch: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
548
- readonly wasmworkerbridge_acknowledgeRejectedBatch: (a: number, b: number, c: number) => void;
549
442
  readonly wasmworkerbridge_applyIncomingServerPayload: (a: number, b: any) => [number, number];
550
443
  readonly wasmworkerbridge_attach: (a: any, b: number, c: any) => [number, number, number];
551
444
  readonly wasmworkerbridge_closePeer: (a: number, b: number, c: number) => void;
@@ -562,36 +455,9 @@ export interface InitOutput {
562
455
  readonly wasmworkerbridge_shutdown: (a: number) => any;
563
456
  readonly wasmworkerbridge_simulateCrash: (a: number) => any;
564
457
  readonly wasmworkerbridge_updateAuth: (a: number, b: number, c: number) => void;
565
- readonly wasmworkerbridge_waitForLocalSyncFlush: (a: number, b: number, c: number) => any;
566
458
  readonly wasmworkerbridge_waitForUpstreamServerConnection: (a: number) => any;
567
459
  readonly drainTraceEntries: () => any;
568
460
  readonly subscribeTraceEntries: (a: any) => any;
569
- readonly decodeMainToWorkerJs: (a: any) => [number, number, number];
570
- readonly decodeWorkerToMainJs: (a: any) => [number, number, number];
571
- readonly encodeMainToWorkerJs: (a: any) => [number, number, number];
572
- readonly encodeWorkerToMainJs: (a: any) => [number, number, number];
573
- readonly __wbg_wasmquerybuilder_free: (a: number, b: number) => void;
574
- readonly wasmquerybuilder_alias: (a: number, b: number, c: number) => number;
575
- readonly wasmquerybuilder_branch: (a: number, b: number, c: number) => number;
576
- readonly wasmquerybuilder_branches: (a: number, b: number, c: number) => number;
577
- readonly wasmquerybuilder_build: (a: number) => [number, number, number, number];
578
- readonly wasmquerybuilder_buildJs: (a: number) => [number, number, number];
579
- readonly wasmquerybuilder_filterEq: (a: number, b: number, c: number, d: any) => [number, number, number];
580
- readonly wasmquerybuilder_filterGe: (a: number, b: number, c: number, d: any) => [number, number, number];
581
- readonly wasmquerybuilder_filterGt: (a: number, b: number, c: number, d: any) => [number, number, number];
582
- readonly wasmquerybuilder_filterLe: (a: number, b: number, c: number, d: any) => [number, number, number];
583
- readonly wasmquerybuilder_filterLt: (a: number, b: number, c: number, d: any) => [number, number, number];
584
- readonly wasmquerybuilder_filterNe: (a: number, b: number, c: number, d: any) => [number, number, number];
585
- readonly wasmquerybuilder_includeDeleted: (a: number) => number;
586
- readonly wasmquerybuilder_join: (a: number, b: number, c: number) => number;
587
- readonly wasmquerybuilder_limit: (a: number, b: number) => number;
588
- readonly wasmquerybuilder_new: (a: number, b: number) => number;
589
- readonly wasmquerybuilder_offset: (a: number, b: number) => number;
590
- readonly wasmquerybuilder_on: (a: number, b: number, c: number, d: number, e: number) => number;
591
- readonly wasmquerybuilder_or: (a: number) => number;
592
- readonly wasmquerybuilder_orderBy: (a: number, b: number, c: number) => number;
593
- readonly wasmquerybuilder_orderByDesc: (a: number, b: number, c: number) => number;
594
- readonly wasmquerybuilder_select: (a: number, b: number, c: number) => number;
595
461
  readonly bench_get_pin_internal_pages: () => number;
596
462
  readonly bench_opfs_cold_random_read: (a: number, b: number) => any;
597
463
  readonly bench_opfs_cold_sequential_read: (a: number, b: number) => any;
package/pkg/jazz_wasm.js CHANGED
@@ -312,13 +312,6 @@ if (Symbol.dispose) WasmQueryBuilder.prototype[Symbol.dispose] = WasmQueryBuilde
312
312
  * Async scheduling happens via WasmScheduler.schedule_batched_tick().
313
313
  */
314
314
  export class WasmRuntime {
315
- static __wrap(ptr) {
316
- ptr = ptr >>> 0;
317
- const obj = Object.create(WasmRuntime.prototype);
318
- obj.__wbg_ptr = ptr;
319
- WasmRuntimeFinalization.register(obj, obj.__wbg_ptr, obj);
320
- return obj;
321
- }
322
315
  __destroy_into_raw() {
323
316
  const ptr = this.__wbg_ptr;
324
317
  this.__wbg_ptr = 0;
@@ -341,69 +334,40 @@ export class WasmRuntime {
341
334
  return takeFromExternrefTable0(ret[0]);
342
335
  }
343
336
  /**
344
- * Debug helper: seed a historical schema and persist schema/lens catalogue objects.
345
- * @param {string} schema_json
346
- */
347
- __debugSeedLiveSchema(schema_json) {
348
- const ptr0 = passStringToWasm0(schema_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
349
- const len0 = WASM_VECTOR_LEN;
350
- const ret = wasm.wasmruntime___debugSeedLiveSchema(this.__wbg_ptr, ptr0, len0);
351
- if (ret[1]) {
352
- throw takeFromExternrefTable0(ret[0]);
353
- }
354
- }
355
- /**
356
- * @param {string} batch_id
357
- * @returns {boolean}
358
- */
359
- acknowledgeRejectedBatch(batch_id) {
360
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
361
- const len0 = WASM_VECTOR_LEN;
362
- const ret = wasm.wasmruntime_acknowledgeRejectedBatch(this.__wbg_ptr, ptr0, len0);
363
- if (ret[2]) {
364
- throw takeFromExternrefTable0(ret[1]);
365
- }
366
- return ret[0] !== 0;
367
- }
368
- /**
369
- * Add a client connection (for server-side use in tests).
337
+ * @param {string} batch_mode
370
338
  * @returns {string}
371
339
  */
372
- addClient() {
373
- let deferred1_0;
374
- let deferred1_1;
340
+ beginBatch(batch_mode) {
341
+ let deferred3_0;
342
+ let deferred3_1;
375
343
  try {
376
- const ret = wasm.wasmruntime_addClient(this.__wbg_ptr);
377
- deferred1_0 = ret[0];
378
- deferred1_1 = ret[1];
379
- return getStringFromWasm0(ret[0], ret[1]);
344
+ const ptr0 = passStringToWasm0(batch_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
345
+ const len0 = WASM_VECTOR_LEN;
346
+ const ret = wasm.wasmruntime_beginBatch(this.__wbg_ptr, ptr0, len0);
347
+ var ptr2 = ret[0];
348
+ var len2 = ret[1];
349
+ if (ret[3]) {
350
+ ptr2 = 0; len2 = 0;
351
+ throw takeFromExternrefTable0(ret[2]);
352
+ }
353
+ deferred3_0 = ptr2;
354
+ deferred3_1 = len2;
355
+ return getStringFromWasm0(ptr2, len2);
380
356
  } finally {
381
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
357
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
382
358
  }
383
359
  }
384
360
  /**
385
- * Add a server connection.
386
- *
387
- * After adding the server, immediately flushes the outbox so that
388
- * catalogue sync messages (from queue_full_sync_to_server) are sent
389
- * before the call returns, rather than being deferred to a microtask.
390
- * @param {string | null} [server_catalogue_state_hash]
391
- * @param {number | null} [next_sync_seq]
361
+ * @param {string} batch_id
392
362
  */
393
- addServer(server_catalogue_state_hash, next_sync_seq) {
394
- var ptr0 = isLikeNone(server_catalogue_state_hash) ? 0 : passStringToWasm0(server_catalogue_state_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
395
- var len0 = WASM_VECTOR_LEN;
396
- const ret = wasm.wasmruntime_addServer(this.__wbg_ptr, ptr0, len0, !isLikeNone(next_sync_seq), isLikeNone(next_sync_seq) ? 0 : next_sync_seq);
363
+ commitBatch(batch_id) {
364
+ const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
365
+ const len0 = WASM_VECTOR_LEN;
366
+ const ret = wasm.wasmruntime_commitBatch(this.__wbg_ptr, ptr0, len0);
397
367
  if (ret[1]) {
398
368
  throw takeFromExternrefTable0(ret[0]);
399
369
  }
400
370
  }
401
- /**
402
- * Drive the runtime's batched receive/apply/send loop immediately.
403
- */
404
- batchedTick() {
405
- wasm.wasmruntime_batchedTick(this.__wbg_ptr);
406
- }
407
371
  /**
408
372
  * Connect to a Jazz server over WebSocket.
409
373
  *
@@ -468,29 +432,15 @@ export class WasmRuntime {
468
432
  /**
469
433
  * Delete a row by ObjectId.
470
434
  * @param {string} object_id
471
- * @returns {any}
472
- */
473
- delete(object_id) {
474
- const ptr0 = passStringToWasm0(object_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
475
- const len0 = WASM_VECTOR_LEN;
476
- const ret = wasm.wasmruntime_delete(this.__wbg_ptr, ptr0, len0);
477
- if (ret[2]) {
478
- throw takeFromExternrefTable0(ret[1]);
479
- }
480
- return takeFromExternrefTable0(ret[0]);
481
- }
482
- /**
483
- * Delete a row by ObjectId as an explicit session principal.
484
- * @param {string} object_id
485
435
  * @param {string | null} [write_context_json]
486
436
  * @returns {any}
487
437
  */
488
- deleteWithSession(object_id, write_context_json) {
438
+ delete(object_id, write_context_json) {
489
439
  const ptr0 = passStringToWasm0(object_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
490
440
  const len0 = WASM_VECTOR_LEN;
491
441
  var ptr1 = isLikeNone(write_context_json) ? 0 : passStringToWasm0(write_context_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
492
442
  var len1 = WASM_VECTOR_LEN;
493
- const ret = wasm.wasmruntime_deleteWithSession(this.__wbg_ptr, ptr0, len0, ptr1, len1);
443
+ const ret = wasm.wasmruntime_delete(this.__wbg_ptr, ptr0, len0, ptr1, len1);
494
444
  if (ret[2]) {
495
445
  throw takeFromExternrefTable0(ret[1]);
496
446
  }
@@ -520,19 +470,6 @@ export class WasmRuntime {
520
470
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
521
471
  }
522
472
  }
523
- /**
524
- * @param {string} batch_id
525
- * @returns {boolean}
526
- */
527
- discardLocalBatch(batch_id) {
528
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
529
- const len0 = WASM_VECTOR_LEN;
530
- const ret = wasm.wasmruntime_discardLocalBatch(this.__wbg_ptr, ptr0, len0);
531
- if (ret[2]) {
532
- throw takeFromExternrefTable0(ret[1]);
533
- }
534
- return ret[0] !== 0;
535
- }
536
473
  /**
537
474
  * Disconnect from the Jazz server and drop the transport handle.
538
475
  */
@@ -553,42 +490,6 @@ export class WasmRuntime {
553
490
  throw takeFromExternrefTable0(ret[0]);
554
491
  }
555
492
  }
556
- /**
557
- * Flush all data to persistent storage (snapshot).
558
- */
559
- flush() {
560
- wasm.wasmruntime_flush(this.__wbg_ptr);
561
- }
562
- /**
563
- * Flush only the WAL buffer to OPFS (not the snapshot).
564
- */
565
- flushWal() {
566
- wasm.wasmruntime_flushWal(this.__wbg_ptr);
567
- }
568
- /**
569
- * @param {string} seed_b64
570
- * @returns {string}
571
- */
572
- static getPublicKeyBase64url(seed_b64) {
573
- let deferred3_0;
574
- let deferred3_1;
575
- try {
576
- const ptr0 = passStringToWasm0(seed_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
577
- const len0 = WASM_VECTOR_LEN;
578
- const ret = wasm.wasmruntime_getPublicKeyBase64url(ptr0, len0);
579
- var ptr2 = ret[0];
580
- var len2 = ret[1];
581
- if (ret[3]) {
582
- ptr2 = 0; len2 = 0;
583
- throw takeFromExternrefTable0(ret[2]);
584
- }
585
- deferred3_0 = ptr2;
586
- deferred3_1 = len2;
587
- return getStringFromWasm0(ptr2, len2);
588
- } finally {
589
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
590
- }
591
- }
592
493
  /**
593
494
  * Get the current schema as JSON.
594
495
  * @returns {any}
@@ -616,15 +517,6 @@ export class WasmRuntime {
616
517
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
617
518
  }
618
519
  }
619
- /**
620
- * @param {Uint8Array} bytes
621
- */
622
- hydrateLocalBatchRecordStorageRow(bytes) {
623
- const ret = wasm.wasmruntime_hydrateLocalBatchRecordStorageRow(this.__wbg_ptr, bytes);
624
- if (ret[1]) {
625
- throw takeFromExternrefTable0(ret[0]);
626
- }
627
- }
628
520
  /**
629
521
  * Insert a row into a table.
630
522
  *
@@ -632,85 +524,18 @@ export class WasmRuntime {
632
524
  * The inserted row as `{ id, values, batchId }`.
633
525
  * @param {string} table
634
526
  * @param {any} values
635
- * @param {string | null} [object_id]
636
- * @returns {any}
637
- */
638
- insert(table, values, object_id) {
639
- const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
640
- const len0 = WASM_VECTOR_LEN;
641
- var ptr1 = isLikeNone(object_id) ? 0 : passStringToWasm0(object_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
642
- var len1 = WASM_VECTOR_LEN;
643
- const ret = wasm.wasmruntime_insert(this.__wbg_ptr, ptr0, len0, values, ptr1, len1);
644
- if (ret[2]) {
645
- throw takeFromExternrefTable0(ret[1]);
646
- }
647
- return takeFromExternrefTable0(ret[0]);
648
- }
649
- /**
650
- * Insert a row into a table as an explicit session principal.
651
- * @param {string} table
652
- * @param {any} values
653
527
  * @param {string | null} [write_context_json]
654
528
  * @param {string | null} [object_id]
655
529
  * @returns {any}
656
530
  */
657
- insertWithSession(table, values, write_context_json, object_id) {
531
+ insert(table, values, write_context_json, object_id) {
658
532
  const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
659
533
  const len0 = WASM_VECTOR_LEN;
660
534
  var ptr1 = isLikeNone(write_context_json) ? 0 : passStringToWasm0(write_context_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
661
535
  var len1 = WASM_VECTOR_LEN;
662
536
  var ptr2 = isLikeNone(object_id) ? 0 : passStringToWasm0(object_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
663
537
  var len2 = WASM_VECTOR_LEN;
664
- const ret = wasm.wasmruntime_insertWithSession(this.__wbg_ptr, ptr0, len0, values, ptr1, len1, ptr2, len2);
665
- if (ret[2]) {
666
- throw takeFromExternrefTable0(ret[1]);
667
- }
668
- return takeFromExternrefTable0(ret[0]);
669
- }
670
- /**
671
- * @param {string} batch_id
672
- * @returns {any}
673
- */
674
- loadBatchFate(batch_id) {
675
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
676
- const len0 = WASM_VECTOR_LEN;
677
- const ret = wasm.wasmruntime_loadBatchFate(this.__wbg_ptr, ptr0, len0);
678
- if (ret[2]) {
679
- throw takeFromExternrefTable0(ret[1]);
680
- }
681
- return takeFromExternrefTable0(ret[0]);
682
- }
683
- /**
684
- * @param {string} batch_id
685
- * @returns {any}
686
- */
687
- loadLocalBatchRecord(batch_id) {
688
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
689
- const len0 = WASM_VECTOR_LEN;
690
- const ret = wasm.wasmruntime_loadLocalBatchRecord(this.__wbg_ptr, ptr0, len0);
691
- if (ret[2]) {
692
- throw takeFromExternrefTable0(ret[1]);
693
- }
694
- return takeFromExternrefTable0(ret[0]);
695
- }
696
- /**
697
- * @param {string} batch_id
698
- * @returns {any}
699
- */
700
- loadLocalBatchRecordStorageRow(batch_id) {
701
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
702
- const len0 = WASM_VECTOR_LEN;
703
- const ret = wasm.wasmruntime_loadLocalBatchRecordStorageRow(this.__wbg_ptr, ptr0, len0);
704
- if (ret[2]) {
705
- throw takeFromExternrefTable0(ret[1]);
706
- }
707
- return takeFromExternrefTable0(ret[0]);
708
- }
709
- /**
710
- * @returns {any}
711
- */
712
- loadLocalBatchRecords() {
713
- const ret = wasm.wasmruntime_loadLocalBatchRecords(this.__wbg_ptr);
538
+ const ret = wasm.wasmruntime_insert(this.__wbg_ptr, ptr0, len0, values, ptr1, len1, ptr2, len2);
714
539
  if (ret[2]) {
715
540
  throw takeFromExternrefTable0(ret[1]);
716
541
  }
@@ -762,14 +587,17 @@ export class WasmRuntime {
762
587
  * Set for server nodes to enable ack emission.
763
588
  * * `use_binary_encoding` - Optional outgoing sync payload encoding mode.
764
589
  * `Some(true)` emits postcard bytes (`Uint8Array`), otherwise JSON strings.
590
+ * * `non_durable_client` - Internal browser main-thread mode. When true,
591
+ * direct writes stay optimistic until a durable peer syncs `BatchFate`.
765
592
  * @param {string} schema_json
766
593
  * @param {string} app_id
767
594
  * @param {string} env
768
595
  * @param {string} user_branch
769
596
  * @param {string | null} [tier]
770
597
  * @param {boolean | null} [use_binary_encoding]
598
+ * @param {boolean | null} [non_durable_client]
771
599
  */
772
- constructor(schema_json, app_id, env, user_branch, tier, use_binary_encoding) {
600
+ constructor(schema_json, app_id, env, user_branch, tier, use_binary_encoding, non_durable_client) {
773
601
  const ptr0 = passStringToWasm0(schema_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
774
602
  const len0 = WASM_VECTOR_LEN;
775
603
  const ptr1 = passStringToWasm0(app_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -780,7 +608,7 @@ export class WasmRuntime {
780
608
  const len3 = WASM_VECTOR_LEN;
781
609
  var ptr4 = isLikeNone(tier) ? 0 : passStringToWasm0(tier, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
782
610
  var len4 = WASM_VECTOR_LEN;
783
- const ret = wasm.wasmruntime_new(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, isLikeNone(use_binary_encoding) ? 0xFFFFFF : use_binary_encoding ? 1 : 0);
611
+ const ret = wasm.wasmruntime_new(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, isLikeNone(use_binary_encoding) ? 0xFFFFFF : use_binary_encoding ? 1 : 0, isLikeNone(non_durable_client) ? 0xFFFFFF : non_durable_client ? 1 : 0);
784
612
  if (ret[2]) {
785
613
  throw takeFromExternrefTable0(ret[1]);
786
614
  }
@@ -805,101 +633,6 @@ export class WasmRuntime {
805
633
  onMutationError(callback) {
806
634
  wasm.wasmruntime_onMutationError(this.__wbg_ptr, callback);
807
635
  }
808
- /**
809
- * Called by JS when a sync message arrives from the server.
810
- *
811
- * # Arguments
812
- * * `payload` - Either postcard-encoded SyncPayload bytes (`Uint8Array`)
813
- * or JSON-encoded SyncPayload (`string`)
814
- * @param {any} payload
815
- * @param {number | null} [sequence]
816
- */
817
- onSyncMessageReceived(payload, sequence) {
818
- const ret = wasm.wasmruntime_onSyncMessageReceived(this.__wbg_ptr, payload, !isLikeNone(sequence), isLikeNone(sequence) ? 0 : sequence);
819
- if (ret[1]) {
820
- throw takeFromExternrefTable0(ret[0]);
821
- }
822
- }
823
- /**
824
- * Called by JS when a sync message arrives from a client (not a server).
825
- *
826
- * # Arguments
827
- * * `client_id` - UUID string of the sending client
828
- * * `payload` - Postcard-encoded SyncPayload bytes
829
- * @param {string} client_id
830
- * @param {any} payload
831
- */
832
- onSyncMessageReceivedFromClient(client_id, payload) {
833
- const ptr0 = passStringToWasm0(client_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
834
- const len0 = WASM_VECTOR_LEN;
835
- const ret = wasm.wasmruntime_onSyncMessageReceivedFromClient(this.__wbg_ptr, ptr0, len0, payload);
836
- if (ret[1]) {
837
- throw takeFromExternrefTable0(ret[0]);
838
- }
839
- }
840
- /**
841
- * Create an ephemeral WasmRuntime backed by in-memory storage.
842
- *
843
- * Data is not persisted across page loads. Used as a fallback when OPFS
844
- * is unavailable (e.g. Firefox private browsing mode).
845
- * @param {string} schema_json
846
- * @param {string} app_id
847
- * @param {string} env
848
- * @param {string} user_branch
849
- * @param {string} db_name
850
- * @param {string | null | undefined} tier
851
- * @param {boolean} use_binary_encoding
852
- * @returns {WasmRuntime}
853
- */
854
- static openEphemeral(schema_json, app_id, env, user_branch, db_name, tier, use_binary_encoding) {
855
- const ptr0 = passStringToWasm0(schema_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
856
- const len0 = WASM_VECTOR_LEN;
857
- const ptr1 = passStringToWasm0(app_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
858
- const len1 = WASM_VECTOR_LEN;
859
- const ptr2 = passStringToWasm0(env, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
860
- const len2 = WASM_VECTOR_LEN;
861
- const ptr3 = passStringToWasm0(user_branch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
862
- const len3 = WASM_VECTOR_LEN;
863
- const ptr4 = passStringToWasm0(db_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
864
- const len4 = WASM_VECTOR_LEN;
865
- var ptr5 = isLikeNone(tier) ? 0 : passStringToWasm0(tier, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
866
- var len5 = WASM_VECTOR_LEN;
867
- const ret = wasm.wasmruntime_openEphemeral(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, use_binary_encoding);
868
- if (ret[2]) {
869
- throw takeFromExternrefTable0(ret[1]);
870
- }
871
- return WasmRuntime.__wrap(ret[0]);
872
- }
873
- /**
874
- * Create a persistent WasmRuntime backed by OPFS.
875
- *
876
- * Opens a single OPFS file namespace and restores state from the latest
877
- * durable checkpoint.
878
- * @param {string} schema_json
879
- * @param {string} app_id
880
- * @param {string} env
881
- * @param {string} user_branch
882
- * @param {string} db_name
883
- * @param {string | null | undefined} tier
884
- * @param {boolean} use_binary_encoding
885
- * @returns {Promise<WasmRuntime>}
886
- */
887
- static openPersistent(schema_json, app_id, env, user_branch, db_name, tier, use_binary_encoding) {
888
- const ptr0 = passStringToWasm0(schema_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
889
- const len0 = WASM_VECTOR_LEN;
890
- const ptr1 = passStringToWasm0(app_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
891
- const len1 = WASM_VECTOR_LEN;
892
- const ptr2 = passStringToWasm0(env, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
893
- const len2 = WASM_VECTOR_LEN;
894
- const ptr3 = passStringToWasm0(user_branch, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
895
- const len3 = WASM_VECTOR_LEN;
896
- const ptr4 = passStringToWasm0(db_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
897
- const len4 = WASM_VECTOR_LEN;
898
- var ptr5 = isLikeNone(tier) ? 0 : passStringToWasm0(tier, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
899
- var len5 = WASM_VECTOR_LEN;
900
- const ret = wasm.wasmruntime_openPersistent(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, use_binary_encoding);
901
- return ret;
902
- }
903
636
  /**
904
637
  * Execute a query and return results as a Promise.
905
638
  *
@@ -926,47 +659,21 @@ export class WasmRuntime {
926
659
  return takeFromExternrefTable0(ret[0]);
927
660
  }
928
661
  /**
929
- * @param {string} batch_id
930
- */
931
- reconcileLocalBatchWithServer(batch_id) {
932
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
933
- const len0 = WASM_VECTOR_LEN;
934
- const ret = wasm.wasmruntime_reconcileLocalBatchWithServer(this.__wbg_ptr, ptr0, len0);
935
- if (ret[1]) {
936
- throw takeFromExternrefTable0(ret[0]);
937
- }
938
- }
939
- /**
940
- * Remove the current upstream server connection.
941
- */
942
- removeServer() {
943
- wasm.wasmruntime_removeServer(this.__wbg_ptr);
944
- }
945
- /**
946
- * @param {string} batch_id
947
- * @param {string} code
948
- * @param {string} reason
662
+ * Restore a soft-deleted row by ObjectId.
663
+ * @param {string} table
664
+ * @param {string} object_id
665
+ * @param {any} values
666
+ * @param {string | null} [write_context_json]
667
+ * @returns {any}
949
668
  */
950
- replayBatchRejection(batch_id, code, reason) {
951
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
669
+ restore(table, object_id, values, write_context_json) {
670
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
952
671
  const len0 = WASM_VECTOR_LEN;
953
- const ptr1 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
672
+ const ptr1 = passStringToWasm0(object_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
954
673
  const len1 = WASM_VECTOR_LEN;
955
- const ptr2 = passStringToWasm0(reason, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
956
- const len2 = WASM_VECTOR_LEN;
957
- const ret = wasm.wasmruntime_replayBatchRejection(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
958
- if (ret[1]) {
959
- throw takeFromExternrefTable0(ret[0]);
960
- }
961
- }
962
- /**
963
- * @param {string} batch_id
964
- * @returns {Array<any>}
965
- */
966
- replayLocalBatchPayloads(batch_id) {
967
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
968
- const len0 = WASM_VECTOR_LEN;
969
- const ret = wasm.wasmruntime_replayLocalBatchPayloads(this.__wbg_ptr, ptr0, len0);
674
+ var ptr2 = isLikeNone(write_context_json) ? 0 : passStringToWasm0(write_context_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
675
+ var len2 = WASM_VECTOR_LEN;
676
+ const ret = wasm.wasmruntime_restore(this.__wbg_ptr, ptr0, len0, ptr1, len1, values, ptr2, len2);
970
677
  if (ret[2]) {
971
678
  throw takeFromExternrefTable0(ret[1]);
972
679
  }
@@ -974,77 +681,16 @@ export class WasmRuntime {
974
681
  }
975
682
  /**
976
683
  * @param {string} batch_id
684
+ * @returns {boolean}
977
685
  */
978
- retransmitLocalBatch(batch_id) {
979
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
980
- const len0 = WASM_VECTOR_LEN;
981
- const ret = wasm.wasmruntime_retransmitLocalBatch(this.__wbg_ptr, ptr0, len0);
982
- if (ret[1]) {
983
- throw takeFromExternrefTable0(ret[0]);
984
- }
985
- }
986
- /**
987
- * @param {string} batch_id
988
- */
989
- sealBatch(batch_id) {
686
+ rollbackBatch(batch_id) {
990
687
  const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
991
688
  const len0 = WASM_VECTOR_LEN;
992
- const ret = wasm.wasmruntime_sealBatch(this.__wbg_ptr, ptr0, len0);
993
- if (ret[1]) {
994
- throw takeFromExternrefTable0(ret[0]);
995
- }
996
- }
997
- /**
998
- * Set a client's role.
999
- *
1000
- * # Arguments
1001
- * * `client_id` - UUID string of the client
1002
- * * `role` - One of "user", "admin", "peer"
1003
- * @param {string} client_id
1004
- * @param {string} role
1005
- */
1006
- setClientRole(client_id, role) {
1007
- const ptr0 = passStringToWasm0(client_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1008
- const len0 = WASM_VECTOR_LEN;
1009
- const ptr1 = passStringToWasm0(role, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1010
- const len1 = WASM_VECTOR_LEN;
1011
- const ret = wasm.wasmruntime_setClientRole(this.__wbg_ptr, ptr0, len0, ptr1, len1);
1012
- if (ret[1]) {
1013
- throw takeFromExternrefTable0(ret[0]);
1014
- }
1015
- }
1016
- /**
1017
- * Subscribe to a query with a callback.
1018
- *
1019
- * Default behavior matches RuntimeCore:
1020
- * - with upstream server: first callback waits for protocol QuerySettled convergence
1021
- * - without upstream server: first callback is local-immediate
1022
- *
1023
- * Pass durability options to override this default.
1024
- *
1025
- * # Returns
1026
- * Subscription handle (f64) for later unsubscription.
1027
- * @param {string} query_json
1028
- * @param {Function} on_update
1029
- * @param {string | null} [session_json]
1030
- * @param {string | null} [settled_tier]
1031
- * @param {string | null} [options_json]
1032
- * @returns {number}
1033
- */
1034
- subscribe(query_json, on_update, session_json, settled_tier, options_json) {
1035
- const ptr0 = passStringToWasm0(query_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1036
- const len0 = WASM_VECTOR_LEN;
1037
- var ptr1 = isLikeNone(session_json) ? 0 : passStringToWasm0(session_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1038
- var len1 = WASM_VECTOR_LEN;
1039
- var ptr2 = isLikeNone(settled_tier) ? 0 : passStringToWasm0(settled_tier, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1040
- var len2 = WASM_VECTOR_LEN;
1041
- var ptr3 = isLikeNone(options_json) ? 0 : passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1042
- var len3 = WASM_VECTOR_LEN;
1043
- const ret = wasm.wasmruntime_subscribe(this.__wbg_ptr, ptr0, len0, on_update, ptr1, len1, ptr2, len2, ptr3, len3);
689
+ const ret = wasm.wasmruntime_rollbackBatch(this.__wbg_ptr, ptr0, len0);
1044
690
  if (ret[2]) {
1045
691
  throw takeFromExternrefTable0(ret[1]);
1046
692
  }
1047
- return ret[0];
693
+ return ret[0] !== 0;
1048
694
  }
1049
695
  /**
1050
696
  * Unsubscribe from a query.
@@ -1057,12 +703,15 @@ export class WasmRuntime {
1057
703
  * Update a row by ObjectId.
1058
704
  * @param {string} object_id
1059
705
  * @param {any} values
706
+ * @param {string | null} [write_context_json]
1060
707
  * @returns {any}
1061
708
  */
1062
- update(object_id, values) {
709
+ update(object_id, values, write_context_json) {
1063
710
  const ptr0 = passStringToWasm0(object_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1064
711
  const len0 = WASM_VECTOR_LEN;
1065
- const ret = wasm.wasmruntime_update(this.__wbg_ptr, ptr0, len0, values);
712
+ var ptr1 = isLikeNone(write_context_json) ? 0 : passStringToWasm0(write_context_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
713
+ var len1 = WASM_VECTOR_LEN;
714
+ const ret = wasm.wasmruntime_update(this.__wbg_ptr, ptr0, len0, values, ptr1, len1);
1066
715
  if (ret[2]) {
1067
716
  throw takeFromExternrefTable0(ret[1]);
1068
717
  }
@@ -1081,23 +730,21 @@ export class WasmRuntime {
1081
730
  }
1082
731
  }
1083
732
  /**
1084
- * Update a row by ObjectId as an explicit session principal.
1085
- *
1086
- * # Arguments
1087
- * * `object_id` - UUID string of target object
1088
- * * `values` - Partial update map (`{ columnName: Value }`)
1089
- * * `session_json` - Optional JSON-encoded Session used for policy checks
733
+ * Create or update a row using a caller-supplied ObjectId.
734
+ * @param {string} table
1090
735
  * @param {string} object_id
1091
736
  * @param {any} values
1092
737
  * @param {string | null} [write_context_json]
1093
738
  * @returns {any}
1094
739
  */
1095
- updateWithSession(object_id, values, write_context_json) {
1096
- const ptr0 = passStringToWasm0(object_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
740
+ upsert(table, object_id, values, write_context_json) {
741
+ const ptr0 = passStringToWasm0(table, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1097
742
  const len0 = WASM_VECTOR_LEN;
1098
- var ptr1 = isLikeNone(write_context_json) ? 0 : passStringToWasm0(write_context_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1099
- var len1 = WASM_VECTOR_LEN;
1100
- const ret = wasm.wasmruntime_updateWithSession(this.__wbg_ptr, ptr0, len0, values, ptr1, len1);
743
+ const ptr1 = passStringToWasm0(object_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
744
+ const len1 = WASM_VECTOR_LEN;
745
+ var ptr2 = isLikeNone(write_context_json) ? 0 : passStringToWasm0(write_context_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
746
+ var len2 = WASM_VECTOR_LEN;
747
+ const ret = wasm.wasmruntime_upsert(this.__wbg_ptr, ptr0, len0, ptr1, len1, values, ptr2, len2);
1101
748
  if (ret[2]) {
1102
749
  throw takeFromExternrefTable0(ret[1]);
1103
750
  }
@@ -1141,14 +788,6 @@ export class WasmWorkerBridge {
1141
788
  const ptr = this.__destroy_into_raw();
1142
789
  wasm.__wbg_wasmworkerbridge_free(ptr, 0);
1143
790
  }
1144
- /**
1145
- * @param {string} batch_id
1146
- */
1147
- acknowledgeRejectedBatch(batch_id) {
1148
- const ptr0 = passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1149
- const len0 = WASM_VECTOR_LEN;
1150
- wasm.wasmworkerbridge_acknowledgeRejectedBatch(this.__wbg_ptr, ptr0, len0);
1151
- }
1152
791
  /**
1153
792
  * @param {Uint8Array} payload
1154
793
  */
@@ -1284,20 +923,6 @@ export class WasmWorkerBridge {
1284
923
  var len0 = WASM_VECTOR_LEN;
1285
924
  wasm.wasmworkerbridge_updateAuth(this.__wbg_ptr, ptr0, len0);
1286
925
  }
1287
- /**
1288
- * Mirror of the TS-side `waitForLocalSyncFlush(batchId?)` from main: drive
1289
- * the main runtime's outbox to the worker, await a `SyncAck`, optionally
1290
- * retry while the batch is still reconciling. Returns once the worker
1291
- * confirms reconciliation, the 2s budget expires, or any ack times out.
1292
- * @param {string | null} [batch_id]
1293
- * @returns {Promise<any>}
1294
- */
1295
- waitForLocalSyncFlush(batch_id) {
1296
- var ptr0 = isLikeNone(batch_id) ? 0 : passStringToWasm0(batch_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1297
- var len0 = WASM_VECTOR_LEN;
1298
- const ret = wasm.wasmworkerbridge_waitForLocalSyncFlush(this.__wbg_ptr, ptr0, len0);
1299
- return ret;
1300
- }
1301
926
  /**
1302
927
  * @returns {Promise<void>}
1303
928
  */
@@ -2046,25 +1671,6 @@ function __wbg_get_imports() {
2046
1671
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2047
1672
  }
2048
1673
  },
2049
- __wbg_mark_e4b209bb53de57a7: function(arg0, arg1) {
2050
- performance.mark(getStringFromWasm0(arg0, arg1));
2051
- },
2052
- __wbg_measure_0cab89f3addcdc37: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2053
- let deferred0_0;
2054
- let deferred0_1;
2055
- let deferred1_0;
2056
- let deferred1_1;
2057
- try {
2058
- deferred0_0 = arg0;
2059
- deferred0_1 = arg1;
2060
- deferred1_0 = arg2;
2061
- deferred1_1 = arg3;
2062
- performance.measure(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
2063
- } finally {
2064
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2065
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2066
- }
2067
- }, arguments); },
2068
1674
  __wbg_message_52a9425f28c45ebc: function(arg0, arg1) {
2069
1675
  const ret = arg1.message;
2070
1676
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -2397,46 +2003,42 @@ function __wbg_get_imports() {
2397
2003
  const ret = arg0.wasClean;
2398
2004
  return ret;
2399
2005
  },
2400
- __wbg_wasmruntime_new: function(arg0) {
2401
- const ret = WasmRuntime.__wrap(arg0);
2402
- return ret;
2403
- },
2404
2006
  __wbg_write_726121caffd5fc3e: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2405
2007
  const ret = arg0.write(getArrayU8FromWasm0(arg1, arg2), arg3);
2406
2008
  return ret;
2407
2009
  }, arguments); },
2408
2010
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2409
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3293, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2011
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3372, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2410
2012
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h656199c36535c3e6);
2411
2013
  return ret;
2412
2014
  },
2413
2015
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2414
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 816, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2016
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 610, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2415
2017
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__ha139c643be38e81d);
2416
2018
  return ret;
2417
2019
  },
2418
2020
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
2419
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 818, ret: Externref, inner_ret: Some(Externref) }, mutable: false }) -> Externref`.
2021
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 612, ret: Externref, inner_ret: Some(Externref) }, mutable: false }) -> Externref`.
2420
2022
  const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h74026c82fbbbb92b);
2421
2023
  return ret;
2422
2024
  },
2423
2025
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
2424
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 816, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2026
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 610, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2425
2027
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__ha139c643be38e81d_3);
2426
2028
  return ret;
2427
2029
  },
2428
2030
  __wbindgen_cast_0000000000000005: function(arg0, arg1) {
2429
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 998, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2031
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 987, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2430
2032
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hbc8b7acec5ff03a6);
2431
2033
  return ret;
2432
2034
  },
2433
2035
  __wbindgen_cast_0000000000000006: function(arg0, arg1) {
2434
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1393, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2036
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1470, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2435
2037
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h03757a48b3eba690);
2436
2038
  return ret;
2437
2039
  },
2438
2040
  __wbindgen_cast_0000000000000007: function(arg0, arg1) {
2439
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 975, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2041
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 944, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2440
2042
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hcc3019a61bf91992);
2441
2043
  return ret;
2442
2044
  },
Binary file