@ai-matrx/records 0.58.111 → 0.58.113
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 +12 -0
- package/dist/core/index.cjs +109 -9
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +14 -2
- package/dist/core/index.d.ts +14 -2
- package/dist/core/index.js +109 -9
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/react/index.cjs +109 -9
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +24 -2
- package/dist/react/index.d.ts +24 -2
- package/dist/react/index.js +109 -9
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3948,6 +3948,16 @@ interface RecordsConfig {
|
|
|
3948
3948
|
* needs one is sent NULL and refuses in its own words, never a guessed organization.
|
|
3949
3949
|
*/
|
|
3950
3950
|
organizationId: Uuid | null;
|
|
3951
|
+
/**
|
|
3952
|
+
* EVERY organization the person belongs to (active-org-is-never-a-list-filter.md).
|
|
3953
|
+
* `organizationId` above is where NEW things are written and which org a write
|
|
3954
|
+
* runs in; it never decides what a READ shows. With this set, `tableList` /
|
|
3955
|
+
* `tableFacts` span all of these organizations (or one, when the page passes
|
|
3956
|
+
* its `organization_id` filter), and `tableRead` / `recordRead` /
|
|
3957
|
+
* `recordValuesVersioned` open a record in ITS OWN organization. Absent ⇒ the
|
|
3958
|
+
* client reads only `organizationId`, exactly as before.
|
|
3959
|
+
*/
|
|
3960
|
+
organizationIds?: readonly Uuid[];
|
|
3951
3961
|
realtime?: RecordsRealtimePort;
|
|
3952
3962
|
onError?: RecordsErrorSink;
|
|
3953
3963
|
resolver?: RecordsResolverPort;
|
package/dist/index.d.ts
CHANGED
|
@@ -3948,6 +3948,16 @@ interface RecordsConfig {
|
|
|
3948
3948
|
* needs one is sent NULL and refuses in its own words, never a guessed organization.
|
|
3949
3949
|
*/
|
|
3950
3950
|
organizationId: Uuid | null;
|
|
3951
|
+
/**
|
|
3952
|
+
* EVERY organization the person belongs to (active-org-is-never-a-list-filter.md).
|
|
3953
|
+
* `organizationId` above is where NEW things are written and which org a write
|
|
3954
|
+
* runs in; it never decides what a READ shows. With this set, `tableList` /
|
|
3955
|
+
* `tableFacts` span all of these organizations (or one, when the page passes
|
|
3956
|
+
* its `organization_id` filter), and `tableRead` / `recordRead` /
|
|
3957
|
+
* `recordValuesVersioned` open a record in ITS OWN organization. Absent ⇒ the
|
|
3958
|
+
* client reads only `organizationId`, exactly as before.
|
|
3959
|
+
*/
|
|
3960
|
+
organizationIds?: readonly Uuid[];
|
|
3951
3961
|
realtime?: RecordsRealtimePort;
|
|
3952
3962
|
onError?: RecordsErrorSink;
|
|
3953
3963
|
resolver?: RecordsResolverPort;
|
package/dist/react/index.cjs
CHANGED
|
@@ -39854,6 +39854,51 @@ function createRecordsClient(config) {
|
|
|
39854
39854
|
"recordRead"
|
|
39855
39855
|
);
|
|
39856
39856
|
}
|
|
39857
|
+
const readOrgs = (filter) => {
|
|
39858
|
+
if (filter) return [filter];
|
|
39859
|
+
const all = [...org ? [org] : [], ...config.organizationIds ?? []];
|
|
39860
|
+
const unique = [...new Set(all)];
|
|
39861
|
+
return unique.length > 0 ? unique : [org];
|
|
39862
|
+
};
|
|
39863
|
+
const siblings = /* @__PURE__ */ new Map();
|
|
39864
|
+
const clientFor = (target) => {
|
|
39865
|
+
if (target === org) return client;
|
|
39866
|
+
const key = target;
|
|
39867
|
+
let sibling = siblings.get(key);
|
|
39868
|
+
if (!sibling) {
|
|
39869
|
+
sibling = createRecordsClient({ ...config, organizationId: target, organizationIds: [] });
|
|
39870
|
+
siblings.set(key, sibling);
|
|
39871
|
+
}
|
|
39872
|
+
return sibling;
|
|
39873
|
+
};
|
|
39874
|
+
const recordOrgs = /* @__PURE__ */ new Map();
|
|
39875
|
+
async function acrossOrgs(filter, ask, merge) {
|
|
39876
|
+
const targets = readOrgs(filter);
|
|
39877
|
+
if (targets.length === 1) return ask(clientFor(targets[0] ?? null));
|
|
39878
|
+
const answers = await Promise.all(targets.map((t) => ask(clientFor(t))));
|
|
39879
|
+
const parts = [];
|
|
39880
|
+
let firstError = null;
|
|
39881
|
+
for (const a of answers) {
|
|
39882
|
+
if (a.ok) parts.push(a.data);
|
|
39883
|
+
else firstError ??= a.error;
|
|
39884
|
+
}
|
|
39885
|
+
if (parts.length === 0 && firstError) return err(firstError);
|
|
39886
|
+
return ok(merge(parts));
|
|
39887
|
+
}
|
|
39888
|
+
async function openInOwnOrg(recordId, filter, ask, found) {
|
|
39889
|
+
const known = recordOrgs.get(recordId);
|
|
39890
|
+
const targets = filter ? [filter] : known !== void 0 ? [known, ...readOrgs().filter((t) => t !== known)] : readOrgs();
|
|
39891
|
+
let last = null;
|
|
39892
|
+
for (const t of targets) {
|
|
39893
|
+
const answer = await ask(clientFor(t));
|
|
39894
|
+
if (answer.ok && found(answer.data)) {
|
|
39895
|
+
recordOrgs.set(recordId, t);
|
|
39896
|
+
return answer;
|
|
39897
|
+
}
|
|
39898
|
+
last ??= answer;
|
|
39899
|
+
}
|
|
39900
|
+
return last;
|
|
39901
|
+
}
|
|
39857
39902
|
const client = {
|
|
39858
39903
|
config,
|
|
39859
39904
|
async recordWrite({ table_id, data }) {
|
|
@@ -39982,7 +40027,18 @@ function createRecordsClient(config) {
|
|
|
39982
40027
|
"tableArchive"
|
|
39983
40028
|
);
|
|
39984
40029
|
},
|
|
39985
|
-
async recordRead({ record_id, withComputed = false }) {
|
|
40030
|
+
async recordRead({ record_id, withComputed = false, organization_id }) {
|
|
40031
|
+
if (organization_id && organization_id !== org) {
|
|
40032
|
+
return clientFor(organization_id).recordRead({ record_id, withComputed, organization_id });
|
|
40033
|
+
}
|
|
40034
|
+
if (readOrgs(organization_id).length > 1) {
|
|
40035
|
+
return openInOwnOrg(
|
|
40036
|
+
record_id,
|
|
40037
|
+
organization_id,
|
|
40038
|
+
(sub) => sub.recordRead({ record_id, withComputed, organization_id: sub.config.organizationId }),
|
|
40039
|
+
() => true
|
|
40040
|
+
);
|
|
40041
|
+
}
|
|
39986
40042
|
const door = await callDoor(
|
|
39987
40043
|
DOORS.readRecord,
|
|
39988
40044
|
{ p_organization_id: org, p_record_id: record_id },
|
|
@@ -40018,8 +40074,18 @@ function createRecordsClient(config) {
|
|
|
40018
40074
|
})
|
|
40019
40075
|
);
|
|
40020
40076
|
},
|
|
40021
|
-
async tableFacts() {
|
|
40077
|
+
async tableFacts(args) {
|
|
40022
40078
|
if (!doorExists(DOORS.tableFacts)) return ok(null);
|
|
40079
|
+
if (args?.organization_id && args.organization_id !== org) {
|
|
40080
|
+
return clientFor(args.organization_id).tableFacts(args);
|
|
40081
|
+
}
|
|
40082
|
+
if (readOrgs(args?.organization_id).length > 1) {
|
|
40083
|
+
return acrossOrgs(
|
|
40084
|
+
args?.organization_id,
|
|
40085
|
+
(sub) => sub.tableFacts({ organization_id: sub.config.organizationId }),
|
|
40086
|
+
(parts) => parts.flatMap((p) => p ?? [])
|
|
40087
|
+
);
|
|
40088
|
+
}
|
|
40023
40089
|
return callDoor(DOORS.tableFacts, { p_organization_id: org }, "tableFacts");
|
|
40024
40090
|
},
|
|
40025
40091
|
async tablesLiveWhere({ table_ids }) {
|
|
@@ -40279,7 +40345,18 @@ function createRecordsClient(config) {
|
|
|
40279
40345
|
offset: plan.read.offset
|
|
40280
40346
|
});
|
|
40281
40347
|
},
|
|
40282
|
-
async tableRead({ table_id }) {
|
|
40348
|
+
async tableRead({ table_id, organization_id }) {
|
|
40349
|
+
if (organization_id && organization_id !== org) {
|
|
40350
|
+
return clientFor(organization_id).tableRead({ table_id, organization_id });
|
|
40351
|
+
}
|
|
40352
|
+
if (readOrgs(organization_id).length > 1) {
|
|
40353
|
+
return openInOwnOrg(
|
|
40354
|
+
table_id,
|
|
40355
|
+
organization_id,
|
|
40356
|
+
(sub) => sub.tableRead({ table_id, organization_id: sub.config.organizationId }),
|
|
40357
|
+
(t) => t !== null
|
|
40358
|
+
);
|
|
40359
|
+
}
|
|
40283
40360
|
const kernel = await tableKernel("tableRead.kernel");
|
|
40284
40361
|
if (!kernel.ok) return err(kernel.error);
|
|
40285
40362
|
const door = await callDoor(
|
|
@@ -40293,7 +40370,19 @@ function createRecordsClient(config) {
|
|
|
40293
40370
|
const { document: document2 } = unfold(row.document);
|
|
40294
40371
|
return ok({ ...document2, id: row.id, organization_id: org });
|
|
40295
40372
|
},
|
|
40296
|
-
async tableList() {
|
|
40373
|
+
async tableList(args) {
|
|
40374
|
+
if (args?.organization_id && args.organization_id !== org) {
|
|
40375
|
+
return clientFor(args.organization_id).tableList(args);
|
|
40376
|
+
}
|
|
40377
|
+
if (readOrgs(args?.organization_id).length > 1) {
|
|
40378
|
+
const merged = await acrossOrgs(
|
|
40379
|
+
args?.organization_id,
|
|
40380
|
+
(sub) => sub.tableList({ organization_id: sub.config.organizationId }),
|
|
40381
|
+
(parts) => parts.flat()
|
|
40382
|
+
);
|
|
40383
|
+
if (merged.ok) merged.data.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
40384
|
+
return merged;
|
|
40385
|
+
}
|
|
40297
40386
|
const kernel = await tableKernel("tableList.kernel");
|
|
40298
40387
|
if (!kernel.ok) return err(kernel.error);
|
|
40299
40388
|
const door = await callDoor(
|
|
@@ -41348,7 +41437,18 @@ function createRecordsClient(config) {
|
|
|
41348
41437
|
answered.data.map((row) => ({ ...row, id: row["signature_id"] }))
|
|
41349
41438
|
);
|
|
41350
41439
|
},
|
|
41351
|
-
async recordValuesVersioned({ record_id }) {
|
|
41440
|
+
async recordValuesVersioned({ record_id, organization_id }) {
|
|
41441
|
+
if (organization_id && organization_id !== org) {
|
|
41442
|
+
return clientFor(organization_id).recordValuesVersioned({ record_id, organization_id });
|
|
41443
|
+
}
|
|
41444
|
+
if (readOrgs(organization_id).length > 1) {
|
|
41445
|
+
return openInOwnOrg(
|
|
41446
|
+
record_id,
|
|
41447
|
+
organization_id,
|
|
41448
|
+
(sub) => sub.recordValuesVersioned({ record_id, organization_id: sub.config.organizationId }),
|
|
41449
|
+
(values) => values.length > 0
|
|
41450
|
+
);
|
|
41451
|
+
}
|
|
41352
41452
|
return readValues(record_id);
|
|
41353
41453
|
},
|
|
41354
41454
|
async revisions({ record_id }) {
|
|
@@ -41358,7 +41458,7 @@ function createRecordsClient(config) {
|
|
|
41358
41458
|
"revisions"
|
|
41359
41459
|
);
|
|
41360
41460
|
},
|
|
41361
|
-
async recordScopeContext({ record_id, relations, history, siblings }) {
|
|
41461
|
+
async recordScopeContext({ record_id, relations, history, siblings: siblings2 }) {
|
|
41362
41462
|
return callDoor(
|
|
41363
41463
|
DOORS.recordScopeContext,
|
|
41364
41464
|
{
|
|
@@ -41366,7 +41466,7 @@ function createRecordsClient(config) {
|
|
|
41366
41466
|
p_record_id: record_id,
|
|
41367
41467
|
p_relations: relations ?? 12,
|
|
41368
41468
|
p_history: history ?? 15,
|
|
41369
|
-
p_siblings:
|
|
41469
|
+
p_siblings: siblings2 ?? 8
|
|
41370
41470
|
},
|
|
41371
41471
|
"recordScopeContext"
|
|
41372
41472
|
);
|
|
@@ -41396,7 +41496,7 @@ function createRecordsClient(config) {
|
|
|
41396
41496
|
"conversationScopeUnbind"
|
|
41397
41497
|
);
|
|
41398
41498
|
},
|
|
41399
|
-
async conversationScopeContext({ conversation_id, relations, history, siblings }) {
|
|
41499
|
+
async conversationScopeContext({ conversation_id, relations, history, siblings: siblings2 }) {
|
|
41400
41500
|
return callDoor(
|
|
41401
41501
|
DOORS.conversationScopeContext,
|
|
41402
41502
|
{
|
|
@@ -41404,7 +41504,7 @@ function createRecordsClient(config) {
|
|
|
41404
41504
|
p_conversation_id: conversation_id,
|
|
41405
41505
|
p_relations: relations ?? 12,
|
|
41406
41506
|
p_history: history ?? 15,
|
|
41407
|
-
p_siblings:
|
|
41507
|
+
p_siblings: siblings2 ?? 8
|
|
41408
41508
|
},
|
|
41409
41509
|
"conversationScopeContext"
|
|
41410
41510
|
);
|