reply-cli 0.5.1 → 0.13.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 (73) hide show
  1. package/README.md +137 -11
  2. package/dist/commands/api.js +2 -40
  3. package/dist/commands/api.js.map +1 -1
  4. package/dist/index.js +19 -7
  5. package/dist/index.js.map +1 -1
  6. package/dist/operations/call.d.ts +35 -0
  7. package/dist/operations/call.js +131 -0
  8. package/dist/operations/call.js.map +1 -0
  9. package/dist/operations/commands.d.ts +6 -0
  10. package/dist/operations/commands.js +279 -0
  11. package/dist/operations/commands.js.map +1 -0
  12. package/dist/operations/contact-input.d.ts +33 -0
  13. package/dist/operations/contact-input.js +123 -0
  14. package/dist/operations/contact-input.js.map +1 -0
  15. package/dist/operations/contact-list.d.ts +9 -0
  16. package/dist/operations/contact-list.js +50 -0
  17. package/dist/operations/contact-list.js.map +1 -0
  18. package/dist/operations/contact-record.d.ts +11 -0
  19. package/dist/operations/contact-record.js +176 -0
  20. package/dist/operations/contact-record.js.map +1 -0
  21. package/dist/operations/contact.d.ts +7 -0
  22. package/dist/operations/contact.js +53 -0
  23. package/dist/operations/contact.js.map +1 -0
  24. package/dist/operations/contacts.d.ts +15 -0
  25. package/dist/operations/contacts.js +180 -0
  26. package/dist/operations/contacts.js.map +1 -0
  27. package/dist/operations/inbox-reply.d.ts +11 -0
  28. package/dist/operations/inbox-reply.js +160 -0
  29. package/dist/operations/inbox-reply.js.map +1 -0
  30. package/dist/operations/inbox.d.ts +40 -0
  31. package/dist/operations/inbox.js +180 -0
  32. package/dist/operations/inbox.js.map +1 -0
  33. package/dist/operations/options.d.ts +18 -0
  34. package/dist/operations/options.js +63 -0
  35. package/dist/operations/options.js.map +1 -0
  36. package/dist/operations/result.d.ts +5 -0
  37. package/dist/operations/result.js +20 -0
  38. package/dist/operations/result.js.map +1 -0
  39. package/dist/operations/sequence-by-name.d.ts +9 -0
  40. package/dist/operations/sequence-by-name.js +96 -0
  41. package/dist/operations/sequence-by-name.js.map +1 -0
  42. package/dist/operations/sequence-membership.d.ts +13 -0
  43. package/dist/operations/sequence-membership.js +227 -0
  44. package/dist/operations/sequence-membership.js.map +1 -0
  45. package/dist/operations/sequence-read.d.ts +26 -0
  46. package/dist/operations/sequence-read.js +121 -0
  47. package/dist/operations/sequence-read.js.map +1 -0
  48. package/dist/operations/sequence-state.d.ts +7 -0
  49. package/dist/operations/sequence-state.js +88 -0
  50. package/dist/operations/sequence-state.js.map +1 -0
  51. package/dist/operations/stdin-input.d.ts +10 -0
  52. package/dist/operations/stdin-input.js +34 -0
  53. package/dist/operations/stdin-input.js.map +1 -0
  54. package/dist/skills/adapter-flat.d.ts +3 -1
  55. package/dist/skills/adapter-flat.js +49 -19
  56. package/dist/skills/adapter-flat.js.map +1 -1
  57. package/dist/skills/hosts.js +35 -13
  58. package/dist/skills/hosts.js.map +1 -1
  59. package/dist/skills/orchestrate.js +41 -4
  60. package/dist/skills/orchestrate.js.map +1 -1
  61. package/dist/skills/report.js +36 -10
  62. package/dist/skills/report.js.map +1 -1
  63. package/dist/skills/types.d.ts +11 -1
  64. package/dist/utils/client.d.ts +5 -2
  65. package/dist/utils/client.js +113 -78
  66. package/dist/utils/client.js.map +1 -1
  67. package/dist/utils/errors.d.ts +29 -2
  68. package/dist/utils/errors.js +40 -2
  69. package/dist/utils/errors.js.map +1 -1
  70. package/dist/utils/json-arg.d.ts +10 -0
  71. package/dist/utils/json-arg.js +45 -0
  72. package/dist/utils/json-arg.js.map +1 -0
  73. package/package.json +1 -1
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inbox_command = exports.contact_command = exports.contact_list_command = exports.sequence_command = void 0;
4
+ const commander_1 = require("commander");
5
+ const config_1 = require("../config");
6
+ const context_1 = require("../context");
7
+ const options_1 = require("./options");
8
+ const contact_input_1 = require("./contact-input");
9
+ const sequence_read_1 = require("./sequence-read");
10
+ const sequence_by_name_1 = require("./sequence-by-name");
11
+ const sequence_membership_1 = require("./sequence-membership");
12
+ const sequence_state_1 = require("./sequence-state");
13
+ const inbox_1 = require("./inbox");
14
+ const inbox_reply_1 = require("./inbox-reply");
15
+ const contact_list_1 = require("./contact-list");
16
+ const contact_1 = require("./contact");
17
+ const contact_record_1 = require("./contact-record");
18
+ const P = config_1.PROGRAM_NAME;
19
+ const COMMON_ERRORS = [
20
+ 'access.denied', 'access.feature_unavailable', 'rate_limited', 'reply.unavailable', 'reply.refused', 'reply.invalid_request',
21
+ ];
22
+ const SAFE_TO_REPEAT = 'a write may have happened; re-running is safe';
23
+ const errors_help = (codes, write, unknown_outcome) => '\nErrors (with --json, one line on stderr: {"error":{"code":…,"ids":…}}):\n'
24
+ + [...codes, ...COMMON_ERRORS, ...(write ? ['outcome.unknown'] : [])].map(c => ` ${c}`).join('\n')
25
+ + '\nExit codes: 0 done · 1 failed, main effect not done (partial effects are in "ids") · 2 usage, nothing sent'
26
+ + ` · 3 outcome unknown (${unknown_outcome})`;
27
+ const help = (examples, codes, write, extra = '', unknown_outcome = SAFE_TO_REPEAT) => `\nExamples:\n${examples.map(e => ` ${e}`).join('\n')}\n${extra ? `\n${extra}` : ''}${errors_help(codes, write, unknown_outcome)}`;
28
+ const ex = (command) => `${P} ${command}`;
29
+ // The contact on stdin: the form that keeps personal data off the argument list, so it leads.
30
+ const piped = (command, contact = '{"email":"ann@example.com","first_name":"Ann"}') => `echo '${contact}' | ${P} ${command} --contact -`;
31
+ const ALWAYS_IMPORTED = 'A contact given by email is always imported, so Reply needs a first name, even for one it already holds.\n'
32
+ + 'One given only by LinkedIn URL is looked up first and imported only when Reply holds nobody under it.\n';
33
+ const run = (fn) => async function () {
34
+ await fn(this);
35
+ };
36
+ const ctx_of = (cmd) => {
37
+ const g = (0, options_1.read_op_globals)(cmd);
38
+ return { g, ctx: (0, context_1.build_context)({ profile: g.profile }) };
39
+ };
40
+ const sequence_command = new commander_1.Command('sequence')
41
+ .description('Find or create a sequence by name, read it, put contacts in or take them out, pause or start it');
42
+ exports.sequence_command = sequence_command;
43
+ sequence_command.command('list')
44
+ .option('--name <stdin>', 'Only -: {name} as JSON on stdin')
45
+ .description('Every sequence whose name is this one, ignoring case, archived ones included')
46
+ .addHelpText('after', help([`echo '{"name":"Q4 outreach"}' | ${P} sequence list --name -`], ['sequence.list_incomplete'], false, 'Result: {"items":[{"id","name","status","is_archived","created_at"}]}, oldest first: Reply\'s status (new, active,\n'
47
+ + 'paused), archive flag and creation time, each null when Reply gives none. The name is read from stdin only, so it\n'
48
+ + 'never sits in the argument list. The list is read to its end; sequence.list_incomplete means it did not end within\n'
49
+ + '20000 sequences whose names contain this one.\n'))
50
+ .action(run(async (cmd) => {
51
+ const { g, ctx } = ctx_of(cmd);
52
+ await (0, sequence_by_name_1.handle_sequence_list)(cmd.opts(), ctx, g);
53
+ }));
54
+ sequence_command.command('create')
55
+ .option('--name <stdin>', 'Only -: {name} as JSON on stdin')
56
+ .description('Make a draft sequence of this name, holding nobody, with one task step to replace before it is started')
57
+ .addHelpText('after', help([`echo '{"name":"Q4 outreach"}' | ${P} sequence create --name -`], [], true, 'Result: {"sequence_id","steps_added","status","is_archived"}: status and is_archived are Reply\'s for the new sequence.\n'
58
+ + 'The name is read from stdin only, so it never sits in the argument list. Reply allows two sequences of one name and\n'
59
+ + 'this command does not look first: run `sequence list --name -` before it. The one step is a task for the owner, which\n'
60
+ + 'reaches nobody; Reply gives the draft the account\'s default schedule and mailbox. The draft is never started here.\n', 'the sequence may have been made; running the command again may make a second one, so look it up by name first'))
61
+ .action(run(async (cmd) => {
62
+ const { g, ctx } = ctx_of(cmd);
63
+ await (0, sequence_by_name_1.handle_sequence_create)(cmd.opts(), ctx, g);
64
+ }));
65
+ sequence_command.command('get')
66
+ .argument('<sequence-id>', 'Sequence id')
67
+ .description('The sequence as Reply holds it: settings, steps, state')
68
+ .addHelpText('after', help([ex('sequence get 123')], ['sequence.not_found'], false))
69
+ .action(run(async (cmd) => {
70
+ const { g, ctx } = ctx_of(cmd);
71
+ await (0, sequence_read_1.handle_sequence_get)(cmd.args[0], ctx, g);
72
+ }));
73
+ sequence_command.command('contacts')
74
+ .argument('<sequence-id>', 'Sequence id')
75
+ .option('--limit <n>', 'Contacts per page, 1-1000 (default 100)')
76
+ .option('--offset <n>', 'Contacts to skip (default 0)')
77
+ .description('One page of the contacts in the sequence, newest first, plus the total')
78
+ .addHelpText('after', help([ex('sequence contacts 123 --limit 50')], ['sequence.not_found'], false))
79
+ .action(run(async (cmd) => {
80
+ const { g, ctx } = ctx_of(cmd);
81
+ await (0, sequence_read_1.handle_sequence_contacts)(cmd.args[0], cmd.opts(), ctx, g);
82
+ }));
83
+ sequence_command.command('stats')
84
+ .argument('<sequence-id>', 'Sequence id')
85
+ .option('--preset <window>', 'last-week | last-month | last-year | all-time')
86
+ .option('--from <iso>', 'Window start (with --to)')
87
+ .option('--to <iso>', 'Window end (with --from)')
88
+ .description('Reply\'s email and LinkedIn counts for the sequence over one window')
89
+ .addHelpText('after', help([ex('sequence stats 123 --preset last-month'), ex('sequence stats 123 --from 2026-09-01 --to 2026-10-01')], ['sequence.not_found'], false))
90
+ .action(run(async (cmd) => {
91
+ const { g, ctx } = ctx_of(cmd);
92
+ await (0, sequence_read_1.handle_sequence_stats)(cmd.args[0], cmd.opts(), ctx, g);
93
+ }));
94
+ (0, contact_input_1.add_contact_options)(sequence_command.command('add-contact')
95
+ .argument('<sequence-id>', 'Sequence id'))
96
+ .option('--start-step <n>', 'Start at this step of the sequence (1 = first; the steps must form one chain)')
97
+ .option('--ignore-step-delay', 'Skip the delay of the step the contact starts at (Reply still sends within the sequence\'s schedule)')
98
+ .description('Put a contact into the sequence, creating the contact if Reply has nobody under the address')
99
+ .addHelpText('after', help([piped('sequence add-contact 123'), ex('sequence add-contact 123 --email ann@example.com --first-name Ann'),
100
+ ex('sequence add-contact 123 --contact-id 456 --start-step 2')], ['sequence.not_found', 'sequence.archived', 'sequence.has_no_steps', 'sequence.step_not_found', 'contact.not_found',
101
+ 'contact.not_unique', 'contact.opted_out', 'contact.invalid_email', 'contact.invalid_linkedin_url',
102
+ 'account.contact_limit_reached'], true, 'Result: {"status":"added"|"already_in_sequence","sequence_id","contact_id","contact_created","sequence_active"}\n'
103
+ + contact_input_1.CONTACT_HELP + ALWAYS_IMPORTED))
104
+ .action(run(async (cmd) => {
105
+ const { g, ctx } = ctx_of(cmd);
106
+ await (0, sequence_membership_1.handle_sequence_add_contact)(cmd.args[0], cmd.opts(), ctx, g);
107
+ }));
108
+ (0, contact_input_1.add_contact_options)(sequence_command.command('remove-contact')
109
+ .argument('<sequence-id>', 'Sequence id'))
110
+ .description('Take a contact out of the sequence; their history stays. Never creates a contact')
111
+ .addHelpText('after', help([piped('sequence remove-contact 123', '{"email":"ann@example.com"}'), ex('sequence remove-contact 123 --contact-id 456')], ['sequence.not_found', 'contact.not_unique'], true, 'Result: {"status":"removed"|"not_in_sequence","sequence_id","contact_id"}\n'
112
+ + contact_input_1.CONTACT_HELP + 'A contact given by email or LinkedIn URL is only looked up, never imported, so no first name is needed.\n'))
113
+ .action(run(async (cmd) => {
114
+ const { g, ctx } = ctx_of(cmd);
115
+ await (0, sequence_membership_1.handle_sequence_remove_contact)(cmd.args[0], cmd.opts(), ctx, g);
116
+ }));
117
+ sequence_command.command('pause')
118
+ .argument('<sequence-id>', 'Sequence id')
119
+ .description('Pause the sequence (a paused one stays paused; one never started is refused)')
120
+ .addHelpText('after', help([ex('sequence pause 123')], ['sequence.not_found', 'sequence.archived', 'sequence.not_pausable', 'sequence.busy'], true, 'Result: {"status":"paused","sequence_id"}\n'))
121
+ .action(run(async (cmd) => {
122
+ const { g, ctx } = ctx_of(cmd);
123
+ await (0, sequence_state_1.handle_sequence_pause)(cmd.args[0], ctx, g);
124
+ }));
125
+ sequence_command.command('start')
126
+ .argument('<sequence-id>', 'Sequence id')
127
+ .option('--expect-contacts <n>', 'Start only if the sequence holds exactly this many contacts')
128
+ .description('Start (or resume) the sequence: step 1 goes to everyone in it')
129
+ .addHelpText('after', help([ex('sequence start 123'), ex('sequence start 123 --expect-contacts 40')], ['sequence.not_found', 'sequence.archived', 'sequence.not_startable', 'sequence.busy', 'sequence.contact_count_changed'], true, 'Result: {"status":"started"|"already_active","sequence_id","previous_status","contacts"}. already_active, contacts and\n'
130
+ + 'previous_status come only with --expect-contacts; previous_status is the sequence\'s state before the start: new, paused or active.\n'))
131
+ .action(run(async (cmd) => {
132
+ const { g, ctx } = ctx_of(cmd);
133
+ await (0, sequence_state_1.handle_sequence_start)(cmd.args[0], cmd.opts(), ctx, g);
134
+ }));
135
+ const contact_list_command = new commander_1.Command('contact-list').description('Put contacts on a contact list');
136
+ exports.contact_list_command = contact_list_command;
137
+ (0, contact_input_1.add_contact_options)(contact_list_command.command('add-contact')
138
+ .argument('<list-id>', 'Contact list id'))
139
+ .option('--refuse-opted-out', 'Refuse a contact Reply holds as opted out (a list may otherwise hold them)')
140
+ .description('Put a contact on the list, creating the contact if Reply has nobody under the address')
141
+ .addHelpText('after', help([piped('contact-list add-contact 77'), ex('contact-list add-contact 77 --contact-id 456 --refuse-opted-out')], ['contact-list.not_found', 'contact.not_found', 'contact.not_unique', 'contact.opted_out', 'contact.invalid_email',
142
+ 'contact.invalid_linkedin_url', 'account.contact_limit_reached'], true, 'Result: {"status":"added","list_id","contact_id","contact_created"}\n' + contact_input_1.CONTACT_HELP + ALWAYS_IMPORTED))
143
+ .action(run(async (cmd) => {
144
+ const { g, ctx } = ctx_of(cmd);
145
+ await (0, contact_list_1.handle_contact_list_add_contact)(cmd.args[0], cmd.opts(), ctx, g);
146
+ }));
147
+ const contact_command = new commander_1.Command('contact').description('Find a contact, read it, change or delete it, or opt it out');
148
+ exports.contact_command = contact_command;
149
+ contact_command.command('find')
150
+ .option('--contact <stdin>', 'Only -: {email} or {linkedin_url} as JSON on stdin')
151
+ .description('The id of the contact Reply holds under an email or a LinkedIn URL. Never creates a contact')
152
+ .addHelpText('after', help([`echo '{"email":"ann@example.com"}' | ${P} contact find --contact -`,
153
+ `echo '{"linkedin_url":"https://www.linkedin.com/in/ann-example"}' | ${P} contact find --contact -`], ['contact.not_unique'], false, 'Result: {"contact_id"}: null when Reply holds nobody under the address.\n'
154
+ + 'The address is read from stdin only, so it never sits in the argument list. An email matches ignoring case. A\n'
155
+ + 'LinkedIn URL is matched by its lowercased slug: on linkedin.com the path\'s case does not count, nor the scheme\'s or\n'
156
+ + 'host\'s, a default port, one trailing slash or a fragment, while www and the query do; Reply is asked for it in that\n'
157
+ + 'form first, then as given. contact.not_unique means Reply holds more than one contact under the address.\n'))
158
+ .action(run(async (cmd) => {
159
+ const { g, ctx } = ctx_of(cmd);
160
+ await (0, contact_record_1.handle_contact_find)(cmd.opts(), ctx, g);
161
+ }));
162
+ contact_command.command('get')
163
+ .argument('<contact-id>', 'Contact id')
164
+ .description('The contact as Reply holds it: fields, owner, opt-out, custom fields')
165
+ .addHelpText('after', help([ex('contact get 456')], ['contact.not_found'], false))
166
+ .action(run(async (cmd) => {
167
+ const { g, ctx } = ctx_of(cmd);
168
+ await (0, contact_record_1.handle_contact_get)(cmd.args[0], ctx, g);
169
+ }));
170
+ contact_command.command('update')
171
+ .argument('<contact-id>', 'Contact id')
172
+ .option('--fields <stdin>', 'Only -: the fields to change as JSON on stdin')
173
+ .description('Change some of a contact\'s fields and custom fields; the rest stay as they are')
174
+ .addHelpText('after', help([`echo '{"title":"CTO","company":"Acme"}' | ${P} contact update 456 --fields -`,
175
+ `echo '{"last_name":null,"custom_fields":[{"name":"leadSource","value":"Event"}]}' | ${P} contact update 456 --fields -`], ['contact.not_found', 'contact.field_not_found'], true, 'Result: {"status":"updated","contact_id"}\n'
176
+ + 'Fields: {first_name, last_name, company, title, linkedin_url, custom_fields: [{name, value}]}; a field left out stays as\n'
177
+ + 'it is, and null clears one. They are read from stdin only, so no value ever sits in the argument list. The CLI stores\n'
178
+ + 'a LinkedIn URL by its lowercased slug, the form contacts are looked up by. A custom field is named as the account\n'
179
+ + 'names it (ignoring case); a name the account has none of is contact.field_not_found, and then nothing is changed.\n'))
180
+ .action(run(async (cmd) => {
181
+ const { g, ctx } = ctx_of(cmd);
182
+ await (0, contact_record_1.handle_contact_update)(cmd.args[0], cmd.opts(), ctx, g);
183
+ }));
184
+ contact_command.command('delete')
185
+ .argument('<contact-id>', 'Contact id')
186
+ .description('Delete a contact from the account, with its history at Reply')
187
+ .addHelpText('after', help([ex('contact delete 456')], ['contact.not_found'], true, 'Result: {"status":"deleted","contact_id"}\n'
188
+ + 'After exit 3 the contact may already be gone: running the command again is safe, and then answers contact.not_found.\n'))
189
+ .action(run(async (cmd) => {
190
+ const { g, ctx } = ctx_of(cmd);
191
+ await (0, contact_record_1.handle_contact_delete)(cmd.args[0], ctx, g);
192
+ }));
193
+ (0, contact_input_1.add_contact_options)(contact_command.command('opt-out'))
194
+ .description('Mark the contact as opted out at Reply, creating them only if Reply has nobody under the address')
195
+ .addHelpText('after', help([piped('contact opt-out'), ex('contact opt-out --contact-id 456')], ['contact.not_found', 'contact.not_unique', 'contact.invalid_email', 'contact.invalid_linkedin_url', 'account.contact_limit_reached'], true, 'Result: {"status":"opted_out","contact_id","contact_created"}\n' + contact_input_1.CONTACT_HELP
196
+ + 'A contact given by email or LinkedIn URL is imported only when Reply holds nobody under the address; only then does\n'
197
+ + 'Reply need a first name.\n'))
198
+ .action(run(async (cmd) => {
199
+ const { g, ctx } = ctx_of(cmd);
200
+ await (0, contact_1.handle_contact_opt_out)(cmd.opts(), ctx, g);
201
+ }));
202
+ const inbox_command = new commander_1.Command('inbox').description('Read inbox threads, reply in them, file them under a category, mark them read or unread');
203
+ exports.inbox_command = inbox_command;
204
+ inbox_command.command('list')
205
+ .option('--contact-id <id>', 'Threads with this contact')
206
+ .option('--sequence-id <id>', 'Threads of this sequence')
207
+ .option('--source <source>', 'inbox | sent | unread | ai-draft (Reply\'s default: inbox)')
208
+ .option('--channel <channel>', 'email | linkedin: only threads on this channel')
209
+ .option('--category-id <id>', 'Only threads filed under this inbox category (see `inbox categories`)')
210
+ .option('--since <iso>', 'Only threads that moved at or after this moment')
211
+ .option('--limit <n>', 'Threads per page, 1-100 (default 20)')
212
+ .option('--offset <n>', 'Threads to skip (default 0)')
213
+ .description('One page of inbox threads, by contact or by sequence')
214
+ .addHelpText('after', help([ex('inbox list --contact-id 456'), ex('inbox list --sequence-id 123 --source unread --since 2026-10-01T00:00:00Z'),
215
+ ex('inbox list --sequence-id 123 --channel linkedin --category-id 7')], [], false))
216
+ .action(run(async (cmd) => {
217
+ const { g, ctx } = ctx_of(cmd);
218
+ await (0, inbox_1.handle_inbox_list)(cmd.opts(), ctx, g);
219
+ }));
220
+ inbox_command.command('get')
221
+ .argument('<thread-id>', 'Inbox thread id')
222
+ .option('--limit <n>', 'Messages per page, 1-20 (default 20)')
223
+ .option('--offset <n>', 'Messages to skip (default 0)')
224
+ .description('One inbox thread and one page of its messages, oldest first')
225
+ .addHelpText('after', help([ex('inbox get 9876'), ex('inbox get 9876 --offset 20')], ['inbox.thread_not_found'], false, 'Result: {"thread","messages":{"items","has_more"}}. The thread is Reply\'s without its inline history, which has no limit;\n'
226
+ + 'its "subject" is the latest email message\'s (null when there is none).\n'))
227
+ .action(run(async (cmd) => {
228
+ const { g, ctx } = ctx_of(cmd);
229
+ await (0, inbox_1.handle_inbox_get)(cmd.args[0], cmd.opts(), ctx, g);
230
+ }));
231
+ inbox_command.command('reply')
232
+ .argument('<thread-id>', 'Inbox thread id')
233
+ .option('--message <stdin>', 'Only -: the message {body, reply_to_message_id} as JSON on stdin')
234
+ .description('Reply to the contact in an existing thread, on the thread\'s own channel')
235
+ .addHelpText('after', help([`echo '{"body":"Thanks, Tuesday works."}' | ${P} inbox reply 9876 --message -`,
236
+ `echo '{"body":"Thanks!","reply_to_message_id":"<abc@example.com>"}' | ${P} inbox reply 9876 --message -`], ['inbox.thread_not_found', 'inbox.channel_mismatch', 'contact.opted_out', 'inbox.send_failed'], true, 'Result: {"status":"sent","thread_id","channel":"email"|"linkedin","message_id","sent_at"}: Reply\'s messageId and date,\n'
237
+ + 'each null when Reply gives none.\n'
238
+ + 'The message is read from stdin only, so its text never sits in the argument list. The reply goes to the thread\'s\n'
239
+ + 'contact from the account that owns the thread; no other recipient can be named. reply_to_message_id (email only)\n'
240
+ + 'answers one message of the thread; without it Reply answers the latest. inbox.send_failed means Reply could not\n'
241
+ + 'deliver it: "details.status_code" is Reply\'s reason (e.g. linkedInSendingLimitExceeded), null when it gave none.\n', 'the reply may have been sent; running the command again may send it twice, so read the thread first'))
242
+ .action(run(async (cmd) => {
243
+ const { g, ctx } = ctx_of(cmd);
244
+ await (0, inbox_reply_1.handle_inbox_reply)(cmd.args[0], cmd.opts(), ctx, g);
245
+ }));
246
+ inbox_command.command('categories')
247
+ .description('The inbox categories a thread can be filed under, Reply\'s reserved ones included')
248
+ .addHelpText('after', help([ex('inbox categories')], [], false, 'Result: {"items"}: Reply\'s categories as it gives them (id, name, color, isReserved, unreadThreadsCount).\n'))
249
+ .action(run(async (cmd) => {
250
+ const { g, ctx } = ctx_of(cmd);
251
+ await (0, inbox_1.handle_inbox_categories)(ctx, g);
252
+ }));
253
+ inbox_command.command('categorize')
254
+ .argument('<thread-id>', 'Inbox thread id')
255
+ .option('--category-id <id>', 'File the thread under this category (see `inbox categories`)')
256
+ .option('--clear', 'Take the thread out of its category')
257
+ .description('File a thread under one inbox category, or clear its category (a thread is in at most one)')
258
+ .addHelpText('after', help([ex('inbox categorize 9876 --category-id 7'), ex('inbox categorize 9876 --clear')], ['inbox.thread_not_found', 'inbox.category_not_found'], true, 'Result: {"status":"categorized"|"cleared","thread_id","category_id"}; category_id is null after --clear.\n'))
259
+ .action(run(async (cmd) => {
260
+ const { g, ctx } = ctx_of(cmd);
261
+ await (0, inbox_1.handle_inbox_categorize)(cmd.args[0], cmd.opts(), ctx, g);
262
+ }));
263
+ inbox_command.command('mark-read')
264
+ .argument('<thread-id>', 'Inbox thread id')
265
+ .description('Mark a thread as read (one that is already read stays read)')
266
+ .addHelpText('after', help([ex('inbox mark-read 9876')], ['inbox.thread_not_found'], true, 'Result: {"status":"read","thread_id"}\n'))
267
+ .action(run(async (cmd) => {
268
+ const { g, ctx } = ctx_of(cmd);
269
+ await (0, inbox_1.handle_inbox_mark_read)(cmd.args[0], ctx, g);
270
+ }));
271
+ inbox_command.command('mark-unread')
272
+ .argument('<thread-id>', 'Inbox thread id')
273
+ .description('Mark a thread as unread, so it needs attention again')
274
+ .addHelpText('after', help([ex('inbox mark-unread 9876')], ['inbox.thread_not_found'], true, 'Result: {"status":"unread","thread_id"}\n'))
275
+ .action(run(async (cmd) => {
276
+ const { g, ctx } = ctx_of(cmd);
277
+ await (0, inbox_1.handle_inbox_mark_unread)(cmd.args[0], ctx, g);
278
+ }));
279
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/operations/commands.ts"],"names":[],"mappings":";;;AAAA,yCAAkC;AAClC,sCAAuC;AACvC,wCAAyC;AACzC,uCAA0C;AAC1C,mDAAkE;AAClE,mDAAqG;AACrG,yDAAgF;AAChF,+DAAkG;AAClG,qDAA8E;AAC9E,mCAEiB;AACjB,+CAAiD;AACjD,iDAA+D;AAC/D,uCAAiD;AACjD,qDAAuH;AAEvH,MAAM,CAAC,GAAG,qBAAY,CAAC;AACvB,MAAM,aAAa,GAAG;IAClB,eAAe,EAAE,4BAA4B,EAAE,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,uBAAuB;CAC/H,CAAC;AAEF,MAAM,cAAc,GAAG,+CAA+C,CAAC;AAEvE,MAAM,WAAW,GAAG,CAAC,KAAe,EAAE,KAAc,EAAE,eAAuB,EAAS,EAAE,CACpF,6EAA6E;MAC3E,CAAC,GAAG,KAAK,EAAE,GAAG,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG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E,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { Command } from 'commander';
2
+ type Person = {
3
+ email?: string;
4
+ linkedin_url?: string;
5
+ first_name?: string;
6
+ last_name?: string;
7
+ company?: string;
8
+ title?: string;
9
+ };
10
+ type Contact_ref = {
11
+ kind: 'id';
12
+ id: number;
13
+ } | {
14
+ kind: 'person';
15
+ person: Person;
16
+ };
17
+ type Contact_flags = {
18
+ contactId?: string;
19
+ email?: string;
20
+ firstName?: string;
21
+ lastName?: string;
22
+ company?: string;
23
+ title?: string;
24
+ contact?: string;
25
+ };
26
+ declare const add_contact_options: (cmd: Command) => Command;
27
+ declare const CONTACT_HELP = "\nA contact is given exactly one way:\n --contact <json>|@file|- {email, linkedin_url, first_name, last_name, company, title},\n with an email, a LinkedIn URL or both; '-' reads stdin, which\n keeps personal data out of the argument list\n --email <address> [--first-name <name>] [--last-name <name>] [--company <name>] [--title <title>]\n --contact-id <id> a contact Reply already holds\nReply is asked about a contact by its email; one with only a LinkedIn URL, by that. A LinkedIn URL is\nmatched by its lowercased slug, and the CLI stores it by that slug when it imports the contact.\n\n";
28
+ declare const is_email: (text: string) => boolean;
29
+ declare const linkedin_key: (text: string) => string | null;
30
+ declare const person_of: (raw: Record<string, unknown>) => Person;
31
+ declare const read_contact_input: (f: Contact_flags, read_stdin?: () => string) => Contact_ref;
32
+ export { read_contact_input, add_contact_options, person_of, CONTACT_HELP, linkedin_key, is_email };
33
+ export type { Person, Contact_ref, Contact_flags };
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.is_email = exports.linkedin_key = exports.CONTACT_HELP = exports.person_of = exports.add_contact_options = exports.read_contact_input = void 0;
4
+ const errors_1 = require("../utils/errors");
5
+ const json_arg_1 = require("../utils/json-arg");
6
+ const options_1 = require("./options");
7
+ const PERSON_FIELDS = ['email', 'linkedin_url', 'first_name', 'last_name', 'company', 'title'];
8
+ const CODE = 'usage.contact';
9
+ const ONE_WAY_HINT = 'Use exactly one of --contact-id, --email (with its name flags), or --contact (which also takes linkedin_url).';
10
+ const add_contact_options = (cmd) => cmd
11
+ .option('--contact-id <id>', 'The contact by its Reply id')
12
+ .option('--email <address>', 'The contact by email; with --first-name, --last-name, --company, --title')
13
+ .option('--first-name <name>', 'First name (with --email; Reply refuses to import a contact without one)')
14
+ .option('--last-name <name>', 'Last name (with --email)')
15
+ .option('--company <name>', 'Company (with --email)')
16
+ .option('--title <title>', 'Job title (with --email)')
17
+ .option('--contact <json>', 'The contact as JSON {email, linkedin_url, first_name, last_name, company, title}: inline, @file, or - for stdin');
18
+ exports.add_contact_options = add_contact_options;
19
+ const CONTACT_HELP = `
20
+ A contact is given exactly one way:
21
+ --contact <json>|@file|- {email, linkedin_url, first_name, last_name, company, title},
22
+ with an email, a LinkedIn URL or both; '-' reads stdin, which
23
+ keeps personal data out of the argument list
24
+ --email <address> [--first-name <name>] [--last-name <name>] [--company <name>] [--title <title>]
25
+ --contact-id <id> a contact Reply already holds
26
+ Reply is asked about a contact by its email; one with only a LinkedIn URL, by that. A LinkedIn URL is
27
+ matched by its lowercased slug, and the CLI stores it by that slug when it imports the contact.
28
+
29
+ `;
30
+ exports.CONTACT_HELP = CONTACT_HELP;
31
+ const clean = (v) => {
32
+ const text = typeof v === 'string' ? v.trim() : '';
33
+ return text ? text : undefined;
34
+ };
35
+ const is_email = (text) => /^[^\s@]+@[^\s@]+$/.test(text);
36
+ exports.is_email = is_email;
37
+ const is_linkedin_host = (host) => host === 'linkedin.com' || host.endsWith('.linkedin.com');
38
+ // The form a profile URL is compared and written in, or null when the text is not an absolute
39
+ // http(s) URL. On linkedin.com and its subdomains a URL names a person by its slug whatever its case,
40
+ // so the path is lowercased there; on any other host it keeps its case. The case of the scheme and
41
+ // the host, a default port, one trailing slash and a fragment never count; www and the query do. The
42
+ // CLI stores and matches a LinkedIn URL by this form, so what it writes is what it later finds.
43
+ const linkedin_key = (text) => {
44
+ let url;
45
+ try {
46
+ url = new URL(text.trim());
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ if ((url.protocol !== 'http:' && url.protocol !== 'https:') || url.hostname === '') {
52
+ return null;
53
+ }
54
+ const trimmed = url.pathname.endsWith('/') ? url.pathname.slice(0, -1) : url.pathname;
55
+ const path = is_linkedin_host(url.hostname) ? trimmed.toLowerCase() : trimmed;
56
+ return `${url.protocol}//${url.host}${path}${url.search}`;
57
+ };
58
+ exports.linkedin_key = linkedin_key;
59
+ // The person as Reply will be asked about them: trimmed, empty fields dropped, an email or a
60
+ // LinkedIn URL required. Messages never echo either: a caller may log stderr where personal data
61
+ // must not go.
62
+ const person_of = (raw) => {
63
+ const email = clean(raw.email);
64
+ const linkedin_url = clean(raw.linkedin_url);
65
+ if (email === undefined && linkedin_url === undefined) {
66
+ throw new errors_1.UsageError('The contact needs an email or a LinkedIn URL.', { code: CODE, hint: ONE_WAY_HINT });
67
+ }
68
+ if (email !== undefined && !is_email(email)) {
69
+ throw new errors_1.UsageError('The contact\'s email is not an email address.', { code: CODE });
70
+ }
71
+ if (linkedin_url !== undefined && linkedin_key(linkedin_url) === null) {
72
+ throw new errors_1.UsageError('The contact\'s linkedin_url is not an absolute http or https URL.', { code: CODE });
73
+ }
74
+ const person = {};
75
+ if (email !== undefined) {
76
+ person.email = email;
77
+ }
78
+ if (linkedin_url !== undefined) {
79
+ person.linkedin_url = linkedin_url;
80
+ }
81
+ for (const field of ['first_name', 'last_name', 'company', 'title']) {
82
+ const value = clean(raw[field]);
83
+ if (value !== undefined) {
84
+ person[field] = value;
85
+ }
86
+ }
87
+ return person;
88
+ };
89
+ exports.person_of = person_of;
90
+ const person_from_json = (value) => {
91
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
92
+ throw new errors_1.UsageError('--contact must be a JSON object.', { code: CODE, hint: `Fields: ${PERSON_FIELDS.join(', ')}.` });
93
+ }
94
+ const fields = value;
95
+ const unknown_field = Object.keys(fields).find(k => !PERSON_FIELDS.includes(k));
96
+ if (unknown_field !== undefined) {
97
+ throw new errors_1.UsageError(`--contact has an unknown field '${unknown_field}'.`, { code: CODE, hint: `Fields: ${PERSON_FIELDS.join(', ')}.` });
98
+ }
99
+ for (const field of PERSON_FIELDS) {
100
+ if (fields[field] !== undefined && fields[field] !== null && typeof fields[field] !== 'string') {
101
+ throw new errors_1.UsageError(`--contact field '${field}' must be a string.`, { code: CODE });
102
+ }
103
+ }
104
+ return person_of(fields);
105
+ };
106
+ const read_contact_input = (f, read_stdin) => {
107
+ const by_flags = [f.email, f.firstName, f.lastName, f.company, f.title].some(v => v !== undefined);
108
+ const forms = [f.contactId !== undefined, by_flags, f.contact !== undefined].filter(Boolean).length;
109
+ if (forms !== 1) {
110
+ throw new errors_1.UsageError(forms === 0 ? 'No contact was given.' : 'The contact was given more than one way.', { code: CODE, hint: ONE_WAY_HINT });
111
+ }
112
+ if (f.contactId !== undefined) {
113
+ return { kind: 'id', id: (0, options_1.parse_id)(f.contactId, '--contact-id') };
114
+ }
115
+ if (f.contact !== undefined) {
116
+ return { kind: 'person', person: person_from_json((0, json_arg_1.read_json_arg)(f.contact, { flag: '--contact', what: 'contact', code: CODE, read_stdin })) };
117
+ }
118
+ return { kind: 'person', person: person_of({
119
+ email: f.email, first_name: f.firstName, last_name: f.lastName, company: f.company, title: f.title,
120
+ }) };
121
+ };
122
+ exports.read_contact_input = read_contact_input;
123
+ //# sourceMappingURL=contact-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contact-input.js","sourceRoot":"","sources":["../../src/operations/contact-input.ts"],"names":[],"mappings":";;;AACA,4CAA2C;AAC3C,gDAAgD;AAChD,uCAAmC;AAenC,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AACxG,MAAM,IAAI,GAAG,eAAe,CAAC;AAC7B,MAAM,YAAY,GAAG,+GAA+G,CA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,MAAM,IAAI,mBAAU,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,0CAA0C,EAAE,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAC,CAAC,CAAC;IAC/I,CAAC;IACD,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS,EAC7B,CAAC;QACG,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAA,kBAAQ,EAAC,CAAC,CAAC,SAAS,EAAE,cAAc,CAAC,EAAC,CAAC;IACnE,CAAC;IACD,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS,EAC3B,CAAC;QACG,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,CAAC,IAAA,wBAAa,EAAC,CAAC,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAC,CAAC,CAAC,EAAC,CAAC;IAC9I,CAAC;IACD,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC;YACtC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK;SACrG,CAAC,EAAC,CAAC;AACR,CAAC,CAAC;AAEM,gDAAkB"}
@@ -0,0 +1,9 @@
1
+ import { type Op_globals } from './options';
2
+ import { type Contact_flags } from './contact-input';
3
+ import type { Cli_context } from '../context';
4
+ type List_add_opts = Contact_flags & {
5
+ refuseOptedOut?: boolean;
6
+ };
7
+ declare const handle_contact_list_add_contact: (list_arg: string, opts: List_add_opts, ctx: Cli_context, g: Op_globals, read_stdin?: () => string) => Promise<void>;
8
+ export { handle_contact_list_add_contact };
9
+ export type { List_add_opts };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handle_contact_list_add_contact = void 0;
4
+ const errors_1 = require("../utils/errors");
5
+ const call_1 = require("./call");
6
+ const options_1 = require("./options");
7
+ const contact_input_1 = require("./contact-input");
8
+ const contacts_1 = require("./contacts");
9
+ const result_1 = require("./result");
10
+ const add_to_list = async (s, list_id, contact_id) => {
11
+ const a = await (0, call_1.call_reply)(s, 'POST', `/v3/contact-lists/${list_id}/add-contacts`, 'write', { contactIds: [contact_id] });
12
+ if (a.status === 404) {
13
+ throw new errors_1.Operation_error('contact-list.not_found', `This account has no contact list ${list_id}.`, {
14
+ status: 404, reply_code: (0, call_1.reply_code_of)(a),
15
+ });
16
+ }
17
+ if (a.status !== 200) {
18
+ throw (0, call_1.refusal)(a, 'write');
19
+ }
20
+ // The answer is a failures-only dictionary: a contact missing from it was added, or already
21
+ // on the list.
22
+ const failed = (0, call_1.item_failure)((0, call_1.expect_object)(a, 'write'), contact_id);
23
+ if (failed !== undefined) {
24
+ throw new errors_1.Operation_error('reply.refused', 'Reply did not add the contact to the list.', {
25
+ status: 200, reply_code: failed.error ?? undefined, detail: failed.details ?? undefined,
26
+ });
27
+ }
28
+ };
29
+ const handle_contact_list_add_contact = async (list_arg, opts, ctx, g, read_stdin) => {
30
+ const list_id = (0, options_1.parse_id)(list_arg, 'List id');
31
+ const contact = (0, contact_input_1.read_contact_input)(opts, read_stdin);
32
+ const s = await (0, call_1.open_session)(ctx, g);
33
+ const ids = { list_id };
34
+ try {
35
+ const ensured = await (0, contacts_1.ensure_contact)(s, contact);
36
+ ids.contact_id = ensured.id;
37
+ // The caller's policy, not an API gap: a Reply list may hold opted-out contacts, but a
38
+ // caller that keeps opted-out people off its outreach lists asks for the check.
39
+ if (opts.refuseOptedOut === true && await (0, contacts_1.read_opted_out)(s, ensured.id)) {
40
+ throw new errors_1.Operation_error('contact.opted_out', `Contact ${ensured.id} is opted out, so it was not added to the list.`, { status: 200 });
41
+ }
42
+ await add_to_list(s, list_id, ensured.id);
43
+ (0, result_1.print_result)({ status: 'added', list_id, contact_id: ensured.id, contact_created: ensured.created }, g);
44
+ }
45
+ catch (e) {
46
+ throw (0, result_1.with_ids)(e, ids);
47
+ }
48
+ };
49
+ exports.handle_contact_list_add_contact = handle_contact_list_add_contact;
50
+ //# sourceMappingURL=contact-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contact-list.js","sourceRoot":"","sources":["../../src/operations/contact-list.ts"],"names":[],"mappings":";;;AAAA,4CAA0D;AAC1D,iCAAsH;AACtH,uCAAoD;AACpD,mDAAuE;AACvE,yCAA0D;AAC1D,qCAAgD;AAKhD,MAAM,WAAW,GAAG,KAAK,EAAC,CAAa,EAAE,OAAe,EAAE,UAAkB,EAAgB,EAAE;IAC1F,MAAM,CAAC,GAAG,MAAM,IAAA,iBAAU,EAAC,CAAC,EAAE,MAAM,EAAE,qBAAqB,OAAO,eAAe,EAAE,OAAO,EAAE,EAAC,UAAU,EAAE,CAAC,UAAU,CAAC,EAAC,CAAC,CAAC;IACxH,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EACpB,CAAC;QACG,MAAM,IAAI,wBAAe,CAAC,wBAAwB,EAAE,oCAAoC,OAAO,GAAG,EAAE;YAChG,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,IAAA,oBAAa,EAAC,CAAC,CAAC;SAC5C,CAAC,CAAC;IACP,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EACpB,CAAC;QACG,MAAM,IAAA,cAAO,EAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;IACD,4FAA4F;IAC5F,eAAe;IACf,MAAM,MAAM,GAAG,IAAA,mBAAY,EAAC,IAAA,oBAAa,EAAC,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;IACnE,IAAI,MAAM,KAAK,SAAS,EACxB,CAAC;QACG,MA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e,EAAE,OAAO,CAAC,OAAO,EAAC,EAAE,CAAC,CAAC,CAAC;IAC1G,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,IAAA,iBAAQ,EAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEM,0EAA+B"}
@@ -0,0 +1,11 @@
1
+ import { type Op_globals } from './options';
2
+ import type { Cli_context } from '../context';
3
+ declare const handle_contact_find: (opts: {
4
+ contact?: string;
5
+ }, ctx: Cli_context, g: Op_globals, read_stdin?: () => string) => Promise<void>;
6
+ declare const handle_contact_get: (id_arg: string, ctx: Cli_context, g: Op_globals) => Promise<void>;
7
+ declare const handle_contact_update: (id_arg: string, opts: {
8
+ fields?: string;
9
+ }, ctx: Cli_context, g: Op_globals, read_stdin?: () => string) => Promise<void>;
10
+ declare const handle_contact_delete: (id_arg: string, ctx: Cli_context, g: Op_globals) => Promise<void>;
11
+ export { handle_contact_find, handle_contact_get, handle_contact_update, handle_contact_delete };