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

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 (196) hide show
  1. package/README.md +9 -0
  2. package/SKILL.md +468 -0
  3. package/dist/engine-wasm/index.d.ts +15 -11
  4. package/dist/engine-wasm/index.js +105 -38
  5. package/dist/engine-wasm/wasm/lix_engine.d.ts +14 -2
  6. package/dist/engine-wasm/wasm/lix_engine.js +18 -17
  7. package/dist/engine-wasm/wasm/lix_engine.wasm +0 -0
  8. package/dist/engine-wasm/wasm/lix_engine.wasm.d.ts +2 -1
  9. package/dist/generated/builtin-schemas.d.ts +31 -41
  10. package/dist/generated/builtin-schemas.js +52 -56
  11. package/dist/open-lix.d.ts +141 -24
  12. package/dist/open-lix.js +199 -35
  13. package/dist/sqlite/index.js +99 -22
  14. package/dist-engine-src/README.md +18 -0
  15. package/dist-engine-src/src/backend/kv.rs +358 -0
  16. package/dist-engine-src/src/backend/mod.rs +12 -0
  17. package/dist-engine-src/src/backend/testing.rs +658 -0
  18. package/dist-engine-src/src/backend/types.rs +96 -0
  19. package/dist-engine-src/src/binary_cas/chunking.rs +31 -0
  20. package/dist-engine-src/src/binary_cas/codec.rs +346 -0
  21. package/dist-engine-src/src/binary_cas/context.rs +139 -0
  22. package/dist-engine-src/src/binary_cas/kv.rs +1063 -0
  23. package/dist-engine-src/src/binary_cas/mod.rs +11 -0
  24. package/dist-engine-src/src/binary_cas/types.rs +127 -0
  25. package/dist-engine-src/src/cel/context.rs +86 -0
  26. package/dist-engine-src/src/cel/error.rs +19 -0
  27. package/dist-engine-src/src/cel/mod.rs +8 -0
  28. package/dist-engine-src/src/cel/provider.rs +9 -0
  29. package/dist-engine-src/src/cel/runtime.rs +167 -0
  30. package/dist-engine-src/src/cel/value.rs +50 -0
  31. package/dist-engine-src/src/changelog/codec.rs +321 -0
  32. package/dist-engine-src/src/changelog/context.rs +92 -0
  33. package/dist-engine-src/src/changelog/materialization.rs +121 -0
  34. package/dist-engine-src/src/changelog/mod.rs +13 -0
  35. package/dist-engine-src/src/changelog/reader.rs +20 -0
  36. package/dist-engine-src/src/changelog/storage.rs +220 -0
  37. package/dist-engine-src/src/changelog/types.rs +38 -0
  38. package/dist-engine-src/src/commit_graph/context.rs +1588 -0
  39. package/dist-engine-src/src/commit_graph/mod.rs +12 -0
  40. package/dist-engine-src/src/commit_graph/types.rs +145 -0
  41. package/dist-engine-src/src/commit_graph/walker.rs +780 -0
  42. package/dist-engine-src/src/common/error.rs +313 -0
  43. package/dist-engine-src/src/common/fingerprint.rs +3 -0
  44. package/dist-engine-src/src/common/fs_path.rs +1336 -0
  45. package/dist-engine-src/src/common/identity.rs +135 -0
  46. package/dist-engine-src/src/common/metadata.rs +35 -0
  47. package/dist-engine-src/src/common/mod.rs +23 -0
  48. package/dist-engine-src/src/common/types.rs +105 -0
  49. package/dist-engine-src/src/common/wire.rs +222 -0
  50. package/dist-engine-src/src/engine.rs +239 -0
  51. package/dist-engine-src/src/entity_identity.rs +285 -0
  52. package/dist-engine-src/src/functions/context.rs +327 -0
  53. package/dist-engine-src/src/functions/deterministic.rs +113 -0
  54. package/dist-engine-src/src/functions/mod.rs +18 -0
  55. package/dist-engine-src/src/functions/provider.rs +130 -0
  56. package/dist-engine-src/src/functions/state.rs +363 -0
  57. package/dist-engine-src/src/functions/types.rs +37 -0
  58. package/dist-engine-src/src/init.rs +505 -0
  59. package/dist-engine-src/src/json_store/compression.rs +77 -0
  60. package/dist-engine-src/src/json_store/context.rs +129 -0
  61. package/dist-engine-src/src/json_store/encoded.rs +15 -0
  62. package/dist-engine-src/src/json_store/mod.rs +9 -0
  63. package/dist-engine-src/src/json_store/store.rs +236 -0
  64. package/dist-engine-src/src/json_store/types.rs +52 -0
  65. package/dist-engine-src/src/lib.rs +61 -0
  66. package/dist-engine-src/src/live_state/context.rs +2241 -0
  67. package/dist-engine-src/src/live_state/mod.rs +15 -0
  68. package/dist-engine-src/src/live_state/overlay.rs +75 -0
  69. package/dist-engine-src/src/live_state/reader.rs +23 -0
  70. package/dist-engine-src/src/live_state/types.rs +239 -0
  71. package/dist-engine-src/src/live_state/visibility.rs +218 -0
  72. package/dist-engine-src/src/plugin/archive.rs +441 -0
  73. package/dist-engine-src/src/plugin/component.rs +183 -0
  74. package/dist-engine-src/src/plugin/install.rs +637 -0
  75. package/dist-engine-src/src/plugin/manifest.rs +516 -0
  76. package/dist-engine-src/src/plugin/materializer.rs +477 -0
  77. package/dist-engine-src/src/plugin/mod.rs +33 -0
  78. package/dist-engine-src/src/plugin/plugin_manifest.json +119 -0
  79. package/dist-engine-src/src/plugin/storage.rs +74 -0
  80. package/dist-engine-src/src/schema/annotations/defaults.rs +280 -0
  81. package/dist-engine-src/src/schema/annotations/mod.rs +1 -0
  82. package/dist-engine-src/src/schema/builtin/lix_account.json +22 -0
  83. package/dist-engine-src/src/schema/builtin/lix_active_account.json +30 -0
  84. package/dist-engine-src/src/schema/builtin/lix_binary_blob_ref.json +30 -0
  85. package/dist-engine-src/src/schema/builtin/lix_change.json +62 -0
  86. package/dist-engine-src/src/schema/builtin/lix_change_author.json +46 -0
  87. package/dist-engine-src/src/schema/builtin/lix_change_set.json +18 -0
  88. package/dist-engine-src/src/schema/builtin/lix_change_set_element.json +75 -0
  89. package/dist-engine-src/src/schema/builtin/lix_commit.json +62 -0
  90. package/dist-engine-src/src/schema/builtin/lix_commit_edge.json +46 -0
  91. package/dist-engine-src/src/schema/builtin/lix_directory_descriptor.json +53 -0
  92. package/dist-engine-src/src/schema/builtin/lix_entity_label.json +63 -0
  93. package/dist-engine-src/src/schema/builtin/lix_file_descriptor.json +53 -0
  94. package/dist-engine-src/src/schema/builtin/lix_key_value.json +41 -0
  95. package/dist-engine-src/src/schema/builtin/lix_label.json +22 -0
  96. package/dist-engine-src/src/schema/builtin/lix_registered_schema.json +31 -0
  97. package/dist-engine-src/src/schema/builtin/lix_version_descriptor.json +35 -0
  98. package/dist-engine-src/src/schema/builtin/lix_version_ref.json +49 -0
  99. package/dist-engine-src/src/schema/builtin/mod.rs +271 -0
  100. package/dist-engine-src/src/schema/definition.json +157 -0
  101. package/dist-engine-src/src/schema/definition.rs +636 -0
  102. package/dist-engine-src/src/schema/key.rs +206 -0
  103. package/dist-engine-src/src/schema/mod.rs +20 -0
  104. package/dist-engine-src/src/schema/seed.rs +14 -0
  105. package/dist-engine-src/src/schema/tests.rs +739 -0
  106. package/dist-engine-src/src/schema_registry.rs +294 -0
  107. package/dist-engine-src/src/session/context.rs +366 -0
  108. package/dist-engine-src/src/session/create_version.rs +80 -0
  109. package/dist-engine-src/src/session/execute.rs +447 -0
  110. package/dist-engine-src/src/session/merge/analysis.rs +102 -0
  111. package/dist-engine-src/src/session/merge/apply.rs +23 -0
  112. package/dist-engine-src/src/session/merge/conflicts.rs +62 -0
  113. package/dist-engine-src/src/session/merge/mod.rs +11 -0
  114. package/dist-engine-src/src/session/merge/stats.rs +65 -0
  115. package/dist-engine-src/src/session/merge/version.rs +437 -0
  116. package/dist-engine-src/src/session/mod.rs +25 -0
  117. package/dist-engine-src/src/session/switch_version.rs +121 -0
  118. package/dist-engine-src/src/sql2/change_provider.rs +337 -0
  119. package/dist-engine-src/src/sql2/classify.rs +147 -0
  120. package/dist-engine-src/src/sql2/commit_derived_provider.rs +591 -0
  121. package/dist-engine-src/src/sql2/context.rs +307 -0
  122. package/dist-engine-src/src/sql2/directory_history_provider.rs +623 -0
  123. package/dist-engine-src/src/sql2/directory_provider.rs +2405 -0
  124. package/dist-engine-src/src/sql2/dml.rs +148 -0
  125. package/dist-engine-src/src/sql2/entity_history_provider.rs +444 -0
  126. package/dist-engine-src/src/sql2/entity_provider.rs +2700 -0
  127. package/dist-engine-src/src/sql2/error.rs +196 -0
  128. package/dist-engine-src/src/sql2/execute.rs +3379 -0
  129. package/dist-engine-src/src/sql2/file_history_provider.rs +902 -0
  130. package/dist-engine-src/src/sql2/file_provider.rs +3254 -0
  131. package/dist-engine-src/src/sql2/filesystem_planner.rs +1526 -0
  132. package/dist-engine-src/src/sql2/filesystem_predicates.rs +159 -0
  133. package/dist-engine-src/src/sql2/filesystem_visibility.rs +369 -0
  134. package/dist-engine-src/src/sql2/history_projection.rs +80 -0
  135. package/dist-engine-src/src/sql2/history_provider.rs +418 -0
  136. package/dist-engine-src/src/sql2/history_route.rs +643 -0
  137. package/dist-engine-src/src/sql2/lix_state_provider.rs +2430 -0
  138. package/dist-engine-src/src/sql2/mod.rs +43 -0
  139. package/dist-engine-src/src/sql2/read_only.rs +65 -0
  140. package/dist-engine-src/src/sql2/record_batch.rs +17 -0
  141. package/dist-engine-src/src/sql2/result_metadata.rs +29 -0
  142. package/dist-engine-src/src/sql2/runtime.rs +60 -0
  143. package/dist-engine-src/src/sql2/session.rs +135 -0
  144. package/dist-engine-src/src/sql2/udfs/common.rs +295 -0
  145. package/dist-engine-src/src/sql2/udfs/lix_active_version_commit_id.rs +53 -0
  146. package/dist-engine-src/src/sql2/udfs/lix_empty_blob.rs +47 -0
  147. package/dist-engine-src/src/sql2/udfs/lix_json.rs +100 -0
  148. package/dist-engine-src/src/sql2/udfs/lix_json_get.rs +99 -0
  149. package/dist-engine-src/src/sql2/udfs/lix_json_get_text.rs +99 -0
  150. package/dist-engine-src/src/sql2/udfs/lix_text_decode.rs +82 -0
  151. package/dist-engine-src/src/sql2/udfs/lix_text_encode.rs +85 -0
  152. package/dist-engine-src/src/sql2/udfs/lix_uuid_v7.rs +76 -0
  153. package/dist-engine-src/src/sql2/udfs/mod.rs +82 -0
  154. package/dist-engine-src/src/sql2/version_provider.rs +1187 -0
  155. package/dist-engine-src/src/sql2/version_scope.rs +394 -0
  156. package/dist-engine-src/src/sql2/write_normalization.rs +345 -0
  157. package/dist-engine-src/src/storage/context.rs +356 -0
  158. package/dist-engine-src/src/storage/mod.rs +14 -0
  159. package/dist-engine-src/src/storage/read_scope.rs +88 -0
  160. package/dist-engine-src/src/storage/types.rs +501 -0
  161. package/dist-engine-src/src/storage_bench.rs +3406 -0
  162. package/dist-engine-src/src/test_support.rs +81 -0
  163. package/dist-engine-src/src/tracked_state/by_file_index.rs +102 -0
  164. package/dist-engine-src/src/tracked_state/codec.rs +747 -0
  165. package/dist-engine-src/src/tracked_state/context.rs +983 -0
  166. package/dist-engine-src/src/tracked_state/diff.rs +494 -0
  167. package/dist-engine-src/src/tracked_state/materialization.rs +141 -0
  168. package/dist-engine-src/src/tracked_state/merge.rs +474 -0
  169. package/dist-engine-src/src/tracked_state/mod.rs +31 -0
  170. package/dist-engine-src/src/tracked_state/rebuild.rs +771 -0
  171. package/dist-engine-src/src/tracked_state/storage.rs +243 -0
  172. package/dist-engine-src/src/tracked_state/tree.rs +2744 -0
  173. package/dist-engine-src/src/tracked_state/tree_types.rs +176 -0
  174. package/dist-engine-src/src/tracked_state/types.rs +61 -0
  175. package/dist-engine-src/src/transaction/commit.rs +1224 -0
  176. package/dist-engine-src/src/transaction/context.rs +1307 -0
  177. package/dist-engine-src/src/transaction/live_state_overlay.rs +34 -0
  178. package/dist-engine-src/src/transaction/mod.rs +11 -0
  179. package/dist-engine-src/src/transaction/normalization.rs +1026 -0
  180. package/dist-engine-src/src/transaction/schema_resolver.rs +127 -0
  181. package/dist-engine-src/src/transaction/staging.rs +1436 -0
  182. package/dist-engine-src/src/transaction/types.rs +351 -0
  183. package/dist-engine-src/src/transaction/validation.rs +4811 -0
  184. package/dist-engine-src/src/untracked_state/codec.rs +363 -0
  185. package/dist-engine-src/src/untracked_state/context.rs +82 -0
  186. package/dist-engine-src/src/untracked_state/materialization.rs +157 -0
  187. package/dist-engine-src/src/untracked_state/mod.rs +17 -0
  188. package/dist-engine-src/src/untracked_state/storage.rs +348 -0
  189. package/dist-engine-src/src/untracked_state/types.rs +96 -0
  190. package/dist-engine-src/src/version/context.rs +52 -0
  191. package/dist-engine-src/src/version/mod.rs +12 -0
  192. package/dist-engine-src/src/version/refs.rs +421 -0
  193. package/dist-engine-src/src/version/stage_rows.rs +71 -0
  194. package/dist-engine-src/src/version/types.rs +21 -0
  195. package/dist-engine-src/src/wasm/mod.rs +60 -0
  196. package/package.json +68 -63
@@ -16,22 +16,25 @@ export class Value {
16
16
  if (!Number.isFinite(value) || !Number.isInteger(value)) {
17
17
  throw new TypeError("Value.integer() requires a finite integer number");
18
18
  }
19
- return new Value("int", value);
19
+ return new Value("integer", value);
20
20
  }
21
21
  static boolean(value) {
22
- return new Value("bool", value);
22
+ return new Value("boolean", value);
23
23
  }
24
24
  static real(value) {
25
25
  if (!Number.isFinite(value)) {
26
26
  throw new TypeError("Value.real() requires a finite number");
27
27
  }
28
- return new Value("float", value);
28
+ return new Value("real", value);
29
29
  }
30
30
  static text(value) {
31
+ if (!isWellFormedUtf16(value)) {
32
+ throw new TypeError("Value.text() requires a well-formed UTF-16 string");
33
+ }
31
34
  return new Value("text", value);
32
35
  }
33
36
  static json(value) {
34
- return new Value("json", value);
37
+ return new Value("json", normalizeJsonValue(value));
35
38
  }
36
39
  static blob(value) {
37
40
  return new Value("blob", undefined, bytesToBase64(value));
@@ -43,22 +46,25 @@ export class Value {
43
46
  switch (raw.kind) {
44
47
  case "null":
45
48
  return Value.null();
46
- case "bool":
49
+ case "boolean":
47
50
  return Value.boolean(raw.value);
48
- case "int":
51
+ case "integer":
49
52
  return Value.integer(raw.value);
50
- case "float":
53
+ case "real":
51
54
  return Value.real(raw.value);
52
55
  case "text":
53
56
  return Value.text(raw.value);
54
57
  case "json":
55
- return Value.json(raw.value);
58
+ return Value.json(normalizeJsonValue(raw.value));
56
59
  case "blob":
57
60
  return new Value("blob", undefined, raw.base64);
58
61
  }
59
62
  }
60
- if (raw === null || raw === undefined)
63
+ if (raw === null)
61
64
  return Value.null();
65
+ if (raw === undefined) {
66
+ throw new TypeError("undefined is not a valid SQL parameter");
67
+ }
62
68
  if (typeof raw === "number") {
63
69
  return Number.isInteger(raw) ? Value.integer(raw) : Value.real(raw);
64
70
  }
@@ -71,29 +77,30 @@ export class Value {
71
77
  if (raw instanceof ArrayBuffer)
72
78
  return Value.blob(new Uint8Array(raw));
73
79
  if (ArrayBuffer.isView(raw)) {
74
- return Value.blob(new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength));
80
+ throw new TypeError("typed array SQL parameters must be Uint8Array; other ArrayBuffer views are ambiguous");
81
+ }
82
+ if (raw instanceof Date) {
83
+ throw new TypeError("Date is not a valid SQL parameter; pass date.toISOString() or date.getTime() explicitly");
84
+ }
85
+ if (raw && typeof raw === "object") {
86
+ return Value.json(normalizeJsonValue(raw));
75
87
  }
76
- if (isJsonValue(raw))
77
- return Value.json(raw);
78
88
  throw new TypeError("Value.from() requires a LixValue, JSON value, or binary value");
79
89
  }
80
- kindValue() {
81
- return this.kind;
82
- }
83
90
  asInteger() {
84
- return this.kind === "int" ? this.value : undefined;
91
+ return this.kind === "integer" ? this.value : undefined;
85
92
  }
86
93
  asBoolean() {
87
- return this.kind === "bool" ? this.value : undefined;
94
+ return this.kind === "boolean" ? this.value : undefined;
88
95
  }
89
96
  asReal() {
90
- return this.kind === "float" ? this.value : undefined;
97
+ return this.kind === "real" ? this.value : undefined;
91
98
  }
92
99
  asText() {
93
100
  return this.kind === "text" ? this.value : undefined;
94
101
  }
95
102
  asJson() {
96
- return this.kind === "json" ? this.value : undefined;
103
+ return this.kind === "json" ? normalizeJsonValue(this.value) : undefined;
97
104
  }
98
105
  asBlob() {
99
106
  return this.kind === "blob" && this.base64 !== undefined
@@ -104,12 +111,12 @@ export class Value {
104
111
  switch (this.kind) {
105
112
  case "null":
106
113
  return { kind: "null", value: null };
107
- case "bool":
108
- return { kind: "bool", value: this.asBoolean() ?? false };
109
- case "int":
110
- return { kind: "int", value: this.asInteger() ?? 0 };
111
- case "float":
112
- return { kind: "float", value: this.asReal() ?? 0 };
114
+ case "boolean":
115
+ return { kind: "boolean", value: this.asBoolean() ?? false };
116
+ case "integer":
117
+ return { kind: "integer", value: this.asInteger() ?? 0 };
118
+ case "real":
119
+ return { kind: "real", value: this.asReal() ?? 0 };
113
120
  case "text":
114
121
  return { kind: "text", value: this.asText() ?? "" };
115
122
  case "json":
@@ -121,12 +128,12 @@ export class Value {
121
128
  }
122
129
  /**
123
130
  * Type guard: returns `true` when `err` is a Lix-produced error carrying a
124
- * structured `code` field (all engine codes start with `LIX_ERROR_`).
131
+ * structured `code` field (all engine codes start with `LIX_`).
125
132
  */
126
133
  export function isLixError(err) {
127
134
  return (err instanceof Error &&
128
135
  typeof err.code === "string" &&
129
- err.code.startsWith("LIX_ERROR"));
136
+ err.code.startsWith("LIX_"));
130
137
  }
131
138
  function isLixValue(value) {
132
139
  if (!value || typeof value !== "object") {
@@ -136,21 +143,22 @@ function isLixValue(value) {
136
143
  if (kind === "null") {
137
144
  return value.value === null;
138
145
  }
139
- if (kind === "bool") {
146
+ if (kind === "boolean") {
140
147
  return typeof value.value === "boolean";
141
148
  }
142
- if (kind === "int" || kind === "float") {
149
+ if (kind === "integer" || kind === "real") {
143
150
  const raw = value.value;
144
151
  if (typeof raw !== "number" || !Number.isFinite(raw)) {
145
152
  return false;
146
153
  }
147
- if (kind === "int" && !Number.isInteger(raw)) {
154
+ if (kind === "integer" && !Number.isInteger(raw)) {
148
155
  return false;
149
156
  }
150
157
  return true;
151
158
  }
152
159
  if (kind === "text") {
153
- return typeof value.value === "string";
160
+ const raw = value.value;
161
+ return typeof raw === "string" && isWellFormedUtf16(raw);
154
162
  }
155
163
  if (kind === "json") {
156
164
  return isJsonValue(value.value);
@@ -161,21 +169,80 @@ function isLixValue(value) {
161
169
  return false;
162
170
  }
163
171
  function isJsonValue(value) {
164
- if (value === null ||
165
- typeof value === "boolean" ||
166
- typeof value === "string") {
172
+ try {
173
+ normalizeJsonValue(value);
167
174
  return true;
168
175
  }
176
+ catch {
177
+ return false;
178
+ }
179
+ }
180
+ function normalizeJsonValue(value, seen = new WeakSet()) {
181
+ if (value === null ||
182
+ typeof value === "boolean") {
183
+ return value;
184
+ }
185
+ if (typeof value === "string") {
186
+ if (!isWellFormedUtf16(value)) {
187
+ throw new TypeError("JSON strings must be well-formed UTF-16");
188
+ }
189
+ return value;
190
+ }
169
191
  if (typeof value === "number") {
170
- return Number.isFinite(value);
192
+ if (!Number.isFinite(value)) {
193
+ throw new TypeError("JSON numbers must be finite");
194
+ }
195
+ return value;
171
196
  }
172
197
  if (Array.isArray(value)) {
173
- return value.every((item) => isJsonValue(item));
198
+ if (seen.has(value)) {
199
+ throw new TypeError("JSON values must not contain circular references");
200
+ }
201
+ seen.add(value);
202
+ const normalized = value.map((item) => normalizeJsonValue(item, seen));
203
+ seen.delete(value);
204
+ return normalized;
174
205
  }
175
206
  if (!value || typeof value !== "object") {
176
- return false;
207
+ throw new TypeError("expected a JSON-compatible value");
208
+ }
209
+ if (value instanceof Date) {
210
+ throw new TypeError("Date is not a JSON value");
211
+ }
212
+ const prototype = Object.getPrototypeOf(value);
213
+ if (prototype !== Object.prototype && prototype !== null) {
214
+ throw new TypeError("JSON objects must be plain objects");
215
+ }
216
+ if (seen.has(value)) {
217
+ throw new TypeError("JSON values must not contain circular references");
218
+ }
219
+ seen.add(value);
220
+ const normalized = {};
221
+ for (const [key, entry] of Object.entries(value)) {
222
+ if (!isWellFormedUtf16(key)) {
223
+ throw new TypeError("JSON object keys must be well-formed UTF-16");
224
+ }
225
+ normalized[key] = normalizeJsonValue(entry, seen);
226
+ }
227
+ seen.delete(value);
228
+ return normalized;
229
+ }
230
+ function isWellFormedUtf16(value) {
231
+ for (let index = 0; index < value.length; index += 1) {
232
+ const code = value.charCodeAt(index);
233
+ if (code >= 0xd800 && code <= 0xdbff) {
234
+ const next = value.charCodeAt(index + 1);
235
+ if (next < 0xdc00 || next > 0xdfff) {
236
+ return false;
237
+ }
238
+ index += 1;
239
+ continue;
240
+ }
241
+ if (code >= 0xdc00 && code <= 0xdfff) {
242
+ return false;
243
+ }
177
244
  }
178
- return Object.values(value).every((entry) => isJsonValue(entry));
245
+ return true;
179
246
  }
180
247
  function bytesToBase64(bytes) {
181
248
  const maybeBuffer = globalThis.Buffer;
@@ -22,16 +22,28 @@ export class Lix {
22
22
  */
23
23
  createVersion(args: any): Promise<any>;
24
24
  /**
25
- * @param {string} sql
25
+ * Executes one DataFusion SQL statement against this Lix session.
26
+ *
27
+ * The SQL dialect is DataFusion SQL, not SQLite SQL. Positional
28
+ * placeholders use `$1`, `$2`, and so on. SQLite-specific catalog
29
+ * tables and transaction statements such as `sqlite_master`, `BEGIN`,
30
+ * and `COMMIT` are not part of this contract; use
31
+ * `information_schema` for catalog inspection.
32
+ * @param {any} sql
26
33
  * @param {any} params
27
34
  * @returns {Promise<any>}
28
35
  */
29
- execute(sql: string, params: any): Promise<any>;
36
+ execute(sql: any, params: any): Promise<any>;
30
37
  /**
31
38
  * @param {any} args
32
39
  * @returns {Promise<any>}
33
40
  */
34
41
  mergeVersion(args: any): Promise<any>;
42
+ /**
43
+ * @param {any} args
44
+ * @returns {Promise<any>}
45
+ */
46
+ mergeVersionPreview(args: any): Promise<any>;
35
47
  /**
36
48
  * @param {any} args
37
49
  * @returns {Promise<any>}
@@ -40,14 +40,19 @@ export class Lix {
40
40
  return ret;
41
41
  }
42
42
  /**
43
- * @param {string} sql
43
+ * Executes one DataFusion SQL statement against this Lix session.
44
+ *
45
+ * The SQL dialect is DataFusion SQL, not SQLite SQL. Positional
46
+ * placeholders use `$1`, `$2`, and so on. SQLite-specific catalog
47
+ * tables and transaction statements such as `sqlite_master`, `BEGIN`,
48
+ * and `COMMIT` are not part of this contract; use
49
+ * `information_schema` for catalog inspection.
50
+ * @param {any} sql
44
51
  * @param {any} params
45
52
  * @returns {Promise<any>}
46
53
  */
47
54
  execute(sql, params) {
48
- const ptr0 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49
- const len0 = WASM_VECTOR_LEN;
50
- const ret = wasm.lix_execute(this.__wbg_ptr, ptr0, len0, params);
55
+ const ret = wasm.lix_execute(this.__wbg_ptr, sql, params);
51
56
  return ret;
52
57
  }
53
58
  /**
@@ -58,6 +63,14 @@ export class Lix {
58
63
  const ret = wasm.lix_mergeVersion(this.__wbg_ptr, args);
59
64
  return ret;
60
65
  }
66
+ /**
67
+ * @param {any} args
68
+ * @returns {Promise<any>}
69
+ */
70
+ mergeVersionPreview(args) {
71
+ const ret = wasm.lix_mergeVersionPreview(this.__wbg_ptr, args);
72
+ return ret;
73
+ }
61
74
  /**
62
75
  * @param {any} args
63
76
  * @returns {Promise<any>}
@@ -178,18 +191,6 @@ function __wbg_get_imports() {
178
191
  return ret;
179
192
  }, arguments);
180
193
  },
181
- __wbg_call_812d25f1510c13c8: function () {
182
- return handleError(function (arg0, arg1, arg2, arg3) {
183
- const ret = arg0.call(arg1, arg2, arg3);
184
- return ret;
185
- }, arguments);
186
- },
187
- __wbg_call_e8c868596c950cf6: function () {
188
- return handleError(function (arg0, arg1, arg2, arg3, arg4) {
189
- const ret = arg0.call(arg1, arg2, arg3, arg4);
190
- return ret;
191
- }, arguments);
192
- },
193
194
  __wbg_done_57b39ecd9addfe81: function (arg0) {
194
195
  const ret = arg0.done;
195
196
  return ret;
@@ -429,7 +430,7 @@ function __wbg_get_imports() {
429
430
  return ret;
430
431
  },
431
432
  __wbindgen_cast_0000000000000001: function (arg0, arg1) {
432
- // Cast intrinsic for `Closure(Closure { dtor_idx: 2720, function: Function { arguments: [Externref], shim_idx: 2721, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
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`.
433
434
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h259bf120b5b35fc5, wasm_bindgen__convert__closures_____invoke__ha15a27e9815e3c81);
434
435
  return ret;
435
436
  },
@@ -5,8 +5,9 @@ export const __wbg_lix_free: (a: number, b: number) => void;
5
5
  export const lix_activeVersionId: (a: number) => any;
6
6
  export const lix_close: (a: number) => any;
7
7
  export const lix_createVersion: (a: number, b: any) => any;
8
- export const lix_execute: (a: number, b: number, c: number, d: any) => any;
8
+ export const lix_execute: (a: number, b: any, c: any) => any;
9
9
  export const lix_mergeVersion: (a: number, b: any) => any;
10
+ export const lix_mergeVersionPreview: (a: number, b: any) => any;
10
11
  export const lix_switchVersion: (a: number, b: any) => any;
11
12
  export const openLix: (a: number) => any;
12
13
  export const wasm_bindgen__closure__destroy__h259bf120b5b35fc5: (a: number, b: number) => void;
@@ -35,25 +35,6 @@ export declare const LixActiveAccountSchema: {
35
35
  readonly required: readonly ["account_id"];
36
36
  readonly additionalProperties: false;
37
37
  };
38
- export declare const LixActiveVersionSchema: {
39
- readonly "x-lix-key": "lix_active_version";
40
- readonly "x-lix-version": "1";
41
- readonly description: "Singleton tracking which version is currently checked out in the local runtime. Exactly one row exists at all times; writing to this surface is how clients switch versions.";
42
- readonly "x-lix-primary-key": readonly ["/id"];
43
- readonly type: "object";
44
- readonly properties: {
45
- readonly id: {
46
- readonly type: "string";
47
- readonly description: "Fixed singleton key (constant, not a UUID); the primary-key column exists to satisfy entity-model requirements and enforces the one-row invariant.";
48
- };
49
- readonly version_id: {
50
- readonly type: "string";
51
- readonly description: "The currently active version; references `lix_version_descriptor.id` and drives the default scope for reads and writes in the session.";
52
- };
53
- };
54
- readonly required: readonly ["id", "version_id"];
55
- readonly additionalProperties: false;
56
- };
57
38
  export declare const LixBinaryBlobRefSchema: {
58
39
  readonly "x-lix-key": "lix_binary_blob_ref";
59
40
  readonly "x-lix-version": "1";
@@ -81,7 +62,7 @@ export declare const LixBinaryBlobRefSchema: {
81
62
  export declare const LixChangeSchema: {
82
63
  readonly "x-lix-key": "lix_change";
83
64
  readonly "x-lix-version": "1";
84
- readonly description: "Canonical immutable change fact. This surface represents the authoritative stream of journaled change facts. Commit lineage and non-commit scope are modeled separately around these facts. The public `untracked` field is retained as convenience metadata and should not be treated as proof that trackedness is intrinsic to the canonical fact row itself.";
65
+ readonly description: "Canonical immutable change fact. This surface represents the authoritative stream of journaled change facts. Commit lineage and non-commit scope are modeled separately around these facts.";
85
66
  readonly "x-lix-primary-key": readonly ["/id"];
86
67
  readonly type: "object";
87
68
  readonly properties: {
@@ -106,10 +87,6 @@ export declare const LixChangeSchema: {
106
87
  readonly type: readonly ["string", "null"];
107
88
  readonly description: "Filesystem-scoped file identifier when the change belongs to a file; NULL for engine-internal entities (commits, versions, settings).";
108
89
  };
109
- readonly plugin_key: {
110
- readonly type: readonly ["string", "null"];
111
- readonly description: "Plugin that authored the change; NULL for engine-internal changes.";
112
- };
113
90
  readonly metadata: {
114
91
  readonly type: readonly ["object", "null"];
115
92
  readonly description: "Optional user-provided JSON metadata attached to the change; NULL when nothing was supplied.";
@@ -118,16 +95,12 @@ export declare const LixChangeSchema: {
118
95
  readonly type: "string";
119
96
  readonly description: "ISO-8601 timestamp at which the change was recorded (set via `lix_timestamp()` at write time).";
120
97
  };
121
- readonly untracked: {
122
- readonly type: "boolean";
123
- readonly description: "Public convenience field indicating that the change currently participates in non-commit visibility rather than commit lineage. This is intended to become derived metadata rather than intrinsic canonical storage truth.";
124
- };
125
98
  readonly snapshot_content: {
126
99
  readonly type: readonly ["object", "null"];
127
100
  readonly description: "Entity JSON body at this change; NULL represents a tombstone (deletion).";
128
101
  };
129
102
  };
130
- readonly required: readonly ["id", "entity_id", "schema_key", "schema_version", "file_id", "plugin_key", "created_at", "untracked"];
103
+ readonly required: readonly ["id", "entity_id", "schema_key", "schema_version", "file_id", "created_at"];
131
104
  readonly additionalProperties: false;
132
105
  };
133
106
  export declare const LixChangeAuthorSchema: {
@@ -176,7 +149,7 @@ export declare const LixChangeSetSchema: {
176
149
  export declare const LixChangeSetElementSchema: {
177
150
  readonly "x-lix-key": "lix_change_set_element";
178
151
  readonly "x-lix-version": "1";
179
- readonly description: "Derived relational index mapping a change_set to the canonical changes it contains. Rebuildable from `lix_commit.change_ids` plus the referenced `lix_change` rows; the unique constraint enforces at most one change per (entity, schema, file) tuple within a single change_set.";
152
+ readonly description: "Derived relational index mapping a change_set to the canonical changes introduced by its commit relative to the commit's first parent. Rebuildable from `lix_commit.change_ids` plus the referenced `lix_change` rows; the unique constraint enforces at most one change per (entity, schema, file) tuple within a single change_set.";
180
153
  readonly "x-lix-primary-key": readonly ["/change_set_id", "/change_id"];
181
154
  readonly "x-lix-unique": readonly [readonly ["/change_set_id", "/entity_id", "/schema_key", "/file_id"]];
182
155
  readonly "x-lix-foreign-keys": readonly [{
@@ -200,7 +173,7 @@ export declare const LixChangeSetElementSchema: {
200
173
  };
201
174
  readonly change_id: {
202
175
  readonly type: "string";
203
- readonly description: "The canonical change included in the change_set (references `lix_change.id`).";
176
+ readonly description: "The canonical change introduced/adopted by the change_set's commit (references `lix_change.id`).";
204
177
  };
205
178
  readonly entity_id: {
206
179
  readonly type: "string";
@@ -221,7 +194,7 @@ export declare const LixChangeSetElementSchema: {
221
194
  export declare const LixCommitSchema: {
222
195
  readonly "x-lix-key": "lix_commit";
223
196
  readonly "x-lix-version": "1";
224
- readonly description: "Commit header change. Canonical commit membership is stored in change_ids as the ordered list of non-header member changes for this commit. Derived projections such as lix_change_set_element must be rebuildable from this header plus the referenced change rows. Version head pointers such as lix_version_ref are maintained separately and are not commit members.";
197
+ readonly description: "Commit header change. Canonical commit membership is stored in change_ids as the ordered list of canonical changes whose effects this commit introduces relative to its first parent. A merge commit may reference canonical changes originally authored in another parent instead of copying them. Derived projections such as lix_change_set_element must be rebuildable from this header plus the referenced change rows. Version head pointers such as lix_version_ref are maintained separately and are not commit members.";
225
198
  readonly "x-lix-primary-key": readonly ["/id"];
226
199
  readonly "x-lix-foreign-keys": readonly [{
227
200
  readonly properties: readonly ["/change_set_id"];
@@ -247,7 +220,7 @@ export declare const LixCommitSchema: {
247
220
  readonly items: {
248
221
  readonly type: "string";
249
222
  };
250
- readonly description: "Canonical ordered membership list of non-header change IDs that belong to this commit. Derived indexes such as lix_change_set_element must be rebuildable from this list. This does not include lix_version_ref pointer rows.";
223
+ readonly description: "Canonical ordered membership list of non-header change IDs whose effects this commit introduces relative to its first parent. Merge commits may reference existing changes from another parent instead of minting equivalent copies. Derived indexes such as lix_change_set_element must be rebuildable from this list. This does not include lix_version_ref pointer rows.";
251
224
  };
252
225
  readonly author_account_ids: {
253
226
  readonly type: "array";
@@ -303,6 +276,13 @@ export declare const LixDirectoryDescriptorSchema: {
303
276
  readonly "x-lix-version": "1";
304
277
  readonly "x-lix-primary-key": readonly ["/id"];
305
278
  readonly "x-lix-unique": readonly [readonly ["/parent_id", "/name"]];
279
+ readonly "x-lix-foreign-keys": readonly [{
280
+ readonly properties: readonly ["/parent_id"];
281
+ readonly references: {
282
+ readonly schemaKey: "lix_directory_descriptor";
283
+ readonly properties: readonly ["/id"];
284
+ };
285
+ }];
306
286
  readonly type: "object";
307
287
  readonly properties: {
308
288
  readonly id: {
@@ -363,7 +343,14 @@ export declare const LixFileDescriptorSchema: {
363
343
  readonly "x-lix-key": "lix_file_descriptor";
364
344
  readonly "x-lix-version": "1";
365
345
  readonly "x-lix-primary-key": readonly ["/id"];
366
- readonly "x-lix-unique": readonly [readonly ["/directory_id", "/name", "/extension"]];
346
+ readonly "x-lix-unique": readonly [readonly ["/directory_id", "/name"]];
347
+ readonly "x-lix-foreign-keys": readonly [{
348
+ readonly properties: readonly ["/directory_id"];
349
+ readonly references: {
350
+ readonly schemaKey: "lix_directory_descriptor";
351
+ readonly properties: readonly ["/id"];
352
+ };
353
+ }];
367
354
  readonly type: "object";
368
355
  readonly properties: {
369
356
  readonly id: {
@@ -375,18 +362,14 @@ export declare const LixFileDescriptorSchema: {
375
362
  };
376
363
  readonly name: {
377
364
  readonly type: "string";
378
- readonly pattern: "^[^/\\\\]+$";
379
- };
380
- readonly extension: {
381
- readonly type: readonly ["string", "null"];
382
- readonly pattern: "^[^./\\\\]+$";
365
+ readonly pattern: "^(?!\\.{1,2}$)[^/\\\\]+$";
383
366
  };
384
367
  readonly hidden: {
385
368
  readonly type: "boolean";
386
369
  readonly "x-lix-default": "false";
387
370
  };
388
371
  };
389
- readonly required: readonly ["id", "directory_id", "name", "extension"];
372
+ readonly required: readonly ["id", "directory_id", "name"];
390
373
  readonly additionalProperties: false;
391
374
  };
392
375
  export declare const LixKeyValueSchema: {
@@ -463,12 +446,13 @@ export declare const LixVersionDescriptorSchema: {
463
446
  readonly "x-lix-version": "1";
464
447
  readonly description: "User-facing version metadata (name and visibility) for a branch-like version. The stable identity of a version; the matching `lix_version_ref` carries the moving head pointer. The catalog's `lix_version` surface joins this descriptor with its ref to present a single user-visible version row.";
465
448
  readonly "x-lix-primary-key": readonly ["/id"];
449
+ readonly "x-lix-unique": readonly [readonly ["/name"]];
466
450
  readonly type: "object";
467
451
  readonly properties: {
468
452
  readonly id: {
469
453
  readonly type: "string";
470
454
  readonly "x-lix-default": "lix_uuid_v7()";
471
- readonly description: "Stable version identifier (UUIDv7). Referenced by `lix_version_ref.id` and `lix_active_version.version_id`.";
455
+ readonly description: "Stable version identifier (UUIDv7). Referenced by `lix_version_ref.id`.";
472
456
  };
473
457
  readonly name: {
474
458
  readonly type: "string";
@@ -489,6 +473,12 @@ export declare const LixVersionRefSchema: {
489
473
  readonly description: "Version head pointer. Records which commit a version should currently resolve to in the local runtime. Intentionally not part of canonical commit membership: refs may be reset client-side after sync without introducing content conflicts. Each `lix_version_descriptor.id` has exactly one `lix_version_ref` row.";
490
474
  readonly "x-lix-primary-key": readonly ["/id"];
491
475
  readonly "x-lix-foreign-keys": readonly [{
476
+ readonly properties: readonly ["/id"];
477
+ readonly references: {
478
+ readonly schemaKey: "lix_version_descriptor";
479
+ readonly properties: readonly ["/id"];
480
+ };
481
+ }, {
492
482
  readonly properties: readonly ["/commit_id"];
493
483
  readonly references: {
494
484
  readonly schemaKey: "lix_commit";