@ai-matrx/records 0.8.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +163 -0
- package/dist/core/index.cjs +524 -13
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +280 -5
- package/dist/core/index.d.ts +280 -5
- package/dist/core/index.js +524 -13
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +116 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +845 -10
- package/dist/index.d.ts +845 -10
- package/dist/index.js +116 -8
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +592 -10
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1138 -12
- package/dist/react/index.d.ts +1138 -12
- package/dist/react/index.js +592 -10
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.js
CHANGED
|
@@ -81,11 +81,59 @@ function highestLevel(left, right) {
|
|
|
81
81
|
return ORDINAL[left] >= ORDINAL[right] ? left : right;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// src/choice.ts
|
|
85
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
86
|
+
function optionKey(option) {
|
|
87
|
+
const stored = option.metadata?.["option_key"];
|
|
88
|
+
if (typeof stored === "string" && stored.trim() !== "") return stored;
|
|
89
|
+
return choiceSlug(optionLabel(option));
|
|
90
|
+
}
|
|
91
|
+
function optionLabel(option) {
|
|
92
|
+
const doc = option.data;
|
|
93
|
+
const title = doc?.["title"] ?? doc?.["name"];
|
|
94
|
+
if (typeof title === "string" && title.trim() !== "") return title;
|
|
95
|
+
return "Unnamed choice";
|
|
96
|
+
}
|
|
97
|
+
function choiceSlug(word) {
|
|
98
|
+
const slug = word.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 55);
|
|
99
|
+
return slug === "" ? "choice" : slug;
|
|
100
|
+
}
|
|
101
|
+
function isTheChosen(option, value) {
|
|
102
|
+
if (typeof value !== "string") return false;
|
|
103
|
+
const asked = value.trim().toLowerCase();
|
|
104
|
+
if (asked === "") return false;
|
|
105
|
+
return asked === optionKey(option).toLowerCase() || asked === optionLabel(option).toLowerCase() || asked === option.id.toLowerCase();
|
|
106
|
+
}
|
|
107
|
+
function choiceValuesOf(value) {
|
|
108
|
+
if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
|
|
109
|
+
if (typeof value === "string" && value !== "") return [value];
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
function choicesOf(document, fieldKeyOrId) {
|
|
113
|
+
const block = document?.["_choices"];
|
|
114
|
+
if (!block || typeof block !== "object") return [];
|
|
115
|
+
const entry = block[fieldKeyOrId];
|
|
116
|
+
if (!entry) return [];
|
|
117
|
+
const list = Array.isArray(entry) ? entry : [entry];
|
|
118
|
+
return list.filter((x) => !!x && typeof x === "object" && typeof x.key === "string");
|
|
119
|
+
}
|
|
120
|
+
function holdsARetiredChoice(document, fieldKeyOrId) {
|
|
121
|
+
return choicesOf(document, fieldKeyOrId).some((c) => c.retired === true);
|
|
122
|
+
}
|
|
123
|
+
function looksLikeAnId(value) {
|
|
124
|
+
return typeof value === "string" && UUID.test(value);
|
|
125
|
+
}
|
|
126
|
+
|
|
84
127
|
// src/rule.ts
|
|
85
128
|
function publicFormPath(formId) {
|
|
86
129
|
return `/f/${formId}`;
|
|
87
130
|
}
|
|
88
131
|
|
|
132
|
+
// src/portal.ts
|
|
133
|
+
function portalPath(slug) {
|
|
134
|
+
return `/portal/c/${slug}`;
|
|
135
|
+
}
|
|
136
|
+
|
|
89
137
|
// src/aggregate.ts
|
|
90
138
|
function measureKey(measure) {
|
|
91
139
|
return measure.op === "count" ? "count" : `${measure.op}_${measure.key ?? ""}`;
|
|
@@ -200,6 +248,20 @@ var STORE_DOORS = [
|
|
|
200
248
|
{ name: "caller_role", args: "", returns: "name", security: "invoker" },
|
|
201
249
|
{ name: "carrying_edges_in", args: "p_organization_id uuid", returns: "TABLE(container_type text, container_id uuid, item_type text, item_id uuid, conveys_max permission_level)", security: "definer" },
|
|
202
250
|
{ name: "carrying_edges_of", args: "p_item_type text, p_item_id uuid", returns: "TABLE(container_type text, container_id uuid, conveys_max permission_level)", security: "definer" },
|
|
251
|
+
{ name: "choice_census", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
|
|
252
|
+
{ name: "choice_field_map", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "invoker" },
|
|
253
|
+
{ name: "choice_filter_normalize", args: "p_map jsonb, p_filter jsonb", returns: "jsonb", security: "invoker" },
|
|
254
|
+
{ name: "choice_key_for", args: "p_organization_id uuid, p_options_table_id uuid, p_title text, p_exclude uuid DEFAULT NULL::uuid", returns: "text", security: "invoker" },
|
|
255
|
+
{ name: "choice_key_of", args: "p_field jsonb, p_token text", returns: "text", security: "invoker" },
|
|
256
|
+
{ name: "choice_options", args: "p_organization_id uuid, p_options_table_id uuid", returns: "jsonb", security: "invoker" },
|
|
257
|
+
{ name: "choice_render", args: "p_organization_id uuid, p_table_id uuid, p_doc jsonb", returns: "jsonb", security: "invoker" },
|
|
258
|
+
{ name: "choice_render_groups", args: "p_map jsonb, p_groups jsonb", returns: "jsonb", security: "invoker" },
|
|
259
|
+
{ name: "choice_render_note", args: "p_field jsonb, p_value jsonb", returns: "jsonb", security: "invoker" },
|
|
260
|
+
{ name: "choice_render_value", args: "p_field jsonb, p_value jsonb", returns: "jsonb", security: "invoker" },
|
|
261
|
+
{ name: "choice_slug", args: "p_word text", returns: "text", security: "invoker" },
|
|
262
|
+
{ name: "choice_synonyms", args: "p_organization_id uuid, p_table_id uuid, p_token text", returns: "text[]", security: "invoker" },
|
|
263
|
+
{ name: "choice_synonyms_in", args: "p_map jsonb, p_token text", returns: "text[]", security: "invoker" },
|
|
264
|
+
{ name: "choice_words", args: "p_field jsonb", returns: "text", security: "invoker" },
|
|
203
265
|
{ name: "client_write_grants", args: "", returns: "TABLE(role_name text, object_name text, privilege text)", security: "invoker" },
|
|
204
266
|
{ name: "computed_provenance", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(field_key text, field_id uuid, value jsonb, rule_id uuid, rule_version integer, computed_at timestamp with time zone)", security: "invoker" },
|
|
205
267
|
{ name: "containment_chain", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(ancestor_id uuid, depth integer)", security: "invoker" },
|
|
@@ -208,6 +270,17 @@ var STORE_DOORS = [
|
|
|
208
270
|
{ name: "containment_parent", args: "p_data jsonb", returns: "uuid", security: "invoker" },
|
|
209
271
|
{ name: "cross_organization_links_open", args: "p_source_organization_id uuid, p_target_organization_id uuid", returns: "boolean", security: "invoker" },
|
|
210
272
|
{ name: "custom_fields_tables", args: "", returns: "TABLE(token text, schema_name text, table_name text)", security: "invoker" },
|
|
273
|
+
{ name: "dashboard_block_normalize", args: "p_organization_id uuid, p_subject_table_id uuid, p_block jsonb", returns: "jsonb", security: "definer" },
|
|
274
|
+
{ name: "dashboard_class", args: "", returns: "text", security: "invoker" },
|
|
275
|
+
{ name: "dashboard_declare", args: "p_organization_id uuid, p_table_id uuid, p_name text, p_blocks jsonb DEFAULT '[]'::jsonb, p_presentation jsonb DEFAULT '{}'::jsonb, p_dashboard_id uuid DEFAULT NULL::uuid", returns: "uuid", security: "definer" },
|
|
276
|
+
{ name: "dashboard_delete", args: "p_organization_id uuid, p_dashboard_id uuid", returns: "boolean", security: "definer" },
|
|
277
|
+
{ name: "dashboard_field_keys", args: "p_organization_id uuid, p_table_id uuid", returns: "text[]", security: "definer" },
|
|
278
|
+
{ name: "dashboard_kinds", args: "", returns: "text[]", security: "invoker" },
|
|
279
|
+
{ name: "dashboard_moment_sql", args: "p_key text", returns: "text", security: "invoker" },
|
|
280
|
+
{ name: "dashboard_run", args: "p_organization_id uuid, p_dashboard_id uuid, p_filter jsonb DEFAULT '{}'::jsonb", returns: "jsonb", security: "definer" },
|
|
281
|
+
{ name: "dashboard_stuck", args: "p_organization_id uuid, p_table_id uuid, p_state_key text, p_days integer DEFAULT 14, p_filter jsonb DEFAULT '{}'::jsonb, p_limit integer DEFAULT 50, p_required text DEFAULT 'viewer'::text", returns: "TABLE(record_id uuid, title text, state text, last_changed_at timestamp with time zone, days_unchanged numeric, measured_from text)", security: "definer" },
|
|
282
|
+
{ name: "dashboard_window_sql", args: "p_key text, p_window jsonb", returns: "text", security: "invoker" },
|
|
283
|
+
{ name: "dashboards", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid", returns: "TABLE(dashboard_id uuid, table_id uuid, name text, blocks jsonb, presentation jsonb, block_count integer, version integer, created_at timestamp with time zone, updated_at timestamp with time zone)", security: "definer" },
|
|
211
284
|
{ name: "delete_cascade_closure", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid[]", security: "invoker" },
|
|
212
285
|
{ name: "delete_preview", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "definer" },
|
|
213
286
|
{ name: "delete_rule", args: "p_organization_id uuid, p_record_id uuid, p_apply boolean DEFAULT true", returns: "jsonb", security: "definer" },
|
|
@@ -304,16 +377,20 @@ var STORE_DOORS = [
|
|
|
304
377
|
{ name: "io_restore", args: "p_organization_id uuid, p_record_id uuid, p_version integer", returns: "integer", security: "definer" },
|
|
305
378
|
{ name: "io_revisions", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(version integer, changed_at timestamp with time zone, changed_by uuid, summary text, operation text, changed_fields jsonb)", security: "definer" },
|
|
306
379
|
{ name: "is_a_retirement", args: "p_old_deleted timestamp with time zone, p_new_deleted timestamp with time zone, p_old_data jsonb, p_new_data jsonb, p_old_table uuid, p_new_table uuid, p_old_org uuid, p_new_org uuid, p_old_class text, p_new_class text", returns: "boolean", security: "invoker" },
|
|
380
|
+
{ name: "list_door_disagreements", args: "p_pretend text DEFAULT NULL::text, p_only_organization uuid DEFAULT NULL::uuid, p_sample integer DEFAULT 200", returns: "TABLE(organization_id uuid, organization_name text, member_id uuid, table_id uuid, record_id uuid, door text, why text)", security: "invoker" },
|
|
381
|
+
{ name: "list_door_disagreements", args: "p_pretend text, p_only_organization uuid, p_sample integer, p_exhaustive boolean", returns: "TABLE(organization_id uuid, organization_name text, member_id uuid, table_id uuid, record_id uuid, door text, why text)", security: "invoker" },
|
|
307
382
|
{ name: "lookup_value", args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb", returns: "jsonb", security: "invoker" },
|
|
308
383
|
{ name: "mask_document", args: "p_document jsonb, p_visible_keys text[], p_notices jsonb, p_by_id boolean DEFAULT false, p_key_ids jsonb DEFAULT '{}'::jsonb", returns: "jsonb", security: "invoker" },
|
|
309
384
|
{ name: "mask_document", args: "p_document jsonb, p_visible_keys text[], p_notices jsonb, p_by_id boolean DEFAULT false, p_key_ids jsonb DEFAULT '{}'::jsonb, p_declared_keys text[] DEFAULT NULL::text[]", returns: "jsonb", security: "invoker" },
|
|
310
385
|
{ name: "merge_field_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
386
|
+
{ name: "migrate_choice_keys", args: "p_organization_id uuid, p_table_id uuid, p_dry_run boolean DEFAULT false", returns: "jsonb", security: "definer" },
|
|
311
387
|
{ name: "migrate_delete", args: "p_organization_id uuid, p_record_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
312
388
|
{ name: "migrate_demote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
313
389
|
{ name: "migrate_extract_parent", args: "p_organization_id uuid, p_id uuid, p_parent_table_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
314
390
|
{ name: "migrate_merge", args: "p_organization_id uuid, p_winner_id uuid, p_loser_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
315
391
|
{ name: "migrate_promote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
316
392
|
{ name: "migrate_purge", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true", returns: "jsonb", security: "definer" },
|
|
393
|
+
{ name: "migrate_reclass", args: "p_organization_id uuid, p_id uuid, p_to text DEFAULT 'field'::text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
317
394
|
{ name: "migrate_rename", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
318
395
|
{ name: "migrate_reparent", args: "p_organization_id uuid, p_id uuid, p_parent_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
319
396
|
{ name: "migrate_retype", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
@@ -333,6 +410,20 @@ var STORE_DOORS = [
|
|
|
333
410
|
{ name: "parity_values", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(field_key text, field_id uuid, parity_type text, behavior text, unit text, format text, value jsonb, value_version integer, actor text, written_at timestamp with time zone)", security: "invoker" },
|
|
334
411
|
{ name: "per_value_access_words", args: "", returns: "text[]", security: "invoker" },
|
|
335
412
|
{ name: "person_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
413
|
+
{ name: "portal_admits", args: "p_organization_id uuid, p_user_id uuid DEFAULT NULL::uuid", returns: "boolean", security: "definer" },
|
|
414
|
+
{ name: "portal_card", args: "p_organization_id uuid, p_portal_id uuid", returns: "jsonb", security: "definer" },
|
|
415
|
+
{ name: "portal_declare", args: "p_organization_id uuid, p_title text, p_client_table_id uuid, p_tables jsonb, p_portal_id uuid DEFAULT NULL::uuid, p_slug text DEFAULT NULL::text, p_sign_in_method text DEFAULT 'magic_link'::text", returns: "uuid", security: "definer" },
|
|
416
|
+
{ name: "portal_field_map", args: "p_organization_id uuid, p_table_id uuid", returns: "TABLE(field_id uuid, field_key text, field_type text, points_at uuid)", security: "definer" },
|
|
417
|
+
{ name: "portal_invitation", args: "p_slug text, p_email text", returns: "jsonb", security: "definer" },
|
|
418
|
+
{ name: "portal_invite", args: "p_organization_id uuid, p_portal_id uuid, p_client_record_id uuid, p_email text, p_user_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
|
|
419
|
+
{ name: "portal_me", args: "", returns: "jsonb", security: "definer" },
|
|
420
|
+
{ name: "portal_preview", args: "p_organization_id uuid, p_portal_id uuid, p_principal_id uuid, p_table_id uuid", returns: "TABLE(record_id uuid, title text)", security: "definer" },
|
|
421
|
+
{ name: "portal_principal_bind", args: "p_organization_id uuid, p_principal_id uuid, p_user_id uuid", returns: "jsonb", security: "definer" },
|
|
422
|
+
{ name: "portal_public", args: "p_slug text", returns: "jsonb", security: "definer" },
|
|
423
|
+
{ name: "portal_record_title", args: "p_organization_id uuid, p_record_id uuid", returns: "text", security: "definer" },
|
|
424
|
+
{ name: "portal_revoke", args: "p_organization_id uuid, p_portal_id uuid, p_principal_id uuid", returns: "jsonb", security: "definer" },
|
|
425
|
+
{ name: "portal_slug", args: "p_organization_id uuid, p_title text, p_portal_id uuid DEFAULT NULL::uuid", returns: "text", security: "definer" },
|
|
426
|
+
{ name: "portals", args: "p_organization_id uuid", returns: "TABLE(portal_id uuid, title text, slug text, client_table_id uuid, client_table text, is_active boolean, tables integer, invited integer, signed_in integer, sign_in_method text, opened_at timestamp with time zone)", security: "definer" },
|
|
336
427
|
{ name: "presentation_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
337
428
|
{ name: "promote_field", args: "p_organization_id uuid, p_table_id uuid, p_field_id uuid", returns: "jsonb", security: "invoker" },
|
|
338
429
|
{ name: "promote_table", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
|
|
@@ -383,10 +474,12 @@ var STORE_DOORS = [
|
|
|
383
474
|
{ name: "record_resolve", args: "p_organization_id uuid, p_id uuid", returns: "jsonb", security: "definer" },
|
|
384
475
|
{ name: "record_restore", args: "p_organization_id uuid, p_record_id uuid", returns: "void", security: "definer" },
|
|
385
476
|
{ name: "record_state_as_of", args: "p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(state jsonb, replayed boolean)", security: "definer" },
|
|
477
|
+
{ name: "record_table", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid", security: "definer" },
|
|
386
478
|
{ name: "record_update", args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb, p_expected_version integer DEFAULT NULL::integer", returns: "integer", security: "definer" },
|
|
387
479
|
{ name: "record_values", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
|
|
388
480
|
{ name: "record_values_versioned", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(field_key text, field_id uuid, value jsonb, value_version integer, source jsonb, absent_reason text, actor text, on_behalf_of text, written_at timestamp with time zone, alternates jsonb)", security: "definer" },
|
|
389
481
|
{ name: "record_write", args: "p_organization_id uuid, p_table_id uuid, p_data jsonb", returns: "uuid", security: "definer" },
|
|
482
|
+
{ name: "refusals_claiming_a_level_never_asked", args: "", returns: "TABLE(function_name text, identity_args text, why text)", security: "invoker" },
|
|
390
483
|
{ name: "relation_carry", args: "p_organization_id uuid, p_container_id uuid, p_item_id uuid", returns: "uuid", security: "definer" },
|
|
391
484
|
{ name: "relation_edges_withdraw", args: "p_organization_id uuid, p_field_ids uuid[], p_why text", returns: "integer", security: "definer" },
|
|
392
485
|
{ name: "relation_own", args: "p_organization_id uuid, p_owner_id uuid, p_target_id uuid", returns: "uuid", security: "definer" },
|
|
@@ -432,7 +525,10 @@ var STORE_DOORS = [
|
|
|
432
525
|
{ name: "stamp_value_envelopes", args: "p_data jsonb, p_actor text, p_on_behalf_of text, p_at timestamp with time zone", returns: "jsonb", security: "invoker" },
|
|
433
526
|
{ name: "storage_modes", args: "", returns: "text[]", security: "invoker" },
|
|
434
527
|
{ name: "store_is_open", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "boolean", security: "invoker" },
|
|
528
|
+
{ name: "subscription_mute", args: "p_organization_id uuid, p_rule_id uuid, p_muted boolean DEFAULT true", returns: "boolean", security: "definer" },
|
|
529
|
+
{ name: "subscriptions", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid", returns: "TABLE(rule_id uuid, name text, table_id uuid, saved_view_id uuid, cadence text, schedule text, channel text, recipient_user_id uuid, event_key text, muted boolean, mine boolean, i_may_mute boolean)", security: "definer" },
|
|
435
530
|
{ name: "table_capacity", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
|
|
531
|
+
{ name: "table_carries_its_rows", args: "p_user_id uuid, p_table_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "boolean", security: "definer" },
|
|
436
532
|
{ name: "table_contents", args: "p_organization_id uuid, p_table_id uuid", returns: "TABLE(record_id uuid, kind text, goes_at integer)", security: "invoker" },
|
|
437
533
|
{ name: "table_declare", args: "p_organization_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
|
|
438
534
|
{ name: "table_has_a_visible_record", args: "p_user uuid, p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "definer" },
|
|
@@ -466,6 +562,7 @@ var STORE_DOORS = [
|
|
|
466
562
|
{ name: "widget_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
467
563
|
{ name: "work_approval_approvers", args: "p_organization_id uuid, p_subject_id uuid, p_approver_id uuid DEFAULT NULL::uuid", returns: "TABLE(user_id uuid, name text, why text)", security: "definer" },
|
|
468
564
|
{ name: "work_approval_decide", args: "p_organization_id uuid, p_approval_id uuid, p_approve boolean, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
565
|
+
{ name: "work_approval_kinds", args: "", returns: "text[]", security: "invoker" },
|
|
469
566
|
{ name: "work_approval_may_decide", args: "p_organization_id uuid, p_approval_id uuid", returns: "boolean", security: "definer" },
|
|
470
567
|
{ name: "work_approval_read", args: "p_organization_id uuid, p_approval_id uuid", returns: "jsonb", security: "definer" },
|
|
471
568
|
{ name: "work_approval_request", args: "p_organization_id uuid, p_subject_id uuid, p_change jsonb, p_note text DEFAULT NULL::text, p_approver_id uuid DEFAULT NULL::uuid, p_origin text DEFAULT 'person'::text, p_conversation_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
|
|
@@ -485,6 +582,7 @@ var STORE_DOORS = [
|
|
|
485
582
|
{ name: "work_slot_index_name", args: "p_table_id uuid", returns: "text", security: "invoker" },
|
|
486
583
|
{ name: "work_slot_release", args: "p_organization_id uuid, p_hold_id uuid", returns: "boolean", security: "definer" },
|
|
487
584
|
{ name: "work_slots_declare", args: "p_organization_id uuid, p_name text, p_slug text, p_home_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
|
|
585
|
+
{ name: "work_state_id", args: "p_organization_id uuid, p_table_id uuid, p_value text", returns: "uuid", security: "invoker" },
|
|
488
586
|
{ name: "work_states", args: "", returns: "TABLE(sort integer, name text, terminal boolean, next text[])", security: "invoker" },
|
|
489
587
|
{ name: "work_take_assignment", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
|
|
490
588
|
{ name: "work_template_declare", args: "p_organization_id uuid, p_name text, p_graph jsonb", returns: "uuid", security: "definer" },
|
|
@@ -533,17 +631,18 @@ var STORE_KNOBS = [
|
|
|
533
631
|
{ key: "world_publish_enabled", value: "false", type: "boolean" }
|
|
534
632
|
];
|
|
535
633
|
var STORE_REFUSAL_CODES = [
|
|
536
|
-
{ code: "02000", raised_by: "doc_render_body,doc_render_document,doc_render_read,doc_sign,doc_signature_intact,doc_signature_read,doc_template_read,doc_template_save,entity_field_retire,entity_field_update,entity_record_read,entity_value_write,external_history_event,external_rows,external_stub_upsert,external_writes_set,migrate_delete,migrate_extract_parent,migrate_merge,migrate_rename,migrate_reparent,migrate_retype,migrate_split,migrate_undo,organization_clear,read_record,record_delete,record_restore,record_update,relation_uncarry,share_access,share_grant,share_lane_set,share_people,share_revoke,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_assign,work_record_states,work_set_state" },
|
|
537
|
-
{ code: "0A000", raised_by: "external_rows,external_source_declare,external_write_through,promote_field,promoted_index_expr,promoted_query_sql,promoted_read,rule_eval,work_assign
|
|
538
|
-
{ code: "22004", raised_by: "_entity_custom_fields_guard,_value_envelope,actor_word,agg_assert_key,agg_sql,anon_capture,anon_token_issue,anon_write,assert_client_may_reach,doc_render_write,doc_sign,doc_signature_write,doc_template_save,external_history_event,external_rows,external_source_declare,external_stub_upsert,external_write_through,external_writes_set,form_declare,form_submit,home_add,io_comment_write,io_import_open,io_outbox_drain,io_restore,migrate_purge,migrate_split,migrate_undo,organization_clear,organization_contents,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,relation_carry,relation_own,rule_declare,share_grant,table_declare,work_approval_decide,work_approval_request,work_template_declare" },
|
|
634
|
+
{ code: "02000", raised_by: "dashboard_delete,dashboard_run,doc_render_body,doc_render_document,doc_render_read,doc_sign,doc_signature_intact,doc_signature_read,doc_template_read,doc_template_save,entity_field_retire,entity_field_update,entity_record_read,entity_value_write,external_history_event,external_rows,external_stub_upsert,external_writes_set,migrate_delete,migrate_extract_parent,migrate_merge,migrate_reclass,migrate_rename,migrate_reparent,migrate_retype,migrate_split,migrate_undo,organization_clear,portal_card,portal_declare,portal_invite,portal_preview,portal_principal_bind,portal_revoke,read_record,record_delete,record_restore,record_table,record_update,relation_uncarry,share_access,share_grant,share_lane_set,share_people,share_revoke,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_assign,work_record_states,work_set_state" },
|
|
635
|
+
{ code: "0A000", raised_by: "external_rows,external_source_declare,external_write_through,promote_field,promoted_index_expr,promoted_query_sql,promoted_read,rule_eval,work_assign" },
|
|
636
|
+
{ code: "22004", raised_by: "_entity_custom_fields_guard,_value_envelope,actor_word,agg_assert_key,agg_sql,anon_capture,anon_token_issue,anon_write,assert_client_may_reach,dashboard_block_normalize,dashboard_declare,dashboard_window_sql,doc_render_write,doc_sign,doc_signature_write,doc_template_save,external_history_event,external_rows,external_source_declare,external_stub_upsert,external_write_through,external_writes_set,form_declare,form_submit,home_add,io_comment_write,io_import_open,io_outbox_drain,io_restore,migrate_choice_keys,migrate_purge,migrate_reclass,migrate_split,migrate_undo,organization_clear,organization_contents,portal_declare,portal_invite,portal_principal_bind,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,relation_carry,relation_own,rule_declare,share_grant,table_declare,work_approval_decide,work_approval_request,work_template_declare" },
|
|
637
|
+
{ code: "22007", raised_by: "dashboard_window_sql" },
|
|
539
638
|
{ code: "22012", raised_by: "rule_eval" },
|
|
540
|
-
{ code: "22023", raised_by: "_entity_custom_fields_guard,_value_envelope,_work_shape_guard,actor_word,agg_assert_key,agg_sql,anon_token_issue,containment_parent,doc_render_body,doc_render_write,doc_signature_write,entity_value_write,external_history_event,external_source_declare,external_stub_upsert,external_write_through,io_import_open,io_proposal_accept,migrate_merge,my_levels,organization_clear,query_by_coordinates,query_rollup,record_update,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,table_rules,visibility_as_of,work_approval_request,work_list,work_slot_hold" },
|
|
541
|
-
{ code: "23503", raised_by: "_containment_guard,_field_document_for,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,delete_rule,doc_sign,doc_template_save,form_declare,form_submit,home_add,io_comment_write,io_import_rows,io_proposal_accept,migrate_demote,migrate_promote,promote_field,promote_table,record_applicability,record_reparent,relation_carry,relation_own,resolve_first_match,rule_applies,rule_declare,rule_eval,rule_members,rule_run,work_set_state,work_take_assignment,work_template_instantiate" },
|
|
639
|
+
{ code: "22023", raised_by: "_entity_custom_fields_guard,_value_envelope,_work_shape_guard,actor_word,agg_assert_key,agg_sql,anon_token_issue,containment_parent,dashboard_block_normalize,dashboard_window_sql,doc_render_body,doc_render_write,doc_signature_write,entity_value_write,external_history_event,external_source_declare,external_stub_upsert,external_write_through,io_import_open,io_proposal_accept,migrate_merge,migrate_reclass,my_levels,organization_clear,portal_declare,query_by_coordinates,query_rollup,record_update,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,table_rules,visibility_as_of,work_approval_request,work_list,work_slot_hold" },
|
|
640
|
+
{ code: "23503", raised_by: "_containment_guard,_field_document_for,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,dashboard_declare,delete_rule,doc_sign,doc_template_save,form_declare,form_submit,home_add,io_comment_write,io_import_rows,io_proposal_accept,migrate_demote,migrate_promote,promote_field,promote_table,record_applicability,record_reparent,relation_carry,relation_own,resolve_first_match,rule_applies,rule_declare,rule_eval,rule_members,rule_run,subscription_mute,work_set_state,work_take_assignment,work_template_instantiate" },
|
|
542
641
|
{ code: "23505", raised_by: "_unique_rule_holds,doc_sign,doc_signature_write,entity_field_declare,field_declare,home_add,io_proposal_accept,relation_carry,relation_own,share_grant,work_approval_decide,work_slot_hold" },
|
|
543
|
-
{ code: "23514", raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_entity_custom_fields_guard,_field_document_for,_field_shape_guard,_field_type_parity_guard,_merge_field_shape_guard,_merge_field_temporal_guard,_promoted_field_cap_guard,_record_rule_uses,_resolve_choice_words,_rule_shape_guard,_rule_topology_guard,_store_relation_edge_names_its_field,_table_shape_guard,_value_envelope,_work_shape_guard,_workdoors_approval_guard,assert_entity_is_organization_scoped,doc_sign,doc_signature_write,doc_template_save,entity_field_declare,entity_field_retire,entity_field_update,entity_records_find,entity_table,field_declare,field_retire,field_update,home_add,migrate_merge,relation_carry,relation_own,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate" },
|
|
642
|
+
{ code: "23514", raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_entity_custom_fields_guard,_field_class_guard,_field_document_for,_field_shape_guard,_field_type_parity_guard,_merge_field_shape_guard,_merge_field_temporal_guard,_promoted_field_cap_guard,_record_rule_uses,_resolve_choice_words,_rule_shape_guard,_rule_topology_guard,_store_relation_edge_names_its_field,_table_shape_guard,_value_envelope,_work_shape_guard,_workdoors_approval_guard,assert_entity_is_organization_scoped,doc_sign,doc_signature_write,doc_template_save,entity_field_declare,entity_field_retire,entity_field_update,entity_records_find,entity_table,field_declare,field_retire,field_update,home_add,migrate_merge,relation_carry,relation_own,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate" },
|
|
544
643
|
{ code: "40001", raised_by: "has_visibility_at" },
|
|
545
|
-
{ code: "42501", raised_by: "_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_rule_definition_write,_store_door,anon_capture,anon_inbound_land,anon_publish,anon_token_issue,anon_token_verify,anon_write,assert_client_may_change,assert_client_may_open,assert_client_may_reach,assert_may_know_table,assert_organization_admin,assert_store_door,entity_field_declare,entity_field_retire,entity_field_update,entity_value_write,external_write_through,form_declare,form_submit,io_comment_resolve,io_comment_write,io_restore,migrate_purge,my_levels,organization_clear,promote_table,query_visibility_parity,read_record,read_records,share_grant,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person" },
|
|
546
|
-
{ code: "42703", raised_by: "entity_table" },
|
|
644
|
+
{ code: "42501", raised_by: "_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_rule_definition_write,_store_door,anon_capture,anon_inbound_land,anon_publish,anon_token_issue,anon_token_verify,anon_write,assert_client_may_change,assert_client_may_open,assert_client_may_reach,assert_may_know_table,assert_organization_admin,assert_store_door,entity_field_declare,entity_field_retire,entity_field_update,entity_value_write,external_write_through,form_declare,form_submit,io_comment_resolve,io_comment_write,io_restore,migrate_purge,migrate_reclass,my_levels,organization_clear,portal_declare,portal_invitation,portal_invite,portal_principal_bind,promote_table,query_visibility_parity,read_record,read_records,share_grant,subscription_mute,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person" },
|
|
645
|
+
{ code: "42703", raised_by: "entity_table,portal_declare" },
|
|
547
646
|
{ code: "53400", raised_by: "anon_rate_take,delete_cascade_closure,promote_field" },
|
|
548
647
|
{ code: "54001", raised_by: "record_delete" },
|
|
549
648
|
{ code: "PT409", raised_by: "record_update" }
|
|
@@ -1653,6 +1752,24 @@ var DOORS = {
|
|
|
1653
1752
|
fieldDeclare: "field_declare",
|
|
1654
1753
|
fieldUpdate: "field_update",
|
|
1655
1754
|
fieldRetire: "field_retire",
|
|
1755
|
+
// CUSTOM FIELDS ON A STANDARD BUSINESS TABLE. Every door above is keyed by a
|
|
1756
|
+
// custom Table's uuid, and a standard table has no Table record - so until
|
|
1757
|
+
// 2026-09-20 `custom.applicable_fields(org, 'party', null)` answered `22P02
|
|
1758
|
+
// invalid input syntax for uuid` and there was no other way in. These are
|
|
1759
|
+
// keyed by the REGISTRY TOKEN instead, and they are one set for all 643
|
|
1760
|
+
// tables the registry types Entity or Detail. The three value doors are
|
|
1761
|
+
// SECURITY INVOKER in the database on purpose: the standard table's own
|
|
1762
|
+
// row-level security is what decides who may read and write its rows, and a
|
|
1763
|
+
// definer wrapper would replace it with a second access system.
|
|
1764
|
+
entityTable: "entity_table",
|
|
1765
|
+
entityFields: "entity_fields",
|
|
1766
|
+
entityFieldDeclare: "entity_field_declare",
|
|
1767
|
+
entityFieldUpdate: "entity_field_update",
|
|
1768
|
+
entityFieldRetire: "entity_field_retire",
|
|
1769
|
+
entityFieldRights: "entity_field_rights",
|
|
1770
|
+
entityRecordRead: "entity_record_read",
|
|
1771
|
+
entityValueWrite: "entity_value_write",
|
|
1772
|
+
entityRecordsFind: "entity_records_find",
|
|
1656
1773
|
tableCapacity: "table_capacity",
|
|
1657
1774
|
tableStorage: "table_storage",
|
|
1658
1775
|
promoteTable: "promote_table",
|
|
@@ -1701,6 +1818,32 @@ var DOORS = {
|
|
|
1701
1818
|
// are server-lane doors and a browser never calls them.
|
|
1702
1819
|
forms: "forms",
|
|
1703
1820
|
formDeclare: "form_declare",
|
|
1821
|
+
// THE CLIENT PORTAL, OWNER'S SIDE (VIS-31 / PORTAL). A portal is how somebody
|
|
1822
|
+
// with NO membership is let in to see the records that name them. `portals`
|
|
1823
|
+
// lists them, `portalCard` opens one, `portalDeclare` states what it exposes,
|
|
1824
|
+
// `portalInvite` and `portalRevoke` are the two acts on a person, and
|
|
1825
|
+
// `portalPreview` is "view as this client" — it asks `custom.visible_set` for
|
|
1826
|
+
// HER user id, the same call `custom.read_records` makes when she opens the
|
|
1827
|
+
// page, so the preview cannot disagree with what she sees. The CLIENT-side
|
|
1828
|
+
// pair (`custom.portal_public`, `custom.portal_invitation`, `custom.portal_me`)
|
|
1829
|
+
// is deliberately absent here: those belong to the outsider's own shell.
|
|
1830
|
+
portals: "portals",
|
|
1831
|
+
portalCard: "portal_card",
|
|
1832
|
+
portalDeclare: "portal_declare",
|
|
1833
|
+
portalInvite: "portal_invite",
|
|
1834
|
+
portalRevoke: "portal_revoke",
|
|
1835
|
+
portalPreview: "portal_preview",
|
|
1836
|
+
// SCR-16 — the canvas. A dashboard is a record in the presentation kernel
|
|
1837
|
+
// whose blocks are saved SPECS for the eighth verb; `dashboardRun` walks them
|
|
1838
|
+
// under the CALLER'S principal, so nothing here is precomputed and nothing is
|
|
1839
|
+
// summed in a browser. `dashboardStuck` is the seventh block kind on its own,
|
|
1840
|
+
// because "what has not moved in fourteen days" is a question a screen asks
|
|
1841
|
+
// outside a canvas too.
|
|
1842
|
+
dashboards: "dashboards",
|
|
1843
|
+
dashboardDeclare: "dashboard_declare",
|
|
1844
|
+
dashboardRun: "dashboard_run",
|
|
1845
|
+
dashboardStuck: "dashboard_stuck",
|
|
1846
|
+
dashboardDelete: "dashboard_delete",
|
|
1704
1847
|
// The eighth verb (AGT-N-8): a grouped, bucketed, filtered count/sum/avg/
|
|
1705
1848
|
// min/max computed INSIDE the read door's own query, so a chart shows exactly
|
|
1706
1849
|
// the rows this person may see and never fetches the ones they may not.
|
|
@@ -1711,6 +1854,12 @@ var DOORS = {
|
|
|
1711
1854
|
// over a saved view. There is no subscription TABLE and no second notifier.
|
|
1712
1855
|
aggSubscriptions: "agg_subscriptions",
|
|
1713
1856
|
aggSubscriptionCadences: "agg_subscription_cadences",
|
|
1857
|
+
// The OWNER's side of DOOR-18. `agg_subscriptions` is the notifier's reader
|
|
1858
|
+
// and is not client-callable; these two are what a person reaches: what am I
|
|
1859
|
+
// being told about, and switch this one off. A form's notify Rule is one of
|
|
1860
|
+
// these rows, so "tell me when a patient arrives" can also be un-told.
|
|
1861
|
+
subscriptions: "subscriptions",
|
|
1862
|
+
subscriptionMute: "subscription_mute",
|
|
1714
1863
|
// The doc doors: a template is saved, a render is written once and frozen,
|
|
1715
1864
|
// and a signature is checked against the exact bytes that were signed.
|
|
1716
1865
|
docTemplateSave: "doc_template_save",
|
|
@@ -1759,6 +1908,23 @@ var DOORS = {
|
|
|
1759
1908
|
workSlotRelease: "work_slot_release",
|
|
1760
1909
|
workSlotHolds: "work_slot_holds",
|
|
1761
1910
|
workSlotExpire: "work_slot_expire",
|
|
1911
|
+
// THE WORK LAYER'S OWN DOORS (lane WORK-DOORS, 2026-09-20). Until this lane
|
|
1912
|
+
// all nineteen `custom.work_*` functions were SECURITY INVOKER with no client
|
|
1913
|
+
// grant: REC-69, REC-70 and REC-71 were live in the store and unreachable
|
|
1914
|
+
// from a browser. These are the verbs a person actually uses.
|
|
1915
|
+
workPerson: "work_person",
|
|
1916
|
+
workAssign: "work_assign",
|
|
1917
|
+
workRecordStates: "work_record_states",
|
|
1918
|
+
workSetState: "work_set_state",
|
|
1919
|
+
workList: "work_list",
|
|
1920
|
+
workTemplates: "work_templates",
|
|
1921
|
+
/** THE ONE QUEUE: assignments, approvals and the agent's proposals together. */
|
|
1922
|
+
workInbox: "work_inbox",
|
|
1923
|
+
workApprovalApprovers: "work_approval_approvers",
|
|
1924
|
+
workApprovalRequest: "work_approval_request",
|
|
1925
|
+
workApprovalMayDecide: "work_approval_may_decide",
|
|
1926
|
+
workApprovalDecide: "work_approval_decide",
|
|
1927
|
+
workApprovalRead: "work_approval_read",
|
|
1762
1928
|
// Declared here BECAUSE they do not exist yet: naming them is what makes the
|
|
1763
1929
|
// absence visible to `pnpm check:store-registry` and to the suite.
|
|
1764
1930
|
metadataSearch: "metadata_search",
|
|
@@ -1798,6 +1964,14 @@ var BY_SQLSTATE = {
|
|
|
1798
1964
|
// caught it raised by a door this package did not know about — which is the
|
|
1799
1965
|
// suite working, and is why the map is a census rather than a guess.
|
|
1800
1966
|
"42703": "invalid_argument",
|
|
1967
|
+
// 22007 — a date or a time the store could not read as one. It is raised by
|
|
1968
|
+
// `custom.dashboard_window_sql`, which is handed a window a caller wrote
|
|
1969
|
+
// ("last 30 days", a literal date), so the class is again "the call named
|
|
1970
|
+
// something the shape does not accept" and the store's own sentence names the
|
|
1971
|
+
// text it could not read. Added 2026-09-20 (lane SCREEN-BREAK) after the
|
|
1972
|
+
// live-door census caught it — the same way 42703 arrived, which is the
|
|
1973
|
+
// census working rather than a guess.
|
|
1974
|
+
"22007": "invalid_argument",
|
|
1801
1975
|
"02000": "not_found",
|
|
1802
1976
|
"23503": "missing_reference",
|
|
1803
1977
|
"23505": "already_exists",
|
|
@@ -2167,9 +2341,11 @@ function createRecordsClient(config) {
|
|
|
2167
2341
|
);
|
|
2168
2342
|
if (!applicable.ok) return err(applicable.error);
|
|
2169
2343
|
const rows = applicable.data ?? [];
|
|
2170
|
-
|
|
2171
|
-
|
|
2344
|
+
const fields = rows.map((row) => ({ id: row.id, ...row.data }));
|
|
2345
|
+
fields.sort(
|
|
2346
|
+
(a, b) => (a.sort ?? 0) - (b.sort ?? 0) || (a.label ?? "").localeCompare(b.label ?? "")
|
|
2172
2347
|
);
|
|
2348
|
+
return ok(fields);
|
|
2173
2349
|
},
|
|
2174
2350
|
async fieldOptions({ field_id }) {
|
|
2175
2351
|
return callDoor(
|
|
@@ -2192,6 +2368,88 @@ function createRecordsClient(config) {
|
|
|
2192
2368
|
"fieldDeclare"
|
|
2193
2369
|
);
|
|
2194
2370
|
},
|
|
2371
|
+
async entityTable({ token }) {
|
|
2372
|
+
const answer = await callDoor(
|
|
2373
|
+
DOORS.entityTable,
|
|
2374
|
+
{ p_token: token },
|
|
2375
|
+
"entityTable"
|
|
2376
|
+
);
|
|
2377
|
+
if (!answer.ok) return err(answer.error);
|
|
2378
|
+
const row = Array.isArray(answer.data) ? answer.data[0] : answer.data;
|
|
2379
|
+
if (!row) {
|
|
2380
|
+
return err({
|
|
2381
|
+
code: "not_found",
|
|
2382
|
+
message: `The registry answered nothing for the table "${token}".`,
|
|
2383
|
+
hint: "REC-33: a standard table is named by its registry token. Nothing was read."
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
return ok(row);
|
|
2387
|
+
},
|
|
2388
|
+
async entityFields({ token }) {
|
|
2389
|
+
const rows = await callDoor(
|
|
2390
|
+
DOORS.entityFields,
|
|
2391
|
+
{ p_organization_id: org, p_token: token },
|
|
2392
|
+
"entityFields"
|
|
2393
|
+
);
|
|
2394
|
+
if (!rows.ok) return err(rows.error);
|
|
2395
|
+
return ok((rows.data ?? []).map((row) => ({ id: row.id, ...row.data })));
|
|
2396
|
+
},
|
|
2397
|
+
async entityFieldDeclare({ token, spec }) {
|
|
2398
|
+
return callDoor(
|
|
2399
|
+
DOORS.entityFieldDeclare,
|
|
2400
|
+
{ p_organization_id: org, p_token: token, p_spec: spec },
|
|
2401
|
+
"entityFieldDeclare"
|
|
2402
|
+
);
|
|
2403
|
+
},
|
|
2404
|
+
async entityFieldUpdate({ field_id, patch }) {
|
|
2405
|
+
return callDoor(
|
|
2406
|
+
DOORS.entityFieldUpdate,
|
|
2407
|
+
{ p_organization_id: org, p_field_id: field_id, p_patch: patch },
|
|
2408
|
+
"entityFieldUpdate"
|
|
2409
|
+
);
|
|
2410
|
+
},
|
|
2411
|
+
async entityFieldRetire({ field_id }) {
|
|
2412
|
+
return callDoor(
|
|
2413
|
+
DOORS.entityFieldRetire,
|
|
2414
|
+
{ p_organization_id: org, p_field_id: field_id },
|
|
2415
|
+
"entityFieldRetire"
|
|
2416
|
+
);
|
|
2417
|
+
},
|
|
2418
|
+
async entityFieldRights({ token }) {
|
|
2419
|
+
return callDoor(
|
|
2420
|
+
DOORS.entityFieldRights,
|
|
2421
|
+
{ p_organization_id: org, p_token: token },
|
|
2422
|
+
"entityFieldRights"
|
|
2423
|
+
);
|
|
2424
|
+
},
|
|
2425
|
+
async entityRecordRead({ token, record_id }) {
|
|
2426
|
+
return callDoor(
|
|
2427
|
+
DOORS.entityRecordRead,
|
|
2428
|
+
{ p_organization_id: org, p_token: token, p_record_id: record_id },
|
|
2429
|
+
"entityRecordRead"
|
|
2430
|
+
);
|
|
2431
|
+
},
|
|
2432
|
+
async entityValueWrite({ token, record_id, patch }) {
|
|
2433
|
+
return callDoor(
|
|
2434
|
+
DOORS.entityValueWrite,
|
|
2435
|
+
{ p_organization_id: org, p_token: token, p_record_id: record_id, p_patch: patch },
|
|
2436
|
+
"entityValueWrite"
|
|
2437
|
+
);
|
|
2438
|
+
},
|
|
2439
|
+
async entityRecordsFind({ token, key, value, limit, offset }) {
|
|
2440
|
+
return callDoor(
|
|
2441
|
+
DOORS.entityRecordsFind,
|
|
2442
|
+
{
|
|
2443
|
+
p_organization_id: org,
|
|
2444
|
+
p_token: token,
|
|
2445
|
+
p_key: key,
|
|
2446
|
+
p_value: value === void 0 ? null : value,
|
|
2447
|
+
...limit === void 0 ? {} : { p_limit: limit },
|
|
2448
|
+
...offset === void 0 ? {} : { p_offset: offset }
|
|
2449
|
+
},
|
|
2450
|
+
"entityRecordsFind"
|
|
2451
|
+
);
|
|
2452
|
+
},
|
|
2195
2453
|
async fieldUpdate({ field_id, patch }) {
|
|
2196
2454
|
return callDoor(
|
|
2197
2455
|
DOORS.fieldUpdate,
|
|
@@ -2261,6 +2519,65 @@ function createRecordsClient(config) {
|
|
|
2261
2519
|
"formDeclare"
|
|
2262
2520
|
);
|
|
2263
2521
|
},
|
|
2522
|
+
async portals() {
|
|
2523
|
+
return callDoor(DOORS.portals, { p_organization_id: org }, "portals");
|
|
2524
|
+
},
|
|
2525
|
+
async portalCard({ portal_id }) {
|
|
2526
|
+
return callDoor(
|
|
2527
|
+
DOORS.portalCard,
|
|
2528
|
+
{ p_organization_id: org, p_portal_id: portal_id },
|
|
2529
|
+
"portalCard"
|
|
2530
|
+
);
|
|
2531
|
+
},
|
|
2532
|
+
async portalDeclare(args) {
|
|
2533
|
+
return callDoor(
|
|
2534
|
+
DOORS.portalDeclare,
|
|
2535
|
+
{
|
|
2536
|
+
p_organization_id: org,
|
|
2537
|
+
p_title: args.title,
|
|
2538
|
+
p_client_table_id: args.client_table_id,
|
|
2539
|
+
p_tables: args.tables,
|
|
2540
|
+
p_portal_id: args.portal_id ?? null,
|
|
2541
|
+
p_slug: args.slug ?? null,
|
|
2542
|
+
p_sign_in_method: args.sign_in_method ?? "magic_link"
|
|
2543
|
+
},
|
|
2544
|
+
"portalDeclare"
|
|
2545
|
+
);
|
|
2546
|
+
},
|
|
2547
|
+
async portalInvite(args) {
|
|
2548
|
+
return callDoor(
|
|
2549
|
+
DOORS.portalInvite,
|
|
2550
|
+
{
|
|
2551
|
+
p_organization_id: org,
|
|
2552
|
+
p_portal_id: args.portal_id,
|
|
2553
|
+
p_client_record_id: args.client_record_id,
|
|
2554
|
+
p_email: args.email,
|
|
2555
|
+
// ALWAYS null from a client. See the interface comment: an invitation
|
|
2556
|
+
// confers nothing until the person follows their own sign-in link.
|
|
2557
|
+
p_user_id: null
|
|
2558
|
+
},
|
|
2559
|
+
"portalInvite"
|
|
2560
|
+
);
|
|
2561
|
+
},
|
|
2562
|
+
async portalRevoke({ portal_id, principal_id }) {
|
|
2563
|
+
return callDoor(
|
|
2564
|
+
DOORS.portalRevoke,
|
|
2565
|
+
{ p_organization_id: org, p_portal_id: portal_id, p_principal_id: principal_id },
|
|
2566
|
+
"portalRevoke"
|
|
2567
|
+
);
|
|
2568
|
+
},
|
|
2569
|
+
async portalPreview({ portal_id, principal_id, table_id }) {
|
|
2570
|
+
return callDoor(
|
|
2571
|
+
DOORS.portalPreview,
|
|
2572
|
+
{
|
|
2573
|
+
p_organization_id: org,
|
|
2574
|
+
p_portal_id: portal_id,
|
|
2575
|
+
p_principal_id: principal_id,
|
|
2576
|
+
p_table_id: table_id
|
|
2577
|
+
},
|
|
2578
|
+
"portalPreview"
|
|
2579
|
+
);
|
|
2580
|
+
},
|
|
2264
2581
|
async ruleRun({ rule_id, values, context }) {
|
|
2265
2582
|
return callDoor(
|
|
2266
2583
|
DOORS.ruleRun,
|
|
@@ -2285,6 +2602,55 @@ function createRecordsClient(config) {
|
|
|
2285
2602
|
"ruleEval"
|
|
2286
2603
|
);
|
|
2287
2604
|
},
|
|
2605
|
+
async dashboards(args) {
|
|
2606
|
+
return callDoor(
|
|
2607
|
+
DOORS.dashboards,
|
|
2608
|
+
{ p_organization_id: org, p_table_id: args?.table_id ?? null },
|
|
2609
|
+
"dashboards"
|
|
2610
|
+
);
|
|
2611
|
+
},
|
|
2612
|
+
async dashboardDeclare(args) {
|
|
2613
|
+
return callDoor(
|
|
2614
|
+
DOORS.dashboardDeclare,
|
|
2615
|
+
{
|
|
2616
|
+
p_organization_id: org,
|
|
2617
|
+
p_table_id: args.table_id,
|
|
2618
|
+
p_name: args.name,
|
|
2619
|
+
p_blocks: args.blocks ?? [],
|
|
2620
|
+
p_presentation: args.presentation ?? {},
|
|
2621
|
+
p_dashboard_id: args.dashboard_id ?? null
|
|
2622
|
+
},
|
|
2623
|
+
"dashboardDeclare"
|
|
2624
|
+
);
|
|
2625
|
+
},
|
|
2626
|
+
async dashboardRun({ dashboard_id, filter }) {
|
|
2627
|
+
return callDoor(
|
|
2628
|
+
DOORS.dashboardRun,
|
|
2629
|
+
{ p_organization_id: org, p_dashboard_id: dashboard_id, p_filter: filter ?? {} },
|
|
2630
|
+
"dashboardRun"
|
|
2631
|
+
);
|
|
2632
|
+
},
|
|
2633
|
+
async dashboardStuck({ table_id, state_key, days, filter, limit }) {
|
|
2634
|
+
return callDoor(
|
|
2635
|
+
DOORS.dashboardStuck,
|
|
2636
|
+
{
|
|
2637
|
+
p_organization_id: org,
|
|
2638
|
+
p_table_id: table_id,
|
|
2639
|
+
p_state_key: state_key,
|
|
2640
|
+
p_days: days ?? 14,
|
|
2641
|
+
p_filter: filter ?? {},
|
|
2642
|
+
p_limit: limit ?? 50
|
|
2643
|
+
},
|
|
2644
|
+
"dashboardStuck"
|
|
2645
|
+
);
|
|
2646
|
+
},
|
|
2647
|
+
async dashboardDelete({ dashboard_id }) {
|
|
2648
|
+
return callDoor(
|
|
2649
|
+
DOORS.dashboardDelete,
|
|
2650
|
+
{ p_organization_id: org, p_dashboard_id: dashboard_id },
|
|
2651
|
+
"dashboardDelete"
|
|
2652
|
+
);
|
|
2653
|
+
},
|
|
2288
2654
|
async recordAggregate({ table_id, groupBy, measures, bucket, filter, limit }) {
|
|
2289
2655
|
return callDoor(
|
|
2290
2656
|
DOORS.recordAggregate,
|
|
@@ -2320,6 +2686,20 @@ function createRecordsClient(config) {
|
|
|
2320
2686
|
async aggSubscriptionCadences() {
|
|
2321
2687
|
return callDoor(DOORS.aggSubscriptionCadences, {}, "aggSubscriptionCadences");
|
|
2322
2688
|
},
|
|
2689
|
+
async subscriptions(args) {
|
|
2690
|
+
return callDoor(
|
|
2691
|
+
DOORS.subscriptions,
|
|
2692
|
+
{ p_organization_id: org, p_table_id: args?.table_id ?? null },
|
|
2693
|
+
"subscriptions"
|
|
2694
|
+
);
|
|
2695
|
+
},
|
|
2696
|
+
async subscriptionMute({ rule_id, muted }) {
|
|
2697
|
+
return callDoor(
|
|
2698
|
+
DOORS.subscriptionMute,
|
|
2699
|
+
{ p_organization_id: org, p_rule_id: rule_id, p_muted: muted },
|
|
2700
|
+
"subscriptionMute"
|
|
2701
|
+
);
|
|
2702
|
+
},
|
|
2323
2703
|
async docTemplateSave({ table_id, name, body, template_id }) {
|
|
2324
2704
|
return callDoor(
|
|
2325
2705
|
DOORS.docTemplateSave,
|
|
@@ -2609,6 +2989,128 @@ function createRecordsClient(config) {
|
|
|
2609
2989
|
"workSlotExpire"
|
|
2610
2990
|
);
|
|
2611
2991
|
},
|
|
2992
|
+
// ── the work layer a person actually uses ────────────────────────────
|
|
2993
|
+
async workInbox(args) {
|
|
2994
|
+
return callDoor(
|
|
2995
|
+
DOORS.workInbox,
|
|
2996
|
+
{
|
|
2997
|
+
p_organization_id: org,
|
|
2998
|
+
p_limit: args?.limit ?? 50,
|
|
2999
|
+
p_offset: args?.offset ?? 0,
|
|
3000
|
+
p_include_decided: args?.includeDecided ?? false
|
|
3001
|
+
},
|
|
3002
|
+
"workInbox"
|
|
3003
|
+
);
|
|
3004
|
+
},
|
|
3005
|
+
async workList(args) {
|
|
3006
|
+
return callDoor(
|
|
3007
|
+
DOORS.workList,
|
|
3008
|
+
{
|
|
3009
|
+
p_organization_id: org,
|
|
3010
|
+
p_flavour: args?.flavour ?? "mine",
|
|
3011
|
+
p_include_finished: args?.includeFinished ?? false,
|
|
3012
|
+
p_limit: args?.limit ?? 100,
|
|
3013
|
+
p_offset: args?.offset ?? 0
|
|
3014
|
+
},
|
|
3015
|
+
"workList"
|
|
3016
|
+
);
|
|
3017
|
+
},
|
|
3018
|
+
async workAssign({ record_id, user_id = null, dueDate = null, clearDue = false }) {
|
|
3019
|
+
return callDoor(
|
|
3020
|
+
DOORS.workAssign,
|
|
3021
|
+
{
|
|
3022
|
+
p_organization_id: org,
|
|
3023
|
+
p_record_id: record_id,
|
|
3024
|
+
p_assignee_user_id: user_id,
|
|
3025
|
+
p_due_date: dueDate,
|
|
3026
|
+
p_clear_due: clearDue
|
|
3027
|
+
},
|
|
3028
|
+
"workAssign"
|
|
3029
|
+
);
|
|
3030
|
+
},
|
|
3031
|
+
async workRecordStates({ record_id }) {
|
|
3032
|
+
return callDoor(
|
|
3033
|
+
DOORS.workRecordStates,
|
|
3034
|
+
{ p_organization_id: org, p_record_id: record_id },
|
|
3035
|
+
"workRecordStates"
|
|
3036
|
+
);
|
|
3037
|
+
},
|
|
3038
|
+
async workSetState({ record_id, state_id }) {
|
|
3039
|
+
return callDoor(
|
|
3040
|
+
DOORS.workSetState,
|
|
3041
|
+
{ p_organization_id: org, p_record_id: record_id, p_state_id: state_id },
|
|
3042
|
+
"workSetState"
|
|
3043
|
+
);
|
|
3044
|
+
},
|
|
3045
|
+
async workPerson({ user_id, create = true }) {
|
|
3046
|
+
return callDoor(
|
|
3047
|
+
DOORS.workPerson,
|
|
3048
|
+
{ p_organization_id: org, p_user_id: user_id, p_create: create },
|
|
3049
|
+
"workPerson"
|
|
3050
|
+
);
|
|
3051
|
+
},
|
|
3052
|
+
async workTemplates(args) {
|
|
3053
|
+
return callDoor(
|
|
3054
|
+
DOORS.workTemplates,
|
|
3055
|
+
{ p_organization_id: org, p_limit: args?.limit ?? 100 },
|
|
3056
|
+
"workTemplates"
|
|
3057
|
+
);
|
|
3058
|
+
},
|
|
3059
|
+
async workApprovalApprovers({ subject_id, approver_id = null }) {
|
|
3060
|
+
return callDoor(
|
|
3061
|
+
DOORS.workApprovalApprovers,
|
|
3062
|
+
{ p_organization_id: org, p_subject_id: subject_id, p_approver_id: approver_id },
|
|
3063
|
+
"workApprovalApprovers"
|
|
3064
|
+
);
|
|
3065
|
+
},
|
|
3066
|
+
async workApprovalRequest({
|
|
3067
|
+
subject_id,
|
|
3068
|
+
change,
|
|
3069
|
+
note = null,
|
|
3070
|
+
approver_id = null,
|
|
3071
|
+
origin = "person",
|
|
3072
|
+
conversation_id = null
|
|
3073
|
+
}) {
|
|
3074
|
+
return callDoor(
|
|
3075
|
+
DOORS.workApprovalRequest,
|
|
3076
|
+
{
|
|
3077
|
+
p_organization_id: org,
|
|
3078
|
+
p_subject_id: subject_id,
|
|
3079
|
+
p_change: change,
|
|
3080
|
+
p_note: note,
|
|
3081
|
+
p_approver_id: approver_id,
|
|
3082
|
+
p_origin: origin,
|
|
3083
|
+
p_conversation_id: conversation_id
|
|
3084
|
+
},
|
|
3085
|
+
"workApprovalRequest"
|
|
3086
|
+
);
|
|
3087
|
+
},
|
|
3088
|
+
async workApprovalMayDecide({ approval_id }) {
|
|
3089
|
+
return callDoor(
|
|
3090
|
+
DOORS.workApprovalMayDecide,
|
|
3091
|
+
{ p_organization_id: org, p_approval_id: approval_id },
|
|
3092
|
+
"workApprovalMayDecide"
|
|
3093
|
+
);
|
|
3094
|
+
},
|
|
3095
|
+
async workApprovalDecide({ approval_id, approve, note = null }) {
|
|
3096
|
+
return callDoor(
|
|
3097
|
+
DOORS.workApprovalDecide,
|
|
3098
|
+
{
|
|
3099
|
+
p_organization_id: org,
|
|
3100
|
+
p_approval_id: approval_id,
|
|
3101
|
+
p_approve: approve,
|
|
3102
|
+
p_note: note
|
|
3103
|
+
},
|
|
3104
|
+
"workApprovalDecide"
|
|
3105
|
+
);
|
|
3106
|
+
},
|
|
3107
|
+
async workApprovalRead({ approval_id }) {
|
|
3108
|
+
return callDoor(
|
|
3109
|
+
DOORS.workApprovalRead,
|
|
3110
|
+
{ p_organization_id: org, p_approval_id: approval_id },
|
|
3111
|
+
"workApprovalRead"
|
|
3112
|
+
);
|
|
3113
|
+
},
|
|
2612
3114
|
// ── the trust doors ──────────────────────────────────────────────────
|
|
2613
3115
|
async isExternalPrincipal(args) {
|
|
2614
3116
|
return trustDoor(
|
|
@@ -2801,7 +3303,7 @@ function pgJsonbText(value) {
|
|
|
2801
3303
|
return JSON.stringify(value);
|
|
2802
3304
|
}
|
|
2803
3305
|
var jsonBytes = (value) => new TextEncoder().encode(pgJsonbText(value)).length;
|
|
2804
|
-
var
|
|
3306
|
+
var UUID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
2805
3307
|
function labelOf(field) {
|
|
2806
3308
|
return field.label && field.label.length > 0 ? field.label : field.key;
|
|
2807
3309
|
}
|
|
@@ -2911,7 +3413,7 @@ function predictValueRefusals(fields, values, recordType) {
|
|
|
2911
3413
|
message: `${label} takes one of its choices, and it was given a ${jsonType(item)}`,
|
|
2912
3414
|
hint: "FLD-5 / FLD-6: a list field stores the id of the option RECORD, because every pick-list is already a Table."
|
|
2913
3415
|
});
|
|
2914
|
-
} else if (!
|
|
3416
|
+
} else if (!UUID2.test(item)) {
|
|
2915
3417
|
found.push({
|
|
2916
3418
|
...base,
|
|
2917
3419
|
message: `${label} was given a choice that is not one of its choices`,
|
|
@@ -2921,7 +3423,7 @@ function predictValueRefusals(fields, values, recordType) {
|
|
|
2921
3423
|
} else if (field.type === "relation") {
|
|
2922
3424
|
if (typeof item !== "string") {
|
|
2923
3425
|
found.push({ ...base, message: `${label} points at a record, and it was given a ${jsonType(item)}`, hint: "FLD-1: relation." });
|
|
2924
|
-
} else if (!
|
|
3426
|
+
} else if (!UUID2.test(item)) {
|
|
2925
3427
|
found.push({
|
|
2926
3428
|
...base,
|
|
2927
3429
|
message: `${label} points at something that is not there`,
|
|
@@ -3253,6 +3755,9 @@ export {
|
|
|
3253
3755
|
asWriteConflict,
|
|
3254
3756
|
atLeast,
|
|
3255
3757
|
cellText,
|
|
3758
|
+
choiceSlug,
|
|
3759
|
+
choiceValuesOf,
|
|
3760
|
+
choicesOf,
|
|
3256
3761
|
createRecordsClient,
|
|
3257
3762
|
doorAbsent,
|
|
3258
3763
|
doorCensus,
|
|
@@ -3261,15 +3766,21 @@ export {
|
|
|
3261
3766
|
exportCsv,
|
|
3262
3767
|
exportXlsx,
|
|
3263
3768
|
highestLevel,
|
|
3769
|
+
holdsARetiredChoice,
|
|
3264
3770
|
importCsv,
|
|
3265
3771
|
importXlsx,
|
|
3266
3772
|
intersectIds,
|
|
3267
3773
|
isRecordsErr,
|
|
3774
|
+
isTheChosen,
|
|
3775
|
+
looksLikeAnId,
|
|
3268
3776
|
mapPgError,
|
|
3269
3777
|
measureKey,
|
|
3270
3778
|
ok,
|
|
3779
|
+
optionKey,
|
|
3780
|
+
optionLabel,
|
|
3271
3781
|
parseCsv,
|
|
3272
3782
|
planQuery,
|
|
3783
|
+
portalPath,
|
|
3273
3784
|
predictEnvelopeRefusal,
|
|
3274
3785
|
predictSizeRefusal,
|
|
3275
3786
|
predictValueRefusals,
|