@erdoai/cli 0.257.0 → 0.259.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 +105 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -437,6 +437,9 @@ function formatOrg(name, slug) {
|
|
|
437
437
|
if (name && slug) return `${name} (${slug})`;
|
|
438
438
|
return name || slug || "";
|
|
439
439
|
}
|
|
440
|
+
function communicationCoverageUnavailable(response) {
|
|
441
|
+
return Object.values(response.coverage ?? {}).some((coverage) => coverage.state === "unavailable");
|
|
442
|
+
}
|
|
440
443
|
var TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "declined", "error"]);
|
|
441
444
|
var POLL_STOP_STATUSES = /* @__PURE__ */ new Set([...TERMINAL_RUN_STATUSES, "awaiting_approval"]);
|
|
442
445
|
var ErdoApiError = class extends Error {
|
|
@@ -938,6 +941,29 @@ var ErdoClient = class {
|
|
|
938
941
|
previewEmail(input) {
|
|
939
942
|
return this.request("POST", "/v1/email/preview", input);
|
|
940
943
|
}
|
|
944
|
+
listCommunications(params = {}) {
|
|
945
|
+
const q = new URLSearchParams();
|
|
946
|
+
for (const key of ["channel", "direction", "since", "until", "include", "conversation", "sender", "recipient", "agent", "widget", "subject", "limit", "cursor"]) {
|
|
947
|
+
const value = params[key];
|
|
948
|
+
if (value !== void 0 && value !== "") q.set(key, String(value));
|
|
949
|
+
}
|
|
950
|
+
for (const counterpart of params.counterpart ?? []) q.append("counterpart", counterpart);
|
|
951
|
+
if (params.context !== void 0) q.set("context", JSON.stringify(params.context));
|
|
952
|
+
const qs = q.toString();
|
|
953
|
+
return this.request("GET", `/v1/communications${qs ? `?${qs}` : ""}`);
|
|
954
|
+
}
|
|
955
|
+
queryCommunications(params = {}) {
|
|
956
|
+
return this.request("POST", "/v1/communications/query", params);
|
|
957
|
+
}
|
|
958
|
+
getCommunication(handle, cursor) {
|
|
959
|
+
const q = new URLSearchParams();
|
|
960
|
+
if (cursor) q.set("cursor", cursor);
|
|
961
|
+
const qs = q.toString();
|
|
962
|
+
return this.request(
|
|
963
|
+
"GET",
|
|
964
|
+
`/v1/communications/${encodeURIComponent(handle)}${qs ? `?${qs}` : ""}`
|
|
965
|
+
);
|
|
966
|
+
}
|
|
941
967
|
// Phone conversation records: inbound calls to a voice agent's own number and
|
|
942
968
|
// the outbound calls Erdo placed. Website chat widget conversations are a
|
|
943
969
|
// different resource — they live under /v1/voice/widget-conversations.
|
|
@@ -6891,6 +6917,13 @@ function grantList(v) {
|
|
|
6891
6917
|
}
|
|
6892
6918
|
return slugs;
|
|
6893
6919
|
}
|
|
6920
|
+
function measurementBindingInput(value) {
|
|
6921
|
+
if (value === void 0) return {};
|
|
6922
|
+
const parsed = JSON.parse(readMaybeFile(value));
|
|
6923
|
+
if (parsed === null) return { clear_measurement_binding: true };
|
|
6924
|
+
if (typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("measurement_binding must be a JSON object or null");
|
|
6925
|
+
return { measurement_binding: parsed };
|
|
6926
|
+
}
|
|
6894
6927
|
pagesCmd.command("deploy").description("Deploy a page (HTML/React); --html/--js/--css accept @file").requiredOption("--title <title>", "page title").requiredOption("--html <htmlOr@file>", "HTML (or @path to a file)").option("--js <jsOr@file>", "JS/JSX (or @path)").option("--css <cssOr@file>", "CSS (or @path)").option("--runtime <runtime>", "react-tailwind (default) or none").option(
|
|
6895
6928
|
"--meta-title <title>",
|
|
6896
6929
|
"public SEO title (browser tab + shared-link headline) \u2014 distinct from --title, the internal name"
|
|
@@ -6903,7 +6936,7 @@ pagesCmd.command("deploy").description("Deploy a page (HTML/React); --html/--js/
|
|
|
6903
6936
|
).option(
|
|
6904
6937
|
"--required-modules <csv>",
|
|
6905
6938
|
"runtime modules the page needs (erdoui, landing); a page using the landing components renders blank without landing"
|
|
6906
|
-
).option("--robots-policy <policy>", "index_follow (the primary page of a custom host) or noindex_nofollow (ad variants)").option("--indexing-role <role>", "primary (the page a custom host should index) or variant (an A/B arm or angle sibling)").option("--structured-data <jsonOr@file>", "SEO structured data (schema.org JSON-LD): a JSON object with @type and name, or @path to a file").option("--datasets <csv>", "dataset slugs the page reads").option("--writable-datasets <csv>", "dataset slugs the page may write via erdo.insertRows").option("--kv <csv>", "named KV-store slugs the page reads").option("--writable-kv <csv>", "named KV-store slugs the page may write").option("--request-review", "start a saved page review and wait for the findings").option("--no-wait", "return the review id without polling for findings").option("--public", "make the page publicly viewable").action(
|
|
6939
|
+
).option("--robots-policy <policy>", "index_follow (the primary page of a custom host) or noindex_nofollow (ad variants)").option("--indexing-role <role>", "primary (the page a custom host should index) or variant (an A/B arm or angle sibling)").option("--measurement-binding <jsonOr@file>", "page success event and provider mirrors as JSON (or @path); null clears the binding").option("--structured-data <jsonOr@file>", "SEO structured data (schema.org JSON-LD): a JSON object with @type and name, or @path to a file").option("--datasets <csv>", "dataset slugs the page reads").option("--writable-datasets <csv>", "dataset slugs the page may write via erdo.insertRows").option("--kv <csv>", "named KV-store slugs the page reads").option("--writable-kv <csv>", "named KV-store slugs the page may write").option("--request-review", "start a saved page review and wait for the findings").option("--no-wait", "return the review id without polling for findings").option("--public", "make the page publicly viewable").action(
|
|
6907
6940
|
async (opts) => {
|
|
6908
6941
|
try {
|
|
6909
6942
|
const csv = (v) => v ? v.split(",").map((s) => s.trim()) : void 0;
|
|
@@ -6917,6 +6950,7 @@ pagesCmd.command("deploy").description("Deploy a page (HTML/React); --html/--js/
|
|
|
6917
6950
|
robots_policy: opts.robotsPolicy,
|
|
6918
6951
|
indexing_role: opts.indexingRole,
|
|
6919
6952
|
structured_data: readMaybeFile(opts.structuredData),
|
|
6953
|
+
...measurementBindingInput(opts.measurementBinding),
|
|
6920
6954
|
meta_title: opts.metaTitle,
|
|
6921
6955
|
meta_description: opts.metaDescription,
|
|
6922
6956
|
meta_icon_asset_id: opts.metaIconAsset,
|
|
@@ -6956,7 +6990,7 @@ pagesCmd.command("update <id>").description(
|
|
|
6956
6990
|
).option(
|
|
6957
6991
|
"--required-modules <csv>",
|
|
6958
6992
|
'replacement runtime module list (comma-separated; "[]" clears)'
|
|
6959
|
-
).option("--robots-policy <policy>", "new robots policy: index_follow (the primary page of a custom host) or noindex_nofollow (ad variants)").option("--indexing-role <role>", "primary (the page a custom host should index) or variant (an A/B arm or angle sibling)").option("--structured-data <jsonOr@file>", "SEO structured data (schema.org JSON-LD): a JSON object with @type and name, or @path to a file").option("--datasets <csv>", 'replacement read-dataset slugs ("[]" clears)').option("--writable-datasets <csv>", 'replacement writable-dataset slugs ("[]" clears)').option("--kv <csv>", 'replacement read KV-store slugs ("[]" clears)').option("--writable-kv <csv>", 'replacement writable KV-store slugs ("[]" clears)').option("--public", "make the page publicly viewable").option("--private", "make the page private").option(
|
|
6993
|
+
).option("--robots-policy <policy>", "new robots policy: index_follow (the primary page of a custom host) or noindex_nofollow (ad variants)").option("--indexing-role <role>", "primary (the page a custom host should index) or variant (an A/B arm or angle sibling)").option("--measurement-binding <jsonOr@file>", "page success event and provider mirrors as JSON (or @path); null clears the binding").option("--structured-data <jsonOr@file>", "SEO structured data (schema.org JSON-LD): a JSON object with @type and name, or @path to a file").option("--datasets <csv>", 'replacement read-dataset slugs ("[]" clears)').option("--writable-datasets <csv>", 'replacement writable-dataset slugs ("[]" clears)').option("--kv <csv>", 'replacement read KV-store slugs ("[]" clears)').option("--writable-kv <csv>", 'replacement writable KV-store slugs ("[]" clears)').option("--public", "make the page publicly viewable").option("--private", "make the page private").option(
|
|
6960
6994
|
"--request-review",
|
|
6961
6995
|
"start a saved review and wait for findings; use for material live-page edits"
|
|
6962
6996
|
).option("--no-wait", "return the review id without polling for findings").action(
|
|
@@ -6977,6 +7011,7 @@ pagesCmd.command("update <id>").description(
|
|
|
6977
7011
|
robots_policy: opts.robotsPolicy,
|
|
6978
7012
|
indexing_role: opts.indexingRole,
|
|
6979
7013
|
structured_data: readMaybeFile(opts.structuredData),
|
|
7014
|
+
...measurementBindingInput(opts.measurementBinding),
|
|
6980
7015
|
dataset_slugs: grantList(opts.datasets),
|
|
6981
7016
|
writable_dataset_slugs: grantList(opts.writableDatasets),
|
|
6982
7017
|
kv_slugs: grantList(opts.kv),
|
|
@@ -7590,6 +7625,74 @@ sentEmailsCmd.command("get <emailID>").description("Read one sent email, includi
|
|
|
7590
7625
|
fail(e);
|
|
7591
7626
|
}
|
|
7592
7627
|
});
|
|
7628
|
+
var communicationsCmd = program.command("communications").description("Read organization communications across supported channels");
|
|
7629
|
+
communicationsCmd.command("list").description("List communications, newest first").option("--channel <channel>", "sms, whatsapp, email, voice_call, or widget; comma-separated values are supported").option("--direction <direction>", "inbound or outbound").option("--since <rfc3339>", "event time lower bound; calls/widgets overlap the window").option("--until <rfc3339>", "exclusive event time upper bound; calls/widgets overlap the window").option("--counterpart <uri>", "match tel:+E164 or mailto:address (repeatable)", (value, previous = []) => [...previous, value], []).option("--conversation <id>", "only this conversation").option("--sender <uri>", "only this tel:+E164 number or mailto:address").option("--recipient <uri>", "only this tel:+E164 number or mailto:address").option("--agent <slug>", "only this agent").option("--widget <handle>", "only this widget").option("--subject <text>", "match email subject text").option("--context <json>", "match a structured context object").option("--content", "include message content (bounded per response)").option("--limit <n>", "records per page (default 100, max 100)").option("--cursor <cursor>", "next_cursor from the preceding page").option("--json", "print the raw JSON result instead of a table").action(async (opts) => {
|
|
7630
|
+
try {
|
|
7631
|
+
let context;
|
|
7632
|
+
if (opts.context) {
|
|
7633
|
+
const parsed = JSON.parse(opts.context);
|
|
7634
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
7635
|
+
throw new Error("--context must be a JSON object");
|
|
7636
|
+
}
|
|
7637
|
+
context = parsed;
|
|
7638
|
+
}
|
|
7639
|
+
const filter = {
|
|
7640
|
+
channel: opts.channel,
|
|
7641
|
+
direction: opts.direction,
|
|
7642
|
+
since: opts.since,
|
|
7643
|
+
until: opts.until,
|
|
7644
|
+
counterpart: opts.counterpart,
|
|
7645
|
+
conversation: opts.conversation,
|
|
7646
|
+
sender: opts.sender,
|
|
7647
|
+
recipient: opts.recipient,
|
|
7648
|
+
agent: opts.agent,
|
|
7649
|
+
widget: opts.widget,
|
|
7650
|
+
subject: opts.subject,
|
|
7651
|
+
context,
|
|
7652
|
+
include: opts.content ? "messages" : void 0,
|
|
7653
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
7654
|
+
cursor: opts.cursor
|
|
7655
|
+
};
|
|
7656
|
+
const result = await new ErdoClient().listCommunications(filter);
|
|
7657
|
+
if (opts.json) {
|
|
7658
|
+
print(result);
|
|
7659
|
+
return;
|
|
7660
|
+
}
|
|
7661
|
+
const response = result;
|
|
7662
|
+
const records = response.items ?? [];
|
|
7663
|
+
if (records.length === 0) {
|
|
7664
|
+
console.log(communicationCoverageUnavailable(response) ? "Communication results are incomplete; see source coverage." : response.next_cursor ? "No communications in this page; continue with the next cursor." : "No communications match those filters.");
|
|
7665
|
+
} else {
|
|
7666
|
+
printAlignedTable(
|
|
7667
|
+
["handle", "channel", "kind", "direction", "from", "to", "occurred", "content"],
|
|
7668
|
+
records.map((record) => [
|
|
7669
|
+
record.id,
|
|
7670
|
+
record.channel,
|
|
7671
|
+
record.kind,
|
|
7672
|
+
record.direction ?? "",
|
|
7673
|
+
record.from ?? "",
|
|
7674
|
+
(record.to ?? []).join(", "),
|
|
7675
|
+
record.occurred_at,
|
|
7676
|
+
record.content_complete ? "complete" : "omitted or partial"
|
|
7677
|
+
])
|
|
7678
|
+
);
|
|
7679
|
+
}
|
|
7680
|
+
const coverage = Object.entries(response.coverage ?? {}).map(([channel, value]) => `${channel}=${value.state}`).join(", ");
|
|
7681
|
+
process.stderr.write(`as of ${response.as_of}; coverage: ${coverage || "none"}
|
|
7682
|
+
`);
|
|
7683
|
+
if (response.next_cursor) process.stderr.write(`more available \u2014 re-run with --cursor ${response.next_cursor}
|
|
7684
|
+
`);
|
|
7685
|
+
} catch (e) {
|
|
7686
|
+
fail(e);
|
|
7687
|
+
}
|
|
7688
|
+
});
|
|
7689
|
+
communicationsCmd.command("get <handle>").description("Read one communication by its opaque list handle").option("--cursor <cursor>", "content continuation returned by an earlier read").action(async (handle, opts) => {
|
|
7690
|
+
try {
|
|
7691
|
+
print(await new ErdoClient().getCommunication(handle, opts.cursor));
|
|
7692
|
+
} catch (e) {
|
|
7693
|
+
fail(e);
|
|
7694
|
+
}
|
|
7695
|
+
});
|
|
7593
7696
|
var voiceCmd = program.command("voice").description("A voice agent's phone calls, text conversations, website widget conversations, and its numbers");
|
|
7594
7697
|
function contactLabel(contact) {
|
|
7595
7698
|
if (!contact) return "-";
|