@ai-matrx/records 0.3.0 → 0.4.1
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 +38 -0
- package/dist/core/index.cjs +53 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +35 -3
- package/dist/core/index.d.ts +35 -3
- package/dist/core/index.js +53 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +16 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -1
- package/dist/index.d.ts +67 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +16 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +67 -1
- package/dist/react/index.d.ts +67 -1
- package/dist/react/index.js +16 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog — @ai-matrx/records
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
Carries the live Supabase adapter proof through the shared npm publishing lane
|
|
6
|
+
by supplying its existing main-database HTTP URL and publishable-key secrets to
|
|
7
|
+
the verification step.
|
|
8
|
+
|
|
9
|
+
### Consumer action
|
|
10
|
+
|
|
11
|
+
None beyond taking `latest`; the 0.4.0 API is unchanged.
|
|
12
|
+
|
|
13
|
+
## 0.4.0
|
|
14
|
+
|
|
15
|
+
**The browser can reach the store again — `supabaseDataSource`.** Every screen
|
|
16
|
+
of the record store was dead from a browser, for everybody, and the cause was a
|
|
17
|
+
single silent drop. `RecordsDataSource.rpc(fn, args, { schema })` says the
|
|
18
|
+
schema out loud, because every door is `custom.<name>` and every trust door is
|
|
19
|
+
`iam.<name>`. supabase-js's own `rpc()` has NO schema option — its third
|
|
20
|
+
argument is `{ head, get, count }` — so a host that bound its client as a bare
|
|
21
|
+
structural cast handed the option to a function that dropped it, every door call
|
|
22
|
+
went to PostgREST's default profile, and the store answered, correctly and
|
|
23
|
+
uselessly, `PGRST202 — Could not find the function public.table_kernel_id in the
|
|
24
|
+
schema cache`. Independent verdict, 2026-09-19.
|
|
25
|
+
|
|
26
|
+
The fix is ONE adapter in the headless core, exported from `/core`, that every
|
|
27
|
+
host inherits — never three hosts (web, desktop, extension) each remembering the
|
|
28
|
+
same thing. It routes through `client.schema(name).rpc(...)`, which is the one
|
|
29
|
+
way supabase-js offers, and it refuses two things by name rather than sending
|
|
30
|
+
them: a call with no schema (which would reach `public`), and a client with no
|
|
31
|
+
`.schema()` method (which would throw inside a render).
|
|
32
|
+
|
|
33
|
+
**The test that would have caught it**, `src/__tests__/supabase-adapter.test.ts`:
|
|
34
|
+
a real supabase-js client against the MAIN database, signed in as `test@test.com`,
|
|
35
|
+
calling a real door. A raw `fetch` to `/rest/v1/rpc/...` would NOT have caught
|
|
36
|
+
this — the bug is in supabase-js's option handling, so only a real client
|
|
37
|
+
exercises it. The RED half reconstructs the bare cast that shipped and asserts
|
|
38
|
+
the store's own PGRST202 naming `public`; the GREEN half is the same call
|
|
39
|
+
through the adapter answering the kernel id.
|
|
40
|
+
|
|
3
41
|
## 0.3.0
|
|
4
42
|
|
|
5
43
|
**The anonymous lane, wired to the doors that actually exist.** This package
|
package/dist/core/index.cjs
CHANGED
|
@@ -90,6 +90,7 @@ __export(core_exports, {
|
|
|
90
90
|
predictValueRefusals: () => predictValueRefusals,
|
|
91
91
|
predictWriteRefusals: () => predictWriteRefusals,
|
|
92
92
|
staleWriteDetail: () => staleWriteDetail,
|
|
93
|
+
supabaseDataSource: () => supabaseDataSource,
|
|
93
94
|
toAoa: () => toAoa
|
|
94
95
|
});
|
|
95
96
|
module.exports = __toCommonJS(core_exports);
|
|
@@ -247,6 +248,7 @@ var STORE_DOORS = [
|
|
|
247
248
|
{ 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" },
|
|
248
249
|
{ name: "anon_write", args: "p_secret text, p_origin text, p_payload jsonb, p_client_key text DEFAULT NULL::text, p_raw_payload jsonb DEFAULT '{}'::jsonb", returns: "uuid", security: "definer" },
|
|
249
250
|
{ name: "applicable_fields", args: "p_organization_id uuid, p_table_id uuid, p_record_type text DEFAULT NULL::text", returns: "SETOF custom.record", security: "definer" },
|
|
251
|
+
{ 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" },
|
|
250
252
|
{ name: "assert_client_may_reach", args: "p_organization_id uuid, p_door text", returns: "void", security: "invoker" },
|
|
251
253
|
{ name: "assert_organization_wall", args: "p_kind text, p_organization_id uuid, p_row jsonb", returns: "void", security: "invoker" },
|
|
252
254
|
{ name: "assert_store_door", args: "p_organization_id uuid, p_door text", returns: "void", security: "invoker" },
|
|
@@ -278,6 +280,8 @@ var STORE_DOORS = [
|
|
|
278
280
|
{ name: "doc_token_pattern", args: "", returns: "text", security: "invoker" },
|
|
279
281
|
{ name: "doc_tokens", args: "p_body text", returns: "TABLE(ordinal integer, raw text, field_id uuid)", security: "invoker" },
|
|
280
282
|
{ name: "doc_unresolved_tokens", args: "p_organization_id uuid, p_table_id uuid, p_body text", returns: "TABLE(raw text, field_id uuid, why text)", security: "invoker" },
|
|
283
|
+
{ name: "doors_not_deciding_the_caller", args: "", returns: "TABLE(function_name text, identity_args text)", security: "invoker" },
|
|
284
|
+
{ name: "doors_not_deciding_the_record", args: "", returns: "TABLE(function_name text, identity_args text, why text)", security: "invoker" },
|
|
281
285
|
{ name: "export_records", args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000", returns: "TABLE(id uuid, document jsonb)", security: "invoker" },
|
|
282
286
|
{ name: "external_foreign_table_findings", args: "", returns: "SETOF text", security: "definer" },
|
|
283
287
|
{ name: "external_history_event", args: "p_organization_id uuid, p_link_id uuid, p_operation text", returns: "bigint", security: "definer" },
|
|
@@ -334,12 +338,14 @@ var STORE_DOORS = [
|
|
|
334
338
|
{ name: "migrate_reparent", args: "p_organization_id uuid, p_id uuid, p_parent_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
|
|
335
339
|
{ name: "migrate_retype", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
|
|
336
340
|
{ 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: "invoker" },
|
|
341
|
+
{ name: "organization_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
337
342
|
{ 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" },
|
|
338
343
|
{ name: "parity_field_types", args: "", returns: "TABLE(parity_type text, behavior text, made_of text)", security: "invoker" },
|
|
339
344
|
{ name: "parity_type", args: "p_field_data jsonb", returns: "text", security: "invoker" },
|
|
340
345
|
{ 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" },
|
|
341
346
|
{ name: "per_value_access_words", args: "", returns: "text[]", security: "invoker" },
|
|
342
347
|
{ name: "person_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
348
|
+
{ name: "presentation_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
343
349
|
{ name: "promote_field", args: "p_organization_id uuid, p_table_id uuid, p_field_id uuid", returns: "jsonb", security: "invoker" },
|
|
344
350
|
{ name: "promote_table", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
|
|
345
351
|
{ name: "promoted_field_cap", args: "", returns: "integer", security: "invoker" },
|
|
@@ -435,6 +441,7 @@ var STORE_DOORS = [
|
|
|
435
441
|
{ 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" },
|
|
436
442
|
{ name: "visibility_warm", args: "p_container_type text, p_container_id uuid", returns: "integer", security: "definer" },
|
|
437
443
|
{ name: "visible_record_ids", args: "p_user_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "TABLE(id uuid)", security: "definer" },
|
|
444
|
+
{ name: "widget_kernel_id", args: "", returns: "uuid", security: "invoker" },
|
|
438
445
|
{ name: "work_assignment_fields", args: "p_options_table_id uuid DEFAULT NULL::uuid", returns: "TABLE(key text, label text, spec jsonb)", security: "invoker" },
|
|
439
446
|
{ name: "work_has_assignment", args: "p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "invoker" },
|
|
440
447
|
{ name: "work_instantiation_shape", args: "p_organization_id uuid, p_instantiation_id uuid", returns: "jsonb", security: "invoker" },
|
|
@@ -456,8 +463,17 @@ var STORE_DOORS = [
|
|
|
456
463
|
];
|
|
457
464
|
var STORE_KNOBS = [
|
|
458
465
|
{ key: "accessible_entity_ids_guard", value: "false", type: "boolean" },
|
|
466
|
+
{ key: "agent_schema_changes", value: '"propose"', type: "string" },
|
|
459
467
|
{ key: "associations_guard", value: "false", type: "boolean" },
|
|
460
468
|
{ key: "code_paths_enabled", value: "false", type: "boolean" },
|
|
469
|
+
{ key: "consumer_chat_seeding_enabled", value: "false", type: "boolean" },
|
|
470
|
+
{ key: "consumer_checkout_enabled", value: "false", type: "boolean" },
|
|
471
|
+
{ key: "consumer_education_enabled", value: "false", type: "boolean" },
|
|
472
|
+
{ key: "consumer_extension_enabled", value: "false", type: "boolean" },
|
|
473
|
+
{ key: "consumer_grid_enabled", value: "false", type: "boolean" },
|
|
474
|
+
{ key: "consumer_retirement_enabled", value: "false", type: "boolean" },
|
|
475
|
+
{ key: "consumer_saved_ai_outputs_enabled", value: "false", type: "boolean" },
|
|
476
|
+
{ key: "consumer_scopes_enabled", value: "false", type: "boolean" },
|
|
461
477
|
{ key: "containment_depth_ceiling", value: "16", type: "integer" },
|
|
462
478
|
{ key: "document_max_bytes", value: "1048576", type: "integer" },
|
|
463
479
|
{ key: "emergency_door_guard", value: "false", type: "boolean" },
|
|
@@ -489,7 +505,7 @@ var STORE_REFUSAL_CODES = [
|
|
|
489
505
|
{ code: "23505", raised_by: "doc_sign,doc_signature_write,home_add,io_proposal_accept,work_slot_hold" },
|
|
490
506
|
{ code: "23514", raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_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,_table_shape_guard,_value_envelope,_work_shape_guard,doc_sign,doc_signature_write,doc_template_save,home_add,validate_value_envelope,validate_values,work_slots_declare,work_take_assignment,work_template_instantiate" },
|
|
491
507
|
{ code: "40001", raised_by: "has_visibility_at" },
|
|
492
|
-
{ 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_reach,assert_store_door,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,promote_table,read_record,read_records" },
|
|
508
|
+
{ 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_reach,assert_store_door,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,promote_table,read_record,read_records" },
|
|
493
509
|
{ code: "53400", raised_by: "anon_rate_take,promote_field" },
|
|
494
510
|
{ code: "PT409", raised_by: "record_update" }
|
|
495
511
|
];
|
|
@@ -2560,6 +2576,42 @@ function asWriteConflict(error, recordId) {
|
|
|
2560
2576
|
};
|
|
2561
2577
|
}
|
|
2562
2578
|
|
|
2579
|
+
// src/core/supabase.ts
|
|
2580
|
+
function refuse(code, message, hint) {
|
|
2581
|
+
return { data: null, error: { code, message, hint, details: "" } };
|
|
2582
|
+
}
|
|
2583
|
+
function supabaseDataSource(client) {
|
|
2584
|
+
const supabase = client;
|
|
2585
|
+
const hasSchema = typeof supabase.schema === "function";
|
|
2586
|
+
return {
|
|
2587
|
+
rpc(fn, args, options) {
|
|
2588
|
+
if (!hasSchema) {
|
|
2589
|
+
return Promise.resolve(
|
|
2590
|
+
refuse(
|
|
2591
|
+
"data_source_unbound",
|
|
2592
|
+
`The records client was given something that is not a supabase client: it has no schema() method, so the door ${fn} cannot be called in the schema it lives in.`,
|
|
2593
|
+
"Pass a supabase-js v2 client (createClient(...)) to supabaseDataSource()."
|
|
2594
|
+
)
|
|
2595
|
+
);
|
|
2596
|
+
}
|
|
2597
|
+
const name = options?.schema;
|
|
2598
|
+
if (!name) {
|
|
2599
|
+
return Promise.resolve(
|
|
2600
|
+
refuse(
|
|
2601
|
+
"schema_unsaid",
|
|
2602
|
+
`The door ${fn} was called without saying which schema it lives in. Every door of this store is custom.${fn} and every trust door is iam.${fn}; an unqualified call reaches PostgREST's default profile (public) and is refused there.`,
|
|
2603
|
+
"This is a bug in the caller, not in your data: /core says the schema on every call."
|
|
2604
|
+
)
|
|
2605
|
+
);
|
|
2606
|
+
}
|
|
2607
|
+
return supabase.schema(name).rpc(fn, args);
|
|
2608
|
+
},
|
|
2609
|
+
schema(name) {
|
|
2610
|
+
return supabase.schema(name);
|
|
2611
|
+
}
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2563
2615
|
// src/core/validation.ts
|
|
2564
2616
|
var DEFAULT_VALUE_MAX_BYTES = 1e5;
|
|
2565
2617
|
var DEFAULT_DOCUMENT_MAX_BYTES = 1048576;
|