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,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handle_sequence_create = exports.handle_sequence_list = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const errors_1 = require("../utils/errors");
|
|
6
|
+
const call_1 = require("./call");
|
|
7
|
+
const stdin_input_1 = require("./stdin-input");
|
|
8
|
+
const result_1 = require("./result");
|
|
9
|
+
const PAGE = 1000;
|
|
10
|
+
const PAGES = 20;
|
|
11
|
+
// The one step a sequence needs to exist: Reply refuses a sequence with none. A task is its owner's
|
|
12
|
+
// to-do and reaches nobody, even once the sequence runs; it says what it is, so whoever opens the
|
|
13
|
+
// sequence replaces it.
|
|
14
|
+
const PLACEHOLDER = {
|
|
15
|
+
type: 'task',
|
|
16
|
+
actionType: 'toDo',
|
|
17
|
+
delayInMinutes: 0,
|
|
18
|
+
description: 'Added because a sequence needs one step to exist; replace it before this sequence is ever started.',
|
|
19
|
+
};
|
|
20
|
+
// A sequence's name is a person's text: read from stdin only, sent as given, never repeated in a message.
|
|
21
|
+
const read_name = (source, command, read_stdin) => {
|
|
22
|
+
const raw = (0, stdin_input_1.read_stdin_object)(source, {
|
|
23
|
+
flag: '--name', what: 'name', fields: ['name'], code: 'usage.name',
|
|
24
|
+
hint: `Pipe it in: echo '{"name":"…"}' | ${config_1.PROGRAM_NAME} sequence ${command} --name -`,
|
|
25
|
+
}, read_stdin);
|
|
26
|
+
if (typeof raw.name !== 'string' || raw.name.trim() === '') {
|
|
27
|
+
throw new errors_1.UsageError('The name must be a string that is not blank.', { code: 'usage.name' });
|
|
28
|
+
}
|
|
29
|
+
return raw.name;
|
|
30
|
+
};
|
|
31
|
+
const words_of = (seq) => ({
|
|
32
|
+
status: typeof seq.status === 'string' ? seq.status : null,
|
|
33
|
+
is_archived: typeof seq.isArchived === 'boolean' ? seq.isArchived : null,
|
|
34
|
+
});
|
|
35
|
+
// Every sequence whose name is this one, exactly and ignoring case, archived ones included. Reply's
|
|
36
|
+
// own name filter matches part of a name, ignoring case, so it narrows the list and the names are
|
|
37
|
+
// compared here. Oldest first, so a sequence made while the pages are read lands after them rather
|
|
38
|
+
// than shifting one out of view. A name is free only once the end of the list is reached, so a list
|
|
39
|
+
// that does not end within twenty pages is refused rather than answered in part.
|
|
40
|
+
const handle_sequence_list = async (opts, ctx, g, read_stdin) => {
|
|
41
|
+
const name = read_name(opts.name, 'list', read_stdin);
|
|
42
|
+
const wanted = name.toLowerCase();
|
|
43
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
44
|
+
const items = [];
|
|
45
|
+
for (let page = 0; page < PAGES; page++) {
|
|
46
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/sequences?name=${encodeURIComponent(name)}&sortBy=created&sortDirection=asc&top=${PAGE}&skip=${page * PAGE}`, 'read');
|
|
47
|
+
if (a.status !== 200) {
|
|
48
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
49
|
+
}
|
|
50
|
+
const body = (0, call_1.read_page)(a);
|
|
51
|
+
for (const entry of body.items) {
|
|
52
|
+
if (!(0, call_1.is_object)(entry) || typeof entry.name !== 'string' || entry.name.toLowerCase() !== wanted) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!(0, call_1.is_reply_id)(entry.id)) {
|
|
56
|
+
throw (0, call_1.unreadable)(a, 'read');
|
|
57
|
+
}
|
|
58
|
+
items.push({ id: entry.id, name: entry.name, ...words_of(entry), created_at: typeof entry.created === 'string' ? entry.created : null });
|
|
59
|
+
}
|
|
60
|
+
if (!body.has_more) {
|
|
61
|
+
(0, result_1.print_result)({ items }, g);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
throw new errors_1.Operation_error('sequence.list_incomplete', `Read ${PAGE * PAGES} sequences whose names contain this one and Reply said there were more, so it could not be decided which carry it.`, { status: 200 });
|
|
66
|
+
};
|
|
67
|
+
exports.handle_sequence_list = handle_sequence_list;
|
|
68
|
+
// The draft: the name and the one step, nothing else. Reply attaches the account's default schedule
|
|
69
|
+
// and mailbox on its own; the draft sends nothing, because it holds nobody and is never started here.
|
|
70
|
+
// Reply allows two sequences of one name, and a sequence keeps no key, so a repeat after a lost
|
|
71
|
+
// answer may make a second one.
|
|
72
|
+
const handle_sequence_create = async (opts, ctx, g, read_stdin) => {
|
|
73
|
+
const name = read_name(opts.name, 'create', read_stdin);
|
|
74
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
75
|
+
try {
|
|
76
|
+
const a = await (0, call_1.call_reply)(s, 'POST', '/v3/sequences', 'write', { name, steps: [PLACEHOLDER] });
|
|
77
|
+
if (a.status !== 201 && a.status !== 200) {
|
|
78
|
+
throw (0, call_1.refusal)(a, 'write');
|
|
79
|
+
}
|
|
80
|
+
const made = (0, call_1.expect_object)(a, 'write');
|
|
81
|
+
if (!(0, call_1.is_reply_id)(made.id)) {
|
|
82
|
+
// Reply said it made something and did not say what.
|
|
83
|
+
throw (0, call_1.unreadable)(a, 'write');
|
|
84
|
+
}
|
|
85
|
+
(0, result_1.print_result)({ sequence_id: made.id, steps_added: 1, ...words_of(made) }, g);
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
if (e instanceof errors_1.Unknown_outcome_error) {
|
|
89
|
+
e.hint = 'The sequence may have been made; running the command again may make a second one. Look for it with '
|
|
90
|
+
+ `\`${config_1.PROGRAM_NAME} sequence list --name -\` first.`;
|
|
91
|
+
}
|
|
92
|
+
throw e;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
exports.handle_sequence_create = handle_sequence_create;
|
|
96
|
+
//# sourceMappingURL=sequence-by-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequence-by-name.js","sourceRoot":"","sources":["../../src/operations/sequence-by-name.ts"],"names":[],"mappings":";;;AAAA,sCAAuC;AACvC,4CAAmF;AACnF,iCAAuH;AAEvH,+CAAgD;AAChD,qCAAsC;AAGtC,MAAM,IAAI,GAAG,IAAI,CAAC;AAClB,MAAM,KAAK,GAAG,EAAE,CAAC;AAEjB,oGAAoG;AACpG,kGAAkG;AAClG,wBAAwB;AACxB,MAAM,WAAW,GAAG;IAChB,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,MAAM;IAClB,cAAc,EAAE,CAAC;IACjB,WAAW,EAAE,oGAAoG;CACpH,CAAC;AAEF,0GAA0G;AAC1G,MAAM,SAAS,GAAG,CAAC,MAA0B,EAAE,OAAe,EAAE,UAAyB,EAAS,EAAE;IAChG,MAAM,GAAG,GAAG,IAAA,+BAAiB,EAAC,MAAM,EAAE;QAClC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EA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AI,CAAC,YAAY,8BAAqB,EACtC,CAAC;YACG,CAAC,CAAC,IAAI,GAAG,qGAAqG;kBACxG,KAAK,qBAAY,kCAAkC,CAAC;QAC9D,CAAC;QACD,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC;AAE4B,wDAAsB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Op_globals } from './options';
|
|
2
|
+
import { type Contact_flags } from './contact-input';
|
|
3
|
+
import type { Cli_context } from '../context';
|
|
4
|
+
type Add_contact_opts = Contact_flags & {
|
|
5
|
+
startStep?: string;
|
|
6
|
+
ignoreStepDelay?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const resolve_step_position: (sequence: Record<string, unknown>, position: number) => number;
|
|
9
|
+
declare const handle_sequence_add_contact: (id_arg: string, opts: Add_contact_opts, ctx: Cli_context, g: Op_globals, read_stdin?: () => string) => Promise<void>;
|
|
10
|
+
type Remove_contact_opts = Contact_flags;
|
|
11
|
+
declare const handle_sequence_remove_contact: (id_arg: string, opts: Remove_contact_opts, ctx: Cli_context, g: Op_globals, read_stdin?: () => string) => Promise<void>;
|
|
12
|
+
export { handle_sequence_add_contact, handle_sequence_remove_contact, resolve_step_position };
|
|
13
|
+
export type { Add_contact_opts, Remove_contact_opts };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolve_step_position = exports.handle_sequence_remove_contact = exports.handle_sequence_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 sequence_read_1 = require("./sequence-read");
|
|
10
|
+
const result_1 = require("./result");
|
|
11
|
+
const step_not_found = (position, why) => new errors_1.Operation_error('sequence.step_not_found', `There is no step ${position} to start at: ${why}.`, { status: 200 });
|
|
12
|
+
// INTERIM (API gap): a sequence's steps carry no order field. GET /v3/sequences/{id} returns them
|
|
13
|
+
// as a graph of parentId links, with the order shown only in display names like "1" and "3.1",
|
|
14
|
+
// and no endpoint maps a position to a step id.
|
|
15
|
+
// Needed: a step order field, or a position→id lookup.
|
|
16
|
+
// Workaround: walk the chain from the one step without a parent and take the Nth link. Refuse
|
|
17
|
+
// wherever the answer would be a guess: a fork, a condition, a position past the end.
|
|
18
|
+
const resolve_step_position = (sequence, position) => {
|
|
19
|
+
const steps = Array.isArray(sequence.steps) ? sequence.steps.filter(call_1.is_object) : [];
|
|
20
|
+
if (steps.length === 0) {
|
|
21
|
+
throw step_not_found(position, 'the sequence has no steps');
|
|
22
|
+
}
|
|
23
|
+
const roots = steps.filter(step => step.parentId === null || step.parentId === undefined);
|
|
24
|
+
if (roots.length !== 1) {
|
|
25
|
+
throw step_not_found(position, `its steps have ${roots.length} starting points, so they are not one chain`);
|
|
26
|
+
}
|
|
27
|
+
let at = roots[0];
|
|
28
|
+
for (let index = 1; index <= steps.length; index++) {
|
|
29
|
+
if (typeof at.type === 'string' && at.type.toLowerCase() === 'condition') {
|
|
30
|
+
throw step_not_found(position, `step ${index} is a condition, so the steps after it branch`);
|
|
31
|
+
}
|
|
32
|
+
if (index === position) {
|
|
33
|
+
if (!(0, call_1.is_reply_id)(at.id)) {
|
|
34
|
+
throw step_not_found(position, `step ${position} carries no id`);
|
|
35
|
+
}
|
|
36
|
+
return at.id;
|
|
37
|
+
}
|
|
38
|
+
const current = at;
|
|
39
|
+
const next = steps.filter(step => step.parentId === current.id);
|
|
40
|
+
if (next.length === 0) {
|
|
41
|
+
throw step_not_found(position, `the chain ends at step ${index}`);
|
|
42
|
+
}
|
|
43
|
+
if (next.length > 1) {
|
|
44
|
+
throw step_not_found(position, `step ${index} is followed by ${next.length} steps`);
|
|
45
|
+
}
|
|
46
|
+
at = next[0];
|
|
47
|
+
}
|
|
48
|
+
throw step_not_found(position, 'its steps lead back into one another');
|
|
49
|
+
};
|
|
50
|
+
exports.resolve_step_position = resolve_step_position;
|
|
51
|
+
const NOT_TAKING_PART = ['sequencecontact.notinsequence', 'contact.notfound'];
|
|
52
|
+
const SEQUENCE_MISSING = ['sequence.notfound', 'sequencecontact.sequencenotfound'];
|
|
53
|
+
// A 404 on a call that names both the sequence and the contact. Only the codes that mean the
|
|
54
|
+
// person takes no part are read that way: a missing sequence, or a code this version doesn't know,
|
|
55
|
+
// ends the command rather than being taken for "not in it".
|
|
56
|
+
const require_not_taking_part = (sequence_id, a, kind) => {
|
|
57
|
+
const code = (0, call_1.reply_code_of)(a)?.toLowerCase();
|
|
58
|
+
if (code !== undefined && NOT_TAKING_PART.includes(code)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (code !== undefined && SEQUENCE_MISSING.includes(code)) {
|
|
62
|
+
throw (0, sequence_read_1.sequence_not_found)(sequence_id, a);
|
|
63
|
+
}
|
|
64
|
+
throw (0, call_1.refusal)(a, kind);
|
|
65
|
+
};
|
|
66
|
+
// INTERIM (API gap): POST /v3/sequences/{id}/contact-links/bulk never says that a contact is
|
|
67
|
+
// already in the sequence. For one who is, it acts as a forward-only move: a start step ahead of
|
|
68
|
+
// theirs answers "added" and moves them there, skipping the steps between; the same or an earlier
|
|
69
|
+
// step is refused with the generic invalidInput, and even then can reassign their email account.
|
|
70
|
+
// Needed: a per-item "already in sequence" answer, and a no-op for a contact who is already in.
|
|
71
|
+
// Workaround: for a contact that existed before this call, read its participation first and write
|
|
72
|
+
// nothing when it is there. It costs one extra read per add of an existing contact.
|
|
73
|
+
const participation_before_add = async (s, sequence_id, contact_id) => {
|
|
74
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/sequences/${sequence_id}/contacts/${contact_id}`, 'read');
|
|
75
|
+
if (a.status === 404) {
|
|
76
|
+
require_not_taking_part(sequence_id, a, 'read');
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (a.status !== 200) {
|
|
80
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
81
|
+
}
|
|
82
|
+
(0, call_1.expect_object)(a, 'read');
|
|
83
|
+
return true;
|
|
84
|
+
};
|
|
85
|
+
// INTERIM (API gap): every per-item refusal of POST /v3/sequences/{id}/contact-links/bulk is the
|
|
86
|
+
// same invalidInput, "Contact could not be added to sequence", whether the contact is opted out,
|
|
87
|
+
// over a limit, or anything else. Opted-out contacts are skipped this way without a word.
|
|
88
|
+
// Needed: real per-item reasons (opted out, already in the sequence, limits).
|
|
89
|
+
// Workaround: after a refusal, read the contact's statuses once. Opted out → contact.opted_out;
|
|
90
|
+
// anything else → reply.refused, carrying Reply's own words.
|
|
91
|
+
const explain_not_added = async (s, contact_id, refused) => {
|
|
92
|
+
if (await (0, contacts_1.read_opted_out)(s, contact_id)) {
|
|
93
|
+
return new errors_1.Operation_error('contact.opted_out', `Contact ${contact_id} is opted out, so Reply did not add them to the sequence.`, { status: 200 });
|
|
94
|
+
}
|
|
95
|
+
return new errors_1.Operation_error('reply.refused', 'Reply did not add the contact to the sequence.', {
|
|
96
|
+
status: 200, reply_code: refused.error ?? undefined, detail: refused.details ?? undefined,
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const add_to_sequence = async (s, sequence_id, contact_id, o) => {
|
|
100
|
+
const body = {
|
|
101
|
+
contactIds: [contact_id],
|
|
102
|
+
// Always sent, never left to Reply's default: true would take the person out of every other
|
|
103
|
+
// sequence they are in, which nobody asked for.
|
|
104
|
+
removeFromExisting: false,
|
|
105
|
+
ignoreStepDelay: o.ignore_step_delay,
|
|
106
|
+
};
|
|
107
|
+
if (o.start_step_id !== undefined) {
|
|
108
|
+
body.startStepId = o.start_step_id;
|
|
109
|
+
}
|
|
110
|
+
const a = await (0, call_1.call_reply)(s, 'POST', `/v3/sequences/${sequence_id}/contact-links/bulk`, 'write', body);
|
|
111
|
+
if (a.status === 404) {
|
|
112
|
+
throw (0, sequence_read_1.sequence_not_found)(sequence_id, a);
|
|
113
|
+
}
|
|
114
|
+
if (a.status === 400 && (0, call_1.reply_code_of)(a) === 'sequenceContact.noStepsInSequence') {
|
|
115
|
+
throw new errors_1.Operation_error('sequence.has_no_steps', `Sequence ${sequence_id} has no step to send.`, { status: 400, reply_code: (0, call_1.reply_code_of)(a) });
|
|
116
|
+
}
|
|
117
|
+
if (a.status === 400 && (0, call_1.reply_code_of)(a) === 'sequenceContact.contactLimitExceeded') {
|
|
118
|
+
throw new errors_1.Operation_error('account.contact_limit_reached', 'The account is at its plan\'s limit.', {
|
|
119
|
+
status: 400, reply_code: (0, call_1.reply_code_of)(a), detail: (0, call_1.detail_of)(a),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (a.status !== 200) {
|
|
123
|
+
throw (0, call_1.refusal)(a, 'write');
|
|
124
|
+
}
|
|
125
|
+
const answer = (0, call_1.expect_object)(a, 'write');
|
|
126
|
+
if (Array.isArray(answer.added) && answer.added.includes(contact_id)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const refused = (0, call_1.item_failure)(answer.notProcessed, contact_id);
|
|
130
|
+
if (refused === undefined) {
|
|
131
|
+
throw (0, call_1.unreadable)(a, 'write');
|
|
132
|
+
}
|
|
133
|
+
throw await explain_not_added(s, contact_id, refused);
|
|
134
|
+
};
|
|
135
|
+
const handle_sequence_add_contact = async (id_arg, opts, ctx, g, read_stdin) => {
|
|
136
|
+
const sequence_id = (0, options_1.parse_id)(id_arg, 'Sequence id');
|
|
137
|
+
const contact = (0, contact_input_1.read_contact_input)(opts, read_stdin);
|
|
138
|
+
const start_step = opts.startStep === undefined ? undefined : (0, options_1.parse_int_in)(opts.startStep, '--start-step', 1, 10000, 1);
|
|
139
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
140
|
+
const ids = { sequence_id };
|
|
141
|
+
try {
|
|
142
|
+
const sequence = await (0, sequence_read_1.read_sequence)(s, sequence_id);
|
|
143
|
+
if (sequence.isArchived === true) {
|
|
144
|
+
throw (0, sequence_read_1.sequence_archived)(sequence_id);
|
|
145
|
+
}
|
|
146
|
+
const start_step_id = start_step === undefined ? undefined : resolve_step_position(sequence, start_step);
|
|
147
|
+
const ensured = await (0, contacts_1.ensure_contact)(s, contact);
|
|
148
|
+
ids.contact_id = ensured.id;
|
|
149
|
+
const result = (status) => ({
|
|
150
|
+
status, sequence_id, contact_id: ensured.id, contact_created: ensured.created,
|
|
151
|
+
sequence_active: sequence.status === 'active',
|
|
152
|
+
});
|
|
153
|
+
if (!ensured.created && await participation_before_add(s, sequence_id, ensured.id)) {
|
|
154
|
+
(0, result_1.print_result)(result('already_in_sequence'), g);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
await add_to_sequence(s, sequence_id, ensured.id, { start_step_id, ignore_step_delay: opts.ignoreStepDelay === true });
|
|
158
|
+
(0, result_1.print_result)(result('added'), g);
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
throw (0, result_1.with_ids)(e, ids);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
exports.handle_sequence_add_contact = handle_sequence_add_contact;
|
|
165
|
+
// INTERIM (API gap): GET /v3/sequences/{id}/contacts/{contact_id} and the DELETE answer one and
|
|
166
|
+
// the same 404, sequenceContact.notInSequence, whether the sequence doesn't exist, the contact
|
|
167
|
+
// doesn't exist, or the contact just isn't in it.
|
|
168
|
+
// Needed: distinct 404 codes for a missing sequence and a missing contact.
|
|
169
|
+
// Workaround: after that 404, read the sequence itself, so a mistyped sequence id is reported as
|
|
170
|
+
// sequence.not_found and not as a successful stop.
|
|
171
|
+
const confirm_sequence_after_404 = async (s, sequence_id) => {
|
|
172
|
+
await (0, sequence_read_1.read_sequence)(s, sequence_id);
|
|
173
|
+
};
|
|
174
|
+
// INTERIM (API gap): DELETE /v3/sequences/{id}/contact-links/{contact_id} also removes a
|
|
175
|
+
// participation that has finished, which changes the sequence's statistics, and its answer says
|
|
176
|
+
// nothing about what it removed.
|
|
177
|
+
// Needed: a stop that leaves finished participations alone and reports what it did.
|
|
178
|
+
// Workaround: read the participation first. A finished one, or none at all, is already stopped,
|
|
179
|
+
// and nothing is written.
|
|
180
|
+
const participation_before_remove = async (s, sequence_id, contact_id) => {
|
|
181
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/sequences/${sequence_id}/contacts/${contact_id}`, 'read');
|
|
182
|
+
if (a.status === 404) {
|
|
183
|
+
require_not_taking_part(sequence_id, a, 'read');
|
|
184
|
+
await confirm_sequence_after_404(s, sequence_id);
|
|
185
|
+
return 'stopped';
|
|
186
|
+
}
|
|
187
|
+
if (a.status !== 200) {
|
|
188
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
189
|
+
}
|
|
190
|
+
return (0, call_1.expect_object)(a, 'read').statusInSequence === 'finished' ? 'stopped' : 'active';
|
|
191
|
+
};
|
|
192
|
+
const remove_from_sequence = async (s, sequence_id, contact_id) => {
|
|
193
|
+
if (await participation_before_remove(s, sequence_id, contact_id) === 'stopped') {
|
|
194
|
+
return 'not_in_sequence';
|
|
195
|
+
}
|
|
196
|
+
const a = await (0, call_1.call_reply)(s, 'DELETE', `/v3/sequences/${sequence_id}/contact-links/${contact_id}`, 'write');
|
|
197
|
+
if (a.status === 200 || a.status === 204) {
|
|
198
|
+
return 'removed';
|
|
199
|
+
}
|
|
200
|
+
if (a.status === 404) {
|
|
201
|
+
// The person left between the read and the removal.
|
|
202
|
+
require_not_taking_part(sequence_id, a, 'write');
|
|
203
|
+
return 'not_in_sequence';
|
|
204
|
+
}
|
|
205
|
+
throw (0, call_1.refusal)(a, 'write');
|
|
206
|
+
};
|
|
207
|
+
const handle_sequence_remove_contact = async (id_arg, opts, ctx, g, read_stdin) => {
|
|
208
|
+
const sequence_id = (0, options_1.parse_id)(id_arg, 'Sequence id');
|
|
209
|
+
const contact = (0, contact_input_1.read_contact_input)(opts, read_stdin);
|
|
210
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
211
|
+
const ids = { sequence_id };
|
|
212
|
+
try {
|
|
213
|
+
const contact_id = await (0, contacts_1.find_contact)(s, contact);
|
|
214
|
+
if (contact_id === null) {
|
|
215
|
+
// Nobody under this address: they take part in nothing.
|
|
216
|
+
(0, result_1.print_result)({ status: 'not_in_sequence', sequence_id, contact_id: null }, g);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
ids.contact_id = contact_id;
|
|
220
|
+
(0, result_1.print_result)({ status: await remove_from_sequence(s, sequence_id, contact_id), sequence_id, contact_id }, g);
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
throw (0, result_1.with_ids)(e, ids);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
exports.handle_sequence_remove_contact = handle_sequence_remove_contact;
|
|
227
|
+
//# sourceMappingURL=sequence-membership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequence-membership.js","sourceRoot":"","sources":["../../src/operations/sequence-membership.ts"],"names":[],"mappings":";;;AAAA,4CAA0D;AAC1D,iCAGgB;AAEhB,uCAAkE;AAClE,mDAAuE;AACvE,yCAAwE;AACxE,mDAAqF;AACrF,qCAAgD;AAKhD,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,GAAW,EAAkB,EAAE,CACrE,IAAI,wBAAe,CAAC,yBAAyB,EAAE,oBAAoB,QAAQ,iBAAiB,GAAG,GAAG,EAAE,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC,CAAC;AAEvH,kGAAkG;AAClG,+FAA+F;AAC/F,gDAAgD;AAChD,uDAAuD;AACvD,8FAA8F;AAC9F,sFAAsF;AACtF,MAAM,qBAAqB,GAAG,CAAC,QAAiC,EAAE,QAAgB,EAAS,EAAE;IACzF,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAS,CAAC,CAAC,CAAC,CAA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AY,EAAC,EAAC,MAAM,EAAE,MAAM,oBAAoB,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,WAAW,EAAE,UAAU,EAAC,EAAE,CAAC,CAAC,CAAC;IAC/G,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,IAAA,iBAAQ,EAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEmC,wEAA8B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Operation_error } from '../utils/errors';
|
|
2
|
+
import { type Answer, type Op_session } from './call';
|
|
3
|
+
import { type Op_globals } from './options';
|
|
4
|
+
import type { Cli_context } from '../context';
|
|
5
|
+
declare const PRESETS: {
|
|
6
|
+
readonly 'last-week': "lastWeek";
|
|
7
|
+
readonly 'last-month': "lastMonth";
|
|
8
|
+
readonly 'last-year': "lastYear";
|
|
9
|
+
readonly 'all-time': "allTime";
|
|
10
|
+
};
|
|
11
|
+
declare const sequence_not_found: (id: number, a: Answer) => Operation_error;
|
|
12
|
+
declare const sequence_archived: (id: number, a?: Answer) => Operation_error;
|
|
13
|
+
declare const read_sequence: (s: Op_session, id: number) => Promise<Record<string, unknown>>;
|
|
14
|
+
declare const count_contacts: (s: Op_session, id: number) => Promise<number | null>;
|
|
15
|
+
declare const require_count: (s: Op_session, id: number) => Promise<number>;
|
|
16
|
+
declare const handle_sequence_get: (id_arg: string, ctx: Cli_context, g: Op_globals) => Promise<void>;
|
|
17
|
+
declare const handle_sequence_contacts: (id_arg: string, opts: {
|
|
18
|
+
limit?: string;
|
|
19
|
+
offset?: string;
|
|
20
|
+
}, ctx: Cli_context, g: Op_globals) => Promise<void>;
|
|
21
|
+
declare const handle_sequence_stats: (id_arg: string, opts: {
|
|
22
|
+
preset?: string;
|
|
23
|
+
from?: string;
|
|
24
|
+
to?: string;
|
|
25
|
+
}, ctx: Cli_context, g: Op_globals) => Promise<void>;
|
|
26
|
+
export { read_sequence, count_contacts, require_count, sequence_not_found, sequence_archived, handle_sequence_get, handle_sequence_contacts, handle_sequence_stats, PRESETS, };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PRESETS = exports.handle_sequence_stats = exports.handle_sequence_contacts = exports.handle_sequence_get = exports.sequence_archived = exports.sequence_not_found = exports.require_count = exports.count_contacts = exports.read_sequence = void 0;
|
|
4
|
+
const errors_1 = require("../utils/errors");
|
|
5
|
+
const call_1 = require("./call");
|
|
6
|
+
const options_1 = require("./options");
|
|
7
|
+
const result_1 = require("./result");
|
|
8
|
+
const PRESETS = {
|
|
9
|
+
'last-week': 'lastWeek',
|
|
10
|
+
'last-month': 'lastMonth',
|
|
11
|
+
'last-year': 'lastYear',
|
|
12
|
+
'all-time': 'allTime',
|
|
13
|
+
};
|
|
14
|
+
exports.PRESETS = PRESETS;
|
|
15
|
+
const sequence_not_found = (id, a) => new errors_1.Operation_error('sequence.not_found', `This account has no sequence ${id}.`, { status: a.status, reply_code: (0, call_1.reply_code_of)(a) });
|
|
16
|
+
exports.sequence_not_found = sequence_not_found;
|
|
17
|
+
const sequence_archived = (id, a) => new errors_1.Operation_error('sequence.archived', `Sequence ${id} is archived.`, {
|
|
18
|
+
status: a?.status ?? 200, reply_code: a === undefined ? undefined : (0, call_1.reply_code_of)(a),
|
|
19
|
+
});
|
|
20
|
+
exports.sequence_archived = sequence_archived;
|
|
21
|
+
const read_sequence = async (s, id) => {
|
|
22
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/sequences/${id}`, 'read');
|
|
23
|
+
if (a.status === 404) {
|
|
24
|
+
throw sequence_not_found(id, a);
|
|
25
|
+
}
|
|
26
|
+
if (a.status !== 200) {
|
|
27
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
28
|
+
}
|
|
29
|
+
return (0, call_1.expect_object)(a, 'read');
|
|
30
|
+
};
|
|
31
|
+
exports.read_sequence = read_sequence;
|
|
32
|
+
// Reply's own count of the people in the sequence, or null when it would not count them. The
|
|
33
|
+
// page of contacts answers an empty 200 for a sequence that doesn't exist; the count answers 404,
|
|
34
|
+
// so it is also what tells the two apart.
|
|
35
|
+
const count_contacts = async (s, id) => {
|
|
36
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/sequences/${id}/contacts/count`, 'read');
|
|
37
|
+
if (a.status === 404) {
|
|
38
|
+
throw sequence_not_found(id, a);
|
|
39
|
+
}
|
|
40
|
+
if (a.status !== 200 || !(0, call_1.is_object)(a.data)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const count = a.data.count;
|
|
44
|
+
return typeof count === 'number' && Number.isInteger(count) && count >= 0 ? count : null;
|
|
45
|
+
};
|
|
46
|
+
exports.count_contacts = count_contacts;
|
|
47
|
+
// The count where a decision depends on it: anything but a number is that call's own failure.
|
|
48
|
+
const require_count = async (s, id) => {
|
|
49
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/sequences/${id}/contacts/count`, 'read');
|
|
50
|
+
if (a.status === 404) {
|
|
51
|
+
throw sequence_not_found(id, a);
|
|
52
|
+
}
|
|
53
|
+
if (a.status !== 200) {
|
|
54
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
55
|
+
}
|
|
56
|
+
const count = (0, call_1.expect_object)(a, 'read').count;
|
|
57
|
+
if (typeof count !== 'number' || !Number.isInteger(count) || count < 0) {
|
|
58
|
+
throw (0, call_1.unreadable)(a, 'read');
|
|
59
|
+
}
|
|
60
|
+
return count;
|
|
61
|
+
};
|
|
62
|
+
exports.require_count = require_count;
|
|
63
|
+
const handle_sequence_get = async (id_arg, ctx, g) => {
|
|
64
|
+
const id = (0, options_1.parse_id)(id_arg, 'Sequence id');
|
|
65
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
66
|
+
(0, result_1.print_result)(await read_sequence(s, id), g);
|
|
67
|
+
};
|
|
68
|
+
exports.handle_sequence_get = handle_sequence_get;
|
|
69
|
+
const handle_sequence_contacts = async (id_arg, opts, ctx, g) => {
|
|
70
|
+
const id = (0, options_1.parse_id)(id_arg, 'Sequence id');
|
|
71
|
+
const limit = (0, options_1.parse_int_in)(opts.limit, '--limit', 1, 1000, 100);
|
|
72
|
+
const offset = (0, options_1.parse_int_in)(opts.offset, '--offset', 0, 1000000, 0);
|
|
73
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
74
|
+
const a = await (0, call_1.call_reply)(s, 'GET', `/v3/sequences/${id}/contacts?top=${limit}&skip=${offset}`, 'read');
|
|
75
|
+
if (a.status === 404) {
|
|
76
|
+
throw sequence_not_found(id, a);
|
|
77
|
+
}
|
|
78
|
+
if (a.status !== 200) {
|
|
79
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
80
|
+
}
|
|
81
|
+
const page = (0, call_1.read_page)(a);
|
|
82
|
+
(0, result_1.print_result)({ items: page.items, has_more: page.has_more, total: await count_contacts(s, id) }, g);
|
|
83
|
+
};
|
|
84
|
+
exports.handle_sequence_contacts = handle_sequence_contacts;
|
|
85
|
+
// INTERIM (API gap): POST /v3/sequences/{id}/stats answers a span that doesn't end after it starts
|
|
86
|
+
// with a 500, not a validation problem, so it reads as Reply being down and is asked again.
|
|
87
|
+
// Needed: a 400 validation problem for such a span.
|
|
88
|
+
// Workaround: refuse the span as a usage error before sending.
|
|
89
|
+
const stats_span = (raw_from, raw_to) => {
|
|
90
|
+
const from = (0, options_1.parse_iso)(raw_from, '--from');
|
|
91
|
+
const to = (0, options_1.parse_iso)(raw_to, '--to');
|
|
92
|
+
if (Date.parse(from) >= Date.parse(to)) {
|
|
93
|
+
throw new errors_1.UsageError('--to must be later than --from.', { code: 'usage.stats' });
|
|
94
|
+
}
|
|
95
|
+
return { from, to };
|
|
96
|
+
};
|
|
97
|
+
const handle_sequence_stats = async (id_arg, opts, ctx, g) => {
|
|
98
|
+
const id = (0, options_1.parse_id)(id_arg, 'Sequence id');
|
|
99
|
+
const preset = (0, options_1.parse_choice)(opts.preset, '--preset', Object.keys(PRESETS));
|
|
100
|
+
const by_preset = preset !== undefined;
|
|
101
|
+
const by_span = opts.from !== undefined && opts.to !== undefined;
|
|
102
|
+
const partial_span = (opts.from !== undefined) !== (opts.to !== undefined);
|
|
103
|
+
if (by_preset === by_span || partial_span) {
|
|
104
|
+
throw new errors_1.UsageError('Give the window as --preset, or as both --from and --to.', { code: 'usage.stats' });
|
|
105
|
+
}
|
|
106
|
+
const filters = preset !== undefined
|
|
107
|
+
? { dateRangePreset: PRESETS[preset] }
|
|
108
|
+
: stats_span(opts.from, opts.to);
|
|
109
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
110
|
+
// A POST that changes nothing: the window travels in the body.
|
|
111
|
+
const a = await (0, call_1.call_reply)(s, 'POST', `/v3/sequences/${id}/stats`, 'read', { filters });
|
|
112
|
+
if (a.status === 404) {
|
|
113
|
+
throw sequence_not_found(id, a);
|
|
114
|
+
}
|
|
115
|
+
if (a.status !== 200) {
|
|
116
|
+
throw (0, call_1.refusal)(a, 'read');
|
|
117
|
+
}
|
|
118
|
+
(0, result_1.print_result)((0, call_1.expect_object)(a, 'read'), g);
|
|
119
|
+
};
|
|
120
|
+
exports.handle_sequence_stats = handle_sequence_stats;
|
|
121
|
+
//# sourceMappingURL=sequence-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequence-read.js","sourceRoot":"","sources":["../../src/operations/sequence-read.ts"],"names":[],"mappings":";;;AAAA,4CAA4D;AAC5D,iCAGgB;AAChB,uCAA2F;AAC3F,qCAAsC;AAGtC,MAAM,OAAO,GAAG;IACZ,WAAW,EAAE,UAAU;IACvB,YAAY,EAAE,WAAW;IACzB,WAAW,EAAE,UAAU;IACvB,UAAU,EAAE,SAAS;CACf,CAAC;AAmI+D,0BAAO;AAhIjF,MAAM,kBAAkB,GAAG,CAAC,EAAU,EAAE,CAAS,EAAkB,EAAE,CACjE,IAAI,wBAAe,CAAC,oBAAo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@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Op_globals } from './options';
|
|
2
|
+
import type { Cli_context } from '../context';
|
|
3
|
+
declare const handle_sequence_pause: (id_arg: string, ctx: Cli_context, g: Op_globals) => Promise<void>;
|
|
4
|
+
declare const handle_sequence_start: (id_arg: string, opts: {
|
|
5
|
+
expectContacts?: string;
|
|
6
|
+
}, ctx: Cli_context, g: Op_globals) => Promise<void>;
|
|
7
|
+
export { handle_sequence_pause, handle_sequence_start };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handle_sequence_start = exports.handle_sequence_pause = void 0;
|
|
4
|
+
const errors_1 = require("../utils/errors");
|
|
5
|
+
const call_1 = require("./call");
|
|
6
|
+
const options_1 = require("./options");
|
|
7
|
+
const sequence_read_1 = require("./sequence-read");
|
|
8
|
+
const result_1 = require("./result");
|
|
9
|
+
// What a pause or a start answered when it did not do it.
|
|
10
|
+
const action_refusal = (id, a, refused_code, refused_title) => {
|
|
11
|
+
const code = (0, call_1.reply_code_of)(a);
|
|
12
|
+
if (a.status === 404) {
|
|
13
|
+
return (0, sequence_read_1.sequence_not_found)(id, a);
|
|
14
|
+
}
|
|
15
|
+
if (code === 'sequenceAction.archived') {
|
|
16
|
+
return (0, sequence_read_1.sequence_archived)(id, a);
|
|
17
|
+
}
|
|
18
|
+
if (code === 'sequenceAction.activationInProgress') {
|
|
19
|
+
return new errors_1.Operation_error('sequence.busy', 'Reply is still activating this sequence; try again shortly.', {
|
|
20
|
+
status: a.status, reply_code: code,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (a.status === 400 || a.status === 409) {
|
|
24
|
+
return new errors_1.Operation_error(refused_code, refused_title, { status: a.status, reply_code: code, detail: (0, call_1.detail_of)(a) });
|
|
25
|
+
}
|
|
26
|
+
return (0, call_1.refusal)(a, 'write');
|
|
27
|
+
};
|
|
28
|
+
const handle_sequence_pause = async (id_arg, ctx, g) => {
|
|
29
|
+
const id = (0, options_1.parse_id)(id_arg, 'Sequence id');
|
|
30
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
31
|
+
try {
|
|
32
|
+
// No read first: Reply answers an already-paused sequence with a 200 and changes nothing.
|
|
33
|
+
const a = await (0, call_1.call_reply)(s, 'POST', `/v3/sequences/${id}/pause`, 'write');
|
|
34
|
+
if (a.status !== 200) {
|
|
35
|
+
throw action_refusal(id, a, 'sequence.not_pausable', 'Reply will not pause this sequence.');
|
|
36
|
+
}
|
|
37
|
+
(0, call_1.expect_object)(a, 'write');
|
|
38
|
+
(0, result_1.print_result)({ status: 'paused', sequence_id: id }, g);
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
throw (0, result_1.with_ids)(e, { sequence_id: id });
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.handle_sequence_pause = handle_sequence_pause;
|
|
45
|
+
const handle_sequence_start = async (id_arg, opts, ctx, g) => {
|
|
46
|
+
const id = (0, options_1.parse_id)(id_arg, 'Sequence id');
|
|
47
|
+
const expected = opts.expectContacts === undefined ? undefined : (0, options_1.parse_int_in)(opts.expectContacts, '--expect-contacts', 0, 10000000, 0);
|
|
48
|
+
const s = await (0, call_1.open_session)(ctx, g);
|
|
49
|
+
const ids = { sequence_id: id };
|
|
50
|
+
try {
|
|
51
|
+
let contacts = null;
|
|
52
|
+
let previous_status = null;
|
|
53
|
+
if (expected !== undefined) {
|
|
54
|
+
// The approval guard: start only if the sequence still holds the number of people that
|
|
55
|
+
// was approved. The state is read first, so a repeat after a start that already landed
|
|
56
|
+
// answers already_active instead of failing on a count that has moved since.
|
|
57
|
+
const sequence = await (0, sequence_read_1.read_sequence)(s, id);
|
|
58
|
+
if (sequence.isArchived === true) {
|
|
59
|
+
throw (0, sequence_read_1.sequence_archived)(id);
|
|
60
|
+
}
|
|
61
|
+
// Reply's start answers the sequence as it is afterwards, so only this read can say
|
|
62
|
+
// whether the start was a first start or a resume.
|
|
63
|
+
previous_status = typeof sequence.status === 'string' ? sequence.status : null;
|
|
64
|
+
if (sequence.status === 'active') {
|
|
65
|
+
// Nothing left to guard: the count is reported where Reply gives it, and not needed.
|
|
66
|
+
(0, result_1.print_result)({ status: 'already_active', sequence_id: id, previous_status, contacts: await (0, sequence_read_1.count_contacts)(s, id) }, g);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const count = await (0, sequence_read_1.require_count)(s, id);
|
|
70
|
+
if (count !== expected) {
|
|
71
|
+
throw new errors_1.Operation_error('sequence.contact_count_changed', `The sequence holds ${count} contacts, not the ${expected} expected, so nothing was started.`, { status: 200, details: { expected, actual: count } });
|
|
72
|
+
}
|
|
73
|
+
contacts = count;
|
|
74
|
+
}
|
|
75
|
+
// Reply answers an already-active sequence with a 200 and changes nothing.
|
|
76
|
+
const a = await (0, call_1.call_reply)(s, 'POST', `/v3/sequences/${id}/start`, 'write');
|
|
77
|
+
if (a.status !== 200) {
|
|
78
|
+
throw action_refusal(id, a, 'sequence.not_startable', 'Reply will not start this sequence.');
|
|
79
|
+
}
|
|
80
|
+
(0, call_1.expect_object)(a, 'write');
|
|
81
|
+
(0, result_1.print_result)({ status: 'started', sequence_id: id, previous_status, contacts }, g);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
throw (0, result_1.with_ids)(e, ids);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.handle_sequence_start = handle_sequence_start;
|
|
88
|
+
//# sourceMappingURL=sequence-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequence-state.js","sourceRoot":"","sources":["../../src/operations/sequence-state.ts"],"names":[],"mappings":";;;AAAA,4CAA0D;AAC1D,iCAA+G;AAC/G,uCAAkE;AAClE,mDAAoH;AACpH,qCAAgD;AAGhD,0DAA0D;AAC1D,MAAM,cAAc,GAAG,CAAC,EAAU,EAAE,CAAS,EAAE,YAAoB,EAAE,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