deepspace 0.6.1 → 0.7.0
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/CHANGELOG.md +31 -0
- package/dist/cli.js +446 -92
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +126 -1
- package/dist/index.js +148 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +53 -1
- package/dist/server.js +86 -1
- package/dist/server.js.map +1 -1
- package/dist/worker.d.ts +199 -2
- package/dist/worker.js +191 -1
- package/dist/worker.js.map +1 -1
- package/features/ai-chat/src/ChatPanel.tsx +70 -30
- package/package.json +1 -1
- package/dist/testing.d.ts +0 -115
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli/cli.ts
|
|
4
|
-
import { defineCommand as
|
|
4
|
+
import { defineCommand as defineCommand24, runMain } from "citty";
|
|
5
5
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
6
6
|
import { readFileSync as readFileSync17, existsSync as existsSync15 } from "fs";
|
|
7
7
|
import { dirname as dirname5, join as join16 } from "path";
|
|
@@ -3822,8 +3822,360 @@ var apps_default = defineCommand11({
|
|
|
3822
3822
|
}
|
|
3823
3823
|
});
|
|
3824
3824
|
|
|
3825
|
-
// src/cli/commands/
|
|
3825
|
+
// src/cli/commands/logs.ts
|
|
3826
3826
|
import { defineCommand as defineCommand12 } from "citty";
|
|
3827
|
+
|
|
3828
|
+
// src/shared/log-events.ts
|
|
3829
|
+
var LOG_LEVELS = ["debug", "log", "info", "warn", "error"];
|
|
3830
|
+
|
|
3831
|
+
// src/cli/commands/logs.ts
|
|
3832
|
+
var DEPLOY_URL6 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
3833
|
+
var RETENTION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
3834
|
+
var DEFAULT_WINDOW_MS = 15 * 60 * 1e3;
|
|
3835
|
+
var MIN_POLL_MS = 2500;
|
|
3836
|
+
var FOLLOW_LAG_MS = 9e4;
|
|
3837
|
+
function followInitialLimit(limit, maxLimit) {
|
|
3838
|
+
return limit ?? maxLimit;
|
|
3839
|
+
}
|
|
3840
|
+
function nextPollSince(cursor, floor, lagMs = FOLLOW_LAG_MS) {
|
|
3841
|
+
return Math.max(cursor - lagMs, floor);
|
|
3842
|
+
}
|
|
3843
|
+
function parseSince(input, now = Date.now()) {
|
|
3844
|
+
const trimmed = input.trim();
|
|
3845
|
+
const rel = /^(\d+)([smhd])$/.exec(trimmed);
|
|
3846
|
+
let ts;
|
|
3847
|
+
if (rel) {
|
|
3848
|
+
const unit = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 }[rel[2]];
|
|
3849
|
+
ts = now - Number(rel[1]) * unit;
|
|
3850
|
+
} else {
|
|
3851
|
+
ts = Date.parse(trimmed);
|
|
3852
|
+
if (Number.isNaN(ts)) {
|
|
3853
|
+
throw new Error(`Invalid --since "${input}" \u2014 use 30s, 15m, 2h, 7d, or an ISO timestamp.`);
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
if (now - ts > RETENTION_MS) {
|
|
3857
|
+
throw new Error("Logs are retained for 7 days \u2014 --since can reach back at most 7d.");
|
|
3858
|
+
}
|
|
3859
|
+
return ts;
|
|
3860
|
+
}
|
|
3861
|
+
var SeenEvents = class {
|
|
3862
|
+
constructor(cap = 5e3) {
|
|
3863
|
+
this.cap = cap;
|
|
3864
|
+
}
|
|
3865
|
+
ids = /* @__PURE__ */ new Set();
|
|
3866
|
+
order = [];
|
|
3867
|
+
/** Returns only the events not seen before, recording them. */
|
|
3868
|
+
fresh(events) {
|
|
3869
|
+
const out = [];
|
|
3870
|
+
for (const e of events) {
|
|
3871
|
+
if (this.ids.has(e.id)) continue;
|
|
3872
|
+
this.ids.add(e.id);
|
|
3873
|
+
this.order.push(e.id);
|
|
3874
|
+
out.push(e);
|
|
3875
|
+
}
|
|
3876
|
+
while (this.order.length > this.cap) {
|
|
3877
|
+
this.ids.delete(this.order.shift());
|
|
3878
|
+
}
|
|
3879
|
+
return out;
|
|
3880
|
+
}
|
|
3881
|
+
};
|
|
3882
|
+
var stdoutColor = () => process.stdout.isTTY && !process.env.NO_COLOR;
|
|
3883
|
+
var stderrColor = () => process.stderr.isTTY && !process.env.NO_COLOR;
|
|
3884
|
+
var paint = (code, s, on) => on ? `\x1B[${code}m${s}\x1B[0m` : s;
|
|
3885
|
+
var LEVEL_STYLE = {
|
|
3886
|
+
error: "31",
|
|
3887
|
+
// red
|
|
3888
|
+
warn: "33",
|
|
3889
|
+
// yellow
|
|
3890
|
+
debug: "2",
|
|
3891
|
+
// dim
|
|
3892
|
+
info: null,
|
|
3893
|
+
log: null
|
|
3894
|
+
};
|
|
3895
|
+
function formatTime(ts, now) {
|
|
3896
|
+
const d = new Date(ts);
|
|
3897
|
+
const ref = new Date(now);
|
|
3898
|
+
const hms = `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}:${String(d.getSeconds()).padStart(2, "0")}.${String(d.getMilliseconds()).padStart(3, "0")}`;
|
|
3899
|
+
if (d.toDateString() === ref.toDateString()) return hms;
|
|
3900
|
+
const ymd = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
3901
|
+
return `${ymd} ${hms}`;
|
|
3902
|
+
}
|
|
3903
|
+
function formatEvent(e, color, now = Date.now()) {
|
|
3904
|
+
const time = paint("2", formatTime(e.timestamp, now), color);
|
|
3905
|
+
let tag;
|
|
3906
|
+
let body;
|
|
3907
|
+
if (e.eventType === "exception" && e.exception) {
|
|
3908
|
+
tag = paint("31", "ERROR", color);
|
|
3909
|
+
const where = e.request ? ` \u2014 ${e.request.method} ${e.request.path}` : "";
|
|
3910
|
+
body = `${e.exception.name}: ${e.exception.message}${where}`;
|
|
3911
|
+
if (e.exception.stack) {
|
|
3912
|
+
const lines = e.exception.stack.split("\n");
|
|
3913
|
+
const firstIsHeader = lines.length > 0 && !/^\s*at\s/.test(lines[0]) && lines[0].includes(e.exception.message);
|
|
3914
|
+
const frames = (firstIsHeader ? lines.slice(1) : lines).map((l) => " " + l.trim()).filter((l) => l.trim().length > 0);
|
|
3915
|
+
if (frames.length) body += "\n" + paint("2", frames.join("\n"), color);
|
|
3916
|
+
}
|
|
3917
|
+
} else if (e.eventType === "request" && e.request) {
|
|
3918
|
+
tag = paint("36", "REQ ", color);
|
|
3919
|
+
const status3 = e.request.status !== void 0 ? ` ${e.request.status}` : "";
|
|
3920
|
+
const outcome = e.outcome && e.outcome !== "ok" ? ` (${e.outcome})` : "";
|
|
3921
|
+
body = `${e.request.method} ${e.request.path}${status3}${outcome}`;
|
|
3922
|
+
} else {
|
|
3923
|
+
const style = LEVEL_STYLE[e.level];
|
|
3924
|
+
tag = (e.level.toUpperCase() + " ").slice(0, 5);
|
|
3925
|
+
if (style) tag = paint(style, tag, color);
|
|
3926
|
+
body = style ? paint(style, e.message, color) : e.message;
|
|
3927
|
+
}
|
|
3928
|
+
const client = e.source === "client" ? paint("35", "CLIENT", color) + " " : "";
|
|
3929
|
+
return `${time} ${client}${tag} ${body}`;
|
|
3930
|
+
}
|
|
3931
|
+
var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
3932
|
+
var logs_default = defineCommand12({
|
|
3933
|
+
meta: {
|
|
3934
|
+
name: "logs",
|
|
3935
|
+
description: "Show production logs for a deployed app (add --follow to tail)"
|
|
3936
|
+
},
|
|
3937
|
+
args: {
|
|
3938
|
+
app: {
|
|
3939
|
+
type: "string",
|
|
3940
|
+
alias: "a",
|
|
3941
|
+
description: "App id or name (default: DEEPSPACE_APP_ID from the nearest wrangler.toml)",
|
|
3942
|
+
required: false
|
|
3943
|
+
},
|
|
3944
|
+
env: {
|
|
3945
|
+
type: "string",
|
|
3946
|
+
alias: "e",
|
|
3947
|
+
description: "wrangler.toml [env.<name>] slot \u2014 reads that env\u2019s own app id",
|
|
3948
|
+
required: false
|
|
3949
|
+
},
|
|
3950
|
+
follow: {
|
|
3951
|
+
type: "boolean",
|
|
3952
|
+
alias: "f",
|
|
3953
|
+
description: "Keep polling for new logs until Ctrl+C (~3s cadence)",
|
|
3954
|
+
default: false
|
|
3955
|
+
},
|
|
3956
|
+
since: {
|
|
3957
|
+
type: "string",
|
|
3958
|
+
description: "Window start: 30s, 15m, 2h, 24h, 7d, or an ISO timestamp (default 15m)",
|
|
3959
|
+
required: false
|
|
3960
|
+
},
|
|
3961
|
+
level: {
|
|
3962
|
+
type: "string",
|
|
3963
|
+
description: `Only events at a level: ${LOG_LEVELS.join(", ")}`,
|
|
3964
|
+
required: false
|
|
3965
|
+
},
|
|
3966
|
+
search: {
|
|
3967
|
+
type: "string",
|
|
3968
|
+
description: "Only events whose message contains this text",
|
|
3969
|
+
required: false
|
|
3970
|
+
},
|
|
3971
|
+
limit: {
|
|
3972
|
+
type: "string",
|
|
3973
|
+
description: "Max events per fetch (default 100, max 500)",
|
|
3974
|
+
required: false
|
|
3975
|
+
},
|
|
3976
|
+
json: {
|
|
3977
|
+
type: "boolean",
|
|
3978
|
+
description: "Emit NDJSON \u2014 one event object per line (for agents/pipes)",
|
|
3979
|
+
default: false
|
|
3980
|
+
}
|
|
3981
|
+
},
|
|
3982
|
+
async run({ args }) {
|
|
3983
|
+
const token = await ensureToken();
|
|
3984
|
+
const wranglerEnv = args.env?.trim() || void 0;
|
|
3985
|
+
if (args.app && wranglerEnv) {
|
|
3986
|
+
throw new Error(
|
|
3987
|
+
"Pass either --app or --env, not both \u2014 --env reads the [env.<name>] block\u2019s own app id, --app names an app directly."
|
|
3988
|
+
);
|
|
3989
|
+
}
|
|
3990
|
+
let appId;
|
|
3991
|
+
if (!args.app && wranglerEnv) {
|
|
3992
|
+
const appDir = findAppDir();
|
|
3993
|
+
const id = appDir ? readAppId(appDir, wranglerEnv) : null;
|
|
3994
|
+
if (!id) {
|
|
3995
|
+
throw new Error(
|
|
3996
|
+
`No app id for env "${wranglerEnv}" \u2014 wrangler.toml has no [env.${wranglerEnv}] block with its own DEEPSPACE_APP_ID.`
|
|
3997
|
+
);
|
|
3998
|
+
}
|
|
3999
|
+
appId = id;
|
|
4000
|
+
} else {
|
|
4001
|
+
appId = await resolveAppTarget(DEPLOY_URL6, token, args.app);
|
|
4002
|
+
}
|
|
4003
|
+
if (args.level && !LOG_LEVELS.includes(args.level)) {
|
|
4004
|
+
throw new Error(`Invalid --level "${args.level}". Use: ${LOG_LEVELS.join(", ")}`);
|
|
4005
|
+
}
|
|
4006
|
+
let limit;
|
|
4007
|
+
if (args.limit !== void 0) {
|
|
4008
|
+
limit = Number(args.limit);
|
|
4009
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 500) {
|
|
4010
|
+
throw new Error("Invalid --limit \u2014 expected an integer between 1 and 500.");
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
const initialSince = args.since ? parseSince(args.since) : Date.now() - DEFAULT_WINDOW_MS;
|
|
4014
|
+
const windowLabel = args.since?.trim() || "15m";
|
|
4015
|
+
const MAX_LIMIT = 500;
|
|
4016
|
+
const followLimit = followInitialLimit(limit, MAX_LIMIT);
|
|
4017
|
+
const fetchPage = async (since, pageLimit, token2) => {
|
|
4018
|
+
const params = new URLSearchParams({ since: String(since) });
|
|
4019
|
+
if (pageLimit !== void 0) params.set("limit", String(pageLimit));
|
|
4020
|
+
if (args.level) params.set("level", args.level);
|
|
4021
|
+
if (args.search) params.set("search", args.search);
|
|
4022
|
+
return apiFetch(DEPLOY_URL6, token2, `/api/apps/${appId}/logs?${params}`);
|
|
4023
|
+
};
|
|
4024
|
+
const print = (events) => {
|
|
4025
|
+
for (const e of events) {
|
|
4026
|
+
process.stdout.write(args.json ? JSON.stringify(e) + "\n" : formatEvent(e, stdoutColor()) + "\n");
|
|
4027
|
+
}
|
|
4028
|
+
};
|
|
4029
|
+
const first = await fetchPage(initialSince, args.follow ? followLimit : limit, token);
|
|
4030
|
+
print(first.events);
|
|
4031
|
+
if (!args.follow) {
|
|
4032
|
+
if (first.events.length === 0 && !args.json) {
|
|
4033
|
+
console.log(
|
|
4034
|
+
`No logs in the last ${windowLabel} for ${appId}. New logs can take up to a minute to appear; retention is 7 days.`
|
|
4035
|
+
);
|
|
4036
|
+
} else if (first.truncated) {
|
|
4037
|
+
if (args.json) process.stdout.write(JSON.stringify({ type: "meta", truncated: true }) + "\n");
|
|
4038
|
+
else console.error(`(showing the newest ${first.events.length} events \u2014 narrow with --since/--level/--search)`);
|
|
4039
|
+
}
|
|
4040
|
+
return;
|
|
4041
|
+
}
|
|
4042
|
+
process.on("SIGINT", () => process.exit(0));
|
|
4043
|
+
if (!args.json) {
|
|
4044
|
+
console.error(`Tailing logs for ${appId} \u2014 Ctrl+C to stop.`);
|
|
4045
|
+
}
|
|
4046
|
+
const seen = new SeenEvents();
|
|
4047
|
+
seen.fresh(first.events);
|
|
4048
|
+
let cursor = first.cursor ?? initialSince;
|
|
4049
|
+
let interval = Math.max(first.pollIntervalMs || 0, MIN_POLL_MS);
|
|
4050
|
+
let backoff = 0;
|
|
4051
|
+
let warnedTruncated = false;
|
|
4052
|
+
if (first.truncated) {
|
|
4053
|
+
warnedTruncated = true;
|
|
4054
|
+
if (args.json) {
|
|
4055
|
+
process.stdout.write(JSON.stringify({ type: "meta", truncated: true }) + "\n");
|
|
4056
|
+
} else {
|
|
4057
|
+
console.error(
|
|
4058
|
+
paint("33", `(more than ${followLimit} events in the initial ${windowLabel} window \u2014 some older events not shown; narrow with --since/--level/--search)`, stderrColor())
|
|
4059
|
+
);
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
for (; ; ) {
|
|
4063
|
+
await sleep2(backoff || interval);
|
|
4064
|
+
const freshToken = await ensureToken();
|
|
4065
|
+
let page;
|
|
4066
|
+
try {
|
|
4067
|
+
page = await fetchPage(nextPollSince(cursor, initialSince), followLimit, freshToken);
|
|
4068
|
+
} catch (err) {
|
|
4069
|
+
if (err instanceof ApiError && [401, 403, 404].includes(err.status)) throw err;
|
|
4070
|
+
backoff = Math.min(backoff ? backoff * 2 : MIN_POLL_MS, 3e4);
|
|
4071
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
4072
|
+
console.error(paint("2", `(logs fetch failed: ${msg} \u2014 retrying in ${backoff / 1e3}s)`, stderrColor()));
|
|
4073
|
+
continue;
|
|
4074
|
+
}
|
|
4075
|
+
backoff = 0;
|
|
4076
|
+
interval = Math.max(page.pollIntervalMs || 0, MIN_POLL_MS);
|
|
4077
|
+
const fresh = seen.fresh(page.events);
|
|
4078
|
+
print(fresh);
|
|
4079
|
+
const realDrop = fresh.length >= followLimit;
|
|
4080
|
+
if (realDrop && !warnedTruncated) {
|
|
4081
|
+
warnedTruncated = true;
|
|
4082
|
+
if (args.json) {
|
|
4083
|
+
process.stdout.write(JSON.stringify({ type: "meta", truncated: true }) + "\n");
|
|
4084
|
+
} else {
|
|
4085
|
+
console.error(
|
|
4086
|
+
paint("33", `(burst exceeded ${followLimit} events/poll \u2014 some may be dropped; narrow with --level/--search)`, stderrColor())
|
|
4087
|
+
);
|
|
4088
|
+
}
|
|
4089
|
+
} else if (!realDrop) {
|
|
4090
|
+
warnedTruncated = false;
|
|
4091
|
+
}
|
|
4092
|
+
if (page.cursor !== null) cursor = page.cursor;
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
});
|
|
4096
|
+
|
|
4097
|
+
// src/cli/commands/usage.ts
|
|
4098
|
+
import { defineCommand as defineCommand13 } from "citty";
|
|
4099
|
+
var API_URL3 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
4100
|
+
function formatCredits(value) {
|
|
4101
|
+
if (value > 0 && value < 1) return "<1";
|
|
4102
|
+
if (value < 10) return value.toFixed(1).replace(/\.0$/, "");
|
|
4103
|
+
return Math.round(value).toLocaleString("en-US");
|
|
4104
|
+
}
|
|
4105
|
+
function formatUsd(value) {
|
|
4106
|
+
return `$${Math.abs(value) >= 0.01 || value === 0 ? value.toFixed(2) : value.toFixed(4)}`;
|
|
4107
|
+
}
|
|
4108
|
+
function formatDate(iso) {
|
|
4109
|
+
return new Date(iso).toLocaleDateString("en-US", {
|
|
4110
|
+
month: "short",
|
|
4111
|
+
day: "numeric",
|
|
4112
|
+
year: "numeric",
|
|
4113
|
+
timeZone: "UTC"
|
|
4114
|
+
});
|
|
4115
|
+
}
|
|
4116
|
+
function renderSummary(summary) {
|
|
4117
|
+
const { credits, usageByIntegration } = summary;
|
|
4118
|
+
const lines = [];
|
|
4119
|
+
const renews = credits.subscription.renewsAt ? ` \xB7 renews ${formatDate(credits.subscription.renewsAt)}` : "";
|
|
4120
|
+
lines.push(`Plan: ${credits.subscription.tier}${renews}`);
|
|
4121
|
+
lines.push(
|
|
4122
|
+
`Credits: ${formatCredits(credits.credits)} of ${formatCredits(credits.totalAllocation)} remaining (100 credits = $1)`
|
|
4123
|
+
);
|
|
4124
|
+
const bonusActive = credits.bonus.allocation > 0 || credits.bonus.expired;
|
|
4125
|
+
const purchasedActive = credits.purchased.allocation > 0 || credits.purchased.used > 0;
|
|
4126
|
+
if (bonusActive || purchasedActive) {
|
|
4127
|
+
const bucket = (b) => `${formatCredits(b.remaining)} of ${formatCredits(b.allocation)} remaining`;
|
|
4128
|
+
lines.push(` Subscription: ${bucket(credits.subscription)}`);
|
|
4129
|
+
if (bonusActive) {
|
|
4130
|
+
const expires = credits.bonus.expiresAt ? ` \xB7 expires ${formatDate(credits.bonus.expiresAt)}` : "";
|
|
4131
|
+
lines.push(
|
|
4132
|
+
` Bonus: ${credits.bonus.expired ? "expired" : bucket(credits.bonus) + expires}`
|
|
4133
|
+
);
|
|
4134
|
+
}
|
|
4135
|
+
if (purchasedActive) {
|
|
4136
|
+
lines.push(` Purchased: ${bucket(credits.purchased)}`);
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
lines.push("");
|
|
4140
|
+
if (!usageByIntegration.length) {
|
|
4141
|
+
lines.push("No integration usage in the last 30 days.");
|
|
4142
|
+
} else {
|
|
4143
|
+
lines.push("Usage by integration (last 30 days):");
|
|
4144
|
+
const nameWidth = Math.max(11, ...usageByIntegration.map((u) => u.name.length));
|
|
4145
|
+
lines.push(`${"INTEGRATION".padEnd(nameWidth)} CALLS COST`);
|
|
4146
|
+
for (const u of usageByIntegration) {
|
|
4147
|
+
lines.push(`${u.name.padEnd(nameWidth)} ${String(u.count).padEnd(5)} ${formatUsd(u.totalCost)}`);
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
lines.push("");
|
|
4151
|
+
lines.push(`Dashboard: ${DASHBOARD_URL}`);
|
|
4152
|
+
return lines.join("\n");
|
|
4153
|
+
}
|
|
4154
|
+
var usage_default = defineCommand13({
|
|
4155
|
+
meta: {
|
|
4156
|
+
name: "usage",
|
|
4157
|
+
description: "Show credit balance, quota headroom, and per-integration spend"
|
|
4158
|
+
},
|
|
4159
|
+
args: {
|
|
4160
|
+
json: {
|
|
4161
|
+
type: "boolean",
|
|
4162
|
+
description: "Emit the raw usage summary as JSON instead of human output",
|
|
4163
|
+
default: false
|
|
4164
|
+
}
|
|
4165
|
+
},
|
|
4166
|
+
async run({ args }) {
|
|
4167
|
+
const token = await ensureToken();
|
|
4168
|
+
const summary = await apiFetch(API_URL3, token, "/api/usage/summary");
|
|
4169
|
+
if (args.json) {
|
|
4170
|
+
process.stdout.write(JSON.stringify(summary, null, 2) + "\n");
|
|
4171
|
+
return;
|
|
4172
|
+
}
|
|
4173
|
+
console.log(renderSummary(summary));
|
|
4174
|
+
}
|
|
4175
|
+
});
|
|
4176
|
+
|
|
4177
|
+
// src/cli/commands/add.ts
|
|
4178
|
+
import { defineCommand as defineCommand14 } from "citty";
|
|
3827
4179
|
import { existsSync as existsSync12, readFileSync as readFileSync12 } from "fs";
|
|
3828
4180
|
import { resolve as resolve8, join as join13, dirname as dirname3 } from "path";
|
|
3829
4181
|
import { fileURLToPath } from "url";
|
|
@@ -3859,7 +4211,7 @@ function runInstaller(script, passArgs, cwd) {
|
|
|
3859
4211
|
}
|
|
3860
4212
|
process.exit(res.status ?? 1);
|
|
3861
4213
|
}
|
|
3862
|
-
var add_default =
|
|
4214
|
+
var add_default = defineCommand14({
|
|
3863
4215
|
meta: {
|
|
3864
4216
|
name: "add",
|
|
3865
4217
|
description: "Add a feature to your DeepSpace app"
|
|
@@ -3932,9 +4284,9 @@ var add_default = defineCommand12({
|
|
|
3932
4284
|
});
|
|
3933
4285
|
|
|
3934
4286
|
// src/cli/commands/domain.ts
|
|
3935
|
-
import { defineCommand as
|
|
3936
|
-
var
|
|
3937
|
-
var api = (token, path, init) => apiFetch(
|
|
4287
|
+
import { defineCommand as defineCommand15 } from "citty";
|
|
4288
|
+
var API_URL4 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
4289
|
+
var api = (token, path, init) => apiFetch(API_URL4, token, path, init);
|
|
3938
4290
|
function scrubInternal(value) {
|
|
3939
4291
|
if (Array.isArray(value)) return value.map(scrubInternal);
|
|
3940
4292
|
if (value && typeof value === "object") {
|
|
@@ -3968,7 +4320,7 @@ async function confirm3(message) {
|
|
|
3968
4320
|
});
|
|
3969
4321
|
});
|
|
3970
4322
|
}
|
|
3971
|
-
var search =
|
|
4323
|
+
var search = defineCommand15({
|
|
3972
4324
|
meta: { name: "search", description: "Search for available domains" },
|
|
3973
4325
|
args: {
|
|
3974
4326
|
query: { type: "positional", description: "Domain or keyword", required: true },
|
|
@@ -3998,7 +4350,7 @@ var search = defineCommand13({
|
|
|
3998
4350
|
}
|
|
3999
4351
|
}
|
|
4000
4352
|
});
|
|
4001
|
-
var buy =
|
|
4353
|
+
var buy = defineCommand15({
|
|
4002
4354
|
meta: { name: "buy", description: "Buy a domain and attach it to an app" },
|
|
4003
4355
|
args: {
|
|
4004
4356
|
domain: { type: "positional", description: "Domain to buy", required: true },
|
|
@@ -4108,7 +4460,7 @@ var buy = defineCommand13({
|
|
|
4108
4460
|
process.exit(1);
|
|
4109
4461
|
}
|
|
4110
4462
|
});
|
|
4111
|
-
var list2 =
|
|
4463
|
+
var list2 = defineCommand15({
|
|
4112
4464
|
meta: { name: "list", description: "List your domains" },
|
|
4113
4465
|
args: {
|
|
4114
4466
|
json: { type: "boolean", description: "Emit JSON" }
|
|
@@ -4134,7 +4486,7 @@ var list2 = defineCommand13({
|
|
|
4134
4486
|
}
|
|
4135
4487
|
}
|
|
4136
4488
|
});
|
|
4137
|
-
var status =
|
|
4489
|
+
var status = defineCommand15({
|
|
4138
4490
|
meta: { name: "status", description: "Show details for one domain" },
|
|
4139
4491
|
args: {
|
|
4140
4492
|
domain: { type: "positional", description: "Domain", required: true },
|
|
@@ -4164,7 +4516,7 @@ var status = defineCommand13({
|
|
|
4164
4516
|
console.log(`Charged: ${fmtCents(found.chargedCents)}/yr`);
|
|
4165
4517
|
}
|
|
4166
4518
|
});
|
|
4167
|
-
var attach =
|
|
4519
|
+
var attach = defineCommand15({
|
|
4168
4520
|
meta: { name: "attach", description: "Re-point a domain at a different app" },
|
|
4169
4521
|
args: {
|
|
4170
4522
|
domain: { type: "positional", description: "Domain to re-point", required: true },
|
|
@@ -4195,7 +4547,7 @@ var attach = defineCommand13({
|
|
|
4195
4547
|
console.log(`\u2713 ${args.domain} now points at ${targetApp}`);
|
|
4196
4548
|
}
|
|
4197
4549
|
});
|
|
4198
|
-
var detach =
|
|
4550
|
+
var detach = defineCommand15({
|
|
4199
4551
|
meta: {
|
|
4200
4552
|
name: "detach",
|
|
4201
4553
|
description: "Stop routing the domain (keeps the registration; auto-renew unchanged)"
|
|
@@ -4227,7 +4579,7 @@ var detach = defineCommand13({
|
|
|
4227
4579
|
);
|
|
4228
4580
|
}
|
|
4229
4581
|
});
|
|
4230
|
-
var renew =
|
|
4582
|
+
var renew = defineCommand15({
|
|
4231
4583
|
meta: { name: "renew", description: "Toggle auto-renewal at the registrar" },
|
|
4232
4584
|
args: {
|
|
4233
4585
|
domain: { type: "positional", description: "Domain", required: true },
|
|
@@ -4253,13 +4605,13 @@ var renew = defineCommand13({
|
|
|
4253
4605
|
console.log(`\u2713 ${args.domain} auto-renew ${enabled ? "enabled" : "disabled"}`);
|
|
4254
4606
|
}
|
|
4255
4607
|
});
|
|
4256
|
-
var domain_default =
|
|
4608
|
+
var domain_default = defineCommand15({
|
|
4257
4609
|
meta: { name: "domain", description: "Buy and manage custom domains" },
|
|
4258
4610
|
subCommands: { search, buy, list: list2, status, attach, detach, renew }
|
|
4259
4611
|
});
|
|
4260
4612
|
|
|
4261
4613
|
// src/cli/commands/collaborators.ts
|
|
4262
|
-
import { defineCommand as
|
|
4614
|
+
import { defineCommand as defineCommand16 } from "citty";
|
|
4263
4615
|
|
|
4264
4616
|
// src/server/auth/testAccounts.ts
|
|
4265
4617
|
var TEST_ACCOUNT_EMAIL_SUFFIX = "@deepspace.test";
|
|
@@ -4268,12 +4620,12 @@ function isTestAccountEmail(email) {
|
|
|
4268
4620
|
}
|
|
4269
4621
|
|
|
4270
4622
|
// src/cli/commands/collaborators.ts
|
|
4271
|
-
var
|
|
4272
|
-
var
|
|
4623
|
+
var API_URL5 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
4624
|
+
var DEPLOY_URL7 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
4273
4625
|
function api2(token, path, init) {
|
|
4274
|
-
return apiFetch(
|
|
4626
|
+
return apiFetch(API_URL5, token, path, init);
|
|
4275
4627
|
}
|
|
4276
|
-
var list3 =
|
|
4628
|
+
var list3 = defineCommand16({
|
|
4277
4629
|
meta: { name: "list", description: "List collaborators on your app" },
|
|
4278
4630
|
args: {
|
|
4279
4631
|
app: { type: "string", alias: "a", description: "App id or name (defaults to ./wrangler.toml)" },
|
|
@@ -4281,7 +4633,7 @@ var list3 = defineCommand14({
|
|
|
4281
4633
|
},
|
|
4282
4634
|
async run({ args }) {
|
|
4283
4635
|
const token = await ensureToken();
|
|
4284
|
-
const app = await resolveAppTarget(
|
|
4636
|
+
const app = await resolveAppTarget(DEPLOY_URL7, token, args.app);
|
|
4285
4637
|
const { collaborators, pending = [] } = await api2(token, `/api/app-collaborators/${encodeURIComponent(app)}`);
|
|
4286
4638
|
if (args.json) {
|
|
4287
4639
|
process.stdout.write(JSON.stringify({ collaborators, pending }, null, 2) + "\n");
|
|
@@ -4305,7 +4657,7 @@ var list3 = defineCommand14({
|
|
|
4305
4657
|
}
|
|
4306
4658
|
}
|
|
4307
4659
|
});
|
|
4308
|
-
var add =
|
|
4660
|
+
var add = defineCommand16({
|
|
4309
4661
|
meta: { name: "add", description: "Authorize someone to deploy your app" },
|
|
4310
4662
|
args: {
|
|
4311
4663
|
email: {
|
|
@@ -4318,7 +4670,7 @@ var add = defineCommand14({
|
|
|
4318
4670
|
},
|
|
4319
4671
|
async run({ args }) {
|
|
4320
4672
|
const token = await ensureToken();
|
|
4321
|
-
const app = await resolveAppTarget(
|
|
4673
|
+
const app = await resolveAppTarget(DEPLOY_URL7, token, args.app);
|
|
4322
4674
|
if (isTestAccountEmail(args.email)) {
|
|
4323
4675
|
console.error(
|
|
4324
4676
|
"Test accounts (@deepspace.test) cannot be added as collaborators. Use a real DeepSpace account."
|
|
@@ -4350,7 +4702,7 @@ var add = defineCommand14({
|
|
|
4350
4702
|
console.log(`\u2713 ${res.collaborator.emailDisplay} can now deploy ${app}`);
|
|
4351
4703
|
}
|
|
4352
4704
|
});
|
|
4353
|
-
var remove =
|
|
4705
|
+
var remove = defineCommand16({
|
|
4354
4706
|
meta: { name: "remove", description: "Remove a collaborator from your app" },
|
|
4355
4707
|
args: {
|
|
4356
4708
|
email: { type: "positional", description: "Collaborator email", required: true },
|
|
@@ -4359,7 +4711,7 @@ var remove = defineCommand14({
|
|
|
4359
4711
|
},
|
|
4360
4712
|
async run({ args }) {
|
|
4361
4713
|
const token = await ensureToken();
|
|
4362
|
-
const app = await resolveAppTarget(
|
|
4714
|
+
const app = await resolveAppTarget(DEPLOY_URL7, token, args.app);
|
|
4363
4715
|
const { collaborators } = await api2(
|
|
4364
4716
|
token,
|
|
4365
4717
|
`/api/app-collaborators/${encodeURIComponent(app)}`
|
|
@@ -4382,7 +4734,7 @@ var remove = defineCommand14({
|
|
|
4382
4734
|
console.log(`\u2713 ${found.emailDisplay} can no longer deploy ${app}`);
|
|
4383
4735
|
}
|
|
4384
4736
|
});
|
|
4385
|
-
var cancel4 =
|
|
4737
|
+
var cancel4 = defineCommand16({
|
|
4386
4738
|
meta: { name: "cancel", description: "Cancel a pending (un-accepted) email invite" },
|
|
4387
4739
|
args: {
|
|
4388
4740
|
email: { type: "positional", description: "Invited email", required: true },
|
|
@@ -4391,7 +4743,7 @@ var cancel4 = defineCommand14({
|
|
|
4391
4743
|
},
|
|
4392
4744
|
async run({ args }) {
|
|
4393
4745
|
const token = await ensureToken();
|
|
4394
|
-
const app = await resolveAppTarget(
|
|
4746
|
+
const app = await resolveAppTarget(DEPLOY_URL7, token, args.app);
|
|
4395
4747
|
const { pending = [] } = await api2(
|
|
4396
4748
|
token,
|
|
4397
4749
|
`/api/app-collaborators/${encodeURIComponent(app)}`
|
|
@@ -4414,17 +4766,17 @@ var cancel4 = defineCommand14({
|
|
|
4414
4766
|
console.log(`\u2713 Cancelled the pending invite to ${found.email} on ${app}`);
|
|
4415
4767
|
}
|
|
4416
4768
|
});
|
|
4417
|
-
var collaborators_default =
|
|
4769
|
+
var collaborators_default = defineCommand16({
|
|
4418
4770
|
meta: { name: "collaborators", description: "Manage who can deploy your app" },
|
|
4419
4771
|
subCommands: { list: list3, add, remove, cancel: cancel4 }
|
|
4420
4772
|
});
|
|
4421
4773
|
|
|
4422
4774
|
// src/cli/commands/transfer.ts
|
|
4423
|
-
import { defineCommand as
|
|
4775
|
+
import { defineCommand as defineCommand17 } from "citty";
|
|
4424
4776
|
import * as p6 from "@clack/prompts";
|
|
4425
|
-
var
|
|
4426
|
-
var
|
|
4427
|
-
var offer =
|
|
4777
|
+
var API_URL6 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
4778
|
+
var DEPLOY_URL8 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
4779
|
+
var offer = defineCommand17({
|
|
4428
4780
|
meta: { name: "offer", description: "Offer this app to another DeepSpace user" },
|
|
4429
4781
|
args: {
|
|
4430
4782
|
email: { type: "positional", description: "Recipient email", required: true },
|
|
@@ -4436,9 +4788,9 @@ var offer = defineCommand15({
|
|
|
4436
4788
|
},
|
|
4437
4789
|
async run({ args }) {
|
|
4438
4790
|
const token = await ensureToken();
|
|
4439
|
-
const app = await resolveAppTarget(
|
|
4791
|
+
const app = await resolveAppTarget(DEPLOY_URL8, token, args.app);
|
|
4440
4792
|
const pending = await apiFetch(
|
|
4441
|
-
|
|
4793
|
+
API_URL6,
|
|
4442
4794
|
token,
|
|
4443
4795
|
`/api/app-transfers/${encodeURIComponent(app)}`
|
|
4444
4796
|
);
|
|
@@ -4459,7 +4811,7 @@ var offer = defineCommand15({
|
|
|
4459
4811
|
}
|
|
4460
4812
|
}
|
|
4461
4813
|
const { expiresAt } = await apiFetch(
|
|
4462
|
-
|
|
4814
|
+
API_URL6,
|
|
4463
4815
|
token,
|
|
4464
4816
|
`/api/app-transfers/${encodeURIComponent(app)}`,
|
|
4465
4817
|
{ method: "POST", body: JSON.stringify({ email: args.email }) }
|
|
@@ -4473,15 +4825,15 @@ var offer = defineCommand15({
|
|
|
4473
4825
|
);
|
|
4474
4826
|
}
|
|
4475
4827
|
});
|
|
4476
|
-
var status2 =
|
|
4828
|
+
var status2 = defineCommand17({
|
|
4477
4829
|
meta: { name: "status", description: "Show the pending transfer offer, if any" },
|
|
4478
4830
|
args: {
|
|
4479
4831
|
app: { type: "string", alias: "a", description: "App id or name (defaults to ./wrangler.toml)" }
|
|
4480
4832
|
},
|
|
4481
4833
|
async run({ args }) {
|
|
4482
4834
|
const token = await ensureToken();
|
|
4483
|
-
const app = await resolveAppTarget(
|
|
4484
|
-
const { transfer } = await apiFetch(
|
|
4835
|
+
const app = await resolveAppTarget(DEPLOY_URL8, token, args.app);
|
|
4836
|
+
const { transfer } = await apiFetch(API_URL6, token, `/api/app-transfers/${encodeURIComponent(app)}`);
|
|
4485
4837
|
if (!transfer) {
|
|
4486
4838
|
console.log(`No pending transfer for ${app}.`);
|
|
4487
4839
|
return;
|
|
@@ -4489,7 +4841,7 @@ var status2 = defineCommand15({
|
|
|
4489
4841
|
console.log(`Pending: ${app} \u2192 ${transfer.toEmailDisplay} (expires ${transfer.expiresAt}).`);
|
|
4490
4842
|
}
|
|
4491
4843
|
});
|
|
4492
|
-
var accept =
|
|
4844
|
+
var accept = defineCommand17({
|
|
4493
4845
|
meta: { name: "accept", description: "Accept a transfer offered to you" },
|
|
4494
4846
|
args: {
|
|
4495
4847
|
app: { type: "string", alias: "a", description: "App id of the offered app", required: true }
|
|
@@ -4497,7 +4849,7 @@ var accept = defineCommand15({
|
|
|
4497
4849
|
async run({ args }) {
|
|
4498
4850
|
const token = await ensureToken();
|
|
4499
4851
|
const app = requireAppIdArg(args.app);
|
|
4500
|
-
await apiFetch(
|
|
4852
|
+
await apiFetch(DEPLOY_URL8, token, `/api/apps/${encodeURIComponent(app)}/transfer/accept`, {
|
|
4501
4853
|
method: "POST"
|
|
4502
4854
|
});
|
|
4503
4855
|
console.log(
|
|
@@ -4505,30 +4857,30 @@ var accept = defineCommand15({
|
|
|
4505
4857
|
);
|
|
4506
4858
|
}
|
|
4507
4859
|
});
|
|
4508
|
-
var cancel5 =
|
|
4860
|
+
var cancel5 = defineCommand17({
|
|
4509
4861
|
meta: { name: "cancel", description: "Cancel/decline the pending offer (either party)" },
|
|
4510
4862
|
args: {
|
|
4511
4863
|
app: { type: "string", alias: "a", description: "App id or name (defaults to ./wrangler.toml)" }
|
|
4512
4864
|
},
|
|
4513
4865
|
async run({ args }) {
|
|
4514
4866
|
const token = await ensureToken();
|
|
4515
|
-
const app = await resolveAppTarget(
|
|
4516
|
-
await apiFetch(
|
|
4867
|
+
const app = await resolveAppTarget(DEPLOY_URL8, token, args.app);
|
|
4868
|
+
await apiFetch(API_URL6, token, `/api/app-transfers/${encodeURIComponent(app)}`, { method: "DELETE" });
|
|
4517
4869
|
console.log(`\u2713 Transfer offer for ${app} cancelled.`);
|
|
4518
4870
|
}
|
|
4519
4871
|
});
|
|
4520
|
-
var transfer_default =
|
|
4872
|
+
var transfer_default = defineCommand17({
|
|
4521
4873
|
meta: { name: "transfer", description: "Transfer app ownership to another user" },
|
|
4522
4874
|
subCommands: { offer, status: status2, accept, cancel: cancel5 }
|
|
4523
4875
|
});
|
|
4524
4876
|
|
|
4525
4877
|
// src/cli/commands/integrations.ts
|
|
4526
|
-
import { defineCommand as
|
|
4878
|
+
import { defineCommand as defineCommand18 } from "citty";
|
|
4527
4879
|
|
|
4528
4880
|
// src/cli/commands/_invoke-impl.ts
|
|
4529
4881
|
import { readFileSync as readFileSync13 } from "fs";
|
|
4530
4882
|
import * as p7 from "@clack/prompts";
|
|
4531
|
-
var
|
|
4883
|
+
var API_URL7 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
4532
4884
|
var DEFAULT_TIMEOUT_MS = 12e4;
|
|
4533
4885
|
function parseTarget(target) {
|
|
4534
4886
|
if (!target || typeof target !== "string") {
|
|
@@ -4570,7 +4922,7 @@ function flushAndExit(code) {
|
|
|
4570
4922
|
});
|
|
4571
4923
|
}
|
|
4572
4924
|
async function fetchCatalog(opts = {}) {
|
|
4573
|
-
const url = opts.summary ? `${
|
|
4925
|
+
const url = opts.summary ? `${API_URL7}/api/integrations?summary=1` : `${API_URL7}/api/integrations`;
|
|
4574
4926
|
const res = await fetch(url);
|
|
4575
4927
|
if (!res.ok) {
|
|
4576
4928
|
throw new Error(`Failed to fetch integration catalog (${res.status})`);
|
|
@@ -4694,7 +5046,7 @@ async function runInvoke(args) {
|
|
|
4694
5046
|
const startedAt = Date.now();
|
|
4695
5047
|
let res;
|
|
4696
5048
|
try {
|
|
4697
|
-
res = await fetch(`${
|
|
5049
|
+
res = await fetch(`${API_URL7}/api/integrations/${integration}/${endpoint}`, {
|
|
4698
5050
|
method: "POST",
|
|
4699
5051
|
headers: {
|
|
4700
5052
|
"Content-Type": "application/json",
|
|
@@ -4745,7 +5097,7 @@ async function runInvoke(args) {
|
|
|
4745
5097
|
}
|
|
4746
5098
|
|
|
4747
5099
|
// src/cli/commands/integrations.ts
|
|
4748
|
-
var list4 =
|
|
5100
|
+
var list4 = defineCommand18({
|
|
4749
5101
|
meta: {
|
|
4750
5102
|
name: "list",
|
|
4751
5103
|
description: "List all available integrations"
|
|
@@ -4766,7 +5118,7 @@ var list4 = defineCommand16({
|
|
|
4766
5118
|
}
|
|
4767
5119
|
}
|
|
4768
5120
|
});
|
|
4769
|
-
var info =
|
|
5121
|
+
var info = defineCommand18({
|
|
4770
5122
|
meta: {
|
|
4771
5123
|
name: "info",
|
|
4772
5124
|
description: "Print schema + example body for an integration endpoint"
|
|
@@ -4792,7 +5144,7 @@ var info = defineCommand16({
|
|
|
4792
5144
|
}
|
|
4793
5145
|
}
|
|
4794
5146
|
});
|
|
4795
|
-
var invoke =
|
|
5147
|
+
var invoke = defineCommand18({
|
|
4796
5148
|
meta: {
|
|
4797
5149
|
name: "invoke",
|
|
4798
5150
|
description: "Invoke a platform integration as the logged-in user"
|
|
@@ -4852,7 +5204,7 @@ var invoke = defineCommand16({
|
|
|
4852
5204
|
}
|
|
4853
5205
|
}
|
|
4854
5206
|
});
|
|
4855
|
-
var integrations_default =
|
|
5207
|
+
var integrations_default = defineCommand18({
|
|
4856
5208
|
meta: {
|
|
4857
5209
|
name: "integrations",
|
|
4858
5210
|
description: "List, inspect, and invoke platform integrations"
|
|
@@ -4865,8 +5217,8 @@ var integrations_default = defineCommand16({
|
|
|
4865
5217
|
});
|
|
4866
5218
|
|
|
4867
5219
|
// src/cli/commands/invoke.ts
|
|
4868
|
-
import { defineCommand as
|
|
4869
|
-
var invoke_default =
|
|
5220
|
+
import { defineCommand as defineCommand19 } from "citty";
|
|
5221
|
+
var invoke_default = defineCommand19({
|
|
4870
5222
|
meta: {
|
|
4871
5223
|
name: "invoke",
|
|
4872
5224
|
description: "Invoke a platform integration as the logged-in user"
|
|
@@ -4946,13 +5298,13 @@ var invoke_default = defineCommand17({
|
|
|
4946
5298
|
});
|
|
4947
5299
|
|
|
4948
5300
|
// src/cli/commands/library.ts
|
|
4949
|
-
import { defineCommand as
|
|
5301
|
+
import { defineCommand as defineCommand20 } from "citty";
|
|
4950
5302
|
import { existsSync as existsSync13, readFileSync as readFileSync14 } from "fs";
|
|
4951
5303
|
import { join as join14, resolve as resolve9 } from "path";
|
|
4952
5304
|
import { parse as parseToml4 } from "smol-toml";
|
|
4953
5305
|
import * as p8 from "@clack/prompts";
|
|
4954
5306
|
var DEFAULT_LIBRARY_APP = "deepdotspace-site";
|
|
4955
|
-
var publish =
|
|
5307
|
+
var publish = defineCommand20({
|
|
4956
5308
|
meta: {
|
|
4957
5309
|
name: "publish",
|
|
4958
5310
|
description: "Publish the current app to the DeepSpace library"
|
|
@@ -5091,7 +5443,7 @@ var publish = defineCommand18({
|
|
|
5091
5443
|
p8.outro("Done");
|
|
5092
5444
|
}
|
|
5093
5445
|
});
|
|
5094
|
-
var unpublish =
|
|
5446
|
+
var unpublish = defineCommand20({
|
|
5095
5447
|
meta: {
|
|
5096
5448
|
name: "unpublish",
|
|
5097
5449
|
description: "Remove a library entry (owner or admin only)"
|
|
@@ -5150,7 +5502,7 @@ var unpublish = defineCommand18({
|
|
|
5150
5502
|
p8.outro("Done");
|
|
5151
5503
|
}
|
|
5152
5504
|
});
|
|
5153
|
-
var library_default =
|
|
5505
|
+
var library_default = defineCommand20({
|
|
5154
5506
|
meta: {
|
|
5155
5507
|
name: "library",
|
|
5156
5508
|
description: "Manage your DeepSpace library entries"
|
|
@@ -5162,13 +5514,13 @@ var library_default = defineCommand18({
|
|
|
5162
5514
|
});
|
|
5163
5515
|
|
|
5164
5516
|
// src/cli/commands/feedback.ts
|
|
5165
|
-
import { defineCommand as
|
|
5517
|
+
import { defineCommand as defineCommand21 } from "citty";
|
|
5166
5518
|
import * as p9 from "@clack/prompts";
|
|
5167
5519
|
import { existsSync as existsSync14, readFileSync as readFileSync15 } from "fs";
|
|
5168
5520
|
import { dirname as dirname4, join as join15 } from "path";
|
|
5169
5521
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5170
5522
|
import { release } from "os";
|
|
5171
|
-
var
|
|
5523
|
+
var API_URL8 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
5172
5524
|
var TYPES = ["bug", "feature", "other"];
|
|
5173
5525
|
var TYPE_LABELS = {
|
|
5174
5526
|
bug: "Bug report",
|
|
@@ -5178,7 +5530,7 @@ var TYPE_LABELS = {
|
|
|
5178
5530
|
var MAX_TITLE_LEN = 200;
|
|
5179
5531
|
var MAX_BODY_LEN = 1e4;
|
|
5180
5532
|
var MAX_CONTEXT_LEN = 200;
|
|
5181
|
-
var api3 = (token, path, init) => apiFetch(
|
|
5533
|
+
var api3 = (token, path, init) => apiFetch(API_URL8, token, path, init);
|
|
5182
5534
|
function normalizeType(raw) {
|
|
5183
5535
|
const value = (raw ?? "bug").toLowerCase();
|
|
5184
5536
|
if (TYPES.includes(value)) return value;
|
|
@@ -5240,7 +5592,7 @@ function buildFeedbackPayload(input) {
|
|
|
5240
5592
|
...input.context
|
|
5241
5593
|
};
|
|
5242
5594
|
}
|
|
5243
|
-
var feedback_default =
|
|
5595
|
+
var feedback_default = defineCommand21({
|
|
5244
5596
|
meta: {
|
|
5245
5597
|
name: "feedback",
|
|
5246
5598
|
description: "Submit a bug report, feature request, or feedback to DeepSpace"
|
|
@@ -5402,7 +5754,7 @@ Context: deepspace ${payload.cliVersion} \xB7 ${payload.nodeVersion} \xB7 ${payl
|
|
|
5402
5754
|
});
|
|
5403
5755
|
|
|
5404
5756
|
// src/cli/commands/secrets.ts
|
|
5405
|
-
import { defineCommand as
|
|
5757
|
+
import { defineCommand as defineCommand22 } from "citty";
|
|
5406
5758
|
import { readFileSync as readFileSync16 } from "fs";
|
|
5407
5759
|
|
|
5408
5760
|
// src/cli/lib/citty-args.ts
|
|
@@ -5414,7 +5766,7 @@ function dedupePositionals(bound, rest) {
|
|
|
5414
5766
|
}
|
|
5415
5767
|
|
|
5416
5768
|
// src/cli/commands/secrets.ts
|
|
5417
|
-
var
|
|
5769
|
+
var DEPLOY_URL9 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
5418
5770
|
var COMMON_ARGS = {
|
|
5419
5771
|
app: {
|
|
5420
5772
|
type: "string",
|
|
@@ -5472,7 +5824,7 @@ function warnIfDebugRoutesEnabled(secrets) {
|
|
|
5472
5824
|
}
|
|
5473
5825
|
var APPLY_HINT = "Run `deepspace deploy` to apply \u2014 secrets take effect at deploy time.";
|
|
5474
5826
|
var LOCAL_DEV_HINT = "Running `deepspace dev`? Restart it to load the change locally.";
|
|
5475
|
-
var list5 =
|
|
5827
|
+
var list5 = defineCommand22({
|
|
5476
5828
|
meta: { name: "list", description: "List masked secrets in a config" },
|
|
5477
5829
|
args: {
|
|
5478
5830
|
...COMMON_ARGS,
|
|
@@ -5486,7 +5838,7 @@ var list5 = defineCommand20({
|
|
|
5486
5838
|
async run({ args }) {
|
|
5487
5839
|
try {
|
|
5488
5840
|
const t = await resolveTarget(args);
|
|
5489
|
-
const { secrets } = await listSecrets(
|
|
5841
|
+
const { secrets } = await listSecrets(DEPLOY_URL9, t.token, t.appId, t.configName);
|
|
5490
5842
|
if (args.json) {
|
|
5491
5843
|
console.log(JSON.stringify({ appId: t.appId, config: t.configName, secrets }, null, 2));
|
|
5492
5844
|
return;
|
|
@@ -5503,7 +5855,7 @@ var list5 = defineCommand20({
|
|
|
5503
5855
|
}
|
|
5504
5856
|
}
|
|
5505
5857
|
});
|
|
5506
|
-
var set =
|
|
5858
|
+
var set = defineCommand22({
|
|
5507
5859
|
meta: { name: "set", description: "Set secrets from KEY=value pairs" },
|
|
5508
5860
|
args: {
|
|
5509
5861
|
...COMMON_ARGS,
|
|
@@ -5531,9 +5883,9 @@ var set = defineCommand20({
|
|
|
5531
5883
|
}
|
|
5532
5884
|
if (Object.keys(secrets).length === 1) {
|
|
5533
5885
|
const [[k, v]] = Object.entries(secrets);
|
|
5534
|
-
await setSecret(
|
|
5886
|
+
await setSecret(DEPLOY_URL9, t.token, t.appId, t.configName, k, v);
|
|
5535
5887
|
} else {
|
|
5536
|
-
await uploadSecrets(
|
|
5888
|
+
await uploadSecrets(DEPLOY_URL9, t.token, t.appId, t.configName, secrets, false);
|
|
5537
5889
|
}
|
|
5538
5890
|
console.log(`Set ${Object.keys(secrets).length} secret${Object.keys(secrets).length === 1 ? "" : "s"} in ${t.configName}.`);
|
|
5539
5891
|
if (!warnIfDebugRoutesEnabled(secrets)) {
|
|
@@ -5545,7 +5897,7 @@ var set = defineCommand20({
|
|
|
5545
5897
|
}
|
|
5546
5898
|
}
|
|
5547
5899
|
});
|
|
5548
|
-
var get =
|
|
5900
|
+
var get = defineCommand22({
|
|
5549
5901
|
meta: { name: "get", description: "Get a secret; pass --plain to print the value" },
|
|
5550
5902
|
args: {
|
|
5551
5903
|
...COMMON_ARGS,
|
|
@@ -5557,11 +5909,11 @@ var get = defineCommand20({
|
|
|
5557
5909
|
const t = await resolveTarget(args);
|
|
5558
5910
|
const key = validateSecretName(args.key);
|
|
5559
5911
|
if (args.plain) {
|
|
5560
|
-
const { value } = await getSecretPlain(
|
|
5912
|
+
const { value } = await getSecretPlain(DEPLOY_URL9, t.token, t.appId, t.configName, key);
|
|
5561
5913
|
process.stdout.write(process.stdout.isTTY ? value + "\n" : value);
|
|
5562
5914
|
return;
|
|
5563
5915
|
}
|
|
5564
|
-
const { secrets } = await listSecrets(
|
|
5916
|
+
const { secrets } = await listSecrets(DEPLOY_URL9, t.token, t.appId, t.configName);
|
|
5565
5917
|
const item = secrets.find((s) => s.key === key);
|
|
5566
5918
|
if (!item) fail(new Error(`Secret "${key}" not found in ${t.configName}`));
|
|
5567
5919
|
console.log(`${item.key} (v${item.version}, ${item.updatedAt})`);
|
|
@@ -5570,7 +5922,7 @@ var get = defineCommand20({
|
|
|
5570
5922
|
}
|
|
5571
5923
|
}
|
|
5572
5924
|
});
|
|
5573
|
-
var del2 =
|
|
5925
|
+
var del2 = defineCommand22({
|
|
5574
5926
|
meta: { name: "delete", description: "Delete one or more secrets" },
|
|
5575
5927
|
args: {
|
|
5576
5928
|
...COMMON_ARGS,
|
|
@@ -5585,7 +5937,7 @@ var del2 = defineCommand20({
|
|
|
5585
5937
|
for (const key of keys) {
|
|
5586
5938
|
const name = validateSecretName(key);
|
|
5587
5939
|
try {
|
|
5588
|
-
await deleteSecret(
|
|
5940
|
+
await deleteSecret(DEPLOY_URL9, t.token, t.appId, t.configName, name);
|
|
5589
5941
|
deleted++;
|
|
5590
5942
|
} catch (err) {
|
|
5591
5943
|
if (err?.status === 404) absent++;
|
|
@@ -5600,7 +5952,7 @@ var del2 = defineCommand20({
|
|
|
5600
5952
|
}
|
|
5601
5953
|
}
|
|
5602
5954
|
});
|
|
5603
|
-
var upload =
|
|
5955
|
+
var upload = defineCommand22({
|
|
5604
5956
|
meta: { name: "upload", description: "Upload secrets from a dotenv or JSON file" },
|
|
5605
5957
|
args: {
|
|
5606
5958
|
...COMMON_ARGS,
|
|
@@ -5617,7 +5969,7 @@ var upload = defineCommand20({
|
|
|
5617
5969
|
const content = args.file === "-" ? readFileSync16(0, "utf-8") : readFileSync16(args.file, "utf-8");
|
|
5618
5970
|
const secrets = parseSecretsUpload(content);
|
|
5619
5971
|
if (Object.keys(secrets).length === 0) fail(new Error("No secrets found in the input."));
|
|
5620
|
-
await uploadSecrets(
|
|
5972
|
+
await uploadSecrets(DEPLOY_URL9, t.token, t.appId, t.configName, secrets, args.replace);
|
|
5621
5973
|
console.log(`Uploaded ${Object.keys(secrets).length} secrets to ${t.configName}.`);
|
|
5622
5974
|
if (!warnIfDebugRoutesEnabled(secrets)) console.log(APPLY_HINT);
|
|
5623
5975
|
} catch (err) {
|
|
@@ -5625,7 +5977,7 @@ var upload = defineCommand20({
|
|
|
5625
5977
|
}
|
|
5626
5978
|
}
|
|
5627
5979
|
});
|
|
5628
|
-
var download =
|
|
5980
|
+
var download = defineCommand22({
|
|
5629
5981
|
meta: { name: "download", description: "Download a config\u2019s secrets (dotenv/json/shell)" },
|
|
5630
5982
|
args: {
|
|
5631
5983
|
...COMMON_ARGS,
|
|
@@ -5642,14 +5994,14 @@ var download = defineCommand20({
|
|
|
5642
5994
|
if (!["dotenv", "json", "shell"].includes(format)) {
|
|
5643
5995
|
fail(new Error(`Unknown format "${args.format}" \u2014 use dotenv, json, or shell.`));
|
|
5644
5996
|
}
|
|
5645
|
-
const { secrets } = await fetchSecretsValues(
|
|
5997
|
+
const { secrets } = await fetchSecretsValues(DEPLOY_URL9, t.token, t.appId, t.configName);
|
|
5646
5998
|
process.stdout.write(formatSecretsDownload(secrets, format));
|
|
5647
5999
|
} catch (err) {
|
|
5648
6000
|
fail(err);
|
|
5649
6001
|
}
|
|
5650
6002
|
}
|
|
5651
6003
|
});
|
|
5652
|
-
var pull =
|
|
6004
|
+
var pull = defineCommand22({
|
|
5653
6005
|
meta: { name: "pull", description: "Refresh the .dev.vars cache from the app store" },
|
|
5654
6006
|
args: { ...COMMON_ARGS },
|
|
5655
6007
|
async run({ args }) {
|
|
@@ -5659,7 +6011,7 @@ var pull = defineCommand20({
|
|
|
5659
6011
|
if (!appDir) fail(new Error("Run from a DeepSpace app directory (one containing wrangler.toml)."));
|
|
5660
6012
|
const t = await resolveTarget(args);
|
|
5661
6013
|
const ownerId = decodeJwtPayload(t.token).sub;
|
|
5662
|
-
const pulled = await pullAppSecretsCache(
|
|
6014
|
+
const pulled = await pullAppSecretsCache(DEPLOY_URL9, t.token, t.appId, t.configName);
|
|
5663
6015
|
if (!pulled) {
|
|
5664
6016
|
console.log(`No secrets in ${t.configName} yet \u2014 nothing to pull.`);
|
|
5665
6017
|
return;
|
|
@@ -5677,13 +6029,13 @@ var pull = defineCommand20({
|
|
|
5677
6029
|
}
|
|
5678
6030
|
}
|
|
5679
6031
|
});
|
|
5680
|
-
var configsList =
|
|
6032
|
+
var configsList = defineCommand22({
|
|
5681
6033
|
meta: { name: "list", description: "List the app\u2019s configs" },
|
|
5682
6034
|
args: { ...COMMON_ARGS },
|
|
5683
6035
|
async run({ args }) {
|
|
5684
6036
|
try {
|
|
5685
6037
|
const t = await resolveTarget(args);
|
|
5686
|
-
const { configs: configs2 } = await listConfigs(
|
|
6038
|
+
const { configs: configs2 } = await listConfigs(DEPLOY_URL9, t.token, t.appId);
|
|
5687
6039
|
if (configs2.length === 0) {
|
|
5688
6040
|
console.log("No configs yet \u2014 the first `secrets set` creates one.");
|
|
5689
6041
|
return;
|
|
@@ -5696,7 +6048,7 @@ var configsList = defineCommand20({
|
|
|
5696
6048
|
}
|
|
5697
6049
|
}
|
|
5698
6050
|
});
|
|
5699
|
-
var configsCreate =
|
|
6051
|
+
var configsCreate = defineCommand22({
|
|
5700
6052
|
meta: { name: "create", description: "Create a config (optionally copying another)" },
|
|
5701
6053
|
args: {
|
|
5702
6054
|
...COMMON_ARGS,
|
|
@@ -5708,7 +6060,7 @@ var configsCreate = defineCommand20({
|
|
|
5708
6060
|
const t = await resolveTarget(args);
|
|
5709
6061
|
const name = validateConfigName(args.name);
|
|
5710
6062
|
const copyFrom = args["copy-from"] || void 0;
|
|
5711
|
-
const { configs: configs2 } = await listConfigs(
|
|
6063
|
+
const { configs: configs2 } = await listConfigs(DEPLOY_URL9, t.token, t.appId);
|
|
5712
6064
|
if (configs2.some((c) => c.name === name)) {
|
|
5713
6065
|
if (copyFrom) {
|
|
5714
6066
|
fail(
|
|
@@ -5720,14 +6072,14 @@ var configsCreate = defineCommand20({
|
|
|
5720
6072
|
console.log(`Config ${name} already exists.`);
|
|
5721
6073
|
return;
|
|
5722
6074
|
}
|
|
5723
|
-
await createConfig(
|
|
6075
|
+
await createConfig(DEPLOY_URL9, t.token, t.appId, name, copyFrom);
|
|
5724
6076
|
console.log(`Created ${name}.`);
|
|
5725
6077
|
} catch (err) {
|
|
5726
6078
|
fail(err);
|
|
5727
6079
|
}
|
|
5728
6080
|
}
|
|
5729
6081
|
});
|
|
5730
|
-
var configsDelete =
|
|
6082
|
+
var configsDelete = defineCommand22({
|
|
5731
6083
|
meta: { name: "delete", description: "Delete a config and all of its secrets" },
|
|
5732
6084
|
args: {
|
|
5733
6085
|
...COMMON_ARGS,
|
|
@@ -5737,18 +6089,18 @@ var configsDelete = defineCommand20({
|
|
|
5737
6089
|
try {
|
|
5738
6090
|
const t = await resolveTarget(args);
|
|
5739
6091
|
const name = validateConfigName(args.name);
|
|
5740
|
-
await deleteConfig(
|
|
6092
|
+
await deleteConfig(DEPLOY_URL9, t.token, t.appId, name);
|
|
5741
6093
|
console.log(`Deleted ${name}.`);
|
|
5742
6094
|
} catch (err) {
|
|
5743
6095
|
fail(err);
|
|
5744
6096
|
}
|
|
5745
6097
|
}
|
|
5746
6098
|
});
|
|
5747
|
-
var configs =
|
|
6099
|
+
var configs = defineCommand22({
|
|
5748
6100
|
meta: { name: "configs", description: "Manage the app\u2019s secrets configs" },
|
|
5749
6101
|
subCommands: { list: configsList, create: configsCreate, delete: configsDelete }
|
|
5750
6102
|
});
|
|
5751
|
-
var secrets_default =
|
|
6103
|
+
var secrets_default = defineCommand22({
|
|
5752
6104
|
meta: { name: "secrets", description: "Manage the app\u2019s secrets store" },
|
|
5753
6105
|
subCommands: {
|
|
5754
6106
|
list: list5,
|
|
@@ -5763,8 +6115,8 @@ var secrets_default = defineCommand20({
|
|
|
5763
6115
|
});
|
|
5764
6116
|
|
|
5765
6117
|
// src/cli/commands/init.ts
|
|
5766
|
-
import { defineCommand as
|
|
5767
|
-
var init_default =
|
|
6118
|
+
import { defineCommand as defineCommand23 } from "citty";
|
|
6119
|
+
var init_default = defineCommand23({
|
|
5768
6120
|
meta: {
|
|
5769
6121
|
name: "init",
|
|
5770
6122
|
description: "Mint this app\u2019s immutable DEEPSPACE_APP_ID into wrangler.toml"
|
|
@@ -5814,7 +6166,7 @@ var pkg = JSON.parse(readFileSync17(join16(__dirname, "..", "package.json"), "ut
|
|
|
5814
6166
|
if (process.platform === "linux" && !process.env.SSL_CERT_FILE && existsSync15("/etc/ssl/certs/ca-certificates.crt")) {
|
|
5815
6167
|
process.env.SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt";
|
|
5816
6168
|
}
|
|
5817
|
-
var create2 =
|
|
6169
|
+
var create2 = defineCommand24({
|
|
5818
6170
|
meta: {
|
|
5819
6171
|
name: "create",
|
|
5820
6172
|
description: "Create a new DeepSpace app (runs create-deepspace; all flags are forwarded)"
|
|
@@ -5841,7 +6193,7 @@ var create2 = defineCommand22({
|
|
|
5841
6193
|
process.exit(res.status ?? 1);
|
|
5842
6194
|
}
|
|
5843
6195
|
});
|
|
5844
|
-
var main =
|
|
6196
|
+
var main = defineCommand24({
|
|
5845
6197
|
meta: {
|
|
5846
6198
|
name: "deepspace",
|
|
5847
6199
|
version: pkg.version,
|
|
@@ -5854,6 +6206,8 @@ var main = defineCommand22({
|
|
|
5854
6206
|
logout: logout_default,
|
|
5855
6207
|
whoami: whoami_default,
|
|
5856
6208
|
apps: apps_default,
|
|
6209
|
+
logs: logs_default,
|
|
6210
|
+
usage: usage_default,
|
|
5857
6211
|
dev: dev_default,
|
|
5858
6212
|
kill: kill_default,
|
|
5859
6213
|
test: test_default,
|