deepspace 0.5.2 → 0.5.3
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/dist/cli.js +49 -24
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/dist/testing.d.ts +0 -115
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ var API_ERROR_HINTS = {
|
|
|
13
13
|
app_not_found: "App not found. Check the app name (wrangler.toml `name`) and that it has been deployed.",
|
|
14
14
|
not_app_owner_or_collaborator: "You must be the app owner or a collaborator to do this.",
|
|
15
15
|
test_account_cannot_be_collaborator: "Test accounts cannot be added as collaborators. Use a real DeepSpace account.",
|
|
16
|
-
user_not_found: "No DeepSpace user with that email.
|
|
16
|
+
user_not_found: "No DeepSpace user with that email. They need to log in to DeepSpace at least once (`deepspace login`, or sign in to any app) before they can be referenced by email."
|
|
17
17
|
};
|
|
18
18
|
function formatCliError(err) {
|
|
19
19
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -301,6 +301,19 @@ function mintAppId(now = Date.now()) {
|
|
|
301
301
|
}
|
|
302
302
|
return `app_${ts}${rs}`.slice(0, 30);
|
|
303
303
|
}
|
|
304
|
+
async function resolveOwnedAppId(deployUrl, token, appName) {
|
|
305
|
+
try {
|
|
306
|
+
const res = await fetch(`${deployUrl}/api/apps`, {
|
|
307
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
308
|
+
});
|
|
309
|
+
if (!res.ok) return null;
|
|
310
|
+
const body = await res.json();
|
|
311
|
+
const match = body.apps?.find((a) => a.name === appName);
|
|
312
|
+
return match?.appId ?? null;
|
|
313
|
+
} catch {
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
304
317
|
function readAppId(cwd = process.cwd(), wranglerEnv) {
|
|
305
318
|
const wranglerPath = join(resolve(cwd), "wrangler.toml");
|
|
306
319
|
if (!existsSync(wranglerPath)) return null;
|
|
@@ -862,6 +875,7 @@ function openBrowser(url) {
|
|
|
862
875
|
|
|
863
876
|
// src/cli/commands/login.ts
|
|
864
877
|
var AUTH_URL = process.env.DEEPSPACE_AUTH_URL ?? PLATFORM_URLS.auth;
|
|
878
|
+
var API_URL = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
865
879
|
var login_default = defineCommand({
|
|
866
880
|
meta: {
|
|
867
881
|
name: "login",
|
|
@@ -920,6 +934,7 @@ var login_default = defineCommand({
|
|
|
920
934
|
process.exit(1);
|
|
921
935
|
}
|
|
922
936
|
storeCredentials(result.sessionToken, result.jwt);
|
|
937
|
+
await provisionProfile(result.jwt);
|
|
923
938
|
s.stop("Authenticated");
|
|
924
939
|
p2.log.success(`Logged in as ${result.name ?? result.email}`);
|
|
925
940
|
p2.note(
|
|
@@ -963,6 +978,12 @@ function storeCredentials(sessionToken, jwt) {
|
|
|
963
978
|
writeFileSync5(join3(dir, "session"), sessionToken, { mode: 384 });
|
|
964
979
|
writeFileSync5(join3(dir, "token"), jwt, { mode: 384 });
|
|
965
980
|
}
|
|
981
|
+
async function provisionProfile(jwt) {
|
|
982
|
+
try {
|
|
983
|
+
await fetch(`${API_URL}/api/users/me`, { headers: { Authorization: `Bearer ${jwt}` } });
|
|
984
|
+
} catch {
|
|
985
|
+
}
|
|
986
|
+
}
|
|
966
987
|
function sleep(ms) {
|
|
967
988
|
return new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
968
989
|
}
|
|
@@ -991,6 +1012,7 @@ async function doEmailLogin(email, password) {
|
|
|
991
1012
|
throw new Error("JWT issuance failed");
|
|
992
1013
|
}
|
|
993
1014
|
storeCredentials(sessionToken, jwt);
|
|
1015
|
+
await provisionProfile(jwt);
|
|
994
1016
|
}
|
|
995
1017
|
|
|
996
1018
|
// src/cli/commands/logout.ts
|
|
@@ -2412,7 +2434,7 @@ function asObjectArray(v) {
|
|
|
2412
2434
|
|
|
2413
2435
|
// src/cli/commands/deploy.ts
|
|
2414
2436
|
var DEPLOY_URL3 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
2415
|
-
var
|
|
2437
|
+
var API_URL2 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
2416
2438
|
var CLOUDFLARE_DEPLOY_ERROR_HINT = "Deployment reached the DeepSpace deploy worker, but Cloudflare's deployment control-plane API failed. This is often caused by a Cloudflare Dashboard/API incident or Workers for Platforms entitlement outage. Already deployed apps should keep serving; wait for Cloudflare to recover and retry.";
|
|
2417
2439
|
var RESERVED_RUN_WORKER_FIRST = /* @__PURE__ */ new Set([
|
|
2418
2440
|
"/api/*",
|
|
@@ -2562,13 +2584,7 @@ var deploy_default = defineCommand8({
|
|
|
2562
2584
|
}
|
|
2563
2585
|
const appName = nameRes.name;
|
|
2564
2586
|
let appId = readAppId(appDir, envName);
|
|
2565
|
-
if (!appId) {
|
|
2566
|
-
appId = mintAppId();
|
|
2567
|
-
writeAppId(appDir, appId, { wranglerEnv: envName });
|
|
2568
|
-
p4.log.info(`Minted app id ${appId} \u2014 commit wrangler.toml.`);
|
|
2569
|
-
}
|
|
2570
2587
|
p4.log.info(envName ? `App: ${appName} (env: ${envName})` : `App: ${appName}`);
|
|
2571
|
-
p4.log.info(`Id: ${appId}`);
|
|
2572
2588
|
let token;
|
|
2573
2589
|
let ownerId;
|
|
2574
2590
|
try {
|
|
@@ -2578,6 +2594,15 @@ var deploy_default = defineCommand8({
|
|
|
2578
2594
|
p4.cancel(errMessage(err));
|
|
2579
2595
|
process.exit(1);
|
|
2580
2596
|
}
|
|
2597
|
+
if (!appId) {
|
|
2598
|
+
const adopted = await resolveOwnedAppId(DEPLOY_URL3, token, appName);
|
|
2599
|
+
appId = adopted ?? mintAppId();
|
|
2600
|
+
writeAppId(appDir, appId, { wranglerEnv: envName });
|
|
2601
|
+
p4.log.info(
|
|
2602
|
+
adopted ? `Adopted existing app id ${appId} for ${appName} \u2014 commit wrangler.toml.` : `Minted app id ${appId} \u2014 commit wrangler.toml.`
|
|
2603
|
+
);
|
|
2604
|
+
}
|
|
2605
|
+
p4.log.info(`Id: ${appId}`);
|
|
2581
2606
|
let linkedSecrets = null;
|
|
2582
2607
|
try {
|
|
2583
2608
|
const refreshed = await refreshSecretsCache(DEPLOY_URL3, token, appId, envName);
|
|
@@ -2935,7 +2960,7 @@ async function syncSubscriptionPlans(appDir, appName, token) {
|
|
|
2935
2960
|
s.start("Syncing subscription plans...");
|
|
2936
2961
|
let res;
|
|
2937
2962
|
try {
|
|
2938
|
-
res = await fetch(`${
|
|
2963
|
+
res = await fetch(`${API_URL2}/api/subscriptions/sync`, {
|
|
2939
2964
|
method: "POST",
|
|
2940
2965
|
headers: {
|
|
2941
2966
|
Authorization: `Bearer ${token}`,
|
|
@@ -3009,7 +3034,7 @@ current billing period? (Skip to leave them grandfathered.)`
|
|
|
3009
3034
|
let stopped = false;
|
|
3010
3035
|
try {
|
|
3011
3036
|
while (iteration < MAX_ITERATIONS) {
|
|
3012
|
-
const res = await fetch(`${
|
|
3037
|
+
const res = await fetch(`${API_URL2}/api/subscriptions/admin-cancel`, {
|
|
3013
3038
|
method: "POST",
|
|
3014
3039
|
headers: {
|
|
3015
3040
|
Authorization: `Bearer ${token}`,
|
|
@@ -3083,7 +3108,7 @@ async function syncOneTimeProducts(appDir, appName, token) {
|
|
|
3083
3108
|
s?.start("Syncing one-time products...");
|
|
3084
3109
|
let res;
|
|
3085
3110
|
try {
|
|
3086
|
-
res = await fetch(`${
|
|
3111
|
+
res = await fetch(`${API_URL2}/api/charges/products/sync`, {
|
|
3087
3112
|
method: "POST",
|
|
3088
3113
|
headers: {
|
|
3089
3114
|
Authorization: `Bearer ${token}`,
|
|
@@ -3449,8 +3474,8 @@ async function apiFetch(baseUrl, token, path, init) {
|
|
|
3449
3474
|
}
|
|
3450
3475
|
|
|
3451
3476
|
// src/cli/commands/domain.ts
|
|
3452
|
-
var
|
|
3453
|
-
var api = (token, path, init) => apiFetch(
|
|
3477
|
+
var API_URL3 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
3478
|
+
var api = (token, path, init) => apiFetch(API_URL3, token, path, init);
|
|
3454
3479
|
function scrubInternal(value) {
|
|
3455
3480
|
if (Array.isArray(value)) return value.map(scrubInternal);
|
|
3456
3481
|
if (value && typeof value === "object") {
|
|
@@ -3784,9 +3809,9 @@ function isTestAccountEmail(email) {
|
|
|
3784
3809
|
}
|
|
3785
3810
|
|
|
3786
3811
|
// src/cli/commands/collaborators.ts
|
|
3787
|
-
var
|
|
3812
|
+
var API_URL4 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
3788
3813
|
function api2(token, path, init) {
|
|
3789
|
-
return apiFetch(
|
|
3814
|
+
return apiFetch(API_URL4, token, path, init);
|
|
3790
3815
|
}
|
|
3791
3816
|
var list3 = defineCommand14({
|
|
3792
3817
|
meta: { name: "list", description: "List collaborators on your app" },
|
|
@@ -3885,7 +3910,7 @@ var collaborators_default = defineCommand14({
|
|
|
3885
3910
|
|
|
3886
3911
|
// src/cli/commands/transfer.ts
|
|
3887
3912
|
import { defineCommand as defineCommand15 } from "citty";
|
|
3888
|
-
var
|
|
3913
|
+
var API_URL5 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
3889
3914
|
var DEPLOY_URL5 = process.env.DEEPSPACE_DEPLOY_URL ?? PLATFORM_URLS.deploy;
|
|
3890
3915
|
var offer = defineCommand15({
|
|
3891
3916
|
meta: { name: "offer", description: "Offer this app to another DeepSpace user" },
|
|
@@ -3897,7 +3922,7 @@ var offer = defineCommand15({
|
|
|
3897
3922
|
const token = await ensureToken();
|
|
3898
3923
|
const app = requireAppIdArg(args.app);
|
|
3899
3924
|
const { expiresAt } = await apiFetch(
|
|
3900
|
-
|
|
3925
|
+
API_URL5,
|
|
3901
3926
|
token,
|
|
3902
3927
|
`/api/app-transfers/${encodeURIComponent(app)}`,
|
|
3903
3928
|
{ method: "POST", body: JSON.stringify({ email: args.email }) }
|
|
@@ -3916,7 +3941,7 @@ var status2 = defineCommand15({
|
|
|
3916
3941
|
async run({ args }) {
|
|
3917
3942
|
const token = await ensureToken();
|
|
3918
3943
|
const app = requireAppIdArg(args.app);
|
|
3919
|
-
const { transfer } = await apiFetch(
|
|
3944
|
+
const { transfer } = await apiFetch(API_URL5, token, `/api/app-transfers/${encodeURIComponent(app)}`);
|
|
3920
3945
|
if (!transfer) {
|
|
3921
3946
|
console.log(`No pending transfer for ${app}.`);
|
|
3922
3947
|
return;
|
|
@@ -3948,7 +3973,7 @@ var cancel4 = defineCommand15({
|
|
|
3948
3973
|
async run({ args }) {
|
|
3949
3974
|
const token = await ensureToken();
|
|
3950
3975
|
const app = requireAppIdArg(args.app);
|
|
3951
|
-
await apiFetch(
|
|
3976
|
+
await apiFetch(API_URL5, token, `/api/app-transfers/${encodeURIComponent(app)}`, { method: "DELETE" });
|
|
3952
3977
|
console.log(`\u2713 Transfer offer for ${app} cancelled.`);
|
|
3953
3978
|
}
|
|
3954
3979
|
});
|
|
@@ -3962,7 +3987,7 @@ import { defineCommand as defineCommand16 } from "citty";
|
|
|
3962
3987
|
|
|
3963
3988
|
// src/cli/commands/_invoke-impl.ts
|
|
3964
3989
|
import { readFileSync as readFileSync10 } from "fs";
|
|
3965
|
-
var
|
|
3990
|
+
var API_URL6 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
3966
3991
|
var DEFAULT_TIMEOUT_MS = 12e4;
|
|
3967
3992
|
function parseTarget(target) {
|
|
3968
3993
|
if (!target || typeof target !== "string") {
|
|
@@ -4004,7 +4029,7 @@ function flushAndExit(code) {
|
|
|
4004
4029
|
});
|
|
4005
4030
|
}
|
|
4006
4031
|
async function fetchCatalog(opts = {}) {
|
|
4007
|
-
const url = opts.summary ? `${
|
|
4032
|
+
const url = opts.summary ? `${API_URL6}/api/integrations?summary=1` : `${API_URL6}/api/integrations`;
|
|
4008
4033
|
const res = await fetch(url);
|
|
4009
4034
|
if (!res.ok) {
|
|
4010
4035
|
throw new Error(`Failed to fetch integration catalog (${res.status})`);
|
|
@@ -4092,7 +4117,7 @@ async function runInvoke(args) {
|
|
|
4092
4117
|
const startedAt = Date.now();
|
|
4093
4118
|
let res;
|
|
4094
4119
|
try {
|
|
4095
|
-
res = await fetch(`${
|
|
4120
|
+
res = await fetch(`${API_URL6}/api/integrations/${integration}/${endpoint}`, {
|
|
4096
4121
|
method: "POST",
|
|
4097
4122
|
headers: {
|
|
4098
4123
|
"Content-Type": "application/json",
|
|
@@ -4552,7 +4577,7 @@ import { existsSync as existsSync13, readFileSync as readFileSync12 } from "fs";
|
|
|
4552
4577
|
import { dirname as dirname3, join as join15 } from "path";
|
|
4553
4578
|
import { fileURLToPath } from "url";
|
|
4554
4579
|
import { release } from "os";
|
|
4555
|
-
var
|
|
4580
|
+
var API_URL7 = process.env.DEEPSPACE_API_URL ?? PLATFORM_URLS.api;
|
|
4556
4581
|
var TYPES = ["bug", "feature", "other"];
|
|
4557
4582
|
var TYPE_LABELS = {
|
|
4558
4583
|
bug: "Bug report",
|
|
@@ -4562,7 +4587,7 @@ var TYPE_LABELS = {
|
|
|
4562
4587
|
var MAX_TITLE_LEN = 200;
|
|
4563
4588
|
var MAX_BODY_LEN = 1e4;
|
|
4564
4589
|
var MAX_CONTEXT_LEN = 200;
|
|
4565
|
-
var api3 = (token, path, init) => apiFetch(
|
|
4590
|
+
var api3 = (token, path, init) => apiFetch(API_URL7, token, path, init);
|
|
4566
4591
|
function normalizeType(raw) {
|
|
4567
4592
|
const value = (raw ?? "bug").toLowerCase();
|
|
4568
4593
|
if (TYPES.includes(value)) return value;
|