@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.
- package/LICENSE +21 -0
- package/README.md +384 -0
- package/dist/agent-file-refresh-7XCACU34.js +95 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +184 -0
- package/dist/capture-HUV5BNTC.js +32 -0
- package/dist/chunk-26CNBZE2.js +963 -0
- package/dist/chunk-33ND6LKO.js +78 -0
- package/dist/chunk-3DUAGYGP.js +1550 -0
- package/dist/chunk-3IGNIP6R.js +89 -0
- package/dist/chunk-47WDWMBJ.js +14 -0
- package/dist/chunk-4BXJGVZ3.js +318 -0
- package/dist/chunk-4HT3BNZ7.js +675 -0
- package/dist/chunk-4YMD2OOZ.js +23 -0
- package/dist/chunk-5WGEURVI.js +156 -0
- package/dist/chunk-5YTBTF25.js +29 -0
- package/dist/chunk-6DHBYBTO.js +166 -0
- package/dist/chunk-76QBEIGO.js +66 -0
- package/dist/chunk-7DKX2SPN.js +100 -0
- package/dist/chunk-7REDODS2.js +468 -0
- package/dist/chunk-C56BC2FY.js +254 -0
- package/dist/chunk-DGSF2Q5H.js +60 -0
- package/dist/chunk-EMCAWMHC.js +3982 -0
- package/dist/chunk-EZG76F7R.js +159 -0
- package/dist/chunk-FJ6ZS5KB.js +3607 -0
- package/dist/chunk-GNPVYOPB.js +17 -0
- package/dist/chunk-HJPTWBLH.js +38 -0
- package/dist/chunk-IZW6MK3U.js +248 -0
- package/dist/chunk-LH6Z6KFV.js +247 -0
- package/dist/chunk-MZUI3JNX.js +93 -0
- package/dist/chunk-NDZFBZHC.js +167 -0
- package/dist/chunk-NOO35BQ2.js +37 -0
- package/dist/chunk-NUQCEOKA.js +13 -0
- package/dist/chunk-QTNO2WD6.js +56 -0
- package/dist/chunk-RVB7ITKN.js +49 -0
- package/dist/chunk-TRU5OHQ5.js +6904 -0
- package/dist/chunk-VKFQJEMW.js +814 -0
- package/dist/chunk-VTIL47DT.js +125 -0
- package/dist/chunk-WHOJWOSV.js +112 -0
- package/dist/chunk-WKP4D5MO.js +1692 -0
- package/dist/chunk-X4DVXBFY.js +38 -0
- package/dist/chunk-XQ22GLYS.js +118 -0
- package/dist/chunk-YDZYMZBE.js +670 -0
- package/dist/chunk-YGPIY3WT.js +1146 -0
- package/dist/chunk-YYRDLFSJ.js +602 -0
- package/dist/chunk-ZUTSMMAG.js +46 -0
- package/dist/cli.d.ts +331 -0
- package/dist/cli.js +33 -0
- package/dist/codegen-command-OOKK6AZK.js +40 -0
- package/dist/codegen.d.ts +114 -0
- package/dist/codegen.js +71 -0
- package/dist/completion-TIPPZN7H.js +298 -0
- package/dist/config-NL33PN4D.js +84 -0
- package/dist/deploy-command-4EQ7XX5G.js +451 -0
- package/dist/env-target-IFJ5QDHC.js +16 -0
- package/dist/ephemeral-command-3X3I4ULC.js +242 -0
- package/dist/index.d.ts +4477 -0
- package/dist/index.js +300 -0
- package/dist/init-command-R6H7ZXW5.js +27 -0
- package/dist/internal.d.ts +74 -0
- package/dist/internal.js +2065 -0
- package/dist/io-AMIKRLPC.js +11 -0
- package/dist/live-diff-Y3AKETHE.js +196 -0
- package/dist/lock-3CVKALKT.js +37 -0
- package/dist/lock-commands-XTR2YKLY.js +232 -0
- package/dist/login-command-ACJF6KWQ.js +167 -0
- package/dist/logout-command-MX3MJS5U.js +68 -0
- package/dist/loop-OM3P2Z6O.js +93 -0
- package/dist/marketplace-command-RATXTKXN.js +379 -0
- package/dist/meta-client-OW5WKWW7.js +170 -0
- package/dist/node.d.ts +59 -0
- package/dist/node.js +442 -0
- package/dist/profile-command-SWJ3SPKR.js +77 -0
- package/dist/release-command-VV5UVZKL.js +427 -0
- package/dist/response-CVAE2kMj.d.ts +1915 -0
- package/dist/routes-manifest-SP3ZXLMR.js +244 -0
- package/dist/runtime-V4C3AC3A.js +13 -0
- package/dist/sandbox-details-command-HJE5SPVG.js +18 -0
- package/dist/sandbox-export-command-QCJY4GMV.js +24 -0
- package/dist/static-host-D6KS7X45.js +138 -0
- package/dist/store-BQ97nKIF.d.ts +7760 -0
- package/dist/test-command-TSPBQHBM.js +383 -0
- package/dist/validate-command-4ERHJSCO.js +122 -0
- package/dist/verify-rollout-FAVQ6EJY.js +40 -0
- package/dist/workspace-K72NP7SX.js +49 -0
- package/dist/workspace-command-OF23DPNI.js +156 -0
- package/dist/workspace-export-AJMGN3CQ.js +10 -0
- package/llms/fields.md +104 -0
- package/llms/filters.md +183 -0
- package/llms/kinds-agent-mcp.md +11 -0
- package/llms/kinds-core.md +68 -0
- package/llms/kinds-realtime.md +76 -0
- package/llms/lambda.md +111 -0
- package/llms/legacy.md +43 -0
- package/llms/object-kinds.md +31 -0
- package/llms/statements-calls.md +23 -0
- package/llms/statements-catalog.md +309 -0
- package/llms/statements-data.md +58 -0
- package/llms/statements-runtime.md +48 -0
- package/llms/tests.md +58 -0
- package/llms/triggers.md +22 -0
- package/llms/values.md +29 -0
- package/llms-full.txt +1672 -0
- package/llms.txt +483 -0
- package/manifest.json +9592 -0
- package/package.json +110 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/util/tar.ts
|
|
2
|
+
import { gzipSync } from "zlib";
|
|
3
|
+
function tarHeader(name, size) {
|
|
4
|
+
if (Buffer.byteLength(name, "utf8") > 100) {
|
|
5
|
+
throw new Error(`tar entry name too long for ustar (>100 bytes): ${name}`);
|
|
6
|
+
}
|
|
7
|
+
const h = Buffer.alloc(512, 0);
|
|
8
|
+
h.write(name, 0, "utf8");
|
|
9
|
+
h.write("0000644\0", 100, "ascii");
|
|
10
|
+
h.write("0000000\0", 108, "ascii");
|
|
11
|
+
h.write("0000000\0", 116, "ascii");
|
|
12
|
+
h.write(size.toString(8).padStart(11, "0") + "\0", 124, "ascii");
|
|
13
|
+
h.write("00000000000\0", 136, "ascii");
|
|
14
|
+
h.write(" ", 148, "ascii");
|
|
15
|
+
h.write("0", 156, "ascii");
|
|
16
|
+
h.write("ustar\0", 257, "ascii");
|
|
17
|
+
h.write("00", 263, "ascii");
|
|
18
|
+
let sum = 0;
|
|
19
|
+
for (let i = 0; i < 512; i++) sum += h[i];
|
|
20
|
+
h.write(sum.toString(8).padStart(6, "0") + "\0 ", 148, "ascii");
|
|
21
|
+
return h;
|
|
22
|
+
}
|
|
23
|
+
function tarGz(files) {
|
|
24
|
+
const blocks = [];
|
|
25
|
+
for (const f of files) {
|
|
26
|
+
blocks.push(tarHeader(f.name, f.data.length));
|
|
27
|
+
blocks.push(f.data);
|
|
28
|
+
const pad = (512 - f.data.length % 512) % 512;
|
|
29
|
+
if (pad > 0) blocks.push(Buffer.alloc(pad, 0));
|
|
30
|
+
}
|
|
31
|
+
blocks.push(Buffer.alloc(1024, 0));
|
|
32
|
+
return gzipSync(Buffer.concat(blocks));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
tarGz
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=chunk-X4DVXBFY.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
exportWorkspaceBundle
|
|
3
|
+
} from "./chunk-QTNO2WD6.js";
|
|
4
|
+
import {
|
|
5
|
+
sandboxBaseUrl
|
|
6
|
+
} from "./chunk-7DKX2SPN.js";
|
|
7
|
+
import {
|
|
8
|
+
getAccessToken
|
|
9
|
+
} from "./chunk-C56BC2FY.js";
|
|
10
|
+
import {
|
|
11
|
+
step,
|
|
12
|
+
success
|
|
13
|
+
} from "./chunk-EZG76F7R.js";
|
|
14
|
+
|
|
15
|
+
// src/emit/sandbox-export-command.ts
|
|
16
|
+
import { statSync, writeFileSync } from "fs";
|
|
17
|
+
import { join, resolve } from "path";
|
|
18
|
+
var SANDBOX_TIMEOUT_MS = 12e4;
|
|
19
|
+
var MULTIDOC_PATH = "/api:meta/sandbox/multidoc";
|
|
20
|
+
var SANDBOX_ME_PATH = "/api:meta/sandbox/me";
|
|
21
|
+
var DEFAULT_NAME = "sandbox";
|
|
22
|
+
var DEFAULT_FORMAT = "json";
|
|
23
|
+
function resolveOutputTarget(opts) {
|
|
24
|
+
const { path, name, ext } = opts;
|
|
25
|
+
if (path === "-") return { kind: "stdout" };
|
|
26
|
+
const basename = `${name ?? DEFAULT_NAME}.${ext}`;
|
|
27
|
+
if (path === void 0 || path === "") {
|
|
28
|
+
return { kind: "file", path: resolve(basename) };
|
|
29
|
+
}
|
|
30
|
+
const endsWithSep = path.endsWith("/") || path.endsWith("\\");
|
|
31
|
+
const isDir = statSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
32
|
+
if (endsWithSep || isDir) {
|
|
33
|
+
return { kind: "file", path: resolve(join(path, basename)) };
|
|
34
|
+
}
|
|
35
|
+
return { kind: "file", path: resolve(path) };
|
|
36
|
+
}
|
|
37
|
+
async function fetchSandboxMultidoc(auth) {
|
|
38
|
+
const url = new URL(MULTIDOC_PATH, auth.instance);
|
|
39
|
+
const res = await fetch(url.href, {
|
|
40
|
+
headers: {
|
|
41
|
+
accept: "text/x-xanoscript",
|
|
42
|
+
Authorization: `Bearer ${auth.access_token}`
|
|
43
|
+
},
|
|
44
|
+
signal: AbortSignal.timeout(SANDBOX_TIMEOUT_MS)
|
|
45
|
+
});
|
|
46
|
+
const text = await res.text();
|
|
47
|
+
if (!res.ok) {
|
|
48
|
+
throw new Error(`sandbox export (multidoc) failed (${res.status} ${res.statusText}):
|
|
49
|
+
${text}`);
|
|
50
|
+
}
|
|
51
|
+
return text;
|
|
52
|
+
}
|
|
53
|
+
async function getJson(url, auth, label) {
|
|
54
|
+
const res = await fetch(url, {
|
|
55
|
+
headers: { accept: "application/json", Authorization: `Bearer ${auth.access_token}` },
|
|
56
|
+
signal: AbortSignal.timeout(SANDBOX_TIMEOUT_MS)
|
|
57
|
+
});
|
|
58
|
+
const text = await res.text();
|
|
59
|
+
if (!res.ok) {
|
|
60
|
+
throw new Error(`sandbox export (${label}) failed (${res.status} ${res.statusText}):
|
|
61
|
+
${text}`);
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(text);
|
|
65
|
+
} catch {
|
|
66
|
+
throw new Error(`sandbox export (${label}): could not parse the response as JSON:
|
|
67
|
+
${text.slice(0, 200)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function fetchSandboxBundle(auth) {
|
|
71
|
+
const tenant = await getJson(`${auth.instance}${SANDBOX_ME_PATH}`, auth, "sandbox/me");
|
|
72
|
+
const base = sandboxBaseUrl(tenant, auth.instance);
|
|
73
|
+
const list = await getJson(`${base}/api:meta/workspace`, auth, "workspace list");
|
|
74
|
+
const workspaces = Array.isArray(list) ? list : [];
|
|
75
|
+
const workspaceId = workspaces.find((w) => typeof w.id === "number")?.id;
|
|
76
|
+
if (workspaceId === void 0) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`Your sandbox has no workspace to export yet. Run \`xanots deploy --dest sandbox\` first, then export.`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return exportWorkspaceBundle(auth, {
|
|
82
|
+
base,
|
|
83
|
+
workspaceId,
|
|
84
|
+
label: "sandbox export (workspace export)"
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async function fetchSandboxWorkspaceJson(auth) {
|
|
88
|
+
return JSON.stringify(await fetchSandboxBundle(auth), null, 2);
|
|
89
|
+
}
|
|
90
|
+
async function produce(args, format) {
|
|
91
|
+
if (args.bundle !== void 0) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`\`sandbox export\` takes no input \u2014 it exports the workspace CURRENTLY DEPLOYED to your sandbox (run \`xanots deploy --dest sandbox\` first). To compile a LOCAL workspace to JSON, use \`xanots export <file>\`.`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
const auth = await getAccessToken(args);
|
|
97
|
+
return format === "json" ? { content: await fetchSandboxWorkspaceJson(auth), ext: "json" } : { content: await fetchSandboxMultidoc(auth), ext: "xs" };
|
|
98
|
+
}
|
|
99
|
+
async function runSandboxExportCommand(args) {
|
|
100
|
+
const format = args.format ?? DEFAULT_FORMAT;
|
|
101
|
+
const { content, ext } = await produce(args, format);
|
|
102
|
+
const target = resolveOutputTarget({ path: args.path, name: args.name, ext });
|
|
103
|
+
if (target.kind === "stdout") {
|
|
104
|
+
process.stdout.write(content + "\n");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
writeFileSync(target.path, content + "\n", "utf8");
|
|
108
|
+
step(`Exported ${format} \u2192 ${target.path}`);
|
|
109
|
+
success(`Wrote ${target.path}`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export {
|
|
113
|
+
resolveOutputTarget,
|
|
114
|
+
fetchSandboxMultidoc,
|
|
115
|
+
fetchSandboxBundle,
|
|
116
|
+
runSandboxExportCommand
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=chunk-XQ22GLYS.js.map
|