jazz-wasm 2.0.0-alpha.3 → 2.0.0-alpha.30

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.3",
3
+ "version": "2.0.0-alpha.30",
4
4
  "description": "WebAssembly bindings for the Jazz database engine",
5
5
  "keywords": [
6
6
  "crdt",
@@ -18,12 +18,14 @@
18
18
  "pkg/jazz_wasm.js",
19
19
  "pkg/jazz_wasm.d.ts"
20
20
  ],
21
+ "type": "module",
21
22
  "main": "pkg/jazz_wasm.js",
22
23
  "types": "pkg/jazz_wasm.d.ts",
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "tag": "alpha"
27
+ },
23
28
  "scripts": {
24
29
  "build": "wasm-pack build --target web --profiling"
25
- },
26
- "devDependencies": {
27
- "wasm-pack": "^0.14.0"
28
30
  }
29
- }
31
+ }
@@ -1,57 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export interface WasmColumnDescriptor {
4
- name: string;
5
- column_type: WasmColumnType;
6
- nullable: boolean;
7
- references?: string;
8
- }
9
-
10
- export interface WasmOperationPolicy {
11
- using?: WasmPolicyExpr;
12
- with_check?: WasmPolicyExpr;
13
- }
14
-
15
- export interface WasmRow {
16
- id: string;
17
- values: WasmValue[];
18
- }
19
-
20
- export interface WasmRowDelta {
21
- added: WasmRow[];
22
- removed: WasmRow[];
23
- updated: [WasmRow, WasmRow][];
24
- pending: boolean;
25
- }
26
-
27
- export interface WasmSchema {
28
- tables: Record<string, WasmTableSchema>;
29
- }
30
-
31
- export interface WasmTablePolicies {
32
- select?: WasmOperationPolicy;
33
- insert?: WasmOperationPolicy;
34
- update?: WasmOperationPolicy;
35
- delete?: WasmOperationPolicy;
36
- }
37
-
38
- export interface WasmTableSchema {
39
- columns: WasmColumnDescriptor[];
40
- policies?: WasmTablePolicies;
41
- }
42
-
43
- export type WasmCmpOp = "Eq" | "Ne" | "Lt" | "Le" | "Gt" | "Ge";
44
-
45
- export type WasmColumnType = { type: "Integer" } | { type: "BigInt" } | { type: "Boolean" } | { type: "Text" } | { type: "Enum"; variants: string[] } | { type: "Timestamp" } | { type: "Uuid" } | { type: "Array"; element: WasmColumnType } | { type: "Row"; columns: WasmColumnDescriptor[] };
46
-
47
- export type WasmPolicyExpr = { type: "Cmp"; column: string; op: WasmCmpOp; value: WasmPolicyValue } | { type: "IsNull"; column: string } | { type: "IsNotNull"; column: string } | { type: "In"; column: string; session_path: string[] } | { type: "Exists"; table: string; condition: WasmPolicyExpr } | { type: "ExistsRel"; rel: any } | { type: "Inherits"; operation: WasmPolicyOperation; via_column: string; max_depth?: number } | { type: "And"; exprs: WasmPolicyExpr[] } | { type: "Or"; exprs: WasmPolicyExpr[] } | { type: "Not"; expr: WasmPolicyExpr } | { type: "True" } | { type: "False" };
48
-
49
- export type WasmPolicyOperation = "Select" | "Insert" | "Update" | "Delete";
50
-
51
- export type WasmPolicyValue = { type: "Literal"; value: WasmValue } | { type: "SessionRef"; path: string[] };
52
-
53
- export type WasmValue = { type: "Integer"; value: number } | { type: "BigInt"; value: number } | { type: "Boolean"; value: boolean } | { type: "Text"; value: string } | { type: "Timestamp"; value: number } | { type: "Uuid"; value: string } | { type: "Array"; value: WasmValue[] } | { type: "Row"; value: WasmValue[] } | { type: "Null" };
54
-
55
3
 
56
4
  /**
57
5
  * WASM-exposed QueryBuilder with camelCase methods.
@@ -155,6 +103,14 @@ export class WasmQueryBuilder {
155
103
  export class WasmRuntime {
156
104
  free(): void;
157
105
  [Symbol.dispose](): void;
106
+ /**
107
+ * Debug helper: expose schema/lens state currently loaded in SchemaManager.
108
+ */
109
+ __debugSchemaState(): any;
110
+ /**
111
+ * Debug helper: seed a historical schema and persist schema/lens catalogue objects.
112
+ */
113
+ __debugSeedLiveSchema(schema_json: string): void;
158
114
  /**
159
115
  * Add a client connection (for server-side use in tests).
160
116
  */
@@ -166,7 +122,19 @@ export class WasmRuntime {
166
122
  * catalogue sync messages (from queue_full_sync_to_server) are sent
167
123
  * before the call returns, rather than being deferred to a microtask.
168
124
  */
169
- addServer(): void;
125
+ addServer(server_catalogue_state_hash?: string | null, next_sync_seq?: number | null): void;
126
+ /**
127
+ * Connect to a Jazz server over WebSocket.
128
+ *
129
+ * Parses `auth_json` into `AuthConfig`, wires a `TransportManager` into
130
+ * `RuntimeCore`, and spawns the manager loop via `spawn_local`.
131
+ */
132
+ connect(url: string, auth_json: string): void;
133
+ /**
134
+ * Phase 1 of 2-phase subscribe: allocate a handle and store query params.
135
+ * No compilation, no sync, no tick — just bookkeeping.
136
+ */
137
+ createSubscription(query_json: string, session_json?: string | null, settled_tier?: string | null, options_json?: string | null): number;
170
138
  /**
171
139
  * Delete a row by ObjectId.
172
140
  */
@@ -174,7 +142,28 @@ export class WasmRuntime {
174
142
  /**
175
143
  * Delete a row and return a Promise that resolves when the tier acks.
176
144
  */
177
- deleteWithAck(object_id: string, tier: string): Promise<any>;
145
+ deleteDurable(object_id: string, tier: string): Promise<any>;
146
+ /**
147
+ * Delete a row and return a Promise that resolves when the tier acks,
148
+ * scoped to an explicit session principal.
149
+ */
150
+ deleteDurableWithSession(object_id: string, write_context_json: string | null | undefined, tier: string): Promise<any>;
151
+ /**
152
+ * Delete a row by ObjectId as an explicit session principal.
153
+ */
154
+ deleteWithSession(object_id: string, write_context_json?: string | null): void;
155
+ static deriveUserId(seed_b64: string): string;
156
+ /**
157
+ * Disconnect from the Jazz server and drop the transport handle.
158
+ */
159
+ disconnect(): void;
160
+ /**
161
+ * Phase 2 of 2-phase subscribe: compile graph, register subscription,
162
+ * sync to servers, attach callback, and deliver the first delta.
163
+ *
164
+ * No-ops silently if the handle was already unsubscribed.
165
+ */
166
+ executeSubscription(handle: number, on_update: Function): void;
178
167
  /**
179
168
  * Flush all data to persistent storage (snapshot).
180
169
  */
@@ -183,6 +172,7 @@ export class WasmRuntime {
183
172
  * Flush only the WAL buffer to OPFS (not the snapshot).
184
173
  */
185
174
  flushWal(): void;
175
+ static getPublicKeyBase64url(seed_b64: string): string;
186
176
  /**
187
177
  * Get the current schema as JSON.
188
178
  */
@@ -195,15 +185,25 @@ export class WasmRuntime {
195
185
  * Insert a row into a table.
196
186
  *
197
187
  * # Returns
198
- * The new row's ObjectId as a UUID string.
188
+ * The inserted row as `{ id, values }`.
199
189
  */
200
- insert(table: string, values: any): string;
190
+ insert(table: string, values: any, object_id?: string | null): any;
201
191
  /**
202
192
  * Insert a row and return a Promise that resolves when the tier acks.
203
193
  *
204
- * `tier` must be one of: "worker", "edge", "core".
194
+ * `tier` must be one of: "worker", "edge", "global".
205
195
  */
206
- insertWithAck(table: string, values: any, tier: string): Promise<any>;
196
+ insertDurable(table: string, values: any, tier: string, object_id?: string | null): Promise<any>;
197
+ /**
198
+ * Insert a row and return a Promise that resolves when the tier acks,
199
+ * scoped to an explicit session principal.
200
+ */
201
+ insertDurableWithSession(table: string, values: any, write_context_json: string | null | undefined, tier: string, object_id?: string | null): Promise<any>;
202
+ /**
203
+ * Insert a row into a table as an explicit session principal.
204
+ */
205
+ insertWithSession(table: string, values: any, write_context_json?: string | null, object_id?: string | null): any;
206
+ static mintLocalFirstToken(seed_b64: string, audience: string, ttl_seconds: bigint, now_seconds: bigint): string;
207
207
  /**
208
208
  * Create a new WasmRuntime.
209
209
  *
@@ -214,25 +214,35 @@ export class WasmRuntime {
214
214
  * * `app_id` - Application identifier
215
215
  * * `env` - Environment (e.g., "dev", "prod")
216
216
  * * `user_branch` - User's branch name (e.g., "main")
217
- * * `tier` - Optional persistence tier ("worker", "edge", "core").
217
+ * * `tier` - Optional node durability tier ("worker", "edge", "global").
218
218
  * Set for server nodes to enable ack emission.
219
+ * * `use_binary_encoding` - Optional outgoing sync payload encoding mode.
220
+ * `Some(true)` emits postcard bytes (`Uint8Array`), otherwise JSON strings.
221
+ */
222
+ constructor(schema_json: string, app_id: string, env: string, user_branch: string, tier?: string | null, use_binary_encoding?: boolean | null);
223
+ /**
224
+ * Register a JS callback that fires when the Rust transport receives an
225
+ * auth failure (Unauthorized) from the server during the WS handshake.
226
+ *
227
+ * The callback receives a single string argument: a human-readable reason.
219
228
  */
220
- constructor(schema_json: string, app_id: string, env: string, user_branch: string, tier?: string | null);
229
+ onAuthFailure(callback: Function): void;
221
230
  /**
222
231
  * Called by JS when a sync message arrives from the server.
223
232
  *
224
233
  * # Arguments
225
- * * `message_json` - JSON-encoded SyncPayload
234
+ * * `payload` - Either postcard-encoded SyncPayload bytes (`Uint8Array`)
235
+ * or JSON-encoded SyncPayload (`string`)
226
236
  */
227
- onSyncMessageReceived(message_json: string): void;
237
+ onSyncMessageReceived(payload: any, sequence?: number | null): void;
228
238
  /**
229
239
  * Called by JS when a sync message arrives from a client (not a server).
230
240
  *
231
241
  * # Arguments
232
242
  * * `client_id` - UUID string of the sending client
233
- * * `message_json` - JSON-encoded SyncPayload
243
+ * * `payload` - Postcard-encoded SyncPayload bytes
234
244
  */
235
- onSyncMessageReceivedFromClient(client_id: string, message_json: string): void;
245
+ onSyncMessageReceivedFromClient(client_id: string, payload: any): void;
236
246
  /**
237
247
  * Register a callback for outgoing sync messages.
238
248
  */
@@ -243,13 +253,13 @@ export class WasmRuntime {
243
253
  * Opens a single OPFS file namespace and restores state from the latest
244
254
  * durable checkpoint.
245
255
  */
246
- static openPersistent(schema_json: string, app_id: string, env: string, user_branch: string, db_name: string, tier?: string | null): Promise<WasmRuntime>;
256
+ 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>;
247
257
  /**
248
258
  * Execute a query and return results as a Promise.
249
259
  *
250
- * Optional `settled_tier` holds delivery until the tier confirms.
260
+ * Optional durability tier controls remote settlement behavior.
251
261
  */
252
- query(query_json: string, session_json?: string | null, settled_tier?: string | null): Promise<any>;
262
+ query(query_json: string, session_json?: string | null, settled_tier?: string | null, options_json?: string | null): Promise<any>;
253
263
  /**
254
264
  * Remove the current upstream server connection.
255
265
  */
@@ -269,12 +279,12 @@ export class WasmRuntime {
269
279
  * - with upstream server: first callback waits for protocol QuerySettled convergence
270
280
  * - without upstream server: first callback is local-immediate
271
281
  *
272
- * Pass `settled_tier` to override this default.
282
+ * Pass durability options to override this default.
273
283
  *
274
284
  * # Returns
275
285
  * Subscription handle (f64) for later unsubscription.
276
286
  */
277
- subscribe(query_json: string, on_update: Function, session_json?: string | null, settled_tier?: string | null): number;
287
+ subscribe(query_json: string, on_update: Function, session_json?: string | null, settled_tier?: string | null, options_json?: string | null): number;
278
288
  /**
279
289
  * Unsubscribe from a query.
280
290
  */
@@ -283,10 +293,28 @@ export class WasmRuntime {
283
293
  * Update a row by ObjectId.
284
294
  */
285
295
  update(object_id: string, values: any): void;
296
+ /**
297
+ * Push updated auth credentials into the live transport.
298
+ */
299
+ updateAuth(auth_json: string): void;
286
300
  /**
287
301
  * Update a row and return a Promise that resolves when the tier acks.
288
302
  */
289
- updateWithAck(object_id: string, values: any, tier: string): Promise<any>;
303
+ updateDurable(object_id: string, values: any, tier: string): Promise<any>;
304
+ /**
305
+ * Update a row and return a Promise that resolves when the tier acks,
306
+ * scoped to an explicit session principal.
307
+ */
308
+ updateDurableWithSession(object_id: string, values: any, write_context_json: string | null | undefined, tier: string): Promise<any>;
309
+ /**
310
+ * Update a row by ObjectId as an explicit session principal.
311
+ *
312
+ * # Arguments
313
+ * * `object_id` - UUID string of target object
314
+ * * `values` - Partial update map (`{ columnName: Value }`)
315
+ * * `session_json` - Optional JSON-encoded Session used for policy checks
316
+ */
317
+ updateWithSession(object_id: string, values: any, write_context_json?: string | null): void;
290
318
  }
291
319
 
292
320
  export function bench_get_cache_bytes(): number;
@@ -366,9 +394,6 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
366
394
  export interface InitOutput {
367
395
  readonly memory: WebAssembly.Memory;
368
396
  readonly __wbg_wasmquerybuilder_free: (a: number, b: number) => void;
369
- readonly currentTimestamp: () => bigint;
370
- readonly generateId: () => [number, number];
371
- readonly parseSchema: (a: number, b: number) => [number, number, number];
372
397
  readonly wasmquerybuilder_alias: (a: number, b: number, c: number) => number;
373
398
  readonly wasmquerybuilder_branch: (a: number, b: number, c: number) => number;
374
399
  readonly wasmquerybuilder_branches: (a: number, b: number, c: number) => number;
@@ -390,30 +415,50 @@ export interface InitOutput {
390
415
  readonly wasmquerybuilder_orderBy: (a: number, b: number, c: number) => number;
391
416
  readonly wasmquerybuilder_orderByDesc: (a: number, b: number, c: number) => number;
392
417
  readonly wasmquerybuilder_select: (a: number, b: number, c: number) => number;
418
+ readonly currentTimestamp: () => bigint;
419
+ readonly generateId: () => [number, number];
420
+ readonly parseSchema: (a: number, b: number) => [number, number, number];
393
421
  readonly init: () => void;
394
422
  readonly __wbg_wasmruntime_free: (a: number, b: number) => void;
423
+ readonly wasmruntime___debugSchemaState: (a: number) => [number, number, number];
424
+ readonly wasmruntime___debugSeedLiveSchema: (a: number, b: number, c: number) => [number, number];
395
425
  readonly wasmruntime_addClient: (a: number) => [number, number];
396
- readonly wasmruntime_addServer: (a: number) => void;
426
+ readonly wasmruntime_addServer: (a: number, b: number, c: number, d: number, e: number) => [number, number];
427
+ readonly wasmruntime_connect: (a: number, b: number, c: number, d: number, e: number) => [number, number];
428
+ readonly wasmruntime_createSubscription: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
397
429
  readonly wasmruntime_delete: (a: number, b: number, c: number) => [number, number];
398
- readonly wasmruntime_deleteWithAck: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
430
+ readonly wasmruntime_deleteDurable: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
431
+ readonly wasmruntime_deleteDurableWithSession: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
432
+ readonly wasmruntime_deleteWithSession: (a: number, b: number, c: number, d: number, e: number) => [number, number];
433
+ readonly wasmruntime_deriveUserId: (a: number, b: number) => [number, number, number, number];
434
+ readonly wasmruntime_disconnect: (a: number) => void;
435
+ readonly wasmruntime_executeSubscription: (a: number, b: number, c: any) => [number, number];
399
436
  readonly wasmruntime_flush: (a: number) => void;
400
437
  readonly wasmruntime_flushWal: (a: number) => void;
438
+ readonly wasmruntime_getPublicKeyBase64url: (a: number, b: number) => [number, number, number, number];
401
439
  readonly wasmruntime_getSchema: (a: number) => [number, number, number];
402
440
  readonly wasmruntime_getSchemaHash: (a: number) => [number, number];
403
- readonly wasmruntime_insert: (a: number, b: number, c: number, d: any) => [number, number, number, number];
404
- readonly wasmruntime_insertWithAck: (a: number, b: number, c: number, d: any, e: number, f: number) => [number, number, number];
405
- readonly wasmruntime_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number];
406
- readonly wasmruntime_onSyncMessageReceived: (a: number, b: number, c: number) => [number, number];
407
- readonly wasmruntime_onSyncMessageReceivedFromClient: (a: number, b: number, c: number, d: number, e: number) => [number, number];
441
+ readonly wasmruntime_insert: (a: number, b: number, c: number, d: any, e: number, f: number) => [number, number, number];
442
+ readonly wasmruntime_insertDurable: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number) => [number, number, number];
443
+ readonly wasmruntime_insertDurableWithSession: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number];
444
+ readonly wasmruntime_insertWithSession: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number) => [number, number, number];
445
+ readonly wasmruntime_mintLocalFirstToken: (a: number, b: number, c: number, d: number, e: bigint, f: bigint) => [number, number, number, number];
446
+ 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];
447
+ readonly wasmruntime_onAuthFailure: (a: number, b: any) => void;
448
+ readonly wasmruntime_onSyncMessageReceived: (a: number, b: any, c: number, d: number) => [number, number];
449
+ readonly wasmruntime_onSyncMessageReceivedFromClient: (a: number, b: number, c: number, d: any) => [number, number];
408
450
  readonly wasmruntime_onSyncMessageToSend: (a: number, b: any) => void;
409
- 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) => any;
410
- readonly wasmruntime_query: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
451
+ 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;
452
+ readonly wasmruntime_query: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
411
453
  readonly wasmruntime_removeServer: (a: number) => void;
412
454
  readonly wasmruntime_setClientRole: (a: number, b: number, c: number, d: number, e: number) => [number, number];
413
- readonly wasmruntime_subscribe: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number) => [number, number, number];
455
+ 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];
414
456
  readonly wasmruntime_unsubscribe: (a: number, b: number) => void;
415
457
  readonly wasmruntime_update: (a: number, b: number, c: number, d: any) => [number, number];
416
- readonly wasmruntime_updateWithAck: (a: number, b: number, c: number, d: any, e: number, f: number) => [number, number, number];
458
+ readonly wasmruntime_updateAuth: (a: number, b: number, c: number) => [number, number];
459
+ readonly wasmruntime_updateDurable: (a: number, b: number, c: number, d: any, e: number, f: number) => [number, number, number];
460
+ readonly wasmruntime_updateDurableWithSession: (a: number, b: number, c: number, d: any, e: number, f: number, g: number, h: number) => [number, number, number];
461
+ readonly wasmruntime_updateWithSession: (a: number, b: number, c: number, d: any, e: number, f: number) => [number, number];
417
462
  readonly bench_get_pin_internal_pages: () => number;
418
463
  readonly bench_opfs_cold_random_read: (a: number, b: number) => any;
419
464
  readonly bench_opfs_cold_sequential_read: (a: number, b: number) => any;
@@ -437,15 +482,18 @@ export interface InitOutput {
437
482
  readonly bench_reset_overflow_threshold_bytes: () => void;
438
483
  readonly bench_reset_pin_internal_pages: () => void;
439
484
  readonly bench_reset_read_coalesce_pages: () => void;
440
- readonly wasm_bindgen__closure__destroy__hf4559643960778aa: (a: number, b: number) => void;
441
- readonly wasm_bindgen__convert__closures_____invoke__h80f2dc13026cb48e: (a: number, b: number, c: any, d: any) => void;
442
- readonly wasm_bindgen__convert__closures_____invoke__hb8186e1d67b17c41: (a: number, b: number, c: any) => void;
485
+ readonly wasm_bindgen__convert__closures_____invoke__h656199c36535c3e6: (a: number, b: number, c: any) => [number, number];
486
+ readonly wasm_bindgen__convert__closures_____invoke__h250bbd6a67e0e1e6: (a: number, b: number, c: any, d: any) => void;
487
+ readonly wasm_bindgen__convert__closures_____invoke__hf7ddf3622752ec36: (a: number, b: number, c: any) => void;
488
+ readonly wasm_bindgen__convert__closures_____invoke__hc18e08680cddc2e5: (a: number, b: number, c: any) => void;
489
+ readonly wasm_bindgen__convert__closures_____invoke__h03757a48b3eba690: (a: number, b: number) => void;
443
490
  readonly __wbindgen_malloc: (a: number, b: number) => number;
444
491
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
445
492
  readonly __wbindgen_exn_store: (a: number) => void;
446
493
  readonly __externref_table_alloc: () => number;
447
494
  readonly __wbindgen_externrefs: WebAssembly.Table;
448
495
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
496
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
449
497
  readonly __externref_table_dealloc: (a: number) => void;
450
498
  readonly __wbindgen_start: () => void;
451
499
  }