@erdoai/cli 0.247.0 → 0.249.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/index.js +43 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -125,7 +125,7 @@ function describeFreshnessTarget(state) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// src/index.ts
|
|
128
|
-
import { readFileSync as readFileSync5, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
128
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
129
129
|
|
|
130
130
|
// src/script-edits.ts
|
|
131
131
|
function parseScriptEdits(text) {
|
|
@@ -144,7 +144,7 @@ function parseScriptEdits(text) {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
// src/index.ts
|
|
147
|
-
import { basename as basename2 } from "path";
|
|
147
|
+
import { basename as basename2, resolve } from "path";
|
|
148
148
|
|
|
149
149
|
// src/csv.ts
|
|
150
150
|
function parseCSV(text) {
|
|
@@ -463,7 +463,7 @@ function networkErrorFor(method, path, err) {
|
|
|
463
463
|
const detail = code ? `${code} (${causeMsg})` : causeMsg;
|
|
464
464
|
return new ErdoNetworkError(`${method} ${path} failed: ${detail}`, cause);
|
|
465
465
|
}
|
|
466
|
-
var sleep = (ms) => new Promise((
|
|
466
|
+
var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
467
467
|
async function rawRequest(baseURL, token, orgId, projectId, method, path, body, retryNetworkFailures = true) {
|
|
468
468
|
const headers = { Authorization: `Bearer ${token}` };
|
|
469
469
|
if (orgId) headers["X-Organization-ID"] = orgId;
|
|
@@ -935,6 +935,9 @@ var ErdoClient = class {
|
|
|
935
935
|
getSentEmail(emailID) {
|
|
936
936
|
return this.request("GET", `/v1/emails/${encodeURIComponent(emailID)}`);
|
|
937
937
|
}
|
|
938
|
+
previewEmail(input) {
|
|
939
|
+
return this.request("POST", "/v1/email/preview", input);
|
|
940
|
+
}
|
|
938
941
|
// Phone conversation records: inbound calls to a voice agent's own number and
|
|
939
942
|
// the outbound calls Erdo placed. Website chat widget conversations are a
|
|
940
943
|
// different resource — they live under /v1/voice/widget-conversations.
|
|
@@ -2735,7 +2738,7 @@ function parsePastedCode(input, state) {
|
|
|
2735
2738
|
return { error: "couldn't find an authorization code in that \u2014 paste the full localhost callback URL" };
|
|
2736
2739
|
}
|
|
2737
2740
|
function waitForCode(state) {
|
|
2738
|
-
return new Promise((
|
|
2741
|
+
return new Promise((resolve2, reject) => {
|
|
2739
2742
|
let settled = false;
|
|
2740
2743
|
let server;
|
|
2741
2744
|
let rl;
|
|
@@ -2763,7 +2766,7 @@ function waitForCode(state) {
|
|
|
2763
2766
|
);
|
|
2764
2767
|
if (gotState !== state) return finish(() => reject(new Error("state mismatch \u2014 login aborted")));
|
|
2765
2768
|
if (!code) return finish(() => reject(new Error("no authorization code returned")));
|
|
2766
|
-
finish(() =>
|
|
2769
|
+
finish(() => resolve2(code));
|
|
2767
2770
|
});
|
|
2768
2771
|
server.on("error", (err) => {
|
|
2769
2772
|
if (err.code === "EADDRINUSE") {
|
|
@@ -2808,7 +2811,7 @@ If it doesn't open, visit:
|
|
|
2808
2811
|
console.log(` \u2717 ${parsed.error}`);
|
|
2809
2812
|
return;
|
|
2810
2813
|
}
|
|
2811
|
-
finish(() =>
|
|
2814
|
+
finish(() => resolve2(parsed.code));
|
|
2812
2815
|
return;
|
|
2813
2816
|
}
|
|
2814
2817
|
if (key?.name === "backspace") {
|
|
@@ -7181,7 +7184,40 @@ domainsCmd.command("transfer <domain> <targetOrg>").description("Move a domain t
|
|
|
7181
7184
|
fail(e);
|
|
7182
7185
|
}
|
|
7183
7186
|
});
|
|
7184
|
-
var emailCmd = program.command("email").description("
|
|
7187
|
+
var emailCmd = program.command("email").description("Preview outbound emails, manage their sending domain, and read replies");
|
|
7188
|
+
emailCmd.command("preview").description("Render an email at phone and desktop widths without sending it").option("--subject <text>", "Email subject").option("--html <html|@path>", "Authored HTML, or @path to an HTML file").option("--template <slug>", "Saved email template slug").option("--data <json|@path>", "Template data as JSON or @path to a JSON file").option("--out <directory>", "Directory for email-375.png and email-640.png", ".").action(async (opts) => {
|
|
7189
|
+
try {
|
|
7190
|
+
if (opts.html !== void 0 && opts.template !== void 0) {
|
|
7191
|
+
throw new Error("pass either --html or --template, not both");
|
|
7192
|
+
}
|
|
7193
|
+
const input = { subject: opts.subject };
|
|
7194
|
+
if (opts.html !== void 0) input.html_content = readMaybeFile(opts.html);
|
|
7195
|
+
if (opts.template !== void 0) input.template_slug = opts.template;
|
|
7196
|
+
if (opts.data !== void 0) {
|
|
7197
|
+
try {
|
|
7198
|
+
input.data = JSON.parse(readMaybeFile(opts.data) ?? "");
|
|
7199
|
+
} catch (error) {
|
|
7200
|
+
throw new Error(`--data must be valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
7201
|
+
}
|
|
7202
|
+
}
|
|
7203
|
+
if (input.data !== void 0 && (typeof input.data !== "object" || input.data === null || Array.isArray(input.data))) {
|
|
7204
|
+
throw new Error("--data must be a JSON object");
|
|
7205
|
+
}
|
|
7206
|
+
const preview = await new ErdoClient().previewEmail(input);
|
|
7207
|
+
const widths = new Set(preview.images.map((image) => image.width));
|
|
7208
|
+
if (preview.images.length !== 2 || widths.size !== 2 || !widths.has(375) || !widths.has(640)) {
|
|
7209
|
+
throw new Error("preview must return one image at each of 375px and 640px");
|
|
7210
|
+
}
|
|
7211
|
+
const outDir = resolve(opts.out);
|
|
7212
|
+
mkdirSync3(outDir, { recursive: true });
|
|
7213
|
+
for (const image of preview.images) {
|
|
7214
|
+
writeFileSync3(resolve(outDir, `email-${image.width}.png`), Buffer.from(image.png_base64, "base64"));
|
|
7215
|
+
}
|
|
7216
|
+
console.log(preview.plain_text);
|
|
7217
|
+
} catch (error) {
|
|
7218
|
+
fail(error);
|
|
7219
|
+
}
|
|
7220
|
+
});
|
|
7185
7221
|
var sendingDomainsCmd = emailCmd.command("domains").description("Sending domains \u2014 the verified domain outreach is sent from (one per org)");
|
|
7186
7222
|
function printSendingDomain(d) {
|
|
7187
7223
|
console.log(`${d.domain} ${d.status}${d.error_reason ? ` ${d.error_reason}` : ""}`);
|