groundmail-cli 0.47.3 → 0.49.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/dist/cli.js +396 -283
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -658,8 +658,8 @@ function parseSendCommandOptions(args, env) {
|
|
|
658
658
|
};
|
|
659
659
|
}
|
|
660
660
|
function createDefaultSendDeps(apiKey, baseUrl) {
|
|
661
|
-
let
|
|
662
|
-
const getClient = () =>
|
|
661
|
+
let client3 = null;
|
|
662
|
+
const getClient = () => client3 ?? (client3 = import("groundmail").then(({ Groundmail }) => new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0)));
|
|
663
663
|
return {
|
|
664
664
|
sendEmail: async (params) => (await getClient()).emails.send(params),
|
|
665
665
|
getEmail: async (id) => (await getClient()).emails.get(id),
|
|
@@ -733,10 +733,10 @@ async function runBatchCommandWithClient(args, env = process.env) {
|
|
|
733
733
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
734
734
|
}
|
|
735
735
|
const { Groundmail } = await import("groundmail");
|
|
736
|
-
const
|
|
736
|
+
const client3 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
737
737
|
return runBatchCommand(args, {
|
|
738
738
|
env,
|
|
739
|
-
sendBatch: (emails) =>
|
|
739
|
+
sendBatch: (emails) => client3.emails.batch(emails)
|
|
740
740
|
});
|
|
741
741
|
}
|
|
742
742
|
function parseBatchPayload(source) {
|
|
@@ -789,10 +789,10 @@ async function runCancelCommandWithClient(args, env = process.env) {
|
|
|
789
789
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
790
790
|
}
|
|
791
791
|
const { Groundmail } = await import("groundmail");
|
|
792
|
-
const
|
|
792
|
+
const client3 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
793
793
|
return runCancelCommand(args, {
|
|
794
794
|
env,
|
|
795
|
-
cancelEmail: (id) =>
|
|
795
|
+
cancelEmail: (id) => client3.emails.cancel(id)
|
|
796
796
|
});
|
|
797
797
|
}
|
|
798
798
|
|
|
@@ -832,10 +832,10 @@ async function runResendCommandWithClient(args, env = process.env) {
|
|
|
832
832
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
833
833
|
}
|
|
834
834
|
const { Groundmail } = await import("groundmail");
|
|
835
|
-
const
|
|
835
|
+
const client3 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
836
836
|
return runResendCommand(args, {
|
|
837
837
|
env,
|
|
838
|
-
resendEmail: (id) =>
|
|
838
|
+
resendEmail: (id) => client3.emails.resend(id)
|
|
839
839
|
});
|
|
840
840
|
}
|
|
841
841
|
|
|
@@ -909,10 +909,10 @@ async function runGetCommandWithClient(args, env = process.env) {
|
|
|
909
909
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
910
910
|
}
|
|
911
911
|
const { Groundmail } = await import("groundmail");
|
|
912
|
-
const
|
|
912
|
+
const client3 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
913
913
|
const result = await runGetCommand(args, {
|
|
914
914
|
env,
|
|
915
|
-
getEmail: (id) =>
|
|
915
|
+
getEmail: (id) => client3.emails.get(id),
|
|
916
916
|
resolveMx: lookupMx
|
|
917
917
|
});
|
|
918
918
|
return { exitCode: result.exitCode };
|
|
@@ -954,10 +954,10 @@ async function runInsightsCommandWithClient(args, env = process.env) {
|
|
|
954
954
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
955
955
|
}
|
|
956
956
|
const { Groundmail } = await import("groundmail");
|
|
957
|
-
const
|
|
957
|
+
const client3 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
958
958
|
return runInsightsCommand(args, {
|
|
959
959
|
env,
|
|
960
|
-
getInsights: (window) =>
|
|
960
|
+
getInsights: (window) => client3.emails.insights(window)
|
|
961
961
|
});
|
|
962
962
|
}
|
|
963
963
|
|
|
@@ -1012,10 +1012,10 @@ async function runListCommandWithClient(args, env = process.env) {
|
|
|
1012
1012
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
1013
1013
|
}
|
|
1014
1014
|
const { Groundmail } = await import("groundmail");
|
|
1015
|
-
const
|
|
1015
|
+
const client3 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
1016
1016
|
return runListCommand(args, {
|
|
1017
1017
|
env,
|
|
1018
|
-
listEmails: (params) =>
|
|
1018
|
+
listEmails: (params) => client3.emails.list(params)
|
|
1019
1019
|
});
|
|
1020
1020
|
}
|
|
1021
1021
|
|
|
@@ -1062,8 +1062,8 @@ async function runSendEventCommand(args, env = process.env) {
|
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
1064
|
try {
|
|
1065
|
-
const
|
|
1066
|
-
const result = await
|
|
1065
|
+
const client3 = await createClient(apiKey, baseUrl);
|
|
1066
|
+
const result = await client3.events.trigger({
|
|
1067
1067
|
name,
|
|
1068
1068
|
email,
|
|
1069
1069
|
user_id: userId,
|
|
@@ -1149,8 +1149,8 @@ async function runListCommand2(args, env = process.env) {
|
|
|
1149
1149
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
1150
1150
|
}
|
|
1151
1151
|
try {
|
|
1152
|
-
const
|
|
1153
|
-
const result = await
|
|
1152
|
+
const client3 = await createAutomationsClient(apiKey, options.baseUrl);
|
|
1153
|
+
const result = await client3.automations.list();
|
|
1154
1154
|
console.log(JSON.stringify(result));
|
|
1155
1155
|
return { exitCode: 0 };
|
|
1156
1156
|
} catch (error) {
|
|
@@ -1168,8 +1168,8 @@ async function runGetCommand2(args, env = process.env) {
|
|
|
1168
1168
|
const id = readFlag9(args, "--id");
|
|
1169
1169
|
if (!id) return { exitCode: 1, error: "Required flag: --id" };
|
|
1170
1170
|
try {
|
|
1171
|
-
const
|
|
1172
|
-
const result = await
|
|
1171
|
+
const client3 = await createAutomationsClient(apiKey, options.baseUrl);
|
|
1172
|
+
const result = await client3.automations.get(id);
|
|
1173
1173
|
console.log(JSON.stringify(result));
|
|
1174
1174
|
return { exitCode: 0 };
|
|
1175
1175
|
} catch (error) {
|
|
@@ -1197,8 +1197,8 @@ async function runCreateCommand(args, env = process.env) {
|
|
|
1197
1197
|
return { exitCode: 1, error: "Required: --steps or steps in --file" };
|
|
1198
1198
|
}
|
|
1199
1199
|
try {
|
|
1200
|
-
const
|
|
1201
|
-
const result = await
|
|
1200
|
+
const client3 = await createAutomationsClient(apiKey, options.baseUrl);
|
|
1201
|
+
const result = await client3.automations.create({
|
|
1202
1202
|
name,
|
|
1203
1203
|
trigger,
|
|
1204
1204
|
steps,
|
|
@@ -1230,8 +1230,8 @@ async function runUpdateCommand(args, env = process.env) {
|
|
|
1230
1230
|
};
|
|
1231
1231
|
}
|
|
1232
1232
|
try {
|
|
1233
|
-
const
|
|
1234
|
-
const result = await
|
|
1233
|
+
const client3 = await createAutomationsClient(apiKey, options.baseUrl);
|
|
1234
|
+
const result = await client3.automations.update(id, {
|
|
1235
1235
|
...name ? { name } : {},
|
|
1236
1236
|
...trigger ? { trigger } : {},
|
|
1237
1237
|
...steps ? { steps } : {},
|
|
@@ -1254,8 +1254,8 @@ async function runActivateCommand(args, env = process.env) {
|
|
|
1254
1254
|
const id = readFlag9(args, "--id");
|
|
1255
1255
|
if (!id) return { exitCode: 1, error: "Required flag: --id" };
|
|
1256
1256
|
try {
|
|
1257
|
-
const
|
|
1258
|
-
const result = await
|
|
1257
|
+
const client3 = await createAutomationsClient(apiKey, options.baseUrl);
|
|
1258
|
+
const result = await client3.automations.activate(id);
|
|
1259
1259
|
console.log(JSON.stringify(result));
|
|
1260
1260
|
return { exitCode: 0 };
|
|
1261
1261
|
} catch (error) {
|
|
@@ -1271,8 +1271,8 @@ async function runPauseCommand(args, env = process.env) {
|
|
|
1271
1271
|
const id = readFlag9(args, "--id");
|
|
1272
1272
|
if (!id) return { exitCode: 1, error: "Required flag: --id" };
|
|
1273
1273
|
try {
|
|
1274
|
-
const
|
|
1275
|
-
const result = await
|
|
1274
|
+
const client3 = await createAutomationsClient(apiKey, options.baseUrl);
|
|
1275
|
+
const result = await client3.automations.pause(id);
|
|
1276
1276
|
console.log(JSON.stringify(result));
|
|
1277
1277
|
return { exitCode: 0 };
|
|
1278
1278
|
} catch (error) {
|
|
@@ -1288,8 +1288,8 @@ async function runDeleteCommand(args, env = process.env) {
|
|
|
1288
1288
|
const id = readFlag9(args, "--id");
|
|
1289
1289
|
if (!id) return { exitCode: 1, error: "Required flag: --id" };
|
|
1290
1290
|
try {
|
|
1291
|
-
const
|
|
1292
|
-
const result = await
|
|
1291
|
+
const client3 = await createAutomationsClient(apiKey, options.baseUrl);
|
|
1292
|
+
const result = await client3.automations.remove(id);
|
|
1293
1293
|
console.log(JSON.stringify(result));
|
|
1294
1294
|
return { exitCode: 0 };
|
|
1295
1295
|
} catch (error) {
|
|
@@ -1357,9 +1357,9 @@ async function runAddCommand(args, env = process.env) {
|
|
|
1357
1357
|
};
|
|
1358
1358
|
}
|
|
1359
1359
|
try {
|
|
1360
|
-
const
|
|
1360
|
+
const client3 = await createDomainsClient(apiKey, options.baseUrl);
|
|
1361
1361
|
const inbound = readFlag10(args, "--inbound");
|
|
1362
|
-
const result = await
|
|
1362
|
+
const result = await client3.domains.create({
|
|
1363
1363
|
name,
|
|
1364
1364
|
...inbound === "true" || inbound === "1" ? { inbound_enabled: true } : {},
|
|
1365
1365
|
...options.tenant ? { tenant: options.tenant } : {}
|
|
@@ -1418,10 +1418,10 @@ async function runApplyCommand(args, env = process.env) {
|
|
|
1418
1418
|
};
|
|
1419
1419
|
}
|
|
1420
1420
|
try {
|
|
1421
|
-
const
|
|
1421
|
+
const client3 = await createDomainsClient(apiKey, options.baseUrl);
|
|
1422
1422
|
const dnsProvider = provider;
|
|
1423
1423
|
const useStored = !hasLocalCredentials(dnsProvider, env);
|
|
1424
|
-
const result = useStored ? await
|
|
1424
|
+
const result = useStored ? await client3.domains.apply(idOrName, { provider: dnsProvider }) : await client3.domains.applyDns({
|
|
1425
1425
|
idOrName,
|
|
1426
1426
|
provider: dnsProvider,
|
|
1427
1427
|
cloudflareApiToken: env.CLOUDFLARE_API_TOKEN || env.CLOUDFLARE_API_KEY,
|
|
@@ -1460,8 +1460,8 @@ async function runDeleteCommand2(args, env = process.env) {
|
|
|
1460
1460
|
const idOrName = options.id || options.name || readFirstPositional2(args);
|
|
1461
1461
|
if (!idOrName) return { exitCode: 1, error: "Missing domain. Usage: groundmail domains delete example.com" };
|
|
1462
1462
|
try {
|
|
1463
|
-
const
|
|
1464
|
-
console.log(JSON.stringify(await
|
|
1463
|
+
const client3 = await createDomainsClient(apiKey, options.baseUrl);
|
|
1464
|
+
console.log(JSON.stringify(await client3.domains.delete(idOrName)));
|
|
1465
1465
|
return { exitCode: 0 };
|
|
1466
1466
|
} catch (error) {
|
|
1467
1467
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -1488,8 +1488,8 @@ async function runGetCommand3(args, env = process.env) {
|
|
|
1488
1488
|
const idOrName = options.id || options.name || readFirstPositional3(args);
|
|
1489
1489
|
if (!idOrName) return { exitCode: 1, error: "Missing domain. Usage: groundmail domains get example.com" };
|
|
1490
1490
|
try {
|
|
1491
|
-
const
|
|
1492
|
-
console.log(JSON.stringify(await
|
|
1491
|
+
const client3 = await createDomainsClient(apiKey, options.baseUrl);
|
|
1492
|
+
console.log(JSON.stringify(await client3.domains.get(idOrName)));
|
|
1493
1493
|
return { exitCode: 0 };
|
|
1494
1494
|
} catch (error) {
|
|
1495
1495
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -1515,8 +1515,8 @@ async function runListCommand3(args, env = process.env) {
|
|
|
1515
1515
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
1516
1516
|
}
|
|
1517
1517
|
try {
|
|
1518
|
-
const
|
|
1519
|
-
const result = await
|
|
1518
|
+
const client3 = await createDomainsClient(apiKey, options.baseUrl);
|
|
1519
|
+
const result = await client3.domains.list(options.tenant ? { tenant: options.tenant } : {});
|
|
1520
1520
|
console.log(JSON.stringify(result));
|
|
1521
1521
|
return { exitCode: 0 };
|
|
1522
1522
|
} catch (error) {
|
|
@@ -1542,7 +1542,9 @@ var POSITIONAL_FLAGS3 = [
|
|
|
1542
1542
|
"--click-tracking",
|
|
1543
1543
|
"--inbound",
|
|
1544
1544
|
"--inbound-spam-threshold",
|
|
1545
|
-
"--inbound-spam-action"
|
|
1545
|
+
"--inbound-spam-action",
|
|
1546
|
+
"--inbound-forward-url",
|
|
1547
|
+
"--inbound-forward-secret"
|
|
1546
1548
|
];
|
|
1547
1549
|
function readFirstPositional4(args) {
|
|
1548
1550
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -1602,14 +1604,25 @@ async function runUpdateCommand2(args, env = process.env) {
|
|
|
1602
1604
|
}
|
|
1603
1605
|
payload.inbound_spam_action = spamAction;
|
|
1604
1606
|
}
|
|
1607
|
+
const forwardUrl = readFlag10(args, "--inbound-forward-url");
|
|
1608
|
+
if (forwardUrl != null) {
|
|
1609
|
+
if (forwardUrl === "none" || forwardUrl === "null") payload.inbound_forward_url = null;
|
|
1610
|
+
else if (!forwardUrl.startsWith("https://")) {
|
|
1611
|
+
return { exitCode: 1, error: "--inbound-forward-url must be an https:// URL, or none" };
|
|
1612
|
+
} else payload.inbound_forward_url = forwardUrl;
|
|
1613
|
+
}
|
|
1614
|
+
const forwardSecret = readFlag10(args, "--inbound-forward-secret");
|
|
1615
|
+
if (forwardSecret != null) {
|
|
1616
|
+
payload.inbound_forward_secret = forwardSecret === "none" || forwardSecret === "null" ? null : forwardSecret;
|
|
1617
|
+
}
|
|
1605
1618
|
if (!Object.keys(payload).length) {
|
|
1606
1619
|
return {
|
|
1607
1620
|
exitCode: 1,
|
|
1608
|
-
error: "No updates provided. Pass --inbound true|false, --tls-mode opportunistic|enforced, --open-tracking true|false, --click-tracking true|false, --inbound-spam-threshold <1-100|default>,
|
|
1621
|
+
error: "No updates provided. Pass --inbound true|false, --tls-mode opportunistic|enforced, --open-tracking true|false, --click-tracking true|false, --inbound-spam-threshold <1-100|default>, --inbound-spam-action flag|drop, --inbound-forward-url <https://\u2026|none>, or --inbound-forward-secret <secret|none>."
|
|
1609
1622
|
};
|
|
1610
1623
|
}
|
|
1611
|
-
const
|
|
1612
|
-
console.log(JSON.stringify(await
|
|
1624
|
+
const client3 = await createDomainsClient(apiKey, options.baseUrl);
|
|
1625
|
+
console.log(JSON.stringify(await client3.domains.update(idOrName, payload)));
|
|
1613
1626
|
return { exitCode: 0 };
|
|
1614
1627
|
} catch (error) {
|
|
1615
1628
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -1631,8 +1644,8 @@ async function runVerifyCommand(args, env = process.env) {
|
|
|
1631
1644
|
};
|
|
1632
1645
|
}
|
|
1633
1646
|
try {
|
|
1634
|
-
const
|
|
1635
|
-
const result = await
|
|
1647
|
+
const client3 = await createDomainsClient(apiKey, options.baseUrl);
|
|
1648
|
+
const result = await client3.domains.verify(idOrName);
|
|
1636
1649
|
console.log(JSON.stringify(result));
|
|
1637
1650
|
if (result.verified) {
|
|
1638
1651
|
console.error(`Domain ${result.domain.name} verified.`);
|
|
@@ -1688,8 +1701,8 @@ async function runGetCommand4(args, env = process.env) {
|
|
|
1688
1701
|
return { exitCode: 1, error: "Missing id. Usage: groundmail received-emails get inb_..." };
|
|
1689
1702
|
}
|
|
1690
1703
|
try {
|
|
1691
|
-
const
|
|
1692
|
-
console.log(JSON.stringify(await
|
|
1704
|
+
const client3 = await createReceivedEmailsClient(apiKey, options.baseUrl);
|
|
1705
|
+
console.log(JSON.stringify(await client3.receivedEmails.get(id)));
|
|
1693
1706
|
return { exitCode: 0 };
|
|
1694
1707
|
} catch (error) {
|
|
1695
1708
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -1704,10 +1717,10 @@ async function runListCommand4(args, env = process.env) {
|
|
|
1704
1717
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
1705
1718
|
}
|
|
1706
1719
|
try {
|
|
1707
|
-
const
|
|
1720
|
+
const client3 = await createReceivedEmailsClient(apiKey, options.baseUrl);
|
|
1708
1721
|
console.log(
|
|
1709
1722
|
JSON.stringify(
|
|
1710
|
-
await
|
|
1723
|
+
await client3.receivedEmails.list({
|
|
1711
1724
|
limit: readFlag11(args, "--limit") ? Number(readFlag11(args, "--limit")) : void 0,
|
|
1712
1725
|
cursor: readFlag11(args, "--cursor"),
|
|
1713
1726
|
domain: readFlag11(args, "--domain"),
|
|
@@ -1862,10 +1875,10 @@ async function runCreateCommand2(args, env = process.env) {
|
|
|
1862
1875
|
return { exitCode: 1, error: "Required flag: --url" };
|
|
1863
1876
|
}
|
|
1864
1877
|
try {
|
|
1865
|
-
const
|
|
1878
|
+
const client3 = await createWebhooksClient(apiKey, options.baseUrl);
|
|
1866
1879
|
const tenants = parseTenantsList(readFlag13(args, "--tenants"));
|
|
1867
1880
|
const mailboxes = parseTenantsList(readFlag13(args, "--mailboxes"));
|
|
1868
|
-
const result = await
|
|
1881
|
+
const result = await client3.webhooks.create({
|
|
1869
1882
|
url,
|
|
1870
1883
|
...tenants?.length ? { tenants } : {},
|
|
1871
1884
|
...mailboxes?.length ? { mailboxes } : {}
|
|
@@ -1886,8 +1899,8 @@ async function runGetCommand5(args, env = process.env) {
|
|
|
1886
1899
|
const id = readFlag14(args, "--id") || readFirstPositional6(args);
|
|
1887
1900
|
if (!id) return { exitCode: 1, error: "Missing webhook id. Pass --id wh_\u2026" };
|
|
1888
1901
|
try {
|
|
1889
|
-
const
|
|
1890
|
-
console.log(JSON.stringify(await
|
|
1902
|
+
const client3 = await createWebhooksClient(apiKey, options.baseUrl);
|
|
1903
|
+
console.log(JSON.stringify(await client3.webhooks.get(id)));
|
|
1891
1904
|
return { exitCode: 0 };
|
|
1892
1905
|
} catch (error) {
|
|
1893
1906
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -1921,8 +1934,8 @@ async function runDeleteCommand3(args, env = process.env) {
|
|
|
1921
1934
|
return { exitCode: 1, error: "Required flag: --id" };
|
|
1922
1935
|
}
|
|
1923
1936
|
try {
|
|
1924
|
-
const
|
|
1925
|
-
const result = await
|
|
1937
|
+
const client3 = await createWebhooksClient(apiKey, options.baseUrl);
|
|
1938
|
+
const result = await client3.webhooks.delete(id);
|
|
1926
1939
|
console.log(JSON.stringify(result));
|
|
1927
1940
|
return { exitCode: 0 };
|
|
1928
1941
|
} catch (error) {
|
|
@@ -1938,8 +1951,8 @@ async function runListCommand5(args, env = process.env) {
|
|
|
1938
1951
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
1939
1952
|
}
|
|
1940
1953
|
try {
|
|
1941
|
-
const
|
|
1942
|
-
const result = await
|
|
1954
|
+
const client3 = await createWebhooksClient(apiKey, options.baseUrl);
|
|
1955
|
+
const result = await client3.webhooks.list();
|
|
1943
1956
|
console.log(JSON.stringify(result));
|
|
1944
1957
|
return { exitCode: 0 };
|
|
1945
1958
|
} catch (error) {
|
|
@@ -1972,8 +1985,8 @@ async function runUpdateCommand3(args, env = process.env) {
|
|
|
1972
1985
|
...mailboxes !== void 0 ? { mailboxes } : {}
|
|
1973
1986
|
};
|
|
1974
1987
|
try {
|
|
1975
|
-
const
|
|
1976
|
-
console.log(JSON.stringify(await
|
|
1988
|
+
const client3 = await createWebhooksClient(apiKey, options.baseUrl);
|
|
1989
|
+
console.log(JSON.stringify(await client3.webhooks.update(id, payload)));
|
|
1977
1990
|
return { exitCode: 0 };
|
|
1978
1991
|
} catch (error) {
|
|
1979
1992
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -2072,11 +2085,11 @@ async function runListKeysCommandWithClient(args, env = process.env) {
|
|
|
2072
2085
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
2073
2086
|
}
|
|
2074
2087
|
const { Groundmail } = await import("groundmail");
|
|
2075
|
-
const
|
|
2088
|
+
const client3 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
2076
2089
|
try {
|
|
2077
2090
|
const limitRaw = readFlag16(args, "--limit");
|
|
2078
2091
|
const cursor = readFlag16(args, "--cursor");
|
|
2079
|
-
const result = await
|
|
2092
|
+
const result = await client3.apiKeys.list({
|
|
2080
2093
|
...limitRaw ? { limit: Number(limitRaw) } : {},
|
|
2081
2094
|
...cursor ? { cursor } : {}
|
|
2082
2095
|
});
|
|
@@ -2090,7 +2103,7 @@ async function runListKeysCommandWithClient(args, env = process.env) {
|
|
|
2090
2103
|
}
|
|
2091
2104
|
|
|
2092
2105
|
// package.json
|
|
2093
|
-
var version = "0.
|
|
2106
|
+
var version = "0.49.0";
|
|
2094
2107
|
|
|
2095
2108
|
// src/help.ts
|
|
2096
2109
|
var USAGE_LINES = [
|
|
@@ -2174,6 +2187,13 @@ var USAGE_LINES = [
|
|
|
2174
2187
|
" groundmail suppressions remove --id <id> | --email user@example.com [--tenant <tenant>]",
|
|
2175
2188
|
" groundmail suppressions list --type category_opt_out [--category product|newsletter] [--tenant <tenant> | --include-tenants] one-click category unsubscribes",
|
|
2176
2189
|
" groundmail suppressions remove --type category_opt_out --email user@example.com [--category newsletter] [--tenant <tenant>] re-subscribe to a category",
|
|
2190
|
+
" groundmail routes list <domain> email routing: what happens to mail for each address",
|
|
2191
|
+
" groundmail routes add <domain> --address support --action url --url https://\u2026 [--secret \u2026] send an address to your app (raw message)",
|
|
2192
|
+
" groundmail routes add <domain> --address billing --action forward --forward-to you@example.com forward an address (it confirms first)",
|
|
2193
|
+
" groundmail routes add <domain> --address noreply --action drop|keep drop mail, or keep it in Inbound",
|
|
2194
|
+
" groundmail routes update <domain> <route-id> [--action \u2026] [--url \u2026] [--forward-to \u2026]",
|
|
2195
|
+
" groundmail routes remove <domain> <route-id>",
|
|
2196
|
+
" groundmail routes test <domain> [--address support] send a real test email through routing",
|
|
2177
2197
|
" groundmail templates list [--status draft|published]",
|
|
2178
2198
|
" groundmail templates starters",
|
|
2179
2199
|
" groundmail templates from-starter password-reset",
|
|
@@ -2426,15 +2446,15 @@ function parseArgs(argv, spec) {
|
|
|
2426
2446
|
const booleanFlags = new Set(spec.booleans ?? []);
|
|
2427
2447
|
const values = {};
|
|
2428
2448
|
const booleans = {};
|
|
2429
|
-
const
|
|
2449
|
+
const positionals4 = [];
|
|
2430
2450
|
for (let i = 0; i < argv.length; i++) {
|
|
2431
2451
|
const arg = argv[i];
|
|
2432
2452
|
if (arg === "--") {
|
|
2433
|
-
|
|
2453
|
+
positionals4.push(...argv.slice(i + 1));
|
|
2434
2454
|
break;
|
|
2435
2455
|
}
|
|
2436
2456
|
if (!arg.startsWith("--") || arg === "-") {
|
|
2437
|
-
|
|
2457
|
+
positionals4.push(arg);
|
|
2438
2458
|
continue;
|
|
2439
2459
|
}
|
|
2440
2460
|
const eq = arg.indexOf("=");
|
|
@@ -2460,7 +2480,7 @@ function parseArgs(argv, spec) {
|
|
|
2460
2480
|
const known = [...valueFlags, ...booleanFlags].sort().join(", ");
|
|
2461
2481
|
return { ok: false, error: `Unknown flag ${name}.${known ? ` This command takes: ${known}.` : ""}` };
|
|
2462
2482
|
}
|
|
2463
|
-
return { ok: true, args: { values, booleans, positionals:
|
|
2483
|
+
return { ok: true, args: { values, booleans, positionals: positionals4 } };
|
|
2464
2484
|
}
|
|
2465
2485
|
function wantsJson(args, stdout = process.stdout) {
|
|
2466
2486
|
if (args.booleans["--json"] !== void 0) return args.booleans["--json"];
|
|
@@ -3279,9 +3299,9 @@ async function runDeleteKeyCommandWithClient(args, env = process.env) {
|
|
|
3279
3299
|
return { exitCode: 1, error: "Required: --id <api-key-id>" };
|
|
3280
3300
|
}
|
|
3281
3301
|
const { Groundmail } = await import("groundmail");
|
|
3282
|
-
const
|
|
3302
|
+
const client3 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
3283
3303
|
try {
|
|
3284
|
-
const result = await
|
|
3304
|
+
const result = await client3.apiKeys.remove(id);
|
|
3285
3305
|
console.log(JSON.stringify(result));
|
|
3286
3306
|
return { exitCode: 0 };
|
|
3287
3307
|
} catch (error) {
|
|
@@ -3319,7 +3339,7 @@ async function runListCommand6(args, env = process.env) {
|
|
|
3319
3339
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3320
3340
|
}
|
|
3321
3341
|
try {
|
|
3322
|
-
const
|
|
3342
|
+
const client3 = await createSuppressionsClient(apiKey, options.baseUrl);
|
|
3323
3343
|
const limitRaw = readFlag19(args, "--limit");
|
|
3324
3344
|
const cursor = readFlag19(args, "--cursor");
|
|
3325
3345
|
const email = readFlag19(args, "--email");
|
|
@@ -3333,7 +3353,7 @@ async function runListCommand6(args, env = process.env) {
|
|
|
3333
3353
|
if (category && category !== "product" && category !== "newsletter") {
|
|
3334
3354
|
return { exitCode: 1, error: "--category must be product or newsletter" };
|
|
3335
3355
|
}
|
|
3336
|
-
const optOuts = await
|
|
3356
|
+
const optOuts = await client3.suppressions.listCategoryOptOuts({
|
|
3337
3357
|
...limitRaw ? { limit: Number(limitRaw) } : {},
|
|
3338
3358
|
...cursor ? { cursor } : {},
|
|
3339
3359
|
...email ? { email } : {},
|
|
@@ -3344,7 +3364,7 @@ async function runListCommand6(args, env = process.env) {
|
|
|
3344
3364
|
console.log(JSON.stringify(optOuts));
|
|
3345
3365
|
return { exitCode: 0 };
|
|
3346
3366
|
}
|
|
3347
|
-
const result = await
|
|
3367
|
+
const result = await client3.suppressions.list({
|
|
3348
3368
|
...limitRaw ? { limit: Number(limitRaw) } : {},
|
|
3349
3369
|
...cursor ? { cursor } : {},
|
|
3350
3370
|
...email ? { email } : {},
|
|
@@ -3370,9 +3390,9 @@ async function runAddCommand2(args, env = process.env) {
|
|
|
3370
3390
|
return { exitCode: 1, error: "Missing email. Pass --email user@example.com" };
|
|
3371
3391
|
}
|
|
3372
3392
|
try {
|
|
3373
|
-
const
|
|
3393
|
+
const client3 = await createSuppressionsClient(apiKey, options.baseUrl);
|
|
3374
3394
|
const reason = readFlag19(args, "--reason");
|
|
3375
|
-
const result = await
|
|
3395
|
+
const result = await client3.suppressions.create({
|
|
3376
3396
|
email,
|
|
3377
3397
|
...reason ? { reason } : {},
|
|
3378
3398
|
...tenant ? { tenant } : {}
|
|
@@ -3407,16 +3427,16 @@ async function runRemoveCommand(args, env = process.env) {
|
|
|
3407
3427
|
return { exitCode: 1, error: "Missing id or email. Pass --id <uuid> or --email user@example.com" };
|
|
3408
3428
|
}
|
|
3409
3429
|
try {
|
|
3410
|
-
const
|
|
3430
|
+
const client3 = await createSuppressionsClient(apiKey, options.baseUrl);
|
|
3411
3431
|
if (type === "category_opt_out") {
|
|
3412
|
-
const optOut = await
|
|
3432
|
+
const optOut = await client3.suppressions.removeCategoryOptOut(idOrEmail, {
|
|
3413
3433
|
...category ? { category } : {},
|
|
3414
3434
|
...tenant ? { tenant } : {}
|
|
3415
3435
|
});
|
|
3416
3436
|
console.log(JSON.stringify(optOut));
|
|
3417
3437
|
return { exitCode: 0 };
|
|
3418
3438
|
}
|
|
3419
|
-
const result = tenant ? await
|
|
3439
|
+
const result = tenant ? await client3.suppressions.remove(idOrEmail, { tenant }) : await client3.suppressions.remove(idOrEmail);
|
|
3420
3440
|
console.log(JSON.stringify(result));
|
|
3421
3441
|
return { exitCode: 0 };
|
|
3422
3442
|
} catch (error) {
|
|
@@ -3424,16 +3444,104 @@ async function runRemoveCommand(args, env = process.env) {
|
|
|
3424
3444
|
}
|
|
3425
3445
|
}
|
|
3426
3446
|
|
|
3427
|
-
// src/commands/
|
|
3447
|
+
// src/commands/routes/routes.ts
|
|
3428
3448
|
function readFlag20(args, flag) {
|
|
3449
|
+
const index = args.indexOf(flag);
|
|
3450
|
+
return index === -1 ? void 0 : args[index + 1];
|
|
3451
|
+
}
|
|
3452
|
+
var VALUE_FLAGS2 = ["--api-key", "--base-url", "--address", "--action", "--url", "--secret", "--forward-to", "--skip-spam", "--id"];
|
|
3453
|
+
function positionals2(args) {
|
|
3454
|
+
const out = [];
|
|
3455
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
3456
|
+
if (args[i].startsWith("--")) {
|
|
3457
|
+
if (VALUE_FLAGS2.includes(args[i])) i += 1;
|
|
3458
|
+
continue;
|
|
3459
|
+
}
|
|
3460
|
+
out.push(args[i]);
|
|
3461
|
+
}
|
|
3462
|
+
return out;
|
|
3463
|
+
}
|
|
3464
|
+
async function client(args, env) {
|
|
3465
|
+
const apiKey = readFlag20(args, "--api-key") || env.GROUNDMAIL_API_KEY;
|
|
3466
|
+
if (!apiKey) return null;
|
|
3467
|
+
const baseUrl = readFlag20(args, "--base-url");
|
|
3468
|
+
const { Groundmail } = await import("groundmail");
|
|
3469
|
+
return new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
3470
|
+
}
|
|
3471
|
+
var ACTIONS = ["url", "forward", "keep", "drop"];
|
|
3472
|
+
function routeParams(args) {
|
|
3473
|
+
const params = {};
|
|
3474
|
+
const action = readFlag20(args, "--action");
|
|
3475
|
+
if (action !== void 0) {
|
|
3476
|
+
if (!ACTIONS.includes(action)) return { ok: false, error: "--action must be url, forward, keep or drop" };
|
|
3477
|
+
params.action = action;
|
|
3478
|
+
}
|
|
3479
|
+
const url = readFlag20(args, "--url");
|
|
3480
|
+
if (url !== void 0) params.url = url;
|
|
3481
|
+
const secret = readFlag20(args, "--secret");
|
|
3482
|
+
if (secret !== void 0) params.secret = secret === "none" ? null : secret;
|
|
3483
|
+
const forwardTo = readFlag20(args, "--forward-to");
|
|
3484
|
+
if (forwardTo !== void 0) params.forwardTo = forwardTo;
|
|
3485
|
+
const skipSpam = readFlag20(args, "--skip-spam");
|
|
3486
|
+
if (skipSpam !== void 0) {
|
|
3487
|
+
if (skipSpam !== "true" && skipSpam !== "false") return { ok: false, error: "--skip-spam must be true or false" };
|
|
3488
|
+
params.skipSpam = skipSpam === "true";
|
|
3489
|
+
}
|
|
3490
|
+
return { ok: true, params };
|
|
3491
|
+
}
|
|
3492
|
+
async function runRoutesCommand(subcommand, args, env = process.env) {
|
|
3493
|
+
const gm = await client(args, env);
|
|
3494
|
+
if (!gm) return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3495
|
+
const [domain, routeId] = positionals2(args);
|
|
3496
|
+
if (!domain) return { exitCode: 1, error: "Missing domain. Usage: groundmail routes <list|add|update|remove|test> <domain> \u2026" };
|
|
3497
|
+
try {
|
|
3498
|
+
if (subcommand === "list") {
|
|
3499
|
+
console.log(JSON.stringify(await gm.routes.list(domain)));
|
|
3500
|
+
return { exitCode: 0 };
|
|
3501
|
+
}
|
|
3502
|
+
if (subcommand === "add" || subcommand === "create") {
|
|
3503
|
+
const address = readFlag20(args, "--address");
|
|
3504
|
+
if (!address) return { exitCode: 1, error: "Missing --address (a local part such as support, or *)" };
|
|
3505
|
+
const parsed = routeParams(args);
|
|
3506
|
+
if (!parsed.ok) return { exitCode: 1, error: parsed.error };
|
|
3507
|
+
if (!parsed.params.action) return { exitCode: 1, error: "Missing --action url|forward|keep|drop" };
|
|
3508
|
+
console.log(JSON.stringify(await gm.routes.create(domain, { address, ...parsed.params })));
|
|
3509
|
+
return { exitCode: 0 };
|
|
3510
|
+
}
|
|
3511
|
+
if (subcommand === "update") {
|
|
3512
|
+
const id = readFlag20(args, "--id") ?? routeId;
|
|
3513
|
+
if (!id) return { exitCode: 1, error: "Missing route id" };
|
|
3514
|
+
const parsed = routeParams(args);
|
|
3515
|
+
if (!parsed.ok) return { exitCode: 1, error: parsed.error };
|
|
3516
|
+
console.log(JSON.stringify(await gm.routes.update(domain, id, parsed.params)));
|
|
3517
|
+
return { exitCode: 0 };
|
|
3518
|
+
}
|
|
3519
|
+
if (subcommand === "remove" || subcommand === "delete") {
|
|
3520
|
+
const id = readFlag20(args, "--id") ?? routeId;
|
|
3521
|
+
if (!id) return { exitCode: 1, error: "Missing route id" };
|
|
3522
|
+
console.log(JSON.stringify(await gm.routes.remove(domain, id)));
|
|
3523
|
+
return { exitCode: 0 };
|
|
3524
|
+
}
|
|
3525
|
+
if (subcommand === "test") {
|
|
3526
|
+
console.log(JSON.stringify(await gm.routes.test(domain, readFlag20(args, "--address"))));
|
|
3527
|
+
return { exitCode: 0 };
|
|
3528
|
+
}
|
|
3529
|
+
return { exitCode: 1, error: "Usage: groundmail routes <list|add|update|remove|test> <domain> \u2026" };
|
|
3530
|
+
} catch (error) {
|
|
3531
|
+
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
|
|
3535
|
+
// src/commands/templates/shared.ts
|
|
3536
|
+
function readFlag21(args, flag) {
|
|
3429
3537
|
const index = args.indexOf(flag);
|
|
3430
3538
|
if (index === -1) return void 0;
|
|
3431
3539
|
return args[index + 1];
|
|
3432
3540
|
}
|
|
3433
3541
|
function parseTemplatesCommonArgs(args) {
|
|
3434
3542
|
return {
|
|
3435
|
-
apiKey:
|
|
3436
|
-
baseUrl:
|
|
3543
|
+
apiKey: readFlag21(args, "--api-key"),
|
|
3544
|
+
baseUrl: readFlag21(args, "--base-url")
|
|
3437
3545
|
};
|
|
3438
3546
|
}
|
|
3439
3547
|
function resolveApiKey8(options, env) {
|
|
@@ -3450,11 +3558,11 @@ async function runDeleteCommand4(args, env = process.env) {
|
|
|
3450
3558
|
const options = parseTemplatesCommonArgs(args);
|
|
3451
3559
|
const apiKey = resolveApiKey8(options, env);
|
|
3452
3560
|
if (!apiKey) return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3453
|
-
const idOrAlias =
|
|
3561
|
+
const idOrAlias = readFlag21(args, "--id") || readFlag21(args, "--alias") || readFirstPositional8(args);
|
|
3454
3562
|
if (!idOrAlias) return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
|
|
3455
3563
|
try {
|
|
3456
|
-
const
|
|
3457
|
-
console.log(JSON.stringify(await
|
|
3564
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
3565
|
+
console.log(JSON.stringify(await client3.templates.remove(idOrAlias)));
|
|
3458
3566
|
return { exitCode: 0 };
|
|
3459
3567
|
} catch (error) {
|
|
3460
3568
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -3478,12 +3586,12 @@ async function runDuplicateCommand(args, env = process.env) {
|
|
|
3478
3586
|
const options = parseTemplatesCommonArgs(args);
|
|
3479
3587
|
const apiKey = resolveApiKey8(options, env);
|
|
3480
3588
|
if (!apiKey) return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3481
|
-
const idOrAlias =
|
|
3589
|
+
const idOrAlias = readFlag21(args, "--id") || readFlag21(args, "--alias") || readFirstPositional9(args);
|
|
3482
3590
|
if (!idOrAlias) return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
|
|
3483
|
-
const name =
|
|
3591
|
+
const name = readFlag21(args, "--name");
|
|
3484
3592
|
try {
|
|
3485
|
-
const
|
|
3486
|
-
console.log(JSON.stringify(await
|
|
3593
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
3594
|
+
console.log(JSON.stringify(await client3.templates.duplicate(idOrAlias, name ? { name } : {})));
|
|
3487
3595
|
return { exitCode: 0 };
|
|
3488
3596
|
} catch (error) {
|
|
3489
3597
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -3507,11 +3615,11 @@ async function runGetCommand6(args, env = process.env) {
|
|
|
3507
3615
|
const options = parseTemplatesCommonArgs(args);
|
|
3508
3616
|
const apiKey = resolveApiKey8(options, env);
|
|
3509
3617
|
if (!apiKey) return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3510
|
-
const idOrAlias =
|
|
3618
|
+
const idOrAlias = readFlag21(args, "--id") || readFlag21(args, "--alias") || readFirstPositional10(args);
|
|
3511
3619
|
if (!idOrAlias) return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
|
|
3512
3620
|
try {
|
|
3513
|
-
const
|
|
3514
|
-
console.log(JSON.stringify(await
|
|
3621
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
3622
|
+
console.log(JSON.stringify(await client3.templates.get(idOrAlias)));
|
|
3515
3623
|
return { exitCode: 0 };
|
|
3516
3624
|
} catch (error) {
|
|
3517
3625
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -3537,11 +3645,11 @@ async function runListCommand7(args, env = process.env) {
|
|
|
3537
3645
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3538
3646
|
}
|
|
3539
3647
|
try {
|
|
3540
|
-
const
|
|
3541
|
-
const limitRaw =
|
|
3542
|
-
const cursor =
|
|
3543
|
-
const status =
|
|
3544
|
-
const result = await
|
|
3648
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
3649
|
+
const limitRaw = readFlag21(args, "--limit");
|
|
3650
|
+
const cursor = readFlag21(args, "--cursor");
|
|
3651
|
+
const status = readFlag21(args, "--status");
|
|
3652
|
+
const result = await client3.templates.list({
|
|
3545
3653
|
...limitRaw ? { limit: Number(limitRaw) } : {},
|
|
3546
3654
|
...cursor ? { cursor } : {},
|
|
3547
3655
|
...status ? { status } : {}
|
|
@@ -3559,11 +3667,11 @@ async function runPublishCommand(args, env = process.env) {
|
|
|
3559
3667
|
const options = parseTemplatesCommonArgs(args);
|
|
3560
3668
|
const apiKey = resolveApiKey8(options, env);
|
|
3561
3669
|
if (!apiKey) return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3562
|
-
const idOrAlias =
|
|
3670
|
+
const idOrAlias = readFlag21(args, "--id") || readFlag21(args, "--alias") || readFirstPositional11(args);
|
|
3563
3671
|
if (!idOrAlias) return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
|
|
3564
3672
|
try {
|
|
3565
|
-
const
|
|
3566
|
-
console.log(JSON.stringify(await
|
|
3673
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
3674
|
+
console.log(JSON.stringify(await client3.templates.publish(idOrAlias)));
|
|
3567
3675
|
return { exitCode: 0 };
|
|
3568
3676
|
} catch (error) {
|
|
3569
3677
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -3671,7 +3779,7 @@ async function loadTemplateSource(filePath, options = {}, deps = {}) {
|
|
|
3671
3779
|
}
|
|
3672
3780
|
|
|
3673
3781
|
// src/commands/templates/push.ts
|
|
3674
|
-
var
|
|
3782
|
+
var VALUE_FLAGS3 = /* @__PURE__ */ new Set([
|
|
3675
3783
|
"--alias",
|
|
3676
3784
|
"--subject",
|
|
3677
3785
|
"--name",
|
|
@@ -3685,7 +3793,7 @@ function readPositional(args) {
|
|
|
3685
3793
|
for (let index = 0; index < args.length; index += 1) {
|
|
3686
3794
|
const arg = args[index];
|
|
3687
3795
|
if (arg.startsWith("--")) {
|
|
3688
|
-
if (
|
|
3796
|
+
if (VALUE_FLAGS3.has(arg)) index += 1;
|
|
3689
3797
|
continue;
|
|
3690
3798
|
}
|
|
3691
3799
|
return arg;
|
|
@@ -3702,19 +3810,19 @@ async function runPushCommand(args, env = process.env, deps = {}) {
|
|
|
3702
3810
|
if (!apiKey) {
|
|
3703
3811
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3704
3812
|
}
|
|
3705
|
-
const file =
|
|
3813
|
+
const file = readFlag21(args, "--file") ?? readPositional(args);
|
|
3706
3814
|
if (!file) {
|
|
3707
3815
|
return { exitCode: 1, error: "Missing template file. Usage: templates push <file> --alias <alias>" };
|
|
3708
3816
|
}
|
|
3709
|
-
const alias =
|
|
3817
|
+
const alias = readFlag21(args, "--alias");
|
|
3710
3818
|
if (!alias) {
|
|
3711
3819
|
return { exitCode: 1, error: "Missing --alias. The alias identifies which template to update." };
|
|
3712
3820
|
}
|
|
3713
|
-
const subject =
|
|
3714
|
-
const name =
|
|
3715
|
-
const preheader =
|
|
3716
|
-
const textFile =
|
|
3717
|
-
const propsRaw =
|
|
3821
|
+
const subject = readFlag21(args, "--subject");
|
|
3822
|
+
const name = readFlag21(args, "--name");
|
|
3823
|
+
const preheader = readFlag21(args, "--preheader");
|
|
3824
|
+
const textFile = readFlag21(args, "--text");
|
|
3825
|
+
const propsRaw = readFlag21(args, "--props");
|
|
3718
3826
|
const shouldPublish = args.includes("--publish");
|
|
3719
3827
|
let props = {};
|
|
3720
3828
|
if (propsRaw) {
|
|
@@ -3738,10 +3846,10 @@ async function runPushCommand(args, env = process.env, deps = {}) {
|
|
|
3738
3846
|
return { exitCode: 1, error: `${file} produced no content to push.` };
|
|
3739
3847
|
}
|
|
3740
3848
|
const createClient2 = deps.createClient ?? createTemplatesClient;
|
|
3741
|
-
const
|
|
3849
|
+
const client3 = await createClient2(apiKey, options.baseUrl);
|
|
3742
3850
|
let existed = true;
|
|
3743
3851
|
try {
|
|
3744
|
-
await
|
|
3852
|
+
await client3.templates.get(alias);
|
|
3745
3853
|
} catch (error) {
|
|
3746
3854
|
if (statusOf(error) !== 404) throw error;
|
|
3747
3855
|
existed = false;
|
|
@@ -3756,7 +3864,7 @@ async function runPushCommand(args, env = process.env, deps = {}) {
|
|
|
3756
3864
|
};
|
|
3757
3865
|
let result;
|
|
3758
3866
|
if (existed) {
|
|
3759
|
-
result = await
|
|
3867
|
+
result = await client3.templates.update(alias, body);
|
|
3760
3868
|
} else {
|
|
3761
3869
|
if (!subject) {
|
|
3762
3870
|
return {
|
|
@@ -3764,7 +3872,7 @@ async function runPushCommand(args, env = process.env, deps = {}) {
|
|
|
3764
3872
|
error: `Template "${alias}" does not exist yet. Pass --subject to create it.`
|
|
3765
3873
|
};
|
|
3766
3874
|
}
|
|
3767
|
-
result = await
|
|
3875
|
+
result = await client3.templates.create({
|
|
3768
3876
|
name: name || alias,
|
|
3769
3877
|
subject,
|
|
3770
3878
|
alias,
|
|
@@ -3772,7 +3880,7 @@ async function runPushCommand(args, env = process.env, deps = {}) {
|
|
|
3772
3880
|
});
|
|
3773
3881
|
}
|
|
3774
3882
|
if (shouldPublish) {
|
|
3775
|
-
result = await
|
|
3883
|
+
result = await client3.templates.publish(alias);
|
|
3776
3884
|
}
|
|
3777
3885
|
console.log(JSON.stringify({ ...result, pushed: { file, alias, created: !existed } }));
|
|
3778
3886
|
return { exitCode: 0 };
|
|
@@ -3788,14 +3896,14 @@ async function runCreateCommand3(args, env = process.env) {
|
|
|
3788
3896
|
if (!apiKey) {
|
|
3789
3897
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3790
3898
|
}
|
|
3791
|
-
const name =
|
|
3792
|
-
const subject =
|
|
3793
|
-
const html =
|
|
3794
|
-
const text =
|
|
3795
|
-
const alias =
|
|
3796
|
-
const category =
|
|
3797
|
-
const folder =
|
|
3798
|
-
const sender =
|
|
3899
|
+
const name = readFlag21(args, "--name");
|
|
3900
|
+
const subject = readFlag21(args, "--subject");
|
|
3901
|
+
const html = readFlag21(args, "--html");
|
|
3902
|
+
const text = readFlag21(args, "--text");
|
|
3903
|
+
const alias = readFlag21(args, "--alias");
|
|
3904
|
+
const category = readFlag21(args, "--category");
|
|
3905
|
+
const folder = readFlag21(args, "--folder");
|
|
3906
|
+
const sender = readFlag21(args, "--sender");
|
|
3799
3907
|
const unsubscribeEnabled = args.includes("--unsubscribe-enabled");
|
|
3800
3908
|
if (!name) {
|
|
3801
3909
|
return { exitCode: 1, error: 'Missing name. Pass --name "Welcome"' };
|
|
@@ -3807,8 +3915,8 @@ async function runCreateCommand3(args, env = process.env) {
|
|
|
3807
3915
|
return { exitCode: 1, error: 'Missing body. Pass --html "<p>Hi</p>" or --text "Hi"' };
|
|
3808
3916
|
}
|
|
3809
3917
|
try {
|
|
3810
|
-
const
|
|
3811
|
-
const result = await
|
|
3918
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
3919
|
+
const result = await client3.templates.create({
|
|
3812
3920
|
name,
|
|
3813
3921
|
subject,
|
|
3814
3922
|
...html ? { html } : {},
|
|
@@ -3847,19 +3955,19 @@ async function runUpdateCommand4(args, env = process.env) {
|
|
|
3847
3955
|
if (!apiKey) {
|
|
3848
3956
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3849
3957
|
}
|
|
3850
|
-
const idOrAlias =
|
|
3958
|
+
const idOrAlias = readFlag21(args, "--id") || readFlag21(args, "--alias") || readFirstPositional12(args);
|
|
3851
3959
|
if (!idOrAlias) {
|
|
3852
3960
|
return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
|
|
3853
3961
|
}
|
|
3854
|
-
const name =
|
|
3855
|
-
const subject =
|
|
3856
|
-
const html =
|
|
3857
|
-
const text =
|
|
3858
|
-
const alias =
|
|
3962
|
+
const name = readFlag21(args, "--name");
|
|
3963
|
+
const subject = readFlag21(args, "--subject");
|
|
3964
|
+
const html = readFlag21(args, "--html");
|
|
3965
|
+
const text = readFlag21(args, "--text");
|
|
3966
|
+
const alias = readFlag21(args, "--set-alias");
|
|
3859
3967
|
const variables = readFlags3(args, "--variable");
|
|
3860
|
-
const category =
|
|
3861
|
-
const folder =
|
|
3862
|
-
const sender =
|
|
3968
|
+
const category = readFlag21(args, "--category");
|
|
3969
|
+
const folder = readFlag21(args, "--folder");
|
|
3970
|
+
const sender = readFlag21(args, "--sender");
|
|
3863
3971
|
const unsubscribeEnabled = args.includes("--unsubscribe-enabled");
|
|
3864
3972
|
const unsubscribeDisabled = args.includes("--no-unsubscribe-enabled");
|
|
3865
3973
|
if (!name && !subject && !html && !text && !alias && variables.length === 0 && !category && folder === void 0 && sender === void 0 && !unsubscribeEnabled && !unsubscribeDisabled) {
|
|
@@ -3869,8 +3977,8 @@ async function runUpdateCommand4(args, env = process.env) {
|
|
|
3869
3977
|
};
|
|
3870
3978
|
}
|
|
3871
3979
|
try {
|
|
3872
|
-
const
|
|
3873
|
-
const result = await
|
|
3980
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
3981
|
+
const result = await client3.templates.update(idOrAlias, {
|
|
3874
3982
|
...name ? { name } : {},
|
|
3875
3983
|
...subject ? { subject } : {},
|
|
3876
3984
|
...html ? { html } : {},
|
|
@@ -3927,7 +4035,7 @@ async function runFromStarterCommand(args, env = process.env) {
|
|
|
3927
4035
|
if (!apiKey) {
|
|
3928
4036
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3929
4037
|
}
|
|
3930
|
-
const alias =
|
|
4038
|
+
const alias = readFlag21(args, "--alias") || readFirstPositional13(args);
|
|
3931
4039
|
if (!alias) {
|
|
3932
4040
|
return {
|
|
3933
4041
|
exitCode: 1,
|
|
@@ -3935,8 +4043,8 @@ async function runFromStarterCommand(args, env = process.env) {
|
|
|
3935
4043
|
};
|
|
3936
4044
|
}
|
|
3937
4045
|
try {
|
|
3938
|
-
const
|
|
3939
|
-
console.log(JSON.stringify(await
|
|
4046
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
4047
|
+
console.log(JSON.stringify(await client3.templates.fromStarter(alias)));
|
|
3940
4048
|
return { exitCode: 0 };
|
|
3941
4049
|
} catch (error) {
|
|
3942
4050
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -3949,8 +4057,8 @@ async function runListStartersCommand(args, env = process.env) {
|
|
|
3949
4057
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3950
4058
|
}
|
|
3951
4059
|
try {
|
|
3952
|
-
const
|
|
3953
|
-
console.log(JSON.stringify(await
|
|
4060
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
4061
|
+
console.log(JSON.stringify(await client3.templates.listStarters()));
|
|
3954
4062
|
return { exitCode: 0 };
|
|
3955
4063
|
} catch (error) {
|
|
3956
4064
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -3976,13 +4084,13 @@ async function runVersionsCommand(args, env = process.env) {
|
|
|
3976
4084
|
if (!apiKey) {
|
|
3977
4085
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3978
4086
|
}
|
|
3979
|
-
const idOrAlias =
|
|
4087
|
+
const idOrAlias = readFlag21(args, "--id") || readFlag21(args, "--alias") || readFirstPositional14(args);
|
|
3980
4088
|
if (!idOrAlias) {
|
|
3981
4089
|
return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
|
|
3982
4090
|
}
|
|
3983
4091
|
try {
|
|
3984
|
-
const
|
|
3985
|
-
console.log(JSON.stringify(await
|
|
4092
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
4093
|
+
console.log(JSON.stringify(await client3.templates.listVersions(idOrAlias)));
|
|
3986
4094
|
return { exitCode: 0 };
|
|
3987
4095
|
} catch (error) {
|
|
3988
4096
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -3994,8 +4102,8 @@ async function runRestoreCommand(args, env = process.env) {
|
|
|
3994
4102
|
if (!apiKey) {
|
|
3995
4103
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
3996
4104
|
}
|
|
3997
|
-
const idOrAlias =
|
|
3998
|
-
const versionRaw =
|
|
4105
|
+
const idOrAlias = readFlag21(args, "--id") || readFlag21(args, "--alias") || readFirstPositional14(args);
|
|
4106
|
+
const versionRaw = readFlag21(args, "--version");
|
|
3999
4107
|
const version2 = versionRaw ? Number.parseInt(versionRaw, 10) : NaN;
|
|
4000
4108
|
if (!idOrAlias || !Number.isFinite(version2) || version2 < 1) {
|
|
4001
4109
|
return {
|
|
@@ -4004,8 +4112,8 @@ async function runRestoreCommand(args, env = process.env) {
|
|
|
4004
4112
|
};
|
|
4005
4113
|
}
|
|
4006
4114
|
try {
|
|
4007
|
-
const
|
|
4008
|
-
console.log(JSON.stringify(await
|
|
4115
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
4116
|
+
console.log(JSON.stringify(await client3.templates.restoreVersion(idOrAlias, version2)));
|
|
4009
4117
|
return { exitCode: 0 };
|
|
4010
4118
|
} catch (error) {
|
|
4011
4119
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
@@ -4017,10 +4125,10 @@ async function runTestSendCommand(args, env = process.env) {
|
|
|
4017
4125
|
if (!apiKey) {
|
|
4018
4126
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
4019
4127
|
}
|
|
4020
|
-
const idOrAlias =
|
|
4021
|
-
const from =
|
|
4022
|
-
const sender =
|
|
4023
|
-
const to =
|
|
4128
|
+
const idOrAlias = readFlag21(args, "--id") || readFlag21(args, "--alias") || readFirstPositional14(args);
|
|
4129
|
+
const from = readFlag21(args, "--from");
|
|
4130
|
+
const sender = readFlag21(args, "--sender");
|
|
4131
|
+
const to = readFlag21(args, "--to");
|
|
4024
4132
|
if (!idOrAlias || !to) {
|
|
4025
4133
|
return {
|
|
4026
4134
|
exitCode: 1,
|
|
@@ -4028,10 +4136,10 @@ async function runTestSendCommand(args, env = process.env) {
|
|
|
4028
4136
|
};
|
|
4029
4137
|
}
|
|
4030
4138
|
try {
|
|
4031
|
-
const
|
|
4139
|
+
const client3 = await createTemplatesClient(apiKey, options.baseUrl);
|
|
4032
4140
|
console.log(
|
|
4033
4141
|
JSON.stringify(
|
|
4034
|
-
await
|
|
4142
|
+
await client3.templates.testSend(idOrAlias, { to, ...from ? { from } : {}, ...sender ? { sender } : {} })
|
|
4035
4143
|
)
|
|
4036
4144
|
);
|
|
4037
4145
|
return { exitCode: 0 };
|
|
@@ -4041,15 +4149,15 @@ async function runTestSendCommand(args, env = process.env) {
|
|
|
4041
4149
|
}
|
|
4042
4150
|
|
|
4043
4151
|
// src/commands/integrations/shared.ts
|
|
4044
|
-
function
|
|
4152
|
+
function readFlag22(args, flag) {
|
|
4045
4153
|
const index = args.indexOf(flag);
|
|
4046
4154
|
if (index === -1) return void 0;
|
|
4047
4155
|
return args[index + 1];
|
|
4048
4156
|
}
|
|
4049
4157
|
function parseIntegrationsCommonArgs(args) {
|
|
4050
4158
|
return {
|
|
4051
|
-
apiKey:
|
|
4052
|
-
baseUrl:
|
|
4159
|
+
apiKey: readFlag22(args, "--api-key"),
|
|
4160
|
+
baseUrl: readFlag22(args, "--base-url")
|
|
4053
4161
|
};
|
|
4054
4162
|
}
|
|
4055
4163
|
function resolveApiKey9(options, env) {
|
|
@@ -4068,8 +4176,8 @@ async function runTwilioStatusCommand(args, env = process.env) {
|
|
|
4068
4176
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
4069
4177
|
}
|
|
4070
4178
|
try {
|
|
4071
|
-
const
|
|
4072
|
-
const result = await
|
|
4179
|
+
const client3 = await createIntegrationsClient(apiKey, options.baseUrl);
|
|
4180
|
+
const result = await client3.integrations.getTwilio();
|
|
4073
4181
|
console.log(JSON.stringify(result));
|
|
4074
4182
|
return { exitCode: 0 };
|
|
4075
4183
|
} catch (error) {
|
|
@@ -4082,10 +4190,10 @@ async function runTwilioConnectCommand(args, env = process.env) {
|
|
|
4082
4190
|
if (!apiKey) {
|
|
4083
4191
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
4084
4192
|
}
|
|
4085
|
-
const accountSid =
|
|
4086
|
-
const authToken =
|
|
4087
|
-
const defaultFrom =
|
|
4088
|
-
const messagingServiceSid =
|
|
4193
|
+
const accountSid = readFlag22(args, "--account-sid") || env.TWILIO_ACCOUNT_SID || env.TWILIO_SID || "";
|
|
4194
|
+
const authToken = readFlag22(args, "--auth-token") || env.TWILIO_AUTH_TOKEN || env.TWILIO_TOKEN || "";
|
|
4195
|
+
const defaultFrom = readFlag22(args, "--from") || readFlag22(args, "--default-from") || env.TWILIO_DEFAULT_FROM || "";
|
|
4196
|
+
const messagingServiceSid = readFlag22(args, "--messaging-service-sid") || readFlag22(args, "--messaging-sid") || env.TWILIO_MESSAGING_SERVICE_SID || "";
|
|
4089
4197
|
if (!accountSid.trim() || !authToken.trim()) {
|
|
4090
4198
|
return {
|
|
4091
4199
|
exitCode: 1,
|
|
@@ -4099,8 +4207,8 @@ async function runTwilioConnectCommand(args, env = process.env) {
|
|
|
4099
4207
|
};
|
|
4100
4208
|
}
|
|
4101
4209
|
try {
|
|
4102
|
-
const
|
|
4103
|
-
const result = await
|
|
4210
|
+
const client3 = await createIntegrationsClient(apiKey, options.baseUrl);
|
|
4211
|
+
const result = await client3.integrations.connectTwilio({
|
|
4104
4212
|
accountSid: accountSid.trim(),
|
|
4105
4213
|
authToken: authToken.trim(),
|
|
4106
4214
|
...defaultFrom.trim() ? { defaultFrom: defaultFrom.trim() } : {},
|
|
@@ -4119,8 +4227,8 @@ async function runTwilioDisconnectCommand(args, env = process.env) {
|
|
|
4119
4227
|
return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
4120
4228
|
}
|
|
4121
4229
|
try {
|
|
4122
|
-
const
|
|
4123
|
-
const result = await
|
|
4230
|
+
const client3 = await createIntegrationsClient(apiKey, options.baseUrl);
|
|
4231
|
+
const result = await client3.integrations.disconnectTwilio();
|
|
4124
4232
|
console.log(JSON.stringify(result));
|
|
4125
4233
|
return { exitCode: 0 };
|
|
4126
4234
|
} catch (error) {
|
|
@@ -4134,8 +4242,8 @@ async function withClient(args, env, run) {
|
|
|
4134
4242
|
const apiKey = resolveApiKey5(options, env);
|
|
4135
4243
|
if (!apiKey) return { exitCode: 1, error: MISSING_KEY };
|
|
4136
4244
|
try {
|
|
4137
|
-
const
|
|
4138
|
-
console.log(JSON.stringify(await run(
|
|
4245
|
+
const client3 = await createTenantsClient(apiKey, options.baseUrl);
|
|
4246
|
+
console.log(JSON.stringify(await run(client3)));
|
|
4139
4247
|
return { exitCode: 0 };
|
|
4140
4248
|
} catch (error) {
|
|
4141
4249
|
return failure(error);
|
|
@@ -4154,7 +4262,7 @@ async function runListCommand8(args, env = process.env) {
|
|
|
4154
4262
|
return withClient(
|
|
4155
4263
|
args,
|
|
4156
4264
|
env,
|
|
4157
|
-
(
|
|
4265
|
+
(client3) => client3.tenants.list({
|
|
4158
4266
|
...limitRaw ? { limit: Number(limitRaw) } : {},
|
|
4159
4267
|
...cursor ? { cursor } : {},
|
|
4160
4268
|
...status ? { status } : {}
|
|
@@ -4168,12 +4276,12 @@ async function runCreateCommand4(args, env = process.env) {
|
|
|
4168
4276
|
}
|
|
4169
4277
|
const settings = parseTenantSettings(args);
|
|
4170
4278
|
if ("error" in settings) return { exitCode: 1, error: settings.error };
|
|
4171
|
-
return withClient(args, env, (
|
|
4279
|
+
return withClient(args, env, (client3) => client3.tenants.create({ external_id: externalId, ...settings.value }));
|
|
4172
4280
|
}
|
|
4173
4281
|
async function runGetCommand7(args, env = process.env) {
|
|
4174
4282
|
const tenant = tenantRef(args);
|
|
4175
4283
|
if (!tenant) return missingTenant("groundmail tenants get <tenant>");
|
|
4176
|
-
return withClient(args, env, (
|
|
4284
|
+
return withClient(args, env, (client3) => client3.tenants.get(tenant));
|
|
4177
4285
|
}
|
|
4178
4286
|
async function runUpdateCommand5(args, env = process.env) {
|
|
4179
4287
|
const tenant = tenantRef(args);
|
|
@@ -4186,18 +4294,18 @@ async function runUpdateCommand5(args, env = process.env) {
|
|
|
4186
4294
|
error: "Nothing to update. Pass --name, --default-from-domain, --stream-policy, --daily-limit or --metadata (or use tenants pause / resume)."
|
|
4187
4295
|
};
|
|
4188
4296
|
}
|
|
4189
|
-
return withClient(args, env, (
|
|
4297
|
+
return withClient(args, env, (client3) => client3.tenants.update(tenant, settings.value));
|
|
4190
4298
|
}
|
|
4191
4299
|
async function runPauseCommand2(args, env = process.env) {
|
|
4192
4300
|
const tenant = tenantRef(args);
|
|
4193
4301
|
if (!tenant) return missingTenant("groundmail tenants pause <tenant> [--reason \u2026]");
|
|
4194
4302
|
const reason = readFlag12(args, "--reason");
|
|
4195
|
-
return withClient(args, env, (
|
|
4303
|
+
return withClient(args, env, (client3) => client3.tenants.pause(tenant, reason));
|
|
4196
4304
|
}
|
|
4197
4305
|
async function runResumeCommand(args, env = process.env) {
|
|
4198
4306
|
const tenant = tenantRef(args);
|
|
4199
4307
|
if (!tenant) return missingTenant("groundmail tenants resume <tenant>");
|
|
4200
|
-
return withClient(args, env, (
|
|
4308
|
+
return withClient(args, env, (client3) => client3.tenants.resume(tenant));
|
|
4201
4309
|
}
|
|
4202
4310
|
async function runDeleteCommand5(args, env = process.env) {
|
|
4203
4311
|
const tenant = tenantRef(args);
|
|
@@ -4208,7 +4316,7 @@ async function runDeleteCommand5(args, env = process.env) {
|
|
|
4208
4316
|
error: `This deletes tenant ${tenant} and its suppression list; its domains go back to the account and keys limited to it stop working. Run again with --yes to confirm.`
|
|
4209
4317
|
};
|
|
4210
4318
|
}
|
|
4211
|
-
return withClient(args, env, (
|
|
4319
|
+
return withClient(args, env, (client3) => client3.tenants.delete(tenant));
|
|
4212
4320
|
}
|
|
4213
4321
|
async function runStatsCommand(args, env = process.env) {
|
|
4214
4322
|
const tenant = tenantRef(args);
|
|
@@ -4218,7 +4326,7 @@ async function runStatsCommand(args, env = process.env) {
|
|
|
4218
4326
|
if (days !== void 0 && (!Number.isInteger(days) || days < 1 || days > 90)) {
|
|
4219
4327
|
return { exitCode: 1, error: "--days must be a whole number from 1 to 90" };
|
|
4220
4328
|
}
|
|
4221
|
-
return withClient(args, env, (
|
|
4329
|
+
return withClient(args, env, (client3) => client3.tenants.stats(tenant, days !== void 0 ? { days } : {}));
|
|
4222
4330
|
}
|
|
4223
4331
|
async function runDomainsCommand(args, env = process.env) {
|
|
4224
4332
|
const [action, ...rest] = args;
|
|
@@ -4227,19 +4335,19 @@ async function runDomainsCommand(args, env = process.env) {
|
|
|
4227
4335
|
const domain = readFlag12(rest, "--domain") || pos.shift();
|
|
4228
4336
|
if (action === "list") {
|
|
4229
4337
|
if (!tenant) return missingTenant("groundmail tenants domains list <tenant>");
|
|
4230
|
-
return withClient(rest, env, (
|
|
4338
|
+
return withClient(rest, env, (client3) => client3.tenants.domains.list(tenant));
|
|
4231
4339
|
}
|
|
4232
4340
|
if (action === "add" || action === "assign") {
|
|
4233
4341
|
if (!tenant || !domain) {
|
|
4234
4342
|
return { exitCode: 1, error: "Usage: groundmail tenants domains add <tenant> <domain>" };
|
|
4235
4343
|
}
|
|
4236
|
-
return withClient(rest, env, (
|
|
4344
|
+
return withClient(rest, env, (client3) => client3.tenants.domains.assign(tenant, domain));
|
|
4237
4345
|
}
|
|
4238
4346
|
if (action === "remove" || action === "unassign" || action === "delete") {
|
|
4239
4347
|
if (!tenant || !domain) {
|
|
4240
4348
|
return { exitCode: 1, error: "Usage: groundmail tenants domains remove <tenant> <domain>" };
|
|
4241
4349
|
}
|
|
4242
|
-
return withClient(rest, env, (
|
|
4350
|
+
return withClient(rest, env, (client3) => client3.tenants.domains.unassign(tenant, domain));
|
|
4243
4351
|
}
|
|
4244
4352
|
return {
|
|
4245
4353
|
exitCode: 1,
|
|
@@ -4249,7 +4357,7 @@ async function runDomainsCommand(args, env = process.env) {
|
|
|
4249
4357
|
|
|
4250
4358
|
// src/commands/senders/shared.ts
|
|
4251
4359
|
var SENDER_VALUE_FLAGS = ["--api-key", "--base-url", "--id", "--name", "--address", "--reply-to", "--handle"];
|
|
4252
|
-
function
|
|
4360
|
+
function readFlag23(args, flag) {
|
|
4253
4361
|
const index = args.indexOf(flag);
|
|
4254
4362
|
if (index === -1) return void 0;
|
|
4255
4363
|
return args[index + 1];
|
|
@@ -4257,7 +4365,7 @@ function readFlag22(args, flag) {
|
|
|
4257
4365
|
function hasFlag2(args, flag) {
|
|
4258
4366
|
return args.includes(flag);
|
|
4259
4367
|
}
|
|
4260
|
-
function
|
|
4368
|
+
function positionals3(args, valueFlags = SENDER_VALUE_FLAGS) {
|
|
4261
4369
|
const out = [];
|
|
4262
4370
|
for (let i = 0; i < args.length; i += 1) {
|
|
4263
4371
|
const arg = args[i];
|
|
@@ -4271,8 +4379,8 @@ function positionals2(args, valueFlags = SENDER_VALUE_FLAGS) {
|
|
|
4271
4379
|
}
|
|
4272
4380
|
function parseSendersCommonArgs(args) {
|
|
4273
4381
|
return {
|
|
4274
|
-
apiKey:
|
|
4275
|
-
baseUrl:
|
|
4382
|
+
apiKey: readFlag23(args, "--api-key"),
|
|
4383
|
+
baseUrl: readFlag23(args, "--base-url")
|
|
4276
4384
|
};
|
|
4277
4385
|
}
|
|
4278
4386
|
function resolveApiKey10(options, env) {
|
|
@@ -4290,13 +4398,13 @@ function failure2(error) {
|
|
|
4290
4398
|
${hint}` : message };
|
|
4291
4399
|
}
|
|
4292
4400
|
function senderRef(args) {
|
|
4293
|
-
return
|
|
4401
|
+
return readFlag23(args, "--id") || positionals3(args)[0];
|
|
4294
4402
|
}
|
|
4295
4403
|
function parseSenderFields(args) {
|
|
4296
|
-
const name =
|
|
4297
|
-
const address =
|
|
4298
|
-
const replyTo =
|
|
4299
|
-
const handle =
|
|
4404
|
+
const name = readFlag23(args, "--name");
|
|
4405
|
+
const address = readFlag23(args, "--address");
|
|
4406
|
+
const replyTo = readFlag23(args, "--reply-to");
|
|
4407
|
+
const handle = readFlag23(args, "--handle");
|
|
4300
4408
|
const makeDefault = hasFlag2(args, "--default");
|
|
4301
4409
|
const notDefault = hasFlag2(args, "--no-default");
|
|
4302
4410
|
if (makeDefault && notDefault) return { error: "Pass --default or --no-default, not both" };
|
|
@@ -4317,8 +4425,8 @@ async function withClient2(args, env, run) {
|
|
|
4317
4425
|
const apiKey = resolveApiKey10(options, env);
|
|
4318
4426
|
if (!apiKey) return { exitCode: 1, error: MISSING_KEY2 };
|
|
4319
4427
|
try {
|
|
4320
|
-
const
|
|
4321
|
-
console.log(JSON.stringify(await run(
|
|
4428
|
+
const client3 = await createSendersClient(apiKey, options.baseUrl);
|
|
4429
|
+
console.log(JSON.stringify(await run(client3)));
|
|
4322
4430
|
return { exitCode: 0 };
|
|
4323
4431
|
} catch (error) {
|
|
4324
4432
|
return failure2(error);
|
|
@@ -4328,7 +4436,7 @@ function missingSender(usage) {
|
|
|
4328
4436
|
return { exitCode: 1, error: `Missing sender (id or handle). Usage: ${usage}` };
|
|
4329
4437
|
}
|
|
4330
4438
|
async function runListCommand9(args, env = process.env) {
|
|
4331
|
-
return withClient2(args, env, (
|
|
4439
|
+
return withClient2(args, env, (client3) => client3.senders.list());
|
|
4332
4440
|
}
|
|
4333
4441
|
async function runCreateCommand5(args, env = process.env) {
|
|
4334
4442
|
const fields = parseSenderFields(args);
|
|
@@ -4340,12 +4448,12 @@ async function runCreateCommand5(args, env = process.env) {
|
|
|
4340
4448
|
error: 'Required: --name and --address. Usage: groundmail senders create --name "Acme Billing" --address billing@mail.acme.com [--reply-to \u2026] [--handle billing] [--default]'
|
|
4341
4449
|
};
|
|
4342
4450
|
}
|
|
4343
|
-
return withClient2(args, env, (
|
|
4451
|
+
return withClient2(args, env, (client3) => client3.senders.create({ ...fields.value, name, address }));
|
|
4344
4452
|
}
|
|
4345
4453
|
async function runGetCommand8(args, env = process.env) {
|
|
4346
4454
|
const sender = senderRef(args);
|
|
4347
4455
|
if (!sender) return missingSender("groundmail senders get <id|handle>");
|
|
4348
|
-
return withClient2(args, env, (
|
|
4456
|
+
return withClient2(args, env, (client3) => client3.senders.get(sender));
|
|
4349
4457
|
}
|
|
4350
4458
|
async function runUpdateCommand6(args, env = process.env) {
|
|
4351
4459
|
const sender = senderRef(args);
|
|
@@ -4358,7 +4466,7 @@ async function runUpdateCommand6(args, env = process.env) {
|
|
|
4358
4466
|
error: "Nothing to update. Pass --name, --address, --reply-to, --handle, --default or --no-default."
|
|
4359
4467
|
};
|
|
4360
4468
|
}
|
|
4361
|
-
return withClient2(args, env, (
|
|
4469
|
+
return withClient2(args, env, (client3) => client3.senders.update(sender, fields.value));
|
|
4362
4470
|
}
|
|
4363
4471
|
async function runDeleteCommand6(args, env = process.env) {
|
|
4364
4472
|
const sender = senderRef(args);
|
|
@@ -4369,7 +4477,7 @@ async function runDeleteCommand6(args, env = process.env) {
|
|
|
4369
4477
|
error: `This deletes sender ${sender}. Sends that name it will fail. Run again with --yes to confirm.`
|
|
4370
4478
|
};
|
|
4371
4479
|
}
|
|
4372
|
-
return withClient2(args, env, (
|
|
4480
|
+
return withClient2(args, env, (client3) => client3.senders.remove(sender));
|
|
4373
4481
|
}
|
|
4374
4482
|
|
|
4375
4483
|
// src/commands/brand/commands.ts
|
|
@@ -4393,26 +4501,26 @@ async function withClient3(args, env, run) {
|
|
|
4393
4501
|
const apiKey = resolveApiKey10(options, env);
|
|
4394
4502
|
if (!apiKey) return { exitCode: 1, error: MISSING_KEY2 };
|
|
4395
4503
|
try {
|
|
4396
|
-
const
|
|
4397
|
-
console.log(JSON.stringify(await run(
|
|
4504
|
+
const client3 = await createBrandClient(apiKey, options.baseUrl);
|
|
4505
|
+
console.log(JSON.stringify(await run(client3)));
|
|
4398
4506
|
return { exitCode: 0 };
|
|
4399
4507
|
} catch (error) {
|
|
4400
4508
|
return failure2(error);
|
|
4401
4509
|
}
|
|
4402
4510
|
}
|
|
4403
4511
|
async function runGetCommand9(args, env = process.env) {
|
|
4404
|
-
return withClient3(args, env, (
|
|
4512
|
+
return withClient3(args, env, (client3) => client3.brand.get());
|
|
4405
4513
|
}
|
|
4406
4514
|
function clearable(value) {
|
|
4407
4515
|
if (value === void 0) return void 0;
|
|
4408
4516
|
return value === "none" || value === "" ? null : value;
|
|
4409
4517
|
}
|
|
4410
4518
|
async function runSetCommand(args, env = process.env) {
|
|
4411
|
-
const logoUrl = clearable(
|
|
4412
|
-
const logoAlign =
|
|
4413
|
-
const logoWidth =
|
|
4414
|
-
const color =
|
|
4415
|
-
const settingsFile =
|
|
4519
|
+
const logoUrl = clearable(readFlag23(args, "--logo-url"));
|
|
4520
|
+
const logoAlign = readFlag23(args, "--logo-align");
|
|
4521
|
+
const logoWidth = readFlag23(args, "--logo-width");
|
|
4522
|
+
const color = readFlag23(args, "--color");
|
|
4523
|
+
const settingsFile = readFlag23(args, "--settings-file");
|
|
4416
4524
|
if (logoAlign !== void 0 && logoAlign !== "left" && logoAlign !== "center") {
|
|
4417
4525
|
return { exitCode: 1, error: "--logo-align must be left or center" };
|
|
4418
4526
|
}
|
|
@@ -4433,9 +4541,9 @@ async function runSetCommand(args, env = process.env) {
|
|
|
4433
4541
|
if (logoUrl !== void 0) {
|
|
4434
4542
|
params.logo = logoUrl === null ? null : { url: logoUrl, align: logoAlign ?? "left", ...logoWidth ? { width: Number(logoWidth) } : {} };
|
|
4435
4543
|
}
|
|
4436
|
-
const company = clearable(
|
|
4437
|
-
const address = clearable(
|
|
4438
|
-
const website = clearable(
|
|
4544
|
+
const company = clearable(readFlag23(args, "--company"));
|
|
4545
|
+
const address = clearable(readFlag23(args, "--address"));
|
|
4546
|
+
const website = clearable(readFlag23(args, "--website"));
|
|
4439
4547
|
if (company !== void 0) params.company_name = company;
|
|
4440
4548
|
if (address !== void 0) params.address = address;
|
|
4441
4549
|
if (website !== void 0) params.website = website;
|
|
@@ -4446,9 +4554,9 @@ async function runSetCommand(args, env = process.env) {
|
|
|
4446
4554
|
error: "Nothing to set. Usage: groundmail brand set [--logo-url \u2026] [--color #2f6feb] [--company \u2026] [--address \u2026] [--website \u2026] [--settings-file brand.json]"
|
|
4447
4555
|
};
|
|
4448
4556
|
}
|
|
4449
|
-
return withClient3(args, env, async (
|
|
4557
|
+
return withClient3(args, env, async (client3) => {
|
|
4450
4558
|
if (color) {
|
|
4451
|
-
const base = params.settings ?? (await
|
|
4559
|
+
const base = params.settings ?? (await client3.brand.get()).brand.settings ?? {};
|
|
4452
4560
|
const theme = base.theme ?? {};
|
|
4453
4561
|
params.accent_color = color;
|
|
4454
4562
|
params.settings = {
|
|
@@ -4457,25 +4565,25 @@ async function runSetCommand(args, env = process.env) {
|
|
|
4457
4565
|
theme: { ...theme, buttonBackground: color, buttonTextColor: readableText(color) }
|
|
4458
4566
|
};
|
|
4459
4567
|
}
|
|
4460
|
-
return
|
|
4568
|
+
return client3.brand.update(params);
|
|
4461
4569
|
});
|
|
4462
4570
|
}
|
|
4463
4571
|
|
|
4464
4572
|
// src/commands/batches/commands.ts
|
|
4465
|
-
var
|
|
4573
|
+
var VALUE_FLAGS4 = ["--api-key", "--base-url", "--id"];
|
|
4466
4574
|
var MISSING_KEY3 = "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key.";
|
|
4467
|
-
function
|
|
4575
|
+
function readFlag24(args, flag) {
|
|
4468
4576
|
const index = args.indexOf(flag);
|
|
4469
4577
|
if (index === -1) return void 0;
|
|
4470
4578
|
return args[index + 1];
|
|
4471
4579
|
}
|
|
4472
4580
|
function batchRef(args) {
|
|
4473
|
-
const id =
|
|
4581
|
+
const id = readFlag24(args, "--id");
|
|
4474
4582
|
if (id) return id;
|
|
4475
4583
|
for (let i = 0; i < args.length; i += 1) {
|
|
4476
4584
|
const arg = args[i];
|
|
4477
4585
|
if (arg.startsWith("--")) {
|
|
4478
|
-
if (
|
|
4586
|
+
if (VALUE_FLAGS4.includes(arg)) i += 1;
|
|
4479
4587
|
continue;
|
|
4480
4588
|
}
|
|
4481
4589
|
return arg;
|
|
@@ -4489,21 +4597,21 @@ async function createBatchesClient(apiKey, baseUrl) {
|
|
|
4489
4597
|
async function withBatch(args, env, usage, run) {
|
|
4490
4598
|
const batchId = batchRef(args);
|
|
4491
4599
|
if (!batchId) return { exitCode: 1, error: `Missing batch id (batch_\u2026). Usage: ${usage}` };
|
|
4492
|
-
const apiKey =
|
|
4600
|
+
const apiKey = readFlag24(args, "--api-key") || env.GROUNDMAIL_API_KEY;
|
|
4493
4601
|
if (!apiKey) return { exitCode: 1, error: MISSING_KEY3 };
|
|
4494
4602
|
try {
|
|
4495
|
-
const
|
|
4496
|
-
console.log(JSON.stringify(await run(
|
|
4603
|
+
const client3 = await createBatchesClient(apiKey, readFlag24(args, "--base-url"));
|
|
4604
|
+
console.log(JSON.stringify(await run(client3, batchId)));
|
|
4497
4605
|
return { exitCode: 0 };
|
|
4498
4606
|
} catch (error) {
|
|
4499
4607
|
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
4500
4608
|
}
|
|
4501
4609
|
}
|
|
4502
4610
|
async function runGetCommand10(args, env = process.env) {
|
|
4503
|
-
return withBatch(args, env, "groundmail batches get <batch_id>", (
|
|
4611
|
+
return withBatch(args, env, "groundmail batches get <batch_id>", (client3, id) => client3.batches.get(id));
|
|
4504
4612
|
}
|
|
4505
4613
|
async function runCancelCommand2(args, env = process.env) {
|
|
4506
|
-
return withBatch(args, env, "groundmail batches cancel <batch_id>", (
|
|
4614
|
+
return withBatch(args, env, "groundmail batches cancel <batch_id>", (client3, id) => client3.batches.cancel(id));
|
|
4507
4615
|
}
|
|
4508
4616
|
|
|
4509
4617
|
// src/commands/auth.ts
|
|
@@ -4669,7 +4777,7 @@ function sesParams(args, env) {
|
|
|
4669
4777
|
"Use a key with the read-only import policy (https://docs.groundmail.dev/migrations#amazon-ses-iam-policy). It is used for this import only and never stored."
|
|
4670
4778
|
].join("\n");
|
|
4671
4779
|
}
|
|
4672
|
-
const region =
|
|
4780
|
+
const region = readFlag25(args, "--region") || env.AWS_REGION || env.AWS_DEFAULT_REGION;
|
|
4673
4781
|
if (!region) return "Set the SES region with --region (for example --region us-east-1) or AWS_REGION. One region per import.";
|
|
4674
4782
|
if (!AWS_REGION.test(region)) return `--region must be an AWS region such as us-east-1, not ${region}`;
|
|
4675
4783
|
return {
|
|
@@ -4680,8 +4788,8 @@ function sesParams(args, env) {
|
|
|
4680
4788
|
aws_region: region
|
|
4681
4789
|
};
|
|
4682
4790
|
}
|
|
4683
|
-
var
|
|
4684
|
-
function
|
|
4791
|
+
var VALUE_FLAGS5 = /* @__PURE__ */ new Set(["--api-key", "--base-url"]);
|
|
4792
|
+
function readFlag25(args, flag) {
|
|
4685
4793
|
const index = args.indexOf(flag);
|
|
4686
4794
|
if (index === -1) return void 0;
|
|
4687
4795
|
return args[index + 1];
|
|
@@ -4755,15 +4863,15 @@ function formatMigrationSummary(m) {
|
|
|
4755
4863
|
if (!m.dry_run && !m.has_more) lines.push("", `Report: groundmail migrate report ${m.id} --csv > import-report.csv`);
|
|
4756
4864
|
return lines.join("\n");
|
|
4757
4865
|
}
|
|
4758
|
-
async function
|
|
4759
|
-
const apiKey =
|
|
4866
|
+
async function client2(args, env) {
|
|
4867
|
+
const apiKey = readFlag25(args, "--api-key") || env.GROUNDMAIL_API_KEY;
|
|
4760
4868
|
if (!apiKey) return null;
|
|
4761
4869
|
const { Groundmail } = await import("groundmail");
|
|
4762
|
-
const baseUrl =
|
|
4870
|
+
const baseUrl = readFlag25(args, "--base-url");
|
|
4763
4871
|
return new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
4764
4872
|
}
|
|
4765
4873
|
async function runStoredCommand(sub, args, env) {
|
|
4766
|
-
const gm = await
|
|
4874
|
+
const gm = await client2(args, env);
|
|
4767
4875
|
if (!gm) return { exitCode: 1, error: "Not signed in. Run `groundmail login`, or set GROUNDMAIL_API_KEY." };
|
|
4768
4876
|
try {
|
|
4769
4877
|
if (sub === "list") {
|
|
@@ -4773,7 +4881,7 @@ async function runStoredCommand(sub, args, env) {
|
|
|
4773
4881
|
if (!data.length) console.error("No imports yet. Previews are not stored.");
|
|
4774
4882
|
return { exitCode: 0 };
|
|
4775
4883
|
}
|
|
4776
|
-
const id = args.find((arg, i) => !arg.startsWith("--") && !
|
|
4884
|
+
const id = args.find((arg, i) => !arg.startsWith("--") && !VALUE_FLAGS5.has(args[i - 1] ?? ""));
|
|
4777
4885
|
if (!id) return { exitCode: 1, error: "Usage: groundmail migrate report <import id> [--csv]" };
|
|
4778
4886
|
if (args.includes("--csv")) {
|
|
4779
4887
|
process.stdout.write(await gm.migrations.reportCsv(id));
|
|
@@ -4796,7 +4904,7 @@ async function runMigrateCommand(provider, args, env = process.env) {
|
|
|
4796
4904
|
};
|
|
4797
4905
|
}
|
|
4798
4906
|
const id = provider;
|
|
4799
|
-
const apiKey =
|
|
4907
|
+
const apiKey = readFlag25(args, "--api-key") || env.GROUNDMAIL_API_KEY;
|
|
4800
4908
|
if (!apiKey) {
|
|
4801
4909
|
return { exitCode: 1, error: "Not signed in. Run `groundmail login`, or set GROUNDMAIL_API_KEY." };
|
|
4802
4910
|
}
|
|
@@ -4806,7 +4914,7 @@ async function runMigrateCommand(provider, args, env = process.env) {
|
|
|
4806
4914
|
if (typeof ses === "string") return { exitCode: 1, error: ses };
|
|
4807
4915
|
params = ses;
|
|
4808
4916
|
} else {
|
|
4809
|
-
const providerKey =
|
|
4917
|
+
const providerKey = readFlag25(args, "--key") || env[KEY_ENV[id]];
|
|
4810
4918
|
if (!providerKey) {
|
|
4811
4919
|
const resend = id === "resend" ? " Use a key with Full access (Resend \u2192 API Keys); a Sending access key cannot read your account." : "";
|
|
4812
4920
|
return {
|
|
@@ -4816,15 +4924,15 @@ async function runMigrateCommand(provider, args, env = process.env) {
|
|
|
4816
4924
|
}
|
|
4817
4925
|
params = { provider: id, api_key: providerKey };
|
|
4818
4926
|
if (id === "postmark") {
|
|
4819
|
-
const accountToken =
|
|
4927
|
+
const accountToken = readFlag25(args, "--account-token") || env.POSTMARK_ACCOUNT_TOKEN;
|
|
4820
4928
|
if (accountToken) params.account_api_key = accountToken;
|
|
4821
4929
|
} else if (id === "sendgrid" || id === "mailgun") {
|
|
4822
|
-
const region =
|
|
4930
|
+
const region = readFlag25(args, "--region");
|
|
4823
4931
|
if (region === "us" || region === "eu") params.region = region;
|
|
4824
4932
|
else if (region) return { exitCode: 1, error: "--region must be us or eu" };
|
|
4825
4933
|
}
|
|
4826
4934
|
}
|
|
4827
|
-
const only =
|
|
4935
|
+
const only = readFlag25(args, "--only");
|
|
4828
4936
|
if (only) {
|
|
4829
4937
|
const list = only.split(",").map((s) => s.trim()).filter(Boolean);
|
|
4830
4938
|
const bad = list.filter((r) => !RESOURCES.includes(r));
|
|
@@ -4836,10 +4944,10 @@ async function runMigrateCommand(provider, args, env = process.env) {
|
|
|
4836
4944
|
if (args.includes("--dry-run")) params.dry_run = true;
|
|
4837
4945
|
try {
|
|
4838
4946
|
const { Groundmail } = await import("groundmail");
|
|
4839
|
-
const baseUrl =
|
|
4840
|
-
const
|
|
4947
|
+
const baseUrl = readFlag25(args, "--base-url");
|
|
4948
|
+
const client3 = new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
|
|
4841
4949
|
console.error(`${params.dry_run ? "Previewing" : "Importing"} from ${LABELS[id]}${params.provider === "ses" ? ` (${params.aws_region})` : ""} (Beta)\u2026`);
|
|
4842
|
-
const report = await
|
|
4950
|
+
const report = await client3.migrations.run(params, {
|
|
4843
4951
|
onProgress: (m) => {
|
|
4844
4952
|
if (m.has_more) {
|
|
4845
4953
|
const s = m.suppressions?.totals;
|
|
@@ -4875,8 +4983,8 @@ async function withClient4(args, env, run) {
|
|
|
4875
4983
|
const apiKey = resolveApiKey7(options, env);
|
|
4876
4984
|
if (!apiKey) return { exitCode: 1, error: MISSING_KEY4 };
|
|
4877
4985
|
try {
|
|
4878
|
-
const
|
|
4879
|
-
const output = await run(
|
|
4986
|
+
const client3 = await createSuppressionsClient(apiKey, options.baseUrl);
|
|
4987
|
+
const output = await run(client3);
|
|
4880
4988
|
if (output !== void 0) console.log(JSON.stringify(output));
|
|
4881
4989
|
return { exitCode: 0 };
|
|
4882
4990
|
} catch (error) {
|
|
@@ -4885,7 +4993,7 @@ async function withClient4(args, env, run) {
|
|
|
4885
4993
|
}
|
|
4886
4994
|
async function runSites(action, rest, env) {
|
|
4887
4995
|
if (!action || action === "list" || action.startsWith("--")) {
|
|
4888
|
-
return withClient4(action ? [action, ...rest] : rest, env, (
|
|
4996
|
+
return withClient4(action ? [action, ...rest] : rest, env, (client3) => client3.burrowguard.sites.list());
|
|
4889
4997
|
}
|
|
4890
4998
|
if (action === "create") {
|
|
4891
4999
|
const name = readFlag19(rest, "--name");
|
|
@@ -4896,7 +5004,7 @@ ${USAGE}` };
|
|
|
4896
5004
|
return withClient4(
|
|
4897
5005
|
rest,
|
|
4898
5006
|
env,
|
|
4899
|
-
(
|
|
5007
|
+
(client3) => client3.burrowguard.sites.create({
|
|
4900
5008
|
name,
|
|
4901
5009
|
...hostnames.length > 0 ? { allowed_hostnames: hostnames } : {},
|
|
4902
5010
|
...emailOnly ? { email_checks_only: true } : {},
|
|
@@ -4913,7 +5021,7 @@ ${USAGE}` };
|
|
|
4913
5021
|
const on = rest.includes("--watch-only");
|
|
4914
5022
|
if (on === rest.includes("--no-watch-only")) return { exitCode: 1, error: `Pass --watch-only or --no-watch-only.
|
|
4915
5023
|
${USAGE}` };
|
|
4916
|
-
return withClient4(rest, env, (
|
|
5024
|
+
return withClient4(rest, env, (client3) => client3.burrowguard.sites.update(id, { watch_only: on }));
|
|
4917
5025
|
}
|
|
4918
5026
|
if (action === "delete" || action === "roll-secret") {
|
|
4919
5027
|
const id = rest[0] && !rest[0].startsWith("--") ? rest[0] : void 0;
|
|
@@ -4923,12 +5031,12 @@ ${USAGE}` };
|
|
|
4923
5031
|
const effect = action === "delete" ? "deletes the site and its checks" : "stops the current secret working at once";
|
|
4924
5032
|
return { exitCode: 1, error: `This ${effect}. Pass --yes to go ahead.` };
|
|
4925
5033
|
}
|
|
4926
|
-
return withClient4(rest, env, async (
|
|
5034
|
+
return withClient4(rest, env, async (client3) => {
|
|
4927
5035
|
if (action === "delete") {
|
|
4928
|
-
await
|
|
5036
|
+
await client3.burrowguard.sites.remove(id);
|
|
4929
5037
|
return { deleted: true, id };
|
|
4930
5038
|
}
|
|
4931
|
-
return
|
|
5039
|
+
return client3.burrowguard.sites.rollSecret(id);
|
|
4932
5040
|
});
|
|
4933
5041
|
}
|
|
4934
5042
|
return { exitCode: 1, error: `Unknown command: burrowguard sites ${action}
|
|
@@ -4947,7 +5055,7 @@ function runChecks(args, env) {
|
|
|
4947
5055
|
return withClient4(
|
|
4948
5056
|
args,
|
|
4949
5057
|
env,
|
|
4950
|
-
(
|
|
5058
|
+
(client3) => client3.burrowguard.checks.list({
|
|
4951
5059
|
...readFlag19(args, "--site") ? { site: readFlag19(args, "--site") } : {},
|
|
4952
5060
|
...result ? { result } : {},
|
|
4953
5061
|
...range ? { range } : {},
|
|
@@ -4975,8 +5083,8 @@ async function runValidateCommand(args, env = process.env) {
|
|
|
4975
5083
|
return { exitCode: 1, error: "Missing email. Usage: groundmail validate user@example.com" };
|
|
4976
5084
|
}
|
|
4977
5085
|
try {
|
|
4978
|
-
const
|
|
4979
|
-
const result = await
|
|
5086
|
+
const client3 = await createSuppressionsClient(apiKey, options.baseUrl);
|
|
5087
|
+
const result = await client3.validate(email);
|
|
4980
5088
|
console.log(JSON.stringify(result));
|
|
4981
5089
|
return { exitCode: result.verdict === "invalid" ? 2 : 0 };
|
|
4982
5090
|
} catch (error) {
|
|
@@ -4986,17 +5094,17 @@ async function runValidateCommand(args, env = process.env) {
|
|
|
4986
5094
|
|
|
4987
5095
|
// src/commands/dmarc/dmarc.ts
|
|
4988
5096
|
var DMARC_APPLY_PROVIDERS = ["cloudflare", "vercel", "godaddy", "netlify", "digitalocean", "dnsimple"];
|
|
4989
|
-
function
|
|
5097
|
+
function readFlag26(args, flag) {
|
|
4990
5098
|
const index = args.indexOf(flag);
|
|
4991
5099
|
if (index === -1) return void 0;
|
|
4992
5100
|
return args[index + 1];
|
|
4993
5101
|
}
|
|
4994
|
-
var
|
|
5102
|
+
var VALUE_FLAGS6 = ["--api-key", "--base-url", "--domain", "--apply"];
|
|
4995
5103
|
function readFirstPositional15(args) {
|
|
4996
5104
|
for (let i = 0; i < args.length; i += 1) {
|
|
4997
5105
|
const arg = args[i];
|
|
4998
5106
|
if (arg.startsWith("--")) {
|
|
4999
|
-
if (
|
|
5107
|
+
if (VALUE_FLAGS6.includes(arg)) i += 1;
|
|
5000
5108
|
continue;
|
|
5001
5109
|
}
|
|
5002
5110
|
return arg;
|
|
@@ -5043,27 +5151,27 @@ function formatDmarcStatus(dmarc) {
|
|
|
5043
5151
|
return lines.join("\n");
|
|
5044
5152
|
}
|
|
5045
5153
|
async function runDmarcCommand(subcommand, args, env = process.env) {
|
|
5046
|
-
const apiKey =
|
|
5154
|
+
const apiKey = readFlag26(args, "--api-key") || env.GROUNDMAIL_API_KEY;
|
|
5047
5155
|
if (!apiKey) return { exitCode: 1, error: "Missing API key. Run groundmail login, set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
5048
|
-
const domain =
|
|
5156
|
+
const domain = readFlag26(args, "--domain") || readFirstPositional15(args);
|
|
5049
5157
|
if (!subcommand || !["status", "enable", "disable", "digest"].includes(subcommand)) {
|
|
5050
5158
|
return { exitCode: 1, error: "Usage: groundmail dmarc status|enable|disable|digest <domain>" };
|
|
5051
5159
|
}
|
|
5052
5160
|
if (!domain) return { exitCode: 1, error: `Missing domain. Usage: groundmail dmarc ${subcommand} example.com` };
|
|
5053
5161
|
const json = args.includes("--json");
|
|
5054
5162
|
try {
|
|
5055
|
-
const
|
|
5163
|
+
const client3 = await createDmarcClient(apiKey, readFlag26(args, "--base-url"));
|
|
5056
5164
|
if (subcommand === "status") {
|
|
5057
|
-
const result2 = await
|
|
5165
|
+
const result2 = await client3.dmarc.get(domain);
|
|
5058
5166
|
console.log(json ? JSON.stringify(result2) : formatDmarcStatus(result2.dmarc));
|
|
5059
5167
|
return { exitCode: 0 };
|
|
5060
5168
|
}
|
|
5061
5169
|
if (subcommand === "enable") {
|
|
5062
|
-
const apply =
|
|
5170
|
+
const apply = readFlag26(args, "--apply");
|
|
5063
5171
|
if (apply && !DMARC_APPLY_PROVIDERS.includes(apply)) {
|
|
5064
5172
|
return { exitCode: 1, error: `--apply must be one of: ${DMARC_APPLY_PROVIDERS.join(", ")}` };
|
|
5065
5173
|
}
|
|
5066
|
-
const result2 = await
|
|
5174
|
+
const result2 = await client3.dmarc.enable(domain, apply ? { apply } : {});
|
|
5067
5175
|
if (json) console.log(JSON.stringify(result2));
|
|
5068
5176
|
else {
|
|
5069
5177
|
console.log(formatDmarcStatus(result2.dmarc));
|
|
@@ -5074,13 +5182,13 @@ Updated the DMARC record with ${result2.applied.provider}.`);
|
|
|
5074
5182
|
return { exitCode: 0 };
|
|
5075
5183
|
}
|
|
5076
5184
|
if (subcommand === "disable") {
|
|
5077
|
-
const result2 = await
|
|
5185
|
+
const result2 = await client3.dmarc.disable(domain);
|
|
5078
5186
|
console.log(json ? JSON.stringify(result2) : `DMARC monitoring for ${domain} is off. Remove the report address from your DMARC record's rua= tag too.`);
|
|
5079
5187
|
return { exitCode: 0 };
|
|
5080
5188
|
}
|
|
5081
5189
|
const value = args.includes("--off") ? false : args.includes("--on") ? true : void 0;
|
|
5082
5190
|
if (value === void 0) return { exitCode: 1, error: "Usage: groundmail dmarc digest example.com --on|--off" };
|
|
5083
|
-
const result = await
|
|
5191
|
+
const result = await client3.dmarc.update(domain, { digest_enabled: value });
|
|
5084
5192
|
console.log(json ? JSON.stringify(result) : `Weekly DMARC digest for ${domain} is ${value ? "on" : "off"}.`);
|
|
5085
5193
|
return { exitCode: 0 };
|
|
5086
5194
|
} catch (error) {
|
|
@@ -5089,7 +5197,7 @@ Updated the DMARC record with ${result2.applied.provider}.`);
|
|
|
5089
5197
|
}
|
|
5090
5198
|
|
|
5091
5199
|
// src/commands/test-inbox/test-inbox.ts
|
|
5092
|
-
function
|
|
5200
|
+
function readFlag27(args, flag) {
|
|
5093
5201
|
const index = args.indexOf(flag);
|
|
5094
5202
|
if (index === -1) return void 0;
|
|
5095
5203
|
return args[index + 1];
|
|
@@ -5117,20 +5225,20 @@ function formatTestEmail(email) {
|
|
|
5117
5225
|
var USAGE2 = "Usage: groundmail test-inbox address [--prefix signup] | wait --to <address> [--timeout 30] [--since <iso>] [--json] | list [--to <address>] [--json]";
|
|
5118
5226
|
async function runTestInboxCommand(subcommand, args, env = process.env) {
|
|
5119
5227
|
if (!subcommand || !["address", "wait", "list"].includes(subcommand)) return { exitCode: 1, error: USAGE2 };
|
|
5120
|
-
const apiKey =
|
|
5228
|
+
const apiKey = readFlag27(args, "--api-key") || env.GROUNDMAIL_API_KEY;
|
|
5121
5229
|
if (!apiKey) return { exitCode: 1, error: "Missing API key. Run groundmail login, set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
5122
5230
|
const json = args.includes("--json");
|
|
5123
5231
|
try {
|
|
5124
|
-
const
|
|
5232
|
+
const client3 = await createTestInboxClient(apiKey, readFlag27(args, "--base-url"));
|
|
5125
5233
|
if (subcommand === "address") {
|
|
5126
|
-
console.log(await
|
|
5234
|
+
console.log(await client3.testInbox.address({ prefix: readFlag27(args, "--prefix") }));
|
|
5127
5235
|
return { exitCode: 0 };
|
|
5128
5236
|
}
|
|
5129
5237
|
if (subcommand === "list") {
|
|
5130
|
-
const result = await
|
|
5131
|
-
to:
|
|
5132
|
-
since:
|
|
5133
|
-
limit:
|
|
5238
|
+
const result = await client3.testInbox.list({
|
|
5239
|
+
to: readFlag27(args, "--to"),
|
|
5240
|
+
since: readFlag27(args, "--since"),
|
|
5241
|
+
limit: readFlag27(args, "--limit") ? Number(readFlag27(args, "--limit")) : void 0
|
|
5134
5242
|
});
|
|
5135
5243
|
if (json) console.log(JSON.stringify(result));
|
|
5136
5244
|
else if (!result.emails.length) console.log("No test emails yet.");
|
|
@@ -5141,13 +5249,13 @@ async function runTestInboxCommand(subcommand, args, env = process.env) {
|
|
|
5141
5249
|
}
|
|
5142
5250
|
return { exitCode: 0 };
|
|
5143
5251
|
}
|
|
5144
|
-
const to =
|
|
5252
|
+
const to = readFlag27(args, "--to");
|
|
5145
5253
|
if (!to) return { exitCode: 1, error: "Missing --to. Usage: groundmail test-inbox wait --to signup-k3m9x2pq@acme.test.groundmail.dev" };
|
|
5146
|
-
const timeoutRaw =
|
|
5254
|
+
const timeoutRaw = readFlag27(args, "--timeout");
|
|
5147
5255
|
const seconds = timeoutRaw === void 0 ? 30 : Number(timeoutRaw);
|
|
5148
5256
|
if (!Number.isFinite(seconds) || seconds < 0) return { exitCode: 1, error: "--timeout must be a number of seconds" };
|
|
5149
5257
|
try {
|
|
5150
|
-
const email = await
|
|
5258
|
+
const email = await client3.testInbox.waitFor({ to, timeout: seconds * 1e3, since: readFlag27(args, "--since") });
|
|
5151
5259
|
console.log(json ? JSON.stringify({ email }) : formatTestEmail(email));
|
|
5152
5260
|
return { exitCode: 0 };
|
|
5153
5261
|
} catch (error) {
|
|
@@ -5163,7 +5271,7 @@ async function runTestInboxCommand(subcommand, args, env = process.env) {
|
|
|
5163
5271
|
}
|
|
5164
5272
|
|
|
5165
5273
|
// src/commands/mailboxes/mailboxes.ts
|
|
5166
|
-
var
|
|
5274
|
+
var VALUE_FLAGS7 = [
|
|
5167
5275
|
"--send-as",
|
|
5168
5276
|
"--allowed-senders",
|
|
5169
5277
|
"--blocked-senders",
|
|
@@ -5362,7 +5470,7 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5362
5470
|
if (!subcommand || !["create", "owner", "verify", "list", "get", "update", "delete", "forward", "threads", "read", "wait", "send", "reply"].includes(subcommand)) {
|
|
5363
5471
|
return { exitCode: 1, error: USAGE3 };
|
|
5364
5472
|
}
|
|
5365
|
-
const parsed = parseArgs(argv, { values:
|
|
5473
|
+
const parsed = parseArgs(argv, { values: VALUE_FLAGS7, booleans: BOOLEAN_FLAGS });
|
|
5366
5474
|
if (!parsed.ok) return { exitCode: 1, error: parsed.error };
|
|
5367
5475
|
const { args } = parsed;
|
|
5368
5476
|
if (subcommand === "create" && args.booleans["--instant"] === true) return createInstant(args);
|
|
@@ -5378,30 +5486,30 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5378
5486
|
}
|
|
5379
5487
|
const ref = mailbox;
|
|
5380
5488
|
try {
|
|
5381
|
-
const
|
|
5489
|
+
const client3 = await createMailboxesClient(apiKey, v["--base-url"]);
|
|
5382
5490
|
if (subcommand === "owner") {
|
|
5383
5491
|
if (!v["--owner-email"]) return { exitCode: 1, error: "Missing --owner-email." };
|
|
5384
|
-
const owner = await
|
|
5492
|
+
const owner = await client3.mailboxes.setOwner(ref, v["--owner-email"]);
|
|
5385
5493
|
print(owner, () => `Code sent to ${owner.owner_email}. Ask them for it, then run: groundmail mailboxes verify ${ref} --code <code>`);
|
|
5386
5494
|
return { exitCode: 0 };
|
|
5387
5495
|
}
|
|
5388
5496
|
if (subcommand === "verify") {
|
|
5389
5497
|
if (!v["--code"]) return { exitCode: 1, error: "Missing --code." };
|
|
5390
|
-
const verified = await
|
|
5498
|
+
const verified = await client3.mailboxes.verifyOwner(ref, v["--code"]);
|
|
5391
5499
|
print(verified, () => "Verified. This mailbox now has a normal account, with the same key.");
|
|
5392
5500
|
return { exitCode: 0 };
|
|
5393
5501
|
}
|
|
5394
5502
|
if (subcommand === "create") {
|
|
5395
5503
|
const params = createParams(args);
|
|
5396
5504
|
if ("error" in params) return { exitCode: 1, error: params.error };
|
|
5397
|
-
const created = await
|
|
5505
|
+
const created = await client3.mailboxes.create(params);
|
|
5398
5506
|
print({ mailbox: created }, () => formatMailbox(created));
|
|
5399
5507
|
return { exitCode: 0 };
|
|
5400
5508
|
}
|
|
5401
5509
|
if (subcommand === "list") {
|
|
5402
5510
|
const page = paging(args);
|
|
5403
5511
|
if ("error" in page) return { exitCode: 1, error: page.error };
|
|
5404
|
-
const result = await
|
|
5512
|
+
const result = await client3.mailboxes.list({ ...page, ...v["--tenant"] ? { tenant: v["--tenant"] } : {} });
|
|
5405
5513
|
print(
|
|
5406
5514
|
result,
|
|
5407
5515
|
() => result.data.length ? result.data.map((item) => `${item.id} ${item.address} ${item.status}`).join("\n") : "No mailboxes yet."
|
|
@@ -5409,7 +5517,7 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5409
5517
|
return { exitCode: 0 };
|
|
5410
5518
|
}
|
|
5411
5519
|
if (subcommand === "get") {
|
|
5412
|
-
const found = await
|
|
5520
|
+
const found = await client3.mailboxes.get(ref);
|
|
5413
5521
|
print({ mailbox: found }, () => formatMailbox(found));
|
|
5414
5522
|
return { exitCode: 0 };
|
|
5415
5523
|
}
|
|
@@ -5420,7 +5528,7 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5420
5528
|
if (sendAs === void 0 && !allowed && !blocked) {
|
|
5421
5529
|
return { exitCode: 1, error: "Nothing to change. Usage: groundmail mailboxes update <mailbox> [--send-as support@example.com] [--allowed-senders you@example.com,example.com] [--blocked-senders spam.example]. Use none to clear one." };
|
|
5422
5530
|
}
|
|
5423
|
-
const updated = await
|
|
5531
|
+
const updated = await client3.mailboxes.update(ref, {
|
|
5424
5532
|
...sendAs !== void 0 ? { send_as: sendAs === "none" ? null : sendAs } : {},
|
|
5425
5533
|
...allowed ? { allowed_senders: allowed } : {},
|
|
5426
5534
|
...blocked ? { blocked_senders: blocked } : {}
|
|
@@ -5432,7 +5540,7 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5432
5540
|
if (!on("--yes")) {
|
|
5433
5541
|
return { exitCode: 1, error: "This deletes the mailbox and all its mail. Add --yes to confirm." };
|
|
5434
5542
|
}
|
|
5435
|
-
const result = await
|
|
5543
|
+
const result = await client3.mailboxes.delete(ref);
|
|
5436
5544
|
print(result, () => `Deleted ${result.id}`);
|
|
5437
5545
|
return { exitCode: 0 };
|
|
5438
5546
|
}
|
|
@@ -5445,14 +5553,14 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5445
5553
|
error: "This moves the address for good: it can't send again, and its mail is dropped after 30 days. Add --yes to confirm."
|
|
5446
5554
|
};
|
|
5447
5555
|
}
|
|
5448
|
-
const moved = await
|
|
5556
|
+
const moved = await client3.mailboxes.forward(ref, { to });
|
|
5449
5557
|
print({ mailbox: moved }, () => formatMailbox(moved));
|
|
5450
5558
|
return { exitCode: 0 };
|
|
5451
5559
|
}
|
|
5452
5560
|
if (subcommand === "threads") {
|
|
5453
5561
|
const page = paging(args);
|
|
5454
5562
|
if ("error" in page) return { exitCode: 1, error: page.error };
|
|
5455
|
-
const result = await
|
|
5563
|
+
const result = await client3.mailboxes.threads.list(ref, {
|
|
5456
5564
|
...page,
|
|
5457
5565
|
...v["--label"] ? { label: v["--label"] } : {},
|
|
5458
5566
|
...v["--participant"] ? { participant: v["--participant"] } : {},
|
|
@@ -5466,18 +5574,18 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5466
5574
|
}
|
|
5467
5575
|
if (subcommand === "read") {
|
|
5468
5576
|
if (target?.startsWith("thd_")) {
|
|
5469
|
-
const thread = await
|
|
5577
|
+
const thread = await client3.mailboxes.threads.get(ref, target, on("--include-held") ? { include_held: true } : {});
|
|
5470
5578
|
print({ thread }, () => formatThread(thread));
|
|
5471
5579
|
return { exitCode: 0 };
|
|
5472
5580
|
}
|
|
5473
5581
|
if (target) {
|
|
5474
|
-
const message = await
|
|
5582
|
+
const message = await client3.mailboxes.messages.get(ref, target);
|
|
5475
5583
|
print({ message }, () => formatMessage(message));
|
|
5476
5584
|
return { exitCode: 0 };
|
|
5477
5585
|
}
|
|
5478
5586
|
const page = paging(args);
|
|
5479
5587
|
if ("error" in page) return { exitCode: 1, error: page.error };
|
|
5480
|
-
const result = await
|
|
5588
|
+
const result = await client3.mailboxes.messages.list(ref, {
|
|
5481
5589
|
...page,
|
|
5482
5590
|
...v["--search"] ? { q: v["--search"] } : {},
|
|
5483
5591
|
...v["--from"] ? { from: v["--from"] } : {},
|
|
@@ -5497,7 +5605,7 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5497
5605
|
const body = bodyFlags(args);
|
|
5498
5606
|
if (!body) return { exitCode: 1, error: "Pass --text or --html." };
|
|
5499
5607
|
const cc = addresses(v["--cc"]);
|
|
5500
|
-
const result = await
|
|
5608
|
+
const result = await client3.mailboxes.messages.send(ref, { to, ...cc.length ? { cc } : {}, subject: v["--subject"], ...body });
|
|
5501
5609
|
print(result, () => formatSent(result));
|
|
5502
5610
|
return { exitCode: 0 };
|
|
5503
5611
|
}
|
|
@@ -5505,7 +5613,7 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5505
5613
|
if (!target) return { exitCode: 1, error: "Missing message id. Usage: groundmail mailboxes reply <mailbox> mbm_\u2026 --text \u2026" };
|
|
5506
5614
|
const body = bodyFlags(args);
|
|
5507
5615
|
if (!body) return { exitCode: 1, error: "Pass --text or --html." };
|
|
5508
|
-
const result = await
|
|
5616
|
+
const result = await client3.mailboxes.messages.reply(ref, target, { ...body, ...on("--reply-all") ? { reply_all: true } : {} });
|
|
5509
5617
|
print(result, () => formatSent(result));
|
|
5510
5618
|
return { exitCode: 0 };
|
|
5511
5619
|
}
|
|
@@ -5513,7 +5621,7 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5513
5621
|
const seconds = timeoutRaw === void 0 ? 30 : Number(timeoutRaw);
|
|
5514
5622
|
if (!Number.isFinite(seconds) || seconds < 0) return { exitCode: 1, error: "--timeout must be a number of seconds" };
|
|
5515
5623
|
try {
|
|
5516
|
-
const message = await
|
|
5624
|
+
const message = await client3.mailboxes.wait(ref, {
|
|
5517
5625
|
timeout: seconds * 1e3,
|
|
5518
5626
|
...v["--from"] ? { from: v["--from"] } : {},
|
|
5519
5627
|
...v["--thread"] ? { thread: v["--thread"] } : {},
|
|
@@ -6017,6 +6125,11 @@ async function main() {
|
|
|
6017
6125
|
process.exit(result.exitCode);
|
|
6018
6126
|
}
|
|
6019
6127
|
}
|
|
6128
|
+
if (command === "routes") {
|
|
6129
|
+
const result = await runRoutesCommand(subcommand, rest);
|
|
6130
|
+
if (result.error) console.error(result.error);
|
|
6131
|
+
process.exit(result.exitCode);
|
|
6132
|
+
}
|
|
6020
6133
|
if (command === "templates") {
|
|
6021
6134
|
if (subcommand === "list") {
|
|
6022
6135
|
const result = await runListCommand7(rest);
|