@billionsend/cli 0.3.0 → 0.3.2

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.
Files changed (3) hide show
  1. package/README.md +11 -11
  2. package/dist/index.js +54 -18
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -14,16 +14,16 @@ Node 18 or newer; no dependencies.
14
14
 
15
15
  ## What moves
16
16
 
17
- | Resource | How |
18
- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19
- | Contacts | Upserted by email through the batch endpoint; `unsubscribed` and topic opt-outs are preserved, never re-subscribed. Resend's `unsubscribed` is global, so it lands as BillionSend's team-wide `unsubscribed: true`; no per-domain unsubscribe is created. Topic subscriptions and properties follow in two per-contact passes that run after everything else, so the account is sendable before they finish. The batch endpoint answers created, updated or skipped but never whether a matched contact changed, so the summary reports those as `matched existing`, not as updated or unchanged. |
20
- | Segments, topics, properties | Matched by name / name / key: created when missing, updated when different, left alone when equal. Segment memberships follow the contacts. BillionSend property keys ignore case, Resend's do not: when Resend has both `plan` and `PLAN`, only the first is created, the other is listed as a manual note, and the report counts the contacts whose value for it was not written. A key that differs only in case from one already on BillionSend is the same property, and values are written under the spelling it has. |
21
- | Templates | Name, alias, subject, html, text, default from, reply-to and variables (up to 50 reply-to addresses and 50 variables; what does not fit is listed as a manual note). |
22
- | Webhooks | Endpoint and events. Signing secrets are copied so receivers keep verifying (`--fresh-webhook-secrets` mints new ones, shown once). Events BillionSend also emits carry over (`email.*`, `contact.created`, `contact.updated`, `contact.deleted`, `contact.topics.updated`, `suppression.added`, `suppression.removed`, `domain.created`, `domain.updated`, `domain.deleted`, `topic.created`, `topic.updated`, `topic.deleted` and `inbox.*`); the rest are dropped per webhook and listed. `email.scheduled`, `email.failed` and `email.suppressed` carry over only to an instance that emits them (its `GET /openapi.json` lists them). An older one refuses those webhooks with a 422: migrate to it with `npx @billionsend/cli@0.2.3`, which drops the three along with `suppression.added` and `suppression.removed` and lists all five; add those two back to the webhook afterwards, in the dashboard or with `PATCH /webhooks/{id}`. |
23
- | Suppressions | Bounces, complaints and manual entries, with their origin. |
24
- | Domains | Created with return path and tracking settings, in the one SES region your BillionSend instance serves (BillionSend Cloud: `us-east-2`) — the Resend region does not carry over. DNS records must be added again (DKIM keys are per provider); the report prints a copy-ready table. Both providers can stay verified side by side. Resend has no unsubscribe subdomain or page, so those are left unset. |
25
- | Broadcasts | Drafts and scheduled ones import as drafts; sent ones are skipped unless `--include-sent`. |
26
- | API keys | Not recreated (the source only exposes names); the report lists them as a to-do. |
17
+ | Resource | How |
18
+ | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19
+ | Contacts | Upserted by email through the batch endpoint; `unsubscribed` and topic opt-outs are preserved, never re-subscribed. Resend's `unsubscribed` is global, so it lands as BillionSend's team-wide `unsubscribed: true`; no per-domain unsubscribe is created. Topic subscriptions and properties follow in two per-contact passes that run after everything else, so the account is sendable before they finish. The batch endpoint answers created, updated or skipped but never whether a matched contact changed, so the summary reports those as `matched existing`, not as updated or unchanged. |
20
+ | Segments, topics, properties | Matched by name / name / key: created when missing, updated when different, left alone when equal. Segment memberships follow the contacts. BillionSend property keys ignore case, Resend's do not: when Resend has both `plan` and `PLAN`, only the first is created, the other is listed as a manual note, and the report counts the contacts whose value for it was not written. A key that differs only in case from one already on BillionSend is the same property, and values are written under the spelling it has. |
21
+ | Templates | Name, alias, subject, html, text, default from, reply-to and variables (up to 50 reply-to addresses and 50 variables; what does not fit is listed as a manual note). |
22
+ | Webhooks | Endpoint and events. Signing secrets are copied so receivers keep verifying (`--fresh-webhook-secrets` mints new ones, shown once). Events BillionSend also emits carry over (`email.*`, `contact.created`, `contact.updated`, `contact.deleted`, `contact.topics.updated`, `suppression.added`, `suppression.removed`, `domain.created`, `domain.updated`, `domain.deleted`, `topic.created`, `topic.updated`, `topic.deleted` and `inbox.*`); the rest are dropped per webhook and listed. `email.scheduled`, `email.failed` and `email.suppressed` carry over only to an instance that emits them (its `GET /openapi.json` lists them). An older one refuses those webhooks with a 422: migrate to it with `npx @billionsend/cli@0.2.3`, which drops the three along with `suppression.added` and `suppression.removed` and lists all five; add those two back to the webhook afterwards, in the dashboard or with `PATCH /webhooks/{id}`. |
23
+ | Suppressions | Bounces, complaints and manual entries, with their origin. |
24
+ | Domains | Created with return path and tracking settings, in the one SES region your BillionSend instance serves (BillionSend Cloud: `us-east-2`) — the Resend region does not carry over. The return path is always set explicitly and is never the label the domain has on Resend (`send` unless Resend names another): BillionSend gets `bounce`, or `bounces` when Resend's is already `bounce`, so the bounce MX record on Resend's side is not touched and both providers run in parallel until cutover; the plan and the report state both labels. BillionSend fixes the label at creation (changing it later means deleting the domain and creating it again). A domain that already exists on BillionSend is left as it is. DNS records must be added again (DKIM keys are per provider); the report prints a copy-ready table. Both providers can stay verified side by side. Resend has no unsubscribe subdomain or page, so those are left unset. |
25
+ | Broadcasts | Drafts and scheduled ones import as drafts; sent ones are skipped unless `--include-sent`. |
26
+ | API keys | Not recreated (the source only exposes names); the report lists them as a to-do. |
27
27
 
28
28
  Audiences (deprecated in Resend) are skipped — segments cover them.
29
29
 
@@ -83,7 +83,7 @@ The tests never reach a real account. The source side is a fake account (`test/h
83
83
 
84
84
  Publishing is manual; nothing is published on push.
85
85
 
86
- 1. Set `version` in `package.json`, commit, then tag and push: `git tag v0.3.0 && git push origin main v0.3.0`.
86
+ 1. Set `version` in `package.json`, commit, then tag and push: `git tag v0.3.2 && git push origin main v0.3.2`.
87
87
  2. The first version only: a member of the `@billionsend` npm organization publishes from a clean checkout of the tag, with two-factor authentication: `pnpm install --frozen-lockfile && pnpm typecheck && pnpm lint && pnpm test && npm publish` (`prepublishOnly` builds the bundle; `publishConfig.access` is `public`).
88
88
  3. Once the package exists: on npmjs.com, `@billionsend/cli` → Settings → Trusted Publisher → GitHub Actions, repository `billionsend/billionsend-cli`, workflow `release.yml`.
89
89
  4. Every later version: Actions → `release` → Run workflow, on the version tag. The workflow refuses a branch or a tag that differs from `package.json`, runs every check, and publishes with npm Trusted Publishing (no token stored).
package/dist/index.js CHANGED
@@ -1379,14 +1379,21 @@ function translateWebhookEvents(events) {
1379
1379
  }
1380
1380
  return { events: [...kept], dropped: [...dropped] };
1381
1381
  }
1382
+ var RESEND_DEFAULT_RETURN_PATH = "send";
1383
+ var TARGET_RETURN_PATH = "bounce";
1384
+ var TARGET_RETURN_PATH_FALLBACK = "bounces";
1385
+ function targetReturnPath(source) {
1386
+ return source.toLowerCase() === TARGET_RETURN_PATH ? TARGET_RETURN_PATH_FALLBACK : TARGET_RETURN_PATH;
1387
+ }
1388
+ var returnPathNote = (target, source) => `BillionSend return path is \`${target}\`; Resend's \`${source}\` stays as it is, so both can run in parallel`;
1382
1389
  function returnPathLabel(domain) {
1383
1390
  if (domain.customReturnPath) return domain.customReturnPath;
1384
1391
  const spf = domain.records.find((r) => r.record === "SPF");
1385
- if (!spf) return null;
1392
+ if (!spf) return RESEND_DEFAULT_RETURN_PATH;
1386
1393
  let name = spf.name.toLowerCase();
1387
1394
  if (name.endsWith(`.${domain.name.toLowerCase()}`)) name = name.slice(0, -domain.name.length - 1);
1388
1395
  const label = name.split(".")[0] ?? "";
1389
- return label === "" || label === domain.name.toLowerCase() ? null : label;
1396
+ return label === "" || label === domain.name.toLowerCase() ? RESEND_DEFAULT_RETURN_PATH : label;
1390
1397
  }
1391
1398
  function domainCreateInput(domain) {
1392
1399
  const tracking = {
@@ -1394,12 +1401,12 @@ function domainCreateInput(domain) {
1394
1401
  click_tracking: domain.clickTracking,
1395
1402
  ...domain.trackingSubdomain ? { tracking_subdomain: domain.trackingSubdomain } : {}
1396
1403
  };
1397
- const label = returnPathLabel(domain);
1404
+ const sourceReturnPath = returnPathLabel(domain).toLowerCase();
1398
1405
  const input = {
1399
1406
  name: domain.name,
1400
- ...label && label !== "send" ? { custom_return_path: label } : {}
1407
+ custom_return_path: targetReturnPath(sourceReturnPath)
1401
1408
  };
1402
- return { input, tracking };
1409
+ return { input, tracking, sourceReturnPath };
1403
1410
  }
1404
1411
  var TEMPLATE_VARIABLES_MAX = 50;
1405
1412
  var TEMPLATE_VARIABLE_KEY_RE = /^[A-Za-z0-9_]{1,50}$/;
@@ -1499,7 +1506,7 @@ function broadcastCreateInput(b, ids) {
1499
1506
  }
1500
1507
 
1501
1508
  // src/plan.ts
1502
- var PLAN_VERSION = 2;
1509
+ var PLAN_VERSION = 3;
1503
1510
  var BATCH_SIZE = 1e3;
1504
1511
  var RESOURCE_ORDER = [
1505
1512
  "properties",
@@ -1647,10 +1654,11 @@ function buildPlan({
1647
1654
  }
1648
1655
  continue;
1649
1656
  }
1650
- const { input, tracking } = domainCreateInput(d);
1657
+ const { input, tracking, sourceReturnPath } = domainCreateInput(d);
1651
1658
  creates += 1;
1652
- const payload = { create: input, tracking };
1653
- add("domains", "create", d.name, { payload });
1659
+ const payload = { create: input, tracking, sourceReturnPath };
1660
+ const note2 = returnPathNote(input.custom_return_path ?? "", sourceReturnPath);
1661
+ add("domains", "create", d.name, { payload, detail: note2 });
1654
1662
  manual("domains", d.name, DNS_AFTER_APPLY);
1655
1663
  }
1656
1664
  const limit = target.usage.limits.domains;
@@ -1910,7 +1918,7 @@ function buildPlan({
1910
1918
  const requests = reads + writes;
1911
1919
  const seconds2 = Math.ceil(reads / options.rps + writes / 10);
1912
1920
  return {
1913
- version: 2,
1921
+ version: PLAN_VERSION,
1914
1922
  createdAt: (options.now ?? /* @__PURE__ */ new Date()).toISOString(),
1915
1923
  source: snapshot.provider,
1916
1924
  target: {
@@ -2114,7 +2122,7 @@ function describePlanDiff(saved, current) {
2114
2122
  import { parseArgs } from "node:util";
2115
2123
 
2116
2124
  // src/meta.ts
2117
- var VERSION = true ? "0.3.0" : "0.0.0-dev";
2125
+ var VERSION = true ? "0.3.2" : "0.0.0-dev";
2118
2126
  var REPO_URL = "https://github.com/billionsend/billionsend-cli";
2119
2127
  var USER_AGENT = `billionsend-cli/${VERSION} (+${REPO_URL})`;
2120
2128
  var CLOUD_API_URL = "https://api.billionsend.com";
@@ -3160,12 +3168,13 @@ function buildReport({
3160
3168
  }) {
3161
3169
  const dns = Object.entries(outcome.domainRecords).map(([domain, records]) => ({
3162
3170
  domain,
3163
- records
3171
+ records,
3172
+ note: domainReturnPathNote(plan2, domain)
3164
3173
  }));
3165
3174
  for (const domain of targetState.domains) {
3166
3175
  if (domain.status === "verified" || domain.name in outcome.domainRecords) continue;
3167
3176
  if (!snapshot.domains.some((d) => d.name === domain.name)) continue;
3168
- dns.push({ domain: domain.name, records: domain.records });
3177
+ dns.push({ domain: domain.name, records: domain.records, note: null });
3169
3178
  }
3170
3179
  const apiKeys = plan2.items.filter((i) => i.resource === "api-keys").map((i) => i.key);
3171
3180
  const manual = [
@@ -3217,6 +3226,13 @@ function baseUrlStep(source, baseUrl) {
3217
3226
  const step = `set ${name}=${CLOUD_API_URL} in your app, so ${capitalize(source)} SDK calls go to BillionSend`;
3218
3227
  return baseUrl === CLOUD_API_URL ? step : `${step} (this run used ${baseUrl}; put that address there only if your app reaches BillionSend through it)`;
3219
3228
  }
3229
+ function domainReturnPathNote(plan2, domain) {
3230
+ const item = plan2.items.find(
3231
+ (i) => i.resource === "domains" && i.action === "create" && i.key === domain
3232
+ );
3233
+ const payload = item?.payload;
3234
+ return payload?.create.custom_return_path === void 0 ? null : returnPathNote(payload.create.custom_return_path, payload.sourceReturnPath);
3235
+ }
3220
3236
  function dnsCards(records) {
3221
3237
  return records.flatMap((r, i) => [
3222
3238
  ...i > 0 ? [""] : [],
@@ -3224,7 +3240,7 @@ function dnsCards(records) {
3224
3240
  ` ${bold(r.value)}`
3225
3241
  ]);
3226
3242
  }
3227
- function cutoverReadyLines(source, baseUrl, domainRecords) {
3243
+ function cutoverReadyLines(source, baseUrl, domainRecords, plan2) {
3228
3244
  const lines = [
3229
3245
  "",
3230
3246
  heading("Cutover ready"),
@@ -3236,7 +3252,13 @@ function cutoverReadyLines(source, baseUrl, domainRecords) {
3236
3252
  })
3237
3253
  ];
3238
3254
  for (const [domain, records] of Object.entries(domainRecords)) {
3239
- lines.push("", `DNS records for ${domain}:`, ...dnsCards(records));
3255
+ const note2 = domainReturnPathNote(plan2, domain);
3256
+ lines.push(
3257
+ "",
3258
+ `DNS records for ${domain}:`,
3259
+ ...note2 === null ? [] : [dim(`${note2}.`)],
3260
+ ...dnsCards(records)
3261
+ );
3240
3262
  }
3241
3263
  return lines;
3242
3264
  }
@@ -3323,9 +3345,11 @@ ${bold(String(done.length))} of ${done.length + left.length} steps done \u2014 l
3323
3345
  `);
3324
3346
  for (const item of left)
3325
3347
  line(`${dim("[")} ${dim("]")} ${item}`, { indent: " ", hanging: " " });
3326
- for (const { domain, records } of report.dns) {
3348
+ for (const { domain, records, note: note2 } of report.dns) {
3327
3349
  out.write(`
3328
3350
  DNS records for ${domain}:
3351
+ `);
3352
+ if (note2 !== null) out.write(`${dim(`${note2}.`)}
3329
3353
  `);
3330
3354
  for (const card of dnsCards(records)) out.write(`${card}
3331
3355
  `);
@@ -3384,11 +3408,12 @@ function renderReportMd(raw) {
3384
3408
  ...report.checklist.done.map((step) => `- [x] ${step}`),
3385
3409
  ...report.checklist.left.map((step) => `- [ ] ${step}`)
3386
3410
  ];
3387
- for (const { domain, records } of report.dns) {
3411
+ for (const { domain, records, note: note2 } of report.dns) {
3388
3412
  lines.push(
3389
3413
  "",
3390
3414
  `### DNS records for ${domain}`,
3391
3415
  "",
3416
+ ...note2 === null ? [] : [`${note2}.`, ""],
3392
3417
  "| Type | Name | Priority | Value |",
3393
3418
  "| --- | --- | --- | --- |",
3394
3419
  ...records.map((r) => `| ${r.type} | ${r.name} | ${r.priority ?? ""} | \`${r.value}\` |`)
@@ -3463,6 +3488,17 @@ function renderPlanMd(raw, sourceLabel) {
3463
3488
  "",
3464
3489
  `About ${formatNumber(plan2.estimate.requests)} requests (${formatDuration(plan2.estimate.seconds)} at ${plan2.rps} req/s).`
3465
3490
  ];
3491
+ const returnPaths = plan2.items.filter(
3492
+ (i) => i.resource === "domains" && i.action === "create" && i.detail !== void 0
3493
+ );
3494
+ if (returnPaths.length > 0) {
3495
+ lines.push(
3496
+ "",
3497
+ "## Return paths",
3498
+ "",
3499
+ ...returnPaths.map(({ key, detail }) => `- ${key} \u2014 ${detail}`)
3500
+ );
3501
+ }
3466
3502
  if (plan2.warnings.length > 0) {
3467
3503
  lines.push("", "## Warnings", "", ...plan2.warnings.map((w) => `- ${w}`));
3468
3504
  }
@@ -3835,7 +3871,7 @@ async function applyPlan(input) {
3835
3871
  ];
3836
3872
  if (passes.some((p) => p.wanted)) {
3837
3873
  const leftOut = CUTOVER_RESOURCES.filter((r) => input.include?.has(r) === false);
3838
- const lines = leftOut.length === 0 ? cutoverReadyLines(plan2.source, plan2.target.baseUrl, outcome.domainRecords) : [
3874
+ const lines = leftOut.length === 0 ? cutoverReadyLines(plan2.source, plan2.target.baseUrl, outcome.domainRecords, plan2) : [
3839
3875
  "",
3840
3876
  dim(
3841
3877
  `Enrichment follows. This run left out ${leftOut.join(", ")}, so it is not a cutover; run without --only for the cutover-ready checklist.`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@billionsend/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Migrate an email account to BillionSend: contacts, segments, topics, templates, webhooks, domains and suppressions — read from the source provider, written to your BillionSend account, re-run safe",
5
5
  "license": "MIT",
6
6
  "type": "module",