@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.
- package/CHANGELOG.md +9 -0
- package/dist/app-table/index.cjs +90 -1
- package/dist/app-table/index.cjs.map +1 -1
- package/dist/app-table/index.d.cts +7 -7
- package/dist/app-table/index.d.ts +7 -7
- package/dist/app-table/index.js +90 -1
- package/dist/app-table/index.js.map +1 -1
- package/dist/{client-DZ3UcU4_.d.cts → client-BExNR0TK.d.cts} +5 -5
- package/dist/{client-ZIxyAOdh.d.ts → client-Byn_UthM.d.ts} +5 -5
- package/dist/core/index.cjs +90 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +11 -11
- package/dist/core/index.d.ts +11 -11
- package/dist/core/index.js +90 -1
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +90 -1
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +6 -6
- package/dist/data/index.d.ts +6 -6
- package/dist/data/index.js +90 -1
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-BYZdFrt5.d.cts → declareTable-CgrEusy8.d.cts} +4 -4
- package/dist/{declareTable-DGSJMqGx.d.ts → declareTable-DWOh53eK.d.ts} +4 -4
- package/dist/{field-D7I9yck6.d.ts → field-B2bvpqcE.d.ts} +1 -1
- package/dist/{field-BTW7h7Wh.d.cts → field-t9aefszx.d.cts} +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/index.cjs +2 -0
- package/dist/memory/index.cjs.map +1 -1
- package/dist/memory/index.d.cts +6 -6
- package/dist/memory/index.d.ts +6 -6
- package/dist/memory/index.js +2 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/{ports-CaYEF1dG.d.ts → ports-Ch4Ym0tj.d.ts} +7 -1
- package/dist/{ports-PpvsH1cQ.d.cts → ports-Cjl-IjFa.d.cts} +7 -1
- package/dist/react/index.cjs +90 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +16 -0
- package/dist/react/index.d.ts +16 -0
- package/dist/react/index.js +90 -1
- package/dist/react/index.js.map +1 -1
- package/dist/realtime/index.d.cts +2 -2
- package/dist/realtime/index.d.ts +2 -2
- package/dist/{record-B7iwye2k.d.cts → record-Ba1F1CNS.d.cts} +10 -0
- package/dist/{record-B7iwye2k.d.ts → record-Ba1F1CNS.d.ts} +10 -0
- package/dist/{subscription-BWaRPLyo.d.ts → subscription-CccP6N93.d.ts} +1 -1
- package/dist/{subscription-Br30ZwIt.d.cts → subscription-DGCrwwSR.d.cts} +1 -1
- package/dist/{table-kind-Da21ZLdJ.d.ts → table-kind-BMWi8G37.d.ts} +3 -3
- package/dist/{table-kind-HAQ6WNxZ.d.cts → table-kind-BoelIMjr.d.cts} +3 -3
- package/dist/templates/index.cjs +2 -0
- package/dist/templates/index.cjs.map +1 -1
- package/dist/templates/index.d.cts +9 -9
- package/dist/templates/index.d.ts +9 -9
- package/dist/templates/index.js +2 -0
- package/dist/templates/index.js.map +1 -1
- package/dist/{types-DrJLOqVi.d.ts → types-CiHdoATO.d.ts} +2 -2
- package/dist/{types-DWZ5_3by.d.ts → types-CtyMwJvy.d.ts} +2 -2
- package/dist/{types-DYoWzHwJ.d.cts → types-D-Mhiodh.d.cts} +2 -2
- package/dist/{types-LvxsZ6Zv.d.cts → types-euaQwxnB.d.cts} +2 -2
- package/dist/use-cases/index.cjs.map +1 -1
- package/dist/use-cases/index.d.cts +5 -5
- package/dist/use-cases/index.d.ts +5 -5
- package/dist/use-cases/index.js.map +1 -1
- package/dist/{validate-j0WQoC3C.d.ts → validate-B-p3YPgA.d.ts} +1 -1
- package/dist/{validate-CRdXE73G.d.cts → validate-COvMcv8z.d.cts} +1 -1
- package/package.json +2 -2
package/dist/react/index.d.cts
CHANGED
|
@@ -1504,6 +1504,11 @@ declare const STORE_DOORS: readonly [{
|
|
|
1504
1504
|
readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
|
|
1505
1505
|
readonly returns: "TABLE(kind text, organization_id uuid, organization_name text, item_id uuid, table_id uuid, table_name text, item_row jsonb)";
|
|
1506
1506
|
readonly security: "definer";
|
|
1507
|
+
}, {
|
|
1508
|
+
readonly name: "data_home_slim";
|
|
1509
|
+
readonly args: "p_organization_id uuid DEFAULT NULL::uuid, p_search text DEFAULT NULL::text, p_include_app_tables boolean DEFAULT false";
|
|
1510
|
+
readonly returns: "jsonb";
|
|
1511
|
+
readonly security: "invoker";
|
|
1507
1512
|
}, {
|
|
1508
1513
|
readonly name: "data_home_tables";
|
|
1509
1514
|
readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
|
|
@@ -4404,6 +4409,11 @@ declare const STORE_DOORS: readonly [{
|
|
|
4404
4409
|
readonly args: "p_table_id uuid, p_to_organization_id uuid, p_expected_version integer DEFAULT NULL::integer";
|
|
4405
4410
|
readonly returns: "jsonb";
|
|
4406
4411
|
readonly security: "definer";
|
|
4412
|
+
}, {
|
|
4413
|
+
readonly name: "table_page_bundle";
|
|
4414
|
+
readonly args: "p_organization_id uuid, p_table_id uuid, p_view_id uuid DEFAULT NULL::uuid";
|
|
4415
|
+
readonly returns: "jsonb";
|
|
4416
|
+
readonly security: "invoker";
|
|
4407
4417
|
}, {
|
|
4408
4418
|
readonly name: "table_placement";
|
|
4409
4419
|
readonly args: "p_organization_id uuid, p_table_id uuid, p_data jsonb, p_is_kernel boolean DEFAULT false";
|
|
@@ -11199,6 +11209,12 @@ interface RecordsDataSource {
|
|
|
11199
11209
|
data: unknown;
|
|
11200
11210
|
error: PgError | null;
|
|
11201
11211
|
}>;
|
|
11212
|
+
/**
|
|
11213
|
+
* OPTIONAL. True for the real supabase adapters: the client may open a table page with ONE
|
|
11214
|
+
* `custom.table_page_bundle` call instead of a dozen shape doors one after another (PAGE-BUNDLE).
|
|
11215
|
+
* Leave it off for a test or replay source that does not model the bundle door.
|
|
11216
|
+
*/
|
|
11217
|
+
opensInOneCall?: boolean;
|
|
11202
11218
|
/** Reads of `custom.*` go through the schema-qualified builder, never a bare `from`. */
|
|
11203
11219
|
schema(name: string): {
|
|
11204
11220
|
from(table: string): RecordsTableQuery;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1504,6 +1504,11 @@ declare const STORE_DOORS: readonly [{
|
|
|
1504
1504
|
readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
|
|
1505
1505
|
readonly returns: "TABLE(kind text, organization_id uuid, organization_name text, item_id uuid, table_id uuid, table_name text, item_row jsonb)";
|
|
1506
1506
|
readonly security: "definer";
|
|
1507
|
+
}, {
|
|
1508
|
+
readonly name: "data_home_slim";
|
|
1509
|
+
readonly args: "p_organization_id uuid DEFAULT NULL::uuid, p_search text DEFAULT NULL::text, p_include_app_tables boolean DEFAULT false";
|
|
1510
|
+
readonly returns: "jsonb";
|
|
1511
|
+
readonly security: "invoker";
|
|
1507
1512
|
}, {
|
|
1508
1513
|
readonly name: "data_home_tables";
|
|
1509
1514
|
readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
|
|
@@ -4404,6 +4409,11 @@ declare const STORE_DOORS: readonly [{
|
|
|
4404
4409
|
readonly args: "p_table_id uuid, p_to_organization_id uuid, p_expected_version integer DEFAULT NULL::integer";
|
|
4405
4410
|
readonly returns: "jsonb";
|
|
4406
4411
|
readonly security: "definer";
|
|
4412
|
+
}, {
|
|
4413
|
+
readonly name: "table_page_bundle";
|
|
4414
|
+
readonly args: "p_organization_id uuid, p_table_id uuid, p_view_id uuid DEFAULT NULL::uuid";
|
|
4415
|
+
readonly returns: "jsonb";
|
|
4416
|
+
readonly security: "invoker";
|
|
4407
4417
|
}, {
|
|
4408
4418
|
readonly name: "table_placement";
|
|
4409
4419
|
readonly args: "p_organization_id uuid, p_table_id uuid, p_data jsonb, p_is_kernel boolean DEFAULT false";
|
|
@@ -11199,6 +11209,12 @@ interface RecordsDataSource {
|
|
|
11199
11209
|
data: unknown;
|
|
11200
11210
|
error: PgError | null;
|
|
11201
11211
|
}>;
|
|
11212
|
+
/**
|
|
11213
|
+
* OPTIONAL. True for the real supabase adapters: the client may open a table page with ONE
|
|
11214
|
+
* `custom.table_page_bundle` call instead of a dozen shape doors one after another (PAGE-BUNDLE).
|
|
11215
|
+
* Leave it off for a test or replay source that does not model the bundle door.
|
|
11216
|
+
*/
|
|
11217
|
+
opensInOneCall?: boolean;
|
|
11202
11218
|
/** Reads of `custom.*` go through the schema-qualified builder, never a bare `from`. */
|
|
11203
11219
|
schema(name: string): {
|
|
11204
11220
|
from(table: string): RecordsTableQuery;
|
package/dist/react/index.js
CHANGED
|
@@ -1217,6 +1217,7 @@ var STORE_DOORS = [
|
|
|
1217
1217
|
{ 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" },
|
|
1218
1218
|
{ 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" },
|
|
1219
1219
|
{ 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" },
|
|
1220
|
+
{ 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" },
|
|
1220
1221
|
{ 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" },
|
|
1221
1222
|
{ 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" },
|
|
1222
1223
|
{ name: "declared_conversation", args: "", returns: "uuid", security: "invoker" },
|
|
@@ -1797,6 +1798,7 @@ var STORE_DOORS = [
|
|
|
1797
1798
|
{ name: "table_list_everywhere", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
|
|
1798
1799
|
{ name: "table_list_everywhere", args: "p_organization_id uuid, p_include_app_tables boolean", returns: "jsonb", security: "invoker" },
|
|
1799
1800
|
{ name: "table_move", args: "p_table_id uuid, p_to_organization_id uuid, p_expected_version integer DEFAULT NULL::integer", returns: "jsonb", security: "definer" },
|
|
1801
|
+
{ name: "table_page_bundle", args: "p_organization_id uuid, p_table_id uuid, p_view_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "invoker" },
|
|
1800
1802
|
{ 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" },
|
|
1801
1803
|
{ name: "table_record_ceiling", args: "", returns: "integer", security: "invoker" },
|
|
1802
1804
|
{ name: "table_record_ceiling", args: "p_organization_id uuid", returns: "integer", security: "invoker" },
|
|
@@ -3861,6 +3863,8 @@ function supabaseDataSource(client) {
|
|
|
3861
3863
|
const supabase = client;
|
|
3862
3864
|
const hasSchema = typeof supabase.schema === "function";
|
|
3863
3865
|
const bound = {
|
|
3866
|
+
// PAGE-BUNDLE: the real adapter opens a table page with one `custom.table_page_bundle` call.
|
|
3867
|
+
opensInOneCall: true,
|
|
3864
3868
|
rpc(fn, args, options) {
|
|
3865
3869
|
if (!hasSchema) {
|
|
3866
3870
|
return Promise.resolve(
|
|
@@ -4007,6 +4011,12 @@ function intersectIds(sets) {
|
|
|
4007
4011
|
|
|
4008
4012
|
// src/core/client.ts
|
|
4009
4013
|
var DEFAULT_SCHEMA = "custom";
|
|
4014
|
+
function canonicalArgs(value) {
|
|
4015
|
+
return JSON.stringify(
|
|
4016
|
+
value,
|
|
4017
|
+
(_key, held) => held && typeof held === "object" && !Array.isArray(held) ? Object.fromEntries(Object.keys(held).sort().map((k) => [k, held[k]])) : held
|
|
4018
|
+
);
|
|
4019
|
+
}
|
|
4010
4020
|
var A_PERSONS_REFUSAL = /* @__PURE__ */ new Set([
|
|
4011
4021
|
"refused_by_rule",
|
|
4012
4022
|
"stale_write",
|
|
@@ -4035,7 +4045,83 @@ function createRecordsClient(given) {
|
|
|
4035
4045
|
const schema = config.schema ?? DEFAULT_SCHEMA;
|
|
4036
4046
|
const org = config.organizationId;
|
|
4037
4047
|
const scream = sink(config);
|
|
4048
|
+
const BUNDLE_TTL_MS = 1e4;
|
|
4049
|
+
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"]);
|
|
4050
|
+
const bundleParts = /* @__PURE__ */ new Map();
|
|
4051
|
+
const bundleFlights = /* @__PURE__ */ new Map();
|
|
4052
|
+
const bundleAsked = /* @__PURE__ */ new Map();
|
|
4053
|
+
let bundleKernel = null;
|
|
4054
|
+
const bundleKey = (door, args) => `${door}|${canonicalArgs(args)}`;
|
|
4055
|
+
function bundleTableOf(door, args) {
|
|
4056
|
+
const t = args["p_table_id"];
|
|
4057
|
+
if (door === "read_records_by_ids") {
|
|
4058
|
+
const ids = args["p_record_ids"];
|
|
4059
|
+
return typeof t === "string" && t === bundleKernel && Array.isArray(ids) && ids.length === 1 && typeof ids[0] === "string" ? ids[0] : null;
|
|
4060
|
+
}
|
|
4061
|
+
if (door === "my_levels") {
|
|
4062
|
+
const ids = args["p_ids"];
|
|
4063
|
+
return args["p_type"] === "record" && Array.isArray(ids) && ids.length === 1 && typeof ids[0] === "string" ? ids[0] : null;
|
|
4064
|
+
}
|
|
4065
|
+
return typeof t === "string" ? t : null;
|
|
4066
|
+
}
|
|
4067
|
+
async function fillBundle(tableId, viewId) {
|
|
4068
|
+
try {
|
|
4069
|
+
const response = await config.dataSource.rpc(
|
|
4070
|
+
"table_page_bundle",
|
|
4071
|
+
{ p_organization_id: org, p_table_id: tableId, p_view_id: typeof viewId === "string" ? viewId : null },
|
|
4072
|
+
{ schema }
|
|
4073
|
+
);
|
|
4074
|
+
const answer = response.data;
|
|
4075
|
+
if (response.error || !answer || !Array.isArray(answer.parts)) return;
|
|
4076
|
+
const now = Date.now();
|
|
4077
|
+
for (const part of answer.parts) {
|
|
4078
|
+
if (part.error !== void 0 || part.data === void 0) continue;
|
|
4079
|
+
if (part.door === "table_kernel_id" && typeof part.data === "string") bundleKernel = part.data;
|
|
4080
|
+
bundleParts.set(bundleKey(part.door, part.args), { data: part.data, at: now });
|
|
4081
|
+
}
|
|
4082
|
+
} catch {
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
async function fromBundle(door, args) {
|
|
4086
|
+
if (!config.dataSource.opensInOneCall || !doorReady(config, "table_page_bundle")) return null;
|
|
4087
|
+
const tableId = bundleTableOf(door, args);
|
|
4088
|
+
if (tableId) {
|
|
4089
|
+
const asked = bundleAsked.get(tableId);
|
|
4090
|
+
const fresh = asked !== void 0 && Date.now() - asked < BUNDLE_TTL_MS;
|
|
4091
|
+
if (!fresh && BUNDLE_OPENERS.has(door)) {
|
|
4092
|
+
bundleAsked.set(tableId, Date.now());
|
|
4093
|
+
const flight2 = fillBundle(tableId, door === "grid_layout" ? args["p_view_id"] : null).finally(() => bundleFlights.delete(tableId));
|
|
4094
|
+
bundleFlights.set(tableId, flight2);
|
|
4095
|
+
}
|
|
4096
|
+
const flight = bundleFlights.get(tableId);
|
|
4097
|
+
if (flight) await flight;
|
|
4098
|
+
} else if (door === "table_kernel_id") {
|
|
4099
|
+
if (bundleKernel === null) {
|
|
4100
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
4101
|
+
await Promise.all([...bundleFlights.values()]);
|
|
4102
|
+
}
|
|
4103
|
+
return bundleKernel === null ? null : { data: bundleKernel };
|
|
4104
|
+
} else {
|
|
4105
|
+
return null;
|
|
4106
|
+
}
|
|
4107
|
+
const key = bundleKey(door, args);
|
|
4108
|
+
const held = bundleParts.get(key);
|
|
4109
|
+
if (!held) return null;
|
|
4110
|
+
bundleParts.delete(key);
|
|
4111
|
+
return Date.now() - held.at < BUNDLE_TTL_MS ? { data: held.data } : null;
|
|
4112
|
+
}
|
|
4113
|
+
function bundleDrop(tableId) {
|
|
4114
|
+
if (tableId === null) {
|
|
4115
|
+
bundleParts.clear();
|
|
4116
|
+
bundleAsked.clear();
|
|
4117
|
+
return;
|
|
4118
|
+
}
|
|
4119
|
+
bundleAsked.delete(tableId);
|
|
4120
|
+
for (const key of [...bundleParts.keys()]) if (key.includes(tableId)) bundleParts.delete(key);
|
|
4121
|
+
}
|
|
4038
4122
|
async function callDoor(door, args, where) {
|
|
4123
|
+
const bundled = await fromBundle(door, args);
|
|
4124
|
+
if (bundled) return ok(bundled.data);
|
|
4039
4125
|
if (!doorReady(config, door)) {
|
|
4040
4126
|
const refusal3 = doorAbsent(door);
|
|
4041
4127
|
scream({ code: refusal3.code, message: refusal3.message, ...refusal3.hint ? { hint: refusal3.hint } : {}, where });
|
|
@@ -4050,7 +4136,10 @@ function createRecordsClient(given) {
|
|
|
4050
4136
|
return ok(response.data);
|
|
4051
4137
|
}
|
|
4052
4138
|
function structureMoved(tableId, result) {
|
|
4053
|
-
if (result.ok)
|
|
4139
|
+
if (result.ok) {
|
|
4140
|
+
bundleDrop(tableId);
|
|
4141
|
+
announceTableStructureChanged(tableId);
|
|
4142
|
+
}
|
|
4054
4143
|
return result;
|
|
4055
4144
|
}
|
|
4056
4145
|
async function owedDoor(door, args, where) {
|