@composable-os/cli 0.1.0-beta.11 → 0.1.0-beta.13
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/dist/{accounts-UHYLCLEY.js → accounts-GOCNY6WI.js} +17 -13
- package/dist/app-RPRZMLU5.js +43 -0
- package/dist/app-upload-YJVEKZC6.js +198 -0
- package/dist/{blocks-5IFU25J6.js → blocks-DE4RRWPJ.js} +207 -25
- package/dist/{chunk-XIDLW3EP.js → chunk-2B6YUYZV.js} +23499 -11766
- package/dist/{run-7P4RQALH.js → chunk-2CCHB37H.js} +9 -146
- package/dist/{chunk-DU6OIFOU.js → chunk-3OGDWKJ3.js} +530 -434
- package/dist/{chunk-DHS2CV2M.js → chunk-5D7BDF4Y.js} +15 -13
- package/dist/{chunk-ZAWES2UD.js → chunk-6CM3WZG5.js} +13 -2483
- package/dist/{chunk-7D4GKZOX.js → chunk-CIBJGB5H.js} +422 -75
- package/dist/chunk-EPDTPGZJ.js +330 -0
- package/dist/{chunk-LAAL4YGR.js → chunk-HAYF4G5V.js} +66 -23
- package/dist/chunk-HCG6T53D.js +61904 -0
- package/dist/{chunk-K34UKWEI.js → chunk-JX4IFWNT.js} +64 -32
- package/dist/{chunk-6XTU2MTP.js → chunk-KFHKNXGH.js} +632 -418
- package/dist/chunk-KMFMD52Z.js +13276 -0
- package/dist/{chunk-E4WCYTCT.js → chunk-LX2TTLVY.js} +174 -55
- package/dist/{chunk-GYTEW66E.js → chunk-O3R4FS2J.js} +1 -1
- package/dist/{chunk-E64SG24J.js → chunk-Q6Y45DY6.js} +25 -2
- package/dist/{chunk-MBIKVRAC.js → chunk-QJZGYJVV.js} +823 -44
- package/dist/{chunk-PDD2ETVF.js → chunk-QQ3YSL5F.js} +172 -16
- package/dist/chunk-RGKJKC5T.js +876 -0
- package/dist/{chunk-YFTLIEWU.js → chunk-RSEWEFAV.js} +12 -2
- package/dist/{chunk-2ABSVMGB.js → chunk-SMJZIK2O.js} +1 -1
- package/dist/{chunk-LO6WGU5Y.js → chunk-U72NEGCT.js} +8089 -3464
- package/dist/{chunk-P6UWZ6QQ.js → chunk-Z4IKF23A.js} +11 -7
- package/dist/{chunk-2IVEVPMY.js → chunk-Z7OVQ6BC.js} +105 -61
- package/dist/{chunk-6UWRT4VM.js → chunk-ZJSFX4RD.js} +175 -3
- package/dist/{cli-5UNY5G5L.js → cli-OKQHHSOE.js} +17 -25
- package/dist/{cli-UYZMVQMR.js → cli-VYSD2S4Z.js} +227 -81
- package/dist/cli.js +5 -5
- package/dist/{client-repo-SE4EKG6W.js → client-repo-NNUCHQ2Y.js} +7 -5
- package/dist/create.js +5 -5
- package/dist/{fields-FTWWMD7N.js → fields-GTHE6TTS.js} +27 -3
- package/dist/gateway-DPPEQZT4.js +25 -0
- package/dist/grants-6JY4XZO7.js +27 -0
- package/dist/invoke-MRONRZ5Q.js +33 -0
- package/dist/moves-UAUCMWL5.js +36 -0
- package/dist/{order-U4KZLLSJ.js → order-RKLGT74L.js} +2 -2
- package/dist/{person-UHLVBVLR.js → person-YOZTFV4Q.js} +11 -10
- package/dist/plan-on-sale-H4F26YIN.js +26 -0
- package/dist/platform/migrations/0730_practitioners.sql +79 -0
- package/dist/platform/migrations/0750_routine_mail.sql +98 -0
- package/dist/platform/migrations/0770_clear_fixed_role_grants.sql +64 -0
- package/dist/platform/migrations/0810_recurrence_exceptions.sql +66 -0
- package/dist/platform/migrations/0811_staff_time.sql +109 -0
- package/dist/platform/migrations/0812_staff_offers.sql +112 -0
- package/dist/platform/migrations/0813_pay_periods.sql +241 -0
- package/dist/platform/migrations/0814_staff_feed.sql +47 -0
- package/dist/platform/migrations/0815_checklists.sql +237 -0
- package/dist/platform/migrations/0816_checklist_schedules.sql +121 -0
- package/dist/platform/migrations/0817_checklist_day_window.sql +35 -0
- package/dist/platform/migrations/0850_agreements.sql +271 -0
- package/dist/platform/migrations/0851_agreement_acceptances.sql +387 -0
- package/dist/platform/migrations/0853_agreement_enforcement.sql +58 -0
- package/dist/platform/migrations/0854_agreement_copy.sql +149 -0
- package/dist/platform/migrations/0855_agreement_retention.sql +279 -0
- package/dist/platform/migrations/0856_subscription_cooling_off.sql +159 -0
- package/dist/platform/migrations/0857_agreement_copy_guardian.sql +337 -0
- package/dist/platform/migrations/0858_agreement_desk.sql +175 -0
- package/dist/platform/migrations/0910_routine_messages.sql +99 -0
- package/dist/platform/migrations/0911_texts.sql +60 -0
- package/dist/platform/migrations/0913_contact_consent.sql +93 -0
- package/dist/platform/migrations/0916_contact_mailbox_index.sql +29 -0
- package/dist/platform/migrations/0930_stock_movements.sql +95 -0
- package/dist/platform/migrations/0931_stock_low.sql +25 -0
- package/dist/platform/migrations/0932_order_delivery.sql +78 -0
- package/dist/platform/migrations/0950_order_adjustments.sql +111 -0
- package/dist/platform/migrations/0951_order_price_guards.sql +33 -0
- package/dist/platform/migrations/0952_order_paid_another_way.sql +194 -0
- package/dist/platform/migrations/0953_discount_uses.sql +183 -0
- package/dist/platform/migrations/0955_folded_addresses.sql +92 -0
- package/dist/platform/migrations/0970_published_text.sql +59 -0
- package/dist/platform/migrations/0971_publish_acks.sql +68 -0
- package/dist/platform/migrations/0990_customer_email_change.sql +65 -0
- package/dist/platform/migrations/1010_intake_links.sql +148 -0
- package/dist/platform/migrations/1030_invoices.sql +747 -0
- package/dist/platform/migrations/1031_invoice_orders.sql +327 -0
- package/dist/platform/migrations/1050_inbox_conversations.sql +83 -0
- package/dist/platform/migrations/1090_staff_hours.sql +43 -0
- package/dist/platform/migrations/1091_staff_time_margins.sql +12 -0
- package/dist/platform/migrations/1092_client_guard.sql +26 -0
- package/dist/platform/migrations/1095_thing_time.sql +70 -0
- package/dist/platform/migrations/1130_devices.sql +162 -0
- package/dist/platform/migrations/1135_person_codes.sql +88 -0
- package/dist/platform/migrations/1150_finance_periods.sql +316 -0
- package/dist/platform/migrations/1151_payouts.sql +202 -0
- package/dist/platform/migrations/1153_finance_money_dates.sql +18 -0
- package/dist/platform/migrations/1170_journeys.sql +318 -0
- package/dist/platform/migrations/1171_person_birthday.sql +52 -0
- package/dist/platform/migrations/1175_person_signals.sql +29 -0
- package/dist/platform/migrations/1190_restricted_values.sql +25 -0
- package/dist/platform/migrations/1230_note_levels.sql +113 -0
- package/dist/platform/migrations/1231_person_carers.sql +33 -0
- package/dist/platform/migrations/1232_note_kinds.sql +122 -0
- package/dist/platform/migrations/1270_time_entries.sql +145 -0
- package/dist/platform/migrations/1271_leave.sql +249 -0
- package/dist/platform/migrations/1273_time_entry_reopened.sql +21 -0
- package/dist/platform/migrations/1330_accounting.sql +260 -0
- package/dist/platform/migrations/1350_customer_feed.sql +24 -0
- package/dist/platform/migrations/1390_locations.sql +77 -0
- package/dist/platform/migrations/1410_outside_copy.sql +213 -0
- package/dist/platform/migrations/1430_inbox_activities.sql +231 -0
- package/dist/platform/migrations/1450_wrong_guesses.sql +23 -0
- package/dist/platform/sdk/acknowledge.ts +100 -0
- package/dist/platform/sdk/agreements.ts +185 -0
- package/dist/platform/sdk/allowance.ts +98 -8
- package/dist/platform/sdk/automation-check.ts +120 -9
- package/dist/platform/sdk/automation.ts +78 -10
- package/dist/platform/sdk/behaviour.ts +26 -6
- package/dist/platform/sdk/calendar-entry.ts +258 -0
- package/dist/platform/sdk/capacity.ts +1 -2
- package/dist/platform/sdk/checklists.ts +118 -0
- package/dist/platform/sdk/contract.ts +489 -27
- package/dist/platform/sdk/discount.ts +408 -0
- package/dist/platform/sdk/document.ts +4 -2
- package/dist/platform/sdk/field-types.ts +5 -0
- package/dist/platform/sdk/formula/compile.ts +10 -0
- package/dist/platform/sdk/index.ts +17 -0
- package/dist/platform/sdk/intake.ts +380 -0
- package/dist/platform/sdk/journey-signals.ts +215 -0
- package/dist/platform/sdk/manifest.ts +1236 -65
- package/dist/platform/sdk/mine.ts +161 -0
- package/dist/platform/sdk/occupies.ts +192 -0
- package/dist/platform/sdk/questions.ts +681 -0
- package/dist/platform/sdk/recurring.ts +90 -9
- package/dist/platform/sdk/restricted-fields.ts +129 -0
- package/dist/platform/sdk/rich-text.ts +112 -0
- package/dist/platform/sdk/routine-mail.ts +1272 -0
- package/dist/platform/sdk/runtime.ts +25 -12
- package/dist/platform/sdk/screens.ts +91 -0
- package/dist/platform/sdk/sellable.ts +344 -0
- package/dist/platform/sdk/slug.ts +7 -2
- package/dist/platform/sdk/staffed.ts +474 -0
- package/dist/platform/sdk/states.ts +68 -26
- package/dist/platform/sdk/stock.ts +332 -0
- package/dist/platform/sdk/team.ts +83 -0
- package/dist/platform/sdk/testing.ts +70 -6
- package/dist/platform/sdk/worked-on.ts +134 -0
- package/dist/{products-2H5DR232.js → products-GCQLSZ3U.js} +2 -2
- package/dist/run-7ID64RA6.js +65 -0
- package/dist/run-FH7OGGTV.js +131 -0
- package/dist/run-OYZIAP6M.js +3363 -0
- package/dist/{run-ZCGFMEZF.js → run-QOFRRSZV.js} +41 -60
- package/dist/{run-PO3W5BFA.js → run-TJAEWR5U.js} +21 -51
- package/dist/{src-I3IJ4NKC.js → src-52VERUPK.js} +306 -4
- package/dist/src-PHRELWN5.js +40 -0
- package/dist/{visibility-TVXZ67FD.js → visibility-SZCINPP4.js} +21 -4
- package/package.json +2 -2
- package/dist/chunk-2TWV3SVB.js +0 -349
- package/dist/chunk-2XC5JLBO.js +0 -1931
- package/dist/chunk-324WJXNP.js +0 -320
- package/dist/chunk-6ELZRNUU.js +0 -116
- package/dist/chunk-6WGFA2IV.js +0 -643
- package/dist/chunk-7CQGMVDO.js +0 -63
- package/dist/chunk-7OGCMQXG.js +0 -284
- package/dist/chunk-FJIZGS5Q.js +0 -698
- package/dist/chunk-UB4I2QKR.js +0 -31575
- package/dist/chunk-WHKJGF36.js +0 -2418
- package/dist/chunk-YNUZRTPH.js +0 -182
- package/dist/chunk-ZZFWMVJO.js +0 -704
- package/dist/grants-LOW6TSWD.js +0 -32
- package/dist/invoke-6KVT6WJI.js +0 -41
- package/dist/moves-E2HKYCTK.js +0 -41
- package/dist/plan-on-sale-TJPFCNL7.js +0 -26
- package/dist/src-CRO35DYY.js +0 -46
|
@@ -1,10 +1,80 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// src/import-door/host.ts
|
|
4
|
+
async function readBody(response) {
|
|
5
|
+
return response.json().catch((error) => {
|
|
6
|
+
if (response.ok) throw error;
|
|
7
|
+
return {};
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
async function readError(response) {
|
|
11
|
+
const body = await response.json().catch(() => ({}));
|
|
12
|
+
return body.error?.message ?? `HTTP ${response.status}`;
|
|
13
|
+
}
|
|
14
|
+
function sessionHost(base, headers, fetcher = fetch, outside = fetcher) {
|
|
15
|
+
return {
|
|
16
|
+
async call(name, input) {
|
|
17
|
+
const response = await fetcher(`${base}/api/v1/op/${encodeURIComponent(name)}`, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: {
|
|
20
|
+
"content-type": "application/json",
|
|
21
|
+
"idempotency-key": crypto.randomUUID(),
|
|
22
|
+
...await headers()
|
|
23
|
+
},
|
|
24
|
+
body: JSON.stringify(input)
|
|
25
|
+
});
|
|
26
|
+
const body = await readBody(response);
|
|
27
|
+
if (!response.ok || body.error) {
|
|
28
|
+
throw Object.assign(new Error(body.error?.message ?? `${name}: HTTP ${response.status}`), {
|
|
29
|
+
code: body.error?.code,
|
|
30
|
+
details: body.error?.details
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return body.data;
|
|
34
|
+
},
|
|
35
|
+
async upload(bytes, name) {
|
|
36
|
+
const response = await fetcher(`${base}/api/v1/media?${new URLSearchParams({ name })}`, {
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers: { "content-type": "application/octet-stream", ...await headers() },
|
|
39
|
+
body: new Uint8Array(bytes)
|
|
40
|
+
});
|
|
41
|
+
const body = await readBody(response);
|
|
42
|
+
if (!response.ok || !body.data) {
|
|
43
|
+
throw new Error(`${name}: ${body.error?.message ?? `HTTP ${response.status}`}`);
|
|
44
|
+
}
|
|
45
|
+
return body.data;
|
|
46
|
+
},
|
|
47
|
+
async uploadCaption(id, language, label, vtt) {
|
|
48
|
+
const query = new URLSearchParams({ language, label });
|
|
49
|
+
const response = await fetcher(
|
|
50
|
+
`${base}/api/v1/media/${encodeURIComponent(id)}/captions?${query}`,
|
|
51
|
+
{
|
|
52
|
+
method: "POST",
|
|
53
|
+
headers: { "content-type": "text/vtt", ...await headers() },
|
|
54
|
+
body: new Uint8Array(vtt)
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
if (!response.ok) throw new Error(`captions (${language}): ${await readError(response)}`);
|
|
58
|
+
},
|
|
59
|
+
send: (url, init) => outside(url, init)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
3
63
|
// src/import-door/sign-in.ts
|
|
4
64
|
import { execFile } from "node:child_process";
|
|
5
65
|
import { createServer } from "node:http";
|
|
6
66
|
import { hostname } from "node:os";
|
|
7
67
|
|
|
68
|
+
// ../client/src/agreements.ts
|
|
69
|
+
var SIGNATURE_LIMITS = {
|
|
70
|
+
strokes: 30,
|
|
71
|
+
points: 5e3,
|
|
72
|
+
bytes: 32768,
|
|
73
|
+
/** The least ink, in box units, the host takes as a signature (not a dot or a tap). */
|
|
74
|
+
minLength: 120
|
|
75
|
+
};
|
|
76
|
+
var BYTES_BUDGET = SIGNATURE_LIMITS.bytes - 256;
|
|
77
|
+
|
|
8
78
|
// ../client/src/binding.ts
|
|
9
79
|
var SESSION_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
10
80
|
|
|
@@ -42,7 +112,11 @@ async function post(fetcher, url, body, headers = {}) {
|
|
|
42
112
|
} catch (error) {
|
|
43
113
|
throw new NetworkError("Could not reach the host to sign in", error);
|
|
44
114
|
}
|
|
45
|
-
|
|
115
|
+
let parsed = {};
|
|
116
|
+
try {
|
|
117
|
+
parsed = JSON.parse(await response.text());
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
46
120
|
if (response.status === 200 && parsed.data) return parsed.data;
|
|
47
121
|
throw new ApiError(
|
|
48
122
|
parsed.error?.code ?? "internal",
|
|
@@ -90,12 +164,18 @@ function tokenSession(options) {
|
|
|
90
164
|
/**
|
|
91
165
|
* Signs in with the emailed code and keeps the device session the host answers with. A wrong,
|
|
92
166
|
* used or expired code throws `forbidden` (`invalid_code`). No cookie is involved.
|
|
167
|
+
*
|
|
168
|
+
* A customer signing in again in place (a sensitive act asked for a recent sign-in) names the
|
|
169
|
+
* device session it replaces by its refresh token (`replaces`): once the new sign-in has
|
|
170
|
+
* worked, the host ends that one, so it does not live on beside it. A wrong code ends nothing.
|
|
93
171
|
*/
|
|
94
172
|
async signInWithCode(email, code, deviceName, audience = "customer") {
|
|
173
|
+
const previous = audience === "customer" ? await options.store.load() : null;
|
|
95
174
|
const signedIn = await post(fetcher, `${base}/api/v1/auth/${audience}/sign-in`, {
|
|
96
175
|
email,
|
|
97
176
|
code,
|
|
98
|
-
deviceName
|
|
177
|
+
deviceName,
|
|
178
|
+
...previous?.refreshToken ? { replaces: previous.refreshToken } : {}
|
|
99
179
|
});
|
|
100
180
|
const { account: _account, ...tokens } = signedIn;
|
|
101
181
|
await options.store.save(tokens);
|
|
@@ -273,6 +353,28 @@ async function signInForRun(host, email, io, label) {
|
|
|
273
353
|
back.close();
|
|
274
354
|
}
|
|
275
355
|
}
|
|
356
|
+
function hostOf(flag, io) {
|
|
357
|
+
const host = flag?.replace(/\/+$/, "");
|
|
358
|
+
if (!host || !/^https?:\/\//.test(host)) {
|
|
359
|
+
io.err("--host is the host's address, e.g. https://admin.example.com");
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
return host;
|
|
363
|
+
}
|
|
364
|
+
async function withRunSession(host, email, io, label, work) {
|
|
365
|
+
let session;
|
|
366
|
+
try {
|
|
367
|
+
session = await signInForRun(host, email, io, label);
|
|
368
|
+
} catch (error) {
|
|
369
|
+
io.err(`Could not sign in: ${error.message}`);
|
|
370
|
+
return 1;
|
|
371
|
+
}
|
|
372
|
+
try {
|
|
373
|
+
return await work(sessionHost(host, () => session.headers()));
|
|
374
|
+
} finally {
|
|
375
|
+
await session.signOut();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
276
378
|
function confirmer(io, yes) {
|
|
277
379
|
return async (summary) => {
|
|
278
380
|
if (yes) return true;
|
|
@@ -285,63 +387,80 @@ function confirmer(io, yes) {
|
|
|
285
387
|
};
|
|
286
388
|
}
|
|
287
389
|
|
|
288
|
-
// src/import-door/
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return
|
|
390
|
+
// src/import-door/records.ts
|
|
391
|
+
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
392
|
+
function replaceMarked(value, marker, id) {
|
|
393
|
+
if (Array.isArray(value)) return value.map((v) => replaceMarked(v, marker, id));
|
|
394
|
+
if (!isObject(value)) return value;
|
|
395
|
+
if (typeof value[marker] === "string" && Object.keys(value).length === 1)
|
|
396
|
+
return id(value[marker]);
|
|
397
|
+
return Object.fromEntries(
|
|
398
|
+
Object.entries(value).map(([k, v]) => [k, replaceMarked(v, marker, id)])
|
|
399
|
+
);
|
|
292
400
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
);
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
401
|
+
var IMPORT_BATCH = 25;
|
|
402
|
+
var chunks = (list, size) => Array.from(
|
|
403
|
+
{ length: Math.ceil(list.length / size) },
|
|
404
|
+
(_, i) => list.slice(i * size, (i + 1) * size)
|
|
405
|
+
);
|
|
406
|
+
async function sha256(value) {
|
|
407
|
+
const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
|
|
408
|
+
const digest = await crypto.subtle.digest("SHA-256", new Uint8Array(bytes));
|
|
409
|
+
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
410
|
+
}
|
|
411
|
+
async function importRecords(host, object, records, options) {
|
|
412
|
+
const out = [];
|
|
413
|
+
for (const part of chunks(records, IMPORT_BATCH)) {
|
|
414
|
+
const answer = await host.call("record.import", {
|
|
415
|
+
object,
|
|
416
|
+
records: part.map(({ key, values }) => ({ key, values })),
|
|
417
|
+
dryRun: options.dryRun,
|
|
418
|
+
checkReferences: options.checkReferences
|
|
419
|
+
});
|
|
420
|
+
for (const result of answer.results) {
|
|
421
|
+
const file = part.find((r) => r.key === result.key)?.file ?? null;
|
|
422
|
+
out.push({ ...result, object, file });
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return out;
|
|
426
|
+
}
|
|
427
|
+
async function knownByHash(host, hashes) {
|
|
428
|
+
const known = /* @__PURE__ */ new Map();
|
|
429
|
+
for (const part of chunks([...new Set(hashes)], 200)) {
|
|
430
|
+
if (!part.length) continue;
|
|
431
|
+
const found = await host.call("media.findByHash", { sha256: part });
|
|
432
|
+
for (const item of found.items) known.set(item.sha256, item);
|
|
433
|
+
}
|
|
434
|
+
return known;
|
|
435
|
+
}
|
|
436
|
+
function outcomeLines(records, dryRun) {
|
|
437
|
+
const lines = [];
|
|
438
|
+
const by = (outcome) => records.filter((r) => r.outcome === outcome);
|
|
439
|
+
const verb = dryRun ? "would be" : "were";
|
|
440
|
+
for (const outcome of ["created", "updated", "unchanged"]) {
|
|
441
|
+
const list = by(outcome);
|
|
442
|
+
if (list.length) {
|
|
443
|
+
lines.push(`${list.length} record(s) ${outcome === "unchanged" ? "are" : verb} ${outcome}.`);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const conflicts = by("conflict");
|
|
447
|
+
if (conflicts.length) {
|
|
448
|
+
lines.push(`${conflicts.length} conflict(s), left as they are:`);
|
|
449
|
+
for (const c of conflicts) lines.push(` ${c.file ?? c.key}: ${c.problems.join("; ")}`);
|
|
450
|
+
}
|
|
451
|
+
return lines;
|
|
340
452
|
}
|
|
341
453
|
|
|
342
454
|
export {
|
|
343
|
-
|
|
455
|
+
sessionHost,
|
|
344
456
|
signInForRun,
|
|
457
|
+
hostOf,
|
|
458
|
+
withRunSession,
|
|
345
459
|
confirmer,
|
|
346
|
-
|
|
460
|
+
isObject,
|
|
461
|
+
replaceMarked,
|
|
462
|
+
sha256,
|
|
463
|
+
importRecords,
|
|
464
|
+
knownByHash,
|
|
465
|
+
outcomeLines
|
|
347
466
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ConfigError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RGKJKC5T.js";
|
|
5
5
|
|
|
6
6
|
// ../core/src/orders/gateway.ts
|
|
7
7
|
var PAYMENTS_VENDOR = "payments";
|
|
8
8
|
var PAYMENTS_RESOURCE_PATTERN = "payments://merchant/:provider";
|
|
9
|
+
var REFUND_ACTION_KIND = "payments.refund";
|
|
9
10
|
var notConnected = () => new ConfigError(
|
|
10
11
|
"Payments are not connected: an admin connects a payment account in Settings \u2192 Integrations"
|
|
11
12
|
);
|
|
@@ -79,10 +80,32 @@ async function callSubscriptionGatekeeper(integrations, target, method, request)
|
|
|
79
80
|
purpose: "orders"
|
|
80
81
|
});
|
|
81
82
|
}
|
|
83
|
+
async function sendHostEmail(integrations, target, message) {
|
|
84
|
+
const call = requireHostCalls(integrations);
|
|
85
|
+
return call({
|
|
86
|
+
connectionId: target.connectionId,
|
|
87
|
+
resource: target.resource,
|
|
88
|
+
method: "send",
|
|
89
|
+
args: [
|
|
90
|
+
{
|
|
91
|
+
to: [message.to],
|
|
92
|
+
subject: message.subject,
|
|
93
|
+
text: message.text,
|
|
94
|
+
...message.idempotencyKey ? { idempotencyKey: message.idempotencyKey } : {}
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
purpose: "orders"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
82
100
|
|
|
83
101
|
export {
|
|
102
|
+
PAYMENTS_VENDOR,
|
|
103
|
+
PAYMENTS_RESOURCE_PATTERN,
|
|
104
|
+
REFUND_ACTION_KIND,
|
|
84
105
|
paymentsTarget,
|
|
106
|
+
providerOfUrl,
|
|
85
107
|
openProviderCheckout,
|
|
86
108
|
requestProviderRefund,
|
|
87
|
-
callSubscriptionGatekeeper
|
|
109
|
+
callSubscriptionGatekeeper,
|
|
110
|
+
sendHostEmail
|
|
88
111
|
};
|