@hcmai/sdk 0.27.1 → 0.27.2
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/dist/index.d.ts +32 -0
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -207,11 +207,31 @@ interface QueryWarning {
|
|
|
207
207
|
message?: string;
|
|
208
208
|
suggestion?: string;
|
|
209
209
|
}
|
|
210
|
+
/** match 纳入的一个取值;字面纳入(include)没算过相似度,score 为 null。 */
|
|
211
|
+
interface MatchIncludedValue {
|
|
212
|
+
value: string;
|
|
213
|
+
score?: number | null;
|
|
214
|
+
reason?: string;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 一条 `match` 叶子的改写事实(服务端 `extra.match[]`,core#5841 刀 O)。
|
|
218
|
+
* MATCH_APPLIED 提示正文最多列 `listedInWarning` 个取值,`included` 才是全集。
|
|
219
|
+
*/
|
|
220
|
+
interface MatchResolution {
|
|
221
|
+
field: string;
|
|
222
|
+
mode?: string;
|
|
223
|
+
reason?: string;
|
|
224
|
+
included: MatchIncludedValue[];
|
|
225
|
+
includedTotal?: number;
|
|
226
|
+
listedInWarning?: number;
|
|
227
|
+
}
|
|
210
228
|
interface QueryResult<T = Record<string, unknown>> {
|
|
211
229
|
rows: T[];
|
|
212
230
|
total?: number;
|
|
213
231
|
/** 只在服务端真给了提示时出现。 */
|
|
214
232
|
warnings?: QueryWarning[];
|
|
233
|
+
/** 只在查询里有 match 且服务端给了改写事实时出现。 */
|
|
234
|
+
match?: MatchResolution[];
|
|
215
235
|
}
|
|
216
236
|
interface ActionInput {
|
|
217
237
|
id?: string;
|
|
@@ -335,6 +355,18 @@ interface RelationMeta {
|
|
|
335
355
|
key: string;
|
|
336
356
|
via: string;
|
|
337
357
|
label?: string;
|
|
358
|
+
/** 目标模型;服务端 ADR-474 起随 relations 下发。 */
|
|
359
|
+
target?: string;
|
|
360
|
+
/** one | many;many 的关系只能写进 filter.exists(ADR-474)。缺失 = 服务端没给,不猜。 */
|
|
361
|
+
cardinality?: string;
|
|
362
|
+
/** 外键反向自动登记的关系(仅供 exists)。 */
|
|
363
|
+
auto?: boolean;
|
|
364
|
+
/** INVERSE | FILTER | DERIVED;服务端 core#5841 刀 O 起给。 */
|
|
365
|
+
kind?: string;
|
|
366
|
+
/** 声明它的模型:别处 yml 经 inverseOf 声明给本模型的 FILTER(如 Assignment.yml 的 primaryAssignment)不等于本模型。 */
|
|
367
|
+
declaredIn?: string;
|
|
368
|
+
/** FILTER 关系的过滤条件(`assignmentType:eq:PRIMARY`),主任职与并发任职靠它区分。 */
|
|
369
|
+
filter?: string;
|
|
338
370
|
}
|
|
339
371
|
interface ModelDescription {
|
|
340
372
|
model: string;
|
package/dist/index.js
CHANGED
|
@@ -1597,12 +1597,36 @@ async function query(http, model, dsl) {
|
|
|
1597
1597
|
const url = `/api/models/${model}/list/dsl`;
|
|
1598
1598
|
const resp = dsl.plugin ? await http.post(url, body, { params: { plugin: dsl.plugin } }) : await http.post(url, body);
|
|
1599
1599
|
const warnings = readWarnings(resp.data.extra?.warnings);
|
|
1600
|
+
const match = readMatch(resp.data.extra?.match);
|
|
1600
1601
|
return {
|
|
1601
1602
|
rows: resp.data.content ?? [],
|
|
1602
1603
|
total: resp.data.totalElements,
|
|
1603
|
-
...warnings.length ? { warnings } : {}
|
|
1604
|
+
...warnings.length ? { warnings } : {},
|
|
1605
|
+
...match.length ? { match } : {}
|
|
1604
1606
|
};
|
|
1605
1607
|
}
|
|
1608
|
+
function readMatch(raw) {
|
|
1609
|
+
if (!Array.isArray(raw)) return [];
|
|
1610
|
+
return raw.flatMap((m) => {
|
|
1611
|
+
if (!isPlainObject(m) || typeof m.field !== "string" || !m.field || !Array.isArray(m.included)) return [];
|
|
1612
|
+
const included = m.included.flatMap((hit) => {
|
|
1613
|
+
if (!isPlainObject(hit) || typeof hit.value !== "string") return [];
|
|
1614
|
+
return [{
|
|
1615
|
+
value: hit.value,
|
|
1616
|
+
...typeof hit.score === "number" || hit.score === null ? { score: hit.score } : {},
|
|
1617
|
+
...typeof hit.reason === "string" ? { reason: hit.reason } : {}
|
|
1618
|
+
}];
|
|
1619
|
+
});
|
|
1620
|
+
return [{
|
|
1621
|
+
field: m.field,
|
|
1622
|
+
...typeof m.mode === "string" ? { mode: m.mode } : {},
|
|
1623
|
+
...typeof m.reason === "string" ? { reason: m.reason } : {},
|
|
1624
|
+
included,
|
|
1625
|
+
...typeof m.includedTotal === "number" ? { includedTotal: m.includedTotal } : {},
|
|
1626
|
+
...typeof m.listedInWarning === "number" ? { listedInWarning: m.listedInWarning } : {}
|
|
1627
|
+
}];
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1606
1630
|
function readWarnings(raw) {
|
|
1607
1631
|
if (!Array.isArray(raw)) return [];
|
|
1608
1632
|
return raw.flatMap((w) => {
|
|
@@ -1667,7 +1691,7 @@ function normalizeFilter(filter) {
|
|
|
1667
1691
|
return leaves.length === 1 ? leaves[0] : { and: leaves };
|
|
1668
1692
|
}
|
|
1669
1693
|
function isAstFilter(filter) {
|
|
1670
|
-
return "and" in filter || "or" in filter || "not" in filter || typeof filter.field === "string" && typeof filter.op === "string";
|
|
1694
|
+
return "and" in filter || "or" in filter || "not" in filter || "exists" in filter || typeof filter.field === "string" && typeof filter.op === "string";
|
|
1671
1695
|
}
|
|
1672
1696
|
function filterLeaves(field, value) {
|
|
1673
1697
|
if (isPlainObject(value)) {
|