@composable-os/cli 0.0.0-stage → 0.1.0-beta.11
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/LICENSE +109 -0
- package/README.md +24 -2
- package/dist/accounts-UHYLCLEY.js +45 -0
- package/dist/blocks-5IFU25J6.js +233 -0
- package/dist/chunk-2ABSVMGB.js +13 -0
- package/dist/chunk-2IVEVPMY.js +669 -0
- package/dist/chunk-2TWV3SVB.js +349 -0
- package/dist/chunk-2XC5JLBO.js +1931 -0
- package/dist/chunk-324WJXNP.js +320 -0
- package/dist/chunk-5KSXSK7Y.js +47 -0
- package/dist/chunk-6ELZRNUU.js +116 -0
- package/dist/chunk-6UWRT4VM.js +220 -0
- package/dist/chunk-6WGFA2IV.js +643 -0
- package/dist/chunk-6XTU2MTP.js +11278 -0
- package/dist/chunk-7CQGMVDO.js +63 -0
- package/dist/chunk-7D4GKZOX.js +615 -0
- package/dist/chunk-7OGCMQXG.js +284 -0
- package/dist/chunk-DHS2CV2M.js +139 -0
- package/dist/chunk-DU6OIFOU.js +2358 -0
- package/dist/chunk-E4WCYTCT.js +347 -0
- package/dist/chunk-E64SG24J.js +88 -0
- package/dist/chunk-FJIZGS5Q.js +698 -0
- package/dist/chunk-GYTEW66E.js +50 -0
- package/dist/chunk-HDIOVFAZ.js +544 -0
- package/dist/chunk-K34UKWEI.js +298 -0
- package/dist/chunk-KGHA67HG.js +765 -0
- package/dist/chunk-LAAL4YGR.js +365 -0
- package/dist/chunk-LO6WGU5Y.js +26189 -0
- package/dist/chunk-MBIKVRAC.js +1425 -0
- package/dist/chunk-P6UWZ6QQ.js +426 -0
- package/dist/chunk-PDD2ETVF.js +1302 -0
- package/dist/chunk-UB4I2QKR.js +31575 -0
- package/dist/chunk-WHKJGF36.js +2418 -0
- package/dist/chunk-XIDLW3EP.js +15471 -0
- package/dist/chunk-YFTLIEWU.js +504 -0
- package/dist/chunk-YNUZRTPH.js +182 -0
- package/dist/chunk-ZAWES2UD.js +9364 -0
- package/dist/chunk-ZZFWMVJO.js +704 -0
- package/dist/cli-5UNY5G5L.js +136 -0
- package/dist/cli-UYZMVQMR.js +24534 -0
- package/dist/cli.js +25 -0
- package/dist/client-repo-SE4EKG6W.js +55 -0
- package/dist/create.js +25 -0
- package/dist/fields-FTWWMD7N.js +50 -0
- package/dist/grants-LOW6TSWD.js +32 -0
- package/dist/invoke-6KVT6WJI.js +41 -0
- package/dist/moves-E2HKYCTK.js +41 -0
- package/dist/order-U4KZLLSJ.js +19 -0
- package/dist/person-UHLVBVLR.js +67 -0
- package/dist/plan-on-sale-TJPFCNL7.js +26 -0
- package/dist/platform/migrations/0001_init.sql +59 -0
- package/dist/platform/migrations/0002_users_settings.sql +34 -0
- package/dist/platform/migrations/0003_people_organisations.sql +225 -0
- package/dist/platform/migrations/0004_activities_tasks.sql +88 -0
- package/dist/platform/migrations/0005_views_audit.sql +79 -0
- package/dist/platform/migrations/0006_search.sql +223 -0
- package/dist/platform/migrations/0007_crm_views.sql +141 -0
- package/dist/platform/migrations/0008_audit_redaction.sql +116 -0
- package/dist/platform/migrations/0010_approval_queue.sql +90 -0
- package/dist/platform/migrations/0011_connected_apps.sql +36 -0
- package/dist/platform/migrations/0020_extensions.sql +373 -0
- package/dist/platform/migrations/0030_extension_proposals.sql +29 -0
- package/dist/platform/migrations/0050_live_row_indexes.sql +32 -0
- package/dist/platform/migrations/0060_audit_read_counts.sql +31 -0
- package/dist/platform/migrations/0061_audit_retention.sql +95 -0
- package/dist/platform/migrations/0062_run_history_retention.sql +6 -0
- package/dist/platform/migrations/0063_pending_action_compaction.sql +18 -0
- package/dist/platform/migrations/0064_drop_rate_limit.sql +6 -0
- package/dist/platform/migrations/0065_storage_stats.sql +13 -0
- package/dist/platform/migrations/0070_drop_proposals_ext_idx.sql +9 -0
- package/dist/platform/migrations/0080_views_dashboards.sql +46 -0
- package/dist/platform/migrations/0100_stage_history.sql +54 -0
- package/dist/platform/migrations/0110_integrations.sql +103 -0
- package/dist/platform/migrations/0111_email_calendar_sync.sql +137 -0
- package/dist/platform/migrations/0112_sync_item_occurred_at.sql +8 -0
- package/dist/platform/migrations/0130_automations.sql +113 -0
- package/dist/platform/migrations/0131_notifications.sql +29 -0
- package/dist/platform/migrations/0132_automation_runtime.sql +14 -0
- package/dist/platform/migrations/0150_ai_summaries_embeddings.sql +48 -0
- package/dist/platform/migrations/0160_releases.sql +41 -0
- package/dist/platform/migrations/0161_setup_wizard.sql +30 -0
- package/dist/platform/migrations/0170_automation_connections.sql +32 -0
- package/dist/platform/migrations/0171_automation_outbox.sql +23 -0
- package/dist/platform/migrations/0172_notification_delivery.sql +46 -0
- package/dist/platform/migrations/0200_assistant_conversations.sql +25 -0
- package/dist/platform/migrations/0205_policy_adjudicator.sql +61 -0
- package/dist/platform/migrations/0210_daily_digest.sql +33 -0
- package/dist/platform/migrations/0220_entitlements.sql +13 -0
- package/dist/platform/migrations/0221_support_grants.sql +33 -0
- package/dist/platform/migrations/0250_judge.sql +11 -0
- package/dist/platform/migrations/0251_adjudication_judgement.sql +8 -0
- package/dist/platform/migrations/0252_judge_usage.sql +14 -0
- package/dist/platform/migrations/0255_summary_checks.sql +9 -0
- package/dist/platform/migrations/0256_outbound_check.sql +9 -0
- package/dist/platform/migrations/0260_ai_usage.sql +20 -0
- package/dist/platform/migrations/0270_assistant_conversation_refs.sql +29 -0
- package/dist/platform/migrations/0310_assignment_rules.sql +54 -0
- package/dist/platform/migrations/0320_duplicates.sql +41 -0
- package/dist/platform/migrations/0330_erase_completeness.sql +54 -0
- package/dist/platform/migrations/0350_assistant_thread.sql +38 -0
- package/dist/platform/migrations/0351_assistant_model_roles.sql +26 -0
- package/dist/platform/migrations/0352_assistant_memory.sql +74 -0
- package/dist/platform/migrations/0358_ai_cache_observation.sql +24 -0
- package/dist/platform/migrations/0359_ai_compaction_decision.sql +25 -0
- package/dist/platform/migrations/0360_ai_cache_estimate.sql +35 -0
- package/dist/platform/migrations/0361_voice_preferences.sql +27 -0
- package/dist/platform/migrations/0362_voice_usage.sql +17 -0
- package/dist/platform/migrations/0365_routines.sql +38 -0
- package/dist/platform/migrations/0370_approval_execution.sql +20 -0
- package/dist/platform/migrations/0371_agent_jobs.sql +65 -0
- package/dist/platform/migrations/0380_rec_views.sql +94 -0
- package/dist/platform/migrations/0400_customer_audit_actor.sql +142 -0
- package/dist/platform/migrations/0401_customer_accounts.sql +61 -0
- package/dist/platform/migrations/0402_erase_requests.sql +34 -0
- package/dist/platform/migrations/0410_idempotency_keys.sql +45 -0
- package/dist/platform/migrations/0411_device_sessions.sql +33 -0
- package/dist/platform/migrations/0420_transition_history.sql +100 -0
- package/dist/platform/migrations/0421_orders.sql +134 -0
- package/dist/platform/migrations/0422_order_payments.sql +109 -0
- package/dist/platform/migrations/0440_capacity.sql +100 -0
- package/dist/platform/migrations/0441_capacity_views.sql +40 -0
- package/dist/platform/migrations/0450_order_grants.sql +21 -0
- package/dist/platform/migrations/0451_pack_roles.sql +18 -0
- package/dist/platform/migrations/0460_content.sql +59 -0
- package/dist/platform/migrations/0461_media.sql +52 -0
- package/dist/platform/migrations/0470_publish_versions.sql +36 -0
- package/dist/platform/migrations/0471_permission_grants.sql +18 -0
- package/dist/platform/migrations/0490_staff_invites.sql +40 -0
- package/dist/platform/migrations/0491_sign_in_mail_kind.sql +10 -0
- package/dist/platform/migrations/0492_email_confirmation_and_sign_in_confirm.sql +30 -0
- package/dist/platform/migrations/0500_published_media_field.sql +25 -0
- package/dist/platform/migrations/0501_import_keys.sql +23 -0
- package/dist/platform/migrations/0510_video_and_file_media.sql +109 -0
- package/dist/platform/migrations/0516_order_tax.sql +63 -0
- package/dist/platform/migrations/0520_publish_requests.sql +20 -0
- package/dist/platform/migrations/0530_subscriptions.sql +173 -0
- package/dist/platform/migrations/0531_subscription_trials.sql +56 -0
- package/dist/platform/migrations/0532_subscription_offers.sql +80 -0
- package/dist/platform/migrations/0533_allowances.sql +262 -0
- package/dist/platform/migrations/0560_recurring.sql +75 -0
- package/dist/platform/migrations/0580_subscription_grants.sql +21 -0
- package/dist/platform/migrations/0581_once_per_person.sql +34 -0
- package/dist/platform/migrations/0600_tool_actions_ran_at_queue.sql +22 -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/sdk/allowance.ts +522 -0
- package/dist/platform/sdk/automation-check.ts +534 -0
- package/dist/platform/sdk/automation.ts +743 -0
- package/dist/platform/sdk/behaviour.ts +215 -0
- package/dist/platform/sdk/capacity.ts +303 -0
- package/dist/platform/sdk/contract.ts +909 -0
- package/dist/platform/sdk/document.ts +935 -0
- package/dist/platform/sdk/field-types.ts +111 -0
- package/dist/platform/sdk/formula/ast.ts +72 -0
- package/dist/platform/sdk/formula/compile.ts +454 -0
- package/dist/platform/sdk/formula/index.ts +4 -0
- package/dist/platform/sdk/formula/parser.ts +417 -0
- package/dist/platform/sdk/index.ts +36 -0
- package/dist/platform/sdk/manifest.ts +1785 -0
- package/dist/platform/sdk/media.ts +108 -0
- package/dist/platform/sdk/permissions.ts +60 -0
- package/dist/platform/sdk/recurring.ts +321 -0
- package/dist/platform/sdk/renamed.ts +63 -0
- package/dist/platform/sdk/rich-text-fixture.ts +68 -0
- package/dist/platform/sdk/rich-text.ts +221 -0
- package/dist/platform/sdk/runtime.ts +410 -0
- package/dist/platform/sdk/sellable.ts +1138 -0
- package/dist/platform/sdk/slug.ts +25 -0
- package/dist/platform/sdk/states.ts +598 -0
- package/dist/platform/sdk/testing.ts +847 -0
- package/dist/platform/sdk/unique.ts +81 -0
- package/dist/products-2H5DR232.js +11 -0
- package/dist/run-7P4RQALH.js +648 -0
- package/dist/run-PO3W5BFA.js +508 -0
- package/dist/run-ZCGFMEZF.js +309 -0
- package/dist/src-CRO35DYY.js +46 -0
- package/dist/src-I3IJ4NKC.js +354 -0
- package/dist/token-MOJUA2U6.js +70 -0
- package/dist/token-util-TENRN4V7.js +6 -0
- package/dist/visibility-TVXZ67FD.js +41 -0
- package/package.json +33 -4
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/import-door/records.ts
|
|
4
|
+
var IMPORT_BATCH = 25;
|
|
5
|
+
var chunks = (list, size) => Array.from(
|
|
6
|
+
{ length: Math.ceil(list.length / size) },
|
|
7
|
+
(_, i) => list.slice(i * size, (i + 1) * size)
|
|
8
|
+
);
|
|
9
|
+
async function sha256(value) {
|
|
10
|
+
const bytes = typeof value === "string" ? new TextEncoder().encode(value) : value;
|
|
11
|
+
const digest = await crypto.subtle.digest("SHA-256", new Uint8Array(bytes));
|
|
12
|
+
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
13
|
+
}
|
|
14
|
+
async function importRecords(host, object, records, options) {
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const part of chunks(records, IMPORT_BATCH)) {
|
|
17
|
+
const answer = await host.call("record.import", {
|
|
18
|
+
object,
|
|
19
|
+
records: part.map(({ key, values }) => ({ key, values })),
|
|
20
|
+
dryRun: options.dryRun,
|
|
21
|
+
checkReferences: options.checkReferences
|
|
22
|
+
});
|
|
23
|
+
for (const result of answer.results) {
|
|
24
|
+
const file = part.find((r) => r.key === result.key)?.file ?? null;
|
|
25
|
+
out.push({ ...result, object, file });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
async function knownByHash(host, hashes) {
|
|
31
|
+
const known = /* @__PURE__ */ new Map();
|
|
32
|
+
for (const part of chunks([...new Set(hashes)], 200)) {
|
|
33
|
+
if (!part.length) continue;
|
|
34
|
+
const found = await host.call("media.findByHash", { sha256: part });
|
|
35
|
+
for (const item of found.items) known.set(item.sha256, item);
|
|
36
|
+
}
|
|
37
|
+
return known;
|
|
38
|
+
}
|
|
39
|
+
function outcomeLines(records, dryRun) {
|
|
40
|
+
const lines = [];
|
|
41
|
+
const by = (outcome) => records.filter((r) => r.outcome === outcome);
|
|
42
|
+
const verb = dryRun ? "would be" : "were";
|
|
43
|
+
for (const outcome of ["created", "updated", "unchanged"]) {
|
|
44
|
+
const list = by(outcome);
|
|
45
|
+
if (list.length) {
|
|
46
|
+
lines.push(`${list.length} record(s) ${outcome === "unchanged" ? "are" : verb} ${outcome}.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const conflicts = by("conflict");
|
|
50
|
+
if (conflicts.length) {
|
|
51
|
+
lines.push(`${conflicts.length} conflict(s), left as they are:`);
|
|
52
|
+
for (const c of conflicts) lines.push(` ${c.file ?? c.key}: ${c.problems.join("; ")}`);
|
|
53
|
+
}
|
|
54
|
+
return lines;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
chunks,
|
|
59
|
+
sha256,
|
|
60
|
+
importRecords,
|
|
61
|
+
knownByHash,
|
|
62
|
+
outcomeLines
|
|
63
|
+
};
|
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
MEDIA_FILE_TYPES,
|
|
4
|
+
MEDIA_KINDS,
|
|
5
|
+
MEDIA_TYPES,
|
|
6
|
+
MEDIA_VIDEO_TYPE
|
|
7
|
+
} from "./chunk-LO6WGU5Y.js";
|
|
8
|
+
|
|
9
|
+
// ../core/src/fields/types.ts
|
|
10
|
+
function defineObject(object) {
|
|
11
|
+
const names = /* @__PURE__ */ new Set();
|
|
12
|
+
for (const field of object.fields) {
|
|
13
|
+
if (names.has(field.name)) throw new Error(`${object.name}: duplicate field ${field.name}`);
|
|
14
|
+
names.add(field.name);
|
|
15
|
+
if ((field.filterable || field.sortable) && !field.column && !field.related) {
|
|
16
|
+
throw new Error(`${object.name}.${field.name}: filterable fields need a column or related`);
|
|
17
|
+
}
|
|
18
|
+
if (field.sortable && !field.column) {
|
|
19
|
+
throw new Error(`${object.name}.${field.name}: only single-valued fields can be sortable`);
|
|
20
|
+
}
|
|
21
|
+
if (field.type === "enum" && !field.enumValues?.length) {
|
|
22
|
+
throw new Error(`${object.name}.${field.name}: enum fields need enumValues`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (!names.has(object.defaultSort.field)) {
|
|
26
|
+
throw new Error(`${object.name}: default sort field ${object.defaultSort.field} is unknown`);
|
|
27
|
+
}
|
|
28
|
+
return object;
|
|
29
|
+
}
|
|
30
|
+
function getField(object, name) {
|
|
31
|
+
return object.fields.find((field) => field.name === name);
|
|
32
|
+
}
|
|
33
|
+
function timelineFields(object) {
|
|
34
|
+
return object.fields.filter((field) => field.track === "timeline").map((field) => field.name);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ../core/src/fields/media.ts
|
|
38
|
+
var ITEM_TYPES = [...MEDIA_TYPES, ...MEDIA_FILE_TYPES, MEDIA_VIDEO_TYPE];
|
|
39
|
+
var mediaObject = defineObject({
|
|
40
|
+
name: "media",
|
|
41
|
+
label: "Media",
|
|
42
|
+
plural: "Media",
|
|
43
|
+
source: "rec_media",
|
|
44
|
+
titleField: "name",
|
|
45
|
+
defaultSort: { field: "createdAt", direction: "desc" },
|
|
46
|
+
fields: [
|
|
47
|
+
{ name: "id", label: "ID", type: "id", column: "id", filterable: true, sortable: true },
|
|
48
|
+
{ name: "name", label: "Name", type: "text", column: "name", filterable: true, sortable: true },
|
|
49
|
+
{
|
|
50
|
+
name: "kind",
|
|
51
|
+
label: "Kind",
|
|
52
|
+
type: "enum",
|
|
53
|
+
enumValues: MEDIA_KINDS,
|
|
54
|
+
column: "kind",
|
|
55
|
+
filterable: true,
|
|
56
|
+
sortable: true
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "type",
|
|
60
|
+
label: "Type",
|
|
61
|
+
type: "enum",
|
|
62
|
+
enumValues: ITEM_TYPES,
|
|
63
|
+
column: "type",
|
|
64
|
+
filterable: true,
|
|
65
|
+
sortable: true
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "bytes",
|
|
69
|
+
label: "Size",
|
|
70
|
+
type: "number",
|
|
71
|
+
column: "bytes",
|
|
72
|
+
filterable: true,
|
|
73
|
+
sortable: true
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "width",
|
|
77
|
+
label: "Width",
|
|
78
|
+
type: "number",
|
|
79
|
+
column: "width",
|
|
80
|
+
filterable: true,
|
|
81
|
+
sortable: true
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "height",
|
|
85
|
+
label: "Height",
|
|
86
|
+
type: "number",
|
|
87
|
+
column: "height",
|
|
88
|
+
filterable: true,
|
|
89
|
+
sortable: true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "state",
|
|
93
|
+
label: "State",
|
|
94
|
+
type: "enum",
|
|
95
|
+
enumValues: ["uploading", "processing", "ready", "failed"],
|
|
96
|
+
column: "state",
|
|
97
|
+
filterable: true,
|
|
98
|
+
sortable: true
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "duration",
|
|
102
|
+
label: "Duration (seconds)",
|
|
103
|
+
type: "number",
|
|
104
|
+
column: "duration",
|
|
105
|
+
filterable: true,
|
|
106
|
+
sortable: true
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "alt",
|
|
110
|
+
label: "Alt text",
|
|
111
|
+
type: "text",
|
|
112
|
+
column: "alt",
|
|
113
|
+
filterable: true,
|
|
114
|
+
sortable: false
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "createdAt",
|
|
118
|
+
label: "Uploaded",
|
|
119
|
+
type: "datetime",
|
|
120
|
+
column: "created_at",
|
|
121
|
+
filterable: true,
|
|
122
|
+
sortable: true
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "createdBy",
|
|
126
|
+
label: "Uploaded by",
|
|
127
|
+
type: "id",
|
|
128
|
+
column: "created_by",
|
|
129
|
+
filterable: true,
|
|
130
|
+
sortable: false
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// ../core/src/fields/subscription.ts
|
|
136
|
+
var SUBSCRIPTION_STATES = [
|
|
137
|
+
"incomplete",
|
|
138
|
+
"expired",
|
|
139
|
+
"trialing",
|
|
140
|
+
"active",
|
|
141
|
+
"past_due",
|
|
142
|
+
"unpaid",
|
|
143
|
+
"paused",
|
|
144
|
+
"ended"
|
|
145
|
+
];
|
|
146
|
+
var STATE_LABELS = {
|
|
147
|
+
incomplete: "Incomplete",
|
|
148
|
+
expired: "Expired",
|
|
149
|
+
trialing: "Trial",
|
|
150
|
+
active: "Active",
|
|
151
|
+
past_due: "Past due",
|
|
152
|
+
unpaid: "Unpaid",
|
|
153
|
+
paused: "Paused",
|
|
154
|
+
ended: "Ended"
|
|
155
|
+
};
|
|
156
|
+
var LIVE = ["incomplete", "trialing", "active", "past_due", "unpaid", "paused"];
|
|
157
|
+
var others = (state) => LIVE.filter((s) => s !== state);
|
|
158
|
+
var SUBSCRIPTION_MACHINE = {
|
|
159
|
+
field: "state",
|
|
160
|
+
initial: "incomplete",
|
|
161
|
+
moves: [
|
|
162
|
+
{ from: others("trialing"), to: "trialing", by: ["host"] },
|
|
163
|
+
{ from: others("active"), to: "active", by: ["host"] },
|
|
164
|
+
{ from: others("past_due"), to: "past_due", by: ["host"] },
|
|
165
|
+
{ from: others("unpaid"), to: "unpaid", by: ["host"] },
|
|
166
|
+
{ from: others("paused"), to: "paused", by: ["host"] },
|
|
167
|
+
// The first payment never succeeded within the provider's 23 hours.
|
|
168
|
+
{ from: "incomplete", to: "expired", by: ["host"], final: true },
|
|
169
|
+
{ from: [...LIVE], to: "ended", by: ["host"], final: true }
|
|
170
|
+
]
|
|
171
|
+
};
|
|
172
|
+
var id = { type: "id", filterable: true, sortable: false };
|
|
173
|
+
var amount = { type: "number", filterable: true, sortable: true };
|
|
174
|
+
var when = { type: "datetime", filterable: true, sortable: true };
|
|
175
|
+
var text = (name, label, column) => ({ name, label, type: "text", column, filterable: true, sortable: false });
|
|
176
|
+
var subscriptionObject = defineObject({
|
|
177
|
+
name: "subscription",
|
|
178
|
+
label: "Subscription",
|
|
179
|
+
plural: "Subscriptions",
|
|
180
|
+
source: "rec_subscription",
|
|
181
|
+
titleField: "planTitle",
|
|
182
|
+
defaultSort: { field: "createdAt", direction: "desc" },
|
|
183
|
+
states: SUBSCRIPTION_MACHINE,
|
|
184
|
+
customer: {
|
|
185
|
+
field: "payerPersonId",
|
|
186
|
+
read: [
|
|
187
|
+
"holderPersonId",
|
|
188
|
+
"planObject",
|
|
189
|
+
"planId",
|
|
190
|
+
"planTitle",
|
|
191
|
+
"amount",
|
|
192
|
+
"currency",
|
|
193
|
+
"interval",
|
|
194
|
+
"taxed",
|
|
195
|
+
"state",
|
|
196
|
+
"trialEnd",
|
|
197
|
+
"currentPeriodStart",
|
|
198
|
+
"currentPeriodEnd",
|
|
199
|
+
"cancelAtPeriodEnd",
|
|
200
|
+
"cancelAt",
|
|
201
|
+
"canceledAt",
|
|
202
|
+
"endedAt",
|
|
203
|
+
"actionUrl",
|
|
204
|
+
"createdAt",
|
|
205
|
+
// The change it shows (stage 32b, ADRs 0530, 0531): the payer's own plan change or pause.
|
|
206
|
+
"changeId",
|
|
207
|
+
"changeKind",
|
|
208
|
+
"changeState",
|
|
209
|
+
"changeToPlanId",
|
|
210
|
+
"changeToPlanTitle",
|
|
211
|
+
"changeToAmount",
|
|
212
|
+
"pauseFrom",
|
|
213
|
+
"pauseUntil",
|
|
214
|
+
"changeEffectiveAt",
|
|
215
|
+
"changeRequestedAt",
|
|
216
|
+
"changeCallOutcome",
|
|
217
|
+
"changeActionUrl",
|
|
218
|
+
"changeEndOutcome"
|
|
219
|
+
],
|
|
220
|
+
write: []
|
|
221
|
+
},
|
|
222
|
+
fields: [
|
|
223
|
+
{ name: "id", label: "ID", type: "id", column: "id", filterable: true, sortable: true },
|
|
224
|
+
{
|
|
225
|
+
...id,
|
|
226
|
+
name: "payerPersonId",
|
|
227
|
+
label: "Payer",
|
|
228
|
+
column: "payer_person_id",
|
|
229
|
+
fieldType: "relation",
|
|
230
|
+
options: { to: "person" }
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
...id,
|
|
234
|
+
name: "holderPersonId",
|
|
235
|
+
label: "Holder",
|
|
236
|
+
column: "holder_person_id",
|
|
237
|
+
fieldType: "relation",
|
|
238
|
+
options: { to: "person" }
|
|
239
|
+
},
|
|
240
|
+
text("email", "Email", "email"),
|
|
241
|
+
{
|
|
242
|
+
name: "placedAs",
|
|
243
|
+
label: "Started by",
|
|
244
|
+
type: "enum",
|
|
245
|
+
enumValues: ["customer", "public", "staff"],
|
|
246
|
+
column: "placed_as",
|
|
247
|
+
filterable: true,
|
|
248
|
+
sortable: false
|
|
249
|
+
},
|
|
250
|
+
text("planObject", "Plan's object", "plan_object"),
|
|
251
|
+
{ ...id, name: "planId", label: "Plan", column: "plan_id" },
|
|
252
|
+
text("planTitle", "Plan", "plan_title"),
|
|
253
|
+
{ ...amount, name: "amount", label: "Price per period", column: "amount" },
|
|
254
|
+
text("currency", "Currency", "currency"),
|
|
255
|
+
{
|
|
256
|
+
name: "interval",
|
|
257
|
+
label: "Every",
|
|
258
|
+
type: "enum",
|
|
259
|
+
enumValues: ["week", "month", "year"],
|
|
260
|
+
column: "interval",
|
|
261
|
+
filterable: true,
|
|
262
|
+
sortable: false
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "taxed",
|
|
266
|
+
label: "Taxed",
|
|
267
|
+
type: "boolean",
|
|
268
|
+
column: "taxed",
|
|
269
|
+
filterable: true,
|
|
270
|
+
sortable: false
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "state",
|
|
274
|
+
label: "State",
|
|
275
|
+
type: "enum",
|
|
276
|
+
enumValues: SUBSCRIPTION_STATES,
|
|
277
|
+
column: "state",
|
|
278
|
+
filterable: true,
|
|
279
|
+
sortable: true,
|
|
280
|
+
options: {
|
|
281
|
+
choices: SUBSCRIPTION_STATES.map((value) => ({ value, label: STATE_LABELS[value] }))
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
text("provider", "Provider", "provider"),
|
|
285
|
+
text("providerRef", "Provider's reference", "provider_ref"),
|
|
286
|
+
{ ...when, name: "trialEnd", label: "Trial ends", column: "trial_end" },
|
|
287
|
+
{ ...when, name: "currentPeriodStart", label: "Period from", column: "current_period_start" },
|
|
288
|
+
{ ...when, name: "currentPeriodEnd", label: "Period to", column: "current_period_end" },
|
|
289
|
+
{
|
|
290
|
+
name: "cancelAtPeriodEnd",
|
|
291
|
+
label: "Ends at period end",
|
|
292
|
+
type: "boolean",
|
|
293
|
+
column: "cancel_at_period_end",
|
|
294
|
+
filterable: true,
|
|
295
|
+
sortable: false
|
|
296
|
+
},
|
|
297
|
+
// A date set at the provider another way (its dashboard): the host's resume cannot undo it.
|
|
298
|
+
{ ...when, name: "cancelAt", label: "Ends on", column: "cancel_at" },
|
|
299
|
+
{ ...when, name: "canceledAt", label: "Cancelled on", column: "canceled_at" },
|
|
300
|
+
{ ...when, name: "endedAt", label: "Ended on", column: "ended_at" },
|
|
301
|
+
text("endReason", "Why it ended", "end_reason"),
|
|
302
|
+
text("actionUrl", "Confirm payment at", "action_url"),
|
|
303
|
+
{ ...when, name: "failingSince", label: "Failing since", column: "failing_since" },
|
|
304
|
+
{ ...when, name: "createdAt", label: "Started", column: "created_at" },
|
|
305
|
+
// Stage 32b (migration 0630): the plan change or pause it shows, asked for and not yet over,
|
|
306
|
+
// or the pause it is in. Written by the host only (core_subscription_change).
|
|
307
|
+
text("changeId", "Change", "change_id"),
|
|
308
|
+
{
|
|
309
|
+
name: "changeKind",
|
|
310
|
+
label: "Change",
|
|
311
|
+
type: "enum",
|
|
312
|
+
enumValues: ["upgrade", "downgrade", "pause"],
|
|
313
|
+
column: "change_kind",
|
|
314
|
+
filterable: true,
|
|
315
|
+
sortable: false
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
name: "changeState",
|
|
319
|
+
label: "Change state",
|
|
320
|
+
type: "enum",
|
|
321
|
+
enumValues: ["requested", "waiting", "applied", "lapsed", "withdrawn"],
|
|
322
|
+
column: "change_state",
|
|
323
|
+
filterable: true,
|
|
324
|
+
sortable: false
|
|
325
|
+
},
|
|
326
|
+
{ ...id, name: "changeToPlanId", label: "Changing to", column: "change_to_plan_id" },
|
|
327
|
+
text("changeToPlanTitle", "Changing to", "change_to_plan_title"),
|
|
328
|
+
{ ...amount, name: "changeToAmount", label: "New price", column: "change_to_amount" },
|
|
329
|
+
{ ...when, name: "pauseFrom", label: "Paused from", column: "pause_from" },
|
|
330
|
+
{ ...when, name: "pauseUntil", label: "Paused until", column: "pause_until" },
|
|
331
|
+
{ ...when, name: "changeEffectiveAt", label: "Change from", column: "change_effective_at" },
|
|
332
|
+
{ ...when, name: "changeRequestedAt", label: "Change asked", column: "change_requested_at" },
|
|
333
|
+
{
|
|
334
|
+
name: "changeCallOutcome",
|
|
335
|
+
label: "Provider's answer",
|
|
336
|
+
type: "enum",
|
|
337
|
+
enumValues: ["sent", "pending", "unknown", "refused"],
|
|
338
|
+
column: "change_call_outcome",
|
|
339
|
+
filterable: true,
|
|
340
|
+
sortable: false
|
|
341
|
+
},
|
|
342
|
+
text("changeActionUrl", "Confirm the change's payment at", "change_action_url"),
|
|
343
|
+
{
|
|
344
|
+
name: "changeEndOutcome",
|
|
345
|
+
label: "Ending it: provider's answer",
|
|
346
|
+
type: "enum",
|
|
347
|
+
enumValues: ["sent", "pending", "unknown", "refused"],
|
|
348
|
+
column: "change_end_outcome",
|
|
349
|
+
filterable: true,
|
|
350
|
+
sortable: false
|
|
351
|
+
},
|
|
352
|
+
{ ...when, name: "updatedAt", label: "Updated", column: "updated_at" }
|
|
353
|
+
]
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// ../core/src/fields/order.ts
|
|
357
|
+
var ORDER_STATES = [
|
|
358
|
+
"pending",
|
|
359
|
+
"part_paid",
|
|
360
|
+
"paid",
|
|
361
|
+
"cancelled",
|
|
362
|
+
"expired",
|
|
363
|
+
"refunded"
|
|
364
|
+
];
|
|
365
|
+
var STATE_LABELS2 = {
|
|
366
|
+
pending: "Pending",
|
|
367
|
+
part_paid: "Part paid",
|
|
368
|
+
paid: "Paid",
|
|
369
|
+
cancelled: "Cancelled",
|
|
370
|
+
expired: "Expired",
|
|
371
|
+
refunded: "Refunded"
|
|
372
|
+
};
|
|
373
|
+
var ORDER_MACHINE = {
|
|
374
|
+
field: "state",
|
|
375
|
+
initial: "pending",
|
|
376
|
+
moves: [
|
|
377
|
+
// Only a verified payment marks an order paid, in part or in full.
|
|
378
|
+
{ from: ["pending", "part_paid", "expired"], to: "paid", by: ["host"] },
|
|
379
|
+
// A late deposit staff honour (ADR 0429) makes an expired order part paid.
|
|
380
|
+
{ from: ["pending", "expired"], to: "part_paid", by: ["host"] },
|
|
381
|
+
// A buyer may give up an order they have paid nothing on. Once money is on it, staff cancel.
|
|
382
|
+
// The host too (ADR 0560): a drop-in booking that leaves its held place another way (its
|
|
383
|
+
// class cancelled) cancels its unpaid order in the same batch.
|
|
384
|
+
{ from: "pending", to: "cancelled", by: ["staff", "customer", "host"], final: true },
|
|
385
|
+
{ from: "part_paid", to: "cancelled", by: ["staff"], final: true },
|
|
386
|
+
// Not final: a late payment staff choose to honour makes it paid.
|
|
387
|
+
{ from: "pending", to: "expired", by: ["host"] },
|
|
388
|
+
{ from: "paid", to: "refunded", by: ["host"], final: true }
|
|
389
|
+
]
|
|
390
|
+
};
|
|
391
|
+
var id2 = { type: "id", filterable: true, sortable: false };
|
|
392
|
+
var amount2 = { type: "number", filterable: true, sortable: true };
|
|
393
|
+
var when2 = { type: "datetime", filterable: true, sortable: true };
|
|
394
|
+
var orderObject = defineObject({
|
|
395
|
+
name: "order",
|
|
396
|
+
label: "Order",
|
|
397
|
+
plural: "Orders",
|
|
398
|
+
source: "rec_order",
|
|
399
|
+
defaultSort: { field: "createdAt", direction: "desc" },
|
|
400
|
+
states: ORDER_MACHINE,
|
|
401
|
+
customer: {
|
|
402
|
+
field: "personId",
|
|
403
|
+
read: [
|
|
404
|
+
"state",
|
|
405
|
+
"currency",
|
|
406
|
+
"total",
|
|
407
|
+
"paid",
|
|
408
|
+
"balance",
|
|
409
|
+
"refunded",
|
|
410
|
+
"pay",
|
|
411
|
+
"deposit",
|
|
412
|
+
"balanceDueAt",
|
|
413
|
+
"expiresAt",
|
|
414
|
+
"paidAt",
|
|
415
|
+
"createdAt",
|
|
416
|
+
"taxAmount",
|
|
417
|
+
"taxRefunded",
|
|
418
|
+
"taxCountry",
|
|
419
|
+
"subscriptionId",
|
|
420
|
+
"periodStart",
|
|
421
|
+
"periodEnd"
|
|
422
|
+
],
|
|
423
|
+
write: []
|
|
424
|
+
},
|
|
425
|
+
fields: [
|
|
426
|
+
{ name: "id", label: "ID", type: "id", column: "id", filterable: true, sortable: true },
|
|
427
|
+
{
|
|
428
|
+
...id2,
|
|
429
|
+
name: "personId",
|
|
430
|
+
label: "Person",
|
|
431
|
+
column: "person_id",
|
|
432
|
+
// What the customer declaration needs to know: this is whose order it is.
|
|
433
|
+
fieldType: "relation",
|
|
434
|
+
options: { to: "person" }
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: "email",
|
|
438
|
+
label: "Email",
|
|
439
|
+
type: "text",
|
|
440
|
+
column: "email",
|
|
441
|
+
filterable: true,
|
|
442
|
+
sortable: false
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
name: "state",
|
|
446
|
+
label: "State",
|
|
447
|
+
type: "enum",
|
|
448
|
+
enumValues: ORDER_STATES,
|
|
449
|
+
column: "state",
|
|
450
|
+
filterable: true,
|
|
451
|
+
sortable: true,
|
|
452
|
+
options: {
|
|
453
|
+
choices: ORDER_STATES.map((value) => ({ value, label: STATE_LABELS2[value] }))
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
name: "currency",
|
|
458
|
+
label: "Currency",
|
|
459
|
+
type: "text",
|
|
460
|
+
column: "currency",
|
|
461
|
+
filterable: true,
|
|
462
|
+
sortable: false
|
|
463
|
+
},
|
|
464
|
+
{ ...amount2, name: "total", label: "Total", column: "total" },
|
|
465
|
+
{ ...amount2, name: "paid", label: "Paid", column: "paid" },
|
|
466
|
+
{ ...amount2, name: "balance", label: "Balance", column: "balance" },
|
|
467
|
+
{ ...amount2, name: "refunded", label: "Refunded", column: "refunded" },
|
|
468
|
+
{
|
|
469
|
+
name: "pay",
|
|
470
|
+
label: "Paying",
|
|
471
|
+
type: "enum",
|
|
472
|
+
enumValues: ["full", "deposit"],
|
|
473
|
+
column: "pay",
|
|
474
|
+
filterable: true,
|
|
475
|
+
sortable: false
|
|
476
|
+
},
|
|
477
|
+
{ ...amount2, name: "deposit", label: "Deposit", column: "deposit" },
|
|
478
|
+
{ ...when2, name: "balanceDueAt", label: "Balance due", column: "balance_due_at" },
|
|
479
|
+
{ ...when2, name: "expiresAt", label: "Expires", column: "expires_at" },
|
|
480
|
+
{
|
|
481
|
+
name: "placedAs",
|
|
482
|
+
label: "Placed by",
|
|
483
|
+
type: "enum",
|
|
484
|
+
enumValues: ["customer", "public", "staff"],
|
|
485
|
+
column: "placed_as",
|
|
486
|
+
filterable: true,
|
|
487
|
+
sortable: false
|
|
488
|
+
},
|
|
489
|
+
{ ...when2, name: "paidAt", label: "Paid on", column: "paid_at" },
|
|
490
|
+
{ ...when2, name: "cancelledAt", label: "Cancelled on", column: "cancelled_at" },
|
|
491
|
+
{ ...when2, name: "refundedAt", label: "Refunded on", column: "refunded_at" },
|
|
492
|
+
{ ...when2, name: "createdAt", label: "Created", column: "created_at" },
|
|
493
|
+
{ ...when2, name: "updatedAt", label: "Updated", column: "updated_at" },
|
|
494
|
+
// Tax at checkout (ADR 0479): the provider's figures, inside the amounts above.
|
|
495
|
+
{ ...amount2, name: "taxAmount", label: "Tax", column: "tax_amount" },
|
|
496
|
+
{ ...amount2, name: "taxRefunded", label: "Tax refunded", column: "tax_refunded" },
|
|
497
|
+
{
|
|
498
|
+
name: "taxCountry",
|
|
499
|
+
label: "Tax country",
|
|
500
|
+
type: "text",
|
|
501
|
+
column: "tax_country",
|
|
502
|
+
filterable: true,
|
|
503
|
+
sortable: false
|
|
504
|
+
},
|
|
505
|
+
{ ...amount2, name: "net", label: "Net of tax", column: "net" },
|
|
506
|
+
// A subscription period's order (ADR 0486).
|
|
507
|
+
{ ...id2, name: "subscriptionId", label: "Subscription", column: "subscription_id" },
|
|
508
|
+
{ ...when2, name: "periodStart", label: "Period from", column: "period_start" },
|
|
509
|
+
{ ...when2, name: "periodEnd", label: "Period to", column: "period_end" },
|
|
510
|
+
// Staff only: a period paid other than as agreed, recorded for what was paid.
|
|
511
|
+
{
|
|
512
|
+
name: "periodFlag",
|
|
513
|
+
label: "Paid other than agreed",
|
|
514
|
+
type: "enum",
|
|
515
|
+
enumValues: ["paid_less", "paid_more", "not_as_agreed"],
|
|
516
|
+
column: "period_flag",
|
|
517
|
+
filterable: true,
|
|
518
|
+
sortable: false
|
|
519
|
+
}
|
|
520
|
+
]
|
|
521
|
+
});
|
|
522
|
+
var orderLineObject = defineObject({
|
|
523
|
+
name: "orderLine",
|
|
524
|
+
label: "Order line",
|
|
525
|
+
plural: "Order lines",
|
|
526
|
+
source: "rec_order_line",
|
|
527
|
+
defaultSort: { field: "position", direction: "asc" },
|
|
528
|
+
customer: {
|
|
529
|
+
field: "personId",
|
|
530
|
+
read: [
|
|
531
|
+
"orderId",
|
|
532
|
+
"position",
|
|
533
|
+
"object",
|
|
534
|
+
"recordId",
|
|
535
|
+
"title",
|
|
536
|
+
"quantity",
|
|
537
|
+
"unitPrice",
|
|
538
|
+
"total",
|
|
539
|
+
"taxAmount"
|
|
540
|
+
],
|
|
541
|
+
write: []
|
|
542
|
+
},
|
|
543
|
+
fields: [
|
|
544
|
+
{ name: "id", label: "ID", type: "id", column: "id", filterable: true, sortable: true },
|
|
545
|
+
{ ...id2, name: "orderId", label: "Order", column: "order_id" },
|
|
546
|
+
{
|
|
547
|
+
...id2,
|
|
548
|
+
name: "personId",
|
|
549
|
+
label: "Person",
|
|
550
|
+
column: "person_id",
|
|
551
|
+
fieldType: "relation",
|
|
552
|
+
options: { to: "person" }
|
|
553
|
+
},
|
|
554
|
+
{ ...amount2, name: "position", label: "Position", column: "position" },
|
|
555
|
+
{
|
|
556
|
+
name: "object",
|
|
557
|
+
label: "What is bought",
|
|
558
|
+
type: "text",
|
|
559
|
+
column: "object_type",
|
|
560
|
+
filterable: true,
|
|
561
|
+
sortable: false
|
|
562
|
+
},
|
|
563
|
+
{ ...id2, name: "recordId", label: "Record", column: "record_id" },
|
|
564
|
+
{
|
|
565
|
+
name: "title",
|
|
566
|
+
label: "Title",
|
|
567
|
+
type: "text",
|
|
568
|
+
column: "title",
|
|
569
|
+
filterable: true,
|
|
570
|
+
sortable: false
|
|
571
|
+
},
|
|
572
|
+
{ ...amount2, name: "quantity", label: "Quantity", column: "quantity" },
|
|
573
|
+
{ ...amount2, name: "unitPrice", label: "Unit price", column: "unit_price" },
|
|
574
|
+
{ ...amount2, name: "total", label: "Line total", column: "line_total" },
|
|
575
|
+
{ ...when2, name: "createdAt", label: "Created", column: "created_at" },
|
|
576
|
+
{ ...amount2, name: "taxAmount", label: "Tax", column: "tax_amount" },
|
|
577
|
+
{
|
|
578
|
+
name: "taxCode",
|
|
579
|
+
label: "Tax code",
|
|
580
|
+
type: "text",
|
|
581
|
+
column: "tax_code",
|
|
582
|
+
filterable: true,
|
|
583
|
+
sortable: false
|
|
584
|
+
}
|
|
585
|
+
]
|
|
586
|
+
});
|
|
587
|
+
var BASE_OBJECTS = {
|
|
588
|
+
order: orderObject,
|
|
589
|
+
orderLine: orderLineObject,
|
|
590
|
+
// Stage 28 (ADR 0444): the media library.
|
|
591
|
+
media: mediaObject,
|
|
592
|
+
// Stage 32a (ADR 0485): a subscription the payment provider runs.
|
|
593
|
+
subscription: subscriptionObject
|
|
594
|
+
};
|
|
595
|
+
var BASE_TABLES = {
|
|
596
|
+
order: "core_order",
|
|
597
|
+
orderLine: "core_order_line",
|
|
598
|
+
media: "core_media",
|
|
599
|
+
subscription: "core_subscription"
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
export {
|
|
603
|
+
defineObject,
|
|
604
|
+
getField,
|
|
605
|
+
timelineFields,
|
|
606
|
+
mediaObject,
|
|
607
|
+
SUBSCRIPTION_STATES,
|
|
608
|
+
subscriptionObject,
|
|
609
|
+
ORDER_STATES,
|
|
610
|
+
ORDER_MACHINE,
|
|
611
|
+
orderObject,
|
|
612
|
+
orderLineObject,
|
|
613
|
+
BASE_OBJECTS,
|
|
614
|
+
BASE_TABLES
|
|
615
|
+
};
|