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,348 @@
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.parse_url = exports.handle_show = exports.handle_delete = exports.handle_rename = exports.profile_command = void 0;
7
+ const readline_1 = __importDefault(require("readline"));
8
+ const commander_1 = require("commander");
9
+ const profile_1 = require("../profile");
10
+ const file_store_1 = require("../credentials/file-store");
11
+ const status_1 = require("../auth/status");
12
+ const auth_1 = require("./auth");
13
+ const errors_1 = require("../utils/errors");
14
+ const config_1 = require("../config");
15
+ const output_1 = require("../utils/output");
16
+ const read_globals = (cmd) => {
17
+ const o = cmd.optsWithGlobals();
18
+ return { json: o.json, pretty: o.pretty, apiKey: o.apiKey };
19
+ };
20
+ const wants_json = (g) => Boolean(g.json || g.pretty);
21
+ const print_opts = (g) => ({ json: g.json, pretty: g.pretty });
22
+ const parse_team_id = (v) => {
23
+ if (v === undefined) {
24
+ return undefined;
25
+ }
26
+ if (!/^\d+$/.test(v.trim())) {
27
+ throw new errors_1.UsageError('--team-id must be a positive integer.', { code: 'usage.profile', hint: `Got: ${v}` });
28
+ }
29
+ return parseInt(v.trim(), 10);
30
+ };
31
+ const parse_url = (v) => {
32
+ if (v === undefined) {
33
+ return undefined;
34
+ }
35
+ const s = v.trim();
36
+ let parsed;
37
+ try {
38
+ parsed = new URL(s);
39
+ }
40
+ catch {
41
+ throw new errors_1.UsageError('--authority/--api-base must be an http(s) URL.', {
42
+ code: 'usage.profile', hint: `Got: ${v}`,
43
+ });
44
+ }
45
+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
46
+ throw new errors_1.UsageError('--authority/--api-base must be an http(s) URL.', {
47
+ code: 'usage.profile', hint: `Got: ${v}`,
48
+ });
49
+ }
50
+ return s;
51
+ };
52
+ exports.parse_url = parse_url;
53
+ // User-facing field names for `unset` (hyphenated) mapped to config keys.
54
+ const CLEARABLE_INPUT = {
55
+ 'authority': 'authority',
56
+ 'api_base': 'api_base',
57
+ 'api-base': 'api_base',
58
+ 'team_id': 'team_id',
59
+ 'team-id': 'team_id',
60
+ };
61
+ const map_clearable = (field) => {
62
+ const mapped = CLEARABLE_INPUT[field.trim().toLowerCase()];
63
+ if (!mapped) {
64
+ throw new errors_1.UsageError(`Can't clear '${field}'.`, {
65
+ code: 'usage.profile', hint: 'Clearable fields: authority, api_base, team-id.',
66
+ });
67
+ }
68
+ return mapped;
69
+ };
70
+ // Interactive y/N prompt on stderr (so JSON stdout stays clean). Injected in
71
+ // tests. Anything not starting with y/yes is treated as "no".
72
+ const confirm = (question) => {
73
+ const rl = readline_1.default.createInterface({ input: process.stdin, output: process.stderr });
74
+ return new Promise(resolve => {
75
+ rl.question(`${question} [y/N] `, answer => {
76
+ rl.close();
77
+ resolve(/^y(es)?$/i.test(answer.trim()));
78
+ });
79
+ });
80
+ };
81
+ // Rename orchestration. Ordering (two files, no cross-file transaction — never
82
+ // lose or clobber a login): (1) refuse if a credential already lives under the
83
+ // target key; (2) read the old credential; (3) rename the config def; (4) move
84
+ // the credential. A partial failure orphans the old credential (recoverable by
85
+ // re-login), never destroys it.
86
+ const handle_rename = async (old_name, new_name, g, deps) => {
87
+ const env = deps.env ?? process.env;
88
+ if (await deps.store.get(new_name)) {
89
+ throw new errors_1.UsageError(`A credential already exists for '${new_name}'.`, {
90
+ code: 'usage.profile', hint: `Log out of '${new_name}' or pick another name.`,
91
+ });
92
+ }
93
+ const cred = await deps.store.get(old_name);
94
+ (0, profile_1.rename_profile_def)(old_name, new_name, env);
95
+ let credential_moved = false;
96
+ if (cred) {
97
+ await deps.store.set(new_name, cred);
98
+ await deps.store.remove(old_name);
99
+ credential_moved = true;
100
+ }
101
+ const current_updated = (0, profile_1.current_profile_name)(env) === new_name;
102
+ if (wants_json(g)) {
103
+ (0, output_1.print)({ renamed: { from: old_name, to: new_name }, current_updated, credential_moved }, print_opts(g));
104
+ return;
105
+ }
106
+ (0, output_1.success)(`Renamed profile '${old_name}' → '${new_name}'.`);
107
+ if (current_updated) {
108
+ (0, output_1.info)(' (was the current profile)');
109
+ }
110
+ };
111
+ exports.handle_rename = handle_rename;
112
+ // Delete a profile and its stored credential. Validated before prompting so a
113
+ // bad name fails fast. Confirm-by-default: interactive y/N on a TTY, `--yes`
114
+ // skips it, and a non-interactive shell without `--yes` is refused.
115
+ const handle_delete = async (name, opts, g, deps) => {
116
+ const env = deps.env ?? process.env;
117
+ if (name === 'default') {
118
+ throw new errors_1.UsageError('The built-in default profile can\'t be deleted.', { code: 'usage.profile' });
119
+ }
120
+ if (!(0, profile_1.list_profiles)(env).available.includes(name)) {
121
+ throw new errors_1.UsageError(`Unknown profile '${name}'.`, {
122
+ code: 'usage.profile', hint: 'List profiles with `profile list`.',
123
+ });
124
+ }
125
+ if (!opts.yes) {
126
+ const is_tty = deps.is_tty ?? Boolean(process.stdin.isTTY);
127
+ if (!is_tty) {
128
+ throw new errors_1.UsageError('Refusing to delete without confirmation.', {
129
+ code: 'usage.profile', hint: 'Pass --yes to confirm in a non-interactive shell.',
130
+ });
131
+ }
132
+ const ask = deps.confirm ?? confirm;
133
+ if (!await ask(`Delete profile '${name}' and its stored credential?`)) {
134
+ (0, output_1.info)('Aborted.');
135
+ return;
136
+ }
137
+ }
138
+ const { was_current } = (0, profile_1.delete_profile_def)(name, env);
139
+ const credential_removed = await deps.store.remove(name);
140
+ if (wants_json(g)) {
141
+ (0, output_1.print)({ deleted: name, credential_removed, current_reset: was_current }, print_opts(g));
142
+ return;
143
+ }
144
+ (0, output_1.success)(`Deleted profile '${name}'.`);
145
+ if (credential_removed) {
146
+ (0, output_1.info)(' Removed its stored credential.');
147
+ }
148
+ if (was_current) {
149
+ (0, output_1.info)(' Current profile reset to default.');
150
+ }
151
+ };
152
+ exports.handle_delete = handle_delete;
153
+ // Redacted, one-line summary of the stored credential — never a raw secret.
154
+ const stored_summary = (status, record) => {
155
+ if (!record) {
156
+ return 'none — run `reply auth login`';
157
+ }
158
+ const who = record.user ? (0, auth_1.principal_label)(record.user) : 'unknown';
159
+ if (status.method === 'oauth') {
160
+ return `oauth · ${who} · expires ${status.expires_at}${status.expired ? output_1.pc.red(' (expired)') : ''}`;
161
+ }
162
+ return `api_key · ${who}`;
163
+ };
164
+ const show_json = (d, status, has_flag, has_env, record) => ({
165
+ name: d.name,
166
+ current: d.is_current,
167
+ backend: { authority: d.authority, api_base: d.api_base, inherited: d.inherited },
168
+ team_id: d.team_id ?? null,
169
+ authorization: {
170
+ flag: has_flag,
171
+ env: has_env,
172
+ stored: record
173
+ ? {
174
+ present: true,
175
+ method: status.method,
176
+ ...(status.user ? { user: status.user } : {}),
177
+ ...(status.expires_at ? { expires_at: status.expires_at, expired: status.expired } : {}),
178
+ }
179
+ : null,
180
+ effective_source: status.authenticated ? status.source : null,
181
+ },
182
+ });
183
+ // Show a profile's backend, team, and authorization. Reads the stored credential
184
+ // raw (no refresh, no write) and reuses describe_status for a secret-free summary.
185
+ const handle_show = async (name, g, deps) => {
186
+ const env = deps.env ?? process.env;
187
+ const target = name ?? (0, profile_1.current_profile_name)(env);
188
+ const d = (0, profile_1.describe_profile)(target, env);
189
+ const api_key_env = (0, config_1.get_env)('API_KEY', env);
190
+ const record = await deps.store.get(target);
191
+ const status = (0, status_1.describe_status)({
192
+ profile: target, api_key_flag: deps.api_key_flag, api_key_env, record, now: Date.now(),
193
+ });
194
+ if (wants_json(g)) {
195
+ (0, output_1.print)(show_json(d, status, Boolean(deps.api_key_flag), Boolean(api_key_env), record), print_opts(g));
196
+ return;
197
+ }
198
+ const inh = (on) => on ? ' (inherited)' : '';
199
+ const lines = [
200
+ `Profile: ${d.name}${d.is_current ? ' (current)' : ''}`,
201
+ ' Backend:',
202
+ ` authority : ${d.authority}${inh(d.inherited.authority)}`,
203
+ ` api_base : ${d.api_base}${inh(d.inherited.api_base)}`,
204
+ ' Team:',
205
+ ` team_id : ${d.team_id ?? '—'}`,
206
+ ' Authorization (first available is used):',
207
+ ` 1. --api-key flag : ${deps.api_key_flag ? 'provided' : 'not provided'}`,
208
+ ` 2. ${(0, config_1.env_var)('API_KEY')} env : ${api_key_env ? 'set' : 'not set'}`,
209
+ ` 3. stored credential : ${stored_summary(status, record)}`,
210
+ ];
211
+ console.log(lines.join('\n'));
212
+ };
213
+ exports.handle_show = handle_show;
214
+ const profile_command = new commander_1.Command('profile')
215
+ .description('Manage profiles — optional; most users never need one (default = prod)');
216
+ exports.profile_command = profile_command;
217
+ profile_command
218
+ .command('add')
219
+ .argument('<name>', 'Profile name (e.g. your account email)')
220
+ .option('--team-id <id>', 'Pin a team/workspace for this profile (sent as X-TEAM-ID)')
221
+ .option('--authority <url>', 'Override the OAuth authority (advanced; defaults to prod)')
222
+ .option('--api-base <url>', 'Override the API base (advanced; defaults to prod)')
223
+ .description('Create a profile (URLs optional — omitted fields inherit the default/prod)')
224
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} profile add alice@reply.io`
225
+ + `\n ${config_1.PROGRAM_NAME} profile add dev --api-base https://api.dev.reply.io --team-id 1045`)
226
+ .action(function (name) {
227
+ const g = read_globals(this);
228
+ const opts = this.optsWithGlobals();
229
+ (0, profile_1.add_profile)(name, {
230
+ authority: parse_url(opts.authority), api_base: parse_url(opts.apiBase), team_id: parse_team_id(opts.teamId),
231
+ });
232
+ if (wants_json(g)) {
233
+ (0, output_1.print)({ added: name }, print_opts(g));
234
+ return;
235
+ }
236
+ (0, output_1.success)(`Profile '${name}' created. Make it current with: profile use ${name}`);
237
+ });
238
+ profile_command
239
+ .command('set')
240
+ .argument('<name>', 'Profile to edit (a user profile, or "default" to pin a team globally)')
241
+ .option('--team-id <id>', 'Pin a team/workspace (sent as X-TEAM-ID)')
242
+ .option('--authority <url>', 'Override the OAuth authority (advanced)')
243
+ .option('--api-base <url>', 'Override the API base (advanced)')
244
+ .description('Edit an existing profile in place — only the fields you pass change')
245
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} profile set alice@reply.io --team-id 1045`
246
+ + `\n ${config_1.PROGRAM_NAME} profile set default --team-id 1045 # pin a team globally`)
247
+ .action(function (name) {
248
+ const g = read_globals(this);
249
+ const opts = this.optsWithGlobals();
250
+ (0, profile_1.set_profile)(name, {
251
+ authority: parse_url(opts.authority), api_base: parse_url(opts.apiBase), team_id: parse_team_id(opts.teamId),
252
+ });
253
+ if (wants_json(g)) {
254
+ (0, output_1.print)({ updated: name }, print_opts(g));
255
+ return;
256
+ }
257
+ (0, output_1.success)(`Profile '${name}' updated.`);
258
+ });
259
+ profile_command
260
+ .command('rename')
261
+ .argument('<old>', 'Existing profile to rename')
262
+ .argument('<new>', 'New name')
263
+ .description('Rename a profile (also moves its stored credential)')
264
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} profile rename alice@reply.io ally`)
265
+ .action(async function (old_name, new_name) {
266
+ const g = read_globals(this);
267
+ await handle_rename(old_name, new_name, g, { store: (0, file_store_1.default_credential_store)() });
268
+ });
269
+ profile_command
270
+ .command('delete')
271
+ .alias('rm')
272
+ .argument('<name>', 'Profile to delete')
273
+ .option('-y, --yes', 'Skip the confirmation prompt')
274
+ .description('Delete a profile and its stored credential')
275
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} profile delete ally # confirm y/N (interactive)`
276
+ + `\n ${config_1.PROGRAM_NAME} profile delete ally --yes # skip the prompt (required in scripts)`)
277
+ .action(async function (name) {
278
+ const g = read_globals(this);
279
+ await handle_delete(name, { yes: Boolean(this.opts().yes) }, g, { store: (0, file_store_1.default_credential_store)() });
280
+ });
281
+ profile_command
282
+ .command('use')
283
+ .argument('<name>', 'Profile to make current (a user-defined profile, or "default" for prod)')
284
+ .description('Set the current profile, used until changed')
285
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} profile use dev\n ${config_1.PROGRAM_NAME} profile use default`)
286
+ .action(function (name) {
287
+ const g = read_globals(this);
288
+ (0, profile_1.set_current_profile)(name);
289
+ if (wants_json(g)) {
290
+ (0, output_1.print)({ current: name }, print_opts(g));
291
+ return;
292
+ }
293
+ (0, output_1.success)(`Current profile set to ${name}.`);
294
+ });
295
+ profile_command
296
+ .command('unset')
297
+ .argument('<name>', 'Profile to edit (or "default")')
298
+ .argument('<field>', 'Field to clear: authority | api_base | team-id')
299
+ .description('Clear a config field on a profile (reverts to inherited/unset)')
300
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} profile unset dev team-id`)
301
+ .action(function (name, field) {
302
+ const g = read_globals(this);
303
+ const mapped = map_clearable(field);
304
+ const { changed } = (0, profile_1.unset_profile_field)(name, mapped, process.env);
305
+ if (wants_json(g)) {
306
+ (0, output_1.print)({ unset: mapped, profile: name, changed }, print_opts(g));
307
+ return;
308
+ }
309
+ if (changed) {
310
+ (0, output_1.success)(`Cleared ${mapped} on profile '${name}'.`);
311
+ return;
312
+ }
313
+ (0, output_1.info)(`${mapped} was already not set on '${name}'.`);
314
+ });
315
+ profile_command
316
+ .command('list')
317
+ .description('List available profiles and show which is current')
318
+ .action(function () {
319
+ const g = read_globals(this);
320
+ const { current, available } = (0, profile_1.list_profiles)();
321
+ if (wants_json(g)) {
322
+ (0, output_1.print)({ current, available }, print_opts(g));
323
+ return;
324
+ }
325
+ for (const name of available) {
326
+ const marker = name === current ? output_1.pc.green('*') : ' ';
327
+ console.log(`${marker} ${name}`);
328
+ }
329
+ });
330
+ profile_command
331
+ .command('current')
332
+ .description('Print the current profile name')
333
+ .action(function () {
334
+ const g = read_globals(this);
335
+ const current = (0, profile_1.current_profile_name)();
336
+ (0, output_1.print)(wants_json(g) ? { current } : current, print_opts(g));
337
+ });
338
+ profile_command
339
+ .command('show')
340
+ .argument('[name]', 'Profile to show (default: current)')
341
+ .description('Show a profile\'s backend, team, and authorization (no secrets)')
342
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} profile show # the current profile`
343
+ + `\n ${config_1.PROGRAM_NAME} profile show dev --json`)
344
+ .action(async function (name) {
345
+ const g = read_globals(this);
346
+ await handle_show(name, g, { store: (0, file_store_1.default_credential_store)(), api_key_flag: g.apiKey });
347
+ });
348
+ //# sourceMappingURL=profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/commands/profile.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,yCAAkC;AAClC,wCAIoB;AACpB,0DAAmE;AACnE,2CAAiE;AACjE,iCAAuC;AACvC,4CAA2C;AAC3C,sCAAmE;AACnE,4CAA0E;AAK1E,MAAM,YAAY,GAAG,CAAC,GAAY,EAAc,EAAE;IAC9C,MAAM,CAAC,GAAG,GAAG,CAAC,eAAe,EAAE,CAAC;IAChC,OAAO,EAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,U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AAO,EAChB,kBAAkB,qBAAY,8CAA8C;MAC1E,OAAO,qBAAY,0BAA0B,CAAC;KACnD,MAAM,CAAC,KAAK,WAAyB,IAAa;IAC/C,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,EAAC,KAAK,EAAE,IAAA,qCAAwB,GAAE,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAC,CAAC,CAAC;AAC5F,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Command } from 'commander';
2
+ import { type Cli_context } from '../context';
3
+ type Global_opts = {
4
+ apiKey?: string;
5
+ profile?: string;
6
+ teamId?: string;
7
+ userId?: string;
8
+ userEmail?: string;
9
+ json?: boolean;
10
+ pretty?: boolean;
11
+ };
12
+ declare const handle_team_list: (ctx: Cli_context, g: Global_opts) => Promise<void>;
13
+ declare const handle_team_current: (ctx: Cli_context, g: Global_opts) => Promise<void>;
14
+ declare const handle_team_use: (id_arg: string, ctx: Cli_context, g: Global_opts) => Promise<void>;
15
+ declare const handle_team_clear: (ctx: Cli_context, g: Global_opts) => void;
16
+ declare const team_command: Command;
17
+ export { team_command, handle_team_list, handle_team_current, handle_team_use, handle_team_clear };
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handle_team_clear = exports.handle_team_use = exports.handle_team_current = exports.handle_team_list = exports.team_command = void 0;
4
+ const commander_1 = require("commander");
5
+ const config_1 = require("../config");
6
+ const context_1 = require("../context");
7
+ const client_1 = require("../utils/client");
8
+ const teams_1 = require("../teams");
9
+ const profile_1 = require("../profile");
10
+ const auth_1 = require("./auth");
11
+ const authed_1 = require("./authed");
12
+ const errors_1 = require("../utils/errors");
13
+ const output_1 = require("../utils/output");
14
+ const read_globals = (cmd) => {
15
+ const o = cmd.optsWithGlobals();
16
+ return {
17
+ apiKey: o.apiKey, profile: o.profile,
18
+ teamId: o.teamId, userId: o.userId, userEmail: o.userEmail,
19
+ json: o.json, pretty: o.pretty,
20
+ };
21
+ };
22
+ const wants_json = (g) => Boolean(g.json || g.pretty);
23
+ const print_opts = (g) => ({ json: g.json, pretty: g.pretty });
24
+ const profile_note = (name) => name === 'default' ? '' : ` (profile: ${name})`;
25
+ const parse_positive_int = (v, label) => {
26
+ if (!/^\d+$/.test(v.trim())) {
27
+ throw new errors_1.UsageError(`${label} must be a positive integer.`, { code: 'usage.team', hint: `Got: ${v}` });
28
+ }
29
+ return parseInt(v.trim(), 10);
30
+ };
31
+ const handle_team_list = async (ctx, g) => {
32
+ const { token, headers } = await (0, authed_1.authed)(ctx, g);
33
+ const teams = await (0, teams_1.resolve_my_teams)({ api_base: ctx.api_base, token, headers });
34
+ if (wants_json(g)) {
35
+ (0, output_1.print)({ current_team_id: ctx.team_id ?? null, teams }, print_opts(g));
36
+ return;
37
+ }
38
+ console.log(`Teams you can act in${profile_note(ctx.profile)}`);
39
+ if (!teams.length) {
40
+ (0, output_1.info)(' (none returned)');
41
+ return;
42
+ }
43
+ for (const t of teams) {
44
+ const marker = t.team_id === ctx.team_id ? output_1.pc.green('*') : ' ';
45
+ console.log(` ${marker} ${t.team_id}${t.team_name ? ' ' + t.team_name : ''}`);
46
+ }
47
+ };
48
+ exports.handle_team_list = handle_team_list;
49
+ // Pinned team is the profile's team_id (offline). Effective team is what the
50
+ // server actually resolves — read from /whoami, best-effort: any failure becomes
51
+ // a "failed to retrieve" note rather than an error.
52
+ const handle_team_current = async (ctx, g) => {
53
+ const pinned = ctx.team_id ?? null;
54
+ let effective;
55
+ try {
56
+ const { token, headers } = await (0, authed_1.authed)(ctx, g);
57
+ const raw = await (0, client_1.create_client)(ctx.api_base, token, headers).get('/v3/whoami');
58
+ effective = { team_id: (0, auth_1.normalize_principal)(raw ?? {}).team_id };
59
+ }
60
+ catch (e) {
61
+ effective = { error: e.message };
62
+ }
63
+ if (wants_json(g)) {
64
+ (0, output_1.print)({ profile: ctx.profile, pinned_team_id: pinned, effective }, print_opts(g));
65
+ return;
66
+ }
67
+ const effective_str = effective.error
68
+ ? `failed to retrieve (${effective.error})`
69
+ : (effective.team_id ?? '(none)');
70
+ console.log(`Profile '${ctx.profile}'`);
71
+ console.log(` pinned team : ${pinned ?? '(none)'}`);
72
+ console.log(` effective team : ${effective_str}`);
73
+ };
74
+ exports.handle_team_current = handle_team_current;
75
+ const handle_team_use = async (id_arg, ctx, g) => {
76
+ const id = parse_positive_int(id_arg, 'Team id');
77
+ const { token, headers } = await (0, authed_1.authed)(ctx, g);
78
+ const teams = await (0, teams_1.resolve_my_teams)({ api_base: ctx.api_base, token, headers });
79
+ const match = teams.find(t => t.team_id === id);
80
+ if (!match) {
81
+ throw new errors_1.UsageError(`Team ${id} isn't one you can act in.`, {
82
+ code: 'usage.team',
83
+ hint: teams.length
84
+ ? `Your teams: ${teams.map(t => `${t.team_id} (${t.team_name})`).join(', ')}`
85
+ : 'Run `reply team list` to see your teams.',
86
+ });
87
+ }
88
+ (0, profile_1.set_profile)(ctx.profile, { team_id: id });
89
+ if (wants_json(g)) {
90
+ (0, output_1.print)({ profile: ctx.profile, team_id: id, team_name: match.team_name }, print_opts(g));
91
+ return;
92
+ }
93
+ const label = match.team_name ? ` (${match.team_name})` : '';
94
+ (0, output_1.success)(`Profile '${ctx.profile}' team set to ${id}${label}.`);
95
+ };
96
+ exports.handle_team_use = handle_team_use;
97
+ const handle_team_clear = (ctx, g) => {
98
+ const { changed } = (0, profile_1.unset_profile_field)(ctx.profile, 'team_id');
99
+ if (wants_json(g)) {
100
+ (0, output_1.print)({ profile: ctx.profile, cleared: changed }, print_opts(g));
101
+ return;
102
+ }
103
+ if (changed) {
104
+ (0, output_1.success)(`Cleared team on profile '${ctx.profile}'.`);
105
+ return;
106
+ }
107
+ (0, output_1.info)(`No team was set on '${ctx.profile}'.`);
108
+ };
109
+ exports.handle_team_clear = handle_team_clear;
110
+ const team_command = new commander_1.Command('team')
111
+ .description('See and set the current profile\'s team');
112
+ exports.team_command = team_command;
113
+ team_command
114
+ .command('list')
115
+ .description('List the teams you can act in')
116
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} team list\n\nCalls the API (needs a stored login or --api-key).`)
117
+ .action(async function () {
118
+ const g = read_globals(this);
119
+ await handle_team_list((0, context_1.build_context)({ profile: g.profile }), g);
120
+ });
121
+ team_command
122
+ .command('current')
123
+ .description('Show the current profile\'s pinned and effective team')
124
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} team current\n\n`
125
+ + 'Pinned team is read from the profile (offline); the effective team is fetched from the API.')
126
+ .action(async function () {
127
+ const g = read_globals(this);
128
+ await handle_team_current((0, context_1.build_context)({ profile: g.profile }), g);
129
+ });
130
+ team_command
131
+ .command('use')
132
+ .argument('<id>', 'Team id to pin on the current profile')
133
+ .description('Pin a team on the current profile (verified against your teams)')
134
+ .addHelpText('after', `\nExamples:\n ${config_1.PROGRAM_NAME} team use 1045`)
135
+ .action(async function (id) {
136
+ const g = read_globals(this);
137
+ await handle_team_use(id, (0, context_1.build_context)({ profile: g.profile }), g);
138
+ });
139
+ team_command
140
+ .command('clear')
141
+ .description('Remove the current profile\'s team pin')
142
+ .action(function () {
143
+ const g = read_globals(this);
144
+ handle_team_clear((0, context_1.build_context)({ profile: g.profile }), g);
145
+ });
146
+ //# sourceMappingURL=team.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.js","sourceRoot":"","sources":["../../src/commands/team.ts"],"names":[],"mappings":";;;AAAA,yCAAkC;AAClC,sCAAuC;AACvC,wCAA2D;AAC3D,4CAA8C;AAC9C,oCAA0C;AAC1C,wCAA4D;AAC5D,iCAA2C;AAC3C,qCAAgC;AAChC,4CAA2C;AAC3C,4CAA0E;AAY1E,MAAM,YAAY,GAAG,CAAC,GAAY,EAAc,EAAE;IAC9C,MAAM,CAAC,GAAG,GAAG,CAAC,eAAe,EAAE,CAAC;IAChC,OAAO;QACH,MAAM,EAAE,C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6FAA6F,CAAC;KACnG,MAAM,CAAC,KAAK;IACT,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,mBAAmB,CAAC,IAAA,uBAAa,EAAC,EAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtE,CAAC,CAAC,CAAC;AAEP,YAAY;KACP,OAAO,CAAC,KAAK,CAAC;KACd,QAAQ,CAAC,MAAM,EAAE,uCAAuC,CAAC;KACzD,WAAW,CAAC,iEAAiE,CAAC;KAC9E,WAAW,CAAC,OAAO,EAAE,kBAAkB,qBAAY,gBAAgB,CAAC;KACpE,MAAM,CAAC,KAAK,WAAyB,EAAU;IAC5C,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,eAAe,CAAC,EAAE,EAAE,IAAA,uBAAa,EAAC,EAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtE,CAAC,CAAC,CAAC;AAEP,YAAY;KACP,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,wCAAwC,CAAC;KACrD,MAAM,CAAC;IACJ,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,iBAAiB,CAAC,IAAA,uBAAa,EAAC,EAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ declare const APP_NAME = "reply";
2
+ declare const PROGRAM_NAME = "reply";
3
+ type Env = Record<string, string | undefined>;
4
+ declare const env_prefix: (app?: string) => string;
5
+ declare const env_var: (suffix: string, app?: string) => string;
6
+ declare const get_env: (suffix: string, env?: Env) => string | undefined;
7
+ declare const cli_version: () => string;
8
+ declare const user_agent: () => string;
9
+ declare const default_config_dir: (platform: NodeJS.Platform, env: Env, homedir: string) => string;
10
+ declare const config_dir: (env?: Env) => string;
11
+ declare const credentials_file: (env?: Env) => string;
12
+ declare const config_file: (env?: Env) => string;
13
+ export { PROGRAM_NAME, APP_NAME, env_prefix, env_var, get_env, cli_version, user_agent, default_config_dir, config_dir, credentials_file, config_file, };
14
+ export type { Env };
package/dist/config.js ADDED
@@ -0,0 +1,80 @@
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.config_file = exports.credentials_file = exports.config_dir = exports.default_config_dir = exports.user_agent = exports.cli_version = exports.get_env = exports.env_var = exports.env_prefix = exports.APP_NAME = exports.PROGRAM_NAME = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const os_1 = __importDefault(require("os"));
9
+ const path_1 = __importDefault(require("path"));
10
+ // Single identity. The bin name, config dir, and env-var prefix all derive
11
+ // from APP_NAME. There is one build (`reply`); channels are handled by the
12
+ // registry/dist-tags, not by a second identity.
13
+ const APP_NAME = 'reply';
14
+ exports.APP_NAME = APP_NAME;
15
+ const PROGRAM_NAME = APP_NAME;
16
+ exports.PROGRAM_NAME = PROGRAM_NAME;
17
+ const env_prefix = (app = APP_NAME) => app.toUpperCase().replace(/-/g, '_');
18
+ exports.env_prefix = env_prefix;
19
+ // Build a full env var name, e.g. env_var('API_KEY') -> 'REPLY_API_KEY'.
20
+ const env_var = (suffix, app = APP_NAME) => `${env_prefix(app)}_${suffix}`;
21
+ exports.env_var = env_var;
22
+ const get_env = (suffix, env = process.env) => env[env_var(suffix)];
23
+ exports.get_env = get_env;
24
+ let cached_version;
25
+ // The CLI version, read once from package.json (same file for src and dist —
26
+ // ../package.json resolves to the repo root either way). Falls back to '0.0.0'
27
+ // if the file is missing or malformed.
28
+ const cli_version = () => {
29
+ if (cached_version !== undefined) {
30
+ return cached_version;
31
+ }
32
+ let version = '0.0.0';
33
+ try {
34
+ const pkg = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../package.json'), 'utf8'));
35
+ if (typeof pkg.version === 'string' && pkg.version) {
36
+ version = pkg.version;
37
+ }
38
+ }
39
+ catch {
40
+ // Unreadable/malformed package.json — keep the '0.0.0' fallback.
41
+ }
42
+ cached_version = version;
43
+ return version;
44
+ };
45
+ exports.cli_version = cli_version;
46
+ // Identifies CLI requests for telemetry (not security). Product token derives
47
+ // from APP_NAME to keep the single build identity, e.g. 'reply-cli/0.1.0'.
48
+ const user_agent = () => `${APP_NAME}-cli/${cli_version()}`;
49
+ exports.user_agent = user_agent;
50
+ // Default per-user config dir, mirroring gh/aws/az conventions.
51
+ // linux/mac: $XDG_CONFIG_HOME/<app> (fallback ~/.config/<app>)
52
+ // windows: %APPDATA%\<app> (fallback <home>\AppData\Roaming\<app>)
53
+ const default_config_dir = (platform, env, homedir) => {
54
+ if (platform === 'win32') {
55
+ const appdata = env.APPDATA && env.APPDATA.trim()
56
+ ? env.APPDATA
57
+ : path_1.default.join(homedir, 'AppData', 'Roaming');
58
+ return path_1.default.join(appdata, APP_NAME);
59
+ }
60
+ const xdg = env.XDG_CONFIG_HOME;
61
+ const base = xdg && xdg.trim() ? xdg : path_1.default.join(homedir, '.config');
62
+ return path_1.default.join(base, APP_NAME);
63
+ };
64
+ exports.default_config_dir = default_config_dir;
65
+ // The active config dir. A <PREFIX>_CONFIG_DIR override wins outright.
66
+ const config_dir = (env = process.env) => {
67
+ const override = get_env('CONFIG_DIR', env);
68
+ if (override && override.trim()) {
69
+ return override;
70
+ }
71
+ return default_config_dir(process.platform, env, os_1.default.homedir());
72
+ };
73
+ exports.config_dir = config_dir;
74
+ // Stored credentials, keyed by profile name (see credentials/file-store.ts).
75
+ const credentials_file = (env = process.env) => path_1.default.join(config_dir(env), 'credentials.json');
76
+ exports.credentials_file = credentials_file;
77
+ // User profile definitions live here (see profile.ts).
78
+ const config_file = (env = process.env) => path_1.default.join(config_dir(env), 'config.json');
79
+ exports.config_file = config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