@ai-matrx/records 0.36.0 → 0.39.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 +97 -0
- package/dist/core/index.cjs +57 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +53 -5
- package/dist/core/index.d.ts +53 -5
- package/dist/core/index.js +57 -2
- package/dist/core/index.js.map +1 -1
- package/dist/{field-CWBdZfFv.d.cts → field-C5vJ0Kqv.d.cts} +29 -5
- package/dist/{field-CWBdZfFv.d.ts → field-C5vJ0Kqv.d.ts} +29 -5
- package/dist/index.cjs +6 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -3
- package/dist/index.d.ts +75 -3
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +111 -10
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +152 -6
- package/dist/react/index.d.ts +152 -6
- package/dist/react/index.js +112 -11
- package/dist/react/index.js.map +1 -1
- package/dist/use-cases/index.cjs.map +1 -1
- package/dist/use-cases/index.d.cts +6 -4
- package/dist/use-cases/index.d.ts +6 -4
- package/dist/use-cases/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -152,6 +152,7 @@ var STORE_DOORS = [
|
|
|
152
152
|
{ name: "assert_client_may_change", args: "p_organization_id uuid, p_subject_id uuid, p_door text, p_required permission_level DEFAULT 'editor'::permission_level, p_subject_word text DEFAULT 'record'::text", returns: "void", security: "invoker" },
|
|
153
153
|
{ name: "assert_client_may_open", args: "p_organization_id uuid, p_subject_id uuid, p_door text, p_required permission_level DEFAULT 'viewer'::permission_level, p_subject_word text DEFAULT 'record'::text", returns: "void", security: "invoker" },
|
|
154
154
|
{ name: "assert_client_may_reach", args: "p_organization_id uuid, p_door text", returns: "void", security: "invoker" },
|
|
155
|
+
{ name: "assert_columns_are_defined", args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb", returns: "void", security: "definer" },
|
|
155
156
|
{ name: "assert_entity_door", args: "p_organization_id uuid, p_door text", returns: "void", security: "definer" },
|
|
156
157
|
{ name: "assert_entity_is_organization_scoped", args: "p_token text, p_label text, p_scoped boolean", returns: "void", security: "invoker" },
|
|
157
158
|
{ name: "assert_may_know_table", args: "p_organization_id uuid, p_table_id uuid, p_door text", returns: "void", security: "invoker" },
|
|
@@ -206,6 +207,7 @@ var STORE_DOORS = [
|
|
|
206
207
|
{ name: "comment_mention_deliver", args: "p_organization_id uuid, p_record_id uuid, p_table_id uuid, p_comment_id uuid, p_recipient uuid, p_author_name text, p_record_title text, p_body text", returns: "uuid", security: "definer" },
|
|
207
208
|
{ name: "comment_thread", args: "p_organization_id uuid, p_record_id uuid, p_include_resolved boolean DEFAULT false", returns: "jsonb", security: "definer" },
|
|
208
209
|
{ name: "comment_write", args: "p_organization_id uuid, p_record_id uuid, p_body text, p_anchor jsonb DEFAULT '{}'::jsonb, p_parent_comment_id uuid DEFAULT NULL::uuid, p_mentions uuid[] DEFAULT NULL::uuid[]", returns: "jsonb", security: "definer" },
|
|
210
|
+
{ name: "computed_block", args: "p_block jsonb", returns: "jsonb", security: "invoker" },
|
|
209
211
|
{ 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" },
|
|
210
212
|
{ name: "containment_chain", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(ancestor_id uuid, depth integer)", security: "invoker" },
|
|
211
213
|
{ name: "containment_depth_ceiling", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "integer", security: "invoker" },
|
|
@@ -237,6 +239,7 @@ var STORE_DOORS = [
|
|
|
237
239
|
{ name: "derive_visibility", args: "p_container_type text, p_container_id uuid", returns: "TABLE(item_type text, item_id uuid, depth integer, max_level permission_level)", security: "definer" },
|
|
238
240
|
{ name: "derived_value", args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb, p_values jsonb DEFAULT NULL::jsonb", returns: "jsonb", security: "invoker" },
|
|
239
241
|
{ name: "derived_values", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
|
|
242
|
+
{ name: "derived_values_of", args: "v_rec custom.record", returns: "jsonb", security: "invoker" },
|
|
240
243
|
{ name: "doc_content_hash", args: "p_body text", returns: "text", security: "invoker" },
|
|
241
244
|
{ name: "doc_format_value", args: "p_field_data jsonb, p_value jsonb", returns: "text", security: "invoker" },
|
|
242
245
|
{ name: "doc_letterhead", args: "p_organization_id uuid", returns: "jsonb", security: "definer" },
|
|
@@ -502,6 +505,7 @@ var STORE_DOORS = [
|
|
|
502
505
|
{ name: "record_table", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid", security: "definer" },
|
|
503
506
|
{ 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" },
|
|
504
507
|
{ name: "record_values", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
|
|
508
|
+
{ name: "record_values_of", args: "p_row custom.record", returns: "jsonb", security: "invoker" },
|
|
505
509
|
{ 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" },
|
|
506
510
|
{ name: "record_write", args: "p_organization_id uuid, p_table_id uuid, p_data jsonb", returns: "uuid", security: "definer" },
|
|
507
511
|
{ name: "record_write_many", args: "p_organization_id uuid, p_table_id uuid, p_rows jsonb[], p_ids uuid[] DEFAULT NULL::uuid[]", returns: "uuid[]", security: "definer" },
|
|
@@ -705,7 +709,7 @@ var STORE_REFUSAL_CODES = [
|
|
|
705
709
|
{ code: "22023", raised_by: "_booking_availability,_entity_custom_fields_guard,_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" },
|
|
706
710
|
{ 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" },
|
|
707
711
|
{ 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,work_approval_decide,work_slot_hold" },
|
|
708
|
-
{ code: "23514", raised_by: "_checklist_instantiate,_checklist_step_guard,
|
|
712
|
+
{ 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,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" },
|
|
709
713
|
{ code: "40001", raised_by: "has_visibility_at" },
|
|
710
714
|
{ 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,record_table,share_grant,subscription_mute,subscription_preview,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person" },
|
|
711
715
|
{ code: "42703", raised_by: "entity_table,portal_declare" },
|
|
@@ -1277,6 +1281,7 @@ var ENTITY_TOKENS = [
|
|
|
1277
1281
|
"mandate_advance_batch_row",
|
|
1278
1282
|
"mandate_binding",
|
|
1279
1283
|
"mandate_binding_legacy",
|
|
1284
|
+
"mandate_goal_clauses",
|
|
1280
1285
|
"mandate_legacy",
|
|
1281
1286
|
"mandate_observation",
|
|
1282
1287
|
"mandate_reference",
|
|
@@ -1907,6 +1912,10 @@ var DOORS = {
|
|
|
1907
1912
|
// VISITOR's three (`booking_public`, `booking_hold`, `booking_confirm`) are
|
|
1908
1913
|
// deliberately absent: they are server-lane and a browser never calls them.
|
|
1909
1914
|
bookings: "bookings",
|
|
1915
|
+
// The OWNER's side of a booking page, and the door that had no client method at
|
|
1916
|
+
// all until 2026-09-21: without it the only way to get a booking page was to ask
|
|
1917
|
+
// an agent, which made the agent the ONLY path rather than the faster one.
|
|
1918
|
+
bookingDeclare: "booking_declare",
|
|
1910
1919
|
// PRODUCTS row 9 — "pull my spreadsheet in". W4-IO built `io_import_open` and
|
|
1911
1920
|
// `io_import_rows`; lane IMPORT gave a run an IDENTITY (the file's sha-256, so
|
|
1912
1921
|
// a re-import doubles nothing), a duplicate key, a policy, per-row outcomes
|
|
@@ -2039,6 +2048,13 @@ var DOORS = {
|
|
|
2039
2048
|
// the summary it would send right now without sending it.
|
|
2040
2049
|
subscriptionDeclare: "subscription_declare",
|
|
2041
2050
|
subscriptionPreview: "subscription_preview",
|
|
2051
|
+
// A SUBSCRIPTION IS OVER A SAVED VIEW, so a person who has never saved one has
|
|
2052
|
+
// nothing to subscribe to. These two are the saved-view pair (lane DIGESTS'
|
|
2053
|
+
// `digests_a_saved_view_has_a_door.sql`), unreachable from this client until
|
|
2054
|
+
// 2026-09-21: `views` lists this Table's, `viewDeclare` writes one. A LIST IS A
|
|
2055
|
+
// DOOR, never a grant on `platform.saved_view` behind it.
|
|
2056
|
+
views: "views",
|
|
2057
|
+
viewDeclare: "view_declare",
|
|
2042
2058
|
// The cadence CATALOGUE a person's screen may ask for. `agg_subscription_cadences`
|
|
2043
2059
|
// above is the notifier's own and holds no client grant; this door delegates to
|
|
2044
2060
|
// it, so a picker and the digest runner can never offer different words.
|
|
@@ -2421,7 +2437,8 @@ function createRecordsClient(config) {
|
|
|
2421
2437
|
const { document, hidden } = unfold(row.document);
|
|
2422
2438
|
return { id: row.id, document, level: row.level, hidden };
|
|
2423
2439
|
});
|
|
2424
|
-
|
|
2440
|
+
const total = rows.length < limit ? offset + rows.length : null;
|
|
2441
|
+
return ok({ rows, total });
|
|
2425
2442
|
},
|
|
2426
2443
|
async query(input) {
|
|
2427
2444
|
const plan = planQuery(input);
|
|
@@ -2805,6 +2822,30 @@ function createRecordsClient(config) {
|
|
|
2805
2822
|
"bookings"
|
|
2806
2823
|
);
|
|
2807
2824
|
},
|
|
2825
|
+
async bookingDeclare(args) {
|
|
2826
|
+
return callDoor(
|
|
2827
|
+
DOORS.bookingDeclare,
|
|
2828
|
+
{
|
|
2829
|
+
p_organization_id: org,
|
|
2830
|
+
p_table_id: args.table_id,
|
|
2831
|
+
p_title: args.title,
|
|
2832
|
+
p_questions: args.questions,
|
|
2833
|
+
// AN EMPTY OBJECT IS NOT A MISTAKE. The store owns every default, so a
|
|
2834
|
+
// page declared with no availability comes back Monday-to-Friday,
|
|
2835
|
+
// nine-to-five, in the organization's own zone — and the screen draws
|
|
2836
|
+
// what came BACK rather than what it sent.
|
|
2837
|
+
p_availability: args.availability ?? {},
|
|
2838
|
+
p_presentation: args.presentation ?? {},
|
|
2839
|
+
p_submission_cap: args.submission_cap ?? null,
|
|
2840
|
+
p_quarantine_rule_id: args.quarantine_rule_id ?? null,
|
|
2841
|
+
p_notify_rule_id: args.notify_rule_id ?? null,
|
|
2842
|
+
p_form_id: args.form_id ?? null,
|
|
2843
|
+
p_slug: args.slug ?? null,
|
|
2844
|
+
p_home_id: args.home_id ?? null
|
|
2845
|
+
},
|
|
2846
|
+
"bookingDeclare"
|
|
2847
|
+
);
|
|
2848
|
+
},
|
|
2808
2849
|
async formDeclare(args) {
|
|
2809
2850
|
return callDoor(
|
|
2810
2851
|
DOORS.formDeclare,
|
|
@@ -3229,6 +3270,20 @@ function createRecordsClient(config) {
|
|
|
3229
3270
|
"subscriptionPreview"
|
|
3230
3271
|
);
|
|
3231
3272
|
},
|
|
3273
|
+
async views(args) {
|
|
3274
|
+
return callDoor(
|
|
3275
|
+
DOORS.views,
|
|
3276
|
+
{ p_organization_id: org, p_table_id: args?.table_id ?? null },
|
|
3277
|
+
"views"
|
|
3278
|
+
);
|
|
3279
|
+
},
|
|
3280
|
+
async viewDeclare({ table_id, spec }) {
|
|
3281
|
+
return callDoor(
|
|
3282
|
+
DOORS.viewDeclare,
|
|
3283
|
+
{ p_organization_id: org, p_table_id: table_id, p_spec: spec },
|
|
3284
|
+
"viewDeclare"
|
|
3285
|
+
);
|
|
3286
|
+
},
|
|
3232
3287
|
async subscriptionMute({ rule_id, muted }) {
|
|
3233
3288
|
return callDoor(
|
|
3234
3289
|
DOORS.subscriptionMute,
|
|
@@ -4056,7 +4111,7 @@ function useRecordsActor() {
|
|
|
4056
4111
|
}
|
|
4057
4112
|
|
|
4058
4113
|
// src/react/hooks.ts
|
|
4059
|
-
import { useCallback, useEffect, useMemo as useMemo2, useRef, useState } from "react";
|
|
4114
|
+
import { useCallback, useEffect, useMemo as useMemo2, useRef, useState, useSyncExternalStore } from "react";
|
|
4060
4115
|
function useAsync(run, deps) {
|
|
4061
4116
|
const client = useRecordsClient();
|
|
4062
4117
|
const [state, setState] = useState(
|
|
@@ -4125,13 +4180,36 @@ function useMyLevel(id) {
|
|
|
4125
4180
|
[id]
|
|
4126
4181
|
);
|
|
4127
4182
|
}
|
|
4183
|
+
var shapeRevisions = /* @__PURE__ */ new Map();
|
|
4184
|
+
var shapeListeners = /* @__PURE__ */ new Set();
|
|
4185
|
+
function tableShapeChanged(tableId) {
|
|
4186
|
+
shapeRevisions.set(tableId, (shapeRevisions.get(tableId) ?? 0) + 1);
|
|
4187
|
+
for (const listener of shapeListeners) listener();
|
|
4188
|
+
}
|
|
4189
|
+
function registerShapeInterest(tableId) {
|
|
4190
|
+
if (!shapeRevisions.has(tableId)) shapeRevisions.set(tableId, 0);
|
|
4191
|
+
}
|
|
4192
|
+
function subscribeToShape(listener) {
|
|
4193
|
+
shapeListeners.add(listener);
|
|
4194
|
+
return () => {
|
|
4195
|
+
shapeListeners.delete(listener);
|
|
4196
|
+
};
|
|
4197
|
+
}
|
|
4198
|
+
function useShapeRevision(tableId) {
|
|
4199
|
+
const read = useCallback(() => tableId ? shapeRevisions.get(tableId) ?? 0 : 0, [tableId]);
|
|
4200
|
+
return useSyncExternalStore(subscribeToShape, read, () => 0);
|
|
4201
|
+
}
|
|
4128
4202
|
function useFields(tableId, recordType) {
|
|
4203
|
+
const revision = useShapeRevision(tableId);
|
|
4204
|
+
useEffect(() => {
|
|
4205
|
+
if (tableId) registerShapeInterest(tableId);
|
|
4206
|
+
}, [tableId]);
|
|
4129
4207
|
return useAsync(
|
|
4130
4208
|
async (client) => {
|
|
4131
4209
|
if (!tableId) return { ok: true, data: [] };
|
|
4132
4210
|
return client.fields({ table_id: tableId, ...recordType === void 0 ? {} : { recordType } });
|
|
4133
4211
|
},
|
|
4134
|
-
[tableId, recordType]
|
|
4212
|
+
[tableId, recordType, revision]
|
|
4135
4213
|
);
|
|
4136
4214
|
}
|
|
4137
4215
|
function useRecords(tableId, options = {}) {
|
|
@@ -4304,19 +4382,41 @@ function useFieldMutation() {
|
|
|
4304
4382
|
},
|
|
4305
4383
|
[]
|
|
4306
4384
|
);
|
|
4385
|
+
const announce = useCallback((tableId) => {
|
|
4386
|
+
if (tableId) {
|
|
4387
|
+
tableShapeChanged(tableId);
|
|
4388
|
+
return;
|
|
4389
|
+
}
|
|
4390
|
+
for (const id of [...shapeRevisions.keys()]) tableShapeChanged(id);
|
|
4391
|
+
}, []);
|
|
4307
4392
|
return useMemo2(
|
|
4308
4393
|
() => ({
|
|
4309
|
-
declare: (args) =>
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4394
|
+
declare: async (args) => {
|
|
4395
|
+
const made = await run(
|
|
4396
|
+
() => client.fieldDeclare({ table_id: args.table_id, spec: args.spec }),
|
|
4397
|
+
null
|
|
4398
|
+
);
|
|
4399
|
+
if (made !== null) announce(args.table_id);
|
|
4400
|
+
return made;
|
|
4401
|
+
},
|
|
4402
|
+
update: async (args) => {
|
|
4403
|
+
const changed = await run(
|
|
4404
|
+
() => client.fieldUpdate({ field_id: args.field_id, patch: args.patch }),
|
|
4405
|
+
null
|
|
4406
|
+
);
|
|
4407
|
+
if (changed !== null) announce(null);
|
|
4408
|
+
return changed;
|
|
4409
|
+
},
|
|
4410
|
+
retire: async (args) => {
|
|
4411
|
+
const gone = await run(() => client.fieldRetire({ field_id: args.field_id }), false);
|
|
4412
|
+
if (gone) announce(null);
|
|
4413
|
+
return gone;
|
|
4414
|
+
},
|
|
4315
4415
|
saving,
|
|
4316
4416
|
error,
|
|
4317
4417
|
clearError: () => setError(null)
|
|
4318
4418
|
}),
|
|
4319
|
-
[client, run, saving, error]
|
|
4419
|
+
[client, run, announce, saving, error]
|
|
4320
4420
|
);
|
|
4321
4421
|
}
|
|
4322
4422
|
function useMergeField(key, state) {
|
|
@@ -4829,6 +4929,7 @@ export {
|
|
|
4829
4929
|
portalPath,
|
|
4830
4930
|
publicFormPath,
|
|
4831
4931
|
scopeChip,
|
|
4932
|
+
tableShapeChanged,
|
|
4832
4933
|
useEntityFieldMutation,
|
|
4833
4934
|
useEntityFieldRights,
|
|
4834
4935
|
useEntityFields,
|