@billionsend/cli 0.0.0-stage → 0.2.5

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -2
  3. package/dist/index.js +4251 -0
  4. package/package.json +46 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BillionSend
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,92 @@
1
- # Temporary Holding Version
1
+ # @billionsend/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Moves an email account to [BillionSend](https://billionsend.com): contacts, segments, topics, properties, templates, webhooks, domains and suppressions. Reads from the source provider, writes to your BillionSend account, and is safe to run again — a second run right before cutover syncs what changed since the first.
4
+
5
+ ```sh
6
+ npx @billionsend/cli migrate --from resend # interactive: connect, choose, plan, confirm, apply, summary
7
+ npx @billionsend/cli migrate plan --from resend --out plan.json # read-only; exit 0 nothing to do, 2 changes, 1 error
8
+ npx @billionsend/cli migrate apply plan.json --yes
9
+ npx @billionsend/cli migrate status
10
+ npx @billionsend/cli migrate rollback # deletes only what the tool created
11
+ ```
12
+
13
+ Node 18 or newer; no dependencies.
14
+
15
+ ## What moves
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. |
20
+ | Segments, topics, properties | Matched by name / name / key: created when missing, updated when different, left alone when equal. Segment memberships follow the contacts. |
21
+ | Templates | Name, alias, subject, html, text. From, reply-to and variables cannot be stored — listed as manual steps. |
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`, `suppression.added`, `suppression.removed`, and `inbox.*` except `inbox.thread.assigned` and `inbox.thread.unassigned`); 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. |
27
+
28
+ Audiences (deprecated in Resend) are skipped — segments cover them.
29
+
30
+ ## Environment
31
+
32
+ | Variable | Meaning |
33
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
34
+ | `RESEND_API_KEY` | Source key (full access; the tool only ever reads). Alternatives: `--from-key-stdin`, or a masked prompt in a terminal. |
35
+ | `BILLIONSEND_API_KEY` | BillionSend key (full access). Alternatives: `--to-key-stdin`, or a masked prompt. |
36
+ | `BILLIONSEND_BASE_URL` | BillionSend API URL. Same as `--to-url`. Unset, the target is BillionSend Cloud (`https://api.billionsend.com`), like the SDKs. |
37
+ | `NO_COLOR` | Disables ANSI colors. |
38
+ | `DO_NOT_TRACK` | Honored as a no-op: the tool sends no telemetry, never phones home and never checks for updates. |
39
+
40
+ ## Flags
41
+
42
+ `billionsend --help` lists every flag. The ones that change what happens:
43
+
44
+ - `--only a,b` / `--skip a,b` — resource names: `domains, properties, topics, segments, contacts, enrichment, broadcasts, templates, webhooks, suppressions, api-keys`. `enrichment` is the per-contact pass (topic subscriptions, then properties) that runs last.
45
+ - `--rps N` — requests per second against the source (default 8). Resend's team limit is 10, shared with your production sending; the CLI prints the limit it detects and warns above it. Go past 10 (up to 100) only after Resend raised your limit.
46
+ - `--on-conflict upsert|skip|error` — contacts that already exist on the target (default `upsert`).
47
+ - `--include-sent`, `--fresh-webhook-secrets`, `--fresh` (ignore the state file).
48
+ - `--yes`, `--non-interactive` (automatic when stdin is not a terminal), `--json` (JSON on stdout, progress on stderr), `--verbose`, `--color auto|always|never` (`--no-color` = `never`).
49
+
50
+ Exit codes: 0 ok · 1 error · 2 plan has changes (`plan` only) · 3 partial, some items failed (details in the report).
51
+
52
+ ## Files
53
+
54
+ `.billionsend/migrate-state.json` (every id created, resume cursors, the plan hash) and `.billionsend/migrate-report.{json,md}` are written next to where you run the tool, mode 0600. `.billionsend/` is appended to `.gitignore` when one exists there. No file ever contains a key.
55
+
56
+ ## Security
57
+
58
+ Your Resend key never leaves your machine — the tool only ever contacts `api.resend.com` and your BillionSend API. Against Resend it sends GET requests only, to documented endpoints. Keys live in memory for the duration of the run: they are never written to a file and are redacted from every log line. There is no telemetry, no update check, no third party.
59
+
60
+ ## Re-running and rolling back
61
+
62
+ Every run is a diff: existing rows are updated when they differ and left alone when they match. Run `billionsend migrate --from resend` again right before cutover to sync the contacts that arrived in between.
63
+
64
+ `billionsend migrate rollback` deletes only the ids the tool created (never rows it merely updated), in reverse dependency order, after showing the list and asking for confirmation.
65
+
66
+ ## Development
67
+
68
+ ```sh
69
+ pnpm install
70
+ pnpm typecheck && pnpm lint && pnpm build && pnpm test
71
+ ```
72
+
73
+ The tests never reach a real account. The source side is a fake account (`test/helpers/fake-resend.ts`); the BillionSend side is a contract API (`test/helpers/contract-api.ts`): an in-memory API that checks every request the CLI sends and every answer it gives against the published OpenAPI document, kept in `openapi/api.openapi.json`. A request to an undocumented path or with an undocumented parameter, a body off its schema, or an answer the document does not describe fails the test that caused it.
74
+
75
+ `pnpm openapi:sync` refreshes the snapshot from https://billionsend.com/docs/api.openapi.json (`-- --from <file|url>` takes another source, `-- --check` only compares); run the tests after it, and what fails is what the CLI has to follow. CI compares the snapshot with the published document every week.
76
+
77
+ ## Releasing
78
+
79
+ Publishing is manual; nothing is published on push.
80
+
81
+ 1. Set `version` in `package.json`, commit, then tag and push: `git tag v0.2.4 && git push origin main v0.2.4`.
82
+ 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`).
83
+ 3. Once the package exists: on npmjs.com, `@billionsend/cli` → Settings → Trusted Publisher → GitHub Actions, repository `billionsend/billionsend-cli`, workflow `release.yml`.
84
+ 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).
85
+
86
+ ## License
87
+
88
+ MIT
89
+
90
+ ---
91
+
92
+ Resend is a trademark of Plus Five Five, Inc. BillionSend is not affiliated with or endorsed by Resend.