@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/core/index.d.cts
CHANGED
|
@@ -264,6 +264,7 @@ interface RecordsClient {
|
|
|
264
264
|
recordRead(args: {
|
|
265
265
|
record_id: Uuid;
|
|
266
266
|
withComputed?: boolean;
|
|
267
|
+
organization_id?: Uuid | null;
|
|
267
268
|
}): Promise<RecordsResult<RecordRead>>;
|
|
268
269
|
/**
|
|
269
270
|
* DOOR-1. A page of one Table's records THROUGH `custom.read_records`: the
|
|
@@ -352,7 +353,14 @@ interface RecordsClient {
|
|
|
352
353
|
rows: ReadRow[];
|
|
353
354
|
total: number | null;
|
|
354
355
|
}>>;
|
|
355
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Every Table the person can see across ALL their organizations
|
|
358
|
+
* (`config.organizationIds`); `organization_id` is the page's optional filter
|
|
359
|
+
* (absent = all). Each Table carries its own `organization_id`.
|
|
360
|
+
*/
|
|
361
|
+
tableList(args?: {
|
|
362
|
+
organization_id?: Uuid | null;
|
|
363
|
+
}): Promise<RecordsResult<Table[]>>;
|
|
356
364
|
/**
|
|
357
365
|
* ONE Table's declaration by id — `null` when this reader may not see it or it is not a Table.
|
|
358
366
|
* The same kernel record `tableList` lists, read through `read_records_by_ids` for exactly
|
|
@@ -361,6 +369,7 @@ interface RecordsClient {
|
|
|
361
369
|
*/
|
|
362
370
|
tableRead(args: {
|
|
363
371
|
table_id: Uuid;
|
|
372
|
+
organization_id?: Uuid | null;
|
|
364
373
|
}): Promise<RecordsResult<Table | null>>;
|
|
365
374
|
/**
|
|
366
375
|
* IS THIS TABLE IN THE ARCHIVE? (lane HUB-FIX, 2026-09-23.) The archived row for one
|
|
@@ -388,7 +397,9 @@ interface RecordsClient {
|
|
|
388
397
|
* The door-presence pattern: when the store's catalogue does not carry the door the
|
|
389
398
|
* answer is `null` — nothing asked, nothing invented.
|
|
390
399
|
*/
|
|
391
|
-
tableFacts(
|
|
400
|
+
tableFacts(args?: {
|
|
401
|
+
organization_id?: Uuid | null;
|
|
402
|
+
}): Promise<RecordsResult<TableFact[] | null>>;
|
|
392
403
|
/**
|
|
393
404
|
* WHICH STORE CURRENTLY WRITES each table — `custom.where_tables_live`.
|
|
394
405
|
*
|
|
@@ -1488,6 +1499,7 @@ interface RecordsClient {
|
|
|
1488
1499
|
*/
|
|
1489
1500
|
recordValuesVersioned(args: {
|
|
1490
1501
|
record_id: Uuid;
|
|
1502
|
+
organization_id?: Uuid | null;
|
|
1491
1503
|
}): Promise<RecordsResult<ReadValue[]>>;
|
|
1492
1504
|
metadataSearch(args: {
|
|
1493
1505
|
text: string;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -264,6 +264,7 @@ interface RecordsClient {
|
|
|
264
264
|
recordRead(args: {
|
|
265
265
|
record_id: Uuid;
|
|
266
266
|
withComputed?: boolean;
|
|
267
|
+
organization_id?: Uuid | null;
|
|
267
268
|
}): Promise<RecordsResult<RecordRead>>;
|
|
268
269
|
/**
|
|
269
270
|
* DOOR-1. A page of one Table's records THROUGH `custom.read_records`: the
|
|
@@ -352,7 +353,14 @@ interface RecordsClient {
|
|
|
352
353
|
rows: ReadRow[];
|
|
353
354
|
total: number | null;
|
|
354
355
|
}>>;
|
|
355
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Every Table the person can see across ALL their organizations
|
|
358
|
+
* (`config.organizationIds`); `organization_id` is the page's optional filter
|
|
359
|
+
* (absent = all). Each Table carries its own `organization_id`.
|
|
360
|
+
*/
|
|
361
|
+
tableList(args?: {
|
|
362
|
+
organization_id?: Uuid | null;
|
|
363
|
+
}): Promise<RecordsResult<Table[]>>;
|
|
356
364
|
/**
|
|
357
365
|
* ONE Table's declaration by id — `null` when this reader may not see it or it is not a Table.
|
|
358
366
|
* The same kernel record `tableList` lists, read through `read_records_by_ids` for exactly
|
|
@@ -361,6 +369,7 @@ interface RecordsClient {
|
|
|
361
369
|
*/
|
|
362
370
|
tableRead(args: {
|
|
363
371
|
table_id: Uuid;
|
|
372
|
+
organization_id?: Uuid | null;
|
|
364
373
|
}): Promise<RecordsResult<Table | null>>;
|
|
365
374
|
/**
|
|
366
375
|
* IS THIS TABLE IN THE ARCHIVE? (lane HUB-FIX, 2026-09-23.) The archived row for one
|
|
@@ -388,7 +397,9 @@ interface RecordsClient {
|
|
|
388
397
|
* The door-presence pattern: when the store's catalogue does not carry the door the
|
|
389
398
|
* answer is `null` — nothing asked, nothing invented.
|
|
390
399
|
*/
|
|
391
|
-
tableFacts(
|
|
400
|
+
tableFacts(args?: {
|
|
401
|
+
organization_id?: Uuid | null;
|
|
402
|
+
}): Promise<RecordsResult<TableFact[] | null>>;
|
|
392
403
|
/**
|
|
393
404
|
* WHICH STORE CURRENTLY WRITES each table — `custom.where_tables_live`.
|
|
394
405
|
*
|
|
@@ -1488,6 +1499,7 @@ interface RecordsClient {
|
|
|
1488
1499
|
*/
|
|
1489
1500
|
recordValuesVersioned(args: {
|
|
1490
1501
|
record_id: Uuid;
|
|
1502
|
+
organization_id?: Uuid | null;
|
|
1491
1503
|
}): Promise<RecordsResult<ReadValue[]>>;
|
|
1492
1504
|
metadataSearch(args: {
|
|
1493
1505
|
text: string;
|
package/dist/core/index.js
CHANGED
|
@@ -40635,6 +40635,51 @@ function createRecordsClient(config) {
|
|
|
40635
40635
|
"recordRead"
|
|
40636
40636
|
);
|
|
40637
40637
|
}
|
|
40638
|
+
const readOrgs = (filter) => {
|
|
40639
|
+
if (filter) return [filter];
|
|
40640
|
+
const all = [...org ? [org] : [], ...config.organizationIds ?? []];
|
|
40641
|
+
const unique = [...new Set(all)];
|
|
40642
|
+
return unique.length > 0 ? unique : [org];
|
|
40643
|
+
};
|
|
40644
|
+
const siblings = /* @__PURE__ */ new Map();
|
|
40645
|
+
const clientFor = (target) => {
|
|
40646
|
+
if (target === org) return client;
|
|
40647
|
+
const key = target;
|
|
40648
|
+
let sibling = siblings.get(key);
|
|
40649
|
+
if (!sibling) {
|
|
40650
|
+
sibling = createRecordsClient({ ...config, organizationId: target, organizationIds: [] });
|
|
40651
|
+
siblings.set(key, sibling);
|
|
40652
|
+
}
|
|
40653
|
+
return sibling;
|
|
40654
|
+
};
|
|
40655
|
+
const recordOrgs = /* @__PURE__ */ new Map();
|
|
40656
|
+
async function acrossOrgs(filter, ask, merge) {
|
|
40657
|
+
const targets = readOrgs(filter);
|
|
40658
|
+
if (targets.length === 1) return ask(clientFor(targets[0] ?? null));
|
|
40659
|
+
const answers = await Promise.all(targets.map((t) => ask(clientFor(t))));
|
|
40660
|
+
const parts = [];
|
|
40661
|
+
let firstError = null;
|
|
40662
|
+
for (const a of answers) {
|
|
40663
|
+
if (a.ok) parts.push(a.data);
|
|
40664
|
+
else firstError ??= a.error;
|
|
40665
|
+
}
|
|
40666
|
+
if (parts.length === 0 && firstError) return err(firstError);
|
|
40667
|
+
return ok(merge(parts));
|
|
40668
|
+
}
|
|
40669
|
+
async function openInOwnOrg(recordId, filter, ask, found) {
|
|
40670
|
+
const known = recordOrgs.get(recordId);
|
|
40671
|
+
const targets = filter ? [filter] : known !== void 0 ? [known, ...readOrgs().filter((t) => t !== known)] : readOrgs();
|
|
40672
|
+
let last = null;
|
|
40673
|
+
for (const t of targets) {
|
|
40674
|
+
const answer = await ask(clientFor(t));
|
|
40675
|
+
if (answer.ok && found(answer.data)) {
|
|
40676
|
+
recordOrgs.set(recordId, t);
|
|
40677
|
+
return answer;
|
|
40678
|
+
}
|
|
40679
|
+
last ??= answer;
|
|
40680
|
+
}
|
|
40681
|
+
return last;
|
|
40682
|
+
}
|
|
40638
40683
|
const client = {
|
|
40639
40684
|
config,
|
|
40640
40685
|
async recordWrite({ table_id, data }) {
|
|
@@ -40763,7 +40808,18 @@ function createRecordsClient(config) {
|
|
|
40763
40808
|
"tableArchive"
|
|
40764
40809
|
);
|
|
40765
40810
|
},
|
|
40766
|
-
async recordRead({ record_id, withComputed = false }) {
|
|
40811
|
+
async recordRead({ record_id, withComputed = false, organization_id }) {
|
|
40812
|
+
if (organization_id && organization_id !== org) {
|
|
40813
|
+
return clientFor(organization_id).recordRead({ record_id, withComputed, organization_id });
|
|
40814
|
+
}
|
|
40815
|
+
if (readOrgs(organization_id).length > 1) {
|
|
40816
|
+
return openInOwnOrg(
|
|
40817
|
+
record_id,
|
|
40818
|
+
organization_id,
|
|
40819
|
+
(sub) => sub.recordRead({ record_id, withComputed, organization_id: sub.config.organizationId }),
|
|
40820
|
+
() => true
|
|
40821
|
+
);
|
|
40822
|
+
}
|
|
40767
40823
|
const door = await callDoor(
|
|
40768
40824
|
DOORS.readRecord,
|
|
40769
40825
|
{ p_organization_id: org, p_record_id: record_id },
|
|
@@ -40799,8 +40855,18 @@ function createRecordsClient(config) {
|
|
|
40799
40855
|
})
|
|
40800
40856
|
);
|
|
40801
40857
|
},
|
|
40802
|
-
async tableFacts() {
|
|
40858
|
+
async tableFacts(args) {
|
|
40803
40859
|
if (!doorExists(DOORS.tableFacts)) return ok(null);
|
|
40860
|
+
if (args?.organization_id && args.organization_id !== org) {
|
|
40861
|
+
return clientFor(args.organization_id).tableFacts(args);
|
|
40862
|
+
}
|
|
40863
|
+
if (readOrgs(args?.organization_id).length > 1) {
|
|
40864
|
+
return acrossOrgs(
|
|
40865
|
+
args?.organization_id,
|
|
40866
|
+
(sub) => sub.tableFacts({ organization_id: sub.config.organizationId }),
|
|
40867
|
+
(parts) => parts.flatMap((p) => p ?? [])
|
|
40868
|
+
);
|
|
40869
|
+
}
|
|
40804
40870
|
return callDoor(DOORS.tableFacts, { p_organization_id: org }, "tableFacts");
|
|
40805
40871
|
},
|
|
40806
40872
|
async tablesLiveWhere({ table_ids }) {
|
|
@@ -41060,7 +41126,18 @@ function createRecordsClient(config) {
|
|
|
41060
41126
|
offset: plan.read.offset
|
|
41061
41127
|
});
|
|
41062
41128
|
},
|
|
41063
|
-
async tableRead({ table_id }) {
|
|
41129
|
+
async tableRead({ table_id, organization_id }) {
|
|
41130
|
+
if (organization_id && organization_id !== org) {
|
|
41131
|
+
return clientFor(organization_id).tableRead({ table_id, organization_id });
|
|
41132
|
+
}
|
|
41133
|
+
if (readOrgs(organization_id).length > 1) {
|
|
41134
|
+
return openInOwnOrg(
|
|
41135
|
+
table_id,
|
|
41136
|
+
organization_id,
|
|
41137
|
+
(sub) => sub.tableRead({ table_id, organization_id: sub.config.organizationId }),
|
|
41138
|
+
(t) => t !== null
|
|
41139
|
+
);
|
|
41140
|
+
}
|
|
41064
41141
|
const kernel = await tableKernel("tableRead.kernel");
|
|
41065
41142
|
if (!kernel.ok) return err(kernel.error);
|
|
41066
41143
|
const door = await callDoor(
|
|
@@ -41074,7 +41151,19 @@ function createRecordsClient(config) {
|
|
|
41074
41151
|
const { document: document2 } = unfold(row.document);
|
|
41075
41152
|
return ok({ ...document2, id: row.id, organization_id: org });
|
|
41076
41153
|
},
|
|
41077
|
-
async tableList() {
|
|
41154
|
+
async tableList(args) {
|
|
41155
|
+
if (args?.organization_id && args.organization_id !== org) {
|
|
41156
|
+
return clientFor(args.organization_id).tableList(args);
|
|
41157
|
+
}
|
|
41158
|
+
if (readOrgs(args?.organization_id).length > 1) {
|
|
41159
|
+
const merged = await acrossOrgs(
|
|
41160
|
+
args?.organization_id,
|
|
41161
|
+
(sub) => sub.tableList({ organization_id: sub.config.organizationId }),
|
|
41162
|
+
(parts) => parts.flat()
|
|
41163
|
+
);
|
|
41164
|
+
if (merged.ok) merged.data.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
41165
|
+
return merged;
|
|
41166
|
+
}
|
|
41078
41167
|
const kernel = await tableKernel("tableList.kernel");
|
|
41079
41168
|
if (!kernel.ok) return err(kernel.error);
|
|
41080
41169
|
const door = await callDoor(
|
|
@@ -42129,7 +42218,18 @@ function createRecordsClient(config) {
|
|
|
42129
42218
|
answered.data.map((row) => ({ ...row, id: row["signature_id"] }))
|
|
42130
42219
|
);
|
|
42131
42220
|
},
|
|
42132
|
-
async recordValuesVersioned({ record_id }) {
|
|
42221
|
+
async recordValuesVersioned({ record_id, organization_id }) {
|
|
42222
|
+
if (organization_id && organization_id !== org) {
|
|
42223
|
+
return clientFor(organization_id).recordValuesVersioned({ record_id, organization_id });
|
|
42224
|
+
}
|
|
42225
|
+
if (readOrgs(organization_id).length > 1) {
|
|
42226
|
+
return openInOwnOrg(
|
|
42227
|
+
record_id,
|
|
42228
|
+
organization_id,
|
|
42229
|
+
(sub) => sub.recordValuesVersioned({ record_id, organization_id: sub.config.organizationId }),
|
|
42230
|
+
(values) => values.length > 0
|
|
42231
|
+
);
|
|
42232
|
+
}
|
|
42133
42233
|
return readValues(record_id);
|
|
42134
42234
|
},
|
|
42135
42235
|
async revisions({ record_id }) {
|
|
@@ -42139,7 +42239,7 @@ function createRecordsClient(config) {
|
|
|
42139
42239
|
"revisions"
|
|
42140
42240
|
);
|
|
42141
42241
|
},
|
|
42142
|
-
async recordScopeContext({ record_id, relations, history, siblings }) {
|
|
42242
|
+
async recordScopeContext({ record_id, relations, history, siblings: siblings2 }) {
|
|
42143
42243
|
return callDoor(
|
|
42144
42244
|
DOORS.recordScopeContext,
|
|
42145
42245
|
{
|
|
@@ -42147,7 +42247,7 @@ function createRecordsClient(config) {
|
|
|
42147
42247
|
p_record_id: record_id,
|
|
42148
42248
|
p_relations: relations ?? 12,
|
|
42149
42249
|
p_history: history ?? 15,
|
|
42150
|
-
p_siblings:
|
|
42250
|
+
p_siblings: siblings2 ?? 8
|
|
42151
42251
|
},
|
|
42152
42252
|
"recordScopeContext"
|
|
42153
42253
|
);
|
|
@@ -42177,7 +42277,7 @@ function createRecordsClient(config) {
|
|
|
42177
42277
|
"conversationScopeUnbind"
|
|
42178
42278
|
);
|
|
42179
42279
|
},
|
|
42180
|
-
async conversationScopeContext({ conversation_id, relations, history, siblings }) {
|
|
42280
|
+
async conversationScopeContext({ conversation_id, relations, history, siblings: siblings2 }) {
|
|
42181
42281
|
return callDoor(
|
|
42182
42282
|
DOORS.conversationScopeContext,
|
|
42183
42283
|
{
|
|
@@ -42185,7 +42285,7 @@ function createRecordsClient(config) {
|
|
|
42185
42285
|
p_conversation_id: conversation_id,
|
|
42186
42286
|
p_relations: relations ?? 12,
|
|
42187
42287
|
p_history: history ?? 15,
|
|
42188
|
-
p_siblings:
|
|
42288
|
+
p_siblings: siblings2 ?? 8
|
|
42189
42289
|
},
|
|
42190
42290
|
"conversationScopeContext"
|
|
42191
42291
|
);
|