@referalli/cli 0.1.0 → 0.2.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 +7 -0
- package/README.md +1 -0
- package/dist/src/commands.d.ts +2 -0
- package/dist/src/commands.js +43 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,14 @@ 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.2.0 - 2026-10-24
|
|
9
|
+
|
|
10
|
+
- API 2026-11-01 additions: 56 new operations (inbound signup connectors, billing product filters, per-org SSO and partner-portal sign-in, support-tool context cards, data-rights executors, account closure, rewards, integration health, plans, the event feed and bulk webhook replay) and 2 webhook topics (`webhook_endpoint.failing`, `webhook_endpoint.recovered`).
|
|
11
|
+
- New error code `reauth_required` (401): sign in again before changing payout details.
|
|
12
|
+
- `events tail --since` backfills from `/v1/events` before tailing live.
|
|
13
|
+
|
|
8
14
|
## [Unreleased]
|
|
9
15
|
|
|
10
16
|
### Added
|
|
11
17
|
- First public release: `referalli login`, `whoami`, `keys`, `listen --forward-to`, `trigger`, `events tail`, `logs tail`, `api` and `open`.
|
|
18
|
+
- `events tail --since 1h` (or an ISO time) prints the events since then from `GET /v1/events`, then tails live without repeating them.
|
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ A triggered event is sent to every running `listen` session and to your webhook
|
|
|
45
45
|
```sh
|
|
46
46
|
referalli events tail # every event, one line each
|
|
47
47
|
referalli events tail --events payout.sent --json # full event bodies, for piping into jq
|
|
48
|
+
referalli events tail --since 2h # backfill the last two hours, then tail live
|
|
48
49
|
referalli logs tail # your API requests: method, path, status, latency
|
|
49
50
|
```
|
|
50
51
|
|
package/dist/src/commands.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export declare function listen(io: Io, flags: Flags): Promise<number>;
|
|
|
25
25
|
* `listen` does, without forwarding, and closes it on exit.
|
|
26
26
|
*/
|
|
27
27
|
export declare function eventsTail(io: Io, flags: Flags): Promise<number>;
|
|
28
|
+
/** `--since`: an ISO time, or a duration back from now (`30m`, `2h`, `7d`). */
|
|
29
|
+
export declare function parseSince(raw: string, now: Date): Date;
|
|
28
30
|
export declare const OPEN_TARGETS: Record<string, string>;
|
|
29
31
|
/** `referalli open [docs|dashboard|keys|webhooks|spec|status]`: open the page, or print it. */
|
|
30
32
|
export declare function open(io: Io, target: string | undefined, flags: Flags): Promise<number>;
|
package/dist/src/commands.js
CHANGED
|
@@ -132,10 +132,38 @@ export async function eventsTail(io, flags) {
|
|
|
132
132
|
const topics = typeof flags.events === 'string' ? flags.events.split(',').map((s) => s.trim()).filter(Boolean) : undefined;
|
|
133
133
|
const max = typeof flags.max === 'string' ? Number(flags.max) : Infinity;
|
|
134
134
|
const wait = typeof flags.wait === 'string' ? Number(flags.wait) : 20;
|
|
135
|
+
const since = typeof flags.since === 'string' ? parseSince(flags.since, new Date()) : null;
|
|
136
|
+
// Open the listener first so nothing emitted during the backfill is missed.
|
|
135
137
|
const listener = await client.request('POST', '/v1/cli/listeners', topics ? { topics } : {});
|
|
138
|
+
let seen = 0;
|
|
139
|
+
const backfilled = new Set();
|
|
140
|
+
if (since) {
|
|
141
|
+
if (!flags.json)
|
|
142
|
+
io.err(`Events since ${since.toISOString()}:`);
|
|
143
|
+
let after = null;
|
|
144
|
+
do {
|
|
145
|
+
const qs = new URLSearchParams({ since: since.toISOString(), limit: '100' });
|
|
146
|
+
if (topics)
|
|
147
|
+
qs.set('topics', topics.join(','));
|
|
148
|
+
if (after)
|
|
149
|
+
qs.set('after', after);
|
|
150
|
+
const page = await client.request('GET', `/v1/events?${qs.toString()}`, undefined, { signal: io.signal });
|
|
151
|
+
for (const e of page.events) {
|
|
152
|
+
if (seen >= max)
|
|
153
|
+
break;
|
|
154
|
+
seen++;
|
|
155
|
+
backfilled.add(e.id);
|
|
156
|
+
const body = JSON.stringify(e);
|
|
157
|
+
if (flags.json)
|
|
158
|
+
io.out(body);
|
|
159
|
+
else
|
|
160
|
+
io.out(`${time(new Date(e.createdAt))} ${e.topic.padEnd(24)} ${e.id}${summarize(body)}`);
|
|
161
|
+
}
|
|
162
|
+
after = page.nextCursor;
|
|
163
|
+
} while (after && seen < max && !io.signal.aborted);
|
|
164
|
+
}
|
|
136
165
|
if (!flags.json)
|
|
137
166
|
io.err(`Tailing ${listener.topics.join(', ')} (Ctrl-C to stop)…`);
|
|
138
|
-
let seen = 0;
|
|
139
167
|
try {
|
|
140
168
|
while (!io.signal.aborted && seen < max) {
|
|
141
169
|
let batch;
|
|
@@ -152,6 +180,8 @@ export async function eventsTail(io, flags) {
|
|
|
152
180
|
continue;
|
|
153
181
|
}
|
|
154
182
|
for (const e of batch) {
|
|
183
|
+
if (backfilled.has(e.eventId))
|
|
184
|
+
continue; // already printed by the backfill
|
|
155
185
|
seen++;
|
|
156
186
|
if (flags.json)
|
|
157
187
|
io.out(e.body);
|
|
@@ -167,6 +197,18 @@ export async function eventsTail(io, flags) {
|
|
|
167
197
|
}
|
|
168
198
|
return 0;
|
|
169
199
|
}
|
|
200
|
+
/** `--since`: an ISO time, or a duration back from now (`30m`, `2h`, `7d`). */
|
|
201
|
+
export function parseSince(raw, now) {
|
|
202
|
+
const m = /^(\d+)\s*([mhd])$/i.exec(raw.trim());
|
|
203
|
+
if (m) {
|
|
204
|
+
const unit = { m: 60_000, h: 3_600_000, d: 86_400_000 }[m[2].toLowerCase()];
|
|
205
|
+
return new Date(now.getTime() - Number(m[1]) * unit);
|
|
206
|
+
}
|
|
207
|
+
const d = new Date(raw);
|
|
208
|
+
if (Number.isNaN(d.getTime()))
|
|
209
|
+
throw new CliError('--since takes a duration (30m, 2h, 7d) or an ISO 8601 time');
|
|
210
|
+
return d;
|
|
211
|
+
}
|
|
170
212
|
/** A short "key=value" tail for an event line: the ids and amounts a developer looks for. */
|
|
171
213
|
function summarize(body) {
|
|
172
214
|
try {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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 events tail [--events topic,topic] [--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]\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\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 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]\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\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,7 +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 events tail [--events topic,topic] [--json] [--max N]
|
|
16
|
+
referalli events tail [--events topic,topic] [--since 1h|ISO] [--json] [--max N]
|
|
17
17
|
referalli logs tail [--max N]
|
|
18
18
|
referalli open [docs|dashboard|keys|webhooks|spec|status]
|
|
19
19
|
referalli api <METHOD> <path> [--data JSON]
|
|
@@ -39,6 +39,7 @@ export async function runCli(argv, io) {
|
|
|
39
39
|
'no-browser': { type: 'boolean' },
|
|
40
40
|
'forward-to': { type: 'string' },
|
|
41
41
|
events: { type: 'string' },
|
|
42
|
+
since: { type: 'string' },
|
|
42
43
|
'max-events': { type: 'string' },
|
|
43
44
|
max: { type: 'string' },
|
|
44
45
|
wait: { type: 'string' },
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Kept in step with package.json by test/version.test.ts. */
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.2.0";
|
package/dist/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Kept in step with package.json by test/version.test.ts. */
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.2.0';
|
package/package.json
CHANGED