@hcmai/sdk 0.21.0 → 0.21.1
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.js +61 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -236,7 +236,14 @@ var CliError = class extends Error {
|
|
|
236
236
|
const detailText = formatDetails(details);
|
|
237
237
|
if (detailText) out += `
|
|
238
238
|
\u8BE6\u60C5: ${detailText}`;
|
|
239
|
-
|
|
239
|
+
const reason = this.context?.reason;
|
|
240
|
+
const reasonText = typeof reason === "string" ? reason.trim() : "";
|
|
241
|
+
if (reasonText && reasonText !== this.message.trim()) out += `
|
|
242
|
+
\u539F\u56E0: ${reasonText}`;
|
|
243
|
+
const note = this.context?.note;
|
|
244
|
+
if (typeof note === "string" && note.trim()) out += `
|
|
245
|
+
\u8BF4\u660E: ${note.trim()}`;
|
|
246
|
+
if (!detailText && !reasonText) {
|
|
240
247
|
const causeText = formatCause(this.cause);
|
|
241
248
|
if (causeText) out += `
|
|
242
249
|
\u539F\u56E0: ${causeText}`;
|
|
@@ -262,11 +269,17 @@ function fromAxiosError(err, profile) {
|
|
|
262
269
|
const status = err.response?.status;
|
|
263
270
|
const traceId = err.response?.headers?.["x-trace-id"];
|
|
264
271
|
const data = err.response?.data;
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
const
|
|
272
|
+
const nested = isRecord(data) && isRecord(data.error);
|
|
273
|
+
const body = nested ? data.error : isRecord(data) ? data : void 0;
|
|
274
|
+
const flat = body !== void 0 && !nested;
|
|
275
|
+
const flatError = flat ? nonBlankString(body.error) : void 0;
|
|
276
|
+
const flatErrorIsCode = flatError !== void 0 && CODE_LIKE.test(flatError.trim());
|
|
277
|
+
const respCode = nonBlankString(body?.code) ?? (flat ? nonBlankString(body.errCode) ?? (flatErrorIsCode ? flatError : void 0) : void 0);
|
|
278
|
+
const respMsg = nonBlankString(body?.message) ?? (flat ? nonBlankString(body.error_description) ?? (flatErrorIsCode ? void 0 : flatError) : void 0);
|
|
268
279
|
const respField = body?.field;
|
|
269
280
|
const respDetails = body?.details;
|
|
281
|
+
const respReason = nonBlankString(body?.reason);
|
|
282
|
+
const respNote = nonBlankString(body?.note);
|
|
270
283
|
const respNextStep = body?.next_step ?? body?.nextStep;
|
|
271
284
|
const respRetryable = body?.retryable;
|
|
272
285
|
const localDiagnosis = respCode === REJECTED_BEFORE_ROUTING_CODE ? diagnoseRejectedBeforeRouting(err.config?.url, err.config?.baseURL) : void 0;
|
|
@@ -289,6 +302,8 @@ function fromAxiosError(err, profile) {
|
|
|
289
302
|
// nextStep 是后端给的路标(ADR-166 终局协议)—— 吞掉它等于让命令行用户自己猜下一步。
|
|
290
303
|
...respField ? { field: respField } : {},
|
|
291
304
|
...respDetails !== void 0 ? { details: respDetails } : {},
|
|
305
|
+
...respReason ? { reason: respReason } : {},
|
|
306
|
+
...respNote ? { note: respNote } : {},
|
|
292
307
|
...respNextStep ? { nextStep: respNextStep } : {},
|
|
293
308
|
...respRetryable !== void 0 ? { retryable: respRetryable } : {},
|
|
294
309
|
// 与后端的 nextStep 并存、不互相覆盖:一个是服务端的通用路标,一个是本地对症结论。
|
|
@@ -299,6 +314,13 @@ function fromAxiosError(err, profile) {
|
|
|
299
314
|
cause: err
|
|
300
315
|
});
|
|
301
316
|
}
|
|
317
|
+
var CODE_LIKE = /^(?:[A-Z][A-Z0-9_]*|[a-z][a-z0-9]*(?:_[a-z0-9]+)+)$/;
|
|
318
|
+
function isRecord(value) {
|
|
319
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
320
|
+
}
|
|
321
|
+
function nonBlankString(value) {
|
|
322
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
323
|
+
}
|
|
302
324
|
function formatDetails(details) {
|
|
303
325
|
if (details === void 0 || details === null) return void 0;
|
|
304
326
|
if (typeof details === "string") return details.trim() || void 0;
|
|
@@ -14288,7 +14310,7 @@ function actionsPath(modelKey, state = "") {
|
|
|
14288
14310
|
if (!state) return base;
|
|
14289
14311
|
return `${base}?${new URLSearchParams({ state }).toString()}`;
|
|
14290
14312
|
}
|
|
14291
|
-
function
|
|
14313
|
+
function isRecord2(v) {
|
|
14292
14314
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
14293
14315
|
}
|
|
14294
14316
|
function keyOrNull(key) {
|
|
@@ -14330,7 +14352,7 @@ async function collectActionGates(probe, modelKeys2, state = "") {
|
|
|
14330
14352
|
continue;
|
|
14331
14353
|
}
|
|
14332
14354
|
const body = out.body;
|
|
14333
|
-
if (!
|
|
14355
|
+
if (!isRecord2(body) || !Array.isArray(body.actions)) {
|
|
14334
14356
|
unavailable.push({
|
|
14335
14357
|
modelKey: model,
|
|
14336
14358
|
status: out.status,
|
|
@@ -14346,13 +14368,13 @@ async function collectActionGates(probe, modelKeys2, state = "") {
|
|
|
14346
14368
|
else statesEchoed.add(echoed);
|
|
14347
14369
|
for (const action3 of body.actions) {
|
|
14348
14370
|
actionsSeen += 1;
|
|
14349
|
-
if (!
|
|
14371
|
+
if (!isRecord2(action3)) {
|
|
14350
14372
|
reject(rejected, model, null, "malformed-action");
|
|
14351
14373
|
continue;
|
|
14352
14374
|
}
|
|
14353
14375
|
const cands = Array.isArray(action3.candidates) ? action3.candidates : [];
|
|
14354
14376
|
for (const c of cands) {
|
|
14355
|
-
if (
|
|
14377
|
+
if (isRecord2(c) && typeof c.source === "string" && c.source) sources.add(c.source);
|
|
14356
14378
|
}
|
|
14357
14379
|
const effectClass = classifyEffect(action3.effect);
|
|
14358
14380
|
if (effectClass !== "absent") actionsWithEffect += 1;
|
|
@@ -14396,7 +14418,7 @@ async function collectActionGates(probe, modelKeys2, state = "") {
|
|
|
14396
14418
|
reject(rejected, model, key, "no-candidates");
|
|
14397
14419
|
continue;
|
|
14398
14420
|
}
|
|
14399
|
-
if (!cands.every((c) =>
|
|
14421
|
+
if (!cands.every((c) => isRecord2(c))) {
|
|
14400
14422
|
reject(rejected, model, key, "malformed-candidate");
|
|
14401
14423
|
continue;
|
|
14402
14424
|
}
|
|
@@ -14719,7 +14741,7 @@ var badSection = (t) => `\u4F20\u5165\u7684 mutation \u6BB5\u4E0D\u662F\u5BF9\u8
|
|
|
14719
14741
|
var badCell = (op, t) => `\u4F20\u5165\u7684 mutation \u91CC ${op} \u8FD9\u4E00\u9879\u4E0D\u662F\u5BF9\u8C61\uFF08${t}\uFF09\uFF0C\u65E0\u6CD5\u5224\u8BFB`;
|
|
14720
14742
|
var missingCell = (op) => `\u4F20\u5165\u7684 mutation \u91CC\u6CA1\u6709 ${op} \u8FD9\u4E00\u9879`;
|
|
14721
14743
|
var WORDING3 = 'writable=false \u7684\u4E24\u79CD\u539F\u56E0\uFF1Aderived:<kind>\uFF08\u6D3E\u751F\u5B57\u6BB5\uFF0C\u670D\u52A1\u7AEF\u7B97\u51FA\u6765\u7684\uFF09\u3001readonly\uFF08\u5143\u6570\u636E\u58F0\u660E\u53EA\u8BFB\uFF09\u3002autoGenerate=true \u7684\u5B57\u6BB5\uFF08\u5DE5\u53F7 / \u7EC4\u7EC7 / \u5C97\u4F4D / \u6CD5\u4EBA\u7F16\u7801\u7B49\uFF09**\u4E0D\u662F**\u4E0D\u53EF\u5199\uFF1A\u670D\u52A1\u7AEF\u53EA\u5728\u5B57\u6BB5\u4E3A\u7A7A\u65F6\u751F\u6210\uFF0C\u8C03\u7528\u65B9\u624B\u5DE5\u6307\u5B9A\u7684\u503C\u4F18\u5148 \u2014\u2014 \u7531\u72EC\u7ACB\u6807\u8BB0 `autoGeneratedIfAbsent` \u70B9\u540D\uFF08\u4E0D\u9001\u5219\u751F\u6210\u3001\u9001\u5219\u91C7\u7EB3\uFF09\uFF0C\u4E0D\u518D\u8FDB notWritableReason\u3002\u{1F534} writable=true **\u53EA\u8868\u793A\u5143\u6570\u636E\u6CA1\u58F0\u660E\u8FD9\u4E24\u79CD\u4E0D\u53EF\u5199**\uFF0C\u4E0D\u8868\u793A\u8FD9\u4E2A\u5B57\u6BB5\u8BE5\u7531\u987E\u95EE\u586B \u2014\u2014 \u5B9E\u6D4B createById / updateById \u8FD9 1476 \u4E2A\u5BA1\u8BA1\u5B57\u6BB5\u56DB\u4E2A\u6807\u5FD7\u5168\u662F false\uFF0C\u7167\u6837\u662F writable=true\uFF0C\u5B83\u4EEC\u7531 ref.auditBackref=true \u70B9\u540D\uFF08topology \u628A\u540C\u4E00\u6279\u8FB9\u6392\u9664\u51FA\u4F9D\u8D56\u56FE\uFF0C\u8FD9\u91CC\u4E0D\u6392\u9664\uFF1Amapping \u662F\u5B57\u6BB5\u6E05\u5355\uFF0C\u4E0D\u662F\u4F9D\u8D56\u56FE\uFF09\u3002ref.valueDomain \u53EA\u5728\u76EE\u6807\u662F\u7801\u8868\uFF08DYNAMIC / CO_*\uFF09\u65F6\u7ED9\u51FA\uFF1B\u6307\u5411\u4E1A\u52A1\u6A21\u578B\u65F6\u4E3A null \u2014\u2014 \u5B9E\u6D4B 234 \u4E2A\u58F0\u660E\u51FA\u6765\u7684\u5F15\u7528\u76EE\u6807\u91CC\uFF0C230 \u4E2A\u5728\u540D\u518C\u4E2D\uFF1A\u5176\u4E2D 32 \u4E2A\u662F\u7801\u8868\u3001198 \u4E2A\u662F\u4E1A\u52A1\u6A21\u578B\uFF08User 1564 / OrgUnit 292 / Employee 199 \u2026\uFF09\u8981\u6309\u4E1A\u52A1\u952E\u73B0\u67E5\uFF1B\u53E6\u6709 4 \u4E2A\u60AC\u7A7A\u76EE\u6807\uFF08\u58F0\u660E\u4E86\u5F15\u7528\u4F46\u4E0D\u5728 /api/system/models \u540D\u518C\u91CC\uFF0C\u89C1 topology.json \u7684 dangling\uFF09\u3002valuedomain \u91CC\u6CA1\u6709\u4E1A\u52A1\u6A21\u578B\u7684\u5BF9\u7167\u8868\uFF0C\u6307\u4E00\u4E2A\u4E0D\u5B58\u5728\u7684\u6587\u4EF6\u6BD4\u4E0D\u6307\u66F4\u7CDF\uFF1A\u987E\u95EE\u4F1A\u4EE5\u4E3A\u90A3\u4EFD\u5BF9\u7167\u8868\u53EA\u662F\u8FD8\u6CA1\u751F\u6210\u3002ref.labelFieldSource=unknown \u8868\u793A\u4EA7\u54C1\u6CA1\u58F0\u660E\u663E\u793A\u5B57\u6BB5\u540D\uFF08\u5B9E\u6D4B\u8FDB\u56FE\u7684 2923 \u6761\u8FB9\u91CC 1366 \u6761\u6CA1\u58F0\u660E\uFF09\uFF0C**\u4E0D\u662F**\u300C\u9ED8\u8BA4\u7528 name\u300D\u2014\u2014 \u90A3 1366 \u6761\u6307\u5411 224 \u4E2A\u5728\u518C\u76EE\u6807\uFF0C\u5176\u4E2D 60 \u4E2A\uFF0827%\uFF0C\u76EE\u6807\u6A21\u578B\u53E3\u5F84\uFF09\u8FDE name \u5B57\u6BB5\u90FD\u6CA1\u6709\uFF0C\u6309\u8FB9\u7B97 152 \u6761\uFF0811%\uFF0C\u5B57\u6BB5\u53E3\u5F84\uFF09\u843D\u5728\u5B83\u4EEC\u8EAB\u4E0A\u3002mutation.allowed \u6052\u4E3A\u4E09\u4E2A\u503C\u4E4B\u4E00\uFF1Atrue / false / "unknown"\u3002"unknown" \u8868\u793A\u8BE5\u6A21\u578B\u8FD9\u4E00\u9879\u6CA1\u67E5\u5230\uFF0C**\u4E0D\u662F**\u300C\u5141\u8BB8\u300D\uFF1B\u5177\u4F53\u662F\u54EA\u4E00\u79CD\u6CA1\u67E5\u5230\u770B reason\uFF08\u670D\u52A1\u7AEF\u4FA7\uFF1A\u6CA1\u5E94\u7B54 / \u54CD\u5E94\u7F3A\u8FD9\u4E00\u9879 / allowed \u4E0D\u662F\u5E03\u5C14\uFF1B\u5DE5\u5177\u4FA7\uFF1A\u5E76\u53D1\u6279\u6B21\u91CC\u6CA1\u62FF\u5230\u8FD9\u4E2A\u6A21\u578B\u7684\u7ED3\u679C\uFF1B\u8C03\u7528\u65B9\u4FA7\uFF1A\u672C\u8F6E\u6CA1\u67E5 / \u4F20\u5165\u7684 mutation \u6BB5\u4E0D\u662F\u5BF9\u8C61 / \u4F20\u5165\u7684\u8FD9\u4E00\u9879\u4E0D\u662F\u5BF9\u8C61 / \u4F20\u5165\u7684\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879 \u2014\u2014 \u516B\u79CD\u6210\u56E0\u63AA\u8F9E\u5404\u4E0D\u76F8\u540C\uFF0C\u300C\u4F20\u5165\u7684\u300D\u5F00\u5934\u7684\u662F\u62FC\u8FD9\u4EFD\u57FA\u7EBF\u7684\u4EBA\u641E\u9519\u4E86\uFF0C\u4E0D\u662F\u670D\u52A1\u7AEF\uFF09\u3002enumCount \u6570\u7684\u662F\u8BE5\u5B57\u6BB5\u5019\u9009\u503C\u7684**\u5143\u7D20\u4E2A\u6570**\uFF0C\u4E0E index/fields.jsonl \u91CC\u8BE5\u5B57\u6BB5\u7684 enums \u884C\u6570\u76F8\u7B49\u3002';
|
|
14722
|
-
function
|
|
14744
|
+
function isRecord3(v) {
|
|
14723
14745
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
14724
14746
|
}
|
|
14725
14747
|
function typeName2(v) {
|
|
@@ -14744,7 +14766,7 @@ async function collectMutation(probe, modelKeys2) {
|
|
|
14744
14766
|
continue;
|
|
14745
14767
|
}
|
|
14746
14768
|
const body = out.error === "ok" ? out.body : null;
|
|
14747
|
-
if (!
|
|
14769
|
+
if (!isRecord3(body)) {
|
|
14748
14770
|
const reason = `\u672A\u5E94\u7B54\uFF08HTTP ${out.status} / ${out.error}\uFF09`;
|
|
14749
14771
|
problems.push(`${key}: mutation-capability ${reason}`);
|
|
14750
14772
|
mutation[key] = Object.fromEntries(MUTATION_OPS.map((op) => [op, { allowed: "unknown", reason }]));
|
|
@@ -14753,7 +14775,7 @@ async function collectMutation(probe, modelKeys2) {
|
|
|
14753
14775
|
const entry = {};
|
|
14754
14776
|
for (const op of MUTATION_OPS) {
|
|
14755
14777
|
const cell = body[op];
|
|
14756
|
-
if (!
|
|
14778
|
+
if (!isRecord3(cell) || !("allowed" in cell)) {
|
|
14757
14779
|
entry[op] = { allowed: "unknown", reason: `\u54CD\u5E94\u91CC\u6CA1\u6709 ${op} \u8FD9\u4E00\u9879` };
|
|
14758
14780
|
problems.push(`${key}: mutation-capability \u54CD\u5E94\u7F3A ${op}`);
|
|
14759
14781
|
continue;
|
|
@@ -14774,14 +14796,14 @@ function mutationSection(entry) {
|
|
|
14774
14796
|
if (entry === void 0 || entry === null) {
|
|
14775
14797
|
return Object.fromEntries(MUTATION_OPS.map((op) => [op, { allowed: "unknown", reason: NOT_QUERIED }]));
|
|
14776
14798
|
}
|
|
14777
|
-
if (!
|
|
14799
|
+
if (!isRecord3(entry)) {
|
|
14778
14800
|
const reason = badSection(typeName2(entry));
|
|
14779
14801
|
return Object.fromEntries(MUTATION_OPS.map((op) => [op, { allowed: "unknown", reason }]));
|
|
14780
14802
|
}
|
|
14781
14803
|
const section = {};
|
|
14782
14804
|
for (const op of MUTATION_OPS) {
|
|
14783
14805
|
const cell = entry[op];
|
|
14784
|
-
if (
|
|
14806
|
+
if (isRecord3(cell)) {
|
|
14785
14807
|
section[op] = cell;
|
|
14786
14808
|
} else if (op in entry) {
|
|
14787
14809
|
section[op] = { allowed: "unknown", reason: badCell(op, typeName2(cell)) };
|
|
@@ -14794,7 +14816,7 @@ function mutationSection(entry) {
|
|
|
14794
14816
|
function writability(field) {
|
|
14795
14817
|
const derived = field.derived;
|
|
14796
14818
|
if (derived) {
|
|
14797
|
-
const kind =
|
|
14819
|
+
const kind = isRecord3(derived) ? derived.kind : null;
|
|
14798
14820
|
return { writable: false, reason: `derived:${typeof kind === "string" && kind ? kind : "unknown"}` };
|
|
14799
14821
|
}
|
|
14800
14822
|
if (field.isReadonly) return { writable: false, reason: "readonly" };
|
|
@@ -14809,7 +14831,7 @@ function buildMapping(metas, edges, mutation, codeTables = []) {
|
|
|
14809
14831
|
const { fields, problem: problem6 } = metaFields(metas[modelKey]);
|
|
14810
14832
|
const rows = [];
|
|
14811
14833
|
for (const f of fields) {
|
|
14812
|
-
if (!
|
|
14834
|
+
if (!isRecord3(f)) continue;
|
|
14813
14835
|
const key = f.key;
|
|
14814
14836
|
if (typeof key !== "string" || !key) continue;
|
|
14815
14837
|
const { writable, reason } = writability(f);
|
|
@@ -14852,7 +14874,7 @@ function buildMapping(metas, edges, mutation, codeTables = []) {
|
|
|
14852
14874
|
// 「爬过且这个模型确实没有字段」必须与「没爬过」(文件不存在)区分开。
|
|
14853
14875
|
crawled: true,
|
|
14854
14876
|
wording: WORDING3,
|
|
14855
|
-
mutation: mutationSection(
|
|
14877
|
+
mutation: mutationSection(isRecord3(mutation) ? mutation[modelKey] : mutation),
|
|
14856
14878
|
fieldCount: rows.length,
|
|
14857
14879
|
// 🔴 `null` = 载荷判读正常(fieldCount=0 就是「这个模型确实没字段」);
|
|
14858
14880
|
// 非 null = **爬过、但判不出字段**,此时 fieldCount=0 不代表「没字段」。
|
|
@@ -14864,8 +14886,8 @@ function buildMapping(metas, edges, mutation, codeTables = []) {
|
|
|
14864
14886
|
}
|
|
14865
14887
|
function allowedIn(sheet, op) {
|
|
14866
14888
|
const section = sheet.mutation;
|
|
14867
|
-
const cell =
|
|
14868
|
-
return
|
|
14889
|
+
const cell = isRecord3(section) ? section[op] : void 0;
|
|
14890
|
+
return isRecord3(cell) ? cell.allowed : "unknown";
|
|
14869
14891
|
}
|
|
14870
14892
|
var PATH_SEPARATORS = ["/", String.fromCharCode(92)];
|
|
14871
14893
|
function unsafeKeyReason(modelKey) {
|
|
@@ -15047,7 +15069,7 @@ function writeModelsMd(layout, text3) {
|
|
|
15047
15069
|
// src/fde/recon/pointer-audit.ts
|
|
15048
15070
|
import { existsSync as existsSync4 } from "fs";
|
|
15049
15071
|
import * as path9 from "path";
|
|
15050
|
-
function
|
|
15072
|
+
function isRecord4(v) {
|
|
15051
15073
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
15052
15074
|
}
|
|
15053
15075
|
function auditValueDomainPointers(layout, sheets) {
|
|
@@ -15056,7 +15078,7 @@ function auditValueDomainPointers(layout, sheets) {
|
|
|
15056
15078
|
for (const sheet of sheets) {
|
|
15057
15079
|
for (const field of sheet.fields) {
|
|
15058
15080
|
const ref = field.ref;
|
|
15059
|
-
const pointer =
|
|
15081
|
+
const pointer = isRecord4(ref) ? ref.valueDomain : null;
|
|
15060
15082
|
if (typeof pointer !== "string" || pointer === "") continue;
|
|
15061
15083
|
if (!seen.has(pointer)) {
|
|
15062
15084
|
seen.set(pointer, existsSync4(path9.join(layout.dir, pointer)));
|
|
@@ -15147,18 +15169,18 @@ var WORDING4 = "rows = \u672C\u8F6E\u4EE5\u5F53\u524D\u767B\u5F55\u8EAB\u4EFD\u8
|
|
|
15147
15169
|
function listPath(modelKey) {
|
|
15148
15170
|
return `/api/models/${modelKey}/list/dsl`;
|
|
15149
15171
|
}
|
|
15150
|
-
function
|
|
15172
|
+
function isRecord5(v) {
|
|
15151
15173
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
15152
15174
|
}
|
|
15153
15175
|
function readContent(body) {
|
|
15154
|
-
if (!
|
|
15176
|
+
if (!isRecord5(body)) return { rows: null, total: null, nonDict: 0 };
|
|
15155
15177
|
const rows = body.content;
|
|
15156
15178
|
const total = body.totalElements;
|
|
15157
15179
|
if (!Array.isArray(rows)) return { rows: null, total: null, nonDict: 0 };
|
|
15158
15180
|
if (typeof total !== "number" || !Number.isInteger(total) || total < 0) {
|
|
15159
15181
|
return { rows: null, total: null, nonDict: 0 };
|
|
15160
15182
|
}
|
|
15161
|
-
const kept = rows.filter((r) =>
|
|
15183
|
+
const kept = rows.filter((r) => isRecord5(r));
|
|
15162
15184
|
return { rows: kept, total, nonDict: rows.length - kept.length };
|
|
15163
15185
|
}
|
|
15164
15186
|
async function collectCodeTables(probe, modelEntries2, opts = {}) {
|
|
@@ -15171,7 +15193,7 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
|
|
|
15171
15193
|
const problems = [];
|
|
15172
15194
|
const keys = [];
|
|
15173
15195
|
for (const entry of modelEntries2) {
|
|
15174
|
-
if (!
|
|
15196
|
+
if (!isRecord5(entry) || entry.type !== DYNAMIC_TYPE) continue;
|
|
15175
15197
|
const key = entry.modelKey;
|
|
15176
15198
|
if (typeof key !== "string" || !key) {
|
|
15177
15199
|
problems.push(`\u540D\u518C\u91CC\u6709\u4E00\u6761 type=DYNAMIC \u7684\u6761\u76EE\u4F46 modelKey \u4E0D\u53EF\u7528\uFF08${JSON.stringify(key)}\uFF09\uFF0C\u5DF2\u8DF3\u8FC7`);
|
|
@@ -15305,12 +15327,12 @@ function collectEnumDomains(metas) {
|
|
|
15305
15327
|
for (const modelKey of Object.keys(metas).sort()) {
|
|
15306
15328
|
const { fields } = metaFields(metas[modelKey]);
|
|
15307
15329
|
for (const field of fields) {
|
|
15308
|
-
if (!
|
|
15330
|
+
if (!isRecord5(field)) continue;
|
|
15309
15331
|
const fieldKey = field.key;
|
|
15310
15332
|
if (typeof fieldKey !== "string" || !fieldKey) continue;
|
|
15311
15333
|
const enums = field.enums;
|
|
15312
15334
|
if (!Array.isArray(enums) || enums.length === 0) continue;
|
|
15313
|
-
const kept = enums.filter(
|
|
15335
|
+
const kept = enums.filter(isRecord5).map((e) => ({ ...e }));
|
|
15314
15336
|
rows.push({
|
|
15315
15337
|
model: modelKey,
|
|
15316
15338
|
field: fieldKey,
|
|
@@ -15321,7 +15343,7 @@ function collectEnumDomains(metas) {
|
|
|
15321
15343
|
// —— 否则「这个字段的枚举少了一项」这件事没有任何出处。
|
|
15322
15344
|
// 实测 3179 条全是对象,这一档从未观测到;**恒发空列表**而不是条件出键:
|
|
15323
15345
|
// 「有这一列且为空」与「没这一列」是两个值,后者读起来像「没检查过」。
|
|
15324
|
-
nonDictElements: enums.filter((e) => !
|
|
15346
|
+
nonDictElements: enums.filter((e) => !isRecord5(e)).map((e) => JSON.stringify(e) ?? String(e))
|
|
15325
15347
|
});
|
|
15326
15348
|
}
|
|
15327
15349
|
}
|
|
@@ -15366,7 +15388,7 @@ function writeValuedomain(layout, codeTables, enums, opts = {}) {
|
|
|
15366
15388
|
roundId: opts.roundId ?? null,
|
|
15367
15389
|
// 🔴 `identity || {}` 会把「调用方没传身份」和「身份是空的」压成同一个值,
|
|
15368
15390
|
// 而它们的下一步不同(前者去补工具的登录,后者去问服务端为什么不给 user)。
|
|
15369
|
-
identity:
|
|
15391
|
+
identity: isRecord5(opts.identity) ? opts.identity : null,
|
|
15370
15392
|
codeTableCount: Object.keys(codeTables).length,
|
|
15371
15393
|
enumFieldCount: enums.length,
|
|
15372
15394
|
// 🔴 名册里一共看到几条。上游名册加载失败给出空数组时,产物会与
|
|
@@ -15436,7 +15458,7 @@ function parseRoundStamp(stamp2) {
|
|
|
15436
15458
|
function newRoundId(started) {
|
|
15437
15459
|
return `${roundStamp(started)}-${randomBytes3(4).toString("hex")}`;
|
|
15438
15460
|
}
|
|
15439
|
-
function
|
|
15461
|
+
function isRecord6(v) {
|
|
15440
15462
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
15441
15463
|
}
|
|
15442
15464
|
function readJsonSoft(file) {
|
|
@@ -15455,8 +15477,8 @@ function readJsonSoft(file) {
|
|
|
15455
15477
|
}
|
|
15456
15478
|
function readCrawledAt(layout) {
|
|
15457
15479
|
const body = readJsonSoft(path10.join(layout.dir, KIT_CRAWLED_AT_FILE));
|
|
15458
|
-
const models =
|
|
15459
|
-
return
|
|
15480
|
+
const models = isRecord6(body) ? body.models : null;
|
|
15481
|
+
return isRecord6(models) ? models : {};
|
|
15460
15482
|
}
|
|
15461
15483
|
function writeCrawledAt(layout, freshKeys, carriedKeys, roundId, started) {
|
|
15462
15484
|
const previous = readCrawledAt(layout);
|
|
@@ -15504,14 +15526,14 @@ function productRoundId(root, rel) {
|
|
|
15504
15526
|
const p = path10.join(root, rel);
|
|
15505
15527
|
if (!existsSync5(p)) return ["missing", null];
|
|
15506
15528
|
const body = readJsonSoft(p);
|
|
15507
|
-
if (body === void 0 || !
|
|
15529
|
+
if (body === void 0 || !isRecord6(body)) return ["unreadable", null];
|
|
15508
15530
|
const rid = body.roundId;
|
|
15509
15531
|
if (typeof rid !== "string" || !rid) return ["unstamped", null];
|
|
15510
15532
|
return ["stamped", rid];
|
|
15511
15533
|
}
|
|
15512
15534
|
function inspectRound(root) {
|
|
15513
15535
|
const raw = readJsonSoft(path10.join(root, KIT_CRAWLED_AT_FILE));
|
|
15514
|
-
const ledger =
|
|
15536
|
+
const ledger = isRecord6(raw) ? raw : {};
|
|
15515
15537
|
const rid = ledger.roundId;
|
|
15516
15538
|
const roundId = typeof rid === "string" && rid ? rid : null;
|
|
15517
15539
|
const rawWritten = ledger.productsWrittenThisRound;
|
|
@@ -15616,7 +15638,7 @@ function renderRound(result) {
|
|
|
15616
15638
|
}
|
|
15617
15639
|
var SCHEMA_RECRAWL_NEXT = "\u4E0B\u4E00\u6B65\uFF1A\u8DD1\u4E00\u6B21**\u5168\u91CF** `hcm chiron recon`\uFF08\u628A `--model` \u53BB\u6389\uFF09\uFF0C\u6574\u4EFD\u57FA\u7EBF\u624D\u90FD\u51FA\u81EA\u672C\u7248 kit\u3002";
|
|
15618
15640
|
function carriedGatesSchemaProblem(oldGates) {
|
|
15619
|
-
if (!
|
|
15641
|
+
if (!isRecord6(oldGates)) {
|
|
15620
15642
|
const shape = Array.isArray(oldGates) ? "list" : oldGates === null ? "null" : typeof oldGates;
|
|
15621
15643
|
return `gates.json: \u4E0A\u4E00\u8F6E\u7684\u95F8\u8868\u8F7D\u8377\u662F ${shape} \u4E0D\u662F\u5BF9\u8C61\uFF0C\u65E2\u8BFB\u4E0D\u51FA schema \u7248\u672C\u3001\u4E5F\u4E00\u6761\u95F8\u90FD\u6CBF\u7528\u4E0D\u4E86\uFF08\u672C\u8F6E\u7684 gates \u6570\u7EC4\u91CC\u53EA\u6709\u8FD9\u4E00\u8F6E\u771F\u722C\u5230\u7684\uFF09\u3002${SCHEMA_RECRAWL_NEXT}`;
|
|
15622
15644
|
}
|
|
@@ -15657,7 +15679,7 @@ function collectCarryOver(layout, freshMetas) {
|
|
|
15657
15679
|
problems.push(`${name}: \u8BFB\u4E0D\u56DE\u4E0A\u4E00\u8F6E\u7684 meta\uFF08${e.message}\uFF09\uFF0C\u8BE5\u6A21\u578B\u8FD9\u6B21\u4E0D\u8FDB\u7D22\u5F15`);
|
|
15658
15680
|
continue;
|
|
15659
15681
|
}
|
|
15660
|
-
if (
|
|
15682
|
+
if (isRecord6(body)) carriedMetas[key] = body;
|
|
15661
15683
|
else {
|
|
15662
15684
|
problems.push(
|
|
15663
15685
|
`${name}: \u4E0A\u4E00\u8F6E\u7684 meta \u8F7D\u8377\u662F ${Array.isArray(body) ? "list" : body === null ? "null" : typeof body} \u4E0D\u662F\u5BF9\u8C61\uFF0C\u8BE5\u6A21\u578B\u8FD9\u6B21\u4E0D\u8FDB\u7D22\u5F15`
|
|
@@ -15672,9 +15694,9 @@ function collectCarryOver(layout, freshMetas) {
|
|
|
15672
15694
|
const stale = carriedGatesSchemaProblem(oldGates);
|
|
15673
15695
|
if (stale) problems.push(stale);
|
|
15674
15696
|
}
|
|
15675
|
-
const oldList =
|
|
15697
|
+
const oldList = isRecord6(oldGates) && Array.isArray(oldGates.gates) ? oldGates.gates : [];
|
|
15676
15698
|
for (const g of oldList) {
|
|
15677
|
-
if (
|
|
15699
|
+
if (isRecord6(g) && !(String(g.model) in freshMetas)) carriedGates.push(g);
|
|
15678
15700
|
}
|
|
15679
15701
|
return { carriedMetas, carriedGates, problems };
|
|
15680
15702
|
}
|
|
@@ -15798,7 +15820,7 @@ async function runRecon(probe, layout, opts = {}) {
|
|
|
15798
15820
|
products.push(...mappingPaths.map((p) => relOf(layout, p)));
|
|
15799
15821
|
const sheetsWritten = Math.max(mappingPaths.length - 1, 0);
|
|
15800
15822
|
let previous = readJsonSoft(path10.join(layout.dir, "fingerprint.json"));
|
|
15801
|
-
if (!
|
|
15823
|
+
if (!isRecord6(previous)) previous = null;
|
|
15802
15824
|
const current = await computeFingerprint(probe);
|
|
15803
15825
|
products.push(relOf(layout, layout.writeJson("fingerprint.json", current)));
|
|
15804
15826
|
const drift = previous === null ? null : compareFingerprint(previous, current);
|