@ai-matrx/records 0.57.1 → 0.57.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.
@@ -3163,6 +3163,7 @@ var STORE_DOORS = [
3163
3163
  { name: "table_declare", args: "p_organization_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
3164
3164
  { name: "table_decorate", args: "p_organization_id uuid, p_table_id uuid, p_path text[], p_value jsonb DEFAULT NULL::jsonb", returns: "jsonb", security: "definer" },
3165
3165
  { name: "table_decorations", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
3166
+ { name: "table_facts", args: "p_organization_id uuid", returns: "TABLE(table_id uuid, visibility text, mine boolean)", security: "definer" },
3166
3167
  { name: "table_from_example", args: "p_organization_id uuid, p_home_id uuid, p_example jsonb", returns: "jsonb", security: "definer" },
3167
3168
  { name: "table_has_a_visible_record", args: "p_user uuid, p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "definer" },
3168
3169
  { name: "table_is_live", args: "p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "invoker" },
@@ -4658,6 +4659,7 @@ var DOORS = {
4658
4659
  // everywhere in that organization. This is the one question the rail has to
4659
4660
  // ask, under the same wall and visibility gate as `portals` itself.
4660
4661
  portalTables: "portal_tables",
4662
+ tableFacts: "table_facts",
4661
4663
  portalCard: "portal_card",
4662
4664
  portalDeclare: "portal_declare",
4663
4665
  portalInvite: "portal_invite",
@@ -5465,6 +5467,23 @@ function createRecordsClient(config) {
5465
5467
  const { document } = unfold(row.document);
5466
5468
  return { ...document, id: row.id, organization_id: org };
5467
5469
  });
5470
+ if (doorExists(DOORS.tableFacts)) {
5471
+ const facts = await callDoor(
5472
+ DOORS.tableFacts,
5473
+ { p_organization_id: org },
5474
+ "tableList.facts"
5475
+ );
5476
+ if (facts.ok) {
5477
+ const byId = new Map((facts.data ?? []).map((f) => [f.table_id, f]));
5478
+ const me = config.actor.user_id ?? null;
5479
+ for (const table of tables) {
5480
+ const fact = byId.get(table.id);
5481
+ if (!fact) continue;
5482
+ table.visibility = fact.visibility;
5483
+ if (fact.mine && me) table.created_by = me;
5484
+ }
5485
+ }
5486
+ }
5468
5487
  tables.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
5469
5488
  return ok(tables);
5470
5489
  },