trackrev 0.1.0 → 0.3.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/README.md +988 -42
- package/package.json +21 -3
- package/src/commands/affiliates.js +162 -0
- package/src/commands/analytics.js +128 -0
- package/src/commands/attribution.js +55 -0
- package/src/commands/auth.js +41 -0
- package/src/commands/domains.js +60 -0
- package/src/commands/folders.js +69 -0
- package/src/commands/keys.js +54 -0
- package/src/commands/links.js +203 -0
- package/src/commands/me.js +25 -0
- package/src/commands/money.js +96 -0
- package/src/commands/people.js +94 -0
- package/src/commands/retargeting.js +49 -0
- package/src/commands/revenue.js +87 -0
- package/src/commands/settings.js +64 -0
- package/src/commands/webhooks.js +79 -0
- package/src/index.js +43 -294
- package/src/lib/api.js +87 -0
- package/src/lib/config.js +52 -0
- package/src/lib/output.js +95 -0
- package/src/lib/prompt.js +55 -0
- package/src/registry.d.ts +58 -0
- package/src/registry.js +840 -0
- package/src/sdk/client.js +177 -0
- package/src/sdk/index.d.ts +534 -0
- package/src/sdk/index.js +1 -0
- package/src/sdk/resources/attribution.js +20 -0
- package/src/sdk/resources/channels.js +16 -0
- package/src/sdk/resources/clicks.js +16 -0
- package/src/sdk/resources/commissions.js +40 -0
- package/src/sdk/resources/credits.js +23 -0
- package/src/sdk/resources/domains.js +35 -0
- package/src/sdk/resources/export.js +15 -0
- package/src/sdk/resources/folders.js +55 -0
- package/src/sdk/resources/keys.js +28 -0
- package/src/sdk/resources/links.js +131 -0
- package/src/sdk/resources/orders.js +15 -0
- package/src/sdk/resources/partners.js +37 -0
- package/src/sdk/resources/payouts.js +22 -0
- package/src/sdk/resources/programs.js +55 -0
- package/src/sdk/resources/referrals.js +83 -0
- package/src/sdk/resources/retargeting.js +23 -0
- package/src/sdk/resources/revenue.js +53 -0
- package/src/sdk/resources/settings.js +29 -0
- package/src/sdk/resources/visitors.js +25 -0
- package/src/sdk/resources/webhooks.js +41 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
2
|
+
import { EXIT, die } from "./api.js";
|
|
3
|
+
|
|
4
|
+
const CTRL_C = String.fromCharCode(3);
|
|
5
|
+
const BACKSPACE = String.fromCharCode(127);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Yes/no on stderr (stdout stays pipe-clean). `--yes` skips it; without a TTY
|
|
9
|
+
* and without --yes we refuse rather than hang a script waiting for a keypress.
|
|
10
|
+
*/
|
|
11
|
+
export async function confirm(question, { yes } = {}) {
|
|
12
|
+
if (yes) return true;
|
|
13
|
+
if (!process.stdin.isTTY) {
|
|
14
|
+
die(`${question}\nRefusing to run a destructive command non-interactively. Pass --yes.`, EXIT.USAGE);
|
|
15
|
+
}
|
|
16
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
17
|
+
const answer = await new Promise((resolve) => rl.question(`${question} [y/N] `, resolve));
|
|
18
|
+
rl.close();
|
|
19
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Read a secret without echoing it. */
|
|
23
|
+
export function promptSecret(label) {
|
|
24
|
+
if (!process.stdin.isTTY) {
|
|
25
|
+
die("No terminal to prompt on. Pass --key or set TRACKREV_KEY.", EXIT.USAGE);
|
|
26
|
+
}
|
|
27
|
+
process.stderr.write(`${label}: `);
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
const { stdin } = process;
|
|
30
|
+
stdin.setRawMode(true);
|
|
31
|
+
stdin.resume();
|
|
32
|
+
stdin.setEncoding("utf8");
|
|
33
|
+
let buf = "";
|
|
34
|
+
const onData = (ch) => {
|
|
35
|
+
if (ch === CTRL_C) {
|
|
36
|
+
process.stderr.write("\n");
|
|
37
|
+
process.exit(EXIT.USAGE);
|
|
38
|
+
}
|
|
39
|
+
if (ch === "\r" || ch === "\n") {
|
|
40
|
+
stdin.setRawMode(false);
|
|
41
|
+
stdin.pause();
|
|
42
|
+
stdin.off("data", onData);
|
|
43
|
+
process.stderr.write("\n");
|
|
44
|
+
resolve(buf);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (ch === BACKSPACE || ch === "\b") {
|
|
48
|
+
buf = buf.slice(0, -1);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
buf += ch;
|
|
52
|
+
};
|
|
53
|
+
stdin.on("data", onData);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface CliFlag {
|
|
2
|
+
name: string;
|
|
3
|
+
type: "string" | "boolean";
|
|
4
|
+
meaning: string;
|
|
5
|
+
/** Placeholder shown after the flag in help, e.g. "N", "ISO", "URL". */
|
|
6
|
+
arg?: string;
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
default?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The heading a command is filed under in `trackrev --help`, on /cli, on
|
|
13
|
+
* /agents and in the generated README tables. Kept in lockstep with the
|
|
14
|
+
* `group:` values in registry.js — a group that exists there but not here is
|
|
15
|
+
* invisible to every TypeScript consumer that filters by group.
|
|
16
|
+
*/
|
|
17
|
+
export type CliGroup =
|
|
18
|
+
| "Analytics"
|
|
19
|
+
| "Links"
|
|
20
|
+
| "Developers"
|
|
21
|
+
| "Setup"
|
|
22
|
+
| "Revenue"
|
|
23
|
+
| "Audience"
|
|
24
|
+
| "Domains"
|
|
25
|
+
| "Affiliate"
|
|
26
|
+
| "Money"
|
|
27
|
+
| "Settings"
|
|
28
|
+
| "Account";
|
|
29
|
+
|
|
30
|
+
export interface CliCommand {
|
|
31
|
+
noun: string;
|
|
32
|
+
verb: string | null;
|
|
33
|
+
group: CliGroup;
|
|
34
|
+
summary: string;
|
|
35
|
+
example: string;
|
|
36
|
+
args: string[];
|
|
37
|
+
flags: CliFlag[];
|
|
38
|
+
module: string;
|
|
39
|
+
handler: string;
|
|
40
|
+
paid: boolean;
|
|
41
|
+
destructive?: boolean;
|
|
42
|
+
aliases?: string[];
|
|
43
|
+
bareNoun?: boolean;
|
|
44
|
+
note?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const VERSION: string;
|
|
48
|
+
export const GLOBAL_FLAGS: CliFlag[];
|
|
49
|
+
export const COMMANDS: CliCommand[];
|
|
50
|
+
export function usageOf(cmd: CliCommand): string;
|
|
51
|
+
export function flagLabel(f: CliFlag): string;
|
|
52
|
+
export function resolve(
|
|
53
|
+
noun: string | undefined,
|
|
54
|
+
verb: string | undefined,
|
|
55
|
+
): { command: CliCommand; consumed: number } | null;
|
|
56
|
+
export function optionsFor(cmd: CliCommand | null): Record<string, unknown>;
|
|
57
|
+
export function helpText(): string;
|
|
58
|
+
export function helpFor(cmd: CliCommand): string;
|