@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,167 @@
1
+ import {
2
+ detail,
3
+ info,
4
+ warn
5
+ } from "./chunk-EZG76F7R.js";
6
+
7
+ // src/deploy/microservice-status.ts
8
+ var TIMEOUT_MS = 3e4;
9
+ var POLL_INTERVAL_MS = 2e3;
10
+ var WAIT_DEADLINE_MS = 3e5;
11
+ function asString(v) {
12
+ return typeof v === "string" && v !== "" ? v : void 0;
13
+ }
14
+ function asNumber(v) {
15
+ return typeof v === "number" ? v : void 0;
16
+ }
17
+ function classify(row) {
18
+ const status = row.status ?? "";
19
+ if (status === "disabled") return "disabled";
20
+ if ((row.tenantDeploy ?? "auto") === "manual") return "manual";
21
+ switch (status) {
22
+ case "ok": {
23
+ return "ready";
24
+ }
25
+ case "error": {
26
+ return "failed";
27
+ }
28
+ // `pending` is the state a freshly imported row sits in until the engine
29
+ // picks it up; both it and `deploying` mean "not serving yet, keep looking".
30
+ case "pending":
31
+ case "deploying": {
32
+ return "inFlight";
33
+ }
34
+ default: {
35
+ return "unknown";
36
+ }
37
+ }
38
+ }
39
+ function isAwaited(m) {
40
+ return m.disposition === "inFlight";
41
+ }
42
+ function project(row) {
43
+ const tenantDeploy = asString(row.tenant_deploy) ?? "auto";
44
+ const status = asString(row.status) ?? "";
45
+ return {
46
+ id: asNumber(row.id),
47
+ name: asString(row.name) ?? "",
48
+ kind: asString(row.kind),
49
+ tenantDeploy,
50
+ status,
51
+ statusDetail: asString(row.status_detail),
52
+ deployedAt: asString(row.deployed_at),
53
+ disposition: classify({ status, tenantDeploy })
54
+ };
55
+ }
56
+ function toRows(data) {
57
+ if (Array.isArray(data)) return data;
58
+ if (data && typeof data === "object" && Array.isArray(data.items)) {
59
+ return data.items;
60
+ }
61
+ return [];
62
+ }
63
+ async function listMicroservices(auth, target, opts = {}) {
64
+ const fetchFn = opts.fetchFn ?? fetch;
65
+ const root = `${target.baseUrl.replace(/\/$/, "")}/api:meta/workspace/${target.workspaceId}/microservice`;
66
+ const out = [];
67
+ let page = 1;
68
+ for (; ; ) {
69
+ const url = `${root}?page=${page}`;
70
+ const res = await fetchFn(url, {
71
+ method: "GET",
72
+ headers: { accept: "application/json", Authorization: `Bearer ${auth.access_token}` },
73
+ signal: AbortSignal.timeout(TIMEOUT_MS)
74
+ });
75
+ const text = await res.text();
76
+ if (!res.ok) {
77
+ throw new Error(`list microservices failed (${res.status} ${res.statusText}):
78
+ ${text}`);
79
+ }
80
+ let data;
81
+ try {
82
+ data = JSON.parse(text);
83
+ } catch {
84
+ throw new Error(`list microservices: could not parse the response as JSON:
85
+ ${text}`);
86
+ }
87
+ out.push(...toRows(data).map((r) => project(r)));
88
+ const next = data?.nextPage;
89
+ if (typeof next !== "number" || next <= page) return out;
90
+ page = next;
91
+ }
92
+ }
93
+ async function waitForMicroservices(auth, target, opts = {}) {
94
+ const now = opts.now ?? Date.now;
95
+ const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
96
+ const totalDeadlineMs = opts.totalDeadlineMs ?? WAIT_DEADLINE_MS;
97
+ const pollIntervalMs = opts.pollIntervalMs ?? POLL_INTERVAL_MS;
98
+ const start = now();
99
+ let microservices = [];
100
+ let sawAnyRead = false;
101
+ for (; ; ) {
102
+ try {
103
+ microservices = await listMicroservices(auth, target, opts);
104
+ sawAnyRead = true;
105
+ opts.onPoll?.(microservices);
106
+ if (!microservices.some((m) => isAwaited(m))) {
107
+ return { microservices, timedOut: false, hadFailure: microservices.some((m) => m.disposition === "failed") };
108
+ }
109
+ } catch (err) {
110
+ if (!sawAnyRead) throw err;
111
+ }
112
+ if (now() - start + pollIntervalMs > totalDeadlineMs) {
113
+ return {
114
+ microservices,
115
+ timedOut: true,
116
+ hadFailure: microservices.some((m) => m.disposition === "failed")
117
+ };
118
+ }
119
+ await sleep(pollIntervalMs);
120
+ }
121
+ }
122
+
123
+ // src/emit/microservice-view.ts
124
+ async function readMicroservices(auth, baseUrl, workspaceId = 1) {
125
+ try {
126
+ return await listMicroservices(auth, { baseUrl, workspaceId });
127
+ } catch (err) {
128
+ warn(`Could not read microservices: ${err instanceof Error ? err.message : String(err)}`);
129
+ return [];
130
+ }
131
+ }
132
+ var DISPOSITION_LABEL = {
133
+ ready: { icon: "\u2713", why: "ready" },
134
+ inFlight: { icon: "\u2026", why: "starting" },
135
+ failed: { icon: "\u2717", why: "failed" },
136
+ manual: { icon: "\u2013", why: "not started \u2014 set to deploy manually" },
137
+ disabled: { icon: "\u2013", why: "disabled" },
138
+ unknown: { icon: "\u2013", why: "unrecognized state" }
139
+ };
140
+ function microserviceLine(m) {
141
+ const { icon, why } = DISPOSITION_LABEL[m.disposition];
142
+ const useDetail = m.disposition !== "manual" && m.disposition !== "disabled";
143
+ const reason = (useDetail ? m.statusDetail : void 0) ?? why;
144
+ return `${icon} ${m.name} \u2014 ${m.disposition === "unknown" ? `${why} (${m.status})` : reason}`;
145
+ }
146
+ function readyRatio(microservices) {
147
+ return {
148
+ ready: microservices.filter((m) => m.disposition === "ready").length,
149
+ // Rows the engine was never going to start don't belong in a readiness ratio.
150
+ startable: microservices.filter((m) => m.disposition !== "manual" && m.disposition !== "disabled").length
151
+ };
152
+ }
153
+ function printMicroserviceSection(microservices) {
154
+ if (microservices.length === 0) return;
155
+ const { ready, startable } = readyRatio(microservices);
156
+ info(startable === 0 ? "Microservices (none set to start):" : `Microservices (${ready}/${startable} ready):`);
157
+ for (const m of microservices) detail(microserviceLine(m));
158
+ }
159
+
160
+ export {
161
+ waitForMicroservices,
162
+ readMicroservices,
163
+ microserviceLine,
164
+ readyRatio,
165
+ printMicroserviceSection
166
+ };
167
+ //# sourceMappingURL=chunk-NDZFBZHC.js.map
@@ -0,0 +1,37 @@
1
+ import {
2
+ compileBundle
3
+ } from "./chunk-YGPIY3WT.js";
4
+ import {
5
+ missingArgument
6
+ } from "./chunk-IZW6MK3U.js";
7
+
8
+ // src/emit/bundle-input.ts
9
+ import { existsSync, readFileSync } from "fs";
10
+ function assertBundleInput(args, target) {
11
+ if (args.bundle === void 0 && args.file === void 0) throw missingArgument("file", target);
12
+ }
13
+ async function loadBundleText(args, target, opts = {}) {
14
+ assertBundleInput(args, target);
15
+ if (args.bundle !== void 0) {
16
+ if (args.file !== void 0) {
17
+ throw new Error(`Pass either an entry <file> or --bundle <path>, not both.`);
18
+ }
19
+ if (!existsSync(args.bundle)) {
20
+ throw new Error(
21
+ `${args.bundle} not found. Run \`xanots export <entry> --out ${args.bundle}\` first.`
22
+ );
23
+ }
24
+ return { bundle: readFileSync(args.bundle, "utf8"), source: args.bundle, content: [], nonPublicSeedValues: [] };
25
+ }
26
+ if (args.file !== void 0) {
27
+ const { bundle, content, nonPublicSeedValues } = await compileBundle(args, { seed: opts.withSeed });
28
+ return { bundle, source: args.file, content, nonPublicSeedValues };
29
+ }
30
+ throw missingArgument("file", target);
31
+ }
32
+
33
+ export {
34
+ assertBundleInput,
35
+ loadBundleText
36
+ };
37
+ //# sourceMappingURL=chunk-NOO35BQ2.js.map
@@ -0,0 +1,13 @@
1
+ // src/emit/output.ts
2
+ function isMachineOutput(args) {
3
+ return args.json === true || process.stdout.isTTY !== true;
4
+ }
5
+ function writeJson(value) {
6
+ process.stdout.write(JSON.stringify(value, null, 2) + "\n");
7
+ }
8
+
9
+ export {
10
+ isMachineOutput,
11
+ writeJson
12
+ };
13
+ //# sourceMappingURL=chunk-NUQCEOKA.js.map
@@ -0,0 +1,56 @@
1
+ import {
2
+ decodeWorkspaceArchive
3
+ } from "./chunk-ZUTSMMAG.js";
4
+ import {
5
+ fetchReadOrExplain
6
+ } from "./chunk-3IGNIP6R.js";
7
+
8
+ // src/deploy/workspace-export.ts
9
+ var EXPORT_TIMEOUT_MS = 12e4;
10
+ async function exportWorkspaceBundle(auth, opts) {
11
+ const base = opts.base.replace(/\/$/, "");
12
+ const url = `${base}/api:meta/workspace/${opts.workspaceId}/export`;
13
+ const res = await fetchReadOrExplain(
14
+ url,
15
+ {
16
+ method: "POST",
17
+ headers: { Authorization: `Bearer ${auth.access_token}`, "Content-Type": "application/json" },
18
+ // `branch`/`password` are required; the defaults mean "current branch, no
19
+ // archive password". `records: false` skips table content — see above.
20
+ body: JSON.stringify({ branch: "", password: "", records: false }),
21
+ signal: AbortSignal.timeout(EXPORT_TIMEOUT_MS)
22
+ },
23
+ opts.label,
24
+ EXPORT_TIMEOUT_MS
25
+ );
26
+ if (!res.ok) {
27
+ throw new Error(
28
+ `${opts.label} failed (${res.status} ${res.statusText}):
29
+ ${describeErrorBody(
30
+ new Uint8Array(await res.arrayBuffer()),
31
+ res.headers.get("content-type")
32
+ )}`
33
+ );
34
+ }
35
+ const bundle = decodeWorkspaceArchive(new Uint8Array(await res.arrayBuffer()));
36
+ if (bundle === null || typeof bundle !== "object" || !("payload" in bundle)) {
37
+ throw new Error(`${opts.label}: the exported archive carried no \`payload\` \u2014 not a workspace bundle.`);
38
+ }
39
+ return bundle;
40
+ }
41
+ function describeErrorBody(bytes, contentType) {
42
+ const type = contentType ? ` (content-type: ${contentType})` : "";
43
+ const text = new TextDecoder("utf-8", { fatal: false }).decode(bytes);
44
+ const NOT_TEXT = /[\uFFFD\u0000-\u0008\u000B\u000C\u000E-\u001F]/;
45
+ if (bytes.length > 0 && !NOT_TEXT.test(text)) {
46
+ return text.length > 2e3 ? `${text.slice(0, 2e3)}
47
+ \u2026 (${text.length} chars, truncated)` : text;
48
+ }
49
+ const gzip = bytes[0] === 31 && bytes[1] === 139;
50
+ return `<${bytes.length} bytes of ${gzip ? "gzip data" : "binary"}, not text${type}>` + (gzip ? ` \u2014 the body looks like a workspace archive, so the instance answered with a payload AND an error status. The status is what XanoTS goes by; re-run the export, and if it persists the instance is failing mid-export.` : "");
51
+ }
52
+
53
+ export {
54
+ exportWorkspaceBundle
55
+ };
56
+ //# sourceMappingURL=chunk-QTNO2WD6.js.map
@@ -0,0 +1,49 @@
1
+ import {
2
+ RAW_ENVELOPE
3
+ } from "./chunk-LH6Z6KFV.js";
4
+
5
+ // src/statements/special/raw.ts
6
+ var CANONICAL_KEYS = [
7
+ "as",
8
+ "name",
9
+ "_xsid",
10
+ "addon",
11
+ "input",
12
+ "mocks",
13
+ "output",
14
+ "context",
15
+ "runtime",
16
+ "disabled",
17
+ "description",
18
+ "settings_registry"
19
+ ];
20
+ function raw(envelope) {
21
+ if (envelope == null || typeof envelope !== "object" || Array.isArray(envelope)) {
22
+ throw new Error(
23
+ 'raw() expects a stored statement envelope object \u2014 at minimum `{ name: "mvp:\u2026", context: {\u2026} }` \u2014 but received ' + (envelope === null ? "null" : Array.isArray(envelope) ? "an array" : typeof envelope)
24
+ );
25
+ }
26
+ const name = envelope.name;
27
+ if (typeof name !== "string" || name === "") {
28
+ throw new Error(
29
+ 'raw() envelope is missing a `name`. A stored statement envelope must carry its `mvp:` name, e.g. `{ name: "mvp:set_var", context: {\u2026} }`.'
30
+ );
31
+ }
32
+ const stored = {};
33
+ for (const key of CANONICAL_KEYS) {
34
+ if (key in envelope) stored[key] = envelope[key];
35
+ }
36
+ for (const key of Object.keys(envelope)) {
37
+ if (!(key in stored)) stored[key] = envelope[key];
38
+ }
39
+ return {
40
+ name,
41
+ context: stored.context,
42
+ [RAW_ENVELOPE]: stored
43
+ };
44
+ }
45
+
46
+ export {
47
+ raw
48
+ };
49
+ //# sourceMappingURL=chunk-RVB7ITKN.js.map