@composable-os/cli 0.1.0-beta.10 → 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-X4CKM3HL.js → accounts-GOCNY6WI.js} +17 -14
- package/dist/app-RPRZMLU5.js +43 -0
- package/dist/app-upload-YJVEKZC6.js +198 -0
- package/dist/{blocks-YWDHEBOK.js → blocks-DE4RRWPJ.js} +207 -25
- package/dist/{chunk-VY64DMQO.js → chunk-2B6YUYZV.js} +23576 -11674
- package/dist/{run-RT2HVWMK.js → chunk-2CCHB37H.js} +9 -146
- package/dist/{chunk-DU6OIFOU.js → chunk-3OGDWKJ3.js} +530 -434
- package/dist/chunk-5D7BDF4Y.js +141 -0
- package/dist/{chunk-WO6D3XP3.js → chunk-6CM3WZG5.js} +13 -2470
- package/dist/chunk-CIBJGB5H.js +962 -0
- package/dist/chunk-EPDTPGZJ.js +330 -0
- package/dist/{chunk-LLULPZAJ.js → chunk-HAYF4G5V.js} +66 -23
- package/dist/chunk-HCG6T53D.js +61904 -0
- package/dist/chunk-JX4IFWNT.js +330 -0
- package/dist/{chunk-A4NTSYWV.js → chunk-KFHKNXGH.js} +786 -386
- 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-LJFLENFC.js → chunk-Q6Y45DY6.js} +25 -2
- package/dist/{chunk-Y7JZFSTQ.js → chunk-QJZGYJVV.js} +823 -44
- package/dist/{chunk-6VXHPKGG.js → chunk-QQ3YSL5F.js} +172 -16
- package/dist/chunk-RGKJKC5T.js +876 -0
- package/dist/{chunk-IFG4FRW5.js → chunk-RSEWEFAV.js} +12 -2
- package/dist/{chunk-2ABSVMGB.js → chunk-SMJZIK2O.js} +1 -1
- package/dist/{chunk-CP6BXI6F.js → chunk-U72NEGCT.js} +8818 -3829
- package/dist/{chunk-WC5LHBBA.js → chunk-Z4IKF23A.js} +11 -7
- package/dist/chunk-Z7OVQ6BC.js +713 -0
- package/dist/{chunk-6UWRT4VM.js → chunk-ZJSFX4RD.js} +175 -3
- package/dist/{cli-2DFENR62.js → cli-OKQHHSOE.js} +17 -23
- package/dist/{cli-YIOVSKOD.js → cli-VYSD2S4Z.js} +231 -82
- package/dist/cli.js +5 -5
- package/dist/{client-repo-PRU3VCQQ.js → client-repo-NNUCHQ2Y.js} +7 -5
- package/dist/create.js +5 -5
- package/dist/{fields-2NC7LSYE.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-PUWD65BC.js → order-RKLGT74L.js} +2 -2
- package/dist/{person-WIQQ7ITU.js → person-YOZTFV4Q.js} +11 -11
- package/dist/plan-on-sale-H4F26YIN.js +26 -0
- package/dist/platform/migrations/0610_waitlists.sql +54 -0
- package/dist/platform/migrations/0630_subscription_changes.sql +122 -0
- package/dist/platform/migrations/0650_person_links.sql +90 -0
- package/dist/platform/migrations/0670_unmoved_guard.sql +52 -0
- package/dist/platform/migrations/0690_sellable_refund_due.sql +98 -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 +103 -2
- package/dist/platform/sdk/checklists.ts +118 -0
- package/dist/platform/sdk/contract.ts +514 -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 +1313 -66
- 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 +595 -1
- package/dist/platform/sdk/slug.ts +7 -2
- package/dist/platform/sdk/staffed.ts +474 -0
- package/dist/platform/sdk/states.ts +220 -64
- 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-Y7T4TVOL.js → run-QOFRRSZV.js} +41 -60
- package/dist/{run-PZUCSDDL.js → run-TJAEWR5U.js} +21 -51
- package/dist/{src-XTOD7EXW.js → src-52VERUPK.js} +312 -4
- package/dist/src-PHRELWN5.js +40 -0
- package/dist/visibility-SZCINPP4.js +58 -0
- package/package.json +2 -2
- package/dist/chunk-6GDEDOV7.js +0 -157
- package/dist/chunk-6UPUF4ML.js +0 -29998
- package/dist/chunk-7CQGMVDO.js +0 -63
- package/dist/chunk-GYSGVT6R.js +0 -284
- package/dist/chunk-JJHHNV46.js +0 -227
- package/dist/chunk-K6T42YCH.js +0 -704
- package/dist/chunk-M7A6FR2Z.js +0 -2586
- package/dist/chunk-O2UIZHND.js +0 -249
- package/dist/chunk-Q4N55M2Z.js +0 -552
- package/dist/chunk-QGGJ2G6Z.js +0 -349
- package/dist/chunk-R4W5XAUD.js +0 -837
- package/dist/chunk-TQFGGSA4.js +0 -748
- package/dist/chunk-YJJHF65I.js +0 -759
- package/dist/chunk-Z3RMMB6S.js +0 -668
- package/dist/grants-QXMKYMGB.js +0 -32
- package/dist/invoke-I3NNNXVL.js +0 -39
- package/dist/plan-on-sale-NB774CQL.js +0 -26
- package/dist/src-GYS6NBQB.js +0 -44
- package/dist/visibility-DLGHU4YN.js +0 -33
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
priceLines
|
|
4
|
+
} from "./chunk-2B6YUYZV.js";
|
|
5
|
+
import {
|
|
6
|
+
loadOrderCurrency,
|
|
7
|
+
loadReturnOrigins,
|
|
8
|
+
sellableOf,
|
|
9
|
+
sellableProblems
|
|
10
|
+
} from "./chunk-KMFMD52Z.js";
|
|
11
|
+
import {
|
|
12
|
+
buyableSource,
|
|
13
|
+
refreshSchemaRegistry,
|
|
14
|
+
scopeOf,
|
|
15
|
+
sql,
|
|
16
|
+
viewColumnOf
|
|
17
|
+
} from "./chunk-KFHKNXGH.js";
|
|
18
|
+
import {
|
|
19
|
+
listObjects
|
|
20
|
+
} from "./chunk-RSEWEFAV.js";
|
|
21
|
+
import {
|
|
22
|
+
paymentsTarget
|
|
23
|
+
} from "./chunk-Q6Y45DY6.js";
|
|
24
|
+
import {
|
|
25
|
+
ConfigError,
|
|
26
|
+
ValidationError
|
|
27
|
+
} from "./chunk-RGKJKC5T.js";
|
|
28
|
+
|
|
29
|
+
// ../core/src/orders/subscription-setup.ts
|
|
30
|
+
async function subscriptionSetup(db) {
|
|
31
|
+
let target = null;
|
|
32
|
+
try {
|
|
33
|
+
target = await paymentsTarget(db);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (!(error instanceof ConfigError)) throw error;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
returnOrigins: [...await loadReturnOrigins(db)],
|
|
39
|
+
currency: await loadOrderCurrency(db),
|
|
40
|
+
target
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function setupComplete(setup) {
|
|
44
|
+
return setup.returnOrigins.length > 0 && setup.currency !== null && setup.target !== null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ../core/src/customers/plan-on-sale.ts
|
|
48
|
+
var PUBLIC = Object.freeze({ kind: "public" });
|
|
49
|
+
var PLANS_LOOKED_AT = 50;
|
|
50
|
+
var PLAN_ON_SALE_MEMO_MS = 6e4;
|
|
51
|
+
var memo = null;
|
|
52
|
+
function forgetPlanOnSale() {
|
|
53
|
+
memo = null;
|
|
54
|
+
}
|
|
55
|
+
async function findPlanOnSale(db, now = (/* @__PURE__ */ new Date()).toISOString(), options = {}) {
|
|
56
|
+
const at = Date.now();
|
|
57
|
+
if (options.memo && memo && at - memo.at < PLAN_ON_SALE_MEMO_MS) return memo.value;
|
|
58
|
+
let value;
|
|
59
|
+
try {
|
|
60
|
+
value = await compute(db, now);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
value = { state: "unknown", reason: error instanceof Error ? error.message : String(error) };
|
|
63
|
+
}
|
|
64
|
+
memo = { at, value };
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
async function hasPlanOnSale(db, now = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
68
|
+
return (await findPlanOnSale(db, now)).state === "on_sale";
|
|
69
|
+
}
|
|
70
|
+
async function compute(db, now) {
|
|
71
|
+
const setup = await subscriptionSetup(db);
|
|
72
|
+
if (!setupComplete(setup)) return { state: "none" };
|
|
73
|
+
await refreshSchemaRegistry(db);
|
|
74
|
+
let unanswered = false;
|
|
75
|
+
for (const object of listObjects()) {
|
|
76
|
+
const sellable = sellableOf(object);
|
|
77
|
+
if (!sellable?.recurring || sellableProblems(sellable, object).length) continue;
|
|
78
|
+
const scope = scopeOf(PUBLIC, object, false);
|
|
79
|
+
if (scope.kind !== "public") continue;
|
|
80
|
+
let source;
|
|
81
|
+
try {
|
|
82
|
+
source = buyableSource({ principal: PUBLIC }, object);
|
|
83
|
+
} catch {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const readable = new Set(scope.columns);
|
|
87
|
+
const columnOf = (name) => {
|
|
88
|
+
const field = name ? object.fields.find((f) => f.name === name) : void 0;
|
|
89
|
+
const column = field ? viewColumnOf(field) : null;
|
|
90
|
+
return column && readable.has(column) ? column : null;
|
|
91
|
+
};
|
|
92
|
+
let query = db.selectFrom(source).select("id");
|
|
93
|
+
const price = columnOf(sellable.price);
|
|
94
|
+
if (price) query = query.where(sql.ref(price), ">", 0);
|
|
95
|
+
const day = now.slice(0, 10);
|
|
96
|
+
const from = columnOf(sellable.saleWindow?.from);
|
|
97
|
+
if (from) {
|
|
98
|
+
query = query.where(
|
|
99
|
+
(eb) => eb.or([eb(sql.ref(from), "is", null), eb(sql.ref(from), "<=", now)])
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const until = columnOf(sellable.saleWindow?.until);
|
|
103
|
+
if (until) {
|
|
104
|
+
query = query.where(
|
|
105
|
+
(eb) => eb.or([eb(sql.ref(until), "is", null), eb(sql.ref(until), ">=", day)])
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
const rows = await query.orderBy("id").limit(PLANS_LOOKED_AT + 1).execute();
|
|
109
|
+
for (const { id } of rows.slice(0, PLANS_LOOKED_AT)) {
|
|
110
|
+
const found = await priced(db, object, id, setup.currency, now);
|
|
111
|
+
if (found) return { state: "on_sale", plan: found };
|
|
112
|
+
}
|
|
113
|
+
if (rows.length > PLANS_LOOKED_AT) unanswered = true;
|
|
114
|
+
}
|
|
115
|
+
return unanswered ? { state: "unknown", reason: `more than ${PLANS_LOOKED_AT} plans to look at` } : { state: "none" };
|
|
116
|
+
}
|
|
117
|
+
async function priced(db, object, id, currency, now) {
|
|
118
|
+
try {
|
|
119
|
+
const [line] = await priceLines(
|
|
120
|
+
db,
|
|
121
|
+
[{ object: object.name, id, quantity: 1 }],
|
|
122
|
+
currency,
|
|
123
|
+
now,
|
|
124
|
+
PUBLIC,
|
|
125
|
+
{ plans: true }
|
|
126
|
+
);
|
|
127
|
+
return line?.recurring && line.unitPrice > 0 ? { object: object.name, id, title: line.title } : null;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if (error instanceof ValidationError) return null;
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export {
|
|
135
|
+
subscriptionSetup,
|
|
136
|
+
PLANS_LOOKED_AT,
|
|
137
|
+
PLAN_ON_SALE_MEMO_MS,
|
|
138
|
+
forgetPlanOnSale,
|
|
139
|
+
findPlanOnSale,
|
|
140
|
+
hasPlanOnSale
|
|
141
|
+
};
|