@referalli/cli 0.3.3 → 0.4.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/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to `@referalli/cli` are recorded here. The format follows
5
5
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Before 1.0, a minor
6
6
  bump may include breaking changes; they are called out under **Changed**.
7
7
 
8
+ ## 0.4.0 - 2026-11-03
9
+
10
+ - `apply` manages `billingConnections`: matched by `name`, with `provider`, `programs` (slugs), `status`, `customerRefMetadataKey`, `filter`, and `stripeKeyEnv` (Stripe one-call connect, create only). Missing connections are created, changed fields PATCHed, none deleted; the new `webhookSecret` goes to `--secret-file` (or is printed once, like other new secrets). `--check` exits 2 on billing connection drift too.
11
+ - `doctor [--program <id>] [--json]`: read-only setup checks (API key, commission rules, webhook endpoints, billing and auth connections, tracking token), each `✓`/`⚠`/`✗` with a fix. Exits 1 on any `✗`.
12
+
8
13
  ## 0.3.3 - 2026-11-02
9
14
 
10
15
  - `trigger --billing <event> --connection <id> [--data JSON]`: send a billing event fixture for any provider (the connection's) into a test-mode billing connection (`POST /v1/sandbox/billing-fixtures`). Events are provider-neutral (`payment.paid`, `payment.refunded`, `payment.disputed`, `subscription.created`, `subscription.canceled`) or the provider's own names. `trigger --stripe` keeps working.
@@ -2,7 +2,7 @@ import type { Client } from './client.js';
2
2
  /**
3
3
  * `referalli plan|apply <file>`: make the account match a declarative file.
4
4
  * Every resource is matched by a stable key (program slug, webhook url, API key
5
- * name + owner); creates carry an Idempotency-Key derived from that key and the
5
+ * name + owner, billing connection name); creates carry an Idempotency-Key derived from that key and the
6
6
  * request, so a retried apply never creates twice. Nothing missing from the file
7
7
  * is ever deleted, rotated or revoked.
8
8
  */
@@ -27,10 +27,18 @@ interface ApiKeySpec extends Obj {
27
27
  owner?: string;
28
28
  programs?: string[];
29
29
  }
30
+ interface BillingConnectionSpec extends Obj {
31
+ name: string;
32
+ provider: string;
33
+ programs?: string[];
34
+ status?: 'active' | 'paused';
35
+ stripeKeyEnv?: string;
36
+ }
30
37
  export interface ApplyConfig {
31
38
  programs: ProgramSpec[];
32
39
  webhooks: WebhookSpec[];
33
40
  apiKeys: ApiKeySpec[];
41
+ billingConnections: BillingConnectionSpec[];
34
42
  }
35
43
  /** Parse and check a referalli.yaml (JSON is YAML too). */
36
44
  export declare function parseConfig(text: string, file?: string): ApplyConfig;
package/dist/src/apply.js CHANGED
@@ -4,7 +4,7 @@ import { load } from 'js-yaml';
4
4
  /**
5
5
  * `referalli plan|apply <file>`: make the account match a declarative file.
6
6
  * Every resource is matched by a stable key (program slug, webhook url, API key
7
- * name + owner); creates carry an Idempotency-Key derived from that key and the
7
+ * name + owner, billing connection name); creates carry an Idempotency-Key derived from that key and the
8
8
  * request, so a retried apply never creates twice. Nothing missing from the file
9
9
  * is ever deleted, rotated or revoked.
10
10
  */
@@ -18,6 +18,8 @@ const PROGRAM_KEYS = ['slug', ...PROGRAM_TOP, ...PROGRAM_SETTINGS, 'destinationU
18
18
  const STRIPE_KEYS = ['enabled', 'referrerMatch', 'metadataKey', 'refereeRewards', 'balanceCurrency', 'createCustomerIfMissing', 'waitForCustomer', 'secretKeyEnv'];
19
19
  const WEBHOOK_KEYS = ['url', 'topics', 'programs', 'status', 'alertContacts'];
20
20
  const API_KEY_KEYS = ['name', 'owner', 'mode', 'scopes', 'expiresInDays', 'programs', 'apiVersion'];
21
+ const BILLING_KEYS = ['name', 'provider', 'programs', 'status', 'customerRefMetadataKey', 'filter', 'stripeKeyEnv'];
22
+ const SECRET_KEYS = ['secretKey', 'stripeKey', 'webhookSecret', 'credentials'];
21
23
  // What the API stores when a rule leaves these out (packages/commissions ruleConfigSchema).
22
24
  const RULE_DEFAULTS = { appliesTo: 'gross', recurring: { type: 'lifetime' }, holdDays: 30, rounding: 'half_even', overrides: [] };
23
25
  const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
@@ -25,8 +27,8 @@ function checkKeys(o, allowed, where, required) {
25
27
  if (!isObj(o))
26
28
  throw new ConfigError(`${where}: expected a mapping`);
27
29
  for (const k of Object.keys(o)) {
28
- if (k === 'secretKey')
29
- throw new ConfigError(`${where}: secrets never go in the file; use secretKeyEnv: ENV_VAR_NAME`);
30
+ if (SECRET_KEYS.includes(k))
31
+ throw new ConfigError(`${where}: secrets never go in the file; use secretKeyEnv / stripeKeyEnv: ENV_VAR_NAME`);
30
32
  if (!allowed.includes(k))
31
33
  throw new ConfigError(`${where}: unknown field "${k}" (allowed: ${allowed.join(', ')})`);
32
34
  }
@@ -49,7 +51,7 @@ export function parseConfig(text, file = 'config') {
49
51
  catch (err) {
50
52
  throw new ConfigError(`${file}: ${err.message}`);
51
53
  }
52
- checkKeys(doc ?? {}, ['programs', 'webhooks', 'apiKeys'], file);
54
+ checkKeys(doc ?? {}, ['programs', 'webhooks', 'apiKeys', 'billingConnections'], file);
53
55
  const d = (doc ?? {});
54
56
  const programs = list(d.programs, 'programs').map((p, i) => {
55
57
  const where = `programs[${i}]`;
@@ -77,7 +79,22 @@ export function parseConfig(text, file = 'config') {
77
79
  checkKeys(k, API_KEY_KEYS, `apiKeys[${i}]`, 'name');
78
80
  return k;
79
81
  });
80
- return { programs, webhooks, apiKeys };
82
+ const billingConnections = list(d.billingConnections, 'billingConnections').map((b, i) => {
83
+ const where = `billingConnections[${i}]`;
84
+ checkKeys(b, BILLING_KEYS, where, 'name');
85
+ if (typeof b.provider !== 'string' || !b.provider)
86
+ throw new ConfigError(`${where}: "provider" is required`);
87
+ if (b.status !== undefined && b.status !== 'active' && b.status !== 'paused')
88
+ throw new ConfigError(`${where}.status: active or paused`);
89
+ if (b.stripeKeyEnv !== undefined && b.provider !== 'stripe')
90
+ throw new ConfigError(`${where}: stripeKeyEnv is for provider "stripe"`);
91
+ return b;
92
+ });
93
+ const names = billingConnections.map((b) => b.name);
94
+ const dupName = names.find((s, i) => names.indexOf(s) !== i);
95
+ if (dupName)
96
+ throw new ConfigError(`billingConnections: name "${dupName}" is listed twice`);
97
+ return { programs, webhooks, apiKeys, billingConnections };
81
98
  }
82
99
  /** Key-order-insensitive JSON, for comparing values. */
83
100
  const canon = (v) => JSON.stringify(v, (_k, x) => (isObj(x) ? Object.fromEntries(Object.entries(x).sort(([a], [b]) => a.localeCompare(b))) : x));
@@ -290,6 +307,69 @@ export async function buildPlan(client, config, env) {
290
307
  },
291
308
  });
292
309
  }
310
+ if (config.billingConnections.length) {
311
+ const conns = await client.request('GET', '/v1/billing/connections');
312
+ for (const spec of config.billingConnections) {
313
+ const label = `billingConnection "${spec.name}"`;
314
+ checkRefs(spec.programs, label);
315
+ const matches = conns.filter((c) => c.name === spec.name);
316
+ if (matches.length > 1)
317
+ throw new ConfigError(`${label}: ${matches.length} connections on the account have this name; rename all but one (PATCH /v1/billing/connections/{id})`);
318
+ const cur = matches[0];
319
+ // programs and status are always managed (like webhooks); the optional fields only when the file sets them (null clears).
320
+ const want = { programs: sorted(spec.programs), status: spec.status ?? 'active' };
321
+ for (const k of ['customerRefMetadataKey', 'filter'])
322
+ if (spec[k] !== undefined)
323
+ want[k] = spec[k];
324
+ const apiBody = (ctx, keys) => Object.fromEntries(keys.map((k) => (k === 'programs' ? ['programIds', programIdsFor(ctx, spec.programs)] : [k, want[k]])));
325
+ if (!cur) {
326
+ const key = spec.stripeKeyEnv;
327
+ if (key && !env[key])
328
+ throw new ConfigError(`${label}: environment variable ${key} is not set`);
329
+ const { status, ...createFields } = want;
330
+ changes.push({
331
+ action: 'create',
332
+ kind: 'billingConnection',
333
+ label,
334
+ fields: [
335
+ ['provider', undefined, spec.provider],
336
+ ...Object.entries(want).map(([k, v]) => [k, undefined, v]),
337
+ ...(key ? [['stripeKey', undefined, `(from $${key})`]] : []),
338
+ ],
339
+ run: async (ctx) => {
340
+ const body = { name: spec.name, provider: spec.provider, ...apiBody(ctx, Object.keys(createFields).filter((k) => createFields[k] !== null)), ...(key ? { stripeKey: env[key] } : {}) };
341
+ const made = await create(ctx.client, '/v1/billing/connections', 'billing', spec.name, body);
342
+ // POST takes no status: pause right after creating.
343
+ if (status === 'paused')
344
+ await ctx.client.request('PATCH', `/v1/billing/connections/${made.id}`, { status });
345
+ // awaiting_secret: the generated secret can't verify this provider; the provider's own is set later with PUT …/secret.
346
+ return typeof made.webhookSecret === 'string' && made.status !== 'awaiting_secret' ? [[label, made.webhookSecret]] : [];
347
+ },
348
+ });
349
+ continue;
350
+ }
351
+ if (cur.provider !== spec.provider) {
352
+ throw new ConfigError(`${label}: the account's connection is provider "${cur.provider}", the file says "${spec.provider}"; a provider can't be changed`);
353
+ }
354
+ const now = {
355
+ programs: sorted((cur.programIds ?? []).map((id) => slugOf.get(id) ?? id)),
356
+ status: cur.status === 'awaiting_secret' ? 'active' : cur.status,
357
+ customerRefMetadataKey: cur.customerRefMetadataKey,
358
+ filter: cur.filter,
359
+ };
360
+ const fields = Object.keys(want).filter((k) => !same(now[k], want[k])).map((k) => [k, now[k], want[k]]);
361
+ changes.push({
362
+ action: fields.length ? 'update' : 'noop',
363
+ kind: 'billingConnection',
364
+ label,
365
+ fields,
366
+ run: async (ctx) => {
367
+ await ctx.client.request('PATCH', `/v1/billing/connections/${cur.id}`, apiBody(ctx, fields.map(([k]) => k)));
368
+ return [];
369
+ },
370
+ });
371
+ }
372
+ }
293
373
  return { changes, ids };
294
374
  }
295
375
  // --- output ----------------------------------------------------------------------
@@ -40,3 +40,5 @@ export declare function keys(io: Io, sub: string | undefined, arg: string | unde
40
40
  export declare function api(io: Io, method: string | undefined, path: string | undefined, flags: Flags): Promise<number>;
41
41
  /** `referalli plan <file>` / `referalli apply <file> [--plan] [--check] [--secret-file PATH]`. */
42
42
  export declare function apply(io: Io, file: string | undefined, flags: Flags, planOnly: boolean): Promise<number>;
43
+ /** `referalli doctor [--program <id>] [--json]`. */
44
+ export declare const doctor: (io: Io, flags: Flags) => Promise<number>;
@@ -2,6 +2,7 @@ import { chmodSync, writeFileSync } from 'node:fs';
2
2
  import { hostname } from 'node:os';
3
3
  import { ConfigError, runApply } from './apply.js';
4
4
  import { ApiError, createClient } from './client.js';
5
+ import { runDoctor } from './doctor.js';
5
6
  import { DEFAULT_BASE_URL, readConfig, removeConfig, writeConfig } from './config.js';
6
7
  /** A user-facing failure: printed without a stack trace, exit code 1. */
7
8
  export class CliError extends Error {
@@ -435,3 +436,5 @@ export async function apply(io, file, flags, planOnly) {
435
436
  throw err;
436
437
  }
437
438
  }
439
+ /** `referalli doctor [--program <id>] [--json]`. */
440
+ export const doctor = (io, flags) => runDoctor(io, signedIn(io).client, flags);
@@ -0,0 +1,11 @@
1
+ import { type Client } from './client.js';
2
+ import type { Flags, Io } from './commands.js';
3
+ /** One line of `referalli doctor`. */
4
+ export interface Check {
5
+ id: string;
6
+ status: 'ok' | 'warn' | 'fail';
7
+ message: string;
8
+ fix?: string;
9
+ }
10
+ /** `referalli doctor [--program <id>] [--json]`: read-only health checks. Exit 1 when any check fails. */
11
+ export declare function runDoctor(io: Io, client: Client, flags: Flags, now?: Date): Promise<number>;
@@ -0,0 +1,143 @@
1
+ import { ApiError } from './client.js';
2
+ const DAY = 86_400_000;
3
+ const reason = (err) => err instanceof ApiError ? `${err.status}${err.code ? ` ${err.code}` : ''}: ${err.message}` : err.message;
4
+ // Lists come back as arrays, or `{ data }` on paginated versions.
5
+ const rows = (res) => (Array.isArray(res) ? res : res.data);
6
+ /** A failed API call is a warning for that check only, never a crash. */
7
+ async function guard(id, fix, fn) {
8
+ try {
9
+ return await fn();
10
+ }
11
+ catch (err) {
12
+ return [{ id, status: 'warn', message: `couldn't check: ${reason(err)}`, ...(fix ? { fix } : {}) }];
13
+ }
14
+ }
15
+ async function keyCheck(client, now) {
16
+ let me;
17
+ try {
18
+ me = await client.request('GET', '/v1/me');
19
+ }
20
+ catch (err) {
21
+ if (err instanceof ApiError && err.status === 401) {
22
+ return [{ id: 'key', status: 'fail', message: `the API key was refused: ${err.message}`, fix: 'referalli login' }];
23
+ }
24
+ throw err;
25
+ }
26
+ const k = me.apiKey;
27
+ if (!k)
28
+ return [{ id: 'key', status: 'warn', message: 'signed in without an API key; key checks skipped', fix: 'referalli login' }];
29
+ const out = [
30
+ { id: 'key', status: 'ok', message: `${k.livemode ? 'live' : 'test'} key "${k.name}", scopes: ${k.scopes.join(', ') || 'none'}` },
31
+ ];
32
+ if (k.expiresAt && new Date(k.expiresAt).getTime() - now.getTime() < 14 * DAY) {
33
+ out.push({ id: 'key.expiry', status: 'warn', message: `the key expires ${k.expiresAt}`, fix: 'referalli keys create --name NAME (then referalli login --key …)' });
34
+ }
35
+ if (k.programIds) {
36
+ out.push({
37
+ id: 'key.programs',
38
+ status: 'warn',
39
+ message: `the key is limited to programs ${k.programIds.join(', ')}: other programs and org-wide setup aren't visible to it`,
40
+ fix: 'run doctor with an org-wide key to check everything',
41
+ });
42
+ }
43
+ return out;
44
+ }
45
+ async function termsChecks(client, programId) {
46
+ const programs = programId
47
+ ? [await client.request('GET', `/v1/programs/${encodeURIComponent(programId)}`)]
48
+ : rows(await client.request('GET', '/v1/programs')).filter((p) => p.status === 'active');
49
+ if (programs.length === 0)
50
+ return [{ id: 'programs', status: 'warn', message: 'no active programs', fix: '/programs' }];
51
+ return Promise.all(programs.map((p) => guard(`program.${p.id}.terms`, undefined, async () => {
52
+ try {
53
+ await client.request('GET', `/v1/programs/${encodeURIComponent(p.id)}/terms`);
54
+ return [{ id: `program.${p.id}.terms`, status: 'ok', message: `program "${p.name}" has a commission rule` }];
55
+ }
56
+ catch (err) {
57
+ if (!(err instanceof ApiError && err.status === 404))
58
+ throw err;
59
+ return [{ id: `program.${p.id}.terms`, status: 'fail', message: `program "${p.name}" has no commission rule: nothing earns commission`, fix: `POST /v1/commission-rules with programId ${p.id}` }];
60
+ }
61
+ }))).then((all) => all.flat());
62
+ }
63
+ async function webhookChecks(client) {
64
+ const endpoints = rows(await client.request('GET', '/v1/webhook-endpoints'));
65
+ if (endpoints.length === 0)
66
+ return [{ id: 'webhooks', status: 'ok', message: 'no webhook endpoints' }];
67
+ return endpoints.map((e) => {
68
+ const id = `webhook.${e.id}`;
69
+ if (e.health === 'healthy')
70
+ return { id, status: 'ok', message: `${e.url} is healthy` };
71
+ const last = e.lastFailure ? ` (last: ${e.lastFailure.statusCode ?? e.lastFailure.error ?? 'error'})` : '';
72
+ const why = e.health === 'failing' ? `failing, ${e.consecutiveFailures} failures in a row${last}` : e.health;
73
+ const fix = e.health === 'failing' ? `GET /v1/webhook-endpoints/${e.id}/deliveries` : `PATCH /v1/webhook-endpoints/${e.id} {"status":"active"}`;
74
+ return { id, status: 'warn', message: `${e.url} is ${why}`, fix };
75
+ });
76
+ }
77
+ async function billingChecks(client) {
78
+ const conns = rows(await client.request('GET', '/v1/billing/connections'));
79
+ if (conns.length === 0) {
80
+ return [{ id: 'billing', status: 'warn', message: "no billing connection: payments won't earn commission", fix: 'POST /v1/billing/connections' }];
81
+ }
82
+ return conns.map((c) => {
83
+ const id = `billing.${c.id}`;
84
+ const label = `${c.provider} connection "${c.name}"`;
85
+ if (c.status === 'awaiting_secret') {
86
+ return { id, status: 'fail', message: `${label}: provider secret not set, every event is refused`, fix: `PUT /v1/billing/connections/${c.id}/secret {"webhookSecret":"…"}` };
87
+ }
88
+ if (c.status === 'paused')
89
+ return { id, status: 'warn', message: `${label} is paused`, fix: `PATCH /v1/billing/connections/${c.id} {"status":"active"}` };
90
+ return { id, status: 'ok', message: `${label} is ${c.status}` };
91
+ });
92
+ }
93
+ async function authChecks(client) {
94
+ const conns = rows(await client.request('GET', '/v1/auth/connections'));
95
+ if (conns.length === 0)
96
+ return [{ id: 'auth', status: 'ok', message: 'no auth connections' }];
97
+ // Protocol connections (Atlas, custom) can't be pinged with an API key: status and settings only.
98
+ return conns.map((c) => {
99
+ const id = `auth.${c.id}`;
100
+ const label = `${c.provider} auth connection${c.name ? ` "${c.name}"` : ''}`;
101
+ if (c.status === 'paused')
102
+ return { id, status: 'warn', message: `${label} is paused`, fix: `PATCH /v1/auth/connections/${c.id} {"status":"active"}` };
103
+ if (c.tokenVerification && c.allowedOrigins.length === 0) {
104
+ return { id, status: 'warn', message: `${label} verifies tokens but has no allowedOrigins: the widget session refuses browsers`, fix: `PATCH /v1/auth/connections/${c.id} {"allowedOrigins":["https://your.app"]}` };
105
+ }
106
+ return { id, status: 'ok', message: `${label} is ${c.status}` };
107
+ });
108
+ }
109
+ async function trackingCheck(client) {
110
+ const org = await client.request('GET', '/v1/org');
111
+ try {
112
+ const cfg = await client.request('GET', `/t/${encodeURIComponent(org.trackingToken)}/config.json`);
113
+ return [{ id: 'tracking', status: 'ok', message: `tracking token ${org.trackingToken} answers; cookie window ${cfg.cookieWindowDays} days` }];
114
+ }
115
+ catch (err) {
116
+ if (!(err instanceof ApiError && err.status === 404))
117
+ throw err;
118
+ return [{ id: 'tracking', status: 'fail', message: `tracking token ${org.trackingToken} is unknown to /t/…/config.json`, fix: '/settings' }];
119
+ }
120
+ }
121
+ const MARK = { ok: '✓', warn: '⚠', fail: '✗' };
122
+ /** `referalli doctor [--program <id>] [--json]`: read-only health checks. Exit 1 when any check fails. */
123
+ export async function runDoctor(io, client, flags, now = new Date()) {
124
+ const program = typeof flags.program === 'string' ? flags.program : undefined;
125
+ const checks = (await Promise.all([
126
+ guard('key', 'referalli login', () => keyCheck(client, now)),
127
+ guard('programs', undefined, () => termsChecks(client, program)),
128
+ guard('webhooks', undefined, () => webhookChecks(client)),
129
+ guard('billing', undefined, () => billingChecks(client)),
130
+ guard('auth', undefined, () => authChecks(client)),
131
+ guard('tracking', undefined, () => trackingCheck(client)),
132
+ ])).flat();
133
+ if (flags.json)
134
+ io.out(JSON.stringify({ checks }, null, 2));
135
+ else {
136
+ for (const c of checks) {
137
+ io.out(`${MARK[c.status]} ${c.id}: ${c.message}`);
138
+ if (c.fix && c.status !== 'ok')
139
+ io.out(` fix: ${c.fix}`);
140
+ }
141
+ }
142
+ return checks.some((c) => c.status === 'fail') ? 1 : 0;
143
+ }
@@ -3,6 +3,6 @@ export { readConfig, writeConfig, configPath, type CliConfig } from './config.js
3
3
  export { createClient, ApiError } from './client.js';
4
4
  export type { Io } from './commands.js';
5
5
  export { VERSION } from './version.js';
6
- export declare const HELP = "referalli: the Referalli command line\n\nUsage:\n referalli login [--key rk_\u2026] [--base-url URL] [--no-browser]\n referalli logout\n referalli whoami\n referalli listen [--forward-to URL] [--events topic,topic] [--max-events N]\n referalli trigger <topic> [--data JSON]\n referalli trigger --billing <event> --connection <id> [--data JSON] (test mode; e.g. payment.paid)\n referalli trigger --stripe <event> --connection <id> [--data JSON] (test mode)\n referalli events tail [--events topic,topic] [--since 1h|ISO] [--json] [--max N]\n referalli logs tail [--max N]\n referalli open [docs|dashboard|keys|webhooks|spec|status]\n referalli api <METHOD> <path> [--data JSON] [--secret-file PATH]\n referalli keys create --name NAME [--owner WHO] [--mode both|live|test] [--scopes full,\u2026] [--expires-days N]\n referalli keys list [--owner WHO] [--mode live|test]\n referalli keys revoke <key id> [--pair] [--cascade]\n referalli plan <referalli.yaml> [--check]\n referalli apply <referalli.yaml> [--plan] [--check] [--secret-file PATH]\n\nEnvironment:\n REFERALLI_API_KEY use this key instead of the saved login\n REFERALLI_API_URL API base URL (default: the hosted API)\n REFERALLI_CONFIG_DIR where the login is saved (default ~/.config/referalli)";
6
+ export declare const HELP = "referalli: the Referalli command line\n\nUsage:\n referalli login [--key rk_\u2026] [--base-url URL] [--no-browser]\n referalli logout\n referalli whoami\n referalli listen [--forward-to URL] [--events topic,topic] [--max-events N]\n referalli trigger <topic> [--data JSON]\n referalli trigger --billing <event> --connection <id> [--data JSON] (test mode; e.g. payment.paid)\n referalli trigger --stripe <event> --connection <id> [--data JSON] (test mode)\n referalli events tail [--events topic,topic] [--since 1h|ISO] [--json] [--max N]\n referalli logs tail [--max N]\n referalli open [docs|dashboard|keys|webhooks|spec|status]\n referalli api <METHOD> <path> [--data JSON] [--secret-file PATH]\n referalli keys create --name NAME [--owner WHO] [--mode both|live|test] [--scopes full,\u2026] [--expires-days N]\n referalli keys list [--owner WHO] [--mode live|test]\n referalli keys revoke <key id> [--pair] [--cascade]\n referalli plan <referalli.yaml> [--check]\n referalli apply <referalli.yaml> [--plan] [--check] [--secret-file PATH]\n referalli doctor [--program <id>] [--json]\n\nEnvironment:\n REFERALLI_API_KEY use this key instead of the saved login\n REFERALLI_API_URL API base URL (default: the hosted API)\n REFERALLI_CONFIG_DIR where the login is saved (default ~/.config/referalli)";
7
7
  /** Run one command; returns the process exit code. */
8
8
  export declare function runCli(argv: string[], io: Io): Promise<number>;
package/dist/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { parseArgs } from 'node:util';
2
2
  import { ApiError } from './client.js';
3
- import { api, apply, CliError, eventsTail, keys, login, listen, logout, logsTail, open, trigger, whoami } from './commands.js';
3
+ import { api, apply, CliError, doctor, eventsTail, keys, login, listen, logout, logsTail, open, trigger, whoami } from './commands.js';
4
4
  import { VERSION } from './version.js';
5
5
  export { readConfig, writeConfig, configPath } from './config.js';
6
6
  export { createClient, ApiError } from './client.js';
@@ -24,6 +24,7 @@ Usage:
24
24
  referalli keys revoke <key id> [--pair] [--cascade]
25
25
  referalli plan <referalli.yaml> [--check]
26
26
  referalli apply <referalli.yaml> [--plan] [--check] [--secret-file PATH]
27
+ referalli doctor [--program <id>] [--json]
27
28
 
28
29
  Environment:
29
30
  REFERALLI_API_KEY use this key instead of the saved login
@@ -51,6 +52,7 @@ export async function runCli(argv, io) {
51
52
  stripe: { type: 'string' },
52
53
  billing: { type: 'string' },
53
54
  connection: { type: 'string' },
55
+ program: { type: 'string' },
54
56
  'secret-file': { type: 'string' },
55
57
  name: { type: 'string' },
56
58
  owner: { type: 'string' },
@@ -114,6 +116,8 @@ export async function runCli(argv, io) {
114
116
  case 'plan':
115
117
  case 'apply':
116
118
  return await apply(io, rest[0], flags, command === 'plan');
119
+ case 'doctor':
120
+ return await doctor(io, flags);
117
121
  default:
118
122
  io.err(`Unknown command "${command}".`);
119
123
  io.err(HELP);
@@ -1,2 +1,2 @@
1
1
  /** Kept in step with package.json by test/version.test.ts. */
2
- export declare const VERSION = "0.3.3";
2
+ export declare const VERSION = "0.4.0";
@@ -1,2 +1,2 @@
1
1
  /** Kept in step with package.json by test/version.test.ts. */
2
- export const VERSION = '0.3.3';
2
+ export const VERSION = '0.4.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@referalli/cli",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "The Referalli command line: sign in, forward webhooks to localhost, trigger test events, tail events and API logs.",
5
5
  "license": "MIT",
6
6
  "type": "module",