@xanots/sdk 0.0.10 → 0.0.11

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 (53) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +38 -0
  3. package/dist/.build-fingerprint +1 -1
  4. package/dist/bin.js +7 -6
  5. package/dist/bundle.d.ts +218 -0
  6. package/dist/bundle.js +143 -0
  7. package/dist/{chunk-5YCQ2QHH.js → chunk-22TKBSDV.js} +2 -2
  8. package/dist/{chunk-YYFXVYPX.js → chunk-4IF54NU5.js} +3 -3
  9. package/dist/{chunk-W24FJHPD.js → chunk-4Q7ZOHH7.js} +2 -2
  10. package/dist/{chunk-4BXJGVZ3.js → chunk-BC2C5GVI.js} +2 -69
  11. package/dist/chunk-BSK7ELHU.js +70 -0
  12. package/dist/chunk-EHP3WPEG.js +21 -0
  13. package/dist/{chunk-75Z74TA7.js → chunk-G4EJMQLD.js} +2 -2
  14. package/dist/{chunk-I7DQDJAM.js → chunk-HYBN4H3F.js} +38 -46
  15. package/dist/chunk-OHX6MIUZ.js +184 -0
  16. package/dist/{chunk-VKSOTZK3.js → chunk-OWGCOGKK.js} +155 -3
  17. package/dist/{chunk-LBYWGMOA.js → chunk-QK7ZQJLP.js} +140 -20
  18. package/dist/{chunk-5R73LFWK.js → chunk-QYMAZRAU.js} +7 -7
  19. package/dist/{chunk-ACCBOMCB.js → chunk-RCT7UX7B.js} +12 -12
  20. package/dist/{chunk-P6TAVLOX.js → chunk-UOZMSF4C.js} +15 -8
  21. package/dist/{chunk-7JDT4PBU.js → chunk-VAF6A3YD.js} +5 -179
  22. package/dist/{chunk-OYMR5AMJ.js → chunk-XEOX6AM7.js} +2 -2
  23. package/dist/cli.js +6 -5
  24. package/dist/{codegen-command-GB3H2KQ7.js → codegen-command-FUT2KJB6.js} +15 -12
  25. package/dist/codegen.d.ts +2 -1
  26. package/dist/{deploy-command-QTIVA22A.js → deploy-command-IP7V7GT4.js} +8 -7
  27. package/dist/index.d.ts +6 -4
  28. package/dist/index.js +10 -9
  29. package/dist/{init-command-MAXULNAD.js → init-command-NPVL32L6.js} +8 -7
  30. package/dist/internal.d.ts +4 -4
  31. package/dist/internal.js +62 -40
  32. package/dist/io-P2H75UV2.js +12 -0
  33. package/dist/{lock-GFXD6G2E.js → lock-46FWYE4D.js} +3 -2
  34. package/dist/{lock-commands-DQ7CUMIV.js → lock-commands-ZZKZ4LZJ.js} +8 -7
  35. package/dist/node.d.ts +5 -4
  36. package/dist/node.js +12 -11
  37. package/dist/{preflight-command-GZ2GE5RN.js → preflight-command-K346GPTY.js} +8 -7
  38. package/dist/{release-command-YUBTNHVX.js → release-command-IMNTIVWK.js} +14 -13
  39. package/dist/response-BQVQ24l1.d.ts +844 -0
  40. package/dist/{store-BG1UPZ3Z.d.ts → store-BLyNeQ8S.d.ts} +16 -3
  41. package/dist/{upgrade-command-FB5QJ363.js → upgrade-command-BN3EHAOI.js} +8 -7
  42. package/dist/{workspace-command-43P42FBP.js → workspace-command-MNK7Y7MQ.js} +15 -12
  43. package/dist/{response-CVAE2kMj.d.ts → xdo-BjJj5W_E.d.ts} +1 -837
  44. package/guides/typed-frontend.md +1 -1
  45. package/llms/filters.md +11 -10
  46. package/llms/kinds-core.md +1 -1
  47. package/llms/statements-data.md +3 -1
  48. package/llms/values.md +1 -1
  49. package/llms-full.txt +41 -30
  50. package/llms.txt +25 -17
  51. package/manifest.json +2 -2
  52. package/package.json +7 -2
  53. package/dist/io-M7XZEMK7.js +0 -11
@@ -0,0 +1,21 @@
1
+ // src/bundle/schema.ts
2
+ function tableRefOf(column) {
3
+ if (column.type !== "int" && column.type !== "uuid") return null;
4
+ const last = column.methods?.[column.methods.length - 1];
5
+ const arg = last?.name === "@" ? last.arg?.[0] : void 0;
6
+ if (typeof arg !== "string" || !arg.startsWith("dbo=")) return null;
7
+ const guid = arg.slice("dbo=".length);
8
+ return guid === "" ? null : guid;
9
+ }
10
+ function linkedTableOf(column) {
11
+ const suffix = "_mvpschema";
12
+ if (typeof column.type !== "string" || !column.type.endsWith(suffix)) return null;
13
+ const guid = column.type.slice(0, -suffix.length);
14
+ return guid === "" ? null : guid;
15
+ }
16
+
17
+ export {
18
+ tableRefOf,
19
+ linkedTableOf
20
+ };
21
+ //# sourceMappingURL=chunk-EHP3WPEG.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  c,
3
3
  resp
4
- } from "./chunk-LBYWGMOA.js";
4
+ } from "./chunk-QK7ZQJLP.js";
5
5
 
6
6
  // src/values/expect.ts
7
7
  var TEST_EXPECT_TYPES = [
@@ -90,4 +90,4 @@ export {
90
90
  TEST_EXPECT_TYPES,
91
91
  expect
92
92
  };
93
- //# sourceMappingURL=chunk-75Z74TA7.js.map
93
+ //# sourceMappingURL=chunk-G4EJMQLD.js.map
@@ -1,21 +1,3 @@
1
- import {
2
- ENGINE_HISTORY_LIMIT,
3
- clearLocalDboRefs,
4
- configuredDeadReturnBlocks,
5
- filledContext,
6
- hasNoListBounds,
7
- hasUnreadableInput,
8
- isBlankAgentSettings,
9
- isBlankGroupStatement,
10
- isDeadResultItem,
11
- isDefaultEnvelopeMember,
12
- isEmptyCustomize,
13
- isEmptyOutput,
14
- liveArrayMapContext,
15
- normalize,
16
- retiredInputSuccessor,
17
- retiredInputs
18
- } from "./chunk-3INK4Y4E.js";
19
1
  import {
20
2
  resolveEphemeralName
21
3
  } from "./chunk-ZQ2PKR6R.js";
@@ -30,7 +12,7 @@ import {
30
12
  resolveFrontendPreset,
31
13
  resolveThemeChoice,
32
14
  sanitizeAppName
33
- } from "./chunk-YYFXVYPX.js";
15
+ } from "./chunk-4IF54NU5.js";
34
16
  import {
35
17
  XANO_DIR,
36
18
  resolveAiPresets,
@@ -38,7 +20,7 @@ import {
38
20
  } from "./chunk-KA6G2L7U.js";
39
21
  import {
40
22
  TEST_EXPECT_TYPES
41
- } from "./chunk-75Z74TA7.js";
23
+ } from "./chunk-G4EJMQLD.js";
42
24
  import {
43
25
  raw
44
26
  } from "./chunk-LU7TRWMC.js";
@@ -50,11 +32,9 @@ import {
50
32
  } from "./chunk-ANUDXFEX.js";
51
33
  import {
52
34
  FIELD_METHODS,
53
- STATEMENT_SURFACES,
54
35
  SUPERSEDED_STATEMENTS,
55
- sPathOf,
56
36
  supersededBy
57
- } from "./chunk-4BXJGVZ3.js";
37
+ } from "./chunk-BSK7ELHU.js";
58
38
  import {
59
39
  DEFAULT_PREFERENCES,
60
40
  DEFAULT_SETTINGS,
@@ -70,11 +50,37 @@ import {
70
50
  searchConstrainsRows,
71
51
  tableTrigger,
72
52
  workspaceTrigger
73
- } from "./chunk-P6TAVLOX.js";
53
+ } from "./chunk-UOZMSF4C.js";
54
+ import {
55
+ linkedTableOf,
56
+ tableRefOf
57
+ } from "./chunk-EHP3WPEG.js";
58
+ import {
59
+ ENGINE_HISTORY_LIMIT,
60
+ clearLocalDboRefs,
61
+ configuredDeadReturnBlocks,
62
+ filledContext,
63
+ hasNoListBounds,
64
+ hasUnreadableInput,
65
+ isBlankAgentSettings,
66
+ isBlankGroupStatement,
67
+ isDeadResultItem,
68
+ isDefaultEnvelopeMember,
69
+ isEmptyCustomize,
70
+ isEmptyOutput,
71
+ liveArrayMapContext,
72
+ normalize,
73
+ retiredInputSuccessor,
74
+ retiredInputs
75
+ } from "./chunk-3INK4Y4E.js";
76
+ import {
77
+ STATEMENT_SURFACES,
78
+ sPathOf
79
+ } from "./chunk-BC2C5GVI.js";
74
80
  import {
75
81
  loadDefault,
76
82
  readVersion
77
- } from "./chunk-ACCBOMCB.js";
83
+ } from "./chunk-RCT7UX7B.js";
78
84
  import {
79
85
  UsageError
80
86
  } from "./chunk-F6CYJ7TN.js";
@@ -118,11 +124,14 @@ import {
118
124
  sys,
119
125
  toolset,
120
126
  withFilters
121
- } from "./chunk-LBYWGMOA.js";
127
+ } from "./chunk-QK7ZQJLP.js";
122
128
  import {
123
129
  parsePathParams,
124
130
  unboundPathParams
125
131
  } from "./chunk-WHOJWOSV.js";
132
+ import {
133
+ REFERENCEABLE_KIND_PAYLOAD_KEYS
134
+ } from "./chunk-VAF6A3YD.js";
126
135
  import {
127
136
  COLUMN_CONTEXT,
128
137
  INPUT_CONTEXT,
@@ -131,9 +140,6 @@ import {
131
140
  encodeMockMap,
132
141
  encodeStatement
133
142
  } from "./chunk-5XZ744TS.js";
134
- import {
135
- REFERENCEABLE_KIND_PAYLOAD_KEYS
136
- } from "./chunk-7JDT4PBU.js";
137
143
 
138
144
  // src/emit/codegen-command.ts
139
145
  import { existsSync, readFileSync, writeFileSync } from "fs";
@@ -1681,20 +1687,6 @@ function recoverOptions(stored, includeDescription, elide = true) {
1681
1687
  function storedChildren(stored) {
1682
1688
  return stored.children ?? [];
1683
1689
  }
1684
- function dbLinkTableGuid(stored) {
1685
- const suffix = "_mvpschema";
1686
- if (typeof stored.type !== "string" || !stored.type.endsWith(suffix)) return null;
1687
- const guid = stored.type.slice(0, -suffix.length);
1688
- return guid === "" ? null : guid;
1689
- }
1690
- function tableRefGuid(stored) {
1691
- if (stored.type !== "int" && stored.type !== "uuid") return null;
1692
- const last = stored.methods?.[stored.methods.length - 1];
1693
- const arg = last?.name === "@" ? last.arg?.[0] : void 0;
1694
- if (typeof arg !== "string" || !arg.startsWith("dbo=")) return null;
1695
- const guid = arg.slice("dbo=".length);
1696
- return guid === "" ? null : guid;
1697
- }
1698
1690
  function unbindLocalCustomizeRefs(stored) {
1699
1691
  const customize = stored.customize;
1700
1692
  if (customize === null || typeof customize !== "object") return { field: stored, unbound: [] };
@@ -1782,7 +1774,7 @@ function decodeField(ctx, refs, stored, surface, resolve2 = {}) {
1782
1774
  return null;
1783
1775
  };
1784
1776
  const catalog = surface === "input" ? input : f;
1785
- const dbLinkGuid = dbLinkTableGuid(stored);
1777
+ const dbLinkGuid = linkedTableOf(stored);
1786
1778
  if (dbLinkGuid !== null && surface === "input") {
1787
1779
  const rest = { ...opts };
1788
1780
  delete rest.merge;
@@ -1797,7 +1789,7 @@ function decodeField(ctx, refs, stored, surface, resolve2 = {}) {
1797
1789
  );
1798
1790
  if (decoded) return decoded;
1799
1791
  }
1800
- const refGuid = tableRefGuid(stored);
1792
+ const refGuid = tableRefOf(stored);
1801
1793
  if (refGuid !== null) {
1802
1794
  const withoutRef = { ...opts, methods: opts.methods.slice(0, -1) };
1803
1795
  if (withoutRef.methods.length === 0) delete withoutRef.methods;
@@ -7016,4 +7008,4 @@ export {
7016
7008
  verifyCrashEntry,
7017
7009
  blameGeneratedFile
7018
7010
  };
7019
- //# sourceMappingURL=chunk-I7DQDJAM.js.map
7011
+ //# sourceMappingURL=chunk-HYBN4H3F.js.map
@@ -0,0 +1,184 @@
1
+ // src/util/hash.ts
2
+ var utf8 = new TextEncoder();
3
+ function toBytes(input) {
4
+ return typeof input === "string" ? utf8.encode(input) : input;
5
+ }
6
+ function md5Bytes(input) {
7
+ const msg = toBytes(input);
8
+ const len = msg.length;
9
+ const withPad = (len + 8 >>> 6) + 1;
10
+ const words = new Int32Array(withPad * 16);
11
+ for (let i = 0; i < len; i++) {
12
+ const idx = i >> 2;
13
+ words[idx] = words[idx] | msg[i] << i % 4 * 8;
14
+ }
15
+ const padIdx = len >> 2;
16
+ words[padIdx] = words[padIdx] | 128 << len % 4 * 8;
17
+ words[words.length - 2] = len * 8;
18
+ let a = 1732584193, b = -271733879, c = -1732584194, d = 271733878;
19
+ const add = (x, y) => x + y | 0;
20
+ const rol = (n, s) => n << s | n >>> 32 - s;
21
+ const cmn = (q, a0, b0, x, s, t) => add(rol(add(add(a0, q), add(x, t)), s), b0);
22
+ const ff = (a0, b0, c0, d0, x, s, t) => cmn(b0 & c0 | ~b0 & d0, a0, b0, x, s, t);
23
+ const gg = (a0, b0, c0, d0, x, s, t) => cmn(b0 & d0 | c0 & ~d0, a0, b0, x, s, t);
24
+ const hh = (a0, b0, c0, d0, x, s, t) => cmn(b0 ^ c0 ^ d0, a0, b0, x, s, t);
25
+ const ii = (a0, b0, c0, d0, x, s, t) => cmn(c0 ^ (b0 | ~d0), a0, b0, x, s, t);
26
+ for (let i = 0; i < words.length; i += 16) {
27
+ const oa = a, ob = b, oc = c, od = d;
28
+ const w = (j) => words[i + j];
29
+ a = ff(a, b, c, d, w(0), 7, -680876936);
30
+ d = ff(d, a, b, c, w(1), 12, -389564586);
31
+ c = ff(c, d, a, b, w(2), 17, 606105819);
32
+ b = ff(b, c, d, a, w(3), 22, -1044525330);
33
+ a = ff(a, b, c, d, w(4), 7, -176418897);
34
+ d = ff(d, a, b, c, w(5), 12, 1200080426);
35
+ c = ff(c, d, a, b, w(6), 17, -1473231341);
36
+ b = ff(b, c, d, a, w(7), 22, -45705983);
37
+ a = ff(a, b, c, d, w(8), 7, 1770035416);
38
+ d = ff(d, a, b, c, w(9), 12, -1958414417);
39
+ c = ff(c, d, a, b, w(10), 17, -42063);
40
+ b = ff(b, c, d, a, w(11), 22, -1990404162);
41
+ a = ff(a, b, c, d, w(12), 7, 1804603682);
42
+ d = ff(d, a, b, c, w(13), 12, -40341101);
43
+ c = ff(c, d, a, b, w(14), 17, -1502002290);
44
+ b = ff(b, c, d, a, w(15), 22, 1236535329);
45
+ a = gg(a, b, c, d, w(1), 5, -165796510);
46
+ d = gg(d, a, b, c, w(6), 9, -1069501632);
47
+ c = gg(c, d, a, b, w(11), 14, 643717713);
48
+ b = gg(b, c, d, a, w(0), 20, -373897302);
49
+ a = gg(a, b, c, d, w(5), 5, -701558691);
50
+ d = gg(d, a, b, c, w(10), 9, 38016083);
51
+ c = gg(c, d, a, b, w(15), 14, -660478335);
52
+ b = gg(b, c, d, a, w(4), 20, -405537848);
53
+ a = gg(a, b, c, d, w(9), 5, 568446438);
54
+ d = gg(d, a, b, c, w(14), 9, -1019803690);
55
+ c = gg(c, d, a, b, w(3), 14, -187363961);
56
+ b = gg(b, c, d, a, w(8), 20, 1163531501);
57
+ a = gg(a, b, c, d, w(13), 5, -1444681467);
58
+ d = gg(d, a, b, c, w(2), 9, -51403784);
59
+ c = gg(c, d, a, b, w(7), 14, 1735328473);
60
+ b = gg(b, c, d, a, w(12), 20, -1926607734);
61
+ a = hh(a, b, c, d, w(5), 4, -378558);
62
+ d = hh(d, a, b, c, w(8), 11, -2022574463);
63
+ c = hh(c, d, a, b, w(11), 16, 1839030562);
64
+ b = hh(b, c, d, a, w(14), 23, -35309556);
65
+ a = hh(a, b, c, d, w(1), 4, -1530992060);
66
+ d = hh(d, a, b, c, w(4), 11, 1272893353);
67
+ c = hh(c, d, a, b, w(7), 16, -155497632);
68
+ b = hh(b, c, d, a, w(10), 23, -1094730640);
69
+ a = hh(a, b, c, d, w(13), 4, 681279174);
70
+ d = hh(d, a, b, c, w(0), 11, -358537222);
71
+ c = hh(c, d, a, b, w(3), 16, -722521979);
72
+ b = hh(b, c, d, a, w(6), 23, 76029189);
73
+ a = hh(a, b, c, d, w(9), 4, -640364487);
74
+ d = hh(d, a, b, c, w(12), 11, -421815835);
75
+ c = hh(c, d, a, b, w(15), 16, 530742520);
76
+ b = hh(b, c, d, a, w(2), 23, -995338651);
77
+ a = ii(a, b, c, d, w(0), 6, -198630844);
78
+ d = ii(d, a, b, c, w(7), 10, 1126891415);
79
+ c = ii(c, d, a, b, w(14), 15, -1416354905);
80
+ b = ii(b, c, d, a, w(5), 21, -57434055);
81
+ a = ii(a, b, c, d, w(12), 6, 1700485571);
82
+ d = ii(d, a, b, c, w(3), 10, -1894986606);
83
+ c = ii(c, d, a, b, w(10), 15, -1051523);
84
+ b = ii(b, c, d, a, w(1), 21, -2054922799);
85
+ a = ii(a, b, c, d, w(8), 6, 1873313359);
86
+ d = ii(d, a, b, c, w(15), 10, -30611744);
87
+ c = ii(c, d, a, b, w(6), 15, -1560198380);
88
+ b = ii(b, c, d, a, w(13), 21, 1309151649);
89
+ a = ii(a, b, c, d, w(4), 6, -145523070);
90
+ d = ii(d, a, b, c, w(11), 10, -1120210379);
91
+ c = ii(c, d, a, b, w(2), 15, 718787259);
92
+ b = ii(b, c, d, a, w(9), 21, -343485551);
93
+ a = add(a, oa);
94
+ b = add(b, ob);
95
+ c = add(c, oc);
96
+ d = add(d, od);
97
+ }
98
+ const out = new Uint8Array(16);
99
+ [a, b, c, d].forEach((word, wi) => {
100
+ for (let j = 0; j < 4; j++) out[wi * 4 + j] = word >>> j * 8 & 255;
101
+ });
102
+ return out;
103
+ }
104
+ function md5Hex(input) {
105
+ return toHex(md5Bytes(input));
106
+ }
107
+ function sha1Bytes(input) {
108
+ const msg = toBytes(input);
109
+ const len = msg.length;
110
+ const withLen = len + 9;
111
+ const blocks = Math.ceil(withLen / 64);
112
+ const total = blocks * 64;
113
+ const buf = new Uint8Array(total);
114
+ buf.set(msg);
115
+ buf[len] = 128;
116
+ const bitLen = len * 8;
117
+ buf[total - 4] = bitLen >>> 24 & 255;
118
+ buf[total - 3] = bitLen >>> 16 & 255;
119
+ buf[total - 2] = bitLen >>> 8 & 255;
120
+ buf[total - 1] = bitLen & 255;
121
+ let h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878, h4 = -1009589776;
122
+ const w = new Int32Array(80);
123
+ const rol = (n, s) => n << s | n >>> 32 - s;
124
+ for (let i = 0; i < total; i += 64) {
125
+ for (let j = 0; j < 16; j++) {
126
+ const k = i + j * 4;
127
+ w[j] = buf[k] << 24 | buf[k + 1] << 16 | buf[k + 2] << 8 | buf[k + 3];
128
+ }
129
+ for (let j = 16; j < 80; j++) w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
130
+ let a = h0, b = h1, c = h2, d = h3, e = h4;
131
+ for (let j = 0; j < 80; j++) {
132
+ let f, k;
133
+ if (j < 20) {
134
+ f = b & c | ~b & d;
135
+ k = 1518500249;
136
+ } else if (j < 40) {
137
+ f = b ^ c ^ d;
138
+ k = 1859775393;
139
+ } else if (j < 60) {
140
+ f = b & c | b & d | c & d;
141
+ k = -1894007588;
142
+ } else {
143
+ f = b ^ c ^ d;
144
+ k = -899497514;
145
+ }
146
+ const t = rol(a, 5) + f + e + k + w[j] | 0;
147
+ e = d;
148
+ d = c;
149
+ c = rol(b, 30);
150
+ b = a;
151
+ a = t;
152
+ }
153
+ h0 = h0 + a | 0;
154
+ h1 = h1 + b | 0;
155
+ h2 = h2 + c | 0;
156
+ h3 = h3 + d | 0;
157
+ h4 = h4 + e | 0;
158
+ }
159
+ const out = new Uint8Array(20);
160
+ [h0, h1, h2, h3, h4].forEach((h, hi) => {
161
+ out[hi * 4] = h >>> 24 & 255;
162
+ out[hi * 4 + 1] = h >>> 16 & 255;
163
+ out[hi * 4 + 2] = h >>> 8 & 255;
164
+ out[hi * 4 + 3] = h & 255;
165
+ });
166
+ return out;
167
+ }
168
+ function toHex(bytes) {
169
+ let s = "";
170
+ for (const b of bytes) s += b.toString(16).padStart(2, "0");
171
+ return s;
172
+ }
173
+ function randomBytes(n) {
174
+ const out = new Uint8Array(n);
175
+ globalThis.crypto.getRandomValues(out);
176
+ return out;
177
+ }
178
+
179
+ export {
180
+ md5Hex,
181
+ sha1Bytes,
182
+ randomBytes
183
+ };
184
+ //# sourceMappingURL=chunk-OHX6MIUZ.js.map
@@ -10,9 +10,10 @@ import {
10
10
  isQueryExpressionFilter,
11
11
  isSeedFileSource,
12
12
  middlewareEntryGuid,
13
+ reversedRegexOperands,
13
14
  stackReferencesAuth,
14
15
  tableColumns
15
- } from "./chunk-LBYWGMOA.js";
16
+ } from "./chunk-QK7ZQJLP.js";
16
17
  import {
17
18
  CANONICAL_PAYLOAD_KEYS,
18
19
  REFERENCEABLE_KINDS,
@@ -25,7 +26,7 @@ import {
25
26
  mintCanonical,
26
27
  recordObserved,
27
28
  resolveRef
28
- } from "./chunk-7JDT4PBU.js";
29
+ } from "./chunk-VAF6A3YD.js";
29
30
 
30
31
  // src/workspace/seed-coerce.ts
31
32
  function coerceScalarValue(label, column, type, value, values) {
@@ -295,6 +296,91 @@ function checkInternalColumnReads(statements, owner, tablesByGuid, bag) {
295
296
  );
296
297
  }
297
298
  }
299
+ var DB_GET_BY_ID = "mvp:dbo_get";
300
+ var ROW_BINDING_STATEMENTS = /* @__PURE__ */ new Set([DB_GET, DB_GET_BY_ID]);
301
+ var INT_COLUMN_TYPES = /* @__PURE__ */ new Set(["int"]);
302
+ function isZeroDefault(value) {
303
+ return value === 0 || value === "0";
304
+ }
305
+ function checkGetByIdZero(record, statements, owner, tablesByGuid, bag) {
306
+ const zeroDefaultInputs = /* @__PURE__ */ new Set();
307
+ if (Array.isArray(record.input)) {
308
+ for (const entry of record.input) {
309
+ const declared = entry;
310
+ if (typeof declared?.name === "string" && isZeroDefault(declared.default)) {
311
+ zeroDefaultInputs.add(declared.name);
312
+ }
313
+ }
314
+ }
315
+ const bindings = /* @__PURE__ */ new Map();
316
+ for (const statement of statements) {
317
+ if (!ROW_BINDING_STATEMENTS.has(statement.name)) continue;
318
+ const as = statement.as;
319
+ if (typeof as !== "string" || as === "") continue;
320
+ const guid = statementTableGuid(statement);
321
+ const def = guid === void 0 ? void 0 : tablesByGuid.get(guid);
322
+ if (def) bindings.set(as, def);
323
+ }
324
+ const tested = /* @__PURE__ */ new Set();
325
+ for (const statement of statements) {
326
+ walkNodes(statement, (node) => {
327
+ if (typeof node.operand === "string") tested.add(node.operand);
328
+ });
329
+ }
330
+ const reported = /* @__PURE__ */ new Set();
331
+ for (const statement of statements) {
332
+ if (statement.name !== DB_GET_BY_ID || !Array.isArray(statement.input)) continue;
333
+ for (const entry of statement.input) {
334
+ const cell = entry;
335
+ if (cell?.name !== "id") continue;
336
+ if (Array.isArray(cell.filters) && cell.filters.length > 0) continue;
337
+ const source = zeroIdSource(cell, zeroDefaultInputs, bindings);
338
+ if (!source) continue;
339
+ if (source.reference !== void 0 && tested.has(source.reference)) continue;
340
+ if (reported.has(source.key)) continue;
341
+ reported.add(source.key);
342
+ bag.warn(
343
+ "db.get-by-id-zero",
344
+ `${owner}: the \`id\` of \`s.db.get_by_id\` ${source.because}, and the engine validates that key as \`>= 1\` \u2014 a \`0\` does not miss, it fails the whole request with HTTP 400 \`Value is less than the minimum value of 1\` naming a \`param\` the caller never sent. Inside a \`foreach\` that 400 ends the request, so one unset key loses every other row's work. Read a nullable foreign key with the field-match form, which binds \`null\` on \`0\` instead: \`s.db.get({ table, fieldName: "id", fieldValue: ${source.operand}, as })\`.`
345
+ );
346
+ }
347
+ }
348
+ }
349
+ function zeroIdSource(cell, zeroDefaultInputs, bindings) {
350
+ const value = typeof cell.value === "string" ? cell.value : "";
351
+ if ((cell.tag === "const:int" || cell.tag === "const:decimal") && Number(value) === 0) {
352
+ return {
353
+ key: "literal:0",
354
+ because: "is the literal `c.int(0)`",
355
+ operand: "c.int(0)"
356
+ };
357
+ }
358
+ if (cell.tag === "input" && zeroDefaultInputs.has(inputBase(value))) {
359
+ return {
360
+ key: `input:${value}`,
361
+ reference: value,
362
+ because: `is \`inp("${value}")\`, whose declared input default is \`0\` \u2014 an omitted input stands the sentinel up with nobody having written it`,
363
+ operand: `inp("${value}")`
364
+ };
365
+ }
366
+ if (cell.tag === "var") {
367
+ const dot = value.indexOf(".");
368
+ if (dot > 0) {
369
+ const def = bindings.get(value.slice(0, dot));
370
+ const column = value.slice(dot + 1);
371
+ const col = def && tableColumns(def).find((candidate) => candidate.name === column);
372
+ if (col && INT_COLUMN_TYPES.has(col.type) && isZeroDefault(col.default)) {
373
+ return {
374
+ key: `var:${value}`,
375
+ reference: value,
376
+ because: `is \`ref("${value}")\`, and "${column}" on table "${def.name}" is declared \`default: 0\` \u2014 every row that never set the link carries the sentinel`,
377
+ operand: `ref("${value}")`
378
+ };
379
+ }
380
+ }
381
+ }
382
+ return null;
383
+ }
298
384
  function collectInputRefs(node, out) {
299
385
  walkNodes(node, (record) => {
300
386
  if (record.tag !== "input") return;
@@ -435,6 +521,7 @@ function checkStacks(tables, sections, bag) {
435
521
  }
436
522
  }
437
523
  checkInternalColumnReads(statements, owner, tablesByGuid, bag);
524
+ checkGetByIdZero(obj, statements, owner, tablesByGuid, bag);
438
525
  }
439
526
  }
440
527
  }
@@ -493,6 +580,28 @@ function checkInterpolatedValues(sections, bag) {
493
580
  }
494
581
  }
495
582
  }
583
+ function checkRegexOperandOrder(sections, bag) {
584
+ for (const [payloadKey, arr] of Object.entries(sections)) {
585
+ for (const obj of arr ?? []) {
586
+ if (!obj || typeof obj !== "object") continue;
587
+ const name = obj.name;
588
+ const seen = /* @__PURE__ */ new Set();
589
+ walkNodes(obj, (record) => {
590
+ if (typeof record.tag !== "string" || typeof record.value !== "string") return;
591
+ if (!Array.isArray(record.filters)) return;
592
+ const reversed = reversedRegexOperands(record);
593
+ if (!reversed) return;
594
+ seen.add(`\`${reversed.filter}\` (pattern ${JSON.stringify(reversed.subject)})`);
595
+ });
596
+ if (seen.size === 0) continue;
597
+ const owner = `${payloadKey} "${typeof name === "string" ? name : "?"}"`;
598
+ bag.warn(
599
+ "value.regex-operands-reversed",
600
+ `${owner} pipes a regex filter's SUBJECT and passes its PATTERN as the argument: ${[...seen].join("; ")}. The regex family is pattern-piped \u2014 the piped value is the PATTERN and the argument is the text tested against it, the reverse of every other filter \u2014 so this answers false for every input with HTTP 200 and no error, and a precondition built on it lets through the values it exists to refuse. Swap the operands: \`withFilters(c.regex(\u2026), fl.regex_test(subject))\`.`
601
+ );
602
+ }
603
+ }
604
+ }
496
605
  function checkSeed(tables, bag) {
497
606
  for (const def of tables) {
498
607
  const source = def.seed;
@@ -506,6 +615,18 @@ function checkSeed(tables, bag) {
506
615
  }
507
616
  }
508
617
  }
618
+ var RESERVED_COLUMN_NAMES = /* @__PURE__ */ new Set(["run"]);
619
+ function checkReservedColumnNames(tables, bag) {
620
+ for (const def of tables) {
621
+ for (const col of tableColumns(def)) {
622
+ if (!RESERVED_COLUMN_NAMES.has(col.name)) continue;
623
+ bag.warn(
624
+ "table.reserved-column-name",
625
+ `table "${def.name}": the column name \`${col.name}\` is reserved by the engine \u2014 it is the key a block statement stores its sub-stack under, and an insert's parameter map collides with it. The table deploys and reads back correctly, and then EVERY \`s.db.add\` into it fails with HTTP 400 naming \`${col.name}\` and complaining about the value \u2014 at every column type, and whether the statement supplies a value or leaves the default to stand in. Rename the column (\`${col.name}_id\`, \`${col.name}s\`); the match is exact and case sensitive, so nothing else is affected.`
626
+ );
627
+ }
628
+ }
629
+ }
509
630
  var GATING_ACTIONS = {
510
631
  realtime_server: ["connect"],
511
632
  channel: ["join"]
@@ -728,6 +849,34 @@ function checkNullMatchArgs(sections, bag) {
728
849
  }
729
850
  }
730
851
  }
852
+ var URL_ONLY_VERBS = /* @__PURE__ */ new Set(["GET", "DELETE", "HEAD"]);
853
+ function checkPathSegmentCandidates(sections, bag) {
854
+ for (const obj of sections["query"] ?? []) {
855
+ if (!obj || typeof obj !== "object") continue;
856
+ const query = obj;
857
+ const name = typeof query.name === "string" ? query.name : "";
858
+ const verb = typeof query.verb === "string" ? query.verb : "";
859
+ if (!URL_ONLY_VERBS.has(verb)) continue;
860
+ const statements = [];
861
+ collectStatements(obj, statements);
862
+ const addressing = /* @__PURE__ */ new Set();
863
+ for (const statement of statements) {
864
+ const matchArg = DB_MATCH_ARG[statement.name];
865
+ if (matchArg === void 0) continue;
866
+ const cell = statementInput(statement, matchArg);
867
+ if (cell?.tag !== "input") continue;
868
+ if (typeof cell?.value !== "string" || cell.value === "") continue;
869
+ if (name.includes(`{${cell.value}}`)) continue;
870
+ addressing.add(cell.value);
871
+ }
872
+ for (const param of addressing) {
873
+ bag.warn(
874
+ "query.path-segment-candidate",
875
+ `query "${name}" (${verb}) looks up one row by the \`${param}\` input, but the path declares no \`{${param}}\` segment \u2014 so the value arrives as \`?${param}=\u2026\` instead of addressing the resource. The endpoint works, but the route is not addressable the way a REST client expects, and \`getPath()\` types as static, so a caller cannot pass the value positionally. Put it in the path: \`name: "${name}/{${param}}"\` (the segment may sit anywhere \u2014 \`"${name}/{${param}}/edit"\` routes too), keeping the \`${param}\` input as it is; the segment binds to the input of the same name. Leave it as-is if \`${param}\` really is a query-string param rather than part of the address.`
876
+ );
877
+ }
878
+ }
879
+ }
731
880
  function checkSameNameSiblings(sections, bag) {
732
881
  const appNames = appNamesByGuid(sections["app"]);
733
882
  for (const [payloadKey, arr] of Object.entries(sections)) {
@@ -1457,6 +1606,7 @@ var Xano = class {
1457
1606
  checkStacks(this.tableDefs, sections, bag);
1458
1607
  checkExpressionOperands(sections, bag);
1459
1608
  checkInterpolatedValues(sections, bag);
1609
+ checkRegexOperandOrder(sections, bag);
1460
1610
  checkReferences(this.bundleType, sections, this.workspaceConfig.guid, bag);
1461
1611
  checkDecodeOnlyStatements(sections, bag);
1462
1612
  checkRunFamilyHosts(sections, bag);
@@ -1469,8 +1619,10 @@ var Xano = class {
1469
1619
  checkUnboundVarRefs(sections, bag);
1470
1620
  checkSafeRefMatchArgs(sections, bag);
1471
1621
  checkNullMatchArgs(sections, bag);
1622
+ checkPathSegmentCandidates(sections, bag);
1472
1623
  checkSameNameSiblings(sections, bag);
1473
1624
  checkSeed(this.tableDefs, bag);
1625
+ checkReservedColumnNames(this.tableDefs, bag);
1474
1626
  checkKnowledge(sections, bag, { resolved: options.knowledge !== void 0 });
1475
1627
  checkRealtimePublish(this.bundleType, sections, bag);
1476
1628
  bag.flush();
@@ -1706,4 +1858,4 @@ export {
1706
1858
  Xano,
1707
1859
  workspace
1708
1860
  };
1709
- //# sourceMappingURL=chunk-VKSOTZK3.js.map
1861
+ //# sourceMappingURL=chunk-OWGCOGKK.js.map