@xanots/sdk 0.0.4 → 0.0.6

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 (78) hide show
  1. package/CHANGELOG.md +21 -10
  2. package/README.md +7 -3
  3. package/dist/.build-fingerprint +1 -0
  4. package/dist/{agent-file-refresh-IJ7GN2FJ.js → agent-file-refresh-6XT23SLU.js} +4 -4
  5. package/dist/bin.js +8 -8
  6. package/dist/branch-commands-R4FR75UW.js +134 -0
  7. package/dist/{chunk-7SISR3CS.js → chunk-2SUCC4DV.js} +2 -2
  8. package/dist/{chunk-BPEEGJJA.js → chunk-3FQD3QME.js} +3 -3
  9. package/dist/{chunk-EAIR6VUL.js → chunk-4HDOP7LH.js} +8 -67
  10. package/dist/chunk-4PTSTDIG.js +59 -0
  11. package/dist/{live-diff-FP4SFNT4.js → chunk-5HCDZ2XN.js} +67 -6
  12. package/dist/{chunk-5WGEURVI.js → chunk-6AAT2AYQ.js} +21 -1
  13. package/dist/{chunk-AJ7JQ4OU.js → chunk-AAFBSOSD.js} +3 -3
  14. package/dist/{chunk-VWGJQTNA.js → chunk-CEFYM6N5.js} +4 -4
  15. package/dist/{chunk-YUPQOLFX.js → chunk-CQBJNFDK.js} +2 -2
  16. package/dist/{chunk-FN4OQT2J.js → chunk-CU5VOSTW.js} +4 -4
  17. package/dist/{chunk-YUBJLB6G.js → chunk-EFH4NFPY.js} +6 -3
  18. package/dist/chunk-EQW3YT5U.js +159 -0
  19. package/dist/{chunk-CYJ7R3AD.js → chunk-GC7ZQHW7.js} +22 -10
  20. package/dist/{chunk-KGNJM4LN.js → chunk-JQLR64UC.js} +6 -5
  21. package/dist/{chunk-PXXLBXOP.js → chunk-JRGDLAEA.js} +2 -2
  22. package/dist/{chunk-7REDODS2.js → chunk-LLWK6H77.js} +20 -2
  23. package/dist/{chunk-WGDAOOXG.js → chunk-MU3O43L2.js} +3 -3
  24. package/dist/{chunk-YYSJAAJM.js → chunk-OKNSR7MT.js} +51 -3
  25. package/dist/{chunk-MFIHIS6B.js → chunk-OLQLJY5T.js} +2 -2
  26. package/dist/{chunk-ACQCK4DT.js → chunk-OR43PDCW.js} +2 -2
  27. package/dist/{chunk-QUUB7HYK.js → chunk-P5C2YKAM.js} +2 -2
  28. package/dist/{chunk-D6OGU2AI.js → chunk-P5OAM3G2.js} +2 -2
  29. package/dist/{chunk-6DHJVLYP.js → chunk-Q77KNEUL.js} +1 -1
  30. package/dist/{chunk-SWIXWJIY.js → chunk-QVSUMHNN.js} +3 -3
  31. package/dist/{chunk-C56BC2FY.js → chunk-SG4UBJ47.js} +2 -2
  32. package/dist/{chunk-DUC3PXDG.js → chunk-SOCYCBYG.js} +54 -27
  33. package/dist/{chunk-VKD3EBKG.js → chunk-TYBB7ON3.js} +58 -38
  34. package/dist/{chunk-VTIL47DT.js → chunk-W5NOKYEG.js} +6 -2
  35. package/dist/{chunk-DGSF2Q5H.js → chunk-WJYB7DSI.js} +2 -2
  36. package/dist/{chunk-T6N3VMMO.js → chunk-Y7BARS25.js} +2 -2
  37. package/dist/cli.d.ts +36 -3
  38. package/dist/cli.js +7 -7
  39. package/dist/{codegen-command-Z7WQMOJ7.js → codegen-command-6XXOIQ25.js} +18 -18
  40. package/dist/{completion-4GYN752B.js → completion-A6BZ3XGU.js} +8 -7
  41. package/dist/{deploy-command-M2S4HHLC.js → deploy-command-MTQQXPOO.js} +16 -16
  42. package/dist/{env-target-GSFCYHKZ.js → env-target-C5JFLDK3.js} +6 -6
  43. package/dist/{ephemeral-command-6WJW7LP6.js → ephemeral-command-K3UJSDS4.js} +13 -13
  44. package/dist/index.d.ts +67 -24
  45. package/dist/index.js +6 -6
  46. package/dist/init-command-AY4KSXR5.js +30 -0
  47. package/dist/internal.js +13 -11
  48. package/dist/{io-7VIA5SON.js → io-65CJNLYI.js} +3 -3
  49. package/dist/live-diff-QK4KC2FJ.js +12 -0
  50. package/dist/{lock-KXOJIGCG.js → lock-PDFCNYUW.js} +2 -2
  51. package/dist/{lock-commands-7IH7RSSP.js → lock-commands-MC6I3MZA.js} +8 -8
  52. package/dist/{login-command-QM5SBBI2.js → login-command-LCOOOPO2.js} +139 -36
  53. package/dist/{logout-command-THPASOHM.js → logout-command-J2AG5NKC.js} +2 -2
  54. package/dist/{marketplace-command-463DT7O7.js → marketplace-command-BCOAAN2I.js} +3 -3
  55. package/dist/{meta-client-OW5WKWW7.js → meta-client-57ZWVHST.js} +2 -2
  56. package/dist/node.js +10 -10
  57. package/dist/{profile-command-EUWPVWED.js → profile-command-ZPC2DPFV.js} +3 -3
  58. package/dist/{release-command-M4CVNTWL.js → release-command-V4K4IORX.js} +193 -25
  59. package/dist/{sandbox-details-command-BRII3QHG.js → sandbox-details-command-DMY2KGA2.js} +4 -4
  60. package/dist/{sandbox-export-command-PCZ5FL4U.js → sandbox-export-command-R6QMEK3D.js} +5 -5
  61. package/dist/scaffold.d.ts +10 -13
  62. package/dist/scaffold.js +3 -3
  63. package/dist/{test-command-U4G5Y3UM.js → test-command-OEBIGOPP.js} +8 -8
  64. package/dist/{upgrade-command-CKJ4BS2P.js → upgrade-command-52AAZ3NV.js} +13 -13
  65. package/dist/{validate-command-S5N37JRP.js → validate-command-KTLPSSH7.js} +10 -10
  66. package/dist/{workspace-command-RALSEJSW.js → workspace-command-LX5S5N2H.js} +24 -20
  67. package/guides/cli.md +1 -0
  68. package/guides/deploying.md +18 -0
  69. package/guides/environment.md +1 -1
  70. package/guides/scaffold.md +3 -2
  71. package/llms/statements-calls.md +1 -1
  72. package/llms/statements-data.md +2 -1
  73. package/llms-full.txt +4 -3
  74. package/llms.txt +1 -1
  75. package/manifest.json +6 -2
  76. package/package.json +1 -1
  77. package/dist/chunk-ALNQCWAW.js +0 -29
  78. package/dist/init-command-GJUPWTKA.js +0 -30
@@ -1,10 +1,14 @@
1
1
  import {
2
+ loopbackRedirectUri,
2
3
  openBrowser,
3
4
  startCallbackServer
4
- } from "./chunk-VTIL47DT.js";
5
+ } from "./chunk-W5NOKYEG.js";
6
+ import {
7
+ promptLine
8
+ } from "./chunk-4PTSTDIG.js";
5
9
  import {
6
10
  envMetaCredentialVarsSet
7
- } from "./chunk-C56BC2FY.js";
11
+ } from "./chunk-SG4UBJ47.js";
8
12
  import {
9
13
  CALLBACK_PATH,
10
14
  DEFAULT_PORT,
@@ -19,7 +23,10 @@ import {
19
23
  resolveAuthHost,
20
24
  resolveScope,
21
25
  writeCredential
22
- } from "./chunk-7REDODS2.js";
26
+ } from "./chunk-LLWK6H77.js";
27
+ import {
28
+ UsageError
29
+ } from "./chunk-JQLR64UC.js";
23
30
  import "./chunk-GNPVYOPB.js";
24
31
  import {
25
32
  blank,
@@ -30,23 +37,81 @@ import {
30
37
  success,
31
38
  warn
32
39
  } from "./chunk-EZG76F7R.js";
40
+ import "./chunk-OKNSR7MT.js";
33
41
 
34
42
  // src/emit/login-command.ts
35
43
  import * as client from "openid-client";
44
+
45
+ // src/auth/paste.ts
46
+ var EXAMPLE = "Paste either the full URL from your browser's address bar (http://127.0.0.1:\u2026/oauth/callback?code=\u2026) or just the code=\u2026 value from it.";
47
+ function normalizePastedCallback(input, ctx) {
48
+ const trimmed = input.trim();
49
+ if (trimmed === "") throw new Error(`Nothing was pasted. ${EXAMPLE}`);
50
+ const params = extractParams(trimmed, ctx);
51
+ const error = params.get("error");
52
+ if (error) {
53
+ const description = params.get("error_description");
54
+ const authError = new Error(
55
+ `Authorization server returned error: ${error}${description ? ` (${description})` : ""}`
56
+ );
57
+ authError.error = error;
58
+ throw authError;
59
+ }
60
+ if (!params.get("code")) {
61
+ throw new Error(`That paste carries no \`code\` value. ${EXAMPLE}`);
62
+ }
63
+ if (!params.get("iss")) params.set("iss", ctx.issuer);
64
+ return `${ctx.redirectUri}?${params.toString()}`;
65
+ }
66
+ function extractParams(trimmed, ctx) {
67
+ const url = parseUrl(trimmed);
68
+ if (url) return url.searchParams;
69
+ const queryStart = trimmed.indexOf("?");
70
+ if (queryStart !== -1 && isRecognizedQuery(trimmed.slice(queryStart + 1))) {
71
+ return new URLSearchParams(trimmed.slice(queryStart + 1));
72
+ }
73
+ if (isRecognizedQuery(trimmed)) return new URLSearchParams(trimmed);
74
+ return new URLSearchParams({ code: trimmed, state: ctx.state, iss: ctx.issuer });
75
+ }
76
+ function isRecognizedQuery(value) {
77
+ return /(^|&)(code|error)=/.test(value);
78
+ }
79
+ function parseUrl(value) {
80
+ try {
81
+ const url = new URL(value);
82
+ return url.protocol === "http:" || url.protocol === "https:" ? url : void 0;
83
+ } catch {
84
+ return void 0;
85
+ }
86
+ }
87
+
88
+ // src/emit/login-command.ts
36
89
  async function runLoginCommand(args) {
37
90
  const authHost = resolveAuthHost(args);
38
91
  const scope = resolveScope(args);
39
92
  const port = args.port ?? DEFAULT_PORT;
40
93
  assertHttpsOrigin(authHost, "--origin");
94
+ if (args.paste && port === 0) {
95
+ throw new UsageError(
96
+ "`--port 0` asks for an ephemeral port, which --paste cannot use: nothing is bound, so the port is only part of the redirect URL's identity. Drop --port to use the default.",
97
+ { helpFor: { command: "login" } }
98
+ );
99
+ }
41
100
  if (!args.force && reportAlreadySignedIn(resolveAuthFilePath(args, "write"))) return;
101
+ if (args.paste && process.stdin.isTTY !== true) {
102
+ throw new UsageError(
103
+ "`--paste` reads the authorization code back from you, so it needs a terminal. For automation, use the XANO_REFRESH_TOKEN / XANO_CLIENT_ID environment credential instead.",
104
+ { helpFor: { command: "login" } }
105
+ );
106
+ }
42
107
  step(`Signing in to ${hostLabel(authHost)}`);
43
108
  let record;
44
109
  try {
45
- record = await attemptLogin({ authHost, scope, port });
110
+ record = await attemptLogin({ authHost, scope, port, paste: args.paste });
46
111
  } catch (err) {
47
112
  if (oauthErrorCode(err) !== "invalid_client") throw err;
48
113
  warn("The registered client was rejected \u2014 re-registering and retrying once.");
49
- record = await attemptLogin({ authHost, scope, port });
114
+ record = await attemptLogin({ authHost, scope, port, paste: args.paste, retry: true });
50
115
  }
51
116
  const authFilePath = resolveAuthFilePath(args, "write");
52
117
  writeCredential(authFilePath, record);
@@ -98,36 +163,7 @@ function reportAlreadySignedIn(authFilePath) {
98
163
  async function attemptLogin(p) {
99
164
  const verifier = client.randomPKCECodeVerifier();
100
165
  const state = client.randomState();
101
- let listener;
102
- try {
103
- listener = await startCallbackServer({ callbackPath: CALLBACK_PATH, expectedState: state, port: p.port });
104
- } catch (err) {
105
- const code = err.code;
106
- if (code === "EADDRINUSE") {
107
- throw new Error(`Loopback port ${p.port} is in use. Pass a free one with --port <n> and retry.`);
108
- }
109
- throw err;
110
- }
111
- const provider = new OpenIdProvider({ authHost: p.authHost, redirectUri: listener.redirectUri, scope: p.scope });
112
- let authorizeUrl;
113
- try {
114
- authorizeUrl = await provider.buildAuthUrl({ verifier, state });
115
- } catch (err) {
116
- listener.close();
117
- throw err;
118
- }
119
- detail("Opening your browser to authorize \u2014 waiting for you to finish\u2026");
120
- detail("If it doesn't open, paste this URL into your browser:");
121
- detail(authorizeUrl);
122
- openBrowser(authorizeUrl);
123
- let callbackUrl;
124
- try {
125
- ({ callbackUrl } = await listener.waitForCallback);
126
- } catch (err) {
127
- listener.close();
128
- if (oauthErrorCode(err) === "invalid_client") await provider.reset();
129
- throw err;
130
- }
166
+ const { callbackUrl, provider } = p.paste ? await acquireByPaste({ ...p, verifier, state }) : await acquireByLoopback({ ...p, verifier, state });
131
167
  let tokens;
132
168
  try {
133
169
  tokens = await provider.exchange(callbackUrl, { verifier, state });
@@ -161,7 +197,74 @@ async function attemptLogin(p) {
161
197
  client_id: provider.clientId()
162
198
  };
163
199
  }
200
+ var MAX_PASTE_ATTEMPTS = 3;
201
+ async function acquireByLoopback(p) {
202
+ let listener;
203
+ try {
204
+ listener = await startCallbackServer({ callbackPath: CALLBACK_PATH, expectedState: p.state, port: p.port });
205
+ } catch (err) {
206
+ const code = err.code;
207
+ if (code === "EADDRINUSE") {
208
+ throw new Error(`Loopback port ${p.port} is in use. Pass a free one with --port <n> and retry.`);
209
+ }
210
+ throw err;
211
+ }
212
+ const provider = new OpenIdProvider({ authHost: p.authHost, redirectUri: listener.redirectUri, scope: p.scope });
213
+ let authorizeUrl;
214
+ try {
215
+ authorizeUrl = await provider.buildAuthUrl({ verifier: p.verifier, state: p.state });
216
+ } catch (err) {
217
+ listener.close();
218
+ throw err;
219
+ }
220
+ detail("Opening your browser to authorize \u2014 waiting for you to finish\u2026");
221
+ detail("If it doesn't open, paste this URL into your browser:");
222
+ detail(authorizeUrl);
223
+ openBrowser(authorizeUrl);
224
+ try {
225
+ const { callbackUrl } = await listener.waitForCallback;
226
+ return { callbackUrl, provider };
227
+ } catch (err) {
228
+ listener.close();
229
+ if (oauthErrorCode(err) === "invalid_client") await provider.reset();
230
+ throw err;
231
+ }
232
+ }
233
+ async function acquireByPaste(p) {
234
+ const redirectUri = loopbackRedirectUri(p.port, CALLBACK_PATH);
235
+ const provider = new OpenIdProvider({ authHost: p.authHost, redirectUri, scope: p.scope });
236
+ const authorizeUrl = await provider.buildAuthUrl({ verifier: p.verifier, state: p.state });
237
+ blank();
238
+ if (p.retry) detail("Starting over with a freshly registered client \u2014 this is a NEW link and a NEW code.");
239
+ detail("Open this URL in any browser and finish signing in:");
240
+ detail(authorizeUrl);
241
+ blank();
242
+ detail(
243
+ `Your browser will then fail to load ${redirectUri} \u2014 that is expected, nothing is listening here. The address bar is what you want.`
244
+ );
245
+ openBrowser(authorizeUrl);
246
+ for (let attempt = 0; ; attempt++) {
247
+ const pasted = await promptLine("Paste that URL (or just the code from it):", {
248
+ noTtyHint: "--paste has to read the code from you, so it needs a terminal. For automation, use the XANO_REFRESH_TOKEN / XANO_CLIENT_ID environment credential instead.",
249
+ helpFor: { command: "login" }
250
+ });
251
+ try {
252
+ const callbackUrl = normalizePastedCallback(pasted, {
253
+ redirectUri,
254
+ state: p.state,
255
+ issuer: provider.issuer()
256
+ });
257
+ return { callbackUrl, provider };
258
+ } catch (err) {
259
+ if (oauthErrorCode(err) === "invalid_client") await provider.reset();
260
+ const unreadable = oauthErrorCode(err) === void 0;
261
+ if (!unreadable || attempt + 1 >= MAX_PASTE_ATTEMPTS) throw err;
262
+ warn(`${err instanceof Error ? err.message : String(err)}`);
263
+ detail("The link above is still valid \u2014 try pasting again.");
264
+ }
265
+ }
266
+ }
164
267
  export {
165
268
  runLoginCommand
166
269
  };
167
- //# sourceMappingURL=login-command-QM5SBBI2.js.map
270
+ //# sourceMappingURL=login-command-LCOOOPO2.js.map
@@ -5,7 +5,7 @@ import {
5
5
  readCredential,
6
6
  resolveAuthFilePath,
7
7
  resolveScope
8
- } from "./chunk-7REDODS2.js";
8
+ } from "./chunk-LLWK6H77.js";
9
9
  import "./chunk-GNPVYOPB.js";
10
10
  import {
11
11
  detail,
@@ -65,4 +65,4 @@ async function runLogoutCommand(args) {
65
65
  export {
66
66
  runLogoutCommand
67
67
  };
68
- //# sourceMappingURL=logout-command-THPASOHM.js.map
68
+ //# sourceMappingURL=logout-command-J2AG5NKC.js.map
@@ -15,7 +15,7 @@ import {
15
15
  UsageError,
16
16
  indentBlock,
17
17
  missingArgument
18
- } from "./chunk-KGNJM4LN.js";
18
+ } from "./chunk-JQLR64UC.js";
19
19
  import {
20
20
  blank,
21
21
  detail,
@@ -26,7 +26,7 @@ import {
26
26
  success,
27
27
  warn
28
28
  } from "./chunk-EZG76F7R.js";
29
- import "./chunk-YYSJAAJM.js";
29
+ import "./chunk-OKNSR7MT.js";
30
30
 
31
31
  // src/emit/marketplace-catalogue.ts
32
32
  var DEFAULT_BASE_URL = "https://xare-rvr8-mnnt.dev.xano.io";
@@ -362,4 +362,4 @@ export {
362
362
  runMarketplaceListCommand,
363
363
  runMarketplaceSearchCommand
364
364
  };
365
- //# sourceMappingURL=marketplace-command-463DT7O7.js.map
365
+ //# sourceMappingURL=marketplace-command-BCOAAN2I.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  importWorkspaceArchive
3
- } from "./chunk-5WGEURVI.js";
3
+ } from "./chunk-6AAT2AYQ.js";
4
4
  import {
5
5
  createEphemeral,
6
6
  deleteEphemeral,
@@ -167,4 +167,4 @@ ${text}`);
167
167
  export {
168
168
  MetaClient
169
169
  };
170
- //# sourceMappingURL=meta-client-OW5WKWW7.js.map
170
+ //# sourceMappingURL=meta-client-57ZWVHST.js.map
package/dist/node.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  TEST_EXPECT_TYPES,
7
7
  expect
8
- } from "./chunk-PXXLBXOP.js";
8
+ } from "./chunk-JRGDLAEA.js";
9
9
  import {
10
10
  addon,
11
11
  agent,
@@ -17,7 +17,7 @@ import {
17
17
  task,
18
18
  tool,
19
19
  workflowTest
20
- } from "./chunk-FN4OQT2J.js";
20
+ } from "./chunk-CU5VOSTW.js";
21
21
  import {
22
22
  actionCall,
23
23
  actionPackageCall,
@@ -100,7 +100,7 @@ import {
100
100
  workflowTestCall,
101
101
  workspaceConfig,
102
102
  workspaceTrigger
103
- } from "./chunk-CYJ7R3AD.js";
103
+ } from "./chunk-GC7ZQHW7.js";
104
104
  import {
105
105
  exportBundleJson,
106
106
  loadDefault,
@@ -108,19 +108,19 @@ import {
108
108
  run,
109
109
  writeArtifact,
110
110
  writeBundle
111
- } from "./chunk-DUC3PXDG.js";
112
- import "./chunk-KGNJM4LN.js";
111
+ } from "./chunk-SOCYCBYG.js";
112
+ import "./chunk-JQLR64UC.js";
113
113
  import {
114
114
  readLockFile,
115
115
  writeLockFile
116
- } from "./chunk-MFIHIS6B.js";
116
+ } from "./chunk-OLQLJY5T.js";
117
117
  import "./chunk-GNPVYOPB.js";
118
118
  import "./chunk-EZG76F7R.js";
119
119
  import {
120
120
  Xano,
121
121
  workspace
122
- } from "./chunk-BPEEGJJA.js";
123
- import "./chunk-YYSJAAJM.js";
122
+ } from "./chunk-3FQD3QME.js";
123
+ import "./chunk-OKNSR7MT.js";
124
124
  import {
125
125
  LAMBDA_BINDINGS,
126
126
  LAMBDA_CODE_FILTERS,
@@ -167,7 +167,7 @@ import {
167
167
  toSearchParams,
168
168
  toolset,
169
169
  withFilters
170
- } from "./chunk-YUPQOLFX.js";
170
+ } from "./chunk-CQBJNFDK.js";
171
171
  import "./chunk-WHOJWOSV.js";
172
172
  import {
173
173
  annotate,
@@ -176,7 +176,7 @@ import {
176
176
  import {
177
177
  resetLockOverrides,
178
178
  seedLockOverrides
179
- } from "./chunk-YUBJLB6G.js";
179
+ } from "./chunk-EFH4NFPY.js";
180
180
 
181
181
  // src/values/lambda-file.ts
182
182
  import { readFileSync } from "fs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getAccessToken
3
- } from "./chunk-C56BC2FY.js";
4
- import "./chunk-7REDODS2.js";
3
+ } from "./chunk-SG4UBJ47.js";
4
+ import "./chunk-LLWK6H77.js";
5
5
  import {
6
6
  isMachineOutput,
7
7
  writeJson
@@ -74,4 +74,4 @@ export {
74
74
  fetchProfile,
75
75
  runProfileCommand
76
76
  };
77
- //# sourceMappingURL=profile-command-EUWPVWED.js.map
77
+ //# sourceMappingURL=profile-command-ZPC2DPFV.js.map