@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,242 @@
1
+ import {
2
+ confirm
3
+ } from "./chunk-5YTBTF25.js";
4
+ import {
5
+ resolveOutputTarget
6
+ } from "./chunk-XQ22GLYS.js";
7
+ import {
8
+ exportWorkspaceBundle
9
+ } from "./chunk-QTNO2WD6.js";
10
+ import {
11
+ deleteEphemeral,
12
+ getEphemeral,
13
+ impersonateEphemeral,
14
+ isExpired,
15
+ listAllEphemeral,
16
+ listEphemeral
17
+ } from "./chunk-6DHBYBTO.js";
18
+ import "./chunk-ZUTSMMAG.js";
19
+ import {
20
+ clearEnvironment,
21
+ getEnvironment,
22
+ readEphemeralState
23
+ } from "./chunk-DGSF2Q5H.js";
24
+ import {
25
+ openBrowser
26
+ } from "./chunk-VTIL47DT.js";
27
+ import "./chunk-X4DVXBFY.js";
28
+ import "./chunk-7DKX2SPN.js";
29
+ import {
30
+ printMicroserviceSection,
31
+ readMicroservices
32
+ } from "./chunk-NDZFBZHC.js";
33
+ import {
34
+ isMachineOutput,
35
+ writeJson
36
+ } from "./chunk-NUQCEOKA.js";
37
+ import "./chunk-3IGNIP6R.js";
38
+ import {
39
+ getAccessToken
40
+ } from "./chunk-C56BC2FY.js";
41
+ import "./chunk-7REDODS2.js";
42
+ import {
43
+ unknownSubcommand
44
+ } from "./chunk-IZW6MK3U.js";
45
+ import {
46
+ detail,
47
+ formatExpiration,
48
+ formatFields,
49
+ info,
50
+ stdoutStyle,
51
+ step,
52
+ success,
53
+ warn
54
+ } from "./chunk-EZG76F7R.js";
55
+ import "./chunk-YYRDLFSJ.js";
56
+ import "./chunk-GNPVYOPB.js";
57
+
58
+ // src/emit/ephemeral-command.ts
59
+ import { writeFileSync } from "fs";
60
+ var TIMEOUT_MS = 12e4;
61
+ function goneError(name, clearedState) {
62
+ const tail = clearedState ? " (cleared its local record)" : "";
63
+ return new Error(
64
+ `Ephemeral "${name}" has expired or no longer exists. Run \`xanots deploy\` to create a fresh one.${tail}`
65
+ );
66
+ }
67
+ async function resolveLive(auth, parentWorkspaceId, name) {
68
+ const summary = await getEphemeral(auth, { parentWorkspaceId, name });
69
+ if (summary === null || isExpired(summary.expiresAt)) {
70
+ const cleared = clearStaleRecord(parentWorkspaceId, name);
71
+ throw goneError(name, cleared);
72
+ }
73
+ return summary;
74
+ }
75
+ function clearStaleRecord(parentWorkspaceId, name) {
76
+ const tracked = getEnvironment(readEphemeralState(process.cwd()), parentWorkspaceId);
77
+ if (tracked?.name === name) return clearEnvironment(process.cwd(), parentWorkspaceId);
78
+ return false;
79
+ }
80
+ async function runEphemeralCommand(args) {
81
+ switch (args.subcommand) {
82
+ case "list":
83
+ return runList(args);
84
+ case "get":
85
+ return runGet(args);
86
+ case "delete":
87
+ return runDelete(args);
88
+ case "export":
89
+ return runExport(args);
90
+ case "impersonate":
91
+ return runImpersonate(args);
92
+ case "codegen": {
93
+ const { runCodegenCommand } = await import("./codegen-command-OOKK6AZK.js");
94
+ return runCodegenCommand(args, { kind: "ephemeral" });
95
+ }
96
+ default:
97
+ throw unknownSubcommand("ephemeral", args.subcommand);
98
+ }
99
+ }
100
+ async function runList(args) {
101
+ const auth = await getAccessToken(args);
102
+ const rows = args.allWorkspaces ? await listAllEphemeral(auth) : await listEphemeral(auth, { parentWorkspaceId: auth.workspaceId });
103
+ if (isMachineOutput(args)) {
104
+ writeJson(rows);
105
+ return;
106
+ }
107
+ const s = stdoutStyle();
108
+ if (rows.length === 0) {
109
+ process.stdout.write("No ephemeral tenants found\n");
110
+ return;
111
+ }
112
+ const lines = rows.map((r) => {
113
+ const exp = formatExpiration(r.expiresAt);
114
+ const expTxt = exp === "expired" ? s.red("expired") : s.dim(`expires ${exp}`);
115
+ const state = r.state ? s.dim(`[${r.state}]`) : "";
116
+ const ws = args.allWorkspaces && r.workspaceId ? s.dim(` (workspace ${r.workspaceId})`) : "";
117
+ const label = r.display && r.display !== r.name ? ` ${s.dim(r.display)}` : "";
118
+ return ` ${s.bold(r.name)}${label} ${state} ${expTxt}${ws}`;
119
+ });
120
+ process.stdout.write(lines.join("\n") + "\n");
121
+ }
122
+ async function runGet(args) {
123
+ const name = requireName(args, "get");
124
+ const auth = await getAccessToken(args);
125
+ const parentWorkspaceId = auth.workspaceId;
126
+ const summary = await resolveLive(auth, parentWorkspaceId, name);
127
+ const microservices = summary.url === void 0 ? [] : await readMicroservices(auth, summary.url);
128
+ if (isMachineOutput(args)) {
129
+ writeJson({ ...summary, microservices });
130
+ return;
131
+ }
132
+ const s = stdoutStyle();
133
+ const rows = [];
134
+ if (summary.url) rows.push(["Base URL", s.bold(s.cyan(summary.url))]);
135
+ const label = summary.display && summary.display !== summary.name ? ` ${s.dim(summary.display)}` : "";
136
+ rows.push(["Tenant", `${s.bold(summary.name)}${label}`]);
137
+ if (summary.state) rows.push(["State", summary.state]);
138
+ rows.push(["Expires", s.dim(formatExpiration(summary.expiresAt))]);
139
+ process.stdout.write("\n" + formatFields(rows));
140
+ printMicroserviceSection(microservices);
141
+ }
142
+ async function runDelete(args) {
143
+ const name = requireName(args, "delete");
144
+ const auth = await getAccessToken(args);
145
+ const parentWorkspaceId = auth.workspaceId;
146
+ if (!args.yes && !args.force) {
147
+ const ok = await confirm(`Delete ephemeral "${name}"? This destroys it permanently.`, {
148
+ flag: "--yes",
149
+ helpFor: { command: "ephemeral", subcommand: "delete" }
150
+ });
151
+ if (!ok) {
152
+ info("Deletion cancelled.");
153
+ return;
154
+ }
155
+ }
156
+ const { alreadyGone } = await deleteEphemeral(auth, { parentWorkspaceId, name });
157
+ const cleared = clearStaleRecord(parentWorkspaceId, name);
158
+ if (alreadyGone) {
159
+ warn(`Ephemeral "${name}" was already gone${cleared ? " (cleared its local record)" : ""}.`);
160
+ } else {
161
+ success(`Deleted ephemeral ${name}${cleared ? " (cleared its local record)" : ""}`);
162
+ }
163
+ }
164
+ async function runExport(args) {
165
+ const name = requireName(args, "export");
166
+ const format = args.format ?? "json";
167
+ const auth = await getAccessToken(args);
168
+ const parentWorkspaceId = auth.workspaceId;
169
+ const summary = await resolveLive(auth, parentWorkspaceId, name);
170
+ const { content, ext } = format === "multidoc" ? { content: await fetchEphemeralMultidoc(auth, parentWorkspaceId, name), ext: "xs" } : { content: await fetchEphemeralJson(auth, summary, name), ext: "json" };
171
+ const target = resolveOutputTarget({ path: args.path, name, ext });
172
+ if (target.kind === "stdout") {
173
+ process.stdout.write(content + "\n");
174
+ return;
175
+ }
176
+ writeFileSync(target.path, content + "\n", "utf8");
177
+ step(`Exported ${format} \u2192 ${target.path}`);
178
+ success(`Wrote ${target.path}`);
179
+ }
180
+ async function fetchEphemeralMultidoc(auth, parentWorkspaceId, name) {
181
+ const url = new URL(`/api:meta/workspace/${parentWorkspaceId}/tenant/${name}/multidoc`, auth.instance);
182
+ const res = await fetch(url.href, {
183
+ headers: { accept: "text/x-xanoscript", Authorization: `Bearer ${auth.access_token}` },
184
+ signal: AbortSignal.timeout(TIMEOUT_MS)
185
+ });
186
+ const text = await res.text();
187
+ if (!res.ok) throw new Error(`ephemeral export (multidoc) failed (${res.status} ${res.statusText}):
188
+ ${text}`);
189
+ return text;
190
+ }
191
+ async function fetchEphemeralBundle(auth, summary, name) {
192
+ if (summary.url === void 0) throw goneError(name, false);
193
+ try {
194
+ return await exportWorkspaceBundle(auth, {
195
+ base: summary.url,
196
+ workspaceId: 1,
197
+ label: "ephemeral export (workspace export)"
198
+ });
199
+ } catch (err) {
200
+ if (err instanceof Error && /failed \(\d/.test(err.message)) throw err;
201
+ detail(err instanceof Error ? err.message : String(err));
202
+ throw goneError(name, false);
203
+ }
204
+ }
205
+ async function fetchEphemeralJson(auth, summary, name) {
206
+ return JSON.stringify(await fetchEphemeralBundle(auth, summary, name), null, 2);
207
+ }
208
+ async function runImpersonate(args) {
209
+ const name = requireName(args, "impersonate");
210
+ const auth = await getAccessToken(args);
211
+ const parentWorkspaceId = auth.workspaceId;
212
+ await resolveLive(auth, parentWorkspaceId, name);
213
+ const { _ti } = await impersonateEphemeral(auth, { parentWorkspaceId, name, guest: args.guest });
214
+ const url = new URL("/impersonate", auth.instance);
215
+ url.searchParams.set("_ti", _ti);
216
+ const dashboardUrl = url.href;
217
+ if (isMachineOutput(args)) {
218
+ writeJson({ _ti, url: dashboardUrl });
219
+ return;
220
+ }
221
+ if (args.urlOnly) {
222
+ process.stdout.write(dashboardUrl + "\n");
223
+ return;
224
+ }
225
+ step("Opening the Xano builder\u2026");
226
+ detail(dashboardUrl);
227
+ openBrowser(dashboardUrl);
228
+ success(`Impersonation session opened for ${name}${args.guest ? " (read-only guest)" : ""}`);
229
+ }
230
+ function requireName(args, verb) {
231
+ const name = args.positionals[0];
232
+ if (name === void 0 || name === "") {
233
+ throw new Error(`\`xanots ephemeral ${verb}\` needs a tenant name. Run \`xanots ephemeral list\` to see them.`);
234
+ }
235
+ return name;
236
+ }
237
+ export {
238
+ fetchEphemeralBundle,
239
+ resolveLive,
240
+ runEphemeralCommand
241
+ };
242
+ //# sourceMappingURL=ephemeral-command-3X3I4ULC.js.map