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.
- package/README.md +137 -11
- package/dist/commands/api.js +2 -40
- package/dist/commands/api.js.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/operations/call.d.ts +35 -0
- package/dist/operations/call.js +131 -0
- package/dist/operations/call.js.map +1 -0
- package/dist/operations/commands.d.ts +6 -0
- package/dist/operations/commands.js +279 -0
- package/dist/operations/commands.js.map +1 -0
- package/dist/operations/contact-input.d.ts +33 -0
- package/dist/operations/contact-input.js +123 -0
- package/dist/operations/contact-input.js.map +1 -0
- package/dist/operations/contact-list.d.ts +9 -0
- package/dist/operations/contact-list.js +50 -0
- package/dist/operations/contact-list.js.map +1 -0
- package/dist/operations/contact-record.d.ts +11 -0
- package/dist/operations/contact-record.js +176 -0
- package/dist/operations/contact-record.js.map +1 -0
- package/dist/operations/contact.d.ts +7 -0
- package/dist/operations/contact.js +53 -0
- package/dist/operations/contact.js.map +1 -0
- package/dist/operations/contacts.d.ts +15 -0
- package/dist/operations/contacts.js +180 -0
- package/dist/operations/contacts.js.map +1 -0
- package/dist/operations/inbox-reply.d.ts +11 -0
- package/dist/operations/inbox-reply.js +160 -0
- package/dist/operations/inbox-reply.js.map +1 -0
- package/dist/operations/inbox.d.ts +40 -0
- package/dist/operations/inbox.js +180 -0
- package/dist/operations/inbox.js.map +1 -0
- package/dist/operations/options.d.ts +18 -0
- package/dist/operations/options.js +63 -0
- package/dist/operations/options.js.map +1 -0
- package/dist/operations/result.d.ts +5 -0
- package/dist/operations/result.js +20 -0
- package/dist/operations/result.js.map +1 -0
- package/dist/operations/sequence-by-name.d.ts +9 -0
- package/dist/operations/sequence-by-name.js +96 -0
- package/dist/operations/sequence-by-name.js.map +1 -0
- package/dist/operations/sequence-membership.d.ts +13 -0
- package/dist/operations/sequence-membership.js +227 -0
- package/dist/operations/sequence-membership.js.map +1 -0
- package/dist/operations/sequence-read.d.ts +26 -0
- package/dist/operations/sequence-read.js +121 -0
- package/dist/operations/sequence-read.js.map +1 -0
- package/dist/operations/sequence-state.d.ts +7 -0
- package/dist/operations/sequence-state.js +88 -0
- package/dist/operations/sequence-state.js.map +1 -0
- package/dist/operations/stdin-input.d.ts +10 -0
- package/dist/operations/stdin-input.js +34 -0
- package/dist/operations/stdin-input.js.map +1 -0
- package/dist/skills/adapter-flat.d.ts +3 -1
- package/dist/skills/adapter-flat.js +49 -19
- package/dist/skills/adapter-flat.js.map +1 -1
- package/dist/skills/hosts.js +35 -13
- package/dist/skills/hosts.js.map +1 -1
- package/dist/skills/orchestrate.js +41 -4
- package/dist/skills/orchestrate.js.map +1 -1
- package/dist/skills/report.js +36 -10
- package/dist/skills/report.js.map +1 -1
- package/dist/skills/types.d.ts +11 -1
- package/dist/utils/client.d.ts +5 -2
- package/dist/utils/client.js +113 -78
- package/dist/utils/client.js.map +1 -1
- package/dist/utils/errors.d.ts +29 -2
- package/dist/utils/errors.js +40 -2
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/json-arg.d.ts +10 -0
- package/dist/utils/json-arg.js +45 -0
- package/dist/utils/json-arg.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handle_contact_delete = exports.handle_contact_update = exports.handle_contact_get = exports.handle_contact_find = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const errors_1 = require("../utils/errors");
|
|
6
|
+
const call_1 = require("./call");
|
|
7
|
+
const options_1 = require("./options");
|
|
8
|
+
const contact_input_1 = require("./contact-input");
|
|
9
|
+
const contacts_1 = require("./contacts");
|
|
10
|
+
const stdin_input_1 = require("./stdin-input");
|
|
11
|
+
const result_1 = require("./result");
|
|
12
|
+
const FIND_FIELDS = ['email', 'linkedin_url'];
|
|
13
|
+
// The address is read from stdin only and is never repeated in a message.
|
|
14
|
+
const read_find_input = (source, read_stdin) => {
|
|
15
|
+
const raw = (0, stdin_input_1.read_stdin_object)(source, {
|
|
16
|
+
flag: '--contact', what: 'contact', fields: FIND_FIELDS, code: 'usage.contact',
|
|
17
|
+
hint: `Pipe it in: echo '{"email":"…"}' | ${config_1.PROGRAM_NAME} contact find --contact -`,
|
|
18
|
+
}, read_stdin);
|
|
19
|
+
const given = FIND_FIELDS.filter(k => raw[k] !== undefined && raw[k] !== null);
|
|
20
|
+
if (given.length !== 1) {
|
|
21
|
+
throw new errors_1.UsageError('Give exactly one of email and linkedin_url.', { code: 'usage.contact' });
|
|
22
|
+
}
|
|
23
|
+
if (typeof raw[given[0]] !== 'string') {
|
|
24
|
+
throw new errors_1.UsageError(`The contact's ${given[0]} must be a string.`, { code: 'usage.contact' });
|
|
25
|
+
}
|
|
26
|
+
return (0, contact_input_1.person_of)(raw);
|
|
27
|
+
};
|
|
28
|
+
// Only looks: a contact Reply does not hold is answered with a null id, never created.
|
|
29
|
+
const handle_contact_find = async (opts, ctx, g, read_stdin) => {
|
|
30
|
+
const person = read_find_input(opts.contact, read_stdin);
|
|
31
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
32
|
+
(0, result_1.print_result)({ contact_id: await (0, contacts_1.find_contact_by_address)(s, person) }, g);
|
|
33
|
+
};
|
|
34
|
+
exports.handle_contact_find = handle_contact_find;
|
|
35
|
+
const handle_contact_get = async (id_arg, ctx, g) => {
|
|
36
|
+
const id = (0, options_1.parse_id)(id_arg, 'Contact id');
|
|
37
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
38
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/contacts/${id}`, 'read');
|
|
39
|
+
if (a.status === 404) {
|
|
40
|
+
throw (0, contacts_1.contact_not_found)(id, a);
|
|
41
|
+
}
|
|
42
|
+
if (a.status !== 200) {
|
|
43
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
44
|
+
}
|
|
45
|
+
(0, result_1.print_result)((0, call_1.expect_object)(a, 'read'), g);
|
|
46
|
+
};
|
|
47
|
+
exports.handle_contact_get = handle_contact_get;
|
|
48
|
+
// The CLI's field names and Reply's.
|
|
49
|
+
const UPDATE_FIELDS = { first_name: 'firstName', last_name: 'lastName', company: 'company', title: 'title', linkedin_url: 'linkedInUrl' };
|
|
50
|
+
const FIELDS_CODE = 'usage.fields';
|
|
51
|
+
// A value to set (trimmed, not blank) or null to clear. Never repeated in a message.
|
|
52
|
+
const field_value = (raw, label) => {
|
|
53
|
+
if (raw === null) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
if (typeof raw !== 'string' || raw.trim() === '') {
|
|
57
|
+
throw new errors_1.UsageError(`${label} must be a string that is not blank, or null to clear it.`, { code: FIELDS_CODE });
|
|
58
|
+
}
|
|
59
|
+
return raw.trim();
|
|
60
|
+
};
|
|
61
|
+
const custom_values_of = (raw) => {
|
|
62
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
63
|
+
throw new errors_1.UsageError('custom_fields must be a list of at least one {name, value}.', { code: FIELDS_CODE });
|
|
64
|
+
}
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
return raw.map((entry, index) => {
|
|
67
|
+
const label = `custom_fields[${index}]`;
|
|
68
|
+
if (!(0, call_1.is_object)(entry) || Object.keys(entry).some(k => k !== 'name' && k !== 'value') || !('value' in entry)) {
|
|
69
|
+
throw new errors_1.UsageError(`${label} must be {name, value}, with value null to clear the field.`, { code: FIELDS_CODE });
|
|
70
|
+
}
|
|
71
|
+
if (typeof entry.name !== 'string' || entry.name.trim() === '') {
|
|
72
|
+
throw new errors_1.UsageError(`${label}'s name must be a string that is not blank.`, { code: FIELDS_CODE });
|
|
73
|
+
}
|
|
74
|
+
const name = entry.name.trim();
|
|
75
|
+
if (seen.has(name.toLowerCase())) {
|
|
76
|
+
throw new errors_1.UsageError(`${label} names a custom field already given.`, { code: FIELDS_CODE });
|
|
77
|
+
}
|
|
78
|
+
seen.add(name.toLowerCase());
|
|
79
|
+
return { name, value: field_value(entry.value, `${label}'s value`) };
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
// The values are read from stdin only and are never repeated in a message.
|
|
83
|
+
const read_contact_update = (source, read_stdin) => {
|
|
84
|
+
const fields = [...Object.keys(UPDATE_FIELDS), 'custom_fields'];
|
|
85
|
+
const raw = (0, stdin_input_1.read_stdin_object)(source, {
|
|
86
|
+
flag: '--fields', what: 'fields', fields, code: FIELDS_CODE,
|
|
87
|
+
hint: `Pipe them in: echo '{"title":"…"}' | ${config_1.PROGRAM_NAME} contact update <contact-id> --fields -`,
|
|
88
|
+
}, read_stdin);
|
|
89
|
+
if (fields.every(k => raw[k] === undefined)) {
|
|
90
|
+
throw new errors_1.UsageError('The fields name nothing to change.', { code: FIELDS_CODE, hint: `Fields: ${fields.join(', ')}.` });
|
|
91
|
+
}
|
|
92
|
+
const patch = {};
|
|
93
|
+
for (const field of Object.keys(UPDATE_FIELDS)) {
|
|
94
|
+
if (raw[field] === undefined) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
let value = field_value(raw[field], field);
|
|
98
|
+
if (field === 'linkedin_url' && value !== null) {
|
|
99
|
+
// Written in the form it is looked up by: its lowercased slug.
|
|
100
|
+
value = (0, contact_input_1.linkedin_key)(value);
|
|
101
|
+
if (value === null) {
|
|
102
|
+
throw new errors_1.UsageError('linkedin_url must be an absolute http or https URL.', { code: FIELDS_CODE });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
patch[UPDATE_FIELDS[field]] = value;
|
|
106
|
+
}
|
|
107
|
+
return { patch, custom: raw.custom_fields === undefined ? undefined : custom_values_of(raw.custom_fields) };
|
|
108
|
+
};
|
|
109
|
+
// INTERIM (API gap): PATCH /v3/contacts/{id} publishes no refusal for a custom field name the team
|
|
110
|
+
// does not have, so such a field may be dropped or refused without a code while the rest is written.
|
|
111
|
+
// Needed: a coded refusal for an unknown custom field, with nothing written.
|
|
112
|
+
// Workaround: when an update names custom fields, read the account's contact fields once and refuse
|
|
113
|
+
// a name none of them carries before anything is written. A name matches ignoring case, and is sent
|
|
114
|
+
// as the account spells it.
|
|
115
|
+
const resolve_custom_fields = async (s, custom) => {
|
|
116
|
+
const a = await (0, call_1.call_reply)(s, 'GET', '/v3/custom-fields?entityType=contact', 'read');
|
|
117
|
+
if (a.status !== 200) {
|
|
118
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
119
|
+
}
|
|
120
|
+
if (!Array.isArray(a.data)) {
|
|
121
|
+
throw (0, call_1.unreadable)(a, 'read');
|
|
122
|
+
}
|
|
123
|
+
const titles = a.data.filter(call_1.is_object).map(f => f.title).filter((t) => typeof t === 'string');
|
|
124
|
+
const title_of = (name) => titles.includes(name) ? name : titles.find(t => t.toLowerCase() === name.toLowerCase());
|
|
125
|
+
const missing = custom.map(c => c.name).filter(name => title_of(name) === undefined);
|
|
126
|
+
if (missing.length > 0) {
|
|
127
|
+
throw new errors_1.Operation_error('contact.field_not_found', 'The account has no contact custom field by a name given, so nothing was changed.', {
|
|
128
|
+
status: 200, details: { fields: missing },
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return custom.map(c => ({ name: title_of(c.name), value: c.value }));
|
|
132
|
+
};
|
|
133
|
+
const handle_contact_update = async (id_arg, opts, ctx, g, read_stdin) => {
|
|
134
|
+
const id = (0, options_1.parse_id)(id_arg, 'Contact id');
|
|
135
|
+
const { patch, custom } = read_contact_update(opts.fields, read_stdin);
|
|
136
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
137
|
+
try {
|
|
138
|
+
// Absent fields stay as they are; a null clears one. Custom fields go by name.
|
|
139
|
+
const body = custom === undefined ? patch : { ...patch, customFields: await resolve_custom_fields(s, custom) };
|
|
140
|
+
const a = await (0, call_1.call_reply)(s, 'PATCH', `/v3/contacts/${id}`, 'write', body);
|
|
141
|
+
if (a.status === 404) {
|
|
142
|
+
throw (0, contacts_1.contact_not_found)(id, a);
|
|
143
|
+
}
|
|
144
|
+
if (a.status !== 200 && a.status !== 204) {
|
|
145
|
+
throw (0, call_1.refusal)(a, 'write');
|
|
146
|
+
}
|
|
147
|
+
(0, result_1.print_result)({ status: 'updated', contact_id: id }, g);
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
throw (0, result_1.with_ids)(e, { contact_id: id });
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
exports.handle_contact_update = handle_contact_update;
|
|
154
|
+
const handle_contact_delete = async (id_arg, ctx, g) => {
|
|
155
|
+
const id = (0, options_1.parse_id)(id_arg, 'Contact id');
|
|
156
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
157
|
+
try {
|
|
158
|
+
const a = await (0, call_1.call_reply)(s, 'DELETE', `/v3/contacts/${id}`, 'write');
|
|
159
|
+
if (a.status === 404) {
|
|
160
|
+
throw (0, contacts_1.contact_not_found)(id, a);
|
|
161
|
+
}
|
|
162
|
+
if (a.status !== 204 && a.status !== 200) {
|
|
163
|
+
throw (0, call_1.refusal)(a, 'write');
|
|
164
|
+
}
|
|
165
|
+
(0, result_1.print_result)({ status: 'deleted', contact_id: id }, g);
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
// Safe to repeat, but not with the same answer: once the contact is gone, a repeat is told it is missing.
|
|
169
|
+
if (e instanceof errors_1.Unknown_outcome_error) {
|
|
170
|
+
e.hint = 'The contact may have been deleted. Running the command again is safe; it answers contact.not_found if it was.';
|
|
171
|
+
}
|
|
172
|
+
throw (0, result_1.with_ids)(e, { contact_id: id });
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
exports.handle_contact_delete = handle_contact_delete;
|
|
176
|
+
//# sourceMappingURL=contact-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-record.js","sourceRoot":"","sources":["../../src/operations/contact-record.ts"],"names":[],"mappings":";;;AAAA,sCAAuC;AACvC,4CAAmF;AACnF,iCAAg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';
|
|
3
|
+
import type { Cli_context } from '../context';
|
|
4
|
+
type Opt_out_opts = Contact_flags;
|
|
5
|
+
declare const handle_contact_opt_out: (opts: Opt_out_opts, ctx: Cli_context, g: Op_globals, read_stdin?: () => string) => Promise<void>;
|
|
6
|
+
export { handle_contact_opt_out };
|
|
7
|
+
export type { Opt_out_opts };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handle_contact_opt_out = void 0;
|
|
4
|
+
const errors_1 = require("../utils/errors");
|
|
5
|
+
const call_1 = require("./call");
|
|
6
|
+
const contact_input_1 = require("./contact-input");
|
|
7
|
+
const contacts_1 = require("./contacts");
|
|
8
|
+
const result_1 = require("./result");
|
|
9
|
+
// Sets the flag; there is no read before it, because Reply answers a contact who is already opted
|
|
10
|
+
// out with the same success.
|
|
11
|
+
const set_opted_out = async (s, contact_id) => {
|
|
12
|
+
const a = await (0, call_1.call_reply)(s, 'POST', '/v3/contacts/set-opted-out', 'write', { contactIds: [contact_id], isOptedOut: true });
|
|
13
|
+
if (a.status !== 200) {
|
|
14
|
+
throw (0, call_1.refusal)(a, 'write');
|
|
15
|
+
}
|
|
16
|
+
const failed = (0, call_1.item_failure)((0, call_1.expect_object)(a, 'write'), contact_id);
|
|
17
|
+
if (failed?.error === 'notFound') {
|
|
18
|
+
throw new errors_1.Operation_error('contact.not_found', `This account has no contact ${contact_id}.`, { status: 200, reply_code: 'notFound' });
|
|
19
|
+
}
|
|
20
|
+
if (failed !== undefined) {
|
|
21
|
+
throw new errors_1.Operation_error('reply.refused', 'Reply did not opt the contact out.', {
|
|
22
|
+
status: 200, reply_code: failed.error ?? undefined, detail: failed.details ?? undefined,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const handle_contact_opt_out = async (opts, ctx, g, read_stdin) => {
|
|
27
|
+
const contact = (0, contact_input_1.read_contact_input)(opts, read_stdin);
|
|
28
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
29
|
+
const ids = {};
|
|
30
|
+
try {
|
|
31
|
+
// The person Reply already holds, so the opt-out lands on them. A contact is created only
|
|
32
|
+
// when Reply holds nobody under the address, by an import that asks nothing again.
|
|
33
|
+
let contact_id;
|
|
34
|
+
let created = false;
|
|
35
|
+
if (contact.kind === 'id') {
|
|
36
|
+
contact_id = contact.id;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const found = await (0, contacts_1.find_contact_by_address)(s, contact.person);
|
|
40
|
+
const ensured = found === null ? await (0, contacts_1.import_contact)(s, contact.person) : { id: found, created: false };
|
|
41
|
+
contact_id = ensured.id;
|
|
42
|
+
created = ensured.created;
|
|
43
|
+
}
|
|
44
|
+
ids.contact_id = contact_id;
|
|
45
|
+
await set_opted_out(s, contact_id);
|
|
46
|
+
(0, result_1.print_result)({ status: 'opted_out', contact_id, contact_created: created }, g);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
throw (0, result_1.with_ids)(e, ids);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.handle_contact_opt_out = handle_contact_opt_out;
|
|
53
|
+
//# sourceMappingURL=contact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact.js","sourceRoot":"","sources":["../../src/operations/contact.ts"],"names":[],"mappings":";;;AAAA,4CAA0D;AAC1D,iCAAuG;AAEvG,mDAAuE;AACvE,yCAAmE;AACnE,qCAAgD;AAKhD,kGAAkG;AAClG,6BAA6B;AAC7B,MAAM,aAAa,GAAG,KAAK,EAAC,CAAa,EAAE,UAAkB,EAAgB,EAAE;IAC3E,MAAM,CAAC,GAAG,MAAM,IAAA,iBAAU,EAAC,CAAC,EAAE,MAAM,EAAE,4BAA4B,EAAE,OAAO,EAAE,EAAC,UAAU,EAAE,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC;IAC3H,IAAI,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MAAM,IAAA,kCAAuB,EAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAC/D,MAAM,OAAO,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,IAAA,yBAAc,EAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAC,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC;YACvG,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;YACxB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC9B,CAAC;QACD,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;QAC5B,MAAM,aAAa,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QACnC,IAAA,qBAAY,EAAC,EAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAC,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,IAAA,iBAAQ,EAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEM,wDAAsB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Operation_error } from '../utils/errors';
|
|
2
|
+
import { type Answer, type Op_session } from './call';
|
|
3
|
+
import { type Contact_ref, type Person } from './contact-input';
|
|
4
|
+
type Ensured = {
|
|
5
|
+
id: number;
|
|
6
|
+
created: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const import_contact: (s: Op_session, person: Person) => Promise<Ensured>;
|
|
9
|
+
declare const find_contact_by_address: (s: Op_session, person: Person) => Promise<number | null>;
|
|
10
|
+
declare const ensure_contact: (s: Op_session, ref: Contact_ref) => Promise<Ensured>;
|
|
11
|
+
declare const find_contact: (s: Op_session, ref: Contact_ref) => Promise<number | null>;
|
|
12
|
+
declare const contact_not_found: (contact_id: number, a: Answer) => Operation_error;
|
|
13
|
+
declare const read_opted_out: (s: Op_session, contact_id: number) => Promise<boolean>;
|
|
14
|
+
export { ensure_contact, import_contact, find_contact, find_contact_by_address, read_opted_out, contact_not_found };
|
|
15
|
+
export type { Ensured };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contact_not_found = exports.read_opted_out = exports.find_contact_by_address = exports.find_contact = exports.import_contact = exports.ensure_contact = void 0;
|
|
4
|
+
const errors_1 = require("../utils/errors");
|
|
5
|
+
const call_1 = require("./call");
|
|
6
|
+
const contact_input_1 = require("./contact-input");
|
|
7
|
+
const LOOKUP_PAGE = 100;
|
|
8
|
+
const LOOKUP_PAGES = 10;
|
|
9
|
+
const import_item = (p) => {
|
|
10
|
+
const item = {};
|
|
11
|
+
if (p.email !== undefined) {
|
|
12
|
+
item.email = p.email;
|
|
13
|
+
}
|
|
14
|
+
if (p.linkedin_url !== undefined) {
|
|
15
|
+
// Written in the form it is looked up by.
|
|
16
|
+
item.linkedInUrl = (0, contact_input_1.linkedin_key)(p.linkedin_url) ?? p.linkedin_url;
|
|
17
|
+
}
|
|
18
|
+
if (p.first_name !== undefined) {
|
|
19
|
+
item.firstName = p.first_name;
|
|
20
|
+
}
|
|
21
|
+
if (p.last_name !== undefined) {
|
|
22
|
+
item.lastName = p.last_name;
|
|
23
|
+
}
|
|
24
|
+
if (p.company !== undefined) {
|
|
25
|
+
item.company = p.company;
|
|
26
|
+
}
|
|
27
|
+
if (p.title !== undefined) {
|
|
28
|
+
item.title = p.title;
|
|
29
|
+
}
|
|
30
|
+
return item;
|
|
31
|
+
};
|
|
32
|
+
const names_field = (a, name) => (0, call_1.invalid_fields)(a)?.some(field => field.toLowerCase() === name.toLowerCase()) === true;
|
|
33
|
+
// v3's import matches an existing contact by email or creates one, and says which, in one call; on
|
|
34
|
+
// a match it fills only the contact's empty fields. A contact with no email is matched by its
|
|
35
|
+
// LinkedIn URL instead: the import's keys add to the email rather than replace it, so that key is
|
|
36
|
+
// asked for only when there is no email to match. Reply requires a first name here, even for a
|
|
37
|
+
// contact it already holds, and refuses an item without one as "Invalid data", which is passed on as
|
|
38
|
+
// reply.refused. POST /v3/contacts is not used: it also requires a first name, and for an email Reply
|
|
39
|
+
// already holds it overwrites that contact and blanks every field the request did not send.
|
|
40
|
+
const import_contact = async (s, person) => {
|
|
41
|
+
const body = { items: [import_item(person)] };
|
|
42
|
+
if (person.email === undefined) {
|
|
43
|
+
body.options = { keys: { linkedInUrl: true } };
|
|
44
|
+
}
|
|
45
|
+
const a = await (0, call_1.call_reply)(s, 'POST', '/v3/contacts/import', 'write', body);
|
|
46
|
+
if (a.status === 400 && names_field(a, 'email')) {
|
|
47
|
+
throw new errors_1.Operation_error('contact.invalid_email', 'Reply did not accept the contact\'s email address.', {
|
|
48
|
+
status: 400, reply_code: (0, call_1.reply_code_of)(a),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (a.status === 400 && names_field(a, 'linkedInUrl')) {
|
|
52
|
+
throw new errors_1.Operation_error('contact.invalid_linkedin_url', 'Reply did not accept the contact\'s LinkedIn URL.', {
|
|
53
|
+
status: 400, reply_code: (0, call_1.reply_code_of)(a),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (a.status === 400 && (0, call_1.reply_code_of)(a) === 'contact.limitExceeded') {
|
|
57
|
+
throw new errors_1.Operation_error('account.contact_limit_reached', 'The account holds as many contacts as its plan allows.', {
|
|
58
|
+
status: 400, reply_code: 'contact.limitExceeded', detail: (0, call_1.detail_of)(a),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (a.status !== 200) {
|
|
62
|
+
throw (0, call_1.refusal)(a, 'write');
|
|
63
|
+
}
|
|
64
|
+
const answer = (0, call_1.expect_object)(a, 'write');
|
|
65
|
+
const item = Array.isArray(answer.items) ? answer.items[0] : undefined;
|
|
66
|
+
if (!(0, call_1.is_object)(item)) {
|
|
67
|
+
throw (0, call_1.unreadable)(a, 'write');
|
|
68
|
+
}
|
|
69
|
+
// A skipped item still names the contact Reply holds under the address (a teammate's, say),
|
|
70
|
+
// except a deleted one, which can't be worked with.
|
|
71
|
+
if (!(0, call_1.is_reply_id)(item.id) || item.status === 'failed' || item.skipReason === 'contactDeleted') {
|
|
72
|
+
throw new errors_1.Operation_error('reply.refused', 'Reply did not import the contact.', {
|
|
73
|
+
status: 200,
|
|
74
|
+
reply_code: typeof item.skipReason === 'string' ? item.skipReason : undefined,
|
|
75
|
+
detail: typeof item.error === 'string' ? item.error : undefined,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return { id: item.id, created: item.status === 'created' };
|
|
79
|
+
};
|
|
80
|
+
exports.import_contact = import_contact;
|
|
81
|
+
// What a person is looked up by: the email when there is one, else the LinkedIn URL. An entry
|
|
82
|
+
// counts only when it carries the same address: an email equal ignoring case, a LinkedIn URL equal
|
|
83
|
+
// under linkedin_key.
|
|
84
|
+
// INTERIM (API gap): the document does not say whether the exact lookup by LinkedIn URL ignores case.
|
|
85
|
+
// Needed: a lookup that matches a LinkedIn URL by its slug whatever its case, or a word that it does.
|
|
86
|
+
// Workaround: ask with the URL in the form it is written in (its lowercased slug) first, then as
|
|
87
|
+
// given, and count the matches of both together, so one slug held under two spellings is refused
|
|
88
|
+
// rather than half seen.
|
|
89
|
+
const lookup_of = (p) => {
|
|
90
|
+
if (p.email !== undefined) {
|
|
91
|
+
const wanted = p.email.toLowerCase();
|
|
92
|
+
return { param: 'email', values: [p.email], holds: entry => typeof entry.email === 'string' && entry.email.toLowerCase() === wanted };
|
|
93
|
+
}
|
|
94
|
+
const given = p.linkedin_url;
|
|
95
|
+
const wanted = (0, contact_input_1.linkedin_key)(given);
|
|
96
|
+
return {
|
|
97
|
+
param: 'linkedIn', values: wanted === given ? [wanted] : [wanted, given],
|
|
98
|
+
holds: entry => typeof entry.linkedInUrl === 'string' && (0, contact_input_1.linkedin_key)(entry.linkedInUrl) === wanted,
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
// GET /v3/contacts looks a contact up by exact email or LinkedIn URL. Each answer is read to its end,
|
|
102
|
+
// and only entries carrying the asked address count; the contact found so far, if any, is carried in.
|
|
103
|
+
// Two contacts under one address is refused rather than guessed between. An exact lookup never runs
|
|
104
|
+
// to pages of entries without an end, so ten such pages are an answer that can't be read, not a
|
|
105
|
+
// reason to guess.
|
|
106
|
+
const read_lookup = async (s, lookup, value, found_before) => {
|
|
107
|
+
let found = found_before;
|
|
108
|
+
for (let page = 0; page < LOOKUP_PAGES; page++) {
|
|
109
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/contacts?${lookup.param}=${encodeURIComponent(value)}&top=${LOOKUP_PAGE}&skip=${page * LOOKUP_PAGE}`, 'read');
|
|
110
|
+
if (a.status !== 200) {
|
|
111
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
112
|
+
}
|
|
113
|
+
const body = (0, call_1.read_page)(a);
|
|
114
|
+
for (const entry of body.items) {
|
|
115
|
+
if (!(0, call_1.is_object)(entry) || !lookup.holds(entry)) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (!(0, call_1.is_reply_id)(entry.id)) {
|
|
119
|
+
throw (0, call_1.unreadable)(a, 'read');
|
|
120
|
+
}
|
|
121
|
+
if (found !== null && found !== entry.id) {
|
|
122
|
+
throw new errors_1.Operation_error('contact.not_unique', 'Reply holds more than one contact under this address.', { status: 200 });
|
|
123
|
+
}
|
|
124
|
+
found = entry.id;
|
|
125
|
+
}
|
|
126
|
+
if (!body.has_more) {
|
|
127
|
+
return found;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
throw new errors_1.Operation_error('reply.unavailable', 'Reply answered the exact lookup with more pages than one address can fill.', { status: 200 });
|
|
131
|
+
};
|
|
132
|
+
const find_contact_by_address = async (s, person) => {
|
|
133
|
+
const lookup = lookup_of(person);
|
|
134
|
+
let found = null;
|
|
135
|
+
for (const value of lookup.values) {
|
|
136
|
+
found = await read_lookup(s, lookup, value, found);
|
|
137
|
+
}
|
|
138
|
+
return found;
|
|
139
|
+
};
|
|
140
|
+
exports.find_contact_by_address = find_contact_by_address;
|
|
141
|
+
// INTERIM (API gap): the document does not say how the import compares a LinkedIn URL when it is the
|
|
142
|
+
// key, so a contact Reply holds under the same slug in another case might be imported a second time.
|
|
143
|
+
// Needed: an import that matches a LinkedIn URL by its slug whatever its case, or a word on how it
|
|
144
|
+
// compares.
|
|
145
|
+
// Workaround: a contact with no email is looked up first, as `contact find` does, and imported only
|
|
146
|
+
// when Reply holds nobody under the URL. A contact with an email is imported straight away: the
|
|
147
|
+
// import matches it by the email.
|
|
148
|
+
const ensure_contact = async (s, ref) => {
|
|
149
|
+
if (ref.kind === 'id') {
|
|
150
|
+
return { id: ref.id, created: false };
|
|
151
|
+
}
|
|
152
|
+
if (ref.person.email === undefined) {
|
|
153
|
+
const found = await find_contact_by_address(s, ref.person);
|
|
154
|
+
if (found !== null) {
|
|
155
|
+
return { id: found, created: false };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return import_contact(s, ref.person);
|
|
159
|
+
};
|
|
160
|
+
exports.ensure_contact = ensure_contact;
|
|
161
|
+
const find_contact = async (s, ref) => ref.kind === 'id' ? ref.id : find_contact_by_address(s, ref.person);
|
|
162
|
+
exports.find_contact = find_contact;
|
|
163
|
+
const contact_not_found = (contact_id, a) => new errors_1.Operation_error('contact.not_found', `This account has no contact ${contact_id}.`, { status: a.status, reply_code: (0, call_1.reply_code_of)(a) });
|
|
164
|
+
exports.contact_not_found = contact_not_found;
|
|
165
|
+
const read_opted_out = async (s, contact_id) => {
|
|
166
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/contacts/${contact_id}/statuses`, 'read');
|
|
167
|
+
if (a.status === 404) {
|
|
168
|
+
throw contact_not_found(contact_id, a);
|
|
169
|
+
}
|
|
170
|
+
if (a.status !== 200) {
|
|
171
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
172
|
+
}
|
|
173
|
+
const body = (0, call_1.expect_object)(a, 'read');
|
|
174
|
+
if (typeof body.isOptedOut !== 'boolean') {
|
|
175
|
+
throw (0, call_1.unreadable)(a, 'read');
|
|
176
|
+
}
|
|
177
|
+
return body.isOptedOut;
|
|
178
|
+
};
|
|
179
|
+
exports.read_opted_out = read_opted_out;
|
|
180
|
+
//# sourceMappingURL=contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/operations/contacts.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAChD,iCAGgB;AAChB,mDAA4E;AAI5E,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,WAAW,GAAG,CAAC,CAAS,EAAyB,EAAE;IACrD,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,EACzB,CAAC;QACG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IACzB,CAAC;IACD,IAAI,CAAC,CAAC,YAAY,KAAK,SAAS,EAChC,CAAC;QACG,0CAA0C;QAC1C,IAAI,CAAC,WAAW,GAAG,IAAA,4BAAY,EAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC;IACtE,CAAC;IACD,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS,EAC9B,CAAC;QACG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,UAAU,CAAC;IAClC,CAAC;IACD,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS,EAC7B,CAAC;QACG,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,SAAS,CAAC;IAChC,CAAC;IACD,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS,EAC3B,CAAC;QACG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC;IAC7B,CAAC;IACD,IAAI,CAAC,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C,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,SAAS,EACxC,CAAC;QACG,MAAM,IAAA,iBAAU,EAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC,UAAU,CAAC;AAC3B,CAAC,CAAC;AAE6E,wCAAc"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Op_globals } from './options';
|
|
2
|
+
import type { Cli_context } from '../context';
|
|
3
|
+
type Reply_message = {
|
|
4
|
+
body: string;
|
|
5
|
+
reply_to_message_id?: string;
|
|
6
|
+
};
|
|
7
|
+
declare const handle_inbox_reply: (thread_arg: string, opts: {
|
|
8
|
+
message?: string;
|
|
9
|
+
}, ctx: Cli_context, g: Op_globals, read_stdin?: () => string) => Promise<void>;
|
|
10
|
+
export { handle_inbox_reply };
|
|
11
|
+
export type { Reply_message };
|