run402 1.38.0 → 1.40.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/lib/agent.mjs +16 -15
- package/lib/ai.mjs +21 -33
- package/lib/allowance.mjs +41 -16
- package/lib/apps.mjs +71 -79
- package/lib/auth.mjs +27 -66
- package/lib/billing.mjs +37 -47
- package/lib/blob.mjs +37 -35
- package/lib/contracts.mjs +82 -193
- package/lib/domains.mjs +30 -34
- package/lib/email.mjs +94 -344
- package/lib/functions.mjs +77 -79
- package/lib/image.mjs +13 -14
- package/lib/message.mjs +11 -10
- package/lib/projects.mjs +121 -90
- package/lib/sdk-errors.mjs +45 -0
- package/lib/sdk.mjs +14 -0
- package/lib/secrets.mjs +18 -26
- package/lib/sender-domain.mjs +28 -45
- package/lib/service.mjs +16 -19
- package/lib/sites.mjs +24 -20
- package/lib/subdomains.mjs +22 -29
- package/lib/tier.mjs +10 -24
- package/lib/webhooks.mjs +32 -129
- package/package.json +1 -1
- package/lib/paid-fetch.mjs +0 -107
package/lib/domains.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveProjectId } from "./config.mjs";
|
|
2
|
+
import { getSdk } from "./sdk.mjs";
|
|
3
|
+
import { reportSdkError } from "./sdk-errors.mjs";
|
|
2
4
|
|
|
3
5
|
const HELP = `run402 domains — Manage custom domains
|
|
4
6
|
|
|
@@ -39,54 +41,48 @@ async function add(args) {
|
|
|
39
41
|
const domain = rest[0];
|
|
40
42
|
const subdomainName = rest[1];
|
|
41
43
|
if (!domain || !subdomainName) { console.error("Usage: run402 domains add <domain> <subdomain_name> [--project <id>]"); process.exit(1); }
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!res.ok) { console.error(JSON.stringify({ status: "error", http: res.status, ...data })); process.exit(1); }
|
|
50
|
-
console.log(JSON.stringify(data, null, 2));
|
|
44
|
+
const projectId = resolveProjectId(project);
|
|
45
|
+
try {
|
|
46
|
+
const data = await getSdk().domains.add(projectId, domain, subdomainName);
|
|
47
|
+
console.log(JSON.stringify(data, null, 2));
|
|
48
|
+
} catch (err) {
|
|
49
|
+
reportSdkError(err);
|
|
50
|
+
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
async function list(
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
async function list(projectIdArg) {
|
|
54
|
+
const projectId = resolveProjectId(projectIdArg);
|
|
55
|
+
try {
|
|
56
|
+
const data = await getSdk().domains.list(projectId);
|
|
57
|
+
console.log(JSON.stringify(data, null, 2));
|
|
58
|
+
} catch (err) {
|
|
59
|
+
reportSdkError(err);
|
|
60
|
+
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
async function status(args) {
|
|
64
64
|
const { project, rest } = parseProjectFlag(args);
|
|
65
65
|
const domain = rest[0];
|
|
66
66
|
if (!domain) { console.error("Usage: run402 domains status <domain> [--project <id>]"); process.exit(1); }
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
const projectId = resolveProjectId(project);
|
|
68
|
+
try {
|
|
69
|
+
const data = await getSdk().domains.status(projectId, domain);
|
|
70
|
+
console.log(JSON.stringify(data, null, 2));
|
|
71
|
+
} catch (err) {
|
|
72
|
+
reportSdkError(err);
|
|
73
|
+
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
async function deleteDomain(args) {
|
|
77
77
|
const { project, rest } = parseProjectFlag(args);
|
|
78
78
|
const domain = rest[0];
|
|
79
79
|
if (!domain) { console.error("Usage: run402 domains delete <domain> [--project <id>]"); process.exit(1); }
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
headers: { "Authorization": `Bearer ${p.service_key}` },
|
|
84
|
-
});
|
|
85
|
-
if (res.status === 204 || res.ok) {
|
|
80
|
+
const projectId = resolveProjectId(project);
|
|
81
|
+
try {
|
|
82
|
+
await getSdk().domains.remove(domain, { projectId });
|
|
86
83
|
console.log(JSON.stringify({ status: "ok", message: `Domain '${domain}' released.` }));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
console.error(JSON.stringify({ status: "error", http: res.status, ...data })); process.exit(1);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
reportSdkError(err);
|
|
90
86
|
}
|
|
91
87
|
}
|
|
92
88
|
|