reply-cli 0.2.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.
Files changed (109) hide show
  1. package/README.md +107 -144
  2. package/dist/api/headers.d.ts +4 -0
  3. package/dist/api/headers.js +13 -0
  4. package/dist/api/headers.js.map +1 -0
  5. package/dist/auth/oauth-flow.d.ts +38 -0
  6. package/dist/auth/oauth-flow.js +193 -0
  7. package/dist/auth/oauth-flow.js.map +1 -0
  8. package/dist/auth/pkce.d.ts +9 -0
  9. package/dist/auth/pkce.js +19 -0
  10. package/dist/auth/pkce.js.map +1 -0
  11. package/dist/auth/request-identity.d.ts +16 -0
  12. package/dist/auth/request-identity.js +67 -0
  13. package/dist/auth/request-identity.js.map +1 -0
  14. package/dist/auth/resolve.d.ts +23 -0
  15. package/dist/auth/resolve.js +55 -0
  16. package/dist/auth/resolve.js.map +1 -0
  17. package/dist/auth/status.d.ts +19 -0
  18. package/dist/auth/status.js +27 -0
  19. package/dist/auth/status.js.map +1 -0
  20. package/dist/auth/token.d.ts +29 -0
  21. package/dist/auth/token.js +39 -0
  22. package/dist/auth/token.js.map +1 -0
  23. package/dist/commands/api.d.ts +19 -0
  24. package/dist/commands/api.js +137 -0
  25. package/dist/commands/api.js.map +1 -0
  26. package/dist/commands/auth.d.ts +19 -3
  27. package/dist/commands/auth.js +251 -16
  28. package/dist/commands/auth.js.map +1 -1
  29. package/dist/commands/authed.d.ts +13 -0
  30. package/dist/commands/authed.js +20 -0
  31. package/dist/commands/authed.js.map +1 -0
  32. package/dist/commands/profile.d.ts +31 -0
  33. package/dist/commands/profile.js +348 -0
  34. package/dist/commands/profile.js.map +1 -0
  35. package/dist/commands/team.d.ts +17 -0
  36. package/dist/commands/team.js +146 -0
  37. package/dist/commands/team.js.map +1 -0
  38. package/dist/config.d.ts +14 -0
  39. package/dist/config.js +80 -0
  40. package/dist/config.js.map +1 -0
  41. package/dist/context.d.ts +15 -0
  42. package/dist/context.js +17 -0
  43. package/dist/context.js.map +1 -0
  44. package/dist/credentials/file-store.d.ts +13 -0
  45. package/dist/credentials/file-store.js +88 -0
  46. package/dist/credentials/file-store.js.map +1 -0
  47. package/dist/credentials/types.d.ts +25 -0
  48. package/dist/credentials/types.js +3 -0
  49. package/dist/credentials/types.js.map +1 -0
  50. package/dist/index.js +97 -69
  51. package/dist/index.js.map +1 -1
  52. package/dist/profile.d.ts +51 -0
  53. package/dist/profile.js +295 -0
  54. package/dist/profile.js.map +1 -0
  55. package/dist/teams.d.ts +14 -0
  56. package/dist/teams.js +103 -0
  57. package/dist/teams.js.map +1 -0
  58. package/dist/utils/client.d.ts +19 -34
  59. package/dist/utils/client.js +123 -94
  60. package/dist/utils/client.js.map +1 -1
  61. package/dist/utils/errors.d.ts +47 -0
  62. package/dist/utils/errors.js +86 -0
  63. package/dist/utils/errors.js.map +1 -0
  64. package/dist/utils/output.d.ts +7 -19
  65. package/dist/utils/output.js +39 -81
  66. package/dist/utils/output.js.map +1 -1
  67. package/package.json +10 -25
  68. package/dist/commands/contacts.d.ts +0 -35
  69. package/dist/commands/contacts.js +0 -412
  70. package/dist/commands/contacts.js.map +0 -1
  71. package/dist/commands/email-accounts.d.ts +0 -11
  72. package/dist/commands/email-accounts.js +0 -97
  73. package/dist/commands/email-accounts.js.map +0 -1
  74. package/dist/commands/inbox.d.ts +0 -30
  75. package/dist/commands/inbox.js +0 -225
  76. package/dist/commands/inbox.js.map +0 -1
  77. package/dist/commands/lists.d.ts +0 -20
  78. package/dist/commands/lists.js +0 -137
  79. package/dist/commands/lists.js.map +0 -1
  80. package/dist/commands/reports.d.ts +0 -10
  81. package/dist/commands/reports.js +0 -70
  82. package/dist/commands/reports.js.map +0 -1
  83. package/dist/commands/schedules.d.ts +0 -6
  84. package/dist/commands/schedules.js +0 -59
  85. package/dist/commands/schedules.js.map +0 -1
  86. package/dist/commands/sequence-contacts.d.ts +0 -19
  87. package/dist/commands/sequence-contacts.js +0 -129
  88. package/dist/commands/sequence-contacts.js.map +0 -1
  89. package/dist/commands/sequences-stats.d.ts +0 -42
  90. package/dist/commands/sequences-stats.js +0 -99
  91. package/dist/commands/sequences-stats.js.map +0 -1
  92. package/dist/commands/sequences.d.ts +0 -22
  93. package/dist/commands/sequences.js +0 -211
  94. package/dist/commands/sequences.js.map +0 -1
  95. package/dist/utils/auth.d.ts +0 -2
  96. package/dist/utils/auth.js +0 -33
  97. package/dist/utils/auth.js.map +0 -1
  98. package/dist/utils/command.d.ts +0 -18
  99. package/dist/utils/command.js +0 -51
  100. package/dist/utils/command.js.map +0 -1
  101. package/dist/utils/csv.d.ts +0 -19
  102. package/dist/utils/csv.js +0 -118
  103. package/dist/utils/csv.js.map +0 -1
  104. package/dist/utils/pagination.d.ts +0 -22
  105. package/dist/utils/pagination.js +0 -37
  106. package/dist/utils/pagination.js.map +0 -1
  107. package/dist/utils/resolve.d.ts +0 -4
  108. package/dist/utils/resolve.js +0 -34
  109. package/dist/utils/resolve.js.map +0 -1
@@ -0,0 +1,15 @@
1
+ import type { CredentialStore, Oauth_record } from './credentials/types';
2
+ type Cli_context = {
3
+ profile: string;
4
+ authority: string;
5
+ api_base: string;
6
+ key: string;
7
+ team_id?: number;
8
+ store: CredentialStore;
9
+ refresh: (record: Oauth_record) => Promise<Oauth_record>;
10
+ };
11
+ declare const build_context: (opts?: {
12
+ profile?: string;
13
+ }) => Cli_context;
14
+ export { build_context };
15
+ export type { Cli_context };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.build_context = void 0;
4
+ const profile_1 = require("./profile");
5
+ const file_store_1 = require("./credentials/file-store");
6
+ const oauth_flow_1 = require("./auth/oauth-flow");
7
+ const build_context = (opts = {}) => {
8
+ const p = (0, profile_1.resolve_profile)(opts.profile);
9
+ const store = (0, file_store_1.default_credential_store)();
10
+ const refresh = (record) => (0, oauth_flow_1.refresh_stored)({ authority: p.authority, record });
11
+ return {
12
+ profile: p.name, authority: p.authority, api_base: p.api_base,
13
+ key: p.name, team_id: p.team_id, store, refresh,
14
+ };
15
+ };
16
+ exports.build_context = build_context;
17
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAC1C,yDAAkE;AAClE,kDAAiD;AAgBjD,MAAM,aAAa,GAAG,CAAC,OAA2B,EAAE,EAAc,EAAE;IAChE,MAAM,CAAC,GAAG,IAAA,yBAAe,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,IAAA,qCAAwB,GAAE,CAAC;IACzC,MAAM,OAAO,GAAG,CAAC,MAAoB,EAAwB,EAAE,CAC3D,IAAA,2BAAc,EAAC,EAAC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM,EAAC,CAAC,CAAC;IACrD,OAAO;QACH,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ;QAC7D,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO;KAClD,CAAC;AACN,CAAC,CAAC;AAEM,sCAAa"}
@@ -0,0 +1,13 @@
1
+ import type { Credential_record, CredentialStore } from './types';
2
+ declare class FileCredentialStore implements CredentialStore {
3
+ private readonly file;
4
+ constructor(file: string);
5
+ get(key: string): Promise<Credential_record | undefined>;
6
+ set(key: string, record: Credential_record): Promise<void>;
7
+ remove(key: string): Promise<boolean>;
8
+ keys(): Promise<string[]>;
9
+ private read;
10
+ private write;
11
+ }
12
+ declare const default_credential_store: () => CredentialStore;
13
+ export { FileCredentialStore, default_credential_store };
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default_credential_store = exports.FileCredentialStore = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const config_1 = require("../config");
10
+ const errors_1 = require("../utils/errors");
11
+ // v1 credential backend: a single JSON file keyed by profile name, written
12
+ // with strict 0600 perms in a 0700 dir (the gh/aws/az plaintext-file model).
13
+ class FileCredentialStore {
14
+ file;
15
+ constructor(file) {
16
+ this.file = file;
17
+ }
18
+ async get(key) {
19
+ return this.read()[key];
20
+ }
21
+ async set(key, record) {
22
+ const map = this.read();
23
+ map[key] = record;
24
+ this.write(map);
25
+ }
26
+ async remove(key) {
27
+ const map = this.read();
28
+ if (!(key in map)) {
29
+ return false;
30
+ }
31
+ delete map[key];
32
+ this.write(map);
33
+ return true;
34
+ }
35
+ async keys() {
36
+ return Object.keys(this.read());
37
+ }
38
+ read() {
39
+ let raw;
40
+ try {
41
+ raw = fs_1.default.readFileSync(this.file, 'utf8');
42
+ }
43
+ catch (e) {
44
+ if (e.code === 'ENOENT') {
45
+ return {};
46
+ }
47
+ throw new errors_1.RuntimeError('Could not read the credential store.', {
48
+ code: 'store.read', detail: this.file,
49
+ hint: e.message,
50
+ });
51
+ }
52
+ if (!raw.trim()) {
53
+ return {};
54
+ }
55
+ let parsed;
56
+ try {
57
+ parsed = JSON.parse(raw);
58
+ }
59
+ catch {
60
+ throw new errors_1.RuntimeError('Credential store is corrupt (invalid JSON).', {
61
+ code: 'store.corrupt', detail: this.file,
62
+ hint: 'Delete the file and log in again.',
63
+ });
64
+ }
65
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
66
+ throw new errors_1.RuntimeError('Credential store is corrupt (unexpected shape).', {
67
+ code: 'store.corrupt', detail: this.file,
68
+ hint: 'Delete the file and log in again.',
69
+ });
70
+ }
71
+ return parsed;
72
+ }
73
+ // Atomic write: temp file created 0600, then renamed into place so the
74
+ // final file is never briefly world-readable and rewrites keep 0600.
75
+ write(map) {
76
+ const dir = path_1.default.dirname(this.file);
77
+ fs_1.default.mkdirSync(dir, { recursive: true, mode: 0o700 });
78
+ fs_1.default.chmodSync(dir, 0o700);
79
+ const tmp = `${this.file}.${process.pid}.tmp`;
80
+ fs_1.default.writeFileSync(tmp, JSON.stringify(map, null, 2), { mode: 0o600 });
81
+ fs_1.default.chmodSync(tmp, 0o600);
82
+ fs_1.default.renameSync(tmp, this.file);
83
+ }
84
+ }
85
+ exports.FileCredentialStore = FileCredentialStore;
86
+ const default_credential_store = () => new FileCredentialStore((0, config_1.credentials_file)());
87
+ exports.default_credential_store = default_credential_store;
88
+ //# sourceMappingURL=file-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-store.js","sourceRoot":"","sources":["../../src/credentials/file-store.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,sCAA2C;AAC3C,4CAA6C;AAK7C,2EAA2E;AAC3E,6EAA6E;AAC7E,MAAM,mBAAmB;IACJ,IAAI,CAAS;IAE9B,YAAY,IAAY;QAEpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QAEjB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,MAAyB;QAE5C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACxB,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,EACjB,CAAC;YACG,OAAO,KAAK,CAAC;QACjB,CA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,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI;gBACxC,IAAI,EAAE,mCAAmC;aAC5C,CAAC,CAAC;QACP,CAAC;QACD,OAAO,MAAiB,CAAC;IAC7B,CAAC;IAED,uEAAuE;IACvE,qEAAqE;IAC7D,KAAK,CAAC,GAAY;QAEtB,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC;QAClD,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,MAAM,CAAC;QAC9C,YAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC;QACnE,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,YAAE,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACJ;AAKO,kDAAmB;AAH3B,MAAM,wBAAwB,GAAG,GAAmB,EAAE,CAClD,IAAI,mBAAmB,CAAC,IAAA,yBAAgB,GAAE,CAAC,CAAC;AAEnB,4DAAwB"}
@@ -0,0 +1,25 @@
1
+ type Principal = {
2
+ id?: number;
3
+ username?: string;
4
+ team_id?: number;
5
+ };
6
+ type Oauth_record = {
7
+ type: 'oauth';
8
+ access_token: string;
9
+ refresh_token?: string;
10
+ expires_at: number;
11
+ user?: Principal;
12
+ };
13
+ type Api_key_record = {
14
+ type: 'api_key';
15
+ key: string;
16
+ user?: Principal;
17
+ };
18
+ type Credential_record = Oauth_record | Api_key_record;
19
+ interface CredentialStore {
20
+ get(key: string): Promise<Credential_record | undefined>;
21
+ set(key: string, record: Credential_record): Promise<void>;
22
+ remove(key: string): Promise<boolean>;
23
+ keys(): Promise<string[]>;
24
+ }
25
+ export type { Principal, Oauth_record, Api_key_record, Credential_record, CredentialStore };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/credentials/types.ts"],"names":[],"mappings":""}
package/dist/index.js CHANGED
@@ -1,97 +1,125 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
3
  Object.defineProperty(exports, "__esModule", { value: true });
7
4
  exports.build_program = void 0;
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
5
  const commander_1 = require("commander");
11
- const client_1 = require("./utils/client");
6
+ const config_1 = require("./config");
12
7
  const auth_1 = require("./commands/auth");
13
- const contacts_1 = require("./commands/contacts");
14
- const lists_1 = require("./commands/lists");
15
- const sequences_1 = require("./commands/sequences");
16
- const sequences_stats_1 = require("./commands/sequences-stats");
17
- const sequence_contacts_1 = require("./commands/sequence-contacts");
18
- const inbox_1 = require("./commands/inbox");
19
- const reports_1 = require("./commands/reports");
20
- const email_accounts_1 = require("./commands/email-accounts");
21
- const schedules_1 = require("./commands/schedules");
22
- const read_version = () => {
23
- try {
24
- const pkg = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../package.json'), 'utf-8'));
25
- return pkg.version || '0.0.0';
26
- }
27
- catch {
28
- return '0.0.0';
8
+ const profile_1 = require("./commands/profile");
9
+ const team_1 = require("./commands/team");
10
+ const api_1 = require("./commands/api");
11
+ const errors_1 = require("./utils/errors");
12
+ const output_1 = require("./utils/output");
13
+ // Route every command through commander's throwing mode so usage errors reach
14
+ // our handler and map to exit code 2 (vs 1 for runtime/API failures).
15
+ const set_exit_override = (cmd) => {
16
+ cmd.exitOverride();
17
+ for (const sub of cmd.commands) {
18
+ set_exit_override(sub);
29
19
  }
30
20
  };
31
21
  const build_program = () => {
32
22
  const program = new commander_1.Command();
23
+ const PREFIX = config_1.PROGRAM_NAME.toUpperCase();
33
24
  program
34
- .name('reply')
35
- .description('Command-line interface for the Reply.io v3 API. Manage contacts,\n'
36
- + 'lists, sequences, inbox, and reports from your terminal.')
37
- .version(read_version(), '-v, --version')
38
- .option('-k, --api-key <key>', 'Reply.io API key (overrides env/config)')
39
- .option('--timing', 'Show request timing')
40
- .option('--json', 'Output as compact JSON')
41
- .option('--pretty', 'Output as formatted JSON');
42
- // stats and contacts are subcommands of sequences
43
- sequences_1.sequences_command.addCommand(sequences_stats_1.sequences_stats_command);
44
- sequences_1.sequences_command.addCommand(sequence_contacts_1.sequence_contacts_command);
25
+ .name(config_1.PROGRAM_NAME)
26
+ .description('Command-line interface for Reply.io — authentication and identity (v1).')
27
+ .version((0, config_1.cli_version)(), '-v, --version')
28
+ .option('-k, --api-key <key>', 'API key (overrides env var and stored credential)')
29
+ .option('-p, --profile <name>', 'Named backend profile (default: prod)')
30
+ .option('--team-id <id>', `Team/workspace to act in (X-TEAM-ID); else ${PREFIX}_TEAM_ID or the profile`)
31
+ .option('--user-id <id>', 'Act as this user id — organization API keys only (X-USER-ID)')
32
+ .option('--user-email <email>', 'Act as this user email — organization API keys only (needs a team id)')
33
+ .option('--json', 'Output compact JSON to stdout')
34
+ .option('--pretty', 'Output indented JSON to stdout')
35
+ .option('--verbose', 'Print the full request/response to stderr, credentials redacted (api)')
36
+ .option('-q, --quiet', 'Suppress progress messages on stderr (warnings and errors still shown)')
37
+ .showHelpAfterError();
38
+ // Apply --quiet before any command action runs, so progress output is
39
+ // silenced for the whole invocation.
40
+ program.hook('preAction', () => { (0, output_1.set_quiet)(program.opts().quiet === true); });
45
41
  program.addCommand(auth_1.auth_command);
46
- program.addCommand(contacts_1.contacts_command);
47
- program.addCommand(lists_1.lists_command);
48
- program.addCommand(sequences_1.sequences_command);
49
- program.addCommand(inbox_1.inbox_command);
50
- program.addCommand(reports_1.reports_command);
51
- program.addCommand(email_accounts_1.email_accounts_command);
52
- program.addCommand(schedules_1.schedules_command);
42
+ program.addCommand(profile_1.profile_command);
43
+ program.addCommand(team_1.team_command);
44
+ program.addCommand(api_1.api_command);
53
45
  program.addHelpText('after', `
54
- Command Groups:
55
- auth Verify authentication (whoami)
56
- contacts Manage contacts (list, get, create, update, delete, search, statuses, import)
57
- lists Manage contact lists (list, get, create, add-contacts)
58
- sequences Manage sequences (list, get, create, update, start, pause, archive)
59
- sequences stats Sequence performance (single or all sequences, --top)
60
- sequences contacts Contacts within a sequence (list, add, remove)
61
- inbox Threads and replies (threads list/get, reply, categories)
62
- reports Account-level reports (emails, sequences)
63
- email-accounts Connected sending accounts (list, check)
64
- schedules Sending schedules (list, get)
46
+ Credential precedence:
47
+ 1. --api-key <key> 2. ${PREFIX}_API_KEY env 3. stored credential
48
+
49
+ Profiles (which backend to talk to):
50
+ Precedence: --profile <name> > ${PREFIX}_PROFILE > current profile > default (prod).
51
+ Define your own profiles under "profiles" in the config file, e.g.:
52
+ { "profiles": { "dev": { "authority": "https://…", "api_base": "https://…" } } }
53
+ Then set one as current so you don't repeat --profile:
54
+ ${config_1.PROGRAM_NAME} profile use dev # used until you change it
55
+ ${config_1.PROGRAM_NAME} profile list # see all, * marks current
56
+ ${config_1.PROGRAM_NAME} profile current
57
+ ${config_1.PROGRAM_NAME} profile show [name] # backend, team, auth (no secrets)
58
+ ${config_1.PROGRAM_NAME} profile rename <old> <new>
59
+ ${config_1.PROGRAM_NAME} profile delete <name> # also removes its stored credential
60
+ ${config_1.PROGRAM_NAME} profile unset <name> <field> # clear authority|api_base|team-id
65
61
 
66
- Authentication:
67
- Set REPLY_API_KEY in your .env file, environment, or pass --api-key.
68
- Same API key as the Reply.io web app (Settings → API Keys). Verify: reply auth whoami
62
+ Team & acting user (headers):
63
+ --team-id <id> Team/workspace to act in. Precedence: --team-id > ${PREFIX}_TEAM_ID > profile team_id.
64
+ Pin one on a profile: ${config_1.PROGRAM_NAME} profile set <name> --team-id <id>
65
+ --user-id <id> / --user-email <email> Identify the acting user for an ORGANIZATION API key.
66
+ Flag-only (never env, never stored); pass exactly one; --user-email also needs a team id.
67
+ Team commands (see & set the current profile's team):
68
+ ${config_1.PROGRAM_NAME} team list # teams you can act in (* marks the profile's)
69
+ ${config_1.PROGRAM_NAME} team current # pinned + effective team
70
+ ${config_1.PROGRAM_NAME} team use <id> # pin a team on the current profile
71
+ ${config_1.PROGRAM_NAME} team clear # remove the pin
69
72
 
70
- Output & safety:
71
- --json for machine-readable output. Write commands prompt for confirmation;
72
- pass --yes in scripts. Bulk commands support --dry-run.
73
+ Raw API (agent/CI escape hatch) — docs: https://docs.reply.io/api-reference/introduction
74
+ Use the path as in the docs (starts with /v3); the query string goes in the path.
75
+ ${config_1.PROGRAM_NAME} api /v3/whoami # GET your identity + team
76
+ ${config_1.PROGRAM_NAME} api /v3/sequences # GET list of sequences
77
+ ${config_1.PROGRAM_NAME} api /v3/contacts --body @c.json # POST (a body switches method; schema per docs)
78
+ ${config_1.PROGRAM_NAME} api /v3/whoami --verbose # full req/resp to stderr (creds redacted)
79
+ Prints {code, data}; exits non-zero on HTTP >= 400.
73
80
 
74
- Coming soon (not yet in the API): prospect search, contact enrichment.
81
+ Configuration (env vars):
82
+ ${PREFIX}_API_KEY API key used as the bearer credential
83
+ ${PREFIX}_PROFILE Profile to use (same as --profile)
84
+ ${PREFIX}_TEAM_ID Team/workspace id (same as --team-id)
85
+ ${PREFIX}_CONFIG_DIR Override the per-user config directory
75
86
 
76
87
  Examples:
77
- reply auth whoami
78
- reply contacts import prospects.csv --dry-run
79
- reply sequences list --status active --json
80
- reply sequences contacts add 12345 --contacts john@co.com --dry-run
81
- reply inbox threads list --unread
88
+ ${config_1.PROGRAM_NAME} auth login
89
+ echo <key> | ${config_1.PROGRAM_NAME} auth login --with-token
90
+ ${config_1.PROGRAM_NAME} --profile dev auth whoami --json
91
+ ${config_1.PROGRAM_NAME} auth status
92
+ ${config_1.PROGRAM_NAME} team list
93
+ ${config_1.PROGRAM_NAME} api /v3/sequences
82
94
  `);
83
95
  return program;
84
96
  };
85
97
  exports.build_program = build_program;
86
98
  const wants_json = () => process.argv.includes('--json') || process.argv.includes('--pretty');
87
99
  const main = async () => {
88
- await build_program().parseAsync(process.argv);
100
+ const program = build_program();
101
+ set_exit_override(program);
102
+ await program.parseAsync(process.argv);
89
103
  };
90
- void main().catch(error => {
91
- if (error instanceof client_1.Api_error && wants_json())
92
- console.error(JSON.stringify(error.to_json()));
93
- else
94
- console.error(error instanceof Error ? error.message : error);
104
+ void main().catch((error) => {
105
+ if (error instanceof commander_1.CommanderError) {
106
+ // commander has already written help/usage text; help & version exit 0,
107
+ // any other usage problem exits 2.
108
+ const ok = error.code === 'commander.helpDisplayed'
109
+ || error.code === 'commander.version'
110
+ || error.code === 'commander.help';
111
+ process.exit(ok ? 0 : 2);
112
+ }
113
+ if (error instanceof errors_1.CliError) {
114
+ if (wants_json()) {
115
+ console.error(JSON.stringify(error.to_json()));
116
+ }
117
+ else {
118
+ console.error(error.message);
119
+ }
120
+ process.exit(error.exit_code);
121
+ }
122
+ console.error(error instanceof Error ? error.message : String(error));
95
123
  process.exit(1);
96
124
  });
97
125
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AACA,4CAAoB;AACpB,gDAAwB;AACxB,yCAAkC;AAClC,2CAAyC;AACzC,0CAA6C;AAC7C,kDAAqD;AACrD,4CAA+C;AAC/C,oDAAuD;AACvD,gEAAmE;AACnE,oEAAuE;AACvE,4CAA+C;AAC/C,gDAAmD;AACnD,8DAAiE;AACjE,oDAAuD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AC,CAAC;IAC7B,CAAC;IACD,IAAI,KAAK,YAAY,iBAAQ,EAC7B,CAAC;QACG,IAAI,UAAU,EAAE,EAChB,CAAC;YACG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACnD,CAAC;aAED,CAAC;YACG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { type Env } from './config';
2
+ type Profile = {
3
+ name: string;
4
+ authority: string;
5
+ api_base: string;
6
+ team_id?: number;
7
+ };
8
+ declare const EMBEDDED: {
9
+ authority: string;
10
+ api_base: string;
11
+ };
12
+ declare const PROD: {
13
+ authority: string;
14
+ api_base: string;
15
+ };
16
+ declare const resolve_profile: (flag?: string, env?: Env) => Profile;
17
+ declare const current_profile_name: (env?: Env) => string;
18
+ type Profile_description = {
19
+ name: string;
20
+ authority: string;
21
+ api_base: string;
22
+ team_id?: number;
23
+ is_current: boolean;
24
+ inherited: {
25
+ authority: boolean;
26
+ api_base: boolean;
27
+ };
28
+ };
29
+ declare const describe_profile: (name: string, env?: Env) => Profile_description;
30
+ declare const list_profiles: (env?: Env) => {
31
+ current: string;
32
+ available: string[];
33
+ };
34
+ type Profile_fields = {
35
+ authority?: string;
36
+ api_base?: string;
37
+ team_id?: number;
38
+ };
39
+ type Clearable_field = 'authority' | 'api_base' | 'team_id';
40
+ declare const add_profile: (name: string, fields: Profile_fields, env?: Env) => void;
41
+ declare const set_profile: (name: string, fields: Profile_fields, env?: Env) => void;
42
+ declare const rename_profile_def: (old_name: string, new_name: string, env?: Env) => void;
43
+ declare const delete_profile_def: (name: string, env?: Env) => {
44
+ was_current: boolean;
45
+ };
46
+ declare const unset_profile_field: (name: string, field: Clearable_field, env?: Env) => {
47
+ changed: boolean;
48
+ };
49
+ declare const set_current_profile: (name: string, env?: Env) => void;
50
+ export { resolve_profile, current_profile_name, list_profiles, set_current_profile, add_profile, set_profile, rename_profile_def, delete_profile_def, unset_profile_field, describe_profile, EMBEDDED, PROD };
51
+ export type { Profile, Profile_fields, Clearable_field, Profile_description };