@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,504 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
BASE_OBJECTS,
|
|
4
|
+
defineObject
|
|
5
|
+
} from "./chunk-7D4GKZOX.js";
|
|
6
|
+
|
|
7
|
+
// ../core/src/fields/activity.ts
|
|
8
|
+
var activityObject = defineObject({
|
|
9
|
+
name: "activity",
|
|
10
|
+
label: "Activity",
|
|
11
|
+
plural: "Activities",
|
|
12
|
+
source: "rec_activity",
|
|
13
|
+
defaultSort: { field: "occurredAt", direction: "desc" },
|
|
14
|
+
fields: [
|
|
15
|
+
{ name: "id", label: "ID", type: "id", column: "id", filterable: true, sortable: true },
|
|
16
|
+
{
|
|
17
|
+
name: "type",
|
|
18
|
+
label: "Type",
|
|
19
|
+
type: "enum",
|
|
20
|
+
enumValues: ["note", "email", "call", "meeting", "system"],
|
|
21
|
+
column: "type",
|
|
22
|
+
filterable: true,
|
|
23
|
+
sortable: true
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "subject",
|
|
27
|
+
label: "Subject",
|
|
28
|
+
type: "text",
|
|
29
|
+
column: "subject",
|
|
30
|
+
filterable: true,
|
|
31
|
+
sortable: true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "body",
|
|
35
|
+
label: "Body",
|
|
36
|
+
type: "text",
|
|
37
|
+
column: "body",
|
|
38
|
+
filterable: true,
|
|
39
|
+
sortable: false
|
|
40
|
+
},
|
|
41
|
+
{ name: "payload", label: "Details", type: "json", filterable: false, sortable: false },
|
|
42
|
+
{
|
|
43
|
+
name: "occurredAt",
|
|
44
|
+
label: "When",
|
|
45
|
+
type: "datetime",
|
|
46
|
+
column: "occurred_at",
|
|
47
|
+
filterable: true,
|
|
48
|
+
sortable: true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "authorUserId",
|
|
52
|
+
label: "Author",
|
|
53
|
+
type: "id",
|
|
54
|
+
column: "author_user_id",
|
|
55
|
+
filterable: true,
|
|
56
|
+
sortable: false
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "authorActor",
|
|
60
|
+
label: "Author type",
|
|
61
|
+
type: "enum",
|
|
62
|
+
enumValues: ["human", "assistant", "mcp", "automation", "system"],
|
|
63
|
+
column: "author_actor",
|
|
64
|
+
filterable: true,
|
|
65
|
+
sortable: false
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "linkedRecordId",
|
|
69
|
+
label: "Linked record",
|
|
70
|
+
type: "id",
|
|
71
|
+
related: { from: "core_activity_links r", link: "r.activity_id", column: "r.record_id" },
|
|
72
|
+
filterable: true,
|
|
73
|
+
sortable: false
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "createdAt",
|
|
77
|
+
label: "Created",
|
|
78
|
+
type: "datetime",
|
|
79
|
+
column: "created_at",
|
|
80
|
+
filterable: true,
|
|
81
|
+
sortable: true
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// ../core/src/fields/organisation.ts
|
|
87
|
+
var organisationObject = defineObject({
|
|
88
|
+
name: "organisation",
|
|
89
|
+
label: "Organisation",
|
|
90
|
+
source: "rec_organisation",
|
|
91
|
+
defaultSort: { field: "name", direction: "asc" },
|
|
92
|
+
ownerField: "ownerId",
|
|
93
|
+
fields: [
|
|
94
|
+
{ name: "id", label: "ID", type: "id", column: "id", filterable: true, sortable: true },
|
|
95
|
+
{
|
|
96
|
+
name: "name",
|
|
97
|
+
label: "Name",
|
|
98
|
+
type: "text",
|
|
99
|
+
column: "name",
|
|
100
|
+
filterable: true,
|
|
101
|
+
sortable: true,
|
|
102
|
+
track: "timeline"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "primaryDomain",
|
|
106
|
+
label: "Primary domain",
|
|
107
|
+
type: "text",
|
|
108
|
+
column: "primary_domain",
|
|
109
|
+
filterable: true,
|
|
110
|
+
sortable: true
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "domains",
|
|
114
|
+
label: "Domains",
|
|
115
|
+
type: "text",
|
|
116
|
+
related: {
|
|
117
|
+
from: "core_organisation_domains r",
|
|
118
|
+
link: "r.organisation_id",
|
|
119
|
+
column: "r.domain"
|
|
120
|
+
},
|
|
121
|
+
filterable: true,
|
|
122
|
+
sortable: false,
|
|
123
|
+
track: "timeline"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "website",
|
|
127
|
+
label: "Website",
|
|
128
|
+
type: "text",
|
|
129
|
+
column: "website",
|
|
130
|
+
filterable: true,
|
|
131
|
+
sortable: true
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "industry",
|
|
135
|
+
label: "Industry",
|
|
136
|
+
type: "text",
|
|
137
|
+
column: "industry",
|
|
138
|
+
filterable: true,
|
|
139
|
+
sortable: true
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "parentId",
|
|
143
|
+
label: "Parent organisation",
|
|
144
|
+
type: "id",
|
|
145
|
+
column: "parent_id",
|
|
146
|
+
filterable: true,
|
|
147
|
+
sortable: false,
|
|
148
|
+
track: "timeline"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "parentName",
|
|
152
|
+
label: "Parent name",
|
|
153
|
+
type: "text",
|
|
154
|
+
column: "parent_name",
|
|
155
|
+
filterable: true,
|
|
156
|
+
sortable: true
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: "ownerId",
|
|
160
|
+
label: "Owner",
|
|
161
|
+
type: "id",
|
|
162
|
+
column: "owner_id",
|
|
163
|
+
filterable: true,
|
|
164
|
+
sortable: false,
|
|
165
|
+
track: "timeline"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "currentPeopleCount",
|
|
169
|
+
label: "People",
|
|
170
|
+
type: "number",
|
|
171
|
+
column: "current_people_count",
|
|
172
|
+
filterable: true,
|
|
173
|
+
sortable: true
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "tags",
|
|
177
|
+
label: "Tags",
|
|
178
|
+
type: "text",
|
|
179
|
+
related: {
|
|
180
|
+
from: "core_record_tags rt JOIN core_tags r ON r.id = rt.tag_id",
|
|
181
|
+
link: "rt.record_id",
|
|
182
|
+
column: "r.name",
|
|
183
|
+
where: "rt.object_type = 'organisation'"
|
|
184
|
+
},
|
|
185
|
+
filterable: true,
|
|
186
|
+
sortable: false
|
|
187
|
+
},
|
|
188
|
+
{ name: "addresses", label: "Addresses", type: "json", filterable: false, sortable: false },
|
|
189
|
+
{ name: "avatarKey", label: "Logo", type: "text", filterable: false, sortable: false },
|
|
190
|
+
{ name: "description", label: "Description", type: "text", filterable: false, sortable: false },
|
|
191
|
+
{
|
|
192
|
+
name: "createdAt",
|
|
193
|
+
label: "Created",
|
|
194
|
+
type: "datetime",
|
|
195
|
+
column: "created_at",
|
|
196
|
+
filterable: true,
|
|
197
|
+
sortable: true
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "updatedAt",
|
|
201
|
+
label: "Updated",
|
|
202
|
+
type: "datetime",
|
|
203
|
+
column: "updated_at",
|
|
204
|
+
filterable: true,
|
|
205
|
+
sortable: true
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// ../core/src/fields/person.ts
|
|
211
|
+
var personObject = defineObject({
|
|
212
|
+
name: "person",
|
|
213
|
+
label: "Person",
|
|
214
|
+
source: "rec_person",
|
|
215
|
+
defaultSort: { field: "displayName", direction: "asc" },
|
|
216
|
+
ownerField: "ownerId",
|
|
217
|
+
// A Person is their own customer (stage 22, ADR 0402): signed in, they read their name, primary
|
|
218
|
+
// email and primary phone (`me.get`) and change their name and phone (`me.update`). The email is
|
|
219
|
+
// not writable: it would tell a customer whether an address belongs to another person (the
|
|
220
|
+
// uniqueness conflict), and sign-in uses the account's own address, not this one.
|
|
221
|
+
customer: {
|
|
222
|
+
field: "id",
|
|
223
|
+
read: ["displayName", "givenName", "familyName", "primaryEmail", "primaryPhone"],
|
|
224
|
+
write: ["displayName", "givenName", "familyName", "primaryPhone"]
|
|
225
|
+
},
|
|
226
|
+
fields: [
|
|
227
|
+
{ name: "id", label: "ID", type: "id", column: "id", filterable: true, sortable: true },
|
|
228
|
+
{
|
|
229
|
+
name: "displayName",
|
|
230
|
+
label: "Name",
|
|
231
|
+
type: "text",
|
|
232
|
+
column: "display_name",
|
|
233
|
+
filterable: true,
|
|
234
|
+
sortable: true
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "givenName",
|
|
238
|
+
label: "Given name",
|
|
239
|
+
type: "text",
|
|
240
|
+
column: "given_name",
|
|
241
|
+
filterable: true,
|
|
242
|
+
sortable: true
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: "familyName",
|
|
246
|
+
label: "Family name",
|
|
247
|
+
type: "text",
|
|
248
|
+
column: "family_name",
|
|
249
|
+
filterable: true,
|
|
250
|
+
sortable: true
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "primaryEmail",
|
|
254
|
+
label: "Primary email",
|
|
255
|
+
type: "text",
|
|
256
|
+
column: "primary_email",
|
|
257
|
+
filterable: true,
|
|
258
|
+
sortable: true
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "emails",
|
|
262
|
+
label: "Emails",
|
|
263
|
+
type: "text",
|
|
264
|
+
related: { from: "core_person_emails r", link: "r.person_id", column: "r.email" },
|
|
265
|
+
filterable: true,
|
|
266
|
+
sortable: false
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: "primaryPhone",
|
|
270
|
+
label: "Primary phone",
|
|
271
|
+
type: "text",
|
|
272
|
+
column: "primary_phone",
|
|
273
|
+
filterable: true,
|
|
274
|
+
sortable: true
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
name: "phones",
|
|
278
|
+
label: "Phones",
|
|
279
|
+
type: "text",
|
|
280
|
+
related: { from: "core_person_phones r", link: "r.person_id", column: "r.number" },
|
|
281
|
+
filterable: true,
|
|
282
|
+
sortable: false
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: "jobTitle",
|
|
286
|
+
label: "Job title",
|
|
287
|
+
type: "text",
|
|
288
|
+
column: "job_title",
|
|
289
|
+
filterable: true,
|
|
290
|
+
sortable: true
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "organisationId",
|
|
294
|
+
label: "Organisation",
|
|
295
|
+
type: "id",
|
|
296
|
+
column: "organisation_id",
|
|
297
|
+
filterable: true,
|
|
298
|
+
sortable: false
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: "organisationName",
|
|
302
|
+
label: "Organisation name",
|
|
303
|
+
type: "text",
|
|
304
|
+
column: "organisation_name",
|
|
305
|
+
filterable: true,
|
|
306
|
+
sortable: true
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
name: "location",
|
|
310
|
+
label: "Location",
|
|
311
|
+
type: "text",
|
|
312
|
+
column: "location",
|
|
313
|
+
filterable: true,
|
|
314
|
+
sortable: true
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
name: "timezone",
|
|
318
|
+
label: "Timezone",
|
|
319
|
+
type: "text",
|
|
320
|
+
column: "timezone",
|
|
321
|
+
filterable: true,
|
|
322
|
+
sortable: true
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
name: "ownerId",
|
|
326
|
+
label: "Owner",
|
|
327
|
+
type: "id",
|
|
328
|
+
column: "owner_id",
|
|
329
|
+
filterable: true,
|
|
330
|
+
sortable: false,
|
|
331
|
+
track: "timeline"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
name: "tags",
|
|
335
|
+
label: "Tags",
|
|
336
|
+
type: "text",
|
|
337
|
+
related: {
|
|
338
|
+
from: "core_record_tags rt JOIN core_tags r ON r.id = rt.tag_id",
|
|
339
|
+
link: "rt.record_id",
|
|
340
|
+
column: "r.name",
|
|
341
|
+
where: "rt.object_type = 'person'"
|
|
342
|
+
},
|
|
343
|
+
filterable: true,
|
|
344
|
+
sortable: false
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "socialProfiles",
|
|
348
|
+
label: "Social profiles",
|
|
349
|
+
type: "json",
|
|
350
|
+
filterable: false,
|
|
351
|
+
sortable: false
|
|
352
|
+
},
|
|
353
|
+
{ name: "avatarKey", label: "Avatar", type: "text", filterable: false, sortable: false },
|
|
354
|
+
{ name: "description", label: "Description", type: "text", filterable: false, sortable: false },
|
|
355
|
+
{
|
|
356
|
+
name: "createdAt",
|
|
357
|
+
label: "Created",
|
|
358
|
+
type: "datetime",
|
|
359
|
+
column: "created_at",
|
|
360
|
+
filterable: true,
|
|
361
|
+
sortable: true
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "updatedAt",
|
|
365
|
+
label: "Updated",
|
|
366
|
+
type: "datetime",
|
|
367
|
+
column: "updated_at",
|
|
368
|
+
filterable: true,
|
|
369
|
+
sortable: true
|
|
370
|
+
}
|
|
371
|
+
]
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
// ../core/src/fields/task.ts
|
|
375
|
+
var taskObject = defineObject({
|
|
376
|
+
name: "task",
|
|
377
|
+
label: "Task",
|
|
378
|
+
source: "rec_task",
|
|
379
|
+
defaultSort: { field: "dueAt", direction: "asc" },
|
|
380
|
+
fields: [
|
|
381
|
+
{ name: "id", label: "ID", type: "id", column: "id", filterable: true, sortable: true },
|
|
382
|
+
{
|
|
383
|
+
name: "title",
|
|
384
|
+
label: "Title",
|
|
385
|
+
type: "text",
|
|
386
|
+
column: "title",
|
|
387
|
+
filterable: true,
|
|
388
|
+
sortable: true
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: "notes",
|
|
392
|
+
label: "Notes",
|
|
393
|
+
type: "text",
|
|
394
|
+
column: "notes",
|
|
395
|
+
filterable: true,
|
|
396
|
+
sortable: false
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: "dueAt",
|
|
400
|
+
label: "Due",
|
|
401
|
+
type: "datetime",
|
|
402
|
+
column: "due_at",
|
|
403
|
+
filterable: true,
|
|
404
|
+
sortable: true
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
name: "status",
|
|
408
|
+
label: "Status",
|
|
409
|
+
type: "enum",
|
|
410
|
+
enumValues: ["open", "done"],
|
|
411
|
+
column: "status",
|
|
412
|
+
filterable: true,
|
|
413
|
+
sortable: true
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
name: "completedAt",
|
|
417
|
+
label: "Completed",
|
|
418
|
+
type: "datetime",
|
|
419
|
+
column: "completed_at",
|
|
420
|
+
filterable: true,
|
|
421
|
+
sortable: true
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
name: "assigneeId",
|
|
425
|
+
label: "Assignee",
|
|
426
|
+
type: "id",
|
|
427
|
+
column: "assignee_id",
|
|
428
|
+
filterable: true,
|
|
429
|
+
sortable: false
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
name: "createdBy",
|
|
433
|
+
label: "Created by",
|
|
434
|
+
type: "id",
|
|
435
|
+
column: "created_by",
|
|
436
|
+
filterable: true,
|
|
437
|
+
sortable: false
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
name: "linkedRecordId",
|
|
441
|
+
label: "Linked record",
|
|
442
|
+
type: "id",
|
|
443
|
+
related: { from: "core_task_links r", link: "r.task_id", column: "r.record_id" },
|
|
444
|
+
filterable: true,
|
|
445
|
+
sortable: false
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
name: "createdAt",
|
|
449
|
+
label: "Created",
|
|
450
|
+
type: "datetime",
|
|
451
|
+
column: "created_at",
|
|
452
|
+
filterable: true,
|
|
453
|
+
sortable: true
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
name: "updatedAt",
|
|
457
|
+
label: "Updated",
|
|
458
|
+
type: "datetime",
|
|
459
|
+
column: "updated_at",
|
|
460
|
+
filterable: true,
|
|
461
|
+
sortable: true
|
|
462
|
+
}
|
|
463
|
+
]
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
// ../core/src/fields/index.ts
|
|
467
|
+
var CORE_OBJECTS = {
|
|
468
|
+
person: personObject,
|
|
469
|
+
organisation: organisationObject,
|
|
470
|
+
activity: activityObject,
|
|
471
|
+
task: taskObject
|
|
472
|
+
};
|
|
473
|
+
var extensionObjects = /* @__PURE__ */ new Map();
|
|
474
|
+
function setExtensionObjects(objects) {
|
|
475
|
+
extensionObjects = objects;
|
|
476
|
+
}
|
|
477
|
+
function getObject(name) {
|
|
478
|
+
const extended = extensionObjects.get(name);
|
|
479
|
+
if (extended) return extended;
|
|
480
|
+
if (Object.hasOwn(CORE_OBJECTS, name)) {
|
|
481
|
+
return CORE_OBJECTS[name];
|
|
482
|
+
}
|
|
483
|
+
return Object.hasOwn(BASE_OBJECTS, name) ? BASE_OBJECTS[name] : void 0;
|
|
484
|
+
}
|
|
485
|
+
function listObjects() {
|
|
486
|
+
const core = Object.keys(CORE_OBJECTS).map((name) => getObject(name));
|
|
487
|
+
const ext = [...extensionObjects.values()].filter((object) => !Object.hasOwn(CORE_OBJECTS, object.name)).sort((a, b) => a.name.localeCompare(b.name));
|
|
488
|
+
return [...core, ...ext];
|
|
489
|
+
}
|
|
490
|
+
function isCoreObject(name) {
|
|
491
|
+
return Object.hasOwn(CORE_OBJECTS, name);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export {
|
|
495
|
+
activityObject,
|
|
496
|
+
organisationObject,
|
|
497
|
+
personObject,
|
|
498
|
+
taskObject,
|
|
499
|
+
CORE_OBJECTS,
|
|
500
|
+
setExtensionObjects,
|
|
501
|
+
getObject,
|
|
502
|
+
listObjects,
|
|
503
|
+
isCoreObject
|
|
504
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
addLocalDays,
|
|
4
|
+
localParts,
|
|
5
|
+
newId,
|
|
6
|
+
wallClockToIso
|
|
7
|
+
} from "./chunk-2XC5JLBO.js";
|
|
8
|
+
import {
|
|
9
|
+
CompiledQuery
|
|
10
|
+
} from "./chunk-6XTU2MTP.js";
|
|
11
|
+
|
|
12
|
+
// ../core/src/allowance/periods.ts
|
|
13
|
+
var TOTAL_PERIOD = {
|
|
14
|
+
key: "total",
|
|
15
|
+
per: "total",
|
|
16
|
+
startsAt: "0000-01-01T00:00:00.000Z",
|
|
17
|
+
endsAt: "9999-12-31T23:59:59.999Z"
|
|
18
|
+
};
|
|
19
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
20
|
+
function periodOf(at, per, zone) {
|
|
21
|
+
if (per === "total") return { ...TOTAL_PERIOD };
|
|
22
|
+
const local = localParts(at, zone);
|
|
23
|
+
if (per === "week") {
|
|
24
|
+
const monday = addLocalDays(local, 1 - local.weekday);
|
|
25
|
+
return {
|
|
26
|
+
key: `week:${monday.year}-${pad(monday.month)}-${pad(monday.day)}`,
|
|
27
|
+
per,
|
|
28
|
+
startsAt: wallClockToIso(monday, zone),
|
|
29
|
+
endsAt: wallClockToIso(addLocalDays(monday, 7), zone)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const first = { year: local.year, month: local.month, day: 1 };
|
|
33
|
+
const next = local.month === 12 ? { year: local.year + 1, month: 1, day: 1 } : { year: local.year, month: local.month + 1, day: 1 };
|
|
34
|
+
return {
|
|
35
|
+
key: `month:${local.year}-${pad(local.month)}`,
|
|
36
|
+
per,
|
|
37
|
+
startsAt: wallClockToIso(first, zone),
|
|
38
|
+
endsAt: wallClockToIso(next, zone)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function boundOf(value, kind, fieldType, zone) {
|
|
42
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
43
|
+
const text = String(value);
|
|
44
|
+
const date = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
|
|
45
|
+
if (date || fieldType === "date") {
|
|
46
|
+
const [y, m, d] = date ? [Number(date[1]), Number(date[2]), Number(date[3])] : (() => {
|
|
47
|
+
const p = localParts(text, zone);
|
|
48
|
+
return [p.year, p.month, p.day];
|
|
49
|
+
})();
|
|
50
|
+
const day = { year: y, month: m, day: d };
|
|
51
|
+
return wallClockToIso(kind === "until" ? addLocalDays(day, 1) : day, zone);
|
|
52
|
+
}
|
|
53
|
+
const at = new Date(text);
|
|
54
|
+
return Number.isNaN(at.getTime()) ? null : at.toISOString();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ../core/src/allowance/index.ts
|
|
58
|
+
var q = (value) => `'${value.replaceAll("'", "''")}'`;
|
|
59
|
+
function termsSyncStatements(storage, target, orgZone, now) {
|
|
60
|
+
const t = (column) => `t.${column}`;
|
|
61
|
+
const uses = `CASE WHEN typeof(${t(storage.uses)}) IN ('integer', 'real') AND ${t(storage.uses)} >= 0 AND ${t(storage.uses)} = CAST(${t(storage.uses)} AS INTEGER) THEN CAST(${t(storage.uses)} AS INTEGER) WHEN ${t(storage.uses)} IS NULL OR ${t(storage.uses)} = '' THEN ${storage.emptyIsUnlimited ? "NULL" : "0"} ELSE 0 END`;
|
|
62
|
+
const per = "fixed" in storage.per ? q(storage.per.fixed) : `CASE WHEN ${t(storage.per.column)} IN ('total', 'week', 'month') THEN ${t(storage.per.column)} ELSE 'total' END`;
|
|
63
|
+
const stored = `(SELECT s.zone FROM core_allowance s WHERE s.object_type = ${q(storage.object)} AND s.record_id = t.id)`;
|
|
64
|
+
const zone = storage.zone ? `coalesce(nullif(${t(storage.zone)}, ''), ${stored}, ?)` : `coalesce(${stored}, ?)`;
|
|
65
|
+
const instant = (bound) => bound && !bound.date ? `CASE WHEN ${t(bound.column)} IS NULL OR ${t(bound.column)} = '' THEN NULL ELSE strftime('%Y-%m-%dT%H:%M:%fZ', ${t(bound.column)}) END` : "NULL";
|
|
66
|
+
const day = (bound) => bound?.date ? `nullif(substr(${t(bound.column)}, 1, 10), '')` : "NULL";
|
|
67
|
+
const live = storage.live ? `CASE WHEN ${t(storage.live.column)} IN (${storage.live.states.map(q).join(", ") || "NULL"}) THEN 1 ELSE 0 END` : "1";
|
|
68
|
+
const person = `CASE WHEN typeof(${t(storage.person)}) = 'text' AND ${t(storage.person)} <> '' THEN ${t(storage.person)} END`;
|
|
69
|
+
const where = target === "all" ? "true" : "t.id = ?";
|
|
70
|
+
return [
|
|
71
|
+
CompiledQuery.raw(
|
|
72
|
+
`INSERT INTO core_allowance (object_type, record_id, person_id, uses, per, zone, valid_from, valid_until, from_date, until_date, live, trashed, updated_at) SELECT ${q(storage.object)}, t.id, ${person}, ${uses}, ${per}, ${zone}, ${instant(storage.from)}, ${instant(storage.until)}, ${day(storage.from)}, ${day(storage.until)}, ${live}, CASE WHEN t.deleted_at IS NULL THEN 0 ELSE 1 END, ? FROM ${storage.table} t WHERE ${where} ON CONFLICT (object_type, record_id) DO UPDATE SET person_id = excluded.person_id, uses = excluded.uses, per = excluded.per, zone = excluded.zone, valid_from = excluded.valid_from, valid_until = excluded.valid_until, from_date = excluded.from_date, until_date = excluded.until_date, live = excluded.live, trashed = excluded.trashed, updated_at = excluded.updated_at`,
|
|
73
|
+
[orgZone, now, ...target === "all" ? [] : [target.id]]
|
|
74
|
+
),
|
|
75
|
+
CompiledQuery.raw(
|
|
76
|
+
`UPDATE core_allowance_period SET uses = (SELECT a.uses FROM core_allowance a WHERE a.object_type = core_allowance_period.object_type AND a.record_id = core_allowance_period.record_id), updated_at = ? WHERE object_type = ? AND ends_at > ?${target === "all" ? "" : " AND record_id = ?"}`,
|
|
77
|
+
[now, storage.object, now, ...target === "all" ? [] : [target.id]]
|
|
78
|
+
)
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
function keyingChangeStatement(holder, previous, appliesFrom, now) {
|
|
82
|
+
return CompiledQuery.raw(
|
|
83
|
+
"UPDATE core_allowance SET prev_per = ?, prev_zone = ?, applies_from = ?, updated_at = ? WHERE object_type = ? AND record_id = ?",
|
|
84
|
+
[previous.per, previous.zone, appliesFrom, now, holder.object, holder.id]
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
function periodInsert(holder, period, zone, now) {
|
|
88
|
+
return CompiledQuery.raw(
|
|
89
|
+
"INSERT INTO core_allowance_period (object_type, record_id, period, per, zone, starts_at, ends_at, uses, used, updated_at) SELECT a.object_type, a.record_id, ?, ?, ?, ?, ?, a.uses, 0, ? FROM core_allowance a WHERE a.object_type = ? AND a.record_id = ? ON CONFLICT (object_type, record_id, period, zone) DO NOTHING",
|
|
90
|
+
[period.key, period.per, zone, period.startsAt, period.endsAt, now, holder.object, holder.id]
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function spendStatements(request, now) {
|
|
94
|
+
const id = request.id ?? newId("allowanceUse");
|
|
95
|
+
const { holder, period, zone } = request;
|
|
96
|
+
return {
|
|
97
|
+
id,
|
|
98
|
+
statements: [
|
|
99
|
+
periodInsert(holder, period, zone, now),
|
|
100
|
+
CompiledQuery.raw(
|
|
101
|
+
"UPDATE core_allowance_period SET used = used + 1, updated_at = ? WHERE object_type = ? AND record_id = ? AND period = ? AND zone = ?",
|
|
102
|
+
[now, holder.object, holder.id, period.key, zone]
|
|
103
|
+
),
|
|
104
|
+
CompiledQuery.raw(
|
|
105
|
+
"INSERT INTO core_allowance_use (id, object_type, record_id, period, zone, spender_type, spender_id, person_id, at, at_date, spent_at, spent_by, moved_from) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
106
|
+
[
|
|
107
|
+
id,
|
|
108
|
+
holder.object,
|
|
109
|
+
holder.id,
|
|
110
|
+
period.key,
|
|
111
|
+
zone,
|
|
112
|
+
request.spender.object,
|
|
113
|
+
request.spender.id,
|
|
114
|
+
request.personId,
|
|
115
|
+
request.at,
|
|
116
|
+
request.atDate,
|
|
117
|
+
now,
|
|
118
|
+
request.by,
|
|
119
|
+
request.movedFrom ?? null
|
|
120
|
+
]
|
|
121
|
+
)
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function returnStatements(spender, by, now) {
|
|
126
|
+
return [
|
|
127
|
+
CompiledQuery.raw(
|
|
128
|
+
"UPDATE core_allowance_period SET used = used - 1, updated_at = ? WHERE (object_type, record_id, period, zone) IN (SELECT object_type, record_id, period, zone FROM core_allowance_use WHERE spender_type = ? AND spender_id = ? AND returned_at IS NULL)",
|
|
129
|
+
[now, spender.object, spender.id]
|
|
130
|
+
),
|
|
131
|
+
CompiledQuery.raw(
|
|
132
|
+
"UPDATE core_allowance_use SET returned_at = ?, returned_by = ? WHERE spender_type = ? AND spender_id = ? AND returned_at IS NULL",
|
|
133
|
+
[now, by, spender.object, spender.id]
|
|
134
|
+
)
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
function rekeyStatements(use, to, now) {
|
|
138
|
+
const { holder } = use;
|
|
139
|
+
return [
|
|
140
|
+
periodInsert(holder, to.period, to.zone, now),
|
|
141
|
+
CompiledQuery.raw(
|
|
142
|
+
"UPDATE core_allowance_period SET used = used - 1, updated_at = ? WHERE object_type = ? AND record_id = ? AND period = ? AND zone = ?",
|
|
143
|
+
[now, holder.object, holder.id, use.period, use.zone]
|
|
144
|
+
),
|
|
145
|
+
CompiledQuery.raw(
|
|
146
|
+
"UPDATE core_allowance_period SET used = used + 1, rekeyed = rekeyed + 1, updated_at = ? WHERE object_type = ? AND record_id = ? AND period = ? AND zone = ?",
|
|
147
|
+
[now, holder.object, holder.id, to.period.key, to.zone]
|
|
148
|
+
),
|
|
149
|
+
CompiledQuery.raw("UPDATE core_allowance_use SET period = ?, zone = ? WHERE id = ?", [
|
|
150
|
+
to.period.key,
|
|
151
|
+
to.zone,
|
|
152
|
+
use.id
|
|
153
|
+
])
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
function dropAllowanceStatements(object, kind, now) {
|
|
157
|
+
if (kind === "holder") {
|
|
158
|
+
return [
|
|
159
|
+
CompiledQuery.raw("DELETE FROM core_allowance_use WHERE object_type = ?", [object]),
|
|
160
|
+
CompiledQuery.raw("DELETE FROM core_allowance_period WHERE object_type = ?", [object]),
|
|
161
|
+
CompiledQuery.raw("DELETE FROM core_allowance WHERE object_type = ?", [object])
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
return [
|
|
165
|
+
CompiledQuery.raw(
|
|
166
|
+
"UPDATE core_allowance_period SET used = used - (SELECT count(*) FROM core_allowance_use u WHERE u.spender_type = ? AND u.returned_at IS NULL AND u.object_type = core_allowance_period.object_type AND u.record_id = core_allowance_period.record_id AND u.period = core_allowance_period.period AND u.zone = core_allowance_period.zone), updated_at = ? WHERE (object_type, record_id, period, zone) IN (SELECT object_type, record_id, period, zone FROM core_allowance_use WHERE spender_type = ? AND returned_at IS NULL)",
|
|
167
|
+
[object, now, object]
|
|
168
|
+
),
|
|
169
|
+
CompiledQuery.raw("DELETE FROM core_allowance_use WHERE spender_type = ?", [object])
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
periodOf,
|
|
175
|
+
boundOf,
|
|
176
|
+
termsSyncStatements,
|
|
177
|
+
keyingChangeStatement,
|
|
178
|
+
spendStatements,
|
|
179
|
+
returnStatements,
|
|
180
|
+
rekeyStatements,
|
|
181
|
+
dropAllowanceStatements
|
|
182
|
+
};
|