@ai-matrx/records 0.77.2 → 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 +15 -0
- package/dist/app-table/index.cjs +94 -5
- 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 +94 -5
- 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 +98 -7
- 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 +98 -7
- 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 +6 -2
- 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 +6 -2
- package/dist/index.js.map +1 -1
- package/dist/memory/index.cjs +6 -1
- 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 +6 -1
- 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 +98 -7
- 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 +98 -7
- 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 +6 -2
- 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 +6 -2
- 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 +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PgError, A as Actor, U as Uuid } from './record-
|
|
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-
|
|
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;
|
package/dist/react/index.cjs
CHANGED
|
@@ -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)
|
|
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) {
|
|
@@ -10832,6 +10921,7 @@ function useStoreTable(table, options = {}) {
|
|
|
10832
10921
|
}
|
|
10833
10922
|
|
|
10834
10923
|
// src/app-table/graduate.ts
|
|
10924
|
+
var import_uuid5 = require("@ai-matrx/kit/uuid");
|
|
10835
10925
|
var TO_CUSTOM_FIELDS = "custom_fields";
|
|
10836
10926
|
var TO_ASSOCIATION = "association";
|
|
10837
10927
|
var GRADUATION_BASE_COLUMNS = [
|
|
@@ -10891,10 +10981,9 @@ function graduationProblems(fields, graduation) {
|
|
|
10891
10981
|
}
|
|
10892
10982
|
return problems;
|
|
10893
10983
|
}
|
|
10894
|
-
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10895
10984
|
function idsOf(value) {
|
|
10896
10985
|
const list = Array.isArray(value) ? value : value === null || value === void 0 ? [] : [value];
|
|
10897
|
-
return list.filter((v) => typeof v === "string" &&
|
|
10986
|
+
return list.filter((v) => typeof v === "string" && (0, import_uuid5.isUuidShape)(v));
|
|
10898
10987
|
}
|
|
10899
10988
|
function graduatedRow(fields, graduation, snapshot) {
|
|
10900
10989
|
const row = {
|
|
@@ -11358,7 +11447,7 @@ function allowsOtherValues(field2) {
|
|
|
11358
11447
|
}
|
|
11359
11448
|
|
|
11360
11449
|
// src/retype.ts
|
|
11361
|
-
var
|
|
11450
|
+
var import_uuid6 = require("@ai-matrx/kit/uuid");
|
|
11362
11451
|
var TRUE_WORDS2 = /* @__PURE__ */ new Set(["true", "t", "yes", "y", "1", "on", "x", "\u2713", "\u2714"]);
|
|
11363
11452
|
var FALSE_WORDS2 = /* @__PURE__ */ new Set(["false", "f", "no", "n", "0", "off", "\u2610"]);
|
|
11364
11453
|
function valueConverts(to, value) {
|
|
@@ -11379,7 +11468,7 @@ function valueConverts(to, value) {
|
|
|
11379
11468
|
return text2.trim() !== "" && /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i.test(text2.trim());
|
|
11380
11469
|
case "list":
|
|
11381
11470
|
case "relation":
|
|
11382
|
-
return typeof value === "string" && (0,
|
|
11471
|
+
return typeof value === "string" && (0, import_uuid6.isUuidShape)(text2);
|
|
11383
11472
|
default:
|
|
11384
11473
|
return false;
|
|
11385
11474
|
}
|
|
@@ -11830,6 +11919,9 @@ function scopeChip(scope) {
|
|
|
11830
11919
|
return scope.title ? `About: ${scope.title}` : "About: this record";
|
|
11831
11920
|
}
|
|
11832
11921
|
|
|
11922
|
+
// src/table-kind.ts
|
|
11923
|
+
var import_uuid7 = require("@ai-matrx/kit/uuid");
|
|
11924
|
+
|
|
11833
11925
|
// src/table-kind-mapping.json
|
|
11834
11926
|
var table_kind_mapping_default = {
|
|
11835
11927
|
about: "THE ONE MAPPING from a store Field to a kind's three schemas (KINDS-GLUE wave 3 \xA72). Hand-written here; aidream copies it verbatim to packages/matrx-graph/matrx_graph/table_kind_mapping.json (scripts/generate_table_kind_mapping.py --check). Both languages derive from this file only: @ai-matrx/records src/table-kind.ts and matrx_graph.table_kinds. Keys of `kinds` are the store's field kinds (custom.field_kinds() plus the formula `system` kinds custom.field_kind_of answers). Stored mode only: `column_source_default` is custom.table_column_source's answer when the facts carry none (silence means the doctrine: Field rows are the columns); `platform_keys` mirrors custom.record_platform_keys() with each key's shape (parent_id: custom.containment_parent's uuid cast; icon: the record's own @ai-matrx/icons name, a string or null); `stored_patterns` mirror custom.validate_values' relation id regex and, for dates, refuse a string the timestamptz cast can never read (no digits, not a special word) while never refusing one it can.",
|
|
@@ -11908,14 +12000,13 @@ var table_kind_mapping_default = {
|
|
|
11908
12000
|
|
|
11909
12001
|
// src/table-kind.ts
|
|
11910
12002
|
var TABLE_KIND_PREFIX = "table:";
|
|
11911
|
-
var UUID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
11912
12003
|
var KIND_KEY = "__kind";
|
|
11913
12004
|
var M = table_kind_mapping_default;
|
|
11914
12005
|
function tableKindMapping() {
|
|
11915
12006
|
return M;
|
|
11916
12007
|
}
|
|
11917
12008
|
function isTableKind(slug) {
|
|
11918
|
-
return typeof slug === "string" && slug.startsWith(TABLE_KIND_PREFIX) &&
|
|
12009
|
+
return typeof slug === "string" && slug.startsWith(TABLE_KIND_PREFIX) && (0, import_uuid7.isLowercaseUuidShape)(slug.slice(TABLE_KIND_PREFIX.length));
|
|
11919
12010
|
}
|
|
11920
12011
|
function tableKindSlug(tableId) {
|
|
11921
12012
|
const slug = `${TABLE_KIND_PREFIX}${String(tableId).trim().toLowerCase()}`;
|