@ai-matrx/records 0.92.1 → 0.93.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 +43 -0
- package/README.md +4 -4
- package/dist/{client-Dzd8gtAo.d.ts → client-DsPuWFp0.d.ts} +8 -8
- package/dist/{client-Cn3odIIB.d.cts → client-EyD3rS0T.d.cts} +8 -8
- package/dist/core/index.cjs +101 -32
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +16 -15
- package/dist/core/index.d.ts +16 -15
- package/dist/core/index.js +101 -32
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +46 -24
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +11 -11
- package/dist/data/index.d.ts +11 -11
- package/dist/data/index.js +46 -24
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-CrL6AZKB.d.cts → declareTable-Bkk_Ewib.d.cts} +4 -4
- package/dist/{declareTable-ZRW5EsTQ.d.ts → declareTable-kL5qZoTe.d.ts} +4 -4
- package/dist/entity/index.cjs +43 -29
- package/dist/entity/index.cjs.map +1 -1
- package/dist/entity/index.d.cts +7 -6
- package/dist/entity/index.d.ts +7 -6
- package/dist/entity/index.js +43 -29
- package/dist/entity/index.js.map +1 -1
- package/dist/entity/react.cjs +43 -29
- package/dist/entity/react.cjs.map +1 -1
- package/dist/entity/react.js +43 -29
- package/dist/entity/react.js.map +1 -1
- package/dist/{field-CCY1rG9l.d.cts → field-6rwt4ejZ.d.cts} +1 -1
- package/dist/{field-enufS5ry.d.ts → field-B-WaVZnS.d.ts} +1 -1
- package/dist/forms/index.d.cts +3 -3
- package/dist/forms/index.d.ts +3 -3
- package/dist/index.cjs +92 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -33
- package/dist/index.d.ts +13 -33
- package/dist/index.js +92 -25
- package/dist/index.js.map +1 -1
- package/dist/memory/index.d.cts +7 -7
- package/dist/memory/index.d.ts +7 -7
- package/dist/objectOrganization-BII_K3Gm.d.ts +45 -0
- package/dist/objectOrganization-DfjDQtDb.d.cts +45 -0
- package/dist/{port-C54ykAOv.d.ts → port--acgmxh5.d.ts} +5 -2
- package/dist/{port-Drioh9al.d.cts → port-Cx76dq-X.d.cts} +5 -2
- package/dist/{portal-DRdmZ-xv.d.cts → portal-9sRr6cpG.d.cts} +1 -1
- package/dist/{portal-or_f7BkT.d.ts → portal-BDAqsGkg.d.ts} +1 -1
- package/dist/{ports-s0D2jvqn.d.cts → ports-9BQ3zo2y.d.cts} +108 -2
- package/dist/{ports-BeOgjwYl.d.ts → ports-DYWE1ENo.d.ts} +108 -2
- package/dist/react/index.cjs +101 -32
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1463 -1363
- package/dist/react/index.d.ts +1463 -1363
- package/dist/react/index.js +101 -32
- package/dist/react/index.js.map +1 -1
- package/dist/realtime/index.cjs +43 -13
- package/dist/realtime/index.cjs.map +1 -1
- package/dist/realtime/index.d.cts +9 -3
- package/dist/realtime/index.d.ts +9 -3
- package/dist/realtime/index.js +43 -13
- package/dist/realtime/index.js.map +1 -1
- package/dist/{record-BwCf9wKW.d.cts → record-DmmeuUrC.d.cts} +1 -1
- package/dist/{record-BwCf9wKW.d.ts → record-DmmeuUrC.d.ts} +1 -1
- package/dist/{relation-eLMgv_dV.d.ts → relation-Op1M67le.d.ts} +2 -2
- package/dist/{relation-8vAWCa67.d.cts → relation-qrb2NbHf.d.cts} +2 -2
- package/dist/{rule-wHI5B0Ka.d.cts → rule-CeHg1sy1.d.cts} +1 -1
- package/dist/{rule-D9yNiorf.d.ts → rule-tN2lxvJ1.d.ts} +1 -1
- package/dist/search/index.d.cts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/setup/index.cjs +117 -42
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +25 -11
- package/dist/setup/index.d.ts +25 -11
- package/dist/setup/index.js +117 -42
- package/dist/setup/index.js.map +1 -1
- package/dist/{subscription-CdoI-UaB.d.cts → subscription-Drbxn-9Z.d.cts} +3 -3
- package/dist/{subscription-BynsG1K6.d.ts → subscription-hdTaRrfK.d.ts} +3 -3
- package/dist/{table-kind-i3lZJa3f.d.ts → table-kind-BZkvzBgc.d.ts} +4 -29
- package/dist/{table-kind-DzctQ7dO.d.cts → table-kind-C-hZxDN7.d.cts} +4 -29
- package/dist/templates/index.d.cts +10 -10
- package/dist/templates/index.d.ts +10 -10
- package/dist/typed-table/index.cjs +46 -24
- package/dist/typed-table/index.cjs.map +1 -1
- package/dist/typed-table/index.d.cts +10 -10
- package/dist/typed-table/index.d.ts +10 -10
- package/dist/typed-table/index.js +46 -24
- package/dist/typed-table/index.js.map +1 -1
- package/dist/{types-BvL_oKFl.d.ts → types-BauAeFW8.d.ts} +2 -2
- package/dist/{types-DAFP6XFe.d.cts → types-CBmUdBT0.d.cts} +2 -2
- package/dist/{types-BKYEeFt4.d.cts → types-Dek9owBe.d.cts} +2 -2
- package/dist/{types-D8qdG3Lg.d.cts → types-DsgXrESm.d.cts} +2 -2
- package/dist/{types-cpKY7Pjb.d.ts → types-HVgWcZDY.d.ts} +2 -2
- package/dist/{types-DYzXhD7j.d.ts → types-hrw-Eff1.d.ts} +2 -2
- package/dist/use-cases/index.d.cts +5 -5
- package/dist/use-cases/index.d.ts +5 -5
- package/dist/{validate-DfNMxjmU.d.cts → validate-B_iUeyh2.d.cts} +1 -1
- package/dist/{validate-DbvAParj.d.ts → validate-w-HGGTf-.d.ts} +1 -1
- package/dist/views/index.cjs +438 -0
- package/dist/views/index.cjs.map +1 -0
- package/dist/views/index.d.cts +401 -0
- package/dist/views/index.d.ts +401 -0
- package/dist/views/index.js +415 -0
- package/dist/views/index.js.map +1 -0
- package/package.json +12 -2
package/dist/react/index.cjs
CHANGED
|
@@ -110,6 +110,7 @@ __export(react_exports, {
|
|
|
110
110
|
TO_CUSTOM_FIELDS: () => TO_CUSTOM_FIELDS,
|
|
111
111
|
VALUE_ALTERNATE_KEYS: () => VALUE_ALTERNATE_KEYS,
|
|
112
112
|
VALUE_ENVELOPE_KEYS: () => VALUE_ENVELOPE_KEYS,
|
|
113
|
+
WHERE_ID_OPENS_DOOR: () => WHERE_ID_OPENS_DOOR,
|
|
113
114
|
actionRefusals: () => actionRefusals,
|
|
114
115
|
addressFromText: () => addressFromText,
|
|
115
116
|
addressMapUrl: () => addressMapUrl,
|
|
@@ -142,8 +143,10 @@ __export(react_exports, {
|
|
|
142
143
|
confidentialRefusal: () => confidentialRefusal,
|
|
143
144
|
confidentialRequest: () => confidentialRequest,
|
|
144
145
|
confidentialState: () => confidentialState,
|
|
146
|
+
createOpLedger: () => createOpLedger,
|
|
145
147
|
decideTypedChoice: () => decideTypedChoice,
|
|
146
148
|
declareDrillDefinition: () => declareDrillDefinition,
|
|
149
|
+
defaultOpLedger: () => defaultOpLedger,
|
|
147
150
|
defineTypedTable: () => defineTypedTable,
|
|
148
151
|
drillAnswerOf: () => drillAnswerOf,
|
|
149
152
|
drillFindingKnob: () => drillFindingKnob,
|
|
@@ -229,6 +232,7 @@ __export(react_exports, {
|
|
|
229
232
|
publicFormPath: () => publicFormPath,
|
|
230
233
|
rankTypedMatches: () => rankTypedMatches,
|
|
231
234
|
ratingMaxOf: () => ratingMaxOf,
|
|
235
|
+
readObjectOrganizationAnswer: () => readObjectOrganizationAnswer,
|
|
232
236
|
readTypedDate: () => readTypedDate,
|
|
233
237
|
readTypedDuration: () => readTypedDuration,
|
|
234
238
|
readTypedNumber: () => readTypedNumber,
|
|
@@ -246,6 +250,7 @@ __export(react_exports, {
|
|
|
246
250
|
rememberedOpCount: () => rememberedOpCount,
|
|
247
251
|
removeAppRow: () => removeAppRow,
|
|
248
252
|
removedChoicesInUse: () => removedChoicesInUse,
|
|
253
|
+
resolveObjectOrganization: () => resolveObjectOrganization,
|
|
249
254
|
richTextPlain: () => richTextPlain,
|
|
250
255
|
rowFromDocument: () => rowFromDocument,
|
|
251
256
|
ruleThatRefuses: () => ruleThatRefuses,
|
|
@@ -310,6 +315,7 @@ __export(react_exports, {
|
|
|
310
315
|
useTables: () => useTables,
|
|
311
316
|
useTypedTable: () => useTypedTable,
|
|
312
317
|
valueConverts: () => valueConverts,
|
|
318
|
+
whereIdOpensPort: () => whereIdOpensPort,
|
|
313
319
|
withCallersClock: () => withCallersClock,
|
|
314
320
|
withRowCounts: () => withRowCounts,
|
|
315
321
|
withTablePlacement: () => withTablePlacement,
|
|
@@ -819,40 +825,59 @@ function sourceArchivedOf(value) {
|
|
|
819
825
|
var import_global_slot2 = require("@ai-matrx/kit/global-slot");
|
|
820
826
|
var REMEMBER_MS = 3e4;
|
|
821
827
|
var REMEMBER_MAX = 500;
|
|
822
|
-
|
|
823
|
-
function trim(now) {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
828
|
+
function ledgerOver(ours) {
|
|
829
|
+
function trim(now) {
|
|
830
|
+
for (const [id, at] of ours) {
|
|
831
|
+
if (now - at <= REMEMBER_MS) break;
|
|
832
|
+
ours.delete(id);
|
|
833
|
+
}
|
|
834
|
+
while (ours.size > REMEMBER_MAX) {
|
|
835
|
+
const oldest = ours.keys().next();
|
|
836
|
+
if (oldest.done === true) break;
|
|
837
|
+
ours.delete(oldest.value);
|
|
838
|
+
}
|
|
832
839
|
}
|
|
840
|
+
return {
|
|
841
|
+
mint() {
|
|
842
|
+
const id = crypto.randomUUID();
|
|
843
|
+
const now = Date.now();
|
|
844
|
+
ours.set(id, now);
|
|
845
|
+
trim(now);
|
|
846
|
+
return id;
|
|
847
|
+
},
|
|
848
|
+
isOwn(opId) {
|
|
849
|
+
if (!opId) return false;
|
|
850
|
+
const at = ours.get(opId);
|
|
851
|
+
if (at === void 0) return false;
|
|
852
|
+
if (Date.now() - at > REMEMBER_MS) {
|
|
853
|
+
ours.delete(opId);
|
|
854
|
+
return false;
|
|
855
|
+
}
|
|
856
|
+
return true;
|
|
857
|
+
},
|
|
858
|
+
clear() {
|
|
859
|
+
ours.clear();
|
|
860
|
+
},
|
|
861
|
+
get size() {
|
|
862
|
+
return ours.size;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
833
865
|
}
|
|
866
|
+
function createOpLedger() {
|
|
867
|
+
return ledgerOver(/* @__PURE__ */ new Map());
|
|
868
|
+
}
|
|
869
|
+
var defaultOpLedger = ledgerOver((0, import_global_slot2.globalSlot)("ai-matrx.records.op-ledger", () => /* @__PURE__ */ new Map()));
|
|
834
870
|
function mintOpId() {
|
|
835
|
-
|
|
836
|
-
const now = Date.now();
|
|
837
|
-
ours.set(id, now);
|
|
838
|
-
trim(now);
|
|
839
|
-
return id;
|
|
871
|
+
return defaultOpLedger.mint();
|
|
840
872
|
}
|
|
841
873
|
function isOwnOp(opId) {
|
|
842
|
-
|
|
843
|
-
const at = ours.get(opId);
|
|
844
|
-
if (at === void 0) return false;
|
|
845
|
-
if (Date.now() - at > REMEMBER_MS) {
|
|
846
|
-
ours.delete(opId);
|
|
847
|
-
return false;
|
|
848
|
-
}
|
|
849
|
-
return true;
|
|
874
|
+
return defaultOpLedger.isOwn(opId);
|
|
850
875
|
}
|
|
851
876
|
function forgetAllOps() {
|
|
852
|
-
|
|
877
|
+
defaultOpLedger.clear();
|
|
853
878
|
}
|
|
854
879
|
function rememberedOpCount() {
|
|
855
|
-
return
|
|
880
|
+
return defaultOpLedger.size;
|
|
856
881
|
}
|
|
857
882
|
|
|
858
883
|
// src/choice.ts
|
|
@@ -4518,6 +4543,8 @@ function createRecordsClient(given) {
|
|
|
4518
4543
|
const config = { ...given, dataSource: asRecordsDataSource(given.dataSource) };
|
|
4519
4544
|
const schema = config.schema ?? DEFAULT_SCHEMA;
|
|
4520
4545
|
const org = config.organizationId;
|
|
4546
|
+
const ledger = config.opLedger ?? defaultOpLedger;
|
|
4547
|
+
const mintOp = () => ledger.mint();
|
|
4521
4548
|
const scream = sink(config);
|
|
4522
4549
|
const BUNDLE_TTL_MS = 1e4;
|
|
4523
4550
|
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"]);
|
|
@@ -4904,14 +4931,14 @@ function createRecordsClient(given) {
|
|
|
4904
4931
|
async recordWrite({ table_id, data }) {
|
|
4905
4932
|
const result = await callDoor(
|
|
4906
4933
|
DOORS.recordWrite,
|
|
4907
|
-
{ p_organization_id: org, p_table_id: table_id, p_data: { ...data, _op_id:
|
|
4934
|
+
{ p_organization_id: org, p_table_id: table_id, p_data: { ...data, _op_id: mintOp() } },
|
|
4908
4935
|
"recordWrite"
|
|
4909
4936
|
);
|
|
4910
4937
|
if (result.ok && typeof result.data === "string") announceRecordChanged(result.data);
|
|
4911
4938
|
return result;
|
|
4912
4939
|
},
|
|
4913
4940
|
async recordWriteMany({ table_id, rows, ids }) {
|
|
4914
|
-
const opId =
|
|
4941
|
+
const opId = mintOp();
|
|
4915
4942
|
return callDoor(
|
|
4916
4943
|
DOORS.recordWriteMany,
|
|
4917
4944
|
{
|
|
@@ -4924,7 +4951,7 @@ function createRecordsClient(given) {
|
|
|
4924
4951
|
);
|
|
4925
4952
|
},
|
|
4926
4953
|
async recordChangeMany({ table_id, changes }) {
|
|
4927
|
-
const opId =
|
|
4954
|
+
const opId = mintOp();
|
|
4928
4955
|
const result = await callDoor(
|
|
4929
4956
|
DOORS.recordChangeMany,
|
|
4930
4957
|
{
|
|
@@ -4947,7 +4974,7 @@ function createRecordsClient(given) {
|
|
|
4947
4974
|
return result;
|
|
4948
4975
|
},
|
|
4949
4976
|
async recordWriteGraph({ table_id, parent, children, edges }) {
|
|
4950
|
-
const opId =
|
|
4977
|
+
const opId = mintOp();
|
|
4951
4978
|
return callDoor(
|
|
4952
4979
|
DOORS.recordWriteGraph,
|
|
4953
4980
|
{
|
|
@@ -4971,7 +4998,7 @@ function createRecordsClient(given) {
|
|
|
4971
4998
|
{
|
|
4972
4999
|
p_organization_id: org,
|
|
4973
5000
|
p_record_id: record_id,
|
|
4974
|
-
p_patch: { ...patch, _op_id:
|
|
5001
|
+
p_patch: { ...patch, _op_id: mintOp() },
|
|
4975
5002
|
...expectedVersion === void 0 ? {} : { p_expected_version: expectedVersion }
|
|
4976
5003
|
},
|
|
4977
5004
|
"recordUpdate"
|
|
@@ -4985,7 +5012,7 @@ function createRecordsClient(given) {
|
|
|
4985
5012
|
{
|
|
4986
5013
|
p_organization_id: org,
|
|
4987
5014
|
p_record_id: record_id,
|
|
4988
|
-
p_patch: { ...patch, _op_id:
|
|
5015
|
+
p_patch: { ...patch, _op_id: mintOp() },
|
|
4989
5016
|
p_add: add,
|
|
4990
5017
|
...expectedVersion === void 0 ? {} : { p_expected_version: expectedVersion }
|
|
4991
5018
|
},
|
|
@@ -6010,7 +6037,7 @@ function createRecordsClient(given) {
|
|
|
6010
6037
|
p_table_id: table_id,
|
|
6011
6038
|
p_key: keys,
|
|
6012
6039
|
// The op id rides the envelope, as `recordWrite` / `recordUpdate` send it; each door takes it off.
|
|
6013
|
-
p_data: { ...data, _op_id:
|
|
6040
|
+
p_data: { ...data, _op_id: mintOp() },
|
|
6014
6041
|
...expectedVersion === void 0 ? {} : { p_expected_version: expectedVersion }
|
|
6015
6042
|
},
|
|
6016
6043
|
"recordUpsert"
|
|
@@ -12413,6 +12440,48 @@ function openCaptureQueue(opts) {
|
|
|
12413
12440
|
return queue;
|
|
12414
12441
|
}
|
|
12415
12442
|
|
|
12443
|
+
// src/objectOrganization.ts
|
|
12444
|
+
var WHERE_ID_OPENS_DOOR = "where_id_opens";
|
|
12445
|
+
function doorIsAbsent(error) {
|
|
12446
|
+
if (error.code === "PGRST202" || error.code === "42883") return true;
|
|
12447
|
+
return /could not find the function/i.test(error.message ?? "");
|
|
12448
|
+
}
|
|
12449
|
+
var DOOR_ABSENT_WHY = "custom.where_id_opens is missing from this database, so this page cannot tell which organization the record lives in and holds instead of guessing. Remedy: the chair applies migrations/campaign/openbyid_one_address_opens_any_id.sql and openbyid_the_resolver_can_be_reached.sql.";
|
|
12450
|
+
async function resolveObjectOrganization(dataSource, id) {
|
|
12451
|
+
let answered;
|
|
12452
|
+
try {
|
|
12453
|
+
answered = await dataSource.rpc(WHERE_ID_OPENS_DOOR, { p_id: id }, { schema: "custom" });
|
|
12454
|
+
} catch (thrown) {
|
|
12455
|
+
return { state: "unavailable", why: thrown instanceof Error ? thrown.message : "The record store did not answer." };
|
|
12456
|
+
}
|
|
12457
|
+
return readObjectOrganizationAnswer(answered, id);
|
|
12458
|
+
}
|
|
12459
|
+
function readObjectOrganizationAnswer(answered, id) {
|
|
12460
|
+
if (answered.error) {
|
|
12461
|
+
if (doorIsAbsent(answered.error)) {
|
|
12462
|
+
console.warn(`[@ai-matrx/records] ${DOOR_ABSENT_WHY}`);
|
|
12463
|
+
return { state: "unavailable", why: DOOR_ABSENT_WHY };
|
|
12464
|
+
}
|
|
12465
|
+
return { state: "unavailable", why: answered.error.message ?? "The record store refused to say where this is." };
|
|
12466
|
+
}
|
|
12467
|
+
const row = answered.data;
|
|
12468
|
+
if (row === null || row === void 0) return { state: "not-given" };
|
|
12469
|
+
if (typeof row !== "object" || typeof row.organization_id !== "string" || typeof row.kind !== "string") {
|
|
12470
|
+
return { state: "unavailable", why: "The record store answered something this page cannot read." };
|
|
12471
|
+
}
|
|
12472
|
+
return {
|
|
12473
|
+
state: "found",
|
|
12474
|
+
organizationId: row.organization_id,
|
|
12475
|
+
kind: row.kind,
|
|
12476
|
+
path: typeof row.path === "string" ? row.path : null,
|
|
12477
|
+
live: row.live !== false,
|
|
12478
|
+
resolvedId: typeof row.resolved_id === "string" ? row.resolved_id : id
|
|
12479
|
+
};
|
|
12480
|
+
}
|
|
12481
|
+
function whereIdOpensPort(dataSource) {
|
|
12482
|
+
return { organizationOf: (id) => resolveObjectOrganization(dataSource, id) };
|
|
12483
|
+
}
|
|
12484
|
+
|
|
12416
12485
|
// src/record-scope.ts
|
|
12417
12486
|
function scopeChip(scope) {
|
|
12418
12487
|
return scope.title ? `About: ${scope.title}` : "About: this record";
|