@xanots/sdk 0.0.1

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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +384 -0
  3. package/dist/agent-file-refresh-7XCACU34.js +95 -0
  4. package/dist/bin.d.ts +1 -0
  5. package/dist/bin.js +184 -0
  6. package/dist/capture-HUV5BNTC.js +32 -0
  7. package/dist/chunk-26CNBZE2.js +963 -0
  8. package/dist/chunk-33ND6LKO.js +78 -0
  9. package/dist/chunk-3DUAGYGP.js +1550 -0
  10. package/dist/chunk-3IGNIP6R.js +89 -0
  11. package/dist/chunk-47WDWMBJ.js +14 -0
  12. package/dist/chunk-4BXJGVZ3.js +318 -0
  13. package/dist/chunk-4HT3BNZ7.js +675 -0
  14. package/dist/chunk-4YMD2OOZ.js +23 -0
  15. package/dist/chunk-5WGEURVI.js +156 -0
  16. package/dist/chunk-5YTBTF25.js +29 -0
  17. package/dist/chunk-6DHBYBTO.js +166 -0
  18. package/dist/chunk-76QBEIGO.js +66 -0
  19. package/dist/chunk-7DKX2SPN.js +100 -0
  20. package/dist/chunk-7REDODS2.js +468 -0
  21. package/dist/chunk-C56BC2FY.js +254 -0
  22. package/dist/chunk-DGSF2Q5H.js +60 -0
  23. package/dist/chunk-EMCAWMHC.js +3982 -0
  24. package/dist/chunk-EZG76F7R.js +159 -0
  25. package/dist/chunk-FJ6ZS5KB.js +3607 -0
  26. package/dist/chunk-GNPVYOPB.js +17 -0
  27. package/dist/chunk-HJPTWBLH.js +38 -0
  28. package/dist/chunk-IZW6MK3U.js +248 -0
  29. package/dist/chunk-LH6Z6KFV.js +247 -0
  30. package/dist/chunk-MZUI3JNX.js +93 -0
  31. package/dist/chunk-NDZFBZHC.js +167 -0
  32. package/dist/chunk-NOO35BQ2.js +37 -0
  33. package/dist/chunk-NUQCEOKA.js +13 -0
  34. package/dist/chunk-QTNO2WD6.js +56 -0
  35. package/dist/chunk-RVB7ITKN.js +49 -0
  36. package/dist/chunk-TRU5OHQ5.js +6904 -0
  37. package/dist/chunk-VKFQJEMW.js +814 -0
  38. package/dist/chunk-VTIL47DT.js +125 -0
  39. package/dist/chunk-WHOJWOSV.js +112 -0
  40. package/dist/chunk-WKP4D5MO.js +1692 -0
  41. package/dist/chunk-X4DVXBFY.js +38 -0
  42. package/dist/chunk-XQ22GLYS.js +118 -0
  43. package/dist/chunk-YDZYMZBE.js +670 -0
  44. package/dist/chunk-YGPIY3WT.js +1146 -0
  45. package/dist/chunk-YYRDLFSJ.js +602 -0
  46. package/dist/chunk-ZUTSMMAG.js +46 -0
  47. package/dist/cli.d.ts +331 -0
  48. package/dist/cli.js +33 -0
  49. package/dist/codegen-command-OOKK6AZK.js +40 -0
  50. package/dist/codegen.d.ts +114 -0
  51. package/dist/codegen.js +71 -0
  52. package/dist/completion-TIPPZN7H.js +298 -0
  53. package/dist/config-NL33PN4D.js +84 -0
  54. package/dist/deploy-command-4EQ7XX5G.js +451 -0
  55. package/dist/env-target-IFJ5QDHC.js +16 -0
  56. package/dist/ephemeral-command-3X3I4ULC.js +242 -0
  57. package/dist/index.d.ts +4477 -0
  58. package/dist/index.js +300 -0
  59. package/dist/init-command-R6H7ZXW5.js +27 -0
  60. package/dist/internal.d.ts +74 -0
  61. package/dist/internal.js +2065 -0
  62. package/dist/io-AMIKRLPC.js +11 -0
  63. package/dist/live-diff-Y3AKETHE.js +196 -0
  64. package/dist/lock-3CVKALKT.js +37 -0
  65. package/dist/lock-commands-XTR2YKLY.js +232 -0
  66. package/dist/login-command-ACJF6KWQ.js +167 -0
  67. package/dist/logout-command-MX3MJS5U.js +68 -0
  68. package/dist/loop-OM3P2Z6O.js +93 -0
  69. package/dist/marketplace-command-RATXTKXN.js +379 -0
  70. package/dist/meta-client-OW5WKWW7.js +170 -0
  71. package/dist/node.d.ts +59 -0
  72. package/dist/node.js +442 -0
  73. package/dist/profile-command-SWJ3SPKR.js +77 -0
  74. package/dist/release-command-VV5UVZKL.js +427 -0
  75. package/dist/response-CVAE2kMj.d.ts +1915 -0
  76. package/dist/routes-manifest-SP3ZXLMR.js +244 -0
  77. package/dist/runtime-V4C3AC3A.js +13 -0
  78. package/dist/sandbox-details-command-HJE5SPVG.js +18 -0
  79. package/dist/sandbox-export-command-QCJY4GMV.js +24 -0
  80. package/dist/static-host-D6KS7X45.js +138 -0
  81. package/dist/store-BQ97nKIF.d.ts +7760 -0
  82. package/dist/test-command-TSPBQHBM.js +383 -0
  83. package/dist/validate-command-4ERHJSCO.js +122 -0
  84. package/dist/verify-rollout-FAVQ6EJY.js +40 -0
  85. package/dist/workspace-K72NP7SX.js +49 -0
  86. package/dist/workspace-command-OF23DPNI.js +156 -0
  87. package/dist/workspace-export-AJMGN3CQ.js +10 -0
  88. package/llms/fields.md +104 -0
  89. package/llms/filters.md +183 -0
  90. package/llms/kinds-agent-mcp.md +11 -0
  91. package/llms/kinds-core.md +68 -0
  92. package/llms/kinds-realtime.md +76 -0
  93. package/llms/lambda.md +111 -0
  94. package/llms/legacy.md +43 -0
  95. package/llms/object-kinds.md +31 -0
  96. package/llms/statements-calls.md +23 -0
  97. package/llms/statements-catalog.md +309 -0
  98. package/llms/statements-data.md +58 -0
  99. package/llms/statements-runtime.md +48 -0
  100. package/llms/tests.md +58 -0
  101. package/llms/triggers.md +22 -0
  102. package/llms/values.md +29 -0
  103. package/llms-full.txt +1672 -0
  104. package/llms.txt +483 -0
  105. package/manifest.json +9592 -0
  106. package/package.json +110 -0
@@ -0,0 +1,17 @@
1
+ // src/util/atomic-write.ts
2
+ import { writeFileSync, renameSync, rmSync } from "fs";
3
+ function atomicWrite(path, contents, opts) {
4
+ const tmp = `${path}.tmp-${process.pid}`;
5
+ try {
6
+ writeFileSync(tmp, contents, opts?.mode !== void 0 ? { encoding: "utf8", mode: opts.mode } : "utf8");
7
+ renameSync(tmp, path);
8
+ } catch (err) {
9
+ rmSync(tmp, { force: true });
10
+ throw err;
11
+ }
12
+ }
13
+
14
+ export {
15
+ atomicWrite
16
+ };
17
+ //# sourceMappingURL=chunk-GNPVYOPB.js.map
@@ -0,0 +1,38 @@
1
+ import {
2
+ atomicWrite
3
+ } from "./chunk-GNPVYOPB.js";
4
+ import {
5
+ parseLock,
6
+ serializeLock
7
+ } from "./chunk-4HT3BNZ7.js";
8
+
9
+ // src/lock/io.ts
10
+ import { readFileSync, existsSync } from "fs";
11
+ function readLockFile(path) {
12
+ let text;
13
+ try {
14
+ text = readFileSync(path, "utf8");
15
+ } catch (err) {
16
+ throw new Error(
17
+ `Cannot read lock file ${path}: ${err instanceof Error ? err.message : String(err)}`
18
+ );
19
+ }
20
+ return parseLock(text, path);
21
+ }
22
+ function writeLockFile(path, lock) {
23
+ const next = serializeLock(lock);
24
+ if (existsSync(path)) {
25
+ try {
26
+ if (readFileSync(path, "utf8") === next) return false;
27
+ } catch {
28
+ }
29
+ }
30
+ atomicWrite(path, next);
31
+ return true;
32
+ }
33
+
34
+ export {
35
+ readLockFile,
36
+ writeLockFile
37
+ };
38
+ //# sourceMappingURL=chunk-HJPTWBLH.js.map
@@ -0,0 +1,248 @@
1
+ import {
2
+ detail,
3
+ error,
4
+ stderrStyle,
5
+ stdoutStyle
6
+ } from "./chunk-EZG76F7R.js";
7
+ import {
8
+ COMMANDS,
9
+ FLAGS,
10
+ GLOBAL_FLAGS,
11
+ HELP_GROUP_ORDER,
12
+ flagKey,
13
+ flagNames,
14
+ flagSummary,
15
+ flagValues,
16
+ getCommand,
17
+ getSubcommand,
18
+ liveCommandNames,
19
+ liveSubcommandNames,
20
+ renderArgs,
21
+ suggest
22
+ } from "./chunk-YYRDLFSJ.js";
23
+
24
+ // src/emit/help.ts
25
+ function table(rows, s, indent = " ", fixedWidth) {
26
+ const width = fixedWidth ?? Math.max(0, ...rows.map(([name]) => name.length));
27
+ return rows.map(([name, desc]) => `${indent}${s.cyan(name.padEnd(width))} ${s.dim(desc)}`);
28
+ }
29
+ function renderFlagSpec(ref) {
30
+ const spec = FLAGS[flagKey(ref)].spec;
31
+ const values = flagValues(ref);
32
+ if (values === void 0 || typeof ref === "string" || ref.values === void 0) return spec;
33
+ return spec.replace(/<[^>]*>/, `<${values.join("|")}>`);
34
+ }
35
+ function flagSection(flags, s) {
36
+ if (!flags || flags.length === 0) return [];
37
+ const rows = flags.filter((ref) => Object.hasOwn(FLAGS, flagKey(ref))).map((ref) => [renderFlagSpec(ref), flagSummary(ref)]);
38
+ if (rows.length === 0) return [];
39
+ return ["", s.bold("Flags"), ...table(rows, s)];
40
+ }
41
+ function argSection(args, s) {
42
+ const rows = (args ?? []).filter((a) => a.values !== void 0 && a.values.length > 0).map((a) => [`<${a.name}>`, a.values.join(", ")]);
43
+ return rows.length === 0 ? [] : ["", s.bold("Arguments"), ...table(rows, s)];
44
+ }
45
+ function exampleSection(example, s) {
46
+ return example ? ["", s.bold("Example"), ` ${s.dim(example)}`] : [];
47
+ }
48
+ function globalFlagRows() {
49
+ return GLOBAL_FLAGS.map((key) => [FLAGS[key].spec, FLAGS[key].summary]);
50
+ }
51
+ function renderGlobalHelp(s = stdoutStyle(), version = "") {
52
+ const byGroup = /* @__PURE__ */ new Map();
53
+ const push = (group, row) => {
54
+ const rows = byGroup.get(group) ?? [];
55
+ rows.push(row);
56
+ byGroup.set(group, rows);
57
+ };
58
+ for (const [name, spec] of Object.entries(COMMANDS)) {
59
+ if (spec.removed === void 0 && spec.aliasOf === void 0) push(spec.group, [spec.display, spec.summary]);
60
+ for (const sub of Object.values(spec.subcommands ?? {})) {
61
+ if (sub.group === void 0 || sub.removed !== void 0) continue;
62
+ push(sub.group, [sub.display ?? `${name} ${sub.summary}`, sub.groupSummary ?? sub.summary]);
63
+ }
64
+ }
65
+ const width = Math.max(0, ...[...byGroup.values()].flat().map(([n]) => n.length));
66
+ const lines = [
67
+ `${s.bold("xanots")}${version ? ` ${s.dim(`v${version}`)}` : ""} \u2014 the AI-first SDK & CLI for Xano backends`,
68
+ "",
69
+ `${s.dim("Usage:")} xanots ${s.cyan("<command>")} ${s.dim("[options]")}`
70
+ ];
71
+ for (const group of HELP_GROUP_ORDER) {
72
+ const rows = byGroup.get(group);
73
+ if (!rows || rows.length === 0) continue;
74
+ lines.push("", s.bold(group), ...table(rows, s, " ", width));
75
+ }
76
+ lines.push("", s.bold("Global flags"), ...table(globalFlagRows(), s, " ", width));
77
+ lines.push(
78
+ "",
79
+ s.dim("Run `xanots <command> --help` for a command's arguments and flags."),
80
+ s.dim("Docs: https://www.npmjs.com/package/@xanots/sdk")
81
+ );
82
+ return lines.join("\n") + "\n";
83
+ }
84
+ function renderCommandHelp(command, s = stdoutStyle()) {
85
+ const spec = getCommand(command);
86
+ if (!spec) return renderGlobalHelp(s);
87
+ const subs = liveSubcommandNames(command);
88
+ const usage = subs.length > 0 ? `xanots ${command} <subcommand> ${s.dim("[options]")}` : `xanots ${command}${renderArgs(spec.args) ? ` ${renderArgs(spec.args)}` : ""} ${s.dim("[options]")}`;
89
+ const lines = [`${s.bold(`xanots ${command}`)} \u2014 ${spec.summary}`, "", `${s.dim("Usage:")} ${usage}`];
90
+ if (subs.length > 0) {
91
+ const rows = subs.map((name) => {
92
+ const sub = getSubcommand(command, name);
93
+ const args = renderArgs(sub.args);
94
+ return [args ? `${name} ${args}` : name, sub.summary];
95
+ });
96
+ lines.push("", s.bold("Subcommands"), ...table(rows, s));
97
+ }
98
+ lines.push(...argSection(spec.args, s));
99
+ lines.push(...flagSection(spec.flags, s));
100
+ lines.push(...exampleSection(spec.example, s));
101
+ if (subs.length > 0) {
102
+ lines.push("", s.dim(`Run \`xanots ${command} <subcommand> --help\` for a subcommand's flags.`));
103
+ }
104
+ return lines.join("\n") + "\n";
105
+ }
106
+ function renderSubcommandHelp(command, sub, s = stdoutStyle()) {
107
+ const spec = getSubcommand(command, sub);
108
+ if (!spec || spec.removed !== void 0) return renderCommandHelp(command, s);
109
+ const args = renderArgs(spec.args);
110
+ const lines = [
111
+ `${s.bold(`xanots ${command} ${sub}`)} \u2014 ${spec.summary}`,
112
+ "",
113
+ `${s.dim("Usage:")} xanots ${command} ${sub}${args ? ` ${args}` : ""} ${s.dim("[options]")}`
114
+ ];
115
+ lines.push(...argSection(spec.args, s));
116
+ lines.push(...flagSection(spec.flags, s));
117
+ lines.push(...exampleSection(spec.example, s));
118
+ return lines.join("\n") + "\n";
119
+ }
120
+ function renderHelpFor(target, s, version = "") {
121
+ if (target?.command === void 0) return renderGlobalHelp(s, version);
122
+ if (target.subcommand !== void 0) return renderSubcommandHelp(target.command, target.subcommand, s);
123
+ return renderCommandHelp(target.command, s);
124
+ }
125
+ function indentBlock(text, indent = " ") {
126
+ return text.split("\n").map((line) => line === "" ? line : indent + line).join("\n");
127
+ }
128
+
129
+ // src/emit/errors.ts
130
+ var UsageError = class extends Error {
131
+ name = "UsageError";
132
+ /** The help block to print under the message. */
133
+ helpFor;
134
+ /** A closest-match hint (`Did you mean: details`), when one is close enough. */
135
+ suggestion;
136
+ constructor(message, opts = {}) {
137
+ super(message);
138
+ this.helpFor = opts.helpFor;
139
+ this.suggestion = opts.suggestion;
140
+ }
141
+ };
142
+ function isUsageError(err) {
143
+ return err instanceof UsageError;
144
+ }
145
+ function unknownCommand(name) {
146
+ const removed = getCommand(name)?.removed;
147
+ if (removed !== void 0) return new UsageError(removed, { helpFor: {} });
148
+ return new UsageError(`Unknown command "${name}".`, {
149
+ helpFor: {},
150
+ suggestion: suggest(name, liveCommandNames())
151
+ });
152
+ }
153
+ function unknownHelpTopic(name) {
154
+ return new UsageError(`\`xanots help\`: no help topic "${name}".`, {
155
+ helpFor: {},
156
+ suggestion: suggest(name, liveCommandNames())
157
+ });
158
+ }
159
+ function unknownSubcommand(command, sub) {
160
+ const removed = sub !== void 0 ? getSubcommand(command, sub)?.removed : void 0;
161
+ if (removed !== void 0) return new UsageError(removed, { helpFor: { command } });
162
+ const what = sub === void 0 || sub === "" ? "no subcommand given" : `unknown subcommand "${sub}"`;
163
+ return new UsageError(`\`xanots ${command}\`: ${what}.`, {
164
+ helpFor: { command },
165
+ suggestion: sub !== void 0 ? suggest(sub, liveSubcommandNames(command)) : void 0
166
+ });
167
+ }
168
+ function removedSubcommand(command, sub) {
169
+ const removed = getSubcommand(command, sub)?.removed;
170
+ return new UsageError(removed ?? `\`xanots ${command} ${sub}\` was removed.`, { helpFor: { command } });
171
+ }
172
+ function assertWritableDest(dest, command) {
173
+ if (dest !== "workspace") return;
174
+ throw new UsageError(
175
+ `\`xanots ${command} --dest workspace\` is not a thing \u2014 the only import path is a FULL REPLACE of the target workspace, so XanoTS never writes back to your real one. Deploy to a disposable environment instead (\`--dest ephemeral\` or \`--dest sandbox\`); to READ your real workspace, use \`xanots workspace codegen\`, or \`xanots test --dest workspace\` to run its tests.`,
176
+ { helpFor: { command } }
177
+ );
178
+ }
179
+ function unknownFlag(flags, target) {
180
+ const first = flags[0] ?? "";
181
+ const rest = flags.slice(1);
182
+ return new UsageError(
183
+ `Unknown flag ${first}${rest.length ? ` (also ${rest.join(", ")})` : ""}.`,
184
+ {
185
+ helpFor: target,
186
+ suggestion: suggestFlag(first)
187
+ }
188
+ );
189
+ }
190
+ function suggestFlag(flag) {
191
+ const typed = flag.replace(/^-+/, "").split("=")[0] ?? "";
192
+ const match = suggest(typed, flagNames());
193
+ return match === void 0 ? void 0 : `--${match}`;
194
+ }
195
+ function extraArguments(extras, target, max, attachedValueFlag) {
196
+ const where = target.subcommand ? `${target.command} ${target.subcommand}` : target.command;
197
+ const named = extras.map((e) => `"${e}"`).join(", ");
198
+ const noun = extras.length === 1 ? "argument" : "arguments";
199
+ const why = attachedValueFlag !== void 0 ? (
200
+ // `--lock` is the only flag with an attached-only value form, and its
201
+ // value is a path — spelled out here rather than reconstructed from the
202
+ // flag registry, whose `spec` strings are written for help, not reuse.
203
+ `\`${attachedValueFlag}\` takes its value attached: \`${attachedValueFlag}=<path>\`.`
204
+ ) : specFor(target)?.extraArgHint ?? (max === 0 ? `\`xanots ${where}\` takes no positional arguments.` : `\`xanots ${where}\` takes at most ${max}: ${renderArgs(specFor(target)?.args)}.`);
205
+ return new UsageError(`\`xanots ${where}\`: unexpected ${noun} ${named} \u2014 ${why}`, {
206
+ helpFor: target
207
+ });
208
+ }
209
+ function specFor(target) {
210
+ return target.subcommand !== void 0 ? getSubcommand(target.command, target.subcommand) : getCommand(target.command);
211
+ }
212
+ function missingArgument(arg, target) {
213
+ const where = target.subcommand ? `${target.command} ${target.subcommand}` : target.command;
214
+ return new UsageError(`\`xanots ${where}\`: missing required <${arg}>.`, { helpFor: target });
215
+ }
216
+ function reportFailure(err, version = "") {
217
+ const s = stderrStyle();
218
+ error(err instanceof Error ? err.message : String(err));
219
+ if (!isUsageError(err)) return;
220
+ if (err.suggestion !== void 0) {
221
+ process.stderr.write("\n");
222
+ detail(`Did you mean: ${s.cyan(err.suggestion)}`);
223
+ }
224
+ if (err.helpFor === void 0) return;
225
+ process.stderr.write("\n" + indentBlock(renderHelpFor(err.helpFor, s, version)));
226
+ }
227
+ function exitCodeOf(err) {
228
+ const code = err?.exitCode;
229
+ return typeof code === "number" && Number.isInteger(code) && code > 0 && code < 256 ? code : 1;
230
+ }
231
+
232
+ export {
233
+ renderGlobalHelp,
234
+ renderHelpFor,
235
+ indentBlock,
236
+ UsageError,
237
+ unknownCommand,
238
+ unknownHelpTopic,
239
+ unknownSubcommand,
240
+ removedSubcommand,
241
+ assertWritableDest,
242
+ unknownFlag,
243
+ extraArguments,
244
+ missingArgument,
245
+ reportFailure,
246
+ exitCodeOf
247
+ };
248
+ //# sourceMappingURL=chunk-IZW6MK3U.js.map
@@ -0,0 +1,247 @@
1
+ // src/values/mock.ts
2
+ function isWrapped(e) {
3
+ return typeof e.tag !== "string";
4
+ }
5
+ function encodeMockMap(mock) {
6
+ const out = {};
7
+ for (const [testName, entry] of Object.entries(mock)) {
8
+ const wrapped = isWrapped(entry);
9
+ const value = wrapped ? entry.value : entry;
10
+ if (typeof value?.tag !== "string") {
11
+ throw new Error(
12
+ `mock for test "${testName}": expected a tagged value (\`c.*\`/\`ref\`/\u2026) or \`{ value, enabled }\`, got ${JSON.stringify(entry)}. A mock stores \`{value,tag,filters}\` copied off this argument, so a plain JS value encodes an empty mock that silently returns nothing when the test runs.`
13
+ );
14
+ }
15
+ out[testName] = {
16
+ value: value.value,
17
+ tag: value.tag,
18
+ filters: value.filters,
19
+ enabled: wrapped ? entry.enabled ?? true : true
20
+ };
21
+ }
22
+ return out;
23
+ }
24
+
25
+ // src/statements/statement.ts
26
+ function annotate(stmt, a) {
27
+ if (a?.disabled !== void 0) stmt.disabled = a.disabled;
28
+ if (a?.description !== void 0) stmt.description = a.description;
29
+ if (a?.mock !== void 0) stmt.mocks = encodeMockMap(a.mock);
30
+ if (a?.asFilters !== void 0 && a.asFilters.length > 0) {
31
+ assertBindsAs(stmt, "asFilters");
32
+ stmt.output = { ...stmt.output ?? {}, filters: a.asFilters };
33
+ }
34
+ return stmt;
35
+ }
36
+ function assertBindsAs(stmt, option) {
37
+ if (stmt.as) return;
38
+ throw new Error(
39
+ `"${stmt.name}" binds no \`as\` variable, so \`${option}\` has nothing to filter. Bind the result with \`as\` first, or drop the option.`
40
+ );
41
+ }
42
+ function statements(...items) {
43
+ return items;
44
+ }
45
+ var RAW_ENVELOPE = /* @__PURE__ */ Symbol.for("xanots.statement.rawEnvelope");
46
+ var registry = /* @__PURE__ */ new Map();
47
+ function registerStatement(name, factory) {
48
+ registry.set(name, factory);
49
+ }
50
+ function isRegisteredStatement(name) {
51
+ return registry.has(name);
52
+ }
53
+ function getStatementFactory(name) {
54
+ const factory = registry.get(name);
55
+ if (!factory) {
56
+ throw new Error(
57
+ `Unknown statement "${name}". Registered: ${[...registry.keys()].join(", ") || "(none)"}`
58
+ );
59
+ }
60
+ return factory;
61
+ }
62
+ function fullInputEntry(raw) {
63
+ const e = raw ?? {};
64
+ return {
65
+ name: e.name,
66
+ value: e.value,
67
+ tag: e.tag,
68
+ filters: e.filters ?? [],
69
+ ignore: e.ignore ?? false,
70
+ expand: e.expand ?? false,
71
+ children: e.children ?? []
72
+ };
73
+ }
74
+ function encodeStatement(stmt) {
75
+ const rawEnvelope = stmt[RAW_ENVELOPE];
76
+ if (rawEnvelope !== void 0) return rawEnvelope;
77
+ if (!isRegisteredStatement(stmt.name)) {
78
+ throw new Error(
79
+ `Cannot encode unregistered statement "${stmt.name}". Registered: ${[...registry.keys()].join(", ") || "(none)"}`
80
+ );
81
+ }
82
+ const output = {
83
+ items: [],
84
+ filters: [],
85
+ customize: false,
86
+ ...stmt.output ?? {}
87
+ };
88
+ const sr = stmt.settings_registry;
89
+ const settings_registry = sr == null || Array.isArray(sr) && sr.length === 0 ? null : sr;
90
+ return {
91
+ as: stmt.as ?? "",
92
+ name: stmt.name,
93
+ _xsid: "",
94
+ addon: stmt.addon ?? [],
95
+ input: (stmt.input ?? []).map(fullInputEntry),
96
+ mocks: stmt.mocks ?? {},
97
+ output,
98
+ context: stmt.context,
99
+ runtime: stmt.runtime ?? null,
100
+ disabled: stmt.disabled ?? false,
101
+ description: stmt.description ?? "",
102
+ settings_registry
103
+ };
104
+ }
105
+
106
+ // src/responses/raw-response.ts
107
+ var RAW_RESPONSE = /* @__PURE__ */ Symbol.for("xanots.response.rawEnvelope");
108
+ var CANONICAL_KEYS = ["filters", "name", "tag", "value", "_xsid", "disabled"];
109
+ function rawResponse(items) {
110
+ if (!Array.isArray(items)) {
111
+ throw new Error(
112
+ 'rawResponse() expects an array of stored result[] entries, e.g. `[{ name: "", tag: "input", value: "x", filters: [] }]` \u2014 but received ' + (items === null ? "null" : typeof items)
113
+ );
114
+ }
115
+ const stored = items.map((item, i) => {
116
+ if (item == null || typeof item !== "object" || Array.isArray(item)) {
117
+ throw new Error(
118
+ `rawResponse() item ${i} is not a stored result envelope object \u2014 received ` + (item === null ? "null" : Array.isArray(item) ? "an array" : typeof item)
119
+ );
120
+ }
121
+ const out = {};
122
+ for (const key of CANONICAL_KEYS) {
123
+ if (Object.hasOwn(item, key)) out[key] = item[key];
124
+ }
125
+ for (const key of Object.keys(item)) {
126
+ if (!Object.hasOwn(out, key)) out[key] = item[key];
127
+ }
128
+ return out;
129
+ });
130
+ return { [RAW_RESPONSE]: stored };
131
+ }
132
+ function rawResponseItems(response) {
133
+ if (response == null || typeof response !== "object") return void 0;
134
+ return response[RAW_RESPONSE];
135
+ }
136
+
137
+ // src/fields/field.ts
138
+ var INPUT_CONTEXT = {
139
+ customize: {},
140
+ marketItem: { id: 0, version: 0, guid: "" },
141
+ includeDescription: true
142
+ };
143
+ var COLUMN_CONTEXT = {
144
+ customize: {},
145
+ marketItem: { id: 0, version: 0, guid: "" },
146
+ includeDescription: true
147
+ };
148
+ function parseMethod(spec) {
149
+ if (typeof spec !== "string") return { name: spec.name, arg: spec.arg ?? [] };
150
+ const [name = spec, ...arg] = spec.split(":");
151
+ return { name, arg: arg.map((part) => isNumericArg(part) ? Number(part) : part) };
152
+ }
153
+ function isNumericArg(part) {
154
+ return part !== "" && String(Number(part)) === part;
155
+ }
156
+ function encodeMethods(methods) {
157
+ return (methods ?? []).map((spec) => {
158
+ const { name, arg } = parseMethod(spec);
159
+ return { name, disabled: false, arg };
160
+ });
161
+ }
162
+ function encodeCustomize(customize) {
163
+ const out = {};
164
+ for (const [name, node] of Object.entries(customize ?? {})) {
165
+ out[name] = {
166
+ hidden: node.hidden ?? false,
167
+ default: node.default !== void 0 ? String(node.default) : "",
168
+ methods: encodeMethods(node.methods),
169
+ required: node.required ?? false,
170
+ customize: encodeCustomize(node.customize)
171
+ };
172
+ }
173
+ return out;
174
+ }
175
+ var RAW_FIELD = /* @__PURE__ */ Symbol.for("xanots.field.rawEnvelope");
176
+ function defaultEntry(options) {
177
+ if (options.noDefault === true) return {};
178
+ return { default: options.default !== void 0 ? String(options.default) : "" };
179
+ }
180
+ var NULLABLE_BY_DEFAULT = /* @__PURE__ */ new Set([
181
+ "blob",
182
+ "blob_img",
183
+ "blob_video",
184
+ "blob_audio",
185
+ "geo_point",
186
+ "geo_multipoint",
187
+ "geo_linestring",
188
+ "geo_multilinestring",
189
+ "geo_polygon",
190
+ "geo_multipolygon",
191
+ "uuid",
192
+ "vector"
193
+ ]);
194
+ function defaultNullable(type) {
195
+ return NULLABLE_BY_DEFAULT.has(type);
196
+ }
197
+ function encodeField(name, type, options, ctx) {
198
+ const rawEnvelope = options?.[RAW_FIELD];
199
+ if (rawEnvelope !== void 0) return rawEnvelope;
200
+ const field = {
201
+ name,
202
+ type,
203
+ _xsid: "",
204
+ nullable: options.nullable ?? NULLABLE_BY_DEFAULT.has(type),
205
+ ...defaultEntry(options),
206
+ merge: options.merge ?? false,
207
+ hidden: options.hidden !== void 0 ? [...options.hidden] : [],
208
+ override: [],
209
+ customize: options.customize !== void 0 ? encodeCustomize(options.customize) : ctx.customize,
210
+ required: options.required ?? false,
211
+ values: options.values ?? [],
212
+ mode: options.mode ?? "",
213
+ format: options.format ?? "",
214
+ sensitive: options.sensitive ?? false,
215
+ list: options.list ?? { min: "", max: "" },
216
+ vector: options.vector ?? { size: 3 },
217
+ access: options.access ?? "public",
218
+ style: options.style ?? { type: options.array ? "list" : "single" },
219
+ children: (options.children ?? []).map((ch) => encodeField(ch.name, ch.type, ch, ctx)),
220
+ methods: encodeMethods(options.methods),
221
+ market_item: ctx.marketItem,
222
+ is_settings_registry: false
223
+ };
224
+ if (ctx.includeDescription) {
225
+ field.description = options.description ?? "";
226
+ }
227
+ return field;
228
+ }
229
+
230
+ export {
231
+ INPUT_CONTEXT,
232
+ COLUMN_CONTEXT,
233
+ RAW_FIELD,
234
+ defaultNullable,
235
+ encodeField,
236
+ encodeMockMap,
237
+ annotate,
238
+ statements,
239
+ RAW_ENVELOPE,
240
+ registerStatement,
241
+ isRegisteredStatement,
242
+ getStatementFactory,
243
+ encodeStatement,
244
+ rawResponse,
245
+ rawResponseItems
246
+ };
247
+ //# sourceMappingURL=chunk-LH6Z6KFV.js.map
@@ -0,0 +1,93 @@
1
+ import {
2
+ c,
3
+ resp
4
+ } from "./chunk-EMCAWMHC.js";
5
+
6
+ // src/values/expect.ts
7
+ var TEST_EXPECT_TYPES = [
8
+ "to_be_defined",
9
+ "to_be_empty",
10
+ "to_be_false",
11
+ "to_be_greater_than",
12
+ "to_be_in_the_future",
13
+ "to_be_in_the_past",
14
+ "to_be_less_than",
15
+ "to_be_null",
16
+ "to_be_true",
17
+ "to_be_within",
18
+ "to_contain",
19
+ "to_end_with",
20
+ "to_equal",
21
+ "to_match",
22
+ "to_not_be_defined",
23
+ "to_not_be_null",
24
+ "to_not_equal",
25
+ "to_start_with",
26
+ "to_throw"
27
+ ];
28
+ function mk(type, ...vars) {
29
+ return { type, vars };
30
+ }
31
+ var expect = {
32
+ /** The subject is set (not undefined). */
33
+ to_be_defined: (subject) => mk("to_be_defined", subject),
34
+ /** The subject is undefined. */
35
+ to_not_be_defined: (subject) => mk("to_not_be_defined", subject),
36
+ /** The subject is empty — `""`, `[]`, `{}`, `0`, or null. */
37
+ to_be_empty: (subject) => mk("to_be_empty", subject),
38
+ /** The subject is `null`. */
39
+ to_be_null: (subject) => mk("to_be_null", subject),
40
+ /** The subject is not `null`. */
41
+ to_not_be_null: (subject) => mk("to_not_be_null", subject),
42
+ /** The subject is boolean true. */
43
+ to_be_true: (subject) => mk("to_be_true", subject),
44
+ /** The subject is boolean false. */
45
+ to_be_false: (subject) => mk("to_be_false", subject),
46
+ /** The subject is a timestamp later than now. */
47
+ to_be_in_the_future: (subject) => mk("to_be_in_the_future", subject),
48
+ /** The subject is a timestamp earlier than now. */
49
+ to_be_in_the_past: (subject) => mk("to_be_in_the_past", subject),
50
+ /** `subject === value`. */
51
+ to_equal: (subject, value) => mk("to_equal", subject, value),
52
+ /** `subject !== value`. */
53
+ to_not_equal: (subject, value) => mk("to_not_equal", subject, value),
54
+ /** `subject > value`, both read as numbers. */
55
+ to_be_greater_than: (subject, value) => mk("to_be_greater_than", subject, value),
56
+ /** `subject < value`, both read as numbers. */
57
+ to_be_less_than: (subject, value) => mk("to_be_less_than", subject, value),
58
+ /** A list subject contains the item; a text subject contains the substring. */
59
+ to_contain: (subject, item) => mk("to_contain", subject, item),
60
+ /** The subject, as text, starts with `prefix`. */
61
+ to_start_with: (subject, prefix) => mk("to_start_with", subject, prefix),
62
+ /** The subject, as text, ends with `suffix`. */
63
+ to_end_with: (subject, suffix) => mk("to_end_with", subject, suffix),
64
+ /**
65
+ * The subject matches a regular expression. `pattern` is a PCRE pattern
66
+ * INCLUDING its delimiters — build it with `c.regex(...)` rather than by hand;
67
+ * a bare `"^a"` is not a runnable pattern and the engine's match silently
68
+ * fails rather than erroring.
69
+ */
70
+ to_match: (subject, pattern) => mk("to_match", subject, pattern),
71
+ /**
72
+ * `min < subject < max`, both bounds EXCLUSIVE and all three read as numbers.
73
+ * A subject equal to either bound fails.
74
+ */
75
+ to_be_within: (subject, min, max) => mk("to_be_within", subject, min, max),
76
+ /**
77
+ * The run raised an error. Pass `exception` to require that text to appear in
78
+ * the error message (a case-insensitive substring, not an exact match);
79
+ * omit it to accept ANY error.
80
+ *
81
+ * Unlike every other matcher this one takes no subject: the thing under
82
+ * assertion is the run's failure, and the engine stores the response slot as
83
+ * a fixed first var. That is what the editor writes, and it is preserved so
84
+ * an authored test and a pulled one are the same bytes.
85
+ */
86
+ to_throw: (exception) => mk("to_throw", resp(), exception ?? c.text(""))
87
+ };
88
+
89
+ export {
90
+ TEST_EXPECT_TYPES,
91
+ expect
92
+ };
93
+ //# sourceMappingURL=chunk-MZUI3JNX.js.map