@ai-matrx/records 0.43.0 → 0.45.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 +36 -0
- package/dist/core/index.cjs +244 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +27 -3
- package/dist/core/index.d.ts +27 -3
- package/dist/core/index.js +244 -2
- package/dist/core/index.js.map +1 -1
- package/dist/{field-CdHqvIIy.d.cts → field-D0Rr4Cqb.d.cts} +52 -3
- package/dist/{field-CdHqvIIy.d.ts → field-D0Rr4Cqb.d.ts} +52 -3
- package/dist/index.cjs +212 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +126 -3
- package/dist/index.d.ts +126 -3
- package/dist/index.js +212 -2
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +244 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +197 -3
- package/dist/react/index.d.ts +197 -3
- package/dist/react/index.js +244 -2
- package/dist/react/index.js.map +1 -1
- package/dist/use-cases/index.cjs.map +1 -1
- package/dist/use-cases/index.d.cts +1 -1
- package/dist/use-cases/index.d.ts +1 -1
- package/dist/use-cases/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ __export(react_exports, {
|
|
|
28
28
|
CONTEXT_POLICIES: () => CONTEXT_POLICIES,
|
|
29
29
|
DELIVERIES: () => DELIVERIES,
|
|
30
30
|
ENTITY_TOKENS: () => ENTITY_TOKENS,
|
|
31
|
+
FIELD_KINDS: () => FIELD_KINDS,
|
|
31
32
|
FIELD_SENSITIVITIES: () => FIELD_SENSITIVITIES,
|
|
32
33
|
FIELD_SOURCES: () => FIELD_SOURCES,
|
|
33
34
|
FRESHNESS: () => FRESHNESS,
|
|
@@ -66,7 +67,11 @@ __export(react_exports, {
|
|
|
66
67
|
choiceSlug: () => choiceSlug,
|
|
67
68
|
choiceValuesOf: () => choiceValuesOf,
|
|
68
69
|
choicesOf: () => choicesOf,
|
|
70
|
+
coerceTypedAnswer: () => coerceTypedAnswer,
|
|
71
|
+
coerceTypedAnswers: () => coerceTypedAnswers,
|
|
72
|
+
coercionLabel: () => coercionLabel,
|
|
69
73
|
err: () => err,
|
|
74
|
+
fieldKindFor: () => fieldKindFor,
|
|
70
75
|
forgetAllOps: () => forgetAllOps,
|
|
71
76
|
highestLevel: () => highestLevel,
|
|
72
77
|
holdsARetiredChoice: () => holdsARetiredChoice,
|
|
@@ -667,6 +672,8 @@ var STORE_DOORS = [
|
|
|
667
672
|
{ name: "relation_target_ours", args: "p_entity_token text, p_row_id uuid", returns: "jsonb", security: "definer" },
|
|
668
673
|
{ name: "relation_targets", args: "p_organization_id uuid, p_record_id uuid, p_via_key text", returns: "SETOF uuid", security: "definer" },
|
|
669
674
|
{ name: "relation_uncarry", args: "p_organization_id uuid, p_container_id uuid, p_item_id uuid", returns: "integer", security: "definer" },
|
|
675
|
+
{ name: "relation_words", args: "p_organization_id uuid, p_field_id uuid, p_value text", returns: "text", security: "definer" },
|
|
676
|
+
{ name: "relation_words_many", args: "p_organization_id uuid, p_field_id uuid, p_record_ids uuid[]", returns: "TABLE(record_id uuid, words text)", security: "definer" },
|
|
670
677
|
{ name: "reopen_declared_doors", args: "", returns: "TABLE(reopened text)", security: "definer" },
|
|
671
678
|
{ name: "required_epoch", args: "p_container_type text, p_container_id uuid, p_item_type text, p_item_id uuid", returns: "bigint", security: "definer" },
|
|
672
679
|
{ name: "resolve_first_match", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
|
|
@@ -863,9 +870,9 @@ var STORE_REFUSAL_CODES = [
|
|
|
863
870
|
{ code: "22007", raised_by: "dashboard_window_sql" },
|
|
864
871
|
{ code: "22012", raised_by: "rule_eval" },
|
|
865
872
|
{ code: "22023", raised_by: "_booking_availability,_entity_custom_fields_guard,_take_op_id,_value_envelope,_work_shape_guard,actor_word,agg_assert_key,agg_sql,anon_token_issue,booking_declare,containment_parent,dashboard_block_normalize,dashboard_window_sql,doc_render_body,doc_render_write,doc_signature_write,enrich_declare,enrich_land,enrich_normalize,enrich_pin,entity_value_write,external_history_event,external_source_declare,external_stub_upsert,external_write_through,field_history,io_export,io_import_begin,io_import_finish,io_import_plan,io_import_report,io_proposal_accept,migrate_merge,migrate_reclass,my_levels,organization_clear,page_size,pin_agent_cells,pipeline_move,portal_declare,provenance_write,query_by_coordinates,query_rollup,record_update,record_write_many,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,sign_request_create,sign_request_sign,subscription_declare,table_rules,visibility_as_of,work_approval_request,work_list,work_slot_hold" },
|
|
866
|
-
{ code: "23503", raised_by: "_booking_availability,_checklist_instantiate,_containment_guard,_field_document_for,_pipeline_stage_key,_record_rule_uses,agg_digest_assemble,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,booking_cancel,booking_confirm,booking_declare,booking_hold,booking_reschedule,capture_publish,checklist_declare,checklist_steps_table,comment_write,dashboard_declare,delete_rule,doc_sign,doc_template_save,enrich_declare,enrich_due,enrich_land,form_declare,form_submit,home_add,inbound_declare,inbound_mail_land,inbound_set,io_comment_write,io_import_begin,io_import_finish,io_import_report,io_import_rows,io_proposal_accept,migrate_demote,migrate_promote,pipeline_board,pipeline_declare,pipeline_move,pipeline_read,pipeline_transition_refusal,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,sign_request_create,subscription_mute,subscription_preview,view_declare,work_set_state,work_take_assignment,work_template_instantiate" },
|
|
873
|
+
{ code: "23503", raised_by: "_booking_availability,_checklist_instantiate,_containment_guard,_display_spec_for,_field_document_for,_pipeline_stage_key,_record_rule_uses,agg_digest_assemble,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,booking_cancel,booking_confirm,booking_declare,booking_hold,booking_reschedule,capture_publish,checklist_declare,checklist_steps_table,comment_write,dashboard_declare,delete_rule,doc_sign,doc_template_save,enrich_declare,enrich_due,enrich_land,form_declare,form_submit,home_add,inbound_declare,inbound_mail_land,inbound_set,io_comment_write,io_import_begin,io_import_finish,io_import_report,io_import_rows,io_proposal_accept,migrate_demote,migrate_promote,pipeline_board,pipeline_declare,pipeline_move,pipeline_read,pipeline_transition_refusal,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,sign_request_create,subscription_mute,subscription_preview,view_declare,work_set_state,work_take_assignment,work_template_instantiate" },
|
|
867
874
|
{ code: "23505", raised_by: "_unique_rule_holds,doc_sign,doc_signature_write,entity_field_declare,field_declare,home_add,inbound_declare,io_proposal_accept,relation_carry,relation_own,share_grant,sign_request_cancel,sign_request_create,table_share_outside_invite,table_share_outside_resend,work_approval_decide,work_slot_hold" },
|
|
868
|
-
{ code: "23514", raised_by: "_checklist_instantiate,_checklist_step_guard,_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_columns_word_guard,_table_shape_guard,_undeclared_key_guard,_value_envelope,_work_shape_guard,_workdoors_approval_guard,assert_columns_are_defined,assert_entity_is_organization_scoped,booking_declare,capture_publish,capture_sheet_declare,checklist_declare,checklist_step_complete,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,io_import_rows,migrate_merge,relation_carry,relation_own,sign_request_create,sign_request_sign,table_declare,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate" },
|
|
875
|
+
{ code: "23514", raised_by: "_checklist_instantiate,_checklist_step_guard,_containment_guard,_dated_values_guard,_derived_fields,_display_spec_for,_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_columns_word_guard,_table_shape_guard,_undeclared_key_guard,_value_envelope,_with_display,_work_shape_guard,_workdoors_approval_guard,assert_columns_are_defined,assert_entity_is_organization_scoped,booking_declare,capture_publish,capture_sheet_declare,checklist_declare,checklist_step_complete,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,io_import_rows,migrate_merge,relation_carry,relation_own,sign_request_create,sign_request_sign,table_declare,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate" },
|
|
869
876
|
{ code: "40001", raised_by: "has_visibility_at" },
|
|
870
877
|
{ 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,booking_confirm,booking_declare,booking_hold,capture_submit,checklist_run,comment_write,conversation_scope_bind,conversation_scope_unbind,enrich_declare,enrich_due,enrich_land,enrich_normalize,entity_field_declare,entity_field_retire,entity_field_update,entity_value_write,external_write_through,form_declare,form_submit,inbound_mail_land,io_comment_resolve,io_comment_write,io_import_begin,io_import_finish,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,read_records_by_ids,record_table,share_grant,subscription_mute,subscription_preview,table_share_outside_accept,table_share_outside_invite,table_share_outside_resend,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person" },
|
|
871
878
|
{ code: "42703", raised_by: "entity_table,portal_declare" },
|
|
@@ -2016,6 +2023,18 @@ var DOORS = {
|
|
|
2016
2023
|
promotedRead: "promoted_read",
|
|
2017
2024
|
relationTargets: "relation_targets",
|
|
2018
2025
|
relationOwn: "relation_own",
|
|
2026
|
+
// REL-DISP, 2026-09-21. WHAT A RELATION CELL READS, through that column's own
|
|
2027
|
+
// display spec. `custom.record_words` is declared server_only — it takes a bare
|
|
2028
|
+
// record id with no field to scope it — so these are how a screen gets the
|
|
2029
|
+
// words, and they are the ONE way in: three separate copies of "read tableList,
|
|
2030
|
+
// find title_field, call rowName" lived in labels.tsx, RelationPicker.tsx and
|
|
2031
|
+
// PortalsPanel.tsx, and none of them could ever have shown two columns joined.
|
|
2032
|
+
// The `_many` door is the batch TAILS-2 recorded as missing ("there is still no
|
|
2033
|
+
// batch door on the store"), which is why the browser resolved labels one id at
|
|
2034
|
+
// a time. The ladder is NOT batched: the store asks it per record inside
|
|
2035
|
+
// `custom._words_for`, so batching buys a round trip and never a disclosure.
|
|
2036
|
+
relationWords: "relation_words",
|
|
2037
|
+
relationWordsMany: "relation_words_many",
|
|
2019
2038
|
homeAdd: "home_add",
|
|
2020
2039
|
recordReparent: "record_reparent",
|
|
2021
2040
|
containmentChain: "containment_chain",
|
|
@@ -2887,6 +2906,26 @@ function createRecordsClient(config) {
|
|
|
2887
2906
|
"fieldRetire"
|
|
2888
2907
|
);
|
|
2889
2908
|
},
|
|
2909
|
+
async relationWords({ field_id, value }) {
|
|
2910
|
+
return callDoor(
|
|
2911
|
+
DOORS.relationWords,
|
|
2912
|
+
{ p_organization_id: org, p_field_id: field_id, p_value: value },
|
|
2913
|
+
"relationWords"
|
|
2914
|
+
);
|
|
2915
|
+
},
|
|
2916
|
+
async relationWordsMany({ field_id, record_ids }) {
|
|
2917
|
+
const result = await callDoor(
|
|
2918
|
+
DOORS.relationWordsMany,
|
|
2919
|
+
{ p_organization_id: org, p_field_id: field_id, p_record_ids: record_ids },
|
|
2920
|
+
"relationWordsMany"
|
|
2921
|
+
);
|
|
2922
|
+
if (!result.ok) return result;
|
|
2923
|
+
const map = {};
|
|
2924
|
+
for (const row of result.data ?? []) {
|
|
2925
|
+
if (row?.record_id && typeof row.words === "string") map[row.record_id] = row.words;
|
|
2926
|
+
}
|
|
2927
|
+
return { ok: true, data: map };
|
|
2928
|
+
},
|
|
2890
2929
|
async tableDeclare({ spec, homeId }) {
|
|
2891
2930
|
return callDoor(
|
|
2892
2931
|
DOORS.tableDeclare,
|
|
@@ -4787,6 +4826,209 @@ function looksLikeAnId(value) {
|
|
|
4787
4826
|
return typeof value === "string" && UUID.test(value);
|
|
4788
4827
|
}
|
|
4789
4828
|
|
|
4829
|
+
// src/coerce.ts
|
|
4830
|
+
var FIELD_KINDS = [
|
|
4831
|
+
"attachment",
|
|
4832
|
+
"checkbox",
|
|
4833
|
+
"currency",
|
|
4834
|
+
"datetime",
|
|
4835
|
+
"email",
|
|
4836
|
+
"formula",
|
|
4837
|
+
"json",
|
|
4838
|
+
"long_text",
|
|
4839
|
+
"lookup",
|
|
4840
|
+
"member",
|
|
4841
|
+
"multi_select",
|
|
4842
|
+
"number",
|
|
4843
|
+
"percent",
|
|
4844
|
+
"phone",
|
|
4845
|
+
"relation",
|
|
4846
|
+
"rollup",
|
|
4847
|
+
"select",
|
|
4848
|
+
"text",
|
|
4849
|
+
"url"
|
|
4850
|
+
];
|
|
4851
|
+
function fieldKindFor(field, kernel) {
|
|
4852
|
+
const format = (field.format ?? "").toLowerCase();
|
|
4853
|
+
const config = field.config ?? {};
|
|
4854
|
+
switch (field.type) {
|
|
4855
|
+
case "boolean":
|
|
4856
|
+
return "checkbox";
|
|
4857
|
+
case "text":
|
|
4858
|
+
if (format === "email") return "email";
|
|
4859
|
+
if (format === "phone") return "phone";
|
|
4860
|
+
if (format === "url") return "url";
|
|
4861
|
+
if (format === "json" || config["json"] === true) return "json";
|
|
4862
|
+
if (format === "long" || config["multiline"] === true) return "long_text";
|
|
4863
|
+
return "text";
|
|
4864
|
+
case "range": {
|
|
4865
|
+
const kind = String(config["kind"] ?? "number");
|
|
4866
|
+
if (kind === "date" || kind === "datetime") return "datetime";
|
|
4867
|
+
if (format === "currency") return "currency";
|
|
4868
|
+
if (format === "percent" || field.unit === "%") return "percent";
|
|
4869
|
+
return "number";
|
|
4870
|
+
}
|
|
4871
|
+
case "list":
|
|
4872
|
+
return field.multi ? "multi_select" : "select";
|
|
4873
|
+
case "relation": {
|
|
4874
|
+
const parity = String(config["parity"] ?? "");
|
|
4875
|
+
if (parity === "attachment" || parity === "member") return parity;
|
|
4876
|
+
if (kernel?.file && field.relation_target === kernel.file) return "attachment";
|
|
4877
|
+
if (kernel?.person && field.relation_target === kernel.person) return "member";
|
|
4878
|
+
return "relation";
|
|
4879
|
+
}
|
|
4880
|
+
case "formula": {
|
|
4881
|
+
const via = config["via"];
|
|
4882
|
+
if (via && config["agg"]) return "rollup";
|
|
4883
|
+
if (via) return "lookup";
|
|
4884
|
+
return "formula";
|
|
4885
|
+
}
|
|
4886
|
+
default:
|
|
4887
|
+
return "text";
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
var TRUE_WORDS = /* @__PURE__ */ new Set(["true", "yes", "y", "1", "\u2713", "x", "checked", "on"]);
|
|
4891
|
+
var FALSE_WORDS = /* @__PURE__ */ new Set(["false", "no", "n", "0", "", "unchecked", "off"]);
|
|
4892
|
+
function coercionLabel(field) {
|
|
4893
|
+
const label = (field.label ?? "").trim();
|
|
4894
|
+
if (label !== "") return label;
|
|
4895
|
+
const name = (field.name ?? "").trim();
|
|
4896
|
+
if (name !== "") return name;
|
|
4897
|
+
return field.key.replace(/[_-]+/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()).trim();
|
|
4898
|
+
}
|
|
4899
|
+
function coerceTypedAnswer(field, raw, opts = {}) {
|
|
4900
|
+
const label = opts.label ?? coercionLabel(field);
|
|
4901
|
+
const text = raw.trim();
|
|
4902
|
+
const kind = fieldKindFor(field, opts.kernel);
|
|
4903
|
+
if (text === "" && kind !== "checkbox") return { value: null };
|
|
4904
|
+
switch (kind) {
|
|
4905
|
+
case "checkbox": {
|
|
4906
|
+
const word = text.toLowerCase();
|
|
4907
|
+
if (TRUE_WORDS.has(word)) return { value: true };
|
|
4908
|
+
if (FALSE_WORDS.has(word)) return { value: word === "" ? null : false };
|
|
4909
|
+
return {
|
|
4910
|
+
refusal: `${label} is a tick box, so it takes yes or no \u2014 \u201C${raw}\u201D is neither. Write TRUE/FALSE, yes/no or 1/0.`
|
|
4911
|
+
};
|
|
4912
|
+
}
|
|
4913
|
+
case "number":
|
|
4914
|
+
case "currency":
|
|
4915
|
+
case "percent": {
|
|
4916
|
+
const negative = /^\(.*\)$/.test(text);
|
|
4917
|
+
const bare = text.replace(/^\(|\)$/g, "").replace(/[\s,]/g, "").replace(/^[^\d.\-+]+/, "").replace(/[^\d.\-+eE]+$/, "");
|
|
4918
|
+
const n = Number(bare);
|
|
4919
|
+
if (bare === "" || Number.isNaN(n)) {
|
|
4920
|
+
return {
|
|
4921
|
+
refusal: `${label} holds a number, and \u201C${raw}\u201D is not one. Write digits \u2014 a currency symbol, a percent sign, commas and brackets for a negative are all fine.`
|
|
4922
|
+
};
|
|
4923
|
+
}
|
|
4924
|
+
return { value: negative ? -n : n };
|
|
4925
|
+
}
|
|
4926
|
+
case "datetime": {
|
|
4927
|
+
const wantsTime = String(field.config?.["kind"] ?? "date") === "datetime";
|
|
4928
|
+
const plainDay = /^\s*(\d{4})-(\d{2})-(\d{2})\s*$/.exec(raw);
|
|
4929
|
+
if (!wantsTime && plainDay) return { value: `${plainDay[1]}-${plainDay[2]}-${plainDay[3]}` };
|
|
4930
|
+
const at = Date.parse(text);
|
|
4931
|
+
if (Number.isNaN(at)) {
|
|
4932
|
+
return {
|
|
4933
|
+
refusal: `${label} holds a date, and \u201C${raw}\u201D is not one this can read. Write it as 2026-09-21, or the way your spreadsheet writes dates.`
|
|
4934
|
+
};
|
|
4935
|
+
}
|
|
4936
|
+
const parsed = new Date(at);
|
|
4937
|
+
if (wantsTime) return { value: parsed.toISOString() };
|
|
4938
|
+
const y = parsed.getFullYear();
|
|
4939
|
+
const m = String(parsed.getMonth() + 1).padStart(2, "0");
|
|
4940
|
+
const d = String(parsed.getDate()).padStart(2, "0");
|
|
4941
|
+
return { value: `${y}-${m}-${d}` };
|
|
4942
|
+
}
|
|
4943
|
+
case "json": {
|
|
4944
|
+
try {
|
|
4945
|
+
return { value: JSON.parse(text) };
|
|
4946
|
+
} catch {
|
|
4947
|
+
return {
|
|
4948
|
+
refusal: `${label} holds a document, and \u201C${raw}\u201D is not valid JSON. Write the whole object, braces and all.`
|
|
4949
|
+
};
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
case "select":
|
|
4953
|
+
case "multi_select": {
|
|
4954
|
+
if (!opts.options) {
|
|
4955
|
+
return {
|
|
4956
|
+
refusal: `${label} is a list and its options have not been read yet, so nothing can be matched to \u201C${raw}\u201D. Try again once the column's choices have loaded.`
|
|
4957
|
+
};
|
|
4958
|
+
}
|
|
4959
|
+
const wanted = kind === "multi_select" ? text.split(/[,;]/).map((w) => w.trim()).filter((w) => w.length > 0) : [text];
|
|
4960
|
+
if (wanted.length === 0) return { value: kind === "multi_select" ? [] : null };
|
|
4961
|
+
const matched = [];
|
|
4962
|
+
const unmatched = [];
|
|
4963
|
+
for (const word of wanted) {
|
|
4964
|
+
const hit = opts.options.byWord.get(word.toLowerCase());
|
|
4965
|
+
if (hit === void 0) unmatched.push(word);
|
|
4966
|
+
else matched.push(hit);
|
|
4967
|
+
}
|
|
4968
|
+
if (unmatched.length > 0) {
|
|
4969
|
+
const offered = opts.options.labels.length > 0 ? opts.options.labels.join(", ") : "it has none yet";
|
|
4970
|
+
return {
|
|
4971
|
+
refusal: `${label} does not have ${unmatched.map((w) => `\u201C${w}\u201D`).join(" or ")} among its options. It offers: ${offered}.`,
|
|
4972
|
+
unmatched
|
|
4973
|
+
};
|
|
4974
|
+
}
|
|
4975
|
+
return { value: kind === "multi_select" ? matched : matched[0] };
|
|
4976
|
+
}
|
|
4977
|
+
// AN IDENTITY IS NOT A WORD. Writing the word would put a string where an
|
|
4978
|
+
// id belongs, and every filter, colour and rollup built on that column
|
|
4979
|
+
// would stop agreeing with it. So it is refused and the person is told
|
|
4980
|
+
// which control does hold it.
|
|
4981
|
+
case "member":
|
|
4982
|
+
return {
|
|
4983
|
+
refusal: `${label} names a person in this organization, so it is chosen rather than typed. Open it and pick them.`
|
|
4984
|
+
};
|
|
4985
|
+
case "attachment":
|
|
4986
|
+
return {
|
|
4987
|
+
refusal: `${label} holds a file, which cannot arrive as typed-in text. Open it and attach the file.`
|
|
4988
|
+
};
|
|
4989
|
+
case "relation":
|
|
4990
|
+
return {
|
|
4991
|
+
refusal: `${label} points at another record, so it is chosen rather than typed. Open it and pick the record.`
|
|
4992
|
+
};
|
|
4993
|
+
case "formula":
|
|
4994
|
+
case "lookup":
|
|
4995
|
+
case "rollup":
|
|
4996
|
+
return {
|
|
4997
|
+
refusal: `${label} is worked out by the system, so nothing can be written into it.`
|
|
4998
|
+
};
|
|
4999
|
+
default:
|
|
5000
|
+
return { value: raw };
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
5003
|
+
function coerceTypedAnswers(fields, answers, opts = {}) {
|
|
5004
|
+
const byKey = new Map(fields.map((f) => [f.key, f]));
|
|
5005
|
+
const values = {};
|
|
5006
|
+
const refusals = {};
|
|
5007
|
+
const unknownKeys = [];
|
|
5008
|
+
for (const [key, given] of Object.entries(answers)) {
|
|
5009
|
+
const field = byKey.get(key);
|
|
5010
|
+
if (!field) {
|
|
5011
|
+
unknownKeys.push(key);
|
|
5012
|
+
values[key] = given;
|
|
5013
|
+
continue;
|
|
5014
|
+
}
|
|
5015
|
+
if (typeof given !== "string") {
|
|
5016
|
+
values[key] = given;
|
|
5017
|
+
continue;
|
|
5018
|
+
}
|
|
5019
|
+
const opt = {};
|
|
5020
|
+
const choices = opts.options?.get(key);
|
|
5021
|
+
if (choices) opt.options = choices;
|
|
5022
|
+
if (opts.kernel) opt.kernel = opts.kernel;
|
|
5023
|
+
const label = opts.labels?.[key];
|
|
5024
|
+
if (label) opt.label = label;
|
|
5025
|
+
const answered = coerceTypedAnswer(field, given, opt);
|
|
5026
|
+
if ("refusal" in answered) refusals[key] = answered.refusal;
|
|
5027
|
+
else values[key] = answered.value;
|
|
5028
|
+
}
|
|
5029
|
+
return { values, refusals, unknownKeys };
|
|
5030
|
+
}
|
|
5031
|
+
|
|
4790
5032
|
// src/pipeline.ts
|
|
4791
5033
|
var PIPELINE_RULE_KINDS = ["moves", "requires", "who", "limit", "entry"];
|
|
4792
5034
|
var STAGE_RULE_ON_FAIL = ["refuse", "require_approval"];
|