@lix-js/sdk 0.6.0-preview.2 → 0.6.0-preview.4

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.
Files changed (169) hide show
  1. package/SKILL.md +46 -8
  2. package/dist/engine-wasm/wasm/lix_engine.d.ts +25 -1
  3. package/dist/engine-wasm/wasm/lix_engine.js +60 -2
  4. package/dist/engine-wasm/wasm/lix_engine.wasm +0 -0
  5. package/dist/engine-wasm/wasm/lix_engine.wasm.d.ts +5 -0
  6. package/dist/generated/builtin-schemas.d.ts +87 -162
  7. package/dist/generated/builtin-schemas.js +139 -236
  8. package/dist/open-lix.d.ts +10 -3
  9. package/dist/open-lix.js +39 -0
  10. package/dist-engine-src/src/binary_cas/types.rs +0 -6
  11. package/dist-engine-src/src/catalog/context.rs +412 -0
  12. package/dist-engine-src/src/catalog/mod.rs +10 -0
  13. package/dist-engine-src/src/catalog/schema.rs +4 -0
  14. package/dist-engine-src/src/catalog/snapshot.rs +1114 -0
  15. package/dist-engine-src/src/cel/mod.rs +1 -1
  16. package/dist-engine-src/src/cel/provider.rs +1 -1
  17. package/dist-engine-src/src/commit_graph/context.rs +328 -1015
  18. package/dist-engine-src/src/commit_graph/mod.rs +2 -3
  19. package/dist-engine-src/src/commit_graph/types.rs +7 -43
  20. package/dist-engine-src/src/commit_graph/walker.rs +57 -81
  21. package/dist-engine-src/src/commit_store/codec.rs +887 -0
  22. package/dist-engine-src/src/commit_store/context.rs +944 -0
  23. package/dist-engine-src/src/commit_store/materialization.rs +84 -0
  24. package/dist-engine-src/src/commit_store/mod.rs +16 -0
  25. package/dist-engine-src/src/commit_store/storage.rs +600 -0
  26. package/dist-engine-src/src/commit_store/types.rs +215 -0
  27. package/dist-engine-src/src/common/identity.rs +15 -5
  28. package/dist-engine-src/src/common/json_pointer.rs +67 -0
  29. package/dist-engine-src/src/common/metadata.rs +17 -12
  30. package/dist-engine-src/src/common/mod.rs +5 -5
  31. package/dist-engine-src/src/domain.rs +324 -0
  32. package/dist-engine-src/src/engine.rs +29 -43
  33. package/dist-engine-src/src/entity_identity.rs +238 -118
  34. package/dist-engine-src/src/functions/context.rs +17 -52
  35. package/dist-engine-src/src/functions/deterministic.rs +1 -1
  36. package/dist-engine-src/src/functions/mod.rs +1 -1
  37. package/dist-engine-src/src/functions/provider.rs +4 -4
  38. package/dist-engine-src/src/functions/state.rs +39 -66
  39. package/dist-engine-src/src/functions/types.rs +1 -1
  40. package/dist-engine-src/src/init.rs +204 -151
  41. package/dist-engine-src/src/json_store/context.rs +354 -60
  42. package/dist-engine-src/src/json_store/encoded.rs +6 -6
  43. package/dist-engine-src/src/json_store/mod.rs +4 -1
  44. package/dist-engine-src/src/json_store/store.rs +884 -11
  45. package/dist-engine-src/src/json_store/types.rs +166 -1
  46. package/dist-engine-src/src/lib.rs +11 -10
  47. package/dist-engine-src/src/live_state/context.rs +608 -830
  48. package/dist-engine-src/src/live_state/mod.rs +3 -3
  49. package/dist-engine-src/src/live_state/overlay.rs +7 -7
  50. package/dist-engine-src/src/live_state/reader.rs +5 -5
  51. package/dist-engine-src/src/live_state/types.rs +19 -36
  52. package/dist-engine-src/src/live_state/visibility.rs +19 -14
  53. package/dist-engine-src/src/plugin/archive.rs +3 -6
  54. package/dist-engine-src/src/plugin/install.rs +0 -18
  55. package/dist-engine-src/src/plugin/plugin_manifest.json +0 -1
  56. package/dist-engine-src/src/schema/annotations/defaults.rs +2 -7
  57. package/dist-engine-src/src/schema/builtin/lix_account.json +0 -1
  58. package/dist-engine-src/src/schema/builtin/lix_active_account.json +0 -1
  59. package/dist-engine-src/src/schema/builtin/lix_binary_blob_ref.json +0 -1
  60. package/dist-engine-src/src/schema/builtin/lix_change.json +11 -10
  61. package/dist-engine-src/src/schema/builtin/lix_change_author.json +0 -1
  62. package/dist-engine-src/src/schema/builtin/lix_commit.json +8 -46
  63. package/dist-engine-src/src/schema/builtin/lix_commit_edge.json +29 -22
  64. package/dist-engine-src/src/schema/builtin/lix_directory_descriptor.json +0 -1
  65. package/dist-engine-src/src/schema/builtin/lix_file_descriptor.json +0 -1
  66. package/dist-engine-src/src/schema/builtin/lix_key_value.json +0 -1
  67. package/dist-engine-src/src/schema/builtin/lix_label.json +10 -3
  68. package/dist-engine-src/src/schema/builtin/lix_label_assignment.json +74 -0
  69. package/dist-engine-src/src/schema/builtin/lix_registered_schema.json +2 -8
  70. package/dist-engine-src/src/schema/builtin/lix_version_descriptor.json +0 -1
  71. package/dist-engine-src/src/schema/builtin/lix_version_ref.json +0 -1
  72. package/dist-engine-src/src/schema/builtin/mod.rs +10 -59
  73. package/dist-engine-src/src/schema/compatibility.rs +787 -0
  74. package/dist-engine-src/src/schema/definition.json +47 -17
  75. package/dist-engine-src/src/schema/definition.rs +202 -96
  76. package/dist-engine-src/src/schema/key.rs +9 -77
  77. package/dist-engine-src/src/schema/mod.rs +4 -4
  78. package/dist-engine-src/src/schema/tests.rs +133 -92
  79. package/dist-engine-src/src/session/context.rs +86 -48
  80. package/dist-engine-src/src/session/create_version.rs +22 -14
  81. package/dist-engine-src/src/session/execute.rs +117 -23
  82. package/dist-engine-src/src/session/merge/apply.rs +4 -4
  83. package/dist-engine-src/src/session/merge/conflicts.rs +3 -2
  84. package/dist-engine-src/src/session/merge/stats.rs +1 -1
  85. package/dist-engine-src/src/session/merge/version.rs +35 -45
  86. package/dist-engine-src/src/session/mod.rs +9 -7
  87. package/dist-engine-src/src/session/optimization9_sql2_bench.rs +100 -0
  88. package/dist-engine-src/src/session/switch_version.rs +17 -28
  89. package/dist-engine-src/src/session/transaction.rs +76 -0
  90. package/dist-engine-src/src/sql2/change_provider.rs +14 -20
  91. package/dist-engine-src/src/sql2/classify.rs +75 -48
  92. package/dist-engine-src/src/sql2/context.rs +22 -18
  93. package/dist-engine-src/src/sql2/directory_history_provider.rs +28 -20
  94. package/dist-engine-src/src/sql2/directory_provider.rs +131 -83
  95. package/dist-engine-src/src/sql2/entity_history_provider.rs +10 -14
  96. package/dist-engine-src/src/sql2/entity_provider.rs +680 -169
  97. package/dist-engine-src/src/sql2/error.rs +24 -5
  98. package/dist-engine-src/src/sql2/execute.rs +426 -272
  99. package/dist-engine-src/src/sql2/file_history_provider.rs +29 -21
  100. package/dist-engine-src/src/sql2/file_provider.rs +533 -108
  101. package/dist-engine-src/src/sql2/filesystem_planner.rs +58 -94
  102. package/dist-engine-src/src/sql2/filesystem_visibility.rs +37 -23
  103. package/dist-engine-src/src/sql2/history_projection.rs +3 -27
  104. package/dist-engine-src/src/sql2/history_provider.rs +11 -17
  105. package/dist-engine-src/src/sql2/history_route.rs +22 -8
  106. package/dist-engine-src/src/sql2/lix_state_provider.rs +178 -96
  107. package/dist-engine-src/src/sql2/mod.rs +8 -4
  108. package/dist-engine-src/src/sql2/predicate_typecheck.rs +246 -0
  109. package/dist-engine-src/src/sql2/public_bind/assignment.rs +46 -0
  110. package/dist-engine-src/src/sql2/public_bind/capability.rs +41 -0
  111. package/dist-engine-src/src/sql2/public_bind/dml.rs +172 -0
  112. package/dist-engine-src/src/sql2/public_bind/mod.rs +26 -0
  113. package/dist-engine-src/src/sql2/public_bind/table.rs +168 -0
  114. package/dist-engine-src/src/sql2/read_only.rs +10 -12
  115. package/dist-engine-src/src/sql2/session.rs +7 -10
  116. package/dist-engine-src/src/sql2/udfs/lix_timestamp.rs +76 -0
  117. package/dist-engine-src/src/sql2/udfs/mod.rs +8 -1
  118. package/dist-engine-src/src/sql2/udfs/public_call.rs +238 -0
  119. package/dist-engine-src/src/sql2/version_provider.rs +46 -31
  120. package/dist-engine-src/src/sql2/version_scope.rs +4 -4
  121. package/dist-engine-src/src/storage_bench.rs +1782 -325
  122. package/dist-engine-src/src/test_support.rs +183 -36
  123. package/dist-engine-src/src/tracked_state/by_file_index.rs +20 -24
  124. package/dist-engine-src/src/tracked_state/codec.rs +1519 -181
  125. package/dist-engine-src/src/tracked_state/context.rs +1155 -271
  126. package/dist-engine-src/src/tracked_state/diff.rs +249 -57
  127. package/dist-engine-src/src/tracked_state/materialization.rs +365 -103
  128. package/dist-engine-src/src/tracked_state/materializer.rs +488 -0
  129. package/dist-engine-src/src/tracked_state/merge.rs +37 -19
  130. package/dist-engine-src/src/tracked_state/mod.rs +8 -7
  131. package/dist-engine-src/src/tracked_state/storage.rs +138 -6
  132. package/dist-engine-src/src/tracked_state/tree.rs +695 -252
  133. package/dist-engine-src/src/tracked_state/types.rs +176 -6
  134. package/dist-engine-src/src/transaction/commit.rs +695 -435
  135. package/dist-engine-src/src/transaction/context.rs +551 -310
  136. package/dist-engine-src/src/transaction/live_state_overlay.rs +9 -8
  137. package/dist-engine-src/src/transaction/mod.rs +2 -0
  138. package/dist-engine-src/src/transaction/normalization.rs +311 -447
  139. package/dist-engine-src/src/transaction/prep.rs +37 -0
  140. package/dist-engine-src/src/transaction/schema_resolver.rs +93 -71
  141. package/dist-engine-src/src/transaction/staging.rs +701 -406
  142. package/dist-engine-src/src/transaction/types.rs +231 -122
  143. package/dist-engine-src/src/transaction/validation.rs +2717 -1698
  144. package/dist-engine-src/src/untracked_state/codec.rs +40 -96
  145. package/dist-engine-src/src/untracked_state/context.rs +21 -5
  146. package/dist-engine-src/src/untracked_state/materialization.rs +10 -104
  147. package/dist-engine-src/src/untracked_state/mod.rs +3 -5
  148. package/dist-engine-src/src/untracked_state/storage.rs +105 -57
  149. package/dist-engine-src/src/untracked_state/types.rs +63 -13
  150. package/dist-engine-src/src/version/context.rs +1 -13
  151. package/dist-engine-src/src/version/lifecycle.rs +221 -0
  152. package/dist-engine-src/src/version/mod.rs +3 -2
  153. package/dist-engine-src/src/version/refs.rs +12 -103
  154. package/dist-engine-src/src/version/stage_rows.rs +15 -19
  155. package/package.json +1 -1
  156. package/dist-engine-src/src/changelog/codec.rs +0 -321
  157. package/dist-engine-src/src/changelog/context.rs +0 -92
  158. package/dist-engine-src/src/changelog/materialization.rs +0 -121
  159. package/dist-engine-src/src/changelog/mod.rs +0 -13
  160. package/dist-engine-src/src/changelog/reader.rs +0 -20
  161. package/dist-engine-src/src/changelog/storage.rs +0 -220
  162. package/dist-engine-src/src/changelog/types.rs +0 -38
  163. package/dist-engine-src/src/schema/builtin/lix_change_set.json +0 -18
  164. package/dist-engine-src/src/schema/builtin/lix_change_set_element.json +0 -75
  165. package/dist-engine-src/src/schema/builtin/lix_entity_label.json +0 -63
  166. package/dist-engine-src/src/schema_registry.rs +0 -294
  167. package/dist-engine-src/src/sql2/commit_derived_provider.rs +0 -591
  168. package/dist-engine-src/src/tracked_state/rebuild.rs +0 -771
  169. package/dist-engine-src/src/tracked_state/tree_types.rs +0 -176
package/SKILL.md CHANGED
@@ -13,6 +13,7 @@ Current `@lix-js/sdk` capabilities:
13
13
 
14
14
  - Register JSON schemas as tracked entity tables.
15
15
  - Read and write entities through generated SQL tables.
16
+ - Group related writes in explicit transactions so they commit once.
16
17
  - Create named versions of state and write/read across versions.
17
18
  - Merge one version into the active version.
18
19
  - Query `lix_change` for history, audit, activity feeds, and undo-style features.
@@ -34,6 +35,7 @@ Use this skill when you need to write or debug consumer code using `@lix-js/sdk`
34
35
  - Opening a persistent `.lix` file.
35
36
  - Registering schemas.
36
37
  - Writing and reading generated SQL entity tables.
38
+ - Grouping imports, migrations, and batch writes into one transaction.
37
39
  - Reading `execute()` results.
38
40
  - Creating, switching, previewing, and merging versions.
39
41
  - Querying history through `lix_change`.
@@ -45,11 +47,12 @@ Do not use this skill for raw SQLite access, private engine/wasm internals, SDK
45
47
 
46
48
  1. Install `@lix-js/sdk` and `better-sqlite3`.
47
49
  2. Open with `createBetterSqlite3Backend({ path })`; do not open `.lix` with raw SQLite.
48
- 3. Register a schema with `x-lix-key`, `x-lix-version`, `x-lix-primary-key`, and `additionalProperties: false`.
50
+ 3. Register a schema with `x-lix-key`, `x-lix-primary-key`, and `additionalProperties: false`.
49
51
  4. Write rows through the generated table named by `x-lix-key`.
50
- 5. Use `<schema>_by_version` plus `lixcol_version_id` for side-by-side version reads/writes.
51
- 6. Query `lix_change` for audit/history instead of hand-rolling audit tables.
52
- 7. Wrap `mergeVersion()` in `try/catch` whenever conflicts are possible.
52
+ 5. Use `beginTransaction()` for imports, migrations, and multi-row writes that should be one commit.
53
+ 6. Use `<schema>_by_version` plus `lixcol_version_id` for side-by-side version reads/writes.
54
+ 7. Query `lix_change` for audit/history instead of hand-rolling audit tables.
55
+ 8. Wrap `mergeVersion()` in `try/catch` whenever conflicts are possible.
53
56
 
54
57
  ## Core Rules
55
58
 
@@ -57,6 +60,9 @@ Do not use this skill for raw SQLite access, private engine/wasm internals, SDK
57
60
  - Use `createBetterSqlite3Backend()` for persistent apps, demos, and tests.
58
61
  - Use numbered SQL placeholders: `$1`, `$2`, `$3`; bare `?` is rejected.
59
62
  - Use `lix_json($1)` when inserting JSON text into JSON-typed columns.
63
+ - Use scalar SQL functions `SELECT lix_uuid_v7()` and `SELECT lix_timestamp()` when consumer code needs Lix-generated UUID v7 ids or ISO timestamps. Do not call them as table functions with `SELECT * FROM ...`.
64
+ - Use `beginTransaction()` for batch writes. One `lix.execute()` write is one transaction and therefore one commit.
65
+ - Do not call `execute()` through the parent `lix` handle while a transaction is active; use the transaction handle for reads and writes until `commit()` or `rollback()`.
60
66
  - Use stable, namespaced, lowercase schema keys like `acme_section`, not generic names like `task`.
61
67
  - Always include `x-lix-primary-key` and `additionalProperties: false` on app schemas.
62
68
  - Use version names from the user's vocabulary, such as `"Marketing edit"` or `"Q3 pricing draft"`.
@@ -134,7 +140,6 @@ await lix.execute(
134
140
  JSON.stringify({
135
141
  $schema: "https://json-schema.org/draft/2020-12/schema",
136
142
  "x-lix-key": "acme_note",
137
- "x-lix-version": "1",
138
143
  "x-lix-primary-key": ["/id"],
139
144
  type: "object",
140
145
  required: ["id", "title", "done"],
@@ -203,6 +208,38 @@ Accessors return `undefined` when the cell kind does not match. Branch on `value
203
208
 
204
209
  `Row` also has convenience methods when native JS values are enough: `get(name)`, `tryGet(name)`, `getAt(index)`, `toObject()`, and `toValueMap()`.
205
210
 
211
+ ## Transactions
212
+
213
+ Use `beginTransaction()` whenever several writes belong to one logical operation: CSV imports, seed scripts, migrations, bulk updates, or multi-table changes. A write through `lix.execute()` opens and commits its own transaction, so thousands of separate `execute()` writes become thousands of commits. A transaction handle stages those writes and commits them together.
214
+
215
+ ```ts
216
+ const tx = await lix.beginTransaction();
217
+
218
+ try {
219
+ for (const note of notes) {
220
+ await tx.execute(
221
+ "INSERT INTO acme_note (id, title, done) VALUES ($1, $2, $3)",
222
+ [note.id, note.title, false],
223
+ );
224
+ }
225
+
226
+ await tx.commit();
227
+ } catch (error) {
228
+ await tx.rollback();
229
+ throw error;
230
+ }
231
+ ```
232
+
233
+ Transaction rules:
234
+
235
+ - `tx.execute()` has the same result shape as `lix.execute()`.
236
+ - Writes are visible to later reads on the same transaction before commit.
237
+ - `commit()` makes the whole transaction durable as one commit.
238
+ - `rollback()` drops the staged writes.
239
+ - After `commit()` or `rollback()`, the transaction handle is closed and cannot be reused.
240
+ - A Lix handle allows one active transaction at a time. While it is active, use `tx.execute()` for reads and writes; parent-handle `lix.execute()` is rejected until the transaction closes.
241
+ - Do not use a callback-style transaction helper. The JS SDK mirrors the Rust SDK shape: explicitly `beginTransaction()`, then `commit()` or `rollback()`.
242
+
206
243
  ## Registering Schemas
207
244
 
208
245
  Register app schemas by inserting JSON into `lix_registered_schema.value`:
@@ -217,7 +254,7 @@ await lix.execute(
217
254
  Schema basics:
218
255
 
219
256
  - `x-lix-key` becomes the generated SQL table name.
220
- - `x-lix-version` versions your schema contract.
257
+ - Compatible schema amendments are keyed by `x-lix-key`.
221
258
  - `x-lix-primary-key` tells Lix how to derive entity identity.
222
259
  - Primary-key entries are JSON Pointers with a leading slash, such as `["/id"]` or `["/owner/email"]`.
223
260
  - Use `additionalProperties: false` so accidental fields fail fast.
@@ -229,7 +266,6 @@ Uniqueness is not inferred from ordinary JSON Schema fields. If a non-primary-ke
229
266
  ```ts
230
267
  const companyDomainSchema = {
231
268
  "x-lix-key": "crm_company_domain",
232
- "x-lix-version": "1",
233
269
  "x-lix-primary-key": ["/id"],
234
270
  "x-lix-unique": [["/domain"]],
235
271
  type: "object",
@@ -389,7 +425,7 @@ Columns consumers usually need:
389
425
 
390
426
  `lix_change` is an immutable SQL table of changes across registered schemas and versions. Use it for audit logs, blame, history, activity feeds, and undo-style UI.
391
427
 
392
- Important columns include `id`, `entity_id`, `schema_key`, `schema_version`, `snapshot_content`, `created_at`, and `lixcol_*` metadata.
428
+ Important columns include `id`, `entity_id`, `schema_key`, `snapshot_content`, `created_at`, and `lixcol_*` metadata.
393
429
 
394
430
  ```ts
395
431
  // Audit log for one entity, oldest to newest.
@@ -454,6 +490,8 @@ Other UDFs, such as `lix_json_get`, `lix_uuid_v7`, `lix_text_encode`, and `lix_e
454
490
  | Use public imports from `@lix-js/sdk` and `@lix-js/sdk/sqlite`. | Importing `engine-wasm` or private internals. |
455
491
  | Use `$1`, `$2`, `$3` placeholders. | Bare `?` placeholders. |
456
492
  | Use `lix_json($1)` for JSON parameters. | Inlining stringified JSON directly into SQL. |
493
+ | Use `beginTransaction()` for imports and batch writes that should be one commit. | Loops of standalone `lix.execute()` writes for bulk imports. |
494
+ | Use the transaction handle for reads and writes until it commits or rolls back. | Calling parent-handle `execute()` during an active transaction. |
457
495
  | Use `_by_version` for cross-version reads/writes. | Switching versions just to render a side-by-side view. |
458
496
  | Name versions in user vocabulary. | User-facing words like branch, branch-1, or generic Draft. |
459
497
  | Model collaborative data as small rows. | One giant row when multiple reviewers edit different parts. |
@@ -12,6 +12,10 @@ export class Lix {
12
12
  * @returns {Promise<string>}
13
13
  */
14
14
  activeVersionId(): Promise<string>;
15
+ /**
16
+ * @returns {Promise<LixTransaction>}
17
+ */
18
+ beginTransaction(): Promise<LixTransaction>;
15
19
  /**
16
20
  * @returns {Promise<void>}
17
21
  */
@@ -25,7 +29,7 @@ export class Lix {
25
29
  * Executes one DataFusion SQL statement against this Lix session.
26
30
  *
27
31
  * The SQL dialect is DataFusion SQL, not SQLite SQL. Positional
28
- * placeholders use `$1`, `$2`, and so on. SQLite-specific catalog
32
+ * placeholders use `?` or `$1`, `$2`, and so on. SQLite-specific catalog
29
33
  * tables and transaction statements such as `sqlite_master`, `BEGIN`,
30
34
  * and `COMMIT` are not part of this contract; use
31
35
  * `information_schema` for catalog inspection.
@@ -50,6 +54,26 @@ export class Lix {
50
54
  */
51
55
  switchVersion(args: any): Promise<any>;
52
56
  }
57
+ export class LixTransaction {
58
+ static __wrap(ptr: any): any;
59
+ __destroy_into_raw(): number | undefined;
60
+ __wbg_ptr: number | undefined;
61
+ free(): void;
62
+ /**
63
+ * @returns {Promise<void>}
64
+ */
65
+ commit(): Promise<void>;
66
+ /**
67
+ * @param {any} sql
68
+ * @param {any} params
69
+ * @returns {Promise<any>}
70
+ */
71
+ execute(sql: any, params: any): Promise<any>;
72
+ /**
73
+ * @returns {Promise<void>}
74
+ */
75
+ rollback(): Promise<void>;
76
+ }
53
77
  export function initSync(module: any): any;
54
78
  declare function __wbg_init(module_or_path: any): Promise<any>;
55
79
  export { __wbg_init as default };
@@ -24,6 +24,13 @@ export class Lix {
24
24
  const ret = wasm.lix_activeVersionId(this.__wbg_ptr);
25
25
  return ret;
26
26
  }
27
+ /**
28
+ * @returns {Promise<LixTransaction>}
29
+ */
30
+ beginTransaction() {
31
+ const ret = wasm.lix_beginTransaction(this.__wbg_ptr);
32
+ return ret;
33
+ }
27
34
  /**
28
35
  * @returns {Promise<void>}
29
36
  */
@@ -43,7 +50,7 @@ export class Lix {
43
50
  * Executes one DataFusion SQL statement against this Lix session.
44
51
  *
45
52
  * The SQL dialect is DataFusion SQL, not SQLite SQL. Positional
46
- * placeholders use `$1`, `$2`, and so on. SQLite-specific catalog
53
+ * placeholders use `?` or `$1`, `$2`, and so on. SQLite-specific catalog
47
54
  * tables and transaction statements such as `sqlite_master`, `BEGIN`,
48
55
  * and `COMMIT` are not part of this contract; use
49
56
  * `information_schema` for catalog inspection.
@@ -82,6 +89,50 @@ export class Lix {
82
89
  }
83
90
  if (Symbol.dispose)
84
91
  Lix.prototype[Symbol.dispose] = Lix.prototype.free;
92
+ export class LixTransaction {
93
+ static __wrap(ptr) {
94
+ ptr = ptr >>> 0;
95
+ const obj = Object.create(LixTransaction.prototype);
96
+ obj.__wbg_ptr = ptr;
97
+ LixTransactionFinalization.register(obj, obj.__wbg_ptr, obj);
98
+ return obj;
99
+ }
100
+ __destroy_into_raw() {
101
+ const ptr = this.__wbg_ptr;
102
+ this.__wbg_ptr = 0;
103
+ LixTransactionFinalization.unregister(this);
104
+ return ptr;
105
+ }
106
+ free() {
107
+ const ptr = this.__destroy_into_raw();
108
+ wasm.__wbg_lixtransaction_free(ptr, 0);
109
+ }
110
+ /**
111
+ * @returns {Promise<void>}
112
+ */
113
+ commit() {
114
+ const ret = wasm.lixtransaction_commit(this.__wbg_ptr);
115
+ return ret;
116
+ }
117
+ /**
118
+ * @param {any} sql
119
+ * @param {any} params
120
+ * @returns {Promise<any>}
121
+ */
122
+ execute(sql, params) {
123
+ const ret = wasm.lixtransaction_execute(this.__wbg_ptr, sql, params);
124
+ return ret;
125
+ }
126
+ /**
127
+ * @returns {Promise<void>}
128
+ */
129
+ rollback() {
130
+ const ret = wasm.lixtransaction_rollback(this.__wbg_ptr);
131
+ return ret;
132
+ }
133
+ }
134
+ if (Symbol.dispose)
135
+ LixTransaction.prototype[Symbol.dispose] = LixTransaction.prototype.free;
85
136
  /**
86
137
  * @param {any | null} [args]
87
138
  * @returns {Promise<Lix>}
@@ -295,6 +346,10 @@ function __wbg_get_imports() {
295
346
  const ret = Lix.__wrap(arg0);
296
347
  return ret;
297
348
  },
349
+ __wbg_lixtransaction_new: function (arg0) {
350
+ const ret = LixTransaction.__wrap(arg0);
351
+ return ret;
352
+ },
298
353
  __wbg_new_0_73afc35eb544e539: function () {
299
354
  const ret = new Date();
300
355
  return ret;
@@ -430,7 +485,7 @@ function __wbg_get_imports() {
430
485
  return ret;
431
486
  },
432
487
  __wbindgen_cast_0000000000000001: function (arg0, arg1) {
433
- // Cast intrinsic for `Closure(Closure { dtor_idx: 3067, function: Function { arguments: [Externref], shim_idx: 3068, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
488
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 3074, function: Function { arguments: [Externref], shim_idx: 3075, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
434
489
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h259bf120b5b35fc5, wasm_bindgen__convert__closures_____invoke__ha15a27e9815e3c81);
435
490
  return ret;
436
491
  },
@@ -482,6 +537,9 @@ function wasm_bindgen__convert__closures_____invoke__h14bc79029e3672a5(arg0, arg
482
537
  const LixFinalization = (typeof FinalizationRegistry === 'undefined')
483
538
  ? { register: () => { }, unregister: () => { } }
484
539
  : new FinalizationRegistry(ptr => wasm.__wbg_lix_free(ptr >>> 0, 1));
540
+ const LixTransactionFinalization = (typeof FinalizationRegistry === 'undefined')
541
+ ? { register: () => { }, unregister: () => { } }
542
+ : new FinalizationRegistry(ptr => wasm.__wbg_lixtransaction_free(ptr >>> 0, 1));
485
543
  function addToExternrefTable0(obj) {
486
544
  const idx = wasm.__externref_table_alloc();
487
545
  wasm.__wbindgen_externrefs.set(idx, obj);
@@ -2,13 +2,18 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_lix_free: (a: number, b: number) => void;
5
+ export const __wbg_lixtransaction_free: (a: number, b: number) => void;
5
6
  export const lix_activeVersionId: (a: number) => any;
7
+ export const lix_beginTransaction: (a: number) => any;
6
8
  export const lix_close: (a: number) => any;
7
9
  export const lix_createVersion: (a: number, b: any) => any;
8
10
  export const lix_execute: (a: number, b: any, c: any) => any;
9
11
  export const lix_mergeVersion: (a: number, b: any) => any;
10
12
  export const lix_mergeVersionPreview: (a: number, b: any) => any;
11
13
  export const lix_switchVersion: (a: number, b: any) => any;
14
+ export const lixtransaction_commit: (a: number) => any;
15
+ export const lixtransaction_execute: (a: number, b: any, c: any) => any;
16
+ export const lixtransaction_rollback: (a: number) => any;
12
17
  export const openLix: (a: number) => any;
13
18
  export const wasm_bindgen__closure__destroy__h259bf120b5b35fc5: (a: number, b: number) => void;
14
19
  export const wasm_bindgen__convert__closures_____invoke__h14bc79029e3672a5: (a: number, b: number, c: any, d: any) => void;