@ai-matrx/records 0.45.0 → 0.47.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.
@@ -570,6 +570,9 @@ var STORE_DOORS = [
570
570
  { 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" },
571
571
  { name: "per_value_access_words", args: "", returns: "text[]", security: "invoker" },
572
572
  { name: "person_kernel_id", args: "", returns: "uuid", security: "invoker" },
573
+ { name: "phone_canonical", args: "p_text text", returns: "text", security: "invoker" },
574
+ { name: "phone_display", args: "p_text text", returns: "text", security: "invoker" },
575
+ { name: "phone_pattern", args: "", returns: "text", security: "invoker" },
573
576
  { name: "pin_agent_cells", args: "p_new jsonb, p_old jsonb, p_agent_keys text[]", returns: "jsonb", security: "invoker" },
574
577
  { name: "pipeline_board", args: "p_organization_id uuid, p_table_id uuid, p_measure text DEFAULT NULL::text", returns: "TABLE(stage_key text, stage_label text, stage_position integer, cards bigint, total numeric, wip_limit integer, over_limit boolean)", security: "definer" },
575
578
  { name: "pipeline_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb", returns: "jsonb", security: "definer" },
@@ -591,6 +594,7 @@ var STORE_DOORS = [
591
594
  { name: "portal_record_title", args: "p_organization_id uuid, p_record_id uuid", returns: "text", security: "definer" },
592
595
  { name: "portal_revoke", args: "p_organization_id uuid, p_portal_id uuid, p_principal_id uuid", returns: "jsonb", security: "definer" },
593
596
  { name: "portal_slug", args: "p_organization_id uuid, p_title text, p_portal_id uuid DEFAULT NULL::uuid", returns: "text", security: "definer" },
597
+ { name: "portal_tables", args: "p_organization_id uuid", returns: "TABLE(portal_id uuid, table_id uuid, name text)", security: "definer" },
594
598
  { 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" },
595
599
  { name: "presentation_kernel_id", args: "", returns: "uuid", security: "invoker" },
596
600
  { name: "promote_field", args: "p_organization_id uuid, p_table_id uuid, p_field_id uuid", returns: "jsonb", security: "invoker" },
@@ -869,7 +873,7 @@ var STORE_REFUSAL_CODES = [
869
873
  { 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,booking_declare,capture_submit,checklist_declare,context_resolve,dashboard_block_normalize,dashboard_declare,dashboard_window_sql,doc_render_write,doc_sign,doc_signature_write,doc_template_save,enrich_land,enrich_normalize,external_history_event,external_rows,external_source_declare,external_stub_upsert,external_write_through,external_writes_set,field_history,form_declare,form_submit,home_add,io_comment_write,io_import_begin,io_infer_column,io_outbox_drain,io_restore,migrate_choice_keys,migrate_purge,migrate_reclass,migrate_split,migrate_undo,organization_clear,organization_contents,pipeline_declare,pipeline_gate_preview,portal_declare,portal_invite,portal_principal_bind,provenance_retention_days,provenance_write,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,record_write_many,relation_carry,relation_own,rule_declare,share_grant,sign_request_create,sign_request_sign,subscription_declare,table_declare,table_share_outside_invite,value_restore,view_declare,work_approval_decide,work_approval_request,work_template_declare" },
870
874
  { code: "22007", raised_by: "dashboard_window_sql" },
871
875
  { code: "22012", raised_by: "rule_eval" },
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" },
876
+ { 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,field_update,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" },
873
877
  { 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" },
874
878
  { 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" },
875
879
  { 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" },
@@ -1769,6 +1773,7 @@ var ENTITY_TOKENS = [
1769
1773
  "template_context_items",
1770
1774
  "template_scope_types",
1771
1775
  "templates",
1776
+ "test_handset_inbox",
1772
1777
  "thread",
1773
1778
  "tool",
1774
1779
  "tool_binding",
@@ -2133,6 +2138,14 @@ var DOORS = {
2133
2138
  // pair (`custom.portal_public`, `custom.portal_invitation`, `custom.portal_me`)
2134
2139
  // is deliberately absent here: those belong to the outsider's own shell.
2135
2140
  portals: "portals",
2141
+ // WHICH TABLES EACH PORTAL SHOWS (TAILS-3). The Portals RAIL lives on a
2142
+ // Table's page beside Forms, Bookings and Dashboards, all of which are
2143
+ // table-scoped; `custom.portals` takes no table, so an organization with one
2144
+ // portal over Jobs saw that portal's cards on its Parts table, the empty
2145
+ // state never rendered, and the whole build/ask offer was unreachable
2146
+ // everywhere in that organization. This is the one question the rail has to
2147
+ // ask, under the same wall and visibility gate as `portals` itself.
2148
+ portalTables: "portal_tables",
2136
2149
  portalCard: "portal_card",
2137
2150
  portalDeclare: "portal_declare",
2138
2151
  portalInvite: "portal_invite",
@@ -2426,19 +2439,34 @@ function parseDetail(details) {
2426
2439
  return details;
2427
2440
  }
2428
2441
  }
2442
+ function isNotASqlstate(code) {
2443
+ if (!code) return true;
2444
+ return /^[0-9]{3}$/.test(code);
2445
+ }
2429
2446
  function mapPgError(error, where) {
2430
- const sqlstate = error.code ?? void 0;
2431
- const code = (sqlstate ? BY_SQLSTATE[sqlstate] : void 0) ?? "internal";
2447
+ const raw = error.code ?? void 0;
2448
+ const sqlstate = raw && raw !== "" ? raw : void 0;
2432
2449
  const mapped = {
2433
- code,
2450
+ code: "internal",
2434
2451
  message: error.message,
2435
2452
  ...error.hint ? { hint: error.hint } : {},
2436
2453
  ...sqlstate ? { sqlstate } : {}
2437
2454
  };
2455
+ if (isNotASqlstate(sqlstate)) {
2456
+ mapped.code = "unreachable";
2457
+ } else {
2458
+ mapped.code = BY_SQLSTATE[sqlstate] ?? "internal";
2459
+ }
2438
2460
  const detail = parseDetail(error.details);
2439
2461
  if (detail !== void 0) mapped.detail = detail;
2440
- if (code === "internal") {
2441
- mapped.hint = (mapped.hint ? `${mapped.hint} ` : "") + `(@ai-matrx/records did not recognise SQLSTATE ${sqlstate ?? "(none)"} from ${where}; the message above is the store's own and is the thing to act on.)`;
2462
+ if (mapped.code === "internal") {
2463
+ mapped.unmapped = true;
2464
+ mapped.diagnostic = `@ai-matrx/records did not recognise SQLSTATE ${sqlstate ?? "(none)"} from ${where}; the store's own message is the thing to act on.`;
2465
+ } else if (mapped.code === "unreachable") {
2466
+ mapped.unmapped = true;
2467
+ mapped.diagnostic = `@ai-matrx/records never reached the store from ${where}: ${raw ? `the transport answered ${raw}` : "no response"} \u2014 ${error.message}`;
2468
+ mapped.message = "We could not reach your data.";
2469
+ delete mapped.hint;
2442
2470
  }
2443
2471
  return mapped;
2444
2472
  }
@@ -3190,6 +3218,9 @@ function createRecordsClient(config) {
3190
3218
  async portals() {
3191
3219
  return callDoor(DOORS.portals, { p_organization_id: org }, "portals");
3192
3220
  },
3221
+ async portalTables() {
3222
+ return callDoor(DOORS.portalTables, { p_organization_id: org }, "portalTables");
3223
+ },
3193
3224
  async portalCard({ portal_id }) {
3194
3225
  return callDoor(
3195
3226
  DOORS.portalCard,