@ai-matrx/records 0.77.3 → 0.78.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/app-table/index.cjs +90 -1
  3. package/dist/app-table/index.cjs.map +1 -1
  4. package/dist/app-table/index.d.cts +7 -7
  5. package/dist/app-table/index.d.ts +7 -7
  6. package/dist/app-table/index.js +90 -1
  7. package/dist/app-table/index.js.map +1 -1
  8. package/dist/{client-DZ3UcU4_.d.cts → client-BExNR0TK.d.cts} +5 -5
  9. package/dist/{client-ZIxyAOdh.d.ts → client-Byn_UthM.d.ts} +5 -5
  10. package/dist/core/index.cjs +90 -1
  11. package/dist/core/index.cjs.map +1 -1
  12. package/dist/core/index.d.cts +11 -11
  13. package/dist/core/index.d.ts +11 -11
  14. package/dist/core/index.js +90 -1
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/data/index.cjs +90 -1
  17. package/dist/data/index.cjs.map +1 -1
  18. package/dist/data/index.d.cts +6 -6
  19. package/dist/data/index.d.ts +6 -6
  20. package/dist/data/index.js +90 -1
  21. package/dist/data/index.js.map +1 -1
  22. package/dist/{declareTable-BYZdFrt5.d.cts → declareTable-CgrEusy8.d.cts} +4 -4
  23. package/dist/{declareTable-DGSJMqGx.d.ts → declareTable-DWOh53eK.d.ts} +4 -4
  24. package/dist/{field-D7I9yck6.d.ts → field-B2bvpqcE.d.ts} +1 -1
  25. package/dist/{field-BTW7h7Wh.d.cts → field-t9aefszx.d.cts} +1 -1
  26. package/dist/index.cjs +2 -0
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +7 -7
  29. package/dist/index.d.ts +7 -7
  30. package/dist/index.js +2 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/memory/index.cjs +2 -0
  33. package/dist/memory/index.cjs.map +1 -1
  34. package/dist/memory/index.d.cts +6 -6
  35. package/dist/memory/index.d.ts +6 -6
  36. package/dist/memory/index.js +2 -0
  37. package/dist/memory/index.js.map +1 -1
  38. package/dist/{ports-CaYEF1dG.d.ts → ports-Ch4Ym0tj.d.ts} +7 -1
  39. package/dist/{ports-PpvsH1cQ.d.cts → ports-Cjl-IjFa.d.cts} +7 -1
  40. package/dist/react/index.cjs +90 -1
  41. package/dist/react/index.cjs.map +1 -1
  42. package/dist/react/index.d.cts +16 -0
  43. package/dist/react/index.d.ts +16 -0
  44. package/dist/react/index.js +90 -1
  45. package/dist/react/index.js.map +1 -1
  46. package/dist/realtime/index.d.cts +2 -2
  47. package/dist/realtime/index.d.ts +2 -2
  48. package/dist/{record-B7iwye2k.d.cts → record-Ba1F1CNS.d.cts} +10 -0
  49. package/dist/{record-B7iwye2k.d.ts → record-Ba1F1CNS.d.ts} +10 -0
  50. package/dist/{subscription-BWaRPLyo.d.ts → subscription-CccP6N93.d.ts} +1 -1
  51. package/dist/{subscription-Br30ZwIt.d.cts → subscription-DGCrwwSR.d.cts} +1 -1
  52. package/dist/{table-kind-Da21ZLdJ.d.ts → table-kind-BMWi8G37.d.ts} +3 -3
  53. package/dist/{table-kind-HAQ6WNxZ.d.cts → table-kind-BoelIMjr.d.cts} +3 -3
  54. package/dist/templates/index.cjs +2 -0
  55. package/dist/templates/index.cjs.map +1 -1
  56. package/dist/templates/index.d.cts +9 -9
  57. package/dist/templates/index.d.ts +9 -9
  58. package/dist/templates/index.js +2 -0
  59. package/dist/templates/index.js.map +1 -1
  60. package/dist/{types-DrJLOqVi.d.ts → types-CiHdoATO.d.ts} +2 -2
  61. package/dist/{types-DWZ5_3by.d.ts → types-CtyMwJvy.d.ts} +2 -2
  62. package/dist/{types-DYoWzHwJ.d.cts → types-D-Mhiodh.d.cts} +2 -2
  63. package/dist/{types-LvxsZ6Zv.d.cts → types-euaQwxnB.d.cts} +2 -2
  64. package/dist/use-cases/index.cjs.map +1 -1
  65. package/dist/use-cases/index.d.cts +5 -5
  66. package/dist/use-cases/index.d.ts +5 -5
  67. package/dist/use-cases/index.js.map +1 -1
  68. package/dist/{validate-j0WQoC3C.d.ts → validate-B-p3YPgA.d.ts} +1 -1
  69. package/dist/{validate-CRdXE73G.d.cts → validate-COvMcv8z.d.cts} +1 -1
  70. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { P as PgError, A as Actor, U as Uuid } from './record-B7iwye2k.js';
1
+ import { P as PgError, A as Actor, U as Uuid } from './record-Ba1F1CNS.js';
2
2
 
3
3
  /**
4
4
  * The data seam: a structural subset of `SupabaseClient`. The package never
@@ -29,6 +29,12 @@ interface RecordsDataSource {
29
29
  data: unknown;
30
30
  error: PgError | null;
31
31
  }>;
32
+ /**
33
+ * OPTIONAL. True for the real supabase adapters: the client may open a table page with ONE
34
+ * `custom.table_page_bundle` call instead of a dozen shape doors one after another (PAGE-BUNDLE).
35
+ * Leave it off for a test or replay source that does not model the bundle door.
36
+ */
37
+ opensInOneCall?: boolean;
32
38
  /** Reads of `custom.*` go through the schema-qualified builder, never a bare `from`. */
33
39
  schema(name: string): {
34
40
  from(table: string): RecordsTableQuery;
@@ -1,4 +1,4 @@
1
- import { P as PgError, A as Actor, U as Uuid } from './record-B7iwye2k.cjs';
1
+ import { P as PgError, A as Actor, U as Uuid } from './record-Ba1F1CNS.cjs';
2
2
 
3
3
  /**
4
4
  * The data seam: a structural subset of `SupabaseClient`. The package never
@@ -29,6 +29,12 @@ interface RecordsDataSource {
29
29
  data: unknown;
30
30
  error: PgError | null;
31
31
  }>;
32
+ /**
33
+ * OPTIONAL. True for the real supabase adapters: the client may open a table page with ONE
34
+ * `custom.table_page_bundle` call instead of a dozen shape doors one after another (PAGE-BUNDLE).
35
+ * Leave it off for a test or replay source that does not model the bundle door.
36
+ */
37
+ opensInOneCall?: boolean;
32
38
  /** Reads of `custom.*` go through the schema-qualified builder, never a bare `from`. */
33
39
  schema(name: string): {
34
40
  from(table: string): RecordsTableQuery;
@@ -1499,6 +1499,7 @@ var STORE_DOORS = [
1499
1499
  { name: "data_home", args: "p_organization_id uuid DEFAULT NULL::uuid, p_search text DEFAULT NULL::text, p_include_app_tables boolean DEFAULT false", returns: "jsonb", security: "definer" },
1500
1500
  { name: "data_home_changed_by", args: "p_asks jsonb", returns: "TABLE(organization_id uuid, id uuid, at timestamp with time zone, who text)", security: "definer" },
1501
1501
  { name: "data_home_items", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "TABLE(kind text, organization_id uuid, organization_name text, item_id uuid, table_id uuid, table_name text, item_row jsonb)", security: "definer" },
1502
+ { name: "data_home_slim", args: "p_organization_id uuid DEFAULT NULL::uuid, p_search text DEFAULT NULL::text, p_include_app_tables boolean DEFAULT false", returns: "jsonb", security: "invoker" },
1502
1503
  { name: "data_home_tables", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "TABLE(table_id uuid, table_name text, organization_id uuid, organization_name text, member boolean, visibility text, updated_at timestamp with time zone, mine boolean, shared_with_me boolean, kept_by_the_app boolean, kind text, team boolean, system boolean, created_by uuid)", security: "definer" },
1503
1504
  { name: "data_home_tables", args: "p_organization_id uuid, p_include_app_tables boolean", returns: "TABLE(table_id uuid, table_name text, organization_id uuid, organization_name text, member boolean, visibility text, updated_at timestamp with time zone, mine boolean, shared_with_me boolean, kept_by_the_app boolean, kind text, team boolean, system boolean, created_by uuid)", security: "invoker" },
1504
1505
  { name: "declared_conversation", args: "", returns: "uuid", security: "invoker" },
@@ -2079,6 +2080,7 @@ var STORE_DOORS = [
2079
2080
  { name: "table_list_everywhere", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
2080
2081
  { name: "table_list_everywhere", args: "p_organization_id uuid, p_include_app_tables boolean", returns: "jsonb", security: "invoker" },
2081
2082
  { name: "table_move", args: "p_table_id uuid, p_to_organization_id uuid, p_expected_version integer DEFAULT NULL::integer", returns: "jsonb", security: "definer" },
2083
+ { name: "table_page_bundle", args: "p_organization_id uuid, p_table_id uuid, p_view_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "invoker" },
2082
2084
  { name: "table_placement", args: "p_organization_id uuid, p_table_id uuid, p_data jsonb, p_is_kernel boolean DEFAULT false", returns: "jsonb", security: "invoker" },
2083
2085
  { name: "table_record_ceiling", args: "", returns: "integer", security: "invoker" },
2084
2086
  { name: "table_record_ceiling", args: "p_organization_id uuid", returns: "integer", security: "invoker" },
@@ -4143,6 +4145,8 @@ function supabaseDataSource(client) {
4143
4145
  const supabase = client;
4144
4146
  const hasSchema = typeof supabase.schema === "function";
4145
4147
  const bound = {
4148
+ // PAGE-BUNDLE: the real adapter opens a table page with one `custom.table_page_bundle` call.
4149
+ opensInOneCall: true,
4146
4150
  rpc(fn, args, options) {
4147
4151
  if (!hasSchema) {
4148
4152
  return Promise.resolve(
@@ -4289,6 +4293,12 @@ function intersectIds(sets) {
4289
4293
 
4290
4294
  // src/core/client.ts
4291
4295
  var DEFAULT_SCHEMA = "custom";
4296
+ function canonicalArgs(value) {
4297
+ return JSON.stringify(
4298
+ value,
4299
+ (_key, held) => held && typeof held === "object" && !Array.isArray(held) ? Object.fromEntries(Object.keys(held).sort().map((k) => [k, held[k]])) : held
4300
+ );
4301
+ }
4292
4302
  var A_PERSONS_REFUSAL = /* @__PURE__ */ new Set([
4293
4303
  "refused_by_rule",
4294
4304
  "stale_write",
@@ -4317,7 +4327,83 @@ function createRecordsClient(given) {
4317
4327
  const schema = config.schema ?? DEFAULT_SCHEMA;
4318
4328
  const org = config.organizationId;
4319
4329
  const scream = sink(config);
4330
+ const BUNDLE_TTL_MS = 1e4;
4331
+ const BUNDLE_OPENERS = /* @__PURE__ */ new Set(["applicable_fields", "views", "view_look_read", "table_decorations", "row_actions", "reverse_columns", "record_change_actions", "grid_layout", "io_imports"]);
4332
+ const bundleParts = /* @__PURE__ */ new Map();
4333
+ const bundleFlights = /* @__PURE__ */ new Map();
4334
+ const bundleAsked = /* @__PURE__ */ new Map();
4335
+ let bundleKernel = null;
4336
+ const bundleKey = (door, args) => `${door}|${canonicalArgs(args)}`;
4337
+ function bundleTableOf(door, args) {
4338
+ const t = args["p_table_id"];
4339
+ if (door === "read_records_by_ids") {
4340
+ const ids = args["p_record_ids"];
4341
+ return typeof t === "string" && t === bundleKernel && Array.isArray(ids) && ids.length === 1 && typeof ids[0] === "string" ? ids[0] : null;
4342
+ }
4343
+ if (door === "my_levels") {
4344
+ const ids = args["p_ids"];
4345
+ return args["p_type"] === "record" && Array.isArray(ids) && ids.length === 1 && typeof ids[0] === "string" ? ids[0] : null;
4346
+ }
4347
+ return typeof t === "string" ? t : null;
4348
+ }
4349
+ async function fillBundle(tableId, viewId) {
4350
+ try {
4351
+ const response = await config.dataSource.rpc(
4352
+ "table_page_bundle",
4353
+ { p_organization_id: org, p_table_id: tableId, p_view_id: typeof viewId === "string" ? viewId : null },
4354
+ { schema }
4355
+ );
4356
+ const answer = response.data;
4357
+ if (response.error || !answer || !Array.isArray(answer.parts)) return;
4358
+ const now = Date.now();
4359
+ for (const part of answer.parts) {
4360
+ if (part.error !== void 0 || part.data === void 0) continue;
4361
+ if (part.door === "table_kernel_id" && typeof part.data === "string") bundleKernel = part.data;
4362
+ bundleParts.set(bundleKey(part.door, part.args), { data: part.data, at: now });
4363
+ }
4364
+ } catch {
4365
+ }
4366
+ }
4367
+ async function fromBundle(door, args) {
4368
+ if (!config.dataSource.opensInOneCall || !doorReady(config, "table_page_bundle")) return null;
4369
+ const tableId = bundleTableOf(door, args);
4370
+ if (tableId) {
4371
+ const asked = bundleAsked.get(tableId);
4372
+ const fresh = asked !== void 0 && Date.now() - asked < BUNDLE_TTL_MS;
4373
+ if (!fresh && BUNDLE_OPENERS.has(door)) {
4374
+ bundleAsked.set(tableId, Date.now());
4375
+ const flight2 = fillBundle(tableId, door === "grid_layout" ? args["p_view_id"] : null).finally(() => bundleFlights.delete(tableId));
4376
+ bundleFlights.set(tableId, flight2);
4377
+ }
4378
+ const flight = bundleFlights.get(tableId);
4379
+ if (flight) await flight;
4380
+ } else if (door === "table_kernel_id") {
4381
+ if (bundleKernel === null) {
4382
+ await new Promise((resolve) => setTimeout(resolve, 0));
4383
+ await Promise.all([...bundleFlights.values()]);
4384
+ }
4385
+ return bundleKernel === null ? null : { data: bundleKernel };
4386
+ } else {
4387
+ return null;
4388
+ }
4389
+ const key = bundleKey(door, args);
4390
+ const held = bundleParts.get(key);
4391
+ if (!held) return null;
4392
+ bundleParts.delete(key);
4393
+ return Date.now() - held.at < BUNDLE_TTL_MS ? { data: held.data } : null;
4394
+ }
4395
+ function bundleDrop(tableId) {
4396
+ if (tableId === null) {
4397
+ bundleParts.clear();
4398
+ bundleAsked.clear();
4399
+ return;
4400
+ }
4401
+ bundleAsked.delete(tableId);
4402
+ for (const key of [...bundleParts.keys()]) if (key.includes(tableId)) bundleParts.delete(key);
4403
+ }
4320
4404
  async function callDoor(door, args, where) {
4405
+ const bundled = await fromBundle(door, args);
4406
+ if (bundled) return ok(bundled.data);
4321
4407
  if (!doorReady(config, door)) {
4322
4408
  const refusal3 = doorAbsent(door);
4323
4409
  scream({ code: refusal3.code, message: refusal3.message, ...refusal3.hint ? { hint: refusal3.hint } : {}, where });
@@ -4332,7 +4418,10 @@ function createRecordsClient(given) {
4332
4418
  return ok(response.data);
4333
4419
  }
4334
4420
  function structureMoved(tableId, result) {
4335
- if (result.ok) announceTableStructureChanged(tableId);
4421
+ if (result.ok) {
4422
+ bundleDrop(tableId);
4423
+ announceTableStructureChanged(tableId);
4424
+ }
4336
4425
  return result;
4337
4426
  }
4338
4427
  async function owedDoor(door, args, where) {