@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/react/index.d.cts
CHANGED
|
@@ -9854,6 +9854,16 @@ interface RecordsConfig {
|
|
|
9854
9854
|
* needs one is sent NULL and refuses in its own words, never a guessed organization.
|
|
9855
9855
|
*/
|
|
9856
9856
|
organizationId: Uuid | null;
|
|
9857
|
+
/**
|
|
9858
|
+
* EVERY organization the person belongs to (active-org-is-never-a-list-filter.md).
|
|
9859
|
+
* `organizationId` above is where NEW things are written and which org a write
|
|
9860
|
+
* runs in; it never decides what a READ shows. With this set, `tableList` /
|
|
9861
|
+
* `tableFacts` span all of these organizations (or one, when the page passes
|
|
9862
|
+
* its `organization_id` filter), and `tableRead` / `recordRead` /
|
|
9863
|
+
* `recordValuesVersioned` open a record in ITS OWN organization. Absent ⇒ the
|
|
9864
|
+
* client reads only `organizationId`, exactly as before.
|
|
9865
|
+
*/
|
|
9866
|
+
organizationIds?: readonly Uuid[];
|
|
9857
9867
|
realtime?: RecordsRealtimePort;
|
|
9858
9868
|
onError?: RecordsErrorSink;
|
|
9859
9869
|
resolver?: RecordsResolverPort;
|
|
@@ -10979,6 +10989,7 @@ interface RecordsClient {
|
|
|
10979
10989
|
recordRead(args: {
|
|
10980
10990
|
record_id: Uuid;
|
|
10981
10991
|
withComputed?: boolean;
|
|
10992
|
+
organization_id?: Uuid | null;
|
|
10982
10993
|
}): Promise<RecordsResult<RecordRead>>;
|
|
10983
10994
|
/**
|
|
10984
10995
|
* DOOR-1. A page of one Table's records THROUGH `custom.read_records`: the
|
|
@@ -11067,7 +11078,14 @@ interface RecordsClient {
|
|
|
11067
11078
|
rows: ReadRow[];
|
|
11068
11079
|
total: number | null;
|
|
11069
11080
|
}>>;
|
|
11070
|
-
|
|
11081
|
+
/**
|
|
11082
|
+
* Every Table the person can see across ALL their organizations
|
|
11083
|
+
* (`config.organizationIds`); `organization_id` is the page's optional filter
|
|
11084
|
+
* (absent = all). Each Table carries its own `organization_id`.
|
|
11085
|
+
*/
|
|
11086
|
+
tableList(args?: {
|
|
11087
|
+
organization_id?: Uuid | null;
|
|
11088
|
+
}): Promise<RecordsResult<Table[]>>;
|
|
11071
11089
|
/**
|
|
11072
11090
|
* ONE Table's declaration by id — `null` when this reader may not see it or it is not a Table.
|
|
11073
11091
|
* The same kernel record `tableList` lists, read through `read_records_by_ids` for exactly
|
|
@@ -11076,6 +11094,7 @@ interface RecordsClient {
|
|
|
11076
11094
|
*/
|
|
11077
11095
|
tableRead(args: {
|
|
11078
11096
|
table_id: Uuid;
|
|
11097
|
+
organization_id?: Uuid | null;
|
|
11079
11098
|
}): Promise<RecordsResult<Table | null>>;
|
|
11080
11099
|
/**
|
|
11081
11100
|
* IS THIS TABLE IN THE ARCHIVE? (lane HUB-FIX, 2026-09-23.) The archived row for one
|
|
@@ -11103,7 +11122,9 @@ interface RecordsClient {
|
|
|
11103
11122
|
* The door-presence pattern: when the store's catalogue does not carry the door the
|
|
11104
11123
|
* answer is `null` — nothing asked, nothing invented.
|
|
11105
11124
|
*/
|
|
11106
|
-
tableFacts(
|
|
11125
|
+
tableFacts(args?: {
|
|
11126
|
+
organization_id?: Uuid | null;
|
|
11127
|
+
}): Promise<RecordsResult<TableFact[] | null>>;
|
|
11107
11128
|
/**
|
|
11108
11129
|
* WHICH STORE CURRENTLY WRITES each table — `custom.where_tables_live`.
|
|
11109
11130
|
*
|
|
@@ -12203,6 +12224,7 @@ interface RecordsClient {
|
|
|
12203
12224
|
*/
|
|
12204
12225
|
recordValuesVersioned(args: {
|
|
12205
12226
|
record_id: Uuid;
|
|
12227
|
+
organization_id?: Uuid | null;
|
|
12206
12228
|
}): Promise<RecordsResult<ReadValue[]>>;
|
|
12207
12229
|
metadataSearch(args: {
|
|
12208
12230
|
text: string;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -9854,6 +9854,16 @@ interface RecordsConfig {
|
|
|
9854
9854
|
* needs one is sent NULL and refuses in its own words, never a guessed organization.
|
|
9855
9855
|
*/
|
|
9856
9856
|
organizationId: Uuid | null;
|
|
9857
|
+
/**
|
|
9858
|
+
* EVERY organization the person belongs to (active-org-is-never-a-list-filter.md).
|
|
9859
|
+
* `organizationId` above is where NEW things are written and which org a write
|
|
9860
|
+
* runs in; it never decides what a READ shows. With this set, `tableList` /
|
|
9861
|
+
* `tableFacts` span all of these organizations (or one, when the page passes
|
|
9862
|
+
* its `organization_id` filter), and `tableRead` / `recordRead` /
|
|
9863
|
+
* `recordValuesVersioned` open a record in ITS OWN organization. Absent ⇒ the
|
|
9864
|
+
* client reads only `organizationId`, exactly as before.
|
|
9865
|
+
*/
|
|
9866
|
+
organizationIds?: readonly Uuid[];
|
|
9857
9867
|
realtime?: RecordsRealtimePort;
|
|
9858
9868
|
onError?: RecordsErrorSink;
|
|
9859
9869
|
resolver?: RecordsResolverPort;
|
|
@@ -10979,6 +10989,7 @@ interface RecordsClient {
|
|
|
10979
10989
|
recordRead(args: {
|
|
10980
10990
|
record_id: Uuid;
|
|
10981
10991
|
withComputed?: boolean;
|
|
10992
|
+
organization_id?: Uuid | null;
|
|
10982
10993
|
}): Promise<RecordsResult<RecordRead>>;
|
|
10983
10994
|
/**
|
|
10984
10995
|
* DOOR-1. A page of one Table's records THROUGH `custom.read_records`: the
|
|
@@ -11067,7 +11078,14 @@ interface RecordsClient {
|
|
|
11067
11078
|
rows: ReadRow[];
|
|
11068
11079
|
total: number | null;
|
|
11069
11080
|
}>>;
|
|
11070
|
-
|
|
11081
|
+
/**
|
|
11082
|
+
* Every Table the person can see across ALL their organizations
|
|
11083
|
+
* (`config.organizationIds`); `organization_id` is the page's optional filter
|
|
11084
|
+
* (absent = all). Each Table carries its own `organization_id`.
|
|
11085
|
+
*/
|
|
11086
|
+
tableList(args?: {
|
|
11087
|
+
organization_id?: Uuid | null;
|
|
11088
|
+
}): Promise<RecordsResult<Table[]>>;
|
|
11071
11089
|
/**
|
|
11072
11090
|
* ONE Table's declaration by id — `null` when this reader may not see it or it is not a Table.
|
|
11073
11091
|
* The same kernel record `tableList` lists, read through `read_records_by_ids` for exactly
|
|
@@ -11076,6 +11094,7 @@ interface RecordsClient {
|
|
|
11076
11094
|
*/
|
|
11077
11095
|
tableRead(args: {
|
|
11078
11096
|
table_id: Uuid;
|
|
11097
|
+
organization_id?: Uuid | null;
|
|
11079
11098
|
}): Promise<RecordsResult<Table | null>>;
|
|
11080
11099
|
/**
|
|
11081
11100
|
* IS THIS TABLE IN THE ARCHIVE? (lane HUB-FIX, 2026-09-23.) The archived row for one
|
|
@@ -11103,7 +11122,9 @@ interface RecordsClient {
|
|
|
11103
11122
|
* The door-presence pattern: when the store's catalogue does not carry the door the
|
|
11104
11123
|
* answer is `null` — nothing asked, nothing invented.
|
|
11105
11124
|
*/
|
|
11106
|
-
tableFacts(
|
|
11125
|
+
tableFacts(args?: {
|
|
11126
|
+
organization_id?: Uuid | null;
|
|
11127
|
+
}): Promise<RecordsResult<TableFact[] | null>>;
|
|
11107
11128
|
/**
|
|
11108
11129
|
* WHICH STORE CURRENTLY WRITES each table — `custom.where_tables_live`.
|
|
11109
11130
|
*
|
|
@@ -12203,6 +12224,7 @@ interface RecordsClient {
|
|
|
12203
12224
|
*/
|
|
12204
12225
|
recordValuesVersioned(args: {
|
|
12205
12226
|
record_id: Uuid;
|
|
12227
|
+
organization_id?: Uuid | null;
|
|
12206
12228
|
}): Promise<RecordsResult<ReadValue[]>>;
|
|
12207
12229
|
metadataSearch(args: {
|
|
12208
12230
|
text: string;
|
package/dist/react/index.js
CHANGED
|
@@ -39679,6 +39679,51 @@ function createRecordsClient(config) {
|
|
|
39679
39679
|
"recordRead"
|
|
39680
39680
|
);
|
|
39681
39681
|
}
|
|
39682
|
+
const readOrgs = (filter) => {
|
|
39683
|
+
if (filter) return [filter];
|
|
39684
|
+
const all = [...org ? [org] : [], ...config.organizationIds ?? []];
|
|
39685
|
+
const unique = [...new Set(all)];
|
|
39686
|
+
return unique.length > 0 ? unique : [org];
|
|
39687
|
+
};
|
|
39688
|
+
const siblings = /* @__PURE__ */ new Map();
|
|
39689
|
+
const clientFor = (target) => {
|
|
39690
|
+
if (target === org) return client;
|
|
39691
|
+
const key = target;
|
|
39692
|
+
let sibling = siblings.get(key);
|
|
39693
|
+
if (!sibling) {
|
|
39694
|
+
sibling = createRecordsClient({ ...config, organizationId: target, organizationIds: [] });
|
|
39695
|
+
siblings.set(key, sibling);
|
|
39696
|
+
}
|
|
39697
|
+
return sibling;
|
|
39698
|
+
};
|
|
39699
|
+
const recordOrgs = /* @__PURE__ */ new Map();
|
|
39700
|
+
async function acrossOrgs(filter, ask, merge) {
|
|
39701
|
+
const targets = readOrgs(filter);
|
|
39702
|
+
if (targets.length === 1) return ask(clientFor(targets[0] ?? null));
|
|
39703
|
+
const answers = await Promise.all(targets.map((t) => ask(clientFor(t))));
|
|
39704
|
+
const parts = [];
|
|
39705
|
+
let firstError = null;
|
|
39706
|
+
for (const a of answers) {
|
|
39707
|
+
if (a.ok) parts.push(a.data);
|
|
39708
|
+
else firstError ??= a.error;
|
|
39709
|
+
}
|
|
39710
|
+
if (parts.length === 0 && firstError) return err(firstError);
|
|
39711
|
+
return ok(merge(parts));
|
|
39712
|
+
}
|
|
39713
|
+
async function openInOwnOrg(recordId, filter, ask, found) {
|
|
39714
|
+
const known = recordOrgs.get(recordId);
|
|
39715
|
+
const targets = filter ? [filter] : known !== void 0 ? [known, ...readOrgs().filter((t) => t !== known)] : readOrgs();
|
|
39716
|
+
let last = null;
|
|
39717
|
+
for (const t of targets) {
|
|
39718
|
+
const answer = await ask(clientFor(t));
|
|
39719
|
+
if (answer.ok && found(answer.data)) {
|
|
39720
|
+
recordOrgs.set(recordId, t);
|
|
39721
|
+
return answer;
|
|
39722
|
+
}
|
|
39723
|
+
last ??= answer;
|
|
39724
|
+
}
|
|
39725
|
+
return last;
|
|
39726
|
+
}
|
|
39682
39727
|
const client = {
|
|
39683
39728
|
config,
|
|
39684
39729
|
async recordWrite({ table_id, data }) {
|
|
@@ -39807,7 +39852,18 @@ function createRecordsClient(config) {
|
|
|
39807
39852
|
"tableArchive"
|
|
39808
39853
|
);
|
|
39809
39854
|
},
|
|
39810
|
-
async recordRead({ record_id, withComputed = false }) {
|
|
39855
|
+
async recordRead({ record_id, withComputed = false, organization_id }) {
|
|
39856
|
+
if (organization_id && organization_id !== org) {
|
|
39857
|
+
return clientFor(organization_id).recordRead({ record_id, withComputed, organization_id });
|
|
39858
|
+
}
|
|
39859
|
+
if (readOrgs(organization_id).length > 1) {
|
|
39860
|
+
return openInOwnOrg(
|
|
39861
|
+
record_id,
|
|
39862
|
+
organization_id,
|
|
39863
|
+
(sub) => sub.recordRead({ record_id, withComputed, organization_id: sub.config.organizationId }),
|
|
39864
|
+
() => true
|
|
39865
|
+
);
|
|
39866
|
+
}
|
|
39811
39867
|
const door = await callDoor(
|
|
39812
39868
|
DOORS.readRecord,
|
|
39813
39869
|
{ p_organization_id: org, p_record_id: record_id },
|
|
@@ -39843,8 +39899,18 @@ function createRecordsClient(config) {
|
|
|
39843
39899
|
})
|
|
39844
39900
|
);
|
|
39845
39901
|
},
|
|
39846
|
-
async tableFacts() {
|
|
39902
|
+
async tableFacts(args) {
|
|
39847
39903
|
if (!doorExists(DOORS.tableFacts)) return ok(null);
|
|
39904
|
+
if (args?.organization_id && args.organization_id !== org) {
|
|
39905
|
+
return clientFor(args.organization_id).tableFacts(args);
|
|
39906
|
+
}
|
|
39907
|
+
if (readOrgs(args?.organization_id).length > 1) {
|
|
39908
|
+
return acrossOrgs(
|
|
39909
|
+
args?.organization_id,
|
|
39910
|
+
(sub) => sub.tableFacts({ organization_id: sub.config.organizationId }),
|
|
39911
|
+
(parts) => parts.flatMap((p) => p ?? [])
|
|
39912
|
+
);
|
|
39913
|
+
}
|
|
39848
39914
|
return callDoor(DOORS.tableFacts, { p_organization_id: org }, "tableFacts");
|
|
39849
39915
|
},
|
|
39850
39916
|
async tablesLiveWhere({ table_ids }) {
|
|
@@ -40104,7 +40170,18 @@ function createRecordsClient(config) {
|
|
|
40104
40170
|
offset: plan.read.offset
|
|
40105
40171
|
});
|
|
40106
40172
|
},
|
|
40107
|
-
async tableRead({ table_id }) {
|
|
40173
|
+
async tableRead({ table_id, organization_id }) {
|
|
40174
|
+
if (organization_id && organization_id !== org) {
|
|
40175
|
+
return clientFor(organization_id).tableRead({ table_id, organization_id });
|
|
40176
|
+
}
|
|
40177
|
+
if (readOrgs(organization_id).length > 1) {
|
|
40178
|
+
return openInOwnOrg(
|
|
40179
|
+
table_id,
|
|
40180
|
+
organization_id,
|
|
40181
|
+
(sub) => sub.tableRead({ table_id, organization_id: sub.config.organizationId }),
|
|
40182
|
+
(t) => t !== null
|
|
40183
|
+
);
|
|
40184
|
+
}
|
|
40108
40185
|
const kernel = await tableKernel("tableRead.kernel");
|
|
40109
40186
|
if (!kernel.ok) return err(kernel.error);
|
|
40110
40187
|
const door = await callDoor(
|
|
@@ -40118,7 +40195,19 @@ function createRecordsClient(config) {
|
|
|
40118
40195
|
const { document: document2 } = unfold(row.document);
|
|
40119
40196
|
return ok({ ...document2, id: row.id, organization_id: org });
|
|
40120
40197
|
},
|
|
40121
|
-
async tableList() {
|
|
40198
|
+
async tableList(args) {
|
|
40199
|
+
if (args?.organization_id && args.organization_id !== org) {
|
|
40200
|
+
return clientFor(args.organization_id).tableList(args);
|
|
40201
|
+
}
|
|
40202
|
+
if (readOrgs(args?.organization_id).length > 1) {
|
|
40203
|
+
const merged = await acrossOrgs(
|
|
40204
|
+
args?.organization_id,
|
|
40205
|
+
(sub) => sub.tableList({ organization_id: sub.config.organizationId }),
|
|
40206
|
+
(parts) => parts.flat()
|
|
40207
|
+
);
|
|
40208
|
+
if (merged.ok) merged.data.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
40209
|
+
return merged;
|
|
40210
|
+
}
|
|
40122
40211
|
const kernel = await tableKernel("tableList.kernel");
|
|
40123
40212
|
if (!kernel.ok) return err(kernel.error);
|
|
40124
40213
|
const door = await callDoor(
|
|
@@ -41173,7 +41262,18 @@ function createRecordsClient(config) {
|
|
|
41173
41262
|
answered.data.map((row) => ({ ...row, id: row["signature_id"] }))
|
|
41174
41263
|
);
|
|
41175
41264
|
},
|
|
41176
|
-
async recordValuesVersioned({ record_id }) {
|
|
41265
|
+
async recordValuesVersioned({ record_id, organization_id }) {
|
|
41266
|
+
if (organization_id && organization_id !== org) {
|
|
41267
|
+
return clientFor(organization_id).recordValuesVersioned({ record_id, organization_id });
|
|
41268
|
+
}
|
|
41269
|
+
if (readOrgs(organization_id).length > 1) {
|
|
41270
|
+
return openInOwnOrg(
|
|
41271
|
+
record_id,
|
|
41272
|
+
organization_id,
|
|
41273
|
+
(sub) => sub.recordValuesVersioned({ record_id, organization_id: sub.config.organizationId }),
|
|
41274
|
+
(values) => values.length > 0
|
|
41275
|
+
);
|
|
41276
|
+
}
|
|
41177
41277
|
return readValues(record_id);
|
|
41178
41278
|
},
|
|
41179
41279
|
async revisions({ record_id }) {
|
|
@@ -41183,7 +41283,7 @@ function createRecordsClient(config) {
|
|
|
41183
41283
|
"revisions"
|
|
41184
41284
|
);
|
|
41185
41285
|
},
|
|
41186
|
-
async recordScopeContext({ record_id, relations, history, siblings }) {
|
|
41286
|
+
async recordScopeContext({ record_id, relations, history, siblings: siblings2 }) {
|
|
41187
41287
|
return callDoor(
|
|
41188
41288
|
DOORS.recordScopeContext,
|
|
41189
41289
|
{
|
|
@@ -41191,7 +41291,7 @@ function createRecordsClient(config) {
|
|
|
41191
41291
|
p_record_id: record_id,
|
|
41192
41292
|
p_relations: relations ?? 12,
|
|
41193
41293
|
p_history: history ?? 15,
|
|
41194
|
-
p_siblings:
|
|
41294
|
+
p_siblings: siblings2 ?? 8
|
|
41195
41295
|
},
|
|
41196
41296
|
"recordScopeContext"
|
|
41197
41297
|
);
|
|
@@ -41221,7 +41321,7 @@ function createRecordsClient(config) {
|
|
|
41221
41321
|
"conversationScopeUnbind"
|
|
41222
41322
|
);
|
|
41223
41323
|
},
|
|
41224
|
-
async conversationScopeContext({ conversation_id, relations, history, siblings }) {
|
|
41324
|
+
async conversationScopeContext({ conversation_id, relations, history, siblings: siblings2 }) {
|
|
41225
41325
|
return callDoor(
|
|
41226
41326
|
DOORS.conversationScopeContext,
|
|
41227
41327
|
{
|
|
@@ -41229,7 +41329,7 @@ function createRecordsClient(config) {
|
|
|
41229
41329
|
p_conversation_id: conversation_id,
|
|
41230
41330
|
p_relations: relations ?? 12,
|
|
41231
41331
|
p_history: history ?? 15,
|
|
41232
|
-
p_siblings:
|
|
41332
|
+
p_siblings: siblings2 ?? 8
|
|
41233
41333
|
},
|
|
41234
41334
|
"conversationScopeContext"
|
|
41235
41335
|
);
|