@referalli/cli 0.3.2 → 0.3.3

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,10 @@ 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.3.3 - 2026-11-02
9
+
10
+ - `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.
11
+
8
12
  ## 0.3.2 - 2026-11-02
9
13
 
10
14
  - `apply` sends `waitForCustomer` under `stripeCredits` (the API replaces all credit settings on save, so leaving it out turns it off; the plan shows it).
@@ -247,8 +247,10 @@ export async function open(io, target, flags) {
247
247
  // --- trigger -----------------------------------------------------------------------
248
248
  export async function trigger(io, topic, flags) {
249
249
  const { client } = signedIn(io);
250
+ if (typeof flags.billing === 'string')
251
+ return triggerBilling(io, client, flags.billing, flags, 'billing');
250
252
  if (typeof flags.stripe === 'string')
251
- return triggerStripe(io, client, flags.stripe, flags);
253
+ return triggerBilling(io, client, flags.stripe, flags, 'stripe');
252
254
  if (!topic) {
253
255
  const { topics } = await client.request('GET', '/v1/cli/topics');
254
256
  throw new CliError(`Usage: referalli trigger <topic>. Topics: ${topics.join(', ')}`);
@@ -266,10 +268,13 @@ export async function trigger(io, topic, flags) {
266
268
  io.out(`Triggered ${topic} [${res.eventId}]: ${res.deliveredTo.listeners} listener(s), ${res.deliveredTo.endpoints} webhook endpoint(s).`);
267
269
  return 0;
268
270
  }
269
- /** `trigger --stripe <event> --connection <id> [--data overrides]`: a Stripe fixture into a test-mode billing connection. */
270
- async function triggerStripe(io, client, event, flags) {
271
+ /**
272
+ * `trigger --billing <event> --connection <id> [--data overrides]`: a provider event fixture into a
273
+ * test-mode billing connection (the provider is the connection's). `--stripe` is the Stripe-only original.
274
+ */
275
+ async function triggerBilling(io, client, event, flags, flag) {
271
276
  if (typeof flags.connection !== 'string') {
272
- throw new CliError('Usage: referalli trigger --stripe <event> --connection <billing connection id> [--data JSON]');
277
+ throw new CliError(`Usage: referalli trigger --${flag} <event> --connection <billing connection id> [--data JSON]`);
273
278
  }
274
279
  let overrides = {};
275
280
  if (typeof flags.data === 'string') {
@@ -282,9 +287,10 @@ async function triggerStripe(io, client, event, flags) {
282
287
  }
283
288
  // `eventId` in --data replays that event instead of sending a new one.
284
289
  const { eventId, ...rest } = overrides;
285
- const res = await client.request('POST', '/v1/sandbox/stripe-fixtures', { connectionId: flags.connection, event, overrides: rest, ...(eventId !== undefined ? { eventId } : {}) });
290
+ const res = await client.request('POST', `/v1/sandbox/${flag}-fixtures`, { connectionId: flags.connection, event, overrides: rest, ...(eventId !== undefined ? { eventId } : {}) });
286
291
  const dup = res.results.some((r) => r.duplicate) ? ' (duplicate)' : '';
287
- io.out(`Sent ${event} [${res.eventId}]${dup}: ${res.received} billing event(s), ${res.commissions.length} commission event(s).`);
292
+ const what = flag === 'billing' && res.provider ? `${event} (${res.provider} ${res.nativeEvent})` : event;
293
+ io.out(`Sent ${what} [${res.eventId}]${dup}: ${res.received} billing event(s), ${res.commissions.length} commission event(s).`);
288
294
  for (const c of res.commissions)
289
295
  io.out(` ${c.type} ${c.amountMinor} ${c.currency} ${c.id}`);
290
296
  return 0;
@@ -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 --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\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
@@ -13,6 +13,7 @@ Usage:
13
13
  referalli whoami
14
14
  referalli listen [--forward-to URL] [--events topic,topic] [--max-events N]
15
15
  referalli trigger <topic> [--data JSON]
16
+ referalli trigger --billing <event> --connection <id> [--data JSON] (test mode; e.g. payment.paid)
16
17
  referalli trigger --stripe <event> --connection <id> [--data JSON] (test mode)
17
18
  referalli events tail [--events topic,topic] [--since 1h|ISO] [--json] [--max N]
18
19
  referalli logs tail [--max N]
@@ -48,6 +49,7 @@ export async function runCli(argv, io) {
48
49
  wait: { type: 'string' },
49
50
  data: { type: 'string' },
50
51
  stripe: { type: 'string' },
52
+ billing: { type: 'string' },
51
53
  connection: { type: 'string' },
52
54
  'secret-file': { type: 'string' },
53
55
  name: { type: 'string' },
@@ -1,2 +1,2 @@
1
1
  /** Kept in step with package.json by test/version.test.ts. */
2
- export declare const VERSION = "0.3.2";
2
+ export declare const VERSION = "0.3.3";
@@ -1,2 +1,2 @@
1
1
  /** Kept in step with package.json by test/version.test.ts. */
2
- export const VERSION = '0.3.2';
2
+ export const VERSION = '0.3.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@referalli/cli",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
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",