@ai-matrx/records 0.6.2 → 0.7.2
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 +68 -0
- package/dist/core/index.cjs +81 -12
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +17 -3
- package/dist/core/index.d.ts +17 -3
- package/dist/core/index.js +81 -12
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +65 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -13
- package/dist/index.d.ts +144 -13
- package/dist/index.js +65 -12
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +108 -12
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +172 -13
- package/dist/react/index.d.ts +172 -13
- package/dist/react/index.js +108 -12
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __export(react_exports, {
|
|
|
38
38
|
ON_DELETE: () => ON_DELETE,
|
|
39
39
|
OVERRIDE_POLICIES: () => OVERRIDE_POLICIES,
|
|
40
40
|
PARITY_FIELD_TYPES: () => PARITY_FIELD_TYPES,
|
|
41
|
+
PERMISSION_LEVELS: () => PERMISSION_LEVELS,
|
|
41
42
|
PER_VALUE_ACCESS_WORDS: () => PER_VALUE_ACCESS_WORDS,
|
|
42
43
|
RELATION_BINDINGS: () => RELATION_BINDINGS,
|
|
43
44
|
RELATION_CARDINALITIES: () => RELATION_CARDINALITIES,
|
|
@@ -55,13 +56,18 @@ __export(react_exports, {
|
|
|
55
56
|
TABLE_TYPES: () => TABLE_TYPES,
|
|
56
57
|
VALUE_ALTERNATE_KEYS: () => VALUE_ALTERNATE_KEYS,
|
|
57
58
|
VALUE_ENVELOPE_KEYS: () => VALUE_ENVELOPE_KEYS,
|
|
59
|
+
asPermissionLevel: () => asPermissionLevel,
|
|
60
|
+
atLeast: () => atLeast,
|
|
58
61
|
err: () => err,
|
|
62
|
+
highestLevel: () => highestLevel,
|
|
59
63
|
isRecordsErr: () => isRecordsErr,
|
|
60
64
|
measureKey: () => measureKey,
|
|
61
65
|
ok: () => ok,
|
|
62
66
|
useFieldMutation: () => useFieldMutation,
|
|
63
67
|
useFields: () => useFields,
|
|
64
68
|
useMergeField: () => useMergeField,
|
|
69
|
+
useMyLevel: () => useMyLevel,
|
|
70
|
+
useMyLevels: () => useMyLevels,
|
|
65
71
|
useRecord: () => useRecord,
|
|
66
72
|
useRecordMutation: () => useRecordMutation,
|
|
67
73
|
useRecords: () => useRecords,
|
|
@@ -75,6 +81,33 @@ module.exports = __toCommonJS(react_exports);
|
|
|
75
81
|
// src/react/context.tsx
|
|
76
82
|
var import_react = require("react");
|
|
77
83
|
|
|
84
|
+
// src/level.ts
|
|
85
|
+
var PERMISSION_LEVELS = [
|
|
86
|
+
"viewer",
|
|
87
|
+
"commenter",
|
|
88
|
+
"editor",
|
|
89
|
+
"admin"
|
|
90
|
+
];
|
|
91
|
+
var ORDINAL = {
|
|
92
|
+
viewer: 1,
|
|
93
|
+
commenter: 2,
|
|
94
|
+
editor: 3,
|
|
95
|
+
admin: 4
|
|
96
|
+
};
|
|
97
|
+
function atLeast(held, needed) {
|
|
98
|
+
if (!held) return false;
|
|
99
|
+
const have = ORDINAL[held];
|
|
100
|
+
return have !== void 0 && have >= ORDINAL[needed];
|
|
101
|
+
}
|
|
102
|
+
function asPermissionLevel(word) {
|
|
103
|
+
return typeof word === "string" && word in ORDINAL ? word : null;
|
|
104
|
+
}
|
|
105
|
+
function highestLevel(left, right) {
|
|
106
|
+
if (!left) return right ?? null;
|
|
107
|
+
if (!right) return left;
|
|
108
|
+
return ORDINAL[left] >= ORDINAL[right] ? left : right;
|
|
109
|
+
}
|
|
110
|
+
|
|
78
111
|
// src/results.ts
|
|
79
112
|
function isRecordsErr(result) {
|
|
80
113
|
return result.ok === false;
|
|
@@ -144,7 +177,9 @@ var STORE_DOORS = [
|
|
|
144
177
|
{ name: "absence_reasons", args: "", returns: "text[]", security: "invoker" },
|
|
145
178
|
{ name: "actor_vocabulary", args: "", returns: "text[]", security: "invoker" },
|
|
146
179
|
{ name: "actor_word", args: "p_declared text", returns: "text", security: "invoker" },
|
|
180
|
+
{ name: "agent_change_approval", args: "p_organization uuid, p_conversation uuid DEFAULT NULL::uuid, p_table uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
|
|
147
181
|
{ name: "agent_context", args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 50", returns: "jsonb", security: "invoker" },
|
|
182
|
+
{ name: "agent_table_claim", args: "p_organization uuid, p_table uuid, p_conversation uuid DEFAULT NULL::uuid", returns: "void", security: "definer" },
|
|
148
183
|
{ name: "agg_assert_key", args: "p_key text", returns: "text", security: "invoker" },
|
|
149
184
|
{ name: "agg_buckets", args: "", returns: "text[]", security: "invoker" },
|
|
150
185
|
{ name: "agg_deliver", args: "p_organization_id uuid, p_rule_id uuid, p_record_id uuid, p_channel text, p_recipient_user_id uuid, p_event_key text, p_subject text, p_body text, p_payload jsonb DEFAULT '{}'::jsonb", returns: "uuid", security: "invoker" },
|
|
@@ -162,6 +197,7 @@ var STORE_DOORS = [
|
|
|
162
197
|
{ name: "anon_inbound_land", args: "p_address text, p_secret text, p_payload jsonb, p_raw_payload jsonb DEFAULT '{}'::jsonb, p_client_key text DEFAULT NULL::text", returns: "uuid", security: "definer" },
|
|
163
198
|
{ name: "anon_publish", args: "p_organization_id uuid, p_form_id uuid, p_published boolean DEFAULT true", returns: "timestamp with time zone", security: "definer" },
|
|
164
199
|
{ name: "anon_rate_take", args: "p_organization_id uuid, p_form_id uuid, p_bucket text, p_token_id uuid DEFAULT NULL::uuid", returns: "integer", security: "definer" },
|
|
200
|
+
{ name: "anon_submissions", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_state text DEFAULT NULL::text, p_limit integer DEFAULT 100, p_offset integer DEFAULT 0", returns: "TABLE(id uuid, form_id uuid, inbound_id uuid, table_id uuid, source text, state text, payload jsonb, raw_payload jsonb, client_key text, record_id uuid, remote_origin text, rejection_reason text, created_at timestamp with time zone, cleared_at timestamp with time zone)", security: "definer" },
|
|
165
201
|
{ name: "anon_token_issue", args: "p_organization_id uuid, p_mode text, p_allowed_origins jsonb, p_form_id uuid DEFAULT NULL::uuid, p_saved_view_id uuid DEFAULT NULL::uuid, p_record_id uuid DEFAULT NULL::uuid, p_expires_at timestamp with time zone DEFAULT NULL::timestamp with time zone", returns: "TABLE(token_id uuid, secret text)", security: "definer" },
|
|
166
202
|
{ name: "anon_token_revoke", args: "p_organization_id uuid, p_token_id uuid", returns: "boolean", security: "definer" },
|
|
167
203
|
{ name: "anon_token_verify", args: "p_secret text, p_origin text, p_required_mode text", returns: "TABLE(token_id uuid, organization_id uuid, form_id uuid, saved_view_id uuid, record_id uuid, mode text)", security: "definer" },
|
|
@@ -177,6 +213,8 @@ var STORE_DOORS = [
|
|
|
177
213
|
{ name: "bump_epoch", args: "p_entity_type text, p_entity_id uuid, p_organization_id uuid DEFAULT NULL::uuid", returns: "bigint", security: "definer" },
|
|
178
214
|
{ name: "cache_lookup", args: "p_container_type text, p_container_id uuid, p_item_type text, p_item_id uuid", returns: "permission_level", security: "definer" },
|
|
179
215
|
{ name: "caller_role", args: "", returns: "name", security: "invoker" },
|
|
216
|
+
{ 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" },
|
|
217
|
+
{ 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" },
|
|
180
218
|
{ name: "client_write_grants", args: "", returns: "TABLE(role_name text, object_name text, privilege text)", security: "invoker" },
|
|
181
219
|
{ 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" },
|
|
182
220
|
{ name: "containment_chain", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(ancestor_id uuid, depth integer)", security: "invoker" },
|
|
@@ -186,6 +224,7 @@ var STORE_DOORS = [
|
|
|
186
224
|
{ name: "cross_organization_links_open", args: "p_source_organization_id uuid, p_target_organization_id uuid", returns: "boolean", security: "invoker" },
|
|
187
225
|
{ name: "custom_fields_tables", args: "", returns: "TABLE(token text, schema_name text, table_name text)", security: "invoker" },
|
|
188
226
|
{ name: "delete_cascade_closure", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid[]", security: "invoker" },
|
|
227
|
+
{ name: "delete_preview", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "definer" },
|
|
189
228
|
{ name: "delete_rule", args: "p_organization_id uuid, p_record_id uuid, p_apply boolean DEFAULT true", returns: "jsonb", security: "definer" },
|
|
190
229
|
{ name: "dependency_cycle", args: "p_organization_id uuid, p_row custom.record", returns: "text[]", security: "invoker" },
|
|
191
230
|
{ name: "dependency_label", args: "p_organization_id uuid, p_node text", returns: "text", security: "invoker" },
|
|
@@ -220,7 +259,7 @@ var STORE_DOORS = [
|
|
|
220
259
|
{ name: "external_writes_set", args: "p_organization_id uuid, p_source_id uuid, p_enabled boolean", returns: "boolean", security: "definer" },
|
|
221
260
|
{ name: "field_behaviour", args: "p_field_data jsonb", returns: "text", security: "invoker" },
|
|
222
261
|
{ name: "field_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
|
|
223
|
-
{ name: "field_dependants", args: "p_organization_id uuid, p_field_id uuid", returns: "TABLE(kind text, dependant_id uuid, label text, how text)", security: "
|
|
262
|
+
{ name: "field_dependants", args: "p_organization_id uuid, p_field_id uuid", returns: "TABLE(kind text, dependant_id uuid, label text, how text)", security: "definer" },
|
|
224
263
|
{ name: "field_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
225
264
|
{ name: "field_options", args: "p_organization_id uuid, p_field_id uuid", returns: "SETOF custom.record", security: "definer" },
|
|
226
265
|
{ name: "field_retire", args: "p_organization_id uuid, p_field_id uuid", returns: "boolean", security: "definer" },
|
|
@@ -229,6 +268,7 @@ var STORE_DOORS = [
|
|
|
229
268
|
{ name: "field_value_convert", args: "p_to jsonb, p_value jsonb", returns: "jsonb", security: "invoker" },
|
|
230
269
|
{ name: "file_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
231
270
|
{ name: "formula_value", args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb, p_values jsonb DEFAULT NULL::jsonb", returns: "jsonb", security: "invoker" },
|
|
271
|
+
{ name: "guard_refusals_are_complete", args: "", returns: "TABLE(guard text, said text)", security: "invoker" },
|
|
232
272
|
{ name: "has_visibility", args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "boolean", security: "definer" },
|
|
233
273
|
{ name: "has_visibility_at", args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level, p_organization_id uuid DEFAULT NULL::uuid, p_min_version bigint DEFAULT NULL::bigint", returns: "boolean", security: "definer" },
|
|
234
274
|
{ name: "hidden_field_notice", args: "p_field custom.record, p_action text DEFAULT 'read'::text", returns: "jsonb", security: "invoker" },
|
|
@@ -260,6 +300,7 @@ var STORE_DOORS = [
|
|
|
260
300
|
{ name: "io_record_changed", args: "", returns: "trigger", security: "definer" },
|
|
261
301
|
{ name: "io_restore", args: "p_organization_id uuid, p_record_id uuid, p_version integer", returns: "integer", security: "definer" },
|
|
262
302
|
{ 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" },
|
|
303
|
+
{ 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" },
|
|
263
304
|
{ name: "lookup_value", args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb", returns: "jsonb", security: "invoker" },
|
|
264
305
|
{ 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" },
|
|
265
306
|
{ 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" },
|
|
@@ -272,9 +313,12 @@ var STORE_DOORS = [
|
|
|
272
313
|
{ 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" },
|
|
273
314
|
{ name: "migrate_rename", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
274
315
|
{ 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" },
|
|
275
|
-
{ name: "migrate_retype", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "
|
|
316
|
+
{ name: "migrate_retype", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
276
317
|
{ name: "migrate_split", args: "p_organization_id uuid, p_record_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
|
|
277
318
|
{ name: "migrate_undo", args: "p_organization_id uuid, p_log_id uuid", returns: "jsonb", security: "definer" },
|
|
319
|
+
{ name: "migrations", args: "p_organization_id uuid, p_target_id uuid DEFAULT NULL::uuid, p_limit integer DEFAULT 100", returns: "TABLE(id uuid, verb text, target_kind text, target_id uuid, note text, applied_at timestamp with time zone, applied_by uuid, undone_at timestamp with time zone)", security: "definer" },
|
|
320
|
+
{ name: "my_level", args: "p_organization_id uuid, p_id uuid, p_type text DEFAULT 'record'::text", returns: "permission_level", security: "definer" },
|
|
321
|
+
{ name: "my_levels", args: "p_organization_id uuid, p_ids jsonb, p_type text DEFAULT 'record'::text", returns: "TABLE(id uuid, level permission_level)", security: "definer" },
|
|
278
322
|
{ name: "organization_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
279
323
|
{ name: "organization_references", args: "p_kind text, p_organization_id uuid, p_row jsonb", returns: "TABLE(site text, what text, ref_id uuid, openable boolean)", security: "invoker" },
|
|
280
324
|
{ name: "owning_table", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid", security: "invoker" },
|
|
@@ -315,11 +359,17 @@ var STORE_DOORS = [
|
|
|
315
359
|
{ name: "query_visibility_parity", args: "p_organization_id uuid", returns: "TABLE(side text, container_type text, container_id uuid, item_type text, item_id uuid, stored_level permission_level, derived_level permission_level, reason text)", security: "definer" },
|
|
316
360
|
{ name: "query_visible_ids", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_required text DEFAULT 'viewer'::text", returns: "SETOF uuid", security: "definer" },
|
|
317
361
|
{ name: "reachable_from", args: "p_organization_id uuid, p_roots uuid[]", returns: "TABLE(record_id uuid, depth integer, via text)", security: "invoker" },
|
|
362
|
+
{ name: "reaches_directly", args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "boolean", security: "definer" },
|
|
363
|
+
{ name: "read_door_carried_ids", args: "p_user uuid, p_organization_id uuid, p_table_id uuid, p_required permission_level, OUT o_ids uuid[], OUT o_containers integer", returns: "record", security: "definer" },
|
|
364
|
+
{ name: "read_door_granted_ids", args: "p_organization_id uuid, p_table_id uuid", returns: "uuid[]", security: "definer" },
|
|
365
|
+
{ name: "read_door_ladder_ceiling", args: "", returns: "integer", security: "invoker" },
|
|
366
|
+
{ name: "read_door_parity", args: "p_organization_id uuid, p_table_id uuid, p_user uuid, p_required permission_level, p_sample integer", returns: "TABLE(record_id uuid, set_based boolean, per_row boolean, verdict text)", security: "definer" },
|
|
318
367
|
{ name: "read_paths_outside_the_door", args: "", returns: "TABLE(object_name text, why text)", security: "invoker" },
|
|
319
368
|
{ name: "read_record", args: "p_organization_id uuid, p_record_id uuid, p_by_id boolean DEFAULT false", returns: "jsonb", security: "definer" },
|
|
320
369
|
{ name: "read_records", args: "p_organization_id uuid, p_table_id uuid, p_by_id boolean DEFAULT false, p_limit integer DEFAULT 200, p_offset integer DEFAULT 0", returns: "TABLE(id uuid, document jsonb, level permission_level)", security: "definer" },
|
|
321
370
|
{ name: "record_aggregate", args: "p_organization_id uuid, p_table_id uuid, p_group_by jsonb DEFAULT '[]'::jsonb, p_measures jsonb DEFAULT '[]'::jsonb, p_bucket jsonb DEFAULT NULL::jsonb, p_filter jsonb DEFAULT '{}'::jsonb, p_limit integer DEFAULT 200, p_required text DEFAULT 'viewer'::text", returns: "TABLE(groups jsonb, measures jsonb, row_count bigint)", security: "definer" },
|
|
322
371
|
{ name: "record_applicability", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(rule_id uuid, rule_name text, rule_version integer, applies boolean, answer jsonb)", security: "invoker" },
|
|
372
|
+
{ name: "record_as_of", args: "p_organization_id uuid, p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(state jsonb, replayed boolean)", security: "definer" },
|
|
323
373
|
{ name: "record_card", args: "p_viewer uuid, p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "definer" },
|
|
324
374
|
{ name: "record_carrying_edges", args: "p_id uuid, p_data_class text, p_data jsonb, p_deleted_at timestamp with time zone", returns: "TABLE(container_id uuid, item_id uuid, edge_role text)", security: "invoker" },
|
|
325
375
|
{ name: "record_delete", args: "p_organization_id uuid, p_record_id uuid", returns: "timestamp with time zone", security: "definer" },
|
|
@@ -359,6 +409,7 @@ var STORE_DOORS = [
|
|
|
359
409
|
{ name: "rule_truth", args: "p_answer jsonb", returns: "boolean", security: "invoker" },
|
|
360
410
|
{ name: "rule_uses", args: "", returns: "text[]", security: "invoker" },
|
|
361
411
|
{ name: "rule_version", args: "p_organization_id uuid, p_rule_id uuid", returns: "integer", security: "invoker" },
|
|
412
|
+
{ name: "said", args: "p_value text, p_when_there_is_none text", returns: "text", security: "invoker" },
|
|
362
413
|
{ name: "share_access", args: "p_organization_id uuid, p_subject_id uuid", returns: "TABLE(principal_kind text, principal_id uuid, principal_label text, level permission_level, reason text, reason_detail text, via_type text, via_id uuid, revocable boolean)", security: "definer" },
|
|
363
414
|
{ name: "share_grant", args: "p_organization_id uuid, p_subject_id uuid, p_principal_kind text, p_principal_id uuid, p_level permission_level DEFAULT 'viewer'::permission_level", returns: "jsonb", security: "definer" },
|
|
364
415
|
{ name: "share_lane_set", args: "p_organization_id uuid, p_subject_id uuid, p_choice text, p_level permission_level DEFAULT NULL::permission_level", returns: "jsonb", security: "definer" },
|
|
@@ -367,6 +418,7 @@ var STORE_DOORS = [
|
|
|
367
418
|
{ name: "share_people", args: "p_organization_id uuid, p_subject_id uuid DEFAULT NULL::uuid, p_query text DEFAULT NULL::text, p_limit integer DEFAULT 25", returns: "TABLE(user_id uuid, email text, display_name text, membership text, already_at permission_level, already_why text)", security: "definer" },
|
|
368
419
|
{ name: "share_revoke", args: "p_organization_id uuid, p_subject_id uuid, p_principal_kind text, p_principal_id uuid", returns: "jsonb", security: "definer" },
|
|
369
420
|
{ name: "share_subject_name", args: "p_organization_id uuid, p_type text, p_id uuid", returns: "text", security: "definer" },
|
|
421
|
+
{ name: "shared_only_disagreements", args: "p_pretend text DEFAULT NULL::text", returns: "TABLE(organization_id uuid, organization_name text, member_id uuid, record_id uuid, table_id uuid, ladder boolean, read_door boolean, rls_mirror boolean, why text)", security: "invoker" },
|
|
370
422
|
{ name: "size_refusal", args: "p_organization_id uuid, p_data jsonb", returns: "text", security: "invoker" },
|
|
371
423
|
{ name: "source_next_pointer", args: "p_sources jsonb", returns: "text", security: "invoker" },
|
|
372
424
|
{ name: "source_pointer", args: "p_sources jsonb, p_source jsonb", returns: "text", security: "invoker" },
|
|
@@ -376,13 +428,14 @@ var STORE_DOORS = [
|
|
|
376
428
|
{ name: "table_capacity", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
|
|
377
429
|
{ name: "table_contents", args: "p_organization_id uuid, p_table_id uuid", returns: "TABLE(record_id uuid, kind text, goes_at integer)", security: "invoker" },
|
|
378
430
|
{ name: "table_declare", args: "p_organization_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
|
|
431
|
+
{ name: "table_has_a_visible_record", args: "p_user uuid, p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "definer" },
|
|
379
432
|
{ name: "table_is_live", args: "p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "invoker" },
|
|
380
433
|
{ name: "table_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
381
434
|
{ name: "table_record_ceiling", args: "", returns: "integer", security: "invoker" },
|
|
382
435
|
{ name: "table_record_ceiling", args: "p_organization_id uuid", returns: "integer", security: "invoker" },
|
|
383
436
|
{ name: "table_rules", args: "p_organization_id uuid, p_table_id uuid, p_use text, p_record_type text DEFAULT NULL::text", returns: "SETOF custom.record", security: "invoker" },
|
|
384
437
|
{ name: "table_storage", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "invoker" },
|
|
385
|
-
{ name: "table_type_field", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "
|
|
438
|
+
{ name: "table_type_field", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "definer" },
|
|
386
439
|
{ name: "tables_at_home", args: "p_organization_id uuid, p_home_ids uuid[]", returns: "TABLE(table_id uuid, home_record_id uuid, kind text)", security: "definer" },
|
|
387
440
|
{ name: "tables_described_without_asking", args: "", returns: "TABLE(function_name text, identity_args text, why text)", security: "invoker" },
|
|
388
441
|
{ name: "trg_associations_bump_visibility", args: "", returns: "trigger", security: "definer" },
|
|
@@ -393,14 +446,16 @@ var STORE_DOORS = [
|
|
|
393
446
|
{ name: "value_envelope_keys", args: "", returns: "text[]", security: "invoker" },
|
|
394
447
|
{ name: "value_envelope_ok", args: "p_data jsonb", returns: "boolean", security: "invoker" },
|
|
395
448
|
{ name: "value_envelope_refusal", args: "p_data jsonb", returns: "text", security: "invoker" },
|
|
396
|
-
{ name: "value_read", args: "p_organization_id uuid, p_record_id uuid, p_key text", 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: "
|
|
449
|
+
{ name: "value_read", args: "p_organization_id uuid, p_record_id uuid, p_key text", 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" },
|
|
397
450
|
{ name: "value_versions", args: "p_old jsonb, p_new jsonb", returns: "jsonb", security: "invoker" },
|
|
398
451
|
{ name: "visibility_ancestors", args: "p_item_type text, p_item_id uuid", returns: "TABLE(container_type text, container_id uuid, depth integer, max_level permission_level)", security: "definer" },
|
|
399
452
|
{ name: "visibility_as_of", args: "p_organization_id uuid, p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(principal_kind text, principal_id uuid, level permission_level, through_kind text, through_id uuid, reason text, replayed boolean, held_from timestamp with time zone, held_to timestamp with time zone)", security: "definer" },
|
|
400
453
|
{ name: "visibility_cache_rebuild", args: "", returns: "integer", security: "definer" },
|
|
401
454
|
{ name: "visibility_parity", args: "", returns: "TABLE(side text, container_type text, container_id uuid, item_type text, item_id uuid, stored_level permission_level, derived_level permission_level, reason text)", security: "definer" },
|
|
402
455
|
{ name: "visibility_warm", args: "p_container_type text, p_container_id uuid", returns: "integer", security: "definer" },
|
|
456
|
+
{ name: "visible_predicate_sql", args: "p_user uuid, p_organization_id uuid, p_table_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level, p_alias text DEFAULT 'r'::text", returns: "text", security: "definer" },
|
|
403
457
|
{ name: "visible_record_ids", args: "p_user_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "TABLE(id uuid)", security: "definer" },
|
|
458
|
+
{ name: "visible_set", args: "p_user uuid, p_organization_id uuid, p_table_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level, OUT o_all_visible boolean, OUT o_true_visibility platform.visibility[], OUT o_granted_all uuid[], OUT o_granted_visible uuid[], OUT o_carried_visible uuid[], OUT o_ladder_calls integer, OUT o_fallback boolean, OUT o_note text", returns: "record", security: "definer" },
|
|
404
459
|
{ name: "widget_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
405
460
|
{ name: "work_assignment_fields", args: "p_options_table_id uuid DEFAULT NULL::uuid", returns: "TABLE(key text, label text, spec jsonb)", security: "invoker" },
|
|
406
461
|
{ name: "work_has_assignment", args: "p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "invoker" },
|
|
@@ -422,9 +477,9 @@ var STORE_DOORS = [
|
|
|
422
477
|
{ name: "work_whose_turn", args: "p_organization_id uuid, p_table_id uuid, p_include_finished boolean DEFAULT false", returns: "TABLE(record_id uuid, title text, assignee_id uuid, turn text, due_on timestamp with time zone, state text, status text, terminal boolean)", security: "invoker" }
|
|
423
478
|
];
|
|
424
479
|
var STORE_KNOBS = [
|
|
425
|
-
{ key: "accessible_entity_ids_guard", value: "
|
|
426
|
-
{ key: "agent_schema_changes", value: '"
|
|
427
|
-
{ key: "associations_guard", value: "
|
|
480
|
+
{ key: "accessible_entity_ids_guard", value: "true", type: "boolean" },
|
|
481
|
+
{ key: "agent_schema_changes", value: '"ask"', type: "string" },
|
|
482
|
+
{ key: "associations_guard", value: "true", type: "boolean" },
|
|
428
483
|
{ key: "code_paths_enabled", value: "false", type: "boolean" },
|
|
429
484
|
{ key: "consumer_chat_seeding_enabled", value: "false", type: "boolean" },
|
|
430
485
|
{ key: "consumer_checkout_enabled", value: "false", type: "boolean" },
|
|
@@ -444,7 +499,7 @@ var STORE_KNOBS = [
|
|
|
444
499
|
{ key: "external_principal_enabled", value: "false", type: "boolean" },
|
|
445
500
|
{ key: "field_index_guard", value: "false", type: "boolean" },
|
|
446
501
|
{ key: "field_sensitivity_levels", value: '{"edit": {"public": "editor", "internal": "editor", "restricted": "admin", "confidential": "admin"}, "read": {"public": "viewer", "internal": "viewer", "restricted": "admin", "confidential": "editor"}}', type: "json" },
|
|
447
|
-
{ key: "member_default_level", value: '"viewer"', type: "
|
|
502
|
+
{ key: "member_default_level", value: '"viewer"', type: "enum" },
|
|
448
503
|
{ key: "member_default_visibility", value: '"all_records"', type: "enum" },
|
|
449
504
|
{ key: "records_tool_default", value: "true", type: "boolean" },
|
|
450
505
|
{ key: "row_versions_guard", value: "false", type: "boolean" },
|
|
@@ -463,12 +518,12 @@ var STORE_REFUSAL_CODES = [
|
|
|
463
518
|
{ 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_slots_declare" },
|
|
464
519
|
{ code: "22004", raised_by: "_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,home_add,io_comment_write,io_import_open,io_outbox_drain,io_restore,migrate_purge,migrate_split,migrate_undo,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,relation_carry,relation_own,share_grant,table_declare,work_template_declare" },
|
|
465
520
|
{ code: "22012", raised_by: "rule_eval" },
|
|
466
|
-
{ code: "22023", raised_by: "_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,external_history_event,external_source_declare,external_stub_upsert,external_write_through,io_import_open,io_proposal_accept,migrate_merge,query_by_coordinates,query_rollup,record_update,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,table_rules,visibility_as_of,work_slot_hold" },
|
|
521
|
+
{ code: "22023", raised_by: "_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,external_history_event,external_source_declare,external_stub_upsert,external_write_through,io_import_open,io_proposal_accept,migrate_merge,my_levels,query_by_coordinates,query_rollup,record_update,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,table_rules,visibility_as_of,work_slot_hold" },
|
|
467
522
|
{ code: "23503", raised_by: "_containment_guard,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,delete_rule,doc_sign,doc_template_save,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_eval,rule_members,rule_run,work_take_assignment,work_template_instantiate" },
|
|
468
|
-
{ code: "23505", raised_by: "doc_sign,doc_signature_write,field_declare,home_add,io_proposal_accept,relation_carry,relation_own,share_grant,work_slot_hold" },
|
|
469
|
-
{ code: "23514", raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_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,_rule_shape_guard,_rule_topology_guard,_store_relation_edge_names_its_field,_table_shape_guard,_value_envelope,_work_shape_guard,doc_sign,doc_signature_write,doc_template_save,field_declare,field_retire,field_update,home_add,migrate_merge,relation_carry,relation_own,validate_value_envelope,validate_values,work_slots_declare,work_take_assignment,work_template_instantiate" },
|
|
523
|
+
{ code: "23505", raised_by: "_unique_rule_holds,doc_sign,doc_signature_write,field_declare,home_add,io_proposal_accept,relation_carry,relation_own,share_grant,work_slot_hold" },
|
|
524
|
+
{ code: "23514", raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_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,doc_sign,doc_signature_write,doc_template_save,field_declare,field_retire,field_update,home_add,migrate_merge,relation_carry,relation_own,validate_value_envelope,validate_values,work_slots_declare,work_take_assignment,work_template_instantiate" },
|
|
470
525
|
{ code: "40001", raised_by: "has_visibility_at" },
|
|
471
|
-
{ 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_organization_admin,assert_store_door,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,promote_table,query_visibility_parity,read_record,read_records,share_grant,visibility_as_of" },
|
|
526
|
+
{ 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,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,my_levels,promote_table,query_visibility_parity,read_record,read_records,share_grant,visibility_as_of" },
|
|
472
527
|
{ code: "53400", raised_by: "anon_rate_take,delete_cascade_closure,promote_field" },
|
|
473
528
|
{ code: "54001", raised_by: "record_delete" },
|
|
474
529
|
{ code: "PT409", raised_by: "record_update" }
|
|
@@ -1590,6 +1645,10 @@ var DOORS = {
|
|
|
1590
1645
|
recordReparent: "record_reparent",
|
|
1591
1646
|
containmentChain: "containment_chain",
|
|
1592
1647
|
storeIsOpen: "store_is_open",
|
|
1648
|
+
// DOOR-1, from the screen's side. What level the CALLER holds on the subjects
|
|
1649
|
+
// they name — the one question a screen has to answer BEFORE it draws a
|
|
1650
|
+
// control, and the only one the store had no client answer to.
|
|
1651
|
+
myLevels: "my_levels",
|
|
1593
1652
|
// DOOR-11. The record's own revision list. A screen that offers an optimistic
|
|
1594
1653
|
// save needs the version it LOADED, and the read door answers documents, not
|
|
1595
1654
|
// versions — so the version comes from here, once, for the one record being
|
|
@@ -2574,6 +2633,18 @@ function createRecordsClient(config) {
|
|
|
2574
2633
|
},
|
|
2575
2634
|
async storeIsOpen() {
|
|
2576
2635
|
return callDoor(DOORS.storeIsOpen, { p_organization_id: org }, "storeIsOpen");
|
|
2636
|
+
},
|
|
2637
|
+
async myLevels({ ids, subject }) {
|
|
2638
|
+
if (ids.length === 0) return ok([]);
|
|
2639
|
+
const answered = await callDoor(
|
|
2640
|
+
DOORS.myLevels,
|
|
2641
|
+
{ p_organization_id: org, p_ids: ids, p_type: subject ?? "record" },
|
|
2642
|
+
"myLevels"
|
|
2643
|
+
);
|
|
2644
|
+
if (!answered.ok) return err(answered.error);
|
|
2645
|
+
return ok(
|
|
2646
|
+
(answered.data ?? []).map((row) => ({ id: row.id, level: asPermissionLevel(row.level) }))
|
|
2647
|
+
);
|
|
2577
2648
|
}
|
|
2578
2649
|
};
|
|
2579
2650
|
return client;
|
|
@@ -2668,6 +2739,31 @@ function useTable(tableId) {
|
|
|
2668
2739
|
function useTables() {
|
|
2669
2740
|
return useAsync((client) => client.tableList(), []);
|
|
2670
2741
|
}
|
|
2742
|
+
function useMyLevels(ids) {
|
|
2743
|
+
const key = ids.join(",");
|
|
2744
|
+
return useAsync(
|
|
2745
|
+
async (client) => {
|
|
2746
|
+
const asked = key === "" ? [] : key.split(",");
|
|
2747
|
+
const answered = await client.myLevels({ ids: asked });
|
|
2748
|
+
if (!answered.ok) return answered;
|
|
2749
|
+
const held = {};
|
|
2750
|
+
for (const row of answered.data) held[row.id] = row.level;
|
|
2751
|
+
return { ok: true, data: held };
|
|
2752
|
+
},
|
|
2753
|
+
[key]
|
|
2754
|
+
);
|
|
2755
|
+
}
|
|
2756
|
+
function useMyLevel(id) {
|
|
2757
|
+
return useAsync(
|
|
2758
|
+
async (client) => {
|
|
2759
|
+
if (!id) return { ok: true, data: null };
|
|
2760
|
+
const answered = await client.myLevels({ ids: [id] });
|
|
2761
|
+
if (!answered.ok) return answered;
|
|
2762
|
+
return { ok: true, data: answered.data[0]?.level ?? null };
|
|
2763
|
+
},
|
|
2764
|
+
[id]
|
|
2765
|
+
);
|
|
2766
|
+
}
|
|
2671
2767
|
function useFields(tableId, recordType) {
|
|
2672
2768
|
return useAsync(
|
|
2673
2769
|
async (client) => {
|