@hcmai/sdk 0.30.0 → 0.31.0
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 +261 -5
- package/dist/index.js +550 -97
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -66,6 +66,8 @@ var ExitCode = /* @__PURE__ */ ((ExitCode2) => {
|
|
|
66
66
|
ExitCode2[ExitCode2["BUSINESS_ERROR"] = 3] = "BUSINESS_ERROR";
|
|
67
67
|
ExitCode2[ExitCode2["NETWORK_ERROR"] = 4] = "NETWORK_ERROR";
|
|
68
68
|
ExitCode2[ExitCode2["CONFIG_ERROR"] = 5] = "CONFIG_ERROR";
|
|
69
|
+
ExitCode2[ExitCode2["VERIFY_MISMATCH"] = 6] = "VERIFY_MISMATCH";
|
|
70
|
+
ExitCode2[ExitCode2["VERIFY_UNAVAILABLE"] = 7] = "VERIFY_UNAVAILABLE";
|
|
69
71
|
ExitCode2[ExitCode2["SIGINT"] = 130] = "SIGINT";
|
|
70
72
|
return ExitCode2;
|
|
71
73
|
})(ExitCode || {});
|
|
@@ -258,9 +260,9 @@ var CliError = class extends Error {
|
|
|
258
260
|
const localDiagnosis = this.context?.localDiagnosis;
|
|
259
261
|
if (typeof localDiagnosis === "string" && localDiagnosis) out += `
|
|
260
262
|
\u8BCA\u65AD: ${localDiagnosis}`;
|
|
261
|
-
const
|
|
262
|
-
if (typeof
|
|
263
|
-
\u4E0B\u4E00\u6B65: ${
|
|
263
|
+
const nextStep2 = this.context?.nextStep;
|
|
264
|
+
if (typeof nextStep2 === "string" && nextStep2) out += `
|
|
265
|
+
\u4E0B\u4E00\u6B65: ${nextStep2}`;
|
|
264
266
|
return out;
|
|
265
267
|
}
|
|
266
268
|
toJSON() {
|
|
@@ -566,11 +568,11 @@ var SDK_VERSION = manifest.version;
|
|
|
566
568
|
|
|
567
569
|
// src/http/endpoint.ts
|
|
568
570
|
function assertUsableEndpoint(endpoint, field = "endpoint") {
|
|
569
|
-
const fail2 = (message,
|
|
571
|
+
const fail2 = (message, nextStep2) => {
|
|
570
572
|
throw new CliError({
|
|
571
573
|
code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */,
|
|
572
574
|
message,
|
|
573
|
-
context: { field, nextStep }
|
|
575
|
+
context: { field, nextStep: nextStep2 }
|
|
574
576
|
});
|
|
575
577
|
};
|
|
576
578
|
if (!endpoint) {
|
|
@@ -1968,7 +1970,10 @@ async function listModels(http) {
|
|
|
1968
1970
|
|
|
1969
1971
|
// src/models/create.ts
|
|
1970
1972
|
function writeParams(opts) {
|
|
1971
|
-
|
|
1973
|
+
const params = {};
|
|
1974
|
+
if (opts?.i18n) params.i18n = "true";
|
|
1975
|
+
if (opts?.verify) params.verify = "true";
|
|
1976
|
+
return Object.keys(params).length ? { params } : {};
|
|
1972
1977
|
}
|
|
1973
1978
|
async function create(http, model, data, opts) {
|
|
1974
1979
|
const resp = await http.post(`/api/models/${model}`, data, writeParams(opts));
|
|
@@ -2166,6 +2171,270 @@ function parseFixture(yamlText, sourcePath) {
|
|
|
2166
2171
|
return fixture;
|
|
2167
2172
|
}
|
|
2168
2173
|
|
|
2174
|
+
// src/models/write-verification.ts
|
|
2175
|
+
var EXCLUDED_REASONS = {
|
|
2176
|
+
SYSTEM_FIELD: "\u7CFB\u7EDF\u5B57\u6BB5\uFF0C\u7531\u670D\u52A1\u7AEF\u7EF4\u62A4\uFF0C\u4E0D\u6BD4",
|
|
2177
|
+
NULL_IS_NO_OP: "\u9001\u7684\u662F null\uFF0C\u6309\u534F\u8BAE\u4E0D\u6539\u8FD9\u4E00\u683C\uFF1B\u8981\u6E05\u7A7A\u7528 _clearFields",
|
|
2178
|
+
SERVER_GENERATES_WHEN_EMPTY: "\u9001\u7684\u662F\u7A7A\u4E32\uFF0C\u7F16\u7801\u7531\u670D\u52A1\u7AEF\u6309\u7F16\u7801\u89C4\u5219\u751F\u6210\uFF0C\u4E0D\u6BD4",
|
|
2179
|
+
TIMELINE_MANAGED: "\u65F6\u95F4\u8F74\u5B57\u6BB5\uFF0C\u7531\u65F6\u95F4\u6A21\u578B\u7EF4\u62A4\uFF0C\u4E0D\u6BD4",
|
|
2180
|
+
READ_TIME_DERIVED: "\u8BFB\u65F6\u6D3E\u751F\u7684\u5B57\u6BB5\uFF0C\u5B58\u4E0D\u8FDB\u53BB\uFF0C\u4E0D\u6BD4",
|
|
2181
|
+
CONSUMED_BY_MODEL: "\u4E0D\u5728\u5143\u6570\u636E\u91CC\uFF0C\u6A21\u578B\u5199\u5165\u65F6\u8BFB\u8D70\u4E86\u5B83\uFF08\u5199\u540E\u5DF2\u4E0D\u5728\u56DE\u5305\u4E0A\uFF09\uFF0C\u4E0D\u6BD4",
|
|
2182
|
+
RESPONSE_ONLY: "\u53EA\u51FA\u73B0\u5728\u54CD\u5E94\u91CC\u7684\u5B57\u6BB5\uFF0C\u5199\u4E0D\u8FDB\u53BB\uFF0C\u4E0D\u6BD4"
|
|
2183
|
+
};
|
|
2184
|
+
var REASON_MEANING = {
|
|
2185
|
+
VALUE_NOT_STORED: "\u9001\u4E86\u503C\uFF0C\u5E93\u91CC\u662F\u7A7A\u7684",
|
|
2186
|
+
VALUE_DIFFERS: "\u5E93\u91CC\u7684\u503C\u548C\u9001\u7684\u4E0D\u4E00\u6837",
|
|
2187
|
+
NOT_A_FIELD: "\u4E0D\u662F\u8FD9\u4E2A\u6A21\u578B\u7684\u5B57\u6BB5\uFF0C\u6807\u51C6\u5199\u5165\u4E0D\u8BFB\u5B83",
|
|
2188
|
+
CONTAINER_KEYS_DROPPED: "\u6574\u4EFD\u9001\u5BB9\u5668\u5B57\u6BB5\uFF0C\u6CA1\u9001\u7684\u5B50\u952E\u88AB\u6E05\u6389\u4E86",
|
|
2189
|
+
FIELD_NOT_READABLE: "\u4F60\u5BF9\u8FD9\u4E2A\u5B57\u6BB5\u6CA1\u6709\u8BFB\u6743\u9650",
|
|
2190
|
+
MASKED: "\u8FD9\u4E2A\u5B57\u6BB5\u5BF9\u4F60\u8131\u654F",
|
|
2191
|
+
AMBIGUOUS: "\u53D6\u503C\u4E0D\u552F\u4E00\uFF0C\u56DE\u8BFB\u683C\u6309\u89C4\u8303\u503C\u56DE\u586B",
|
|
2192
|
+
DEGRADED: "\u56DE\u8BFB\u65F6\u8FD9\u4E00\u683C\u6280\u672F\u964D\u7EA7",
|
|
2193
|
+
UNRESOLVED: "\u8BFB\u65F6\u6D3E\u751F\u5217\u7B97\u4E0D\u51FA",
|
|
2194
|
+
NOT_RETURNED: "\u56DE\u8BFB\u91CC\u6CA1\u6709\u8FD9\u4E2A\u5B57\u6BB5\uFF08\u4F8B\u5982\u53E3\u4EE4\uFF0C\u5929\u751F\u6838\u9A8C\u4E0D\u4E86\uFF09",
|
|
2195
|
+
CONTAINER_BASELINE_UNAVAILABLE: "\u6574\u4EFD\u9001\u5BB9\u5668\u5B57\u6BB5\uFF0C\u5199\u524D\u7684\u5BB9\u5668\u8BFB\u4E0D\u5230\uFF0C\u4E22\u952E\u68C0\u67E5\u505A\u4E0D\u4E86",
|
|
2196
|
+
CONTAINER_KEYS_UNREADABLE: "\u5BB9\u5668\u91CC\u6709\u4F60\u8BFB\u4E0D\u5230\u7684\u5B50\u952E\uFF0C\u770B\u4E0D\u51FA\u5B83\u4EEC\u88AB\u6CA1\u88AB\u6E05\u6389",
|
|
2197
|
+
COMPARE_FAILED: "\u6BD4\u8F83\u65F6\u51FA\u9519",
|
|
2198
|
+
NOTHING_TO_COMPARE: "\u6CA1\u6709\u53EF\u6BD4\u7684\u5185\u5BB9",
|
|
2199
|
+
ALL_FIELDS_UNVERIFIABLE: "\u6BCF\u4E2A\u5B57\u6BB5\u90FD\u6CA1\u6838\u6210",
|
|
2200
|
+
NO_READ_PERMISSION: "\u6309\u5199\u5165\u90A3\u4E00\u7248\u7684\u751F\u6548\u65E5\uFF0C\u4F60\u8BFB\u4E0D\u5230\u8FD9\u4E00\u884C",
|
|
2201
|
+
READBACK_INSIDE_TRANSACTION: "\u56DE\u8BFB\u65F6\u5199\u5165\u8FD8\u6CA1\u63D0\u4EA4",
|
|
2202
|
+
META_UNAVAILABLE: "\u6BD4\u8F83\u8981\u7528\u7684\u5143\u6570\u636E\u8BFB\u4E0D\u5230",
|
|
2203
|
+
EFFECTIVE_DATE_UNKNOWN: "\u65F6\u95F4\u6A21\u578B\u5199\u5B8C\u540E\u5B9A\u4E0D\u51FA\u56DE\u8BFB\u65E5",
|
|
2204
|
+
READBACK_FAILED: "\u56DE\u8BFB\u51FA\u9519",
|
|
2205
|
+
NOT_FOUND_ON_READBACK: "\u6309\u521A\u5199\u5165\u56DE\u7684 id \u8BFB\u4E0D\u5230\u8FD9\u4E00\u884C"
|
|
2206
|
+
};
|
|
2207
|
+
var NEXT_STEP = {
|
|
2208
|
+
VALUE_NOT_STORED: "\u6570\u636E\u6CA1\u5B58\u8FDB\u53BB\uFF0C\u4E0D\u8981\u91CD\u8DD1\uFF1B\u62A5\u7ED9\u4EA7\u54C1\u4FA7\uFF08\u9644\u4E0A\u9762\u7684\u9001\u503C\uFF09",
|
|
2209
|
+
VALUE_DIFFERS: "\u4EE5\u5E93\u91CC\u7684\u503C\u4E3A\u51C6\u6539\u672C\u5730\u6E90\uFF0C\u4E0D\u8981\u91CD\u8DD1\uFF1B\u82E5\u56DE\u8BFB\u65F6\u523B\uFF08readAt\uFF09\u524D\u540E\u6709\u4ED6\u4EBA\u4FEE\u6539\uFF0C\u4EE5\u6700\u65B0\u503C\u4E3A\u51C6",
|
|
2210
|
+
NOT_A_FIELD: "\u6309 /meta \u6539\u5B57\u6BB5\u540D\uFF0C\u4E0D\u8981\u91CD\u8DD1\u540C\u4E00\u6761\uFF08\u82E5\u8BE5\u6A21\u578B\u5728\u94A9\u5B50\u91CC\u8BFB\u8FD9\u4E2A\u952E\uFF0C\u53EF\u5FFD\u7565\uFF09",
|
|
2211
|
+
CONTAINER_KEYS_DROPPED: "\u8865\u56DE\u88AB\u6E05\u6389\u7684\u5B50\u952E\uFF0C\u4E0D\u8981\u91CD\u8DD1\uFF1B\u53EA\u6539\u4E00\u4E2A\u6269\u5C55\u5B57\u6BB5\u65F6\uFF0C\u6309 /meta \u91CC\u8BE5\u5B57\u6BB5\u7684\u952E\u540D\u4F5C\u4E3A\u9876\u5C42\u952E\u5355\u72EC\u9001\uFF0C\u4E0D\u8981\u6574\u4EFD\u9001 flexData",
|
|
2212
|
+
NOT_FOUND_ON_READBACK: "\u6309 id \u8BFB\u4E0D\u5230\uFF0C\u4E0D\u8981\u91CD\u8DD1\uFF1B\u7528\u6709\u6743\u9650\u7684\u8D26\u53F7\u6309 id \u67E5\u4E00\u6B21",
|
|
2213
|
+
FIELD_NOT_READABLE: "\u627E\u6709\u8BFB\u6743\u9650\u7684\u4EBA\u6838\u5BF9\uFF0C\u6216\u63A5\u53D7\u4E0D\u53EF\u6838\u9A8C",
|
|
2214
|
+
MASKED: "\u627E\u6709\u8BFB\u6743\u9650\u7684\u4EBA\u6838\u5BF9\uFF0C\u6216\u63A5\u53D7\u4E0D\u53EF\u6838\u9A8C",
|
|
2215
|
+
NO_READ_PERMISSION: "\u627E\u6709\u8BFB\u6743\u9650\u7684\u4EBA\u6838\u5BF9\uFF0C\u6216\u63A5\u53D7\u4E0D\u53EF\u6838\u9A8C",
|
|
2216
|
+
CONTAINER_KEYS_UNREADABLE: "\u627E\u6709\u8BFB\u6743\u9650\u7684\u4EBA\u6838\u5BF9",
|
|
2217
|
+
AMBIGUOUS: "\u5E26 effectiveDate \u6307\u5B9A\u7248\u672C\u540E\u7528 {get} \u6838\u5BF9",
|
|
2218
|
+
DEGRADED: "\u7A0D\u540E\u7528 {get} \u6838\u5BF9",
|
|
2219
|
+
UNRESOLVED: "\u7A0D\u540E\u7528 {get} \u6838\u5BF9",
|
|
2220
|
+
CONTAINER_BASELINE_UNAVAILABLE: "\u7528 {get} \u8BFB\u51FA\u5BB9\u5668\uFF0C\u786E\u8BA4\u6CA1\u9001\u7684\u5B50\u952E\u8FD8\u5728",
|
|
2221
|
+
COMPARE_FAILED: "\u7528 {get} \u624B\u5DE5\u6838\u5BF9\uFF1B\u62A5\u7ED9\u4EA7\u54C1\u4FA7\u65F6\u9644 traceId\uFF08\u670D\u52A1\u7AEF\u7ED9\u4E86\u4F1A\u6253\u5728\u4E0A\u9762\uFF0C\u6CA1\u7ED9\u5C31\u9644\u8FD9\u6B21\u8BF7\u6C42\u7684\u65F6\u95F4\u4E0E id\uFF09",
|
|
2222
|
+
META_UNAVAILABLE: "\u7A0D\u540E\u7528 {get} \u6838\u5BF9",
|
|
2223
|
+
READBACK_FAILED: "\u7528 {get} \u624B\u5DE5\u6838\u5BF9\uFF1B\u4E0D\u8981\u76F4\u63A5\u91CD\u8DD1 {cmd}",
|
|
2224
|
+
EFFECTIVE_DATE_UNKNOWN: "\u62A5\u7ED9\u4EA7\u54C1\u4FA7\uFF1B\u7528\u5E26 effectiveDate \u7684 {get} \u624B\u5DE5\u6838\u5BF9",
|
|
2225
|
+
READBACK_INSIDE_TRANSACTION: "\u62A5\u7ED9\u4EA7\u54C1\u4FA7\uFF08\u901A\u7528\u5199\u5165\u7AEF\u70B9\u4E0D\u5E94\u51FA\u73B0\uFF09"
|
|
2226
|
+
};
|
|
2227
|
+
var KNOWN_STATUS = /* @__PURE__ */ new Set(["VERIFIED", "MISMATCH", "PARTIAL", "UNVERIFIABLE"]);
|
|
2228
|
+
var VERIFY_ECHO_KEYS = ["writeVerification", "verifyExitReason"];
|
|
2229
|
+
var isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
2230
|
+
var str = (v) => typeof v === "string" && v.length > 0 ? v : void 0;
|
|
2231
|
+
function nonEmptyStrings(value) {
|
|
2232
|
+
return Array.isArray(value) ? value.filter((v) => typeof v === "string" && v.length > 0) : [];
|
|
2233
|
+
}
|
|
2234
|
+
function getUrl(ctx) {
|
|
2235
|
+
return ctx.id ? `GET /api/models/${ctx.model}/${ctx.id}` : `GET /api/models/${ctx.model}/{id}`;
|
|
2236
|
+
}
|
|
2237
|
+
function meaning(reason) {
|
|
2238
|
+
if (!reason) return "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u539F\u56E0\u7801";
|
|
2239
|
+
return REASON_MEANING[reason] ? `${reason}\uFF0C${REASON_MEANING[reason]}` : `${reason}\uFF08\u8FD9\u7248 CLI \u4E0D\u8BA4\u8BC6\u8FD9\u4E2A\u539F\u56E0\u7801\uFF0C\u539F\u6837\u7167\u767B\uFF09`;
|
|
2240
|
+
}
|
|
2241
|
+
function nextStep(reason, ctx) {
|
|
2242
|
+
const step = reason ? NEXT_STEP[reason] : void 0;
|
|
2243
|
+
return step?.replace("{get}", getUrl(ctx)).replace("{cmd}", ctx.command ?? "create");
|
|
2244
|
+
}
|
|
2245
|
+
function show(value, truncated) {
|
|
2246
|
+
const text3 = JSON.stringify(value ?? null);
|
|
2247
|
+
return truncated === true ? `${text3}\u2026\uFF08\u670D\u52A1\u7AEF\u622A\u65AD\uFF09` : text3;
|
|
2248
|
+
}
|
|
2249
|
+
function fieldLines(fields, markUnverifiable = false) {
|
|
2250
|
+
const out = [];
|
|
2251
|
+
let malformed = 0;
|
|
2252
|
+
for (const f of fields) {
|
|
2253
|
+
if (!isObj(f)) {
|
|
2254
|
+
malformed++;
|
|
2255
|
+
continue;
|
|
2256
|
+
}
|
|
2257
|
+
const tag = markUnverifiable && f.status === "UNVERIFIABLE" ? "\uFF08\u6CA1\u6838\u6210\uFF0C\u4E0D\u7B97\u5BF9\u4E0D\u4E0A\uFF09" : "";
|
|
2258
|
+
let line = ` - ${str(f.field) ?? "\uFF08\u6CA1\u7ED9\u5B57\u6BB5\u540D\uFF09"}${tag}\uFF1A${meaning(str(f.reason))}`;
|
|
2259
|
+
const sides = [
|
|
2260
|
+
..."sent" in f ? [`\u9001 ${show(f.sent, f.sentTruncated)}`] : [],
|
|
2261
|
+
..."stored" in f ? [`\u5B58 ${show(f.stored, f.storedTruncated)}`] : []
|
|
2262
|
+
];
|
|
2263
|
+
if (sides.length) line += `\uFF1B${sides.join(" \u2192 ")}`;
|
|
2264
|
+
out.push(line);
|
|
2265
|
+
const dropped = nonEmptyStrings(f.droppedKeys);
|
|
2266
|
+
if (dropped.length) out.push(` \u88AB\u6E05\u6389\u7684\u5B50\u952E\uFF1A${dropped.join("\u3001")}`);
|
|
2267
|
+
for (const leaf of Array.isArray(f.leaves) ? f.leaves : []) {
|
|
2268
|
+
if (!isObj(leaf)) {
|
|
2269
|
+
malformed++;
|
|
2270
|
+
continue;
|
|
2271
|
+
}
|
|
2272
|
+
if (leaf.status === "VERIFIED") continue;
|
|
2273
|
+
out.push(` \xB7 ${str(leaf.path) ?? "\uFF08\u6CA1\u7ED9\u8DEF\u5F84\uFF09"}\uFF1A${str(leaf.status) ?? "\uFF08\u6CA1\u7ED9\u72B6\u6001\uFF09"}\uFF0C${meaning(str(leaf.reason))}`);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
if (malformed) out.push(` \uFF08\u53E6\u6709 ${malformed} \u6761\u5B57\u6BB5 / \u53F6\u5B50\u6761\u76EE\u5F62\u72B6\u8BA4\u4E0D\u51FA\uFF0C\u6CA1\u6253\u51FA\u6765\uFF1B\u539F\u6837\u89C1 --output json \u7684 writeVerification\uFF09`);
|
|
2277
|
+
return out;
|
|
2278
|
+
}
|
|
2279
|
+
function nextStepLines(reasons, ctx) {
|
|
2280
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2281
|
+
const out = [];
|
|
2282
|
+
for (const r of reasons) {
|
|
2283
|
+
const step = nextStep(r, ctx);
|
|
2284
|
+
if (!step || seen.has(step)) continue;
|
|
2285
|
+
seen.add(step);
|
|
2286
|
+
out.push(`\u4E0B\u4E00\u6B65\uFF1A${step}`);
|
|
2287
|
+
}
|
|
2288
|
+
return out;
|
|
2289
|
+
}
|
|
2290
|
+
function excludedLines(block) {
|
|
2291
|
+
const excluded = (Array.isArray(block.excluded) ? block.excluded : []).filter(isObj);
|
|
2292
|
+
if (!excluded.length) return [];
|
|
2293
|
+
return [
|
|
2294
|
+
`\u6CA1\u6BD4\u5BF9\u7684 ${excluded.length} \u4E2A\u5B57\u6BB5\uFF08\u6392\u9664\u6E05\u5355\uFF0C\u4E0D\u7B97\u6CA1\u6838\u6210\uFF09\uFF1A`,
|
|
2295
|
+
...excluded.map((e) => {
|
|
2296
|
+
const reason = str(e.reason);
|
|
2297
|
+
return ` - ${str(e.field) ?? "\uFF08\u6CA1\u7ED9\u5B57\u6BB5\u540D\uFF09"}\uFF1A${reason && EXCLUDED_REASONS[reason] ? EXCLUDED_REASONS[reason] : `${reason ?? "\u6CA1\u7ED9\u539F\u56E0"}\uFF08\u8FD9\u7248 CLI \u4E0D\u8BA4\u8BC6\u8FD9\u4E2A\u539F\u56E0\u7801\uFF0C\u539F\u6837\u7167\u767B\uFF09`}`;
|
|
2298
|
+
})
|
|
2299
|
+
];
|
|
2300
|
+
}
|
|
2301
|
+
function countsText(counts) {
|
|
2302
|
+
if (!isObj(counts)) return "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u8BA1\u6570";
|
|
2303
|
+
const parts = ["considered", "verified", "mismatched", "unverifiable", "excluded"].filter((k) => typeof counts[k] === "number").map((k) => `${k}=${counts[k]}`);
|
|
2304
|
+
return parts.length ? parts.join("\uFF0C") : "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u8BA1\u6570";
|
|
2305
|
+
}
|
|
2306
|
+
function contextLines(block) {
|
|
2307
|
+
const out = [];
|
|
2308
|
+
const detail = isObj(block.detail) ? block.detail : {};
|
|
2309
|
+
if (str(detail.message)) out.push(` \u670D\u52A1\u7AEF\u8BF4\u660E\uFF1A${detail.message}`);
|
|
2310
|
+
const read = [
|
|
2311
|
+
...str(block.readAt) ? [`\u56DE\u8BFB\u65F6\u523B readAt=${block.readAt}`] : [],
|
|
2312
|
+
...str(block.asOf) ? [`\u6309\u751F\u6548\u65E5 asOf=${block.asOf}${str(block.asOfSource) ? `\uFF08${block.asOfSource}\uFF09` : ""} \u8BFB`] : [],
|
|
2313
|
+
...str(detail.asOf) && detail.asOf !== block.asOf ? [`\u8BFB\u4E0D\u5230\u7684\u90A3\u4E00\u7248\u751F\u6548\u65E5 ${detail.asOf}`] : []
|
|
2314
|
+
];
|
|
2315
|
+
if (read.length) out.push(` ${read.join("\uFF1B")}`);
|
|
2316
|
+
if (str(detail.traceId)) out.push(` traceId=${detail.traceId}`);
|
|
2317
|
+
return out;
|
|
2318
|
+
}
|
|
2319
|
+
function truncatedLines(block, listed3) {
|
|
2320
|
+
return block.fieldsTruncated === true ? [` \u2026\u670D\u52A1\u7AEF\u622A\u65AD\u4E86\u5B57\u6BB5\u6E05\u5355\uFF08fieldsTruncated\uFF09\uFF0C\u4E0A\u9762\u53EA\u5217\u51FA ${listed3} \u6761\uFF1B\u5B8C\u6574\u8BA1\u6570\uFF1A${countsText(block.counts)}`] : [];
|
|
2321
|
+
}
|
|
2322
|
+
function malformedVerdict(why, ctx) {
|
|
2323
|
+
return {
|
|
2324
|
+
exitCode: 7 /* VERIFY_UNAVAILABLE */,
|
|
2325
|
+
verifyExitReason: "MALFORMED_VERIFICATION",
|
|
2326
|
+
lines: [
|
|
2327
|
+
`\u5199\u540E\u6838\u9A8C\uFF1A\u6838\u9A8C\u5757\u5F62\u72B6\u8BA4\u4E0D\u51FA\uFF08${why}\uFF09\uFF0C\u5DF2\u5199\u5165\u3001\u672A\u6838\u9A8C\u3002`,
|
|
2328
|
+
`\u4E0B\u4E00\u6B65\uFF1A\u7528 ${getUrl(ctx)} \u624B\u5DE5\u6838\u5BF9\uFF1B\u62A5\u7ED9\u4EA7\u54C1\u4FA7\u65F6\u9644 --output json \u91CC\u7684 writeVerification \u539F\u6837`
|
|
2329
|
+
]
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
function stripVerifyEchoKeys(data) {
|
|
2333
|
+
if (!isObj(data)) return { data, stripped: [] };
|
|
2334
|
+
const stripped = VERIFY_ECHO_KEYS.filter((k) => k in data);
|
|
2335
|
+
if (!stripped.length) return { data, stripped };
|
|
2336
|
+
const copy = { ...data };
|
|
2337
|
+
for (const k of stripped) delete copy[k];
|
|
2338
|
+
return { data: copy, stripped: [...stripped] };
|
|
2339
|
+
}
|
|
2340
|
+
function assessWriteVerification(response, ctx) {
|
|
2341
|
+
try {
|
|
2342
|
+
return assess(response, ctx);
|
|
2343
|
+
} catch (e) {
|
|
2344
|
+
return malformedVerdict(`\u5224\u8BFB\u65F6\u51FA\u9519\uFF1A${e instanceof Error ? e.message : String(e)}`, ctx);
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
function assess(response, ctx) {
|
|
2348
|
+
const body = isObj(response) ? response : {};
|
|
2349
|
+
const unknown = nonEmptyStrings(body.fieldsUnknown);
|
|
2350
|
+
const echoed = unknown.includes("writeVerification");
|
|
2351
|
+
const raw = echoed ? void 0 : body.writeVerification;
|
|
2352
|
+
if (raw === void 0 || raw === null) {
|
|
2353
|
+
const echoNote = echoed ? [" \u56DE\u5305\u91CC\u7684 writeVerification \u662F\u8BF7\u6C42\u91CC\u5E26\u8FC7\u53BB\u7684\u952E\u88AB\u539F\u6837\u56DE\u663E\uFF08\u5B83\u5728\u672A\u77E5\u952E\u56DE\u6267\u91CC\uFF09\uFF0C\u4E0D\u662F\u670D\u52A1\u7AEF\u7684\u6838\u9A8C\u7ED3\u8BBA\u3002"] : [];
|
|
2354
|
+
if (unknown.length) {
|
|
2355
|
+
return {
|
|
2356
|
+
exitCode: 6 /* VERIFY_MISMATCH */,
|
|
2357
|
+
verifyExitReason: "LEGACY_UNKNOWN_FIELDS",
|
|
2358
|
+
lines: [
|
|
2359
|
+
"\u5199\u540E\u6838\u9A8C\uFF1A\u6CA1\u6536\u5230\u6838\u9A8C\u5757\uFF0C\u7ED3\u8BBA\u6765\u81EA\u670D\u52A1\u7AEF\u7684\u672A\u77E5\u952E\u56DE\u6267\u2014\u2014\u5DF2\u5199\u5165\uFF0C\u4F46\u4E0B\u9762\u8FD9\u4E9B\u952E\u4E0D\u5728\u5143\u6570\u636E\u91CC\uFF0C\u6807\u51C6\u5199\u5165\u4E0D\u8BFB\u5B83\u4EEC\uFF08NOT_A_FIELD\uFF09\uFF1A",
|
|
2360
|
+
...unknown.map((k) => ` - ${k}`),
|
|
2361
|
+
...echoNote,
|
|
2362
|
+
...body.fieldsUnknownUnverified === true ? [" \u670D\u52A1\u7AEF\u8BF4\u8FD9\u4EFD\u672A\u77E5\u952E\u540D\u5355\u6CA1\u67E5\u5168\uFF0C\u53EF\u80FD\u8FD8\u6709\u522B\u7684\u9519\u540D\u952E\u3002"] : [],
|
|
2363
|
+
`\u4E0B\u4E00\u6B65\uFF1A${NEXT_STEP.NOT_A_FIELD}`
|
|
2364
|
+
]
|
|
2365
|
+
};
|
|
2366
|
+
}
|
|
2367
|
+
return {
|
|
2368
|
+
exitCode: 7 /* VERIFY_UNAVAILABLE */,
|
|
2369
|
+
verifyExitReason: "LEGACY_NO_VERIFICATION",
|
|
2370
|
+
lines: [
|
|
2371
|
+
"\u5199\u540E\u6838\u9A8C\uFF1A\u6CA1\u6536\u5230\u6838\u9A8C\u5757\uFF08\u5E38\u89C1\u539F\u56E0\uFF1ACore \u7248\u672C\u65E9\u4E8E\u5199\u540E\u6838\u9A8C\u4E0A\u7EBF\uFF1B\u6216\u670D\u52A1\u7AEF\u7EC4\u88C5\u54CD\u5E94\u526F\u672C\u5931\u8D25\uFF09\uFF0C\u5DF2\u5199\u5165\u3001\u672A\u6838\u9A8C\u3002" + (body.fieldsUnknownUnverified === true ? "\u670D\u52A1\u7AEF\u7684\u672A\u77E5\u952E\u56DE\u6267\u4E5F\u6CA1\u67E5\u6210\u3002" : ""),
|
|
2372
|
+
`\u4E0B\u4E00\u6B65\uFF1A\u7528 ${getUrl(ctx)} \u624B\u5DE5\u6838\u5BF9\uFF1B\u5347\u7EA7 Core \u540E --verify \u624D\u6709\u7ED3\u8BBA`
|
|
2373
|
+
]
|
|
2374
|
+
};
|
|
2375
|
+
}
|
|
2376
|
+
if (!isObj(raw)) return malformedVerdict("writeVerification \u4E0D\u662F\u5BF9\u8C61", ctx);
|
|
2377
|
+
const block = raw;
|
|
2378
|
+
const status = str(block.status);
|
|
2379
|
+
if (!status) return malformedVerdict("\u6CA1\u6709\u53EF\u8BFB\u7684 status", ctx);
|
|
2380
|
+
const fields = Array.isArray(block.fields) ? block.fields : [];
|
|
2381
|
+
const reason = str(block.reason);
|
|
2382
|
+
const counts = isObj(block.counts) ? block.counts : void 0;
|
|
2383
|
+
const fieldReasons = fields.filter(isObj).map((f) => str(f.reason));
|
|
2384
|
+
if (!KNOWN_STATUS.has(status)) {
|
|
2385
|
+
return {
|
|
2386
|
+
exitCode: 7 /* VERIFY_UNAVAILABLE */,
|
|
2387
|
+
verifyExitReason: status,
|
|
2388
|
+
lines: [
|
|
2389
|
+
`\u5199\u540E\u6838\u9A8C\uFF1A\u8FD9\u7248 CLI \u4E0D\u8BA4\u8BC6\u6838\u9A8C\u72B6\u6001 ${status}\uFF0C\u5DF2\u5199\u5165\uFF0C\u6309\u300C\u672A\u6838\u9A8C\u300D\u5904\u7406\u3002`,
|
|
2390
|
+
`\u4E0B\u4E00\u6B65\uFF1A\u5347\u7EA7 CLI \u540E\u518D\u770B\uFF1B\u73B0\u5728\u7528 ${getUrl(ctx)} \u624B\u5DE5\u6838\u5BF9`
|
|
2391
|
+
]
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
if (status === "VERIFIED") {
|
|
2395
|
+
const n = typeof counts?.verified === "number" ? counts.verified : Array.isArray(block.verifiedFields) ? block.verifiedFields.length : void 0;
|
|
2396
|
+
return {
|
|
2397
|
+
exitCode: 0 /* SUCCESS */,
|
|
2398
|
+
verifyExitReason: status,
|
|
2399
|
+
lines: [
|
|
2400
|
+
`\u5199\u540E\u6838\u9A8C\uFF1A\u901A\u8FC7\uFF08VERIFIED\uFF09${n !== void 0 ? `\uFF0C${n} \u4E2A\u5B57\u6BB5\u4E0E\u5E93\u91CC\u4E00\u81F4` : ""}\u3002`,
|
|
2401
|
+
...excludedLines(block)
|
|
2402
|
+
]
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
2405
|
+
if (status === "MISMATCH") {
|
|
2406
|
+
const lines2 = ["\u5199\u540E\u6838\u9A8C\uFF1A\u6CA1\u8FC7\uFF08MISMATCH\uFF09\u2014\u2014\u5DF2\u5199\u5165\uFF0C\u4F46\u4E0E\u5E93\u91CC\u5BF9\u4E0D\u4E0A\u3002\u{1F534} \u4E0D\u8981\u91CD\u8DD1\u3002"];
|
|
2407
|
+
if (reason === "NOT_FOUND_ON_READBACK") {
|
|
2408
|
+
lines2.push(` \u6574\u884C\uFF1A${meaning(reason)}`);
|
|
2409
|
+
} else {
|
|
2410
|
+
lines2.push(...fieldLines(fields, true), ...truncatedLines(block, fields.length));
|
|
2411
|
+
if (reason) lines2.push(` \u5176\u4F59\u5B57\u6BB5\u6CA1\u6838\uFF1A${meaning(reason)}`);
|
|
2412
|
+
}
|
|
2413
|
+
lines2.push(...contextLines(block), ...excludedLines(block));
|
|
2414
|
+
lines2.push(...nextStepLines([...fieldReasons, reason], ctx));
|
|
2415
|
+
return { exitCode: 6 /* VERIFY_MISMATCH */, verifyExitReason: status, lines: lines2 };
|
|
2416
|
+
}
|
|
2417
|
+
if (status === "PARTIAL") {
|
|
2418
|
+
const verified = typeof counts?.verified === "number" ? `${counts.verified} \u4E2A\u5B57\u6BB5\u4E00\u81F4` : "\u4E00\u81F4\u7684\u5B57\u6BB5\u6570\u670D\u52A1\u7AEF\u6CA1\u7ED9";
|
|
2419
|
+
const lines2 = [
|
|
2420
|
+
`\u5199\u540E\u6838\u9A8C\uFF1A\u53EA\u6838\u4E86\u4E00\u90E8\u5206\uFF08PARTIAL\uFF09\u2014\u2014\u5DF2\u5199\u5165\uFF0C${verified}\uFF0C\u4E0B\u9762\u8FD9\u4E9B\u6CA1\u6838\u6210\uFF1A`,
|
|
2421
|
+
...fieldLines(fields),
|
|
2422
|
+
...truncatedLines(block, fields.length),
|
|
2423
|
+
...contextLines(block),
|
|
2424
|
+
...excludedLines(block),
|
|
2425
|
+
...nextStepLines(fieldReasons, ctx)
|
|
2426
|
+
];
|
|
2427
|
+
return { exitCode: 7 /* VERIFY_UNAVAILABLE */, verifyExitReason: status, lines: lines2 };
|
|
2428
|
+
}
|
|
2429
|
+
const lines = [`\u5199\u540E\u6838\u9A8C\uFF1A\u6CA1\u6838\u6210\uFF08UNVERIFIABLE\uFF09\u2014\u2014\u5DF2\u5199\u5165\u3001\u672A\u6838\u9A8C\u3002\u539F\u56E0\uFF1A${meaning(reason)}`, ...contextLines(block)];
|
|
2430
|
+
if (reason === "NOTHING_TO_COMPARE") {
|
|
2431
|
+
lines.push(" \u8FD9\u6B21\u9001\u7684\u5B57\u6BB5\u90FD\u5728\u6392\u9664\u6E05\u5355\u91CC\uFF0C\u6CA1\u6709\u53EF\u6BD4\u7684\u3002", ...excludedLines(block));
|
|
2432
|
+
}
|
|
2433
|
+
if (fields.length) lines.push(...fieldLines(fields), ...truncatedLines(block, fields.length));
|
|
2434
|
+
lines.push(...nextStepLines([reason, ...fieldReasons], ctx));
|
|
2435
|
+
return { exitCode: 7 /* VERIFY_UNAVAILABLE */, verifyExitReason: status, lines };
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2169
2438
|
// src/import/runner.ts
|
|
2170
2439
|
var DEFAULT_KEY_FIELD = "code";
|
|
2171
2440
|
async function runImport(client, fixtures, opts = {}) {
|
|
@@ -2176,14 +2445,33 @@ async function runImport(client, fixtures, opts = {}) {
|
|
|
2176
2445
|
const warnings = fixtures.flatMap((fixture) => fixture.warnings ?? []);
|
|
2177
2446
|
const knownKeysOf = /* @__PURE__ */ new Map();
|
|
2178
2447
|
const fieldNamesUnverified = [];
|
|
2448
|
+
const verify = !!opts.verify && !opts.dryRun;
|
|
2449
|
+
const writeOpts = verify ? { verify: true } : void 0;
|
|
2450
|
+
const vsum = { verified: 0, mismatched: 0, unverified: 0, skippedNotVerified: 0 };
|
|
2451
|
+
let stoppedOn;
|
|
2452
|
+
const totalItems = fixtures.reduce((n, fx) => n + fx.items.length, 0);
|
|
2453
|
+
const stop = (model, key, cause) => {
|
|
2454
|
+
stoppedOn = { model, key, cause, notAttempted: totalItems - rows.length };
|
|
2455
|
+
return result();
|
|
2456
|
+
};
|
|
2179
2457
|
const result = () => ({
|
|
2180
2458
|
...tally,
|
|
2181
2459
|
rows,
|
|
2182
2460
|
refs: store.snapshot(),
|
|
2183
2461
|
refsFromTarget: [...refsFromTarget],
|
|
2184
2462
|
...warnings.length > 0 ? { warnings: [...warnings] } : {},
|
|
2185
|
-
fieldNamesUnverified: [...fieldNamesUnverified]
|
|
2463
|
+
fieldNamesUnverified: [...fieldNamesUnverified],
|
|
2464
|
+
...verify ? { verification: { ...vsum } } : {},
|
|
2465
|
+
...stoppedOn ? { stoppedOn } : {}
|
|
2186
2466
|
});
|
|
2467
|
+
const verifyNote = (response, model, id, command) => {
|
|
2468
|
+
if (!verify) return {};
|
|
2469
|
+
const verification = rowVerification(response, { model, id, command });
|
|
2470
|
+
if (verification.exitCode === 0) vsum.verified++;
|
|
2471
|
+
else if (verification.exitCode === 6) vsum.mismatched++;
|
|
2472
|
+
else vsum.unverified++;
|
|
2473
|
+
return { verification };
|
|
2474
|
+
};
|
|
2187
2475
|
const knownKeysFor = async (model) => {
|
|
2188
2476
|
if (!knownKeysOf.has(model)) {
|
|
2189
2477
|
let resolved = null;
|
|
@@ -2219,7 +2507,7 @@ async function runImport(client, fixtures, opts = {}) {
|
|
|
2219
2507
|
error: unresolvedError(unresolved, !!opts.dryRun)
|
|
2220
2508
|
});
|
|
2221
2509
|
tally.failed++;
|
|
2222
|
-
if (opts.onError === "stop") return
|
|
2510
|
+
if (opts.onError === "stop") return stop(fx.model, key, "failed");
|
|
2223
2511
|
continue;
|
|
2224
2512
|
}
|
|
2225
2513
|
if (opts.dryRun) {
|
|
@@ -2236,17 +2524,35 @@ async function runImport(client, fixtures, opts = {}) {
|
|
|
2236
2524
|
store.register(fx.model, key, existingId);
|
|
2237
2525
|
rows.push({ model: fx.model, key, status: "skipped", id: existingId, ...unmappedNote });
|
|
2238
2526
|
tally.skipped++;
|
|
2527
|
+
if (verify) vsum.skippedNotVerified++;
|
|
2239
2528
|
} else if (existingId && opts.updateOnly) {
|
|
2240
|
-
await client.update(fx.model, existingId, payload);
|
|
2529
|
+
const updated = writeOpts ? await client.update(fx.model, existingId, payload, writeOpts) : await client.update(fx.model, existingId, payload);
|
|
2241
2530
|
store.register(fx.model, key, existingId);
|
|
2242
|
-
rows.push({
|
|
2531
|
+
rows.push({
|
|
2532
|
+
model: fx.model,
|
|
2533
|
+
key,
|
|
2534
|
+
status: "updated",
|
|
2535
|
+
id: existingId,
|
|
2536
|
+
...unmappedNote,
|
|
2537
|
+
...verifyNote(updated, fx.model, existingId, "update")
|
|
2538
|
+
});
|
|
2243
2539
|
tally.updated++;
|
|
2244
2540
|
} else {
|
|
2245
|
-
const created = await client.create(fx.model, payload);
|
|
2541
|
+
const created = writeOpts ? await client.create(fx.model, payload, writeOpts) : await client.create(fx.model, payload);
|
|
2246
2542
|
store.register(fx.model, key, created.id);
|
|
2247
|
-
rows.push({
|
|
2543
|
+
rows.push({
|
|
2544
|
+
model: fx.model,
|
|
2545
|
+
key,
|
|
2546
|
+
status: "created",
|
|
2547
|
+
id: created.id,
|
|
2548
|
+
...unmappedNote,
|
|
2549
|
+
...verifyNote(created, fx.model, created.id, "create")
|
|
2550
|
+
});
|
|
2248
2551
|
tally.created++;
|
|
2249
2552
|
}
|
|
2553
|
+
if (opts.onError === "stop" && rows[rows.length - 1]?.verification?.exitCode === 6) {
|
|
2554
|
+
return stop(fx.model, key, "verify-mismatch");
|
|
2555
|
+
}
|
|
2250
2556
|
} catch (e) {
|
|
2251
2557
|
const err = e instanceof CliError ? e : fromAxiosError(e);
|
|
2252
2558
|
const context = err.context;
|
|
@@ -2264,12 +2570,55 @@ async function runImport(client, fixtures, opts = {}) {
|
|
|
2264
2570
|
...unmappedNote
|
|
2265
2571
|
});
|
|
2266
2572
|
tally.failed++;
|
|
2267
|
-
if (opts.onError === "stop") return
|
|
2573
|
+
if (opts.onError === "stop") return stop(fx.model, key, "failed");
|
|
2268
2574
|
}
|
|
2269
2575
|
}
|
|
2270
2576
|
}
|
|
2271
2577
|
return result();
|
|
2272
2578
|
}
|
|
2579
|
+
function rowVerification(response, ctx) {
|
|
2580
|
+
const verdict2 = assessWriteVerification(response, ctx);
|
|
2581
|
+
const body = isRecord2(response) ? response : {};
|
|
2582
|
+
const block = isRecord2(body.writeVerification) && verdict2.verifyExitReason !== "LEGACY_UNKNOWN_FIELDS" ? body.writeVerification : void 0;
|
|
2583
|
+
const reason = typeof block?.reason === "string" && block.reason ? block.reason : void 0;
|
|
2584
|
+
let fields;
|
|
2585
|
+
if (block) {
|
|
2586
|
+
fields = (Array.isArray(block.fields) ? block.fields : []).filter(isRecord2).filter((f) => typeof f.field === "string" && f.field).map(toRowField);
|
|
2587
|
+
} else if (verdict2.verifyExitReason === "LEGACY_UNKNOWN_FIELDS") {
|
|
2588
|
+
fields = (Array.isArray(body.fieldsUnknown) ? body.fieldsUnknown : []).filter((k) => typeof k === "string" && k.length > 0).map((field) => ({ field, status: "MISMATCH", reason: "NOT_A_FIELD" }));
|
|
2589
|
+
} else {
|
|
2590
|
+
fields = [];
|
|
2591
|
+
}
|
|
2592
|
+
return {
|
|
2593
|
+
status: verdict2.verifyExitReason,
|
|
2594
|
+
exitCode: verdict2.exitCode,
|
|
2595
|
+
...reason ? { reason } : {},
|
|
2596
|
+
...fields.length ? { fields } : {},
|
|
2597
|
+
// 服务端说清单不完整就照记:不记的话截断的清单与完整的清单同值
|
|
2598
|
+
...block?.fieldsTruncated === true ? { fieldsTruncated: true } : {},
|
|
2599
|
+
...!block && body.fieldsUnknownUnverified === true ? { fieldNamesIncomplete: true } : {}
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
var nonEmpty = (v) => typeof v === "string" && v.length > 0;
|
|
2603
|
+
function toRowField(f) {
|
|
2604
|
+
const droppedKeys = Array.isArray(f.droppedKeys) ? f.droppedKeys.filter(nonEmpty) : [];
|
|
2605
|
+
const leaves = (Array.isArray(f.leaves) ? f.leaves : []).filter(isRecord2).filter((l) => nonEmpty(l.path) && l.status !== "VERIFIED").map((l) => ({ path: l.path, ...nonEmpty(l.status) ? { status: l.status } : {}, ...nonEmpty(l.reason) ? { reason: l.reason } : {} }));
|
|
2606
|
+
return {
|
|
2607
|
+
field: f.field,
|
|
2608
|
+
...nonEmpty(f.status) ? { status: f.status } : {},
|
|
2609
|
+
...nonEmpty(f.reason) ? { reason: f.reason } : {},
|
|
2610
|
+
...droppedKeys.length ? { droppedKeys } : {},
|
|
2611
|
+
...leaves.length ? { leaves } : {}
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
var isRecord2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
2615
|
+
function importExitCode(result) {
|
|
2616
|
+
const v = result.verification;
|
|
2617
|
+
if (v && v.mismatched > 0) return 6;
|
|
2618
|
+
if (result.failed > 0) return 3;
|
|
2619
|
+
if (v && v.unverified > 0) return 7;
|
|
2620
|
+
return 0;
|
|
2621
|
+
}
|
|
2273
2622
|
async function lookupMissingRefs(item, ctx) {
|
|
2274
2623
|
for (const value of Object.values(item)) {
|
|
2275
2624
|
const ph = parsePlaceholder(value);
|
|
@@ -3505,7 +3854,7 @@ function handshakeRejectedError(res, body) {
|
|
|
3505
3854
|
const bodyText = body.trim().slice(0, 300);
|
|
3506
3855
|
const isAuthReject = httpStatus === 401 || httpStatus === 403;
|
|
3507
3856
|
const rejectedBy = reason ? `HCM \u540E\u7AEF\u63E1\u624B\u62E6\u622A\u5668\u62D2\u7EDD\uFF08X-WebSocket-Auth-Error: ${reason}\uFF09` : "\u54CD\u5E94\u91CC\u6CA1\u6709 X-WebSocket-Auth-Error\uFF0C\u62D2\u7EDD\u65B9\u4E0D\u662F HCM \u540E\u7AEF\u7684\u63E1\u624B\u62E6\u622A\u5668\uFF08\u591A\u534A\u662F\u7F51\u5173 / \u53CD\u5411\u4EE3\u7406\uFF0C\u6216\u8DEF\u5F84\u6CA1\u8DEF\u7531\u5230\u540E\u7AEF\uFF09";
|
|
3508
|
-
const
|
|
3857
|
+
const nextStep2 = reason ? HANDSHAKE_REJECT_NEXT_STEP[reason] ?? `\u540E\u7AEF\u62D2\u7EDD\u539F\u56E0 ${reason} \u672A\u6536\u5F55\uFF1A\u6309\u539F\u56E0\u7801\u5728 Core WebSocketHandshakeAuthInterceptor \u91CC\u67E5\u5904\u7F6E` : isAuthReject ? 'hcm version --env <\u73AF\u5883> \u786E\u8BA4\u540E\u7AEF\u5728\u7EBF\uFF1B\u518D\u7528 curl --http1.1 -H "Upgrade: websocket" \u6253\u540C\u4E00 URL\uFF0C\u770B 401 \u662F\u5426\u5E26 X-WebSocket-Auth-Error \u5934' : "hcm version --env <\u73AF\u5883> \u786E\u8BA4\u540E\u7AEF\u5728\u7EBF\uFF0C\u5E76\u786E\u8BA4 /ws/conversation \u8DEF\u5F84\u88AB\u7F51\u5173\u8DEF\u7531\u5230\u4E86\u540E\u7AEF";
|
|
3509
3858
|
return new CliError({
|
|
3510
3859
|
code: isAuthReject ? "WS_HANDSHAKE_REJECTED" /* WS_HANDSHAKE_REJECTED */ : "NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
3511
3860
|
message: `WebSocket \u63E1\u624B\u88AB\u62D2 HTTP ${httpStatus}\uFF1A${rejectedBy}`,
|
|
@@ -3513,7 +3862,7 @@ function handshakeRejectedError(res, body) {
|
|
|
3513
3862
|
httpStatus,
|
|
3514
3863
|
...reason ? { handshakeAuthError: reason } : {},
|
|
3515
3864
|
...bodyText ? { details: bodyText } : {},
|
|
3516
|
-
nextStep
|
|
3865
|
+
nextStep: nextStep2
|
|
3517
3866
|
},
|
|
3518
3867
|
traceId
|
|
3519
3868
|
});
|
|
@@ -4718,28 +5067,36 @@ function toWorkspacePreflightResult(value) {
|
|
|
4718
5067
|
workspaceKey: stringOr(obj.workspaceKey),
|
|
4719
5068
|
checked: obj.checked,
|
|
4720
5069
|
checkedPaths: Array.isArray(obj.checkedPaths) ? obj.checkedPaths.map((p) => stringOr(p)) : [],
|
|
4721
|
-
issues: obj.issues.map(
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
5070
|
+
issues: obj.issues.map(toWorkspacePreflightIssue),
|
|
5071
|
+
warnings: Array.isArray(obj.warnings) ? obj.warnings.map(toWorkspacePreflightWarning) : void 0,
|
|
5072
|
+
protocol: {
|
|
5073
|
+
protocolVersion: obj.protocolVersion,
|
|
5074
|
+
hasCoverage: "coverage" in obj,
|
|
5075
|
+
coverage: obj.coverage,
|
|
5076
|
+
hasReleaseIssues: "releaseIssues" in obj,
|
|
5077
|
+
releaseIssues: obj.releaseIssues
|
|
5078
|
+
}
|
|
5079
|
+
};
|
|
5080
|
+
}
|
|
5081
|
+
function toWorkspacePreflightIssue(raw) {
|
|
5082
|
+
const issue = asRecord(raw);
|
|
5083
|
+
return {
|
|
5084
|
+
path: issue.path == null ? null : stringOr(issue.path),
|
|
5085
|
+
errCode: stringOrUndefined(issue.errCode),
|
|
5086
|
+
message: stringOr(issue.message),
|
|
5087
|
+
description: stringOrUndefined(issue.description),
|
|
5088
|
+
field: stringOrUndefined(issue.field),
|
|
5089
|
+
data: issue.data
|
|
4733
5090
|
};
|
|
4734
5091
|
}
|
|
4735
5092
|
function toWorkspacePreflightWarning(raw) {
|
|
4736
5093
|
const warning = asRecord(raw);
|
|
4737
|
-
const
|
|
5094
|
+
const nextStep2 = stringOrUndefined(warning.next_step) ?? stringOrUndefined(warning.nextStep);
|
|
4738
5095
|
return {
|
|
4739
5096
|
warnCode: stringOrUndefined(warning.warnCode),
|
|
4740
5097
|
path: warning.path == null ? null : stringOr(warning.path),
|
|
4741
5098
|
message: stringOr(warning.message),
|
|
4742
|
-
...
|
|
5099
|
+
...nextStep2 ? { nextStep: nextStep2 } : {},
|
|
4743
5100
|
...typeof warning.model === "string" ? { model: warning.model } : {},
|
|
4744
5101
|
...typeof warning.versionModel === "string" ? { versionModel: warning.versionModel } : {},
|
|
4745
5102
|
...Array.isArray(warning.fields) ? { fields: warning.fields.map((f) => stringOr(f)) } : {}
|
|
@@ -6633,10 +6990,11 @@ function buildMiniVerifyAgentReport(report) {
|
|
|
6633
6990
|
})
|
|
6634
6991
|
);
|
|
6635
6992
|
const preflightFailed = report.preflight?.status === "failed";
|
|
6993
|
+
const releaseBlocked = report.preflight?.status === "release-blocked";
|
|
6636
6994
|
const safeToPush = report.validate.valid && dryRunOk && previewUrls.length > 0 && smokeOk && !preflightFailed;
|
|
6637
6995
|
const nextAction = chooseMiniVerifyNextAction(report, previewUrls, smoke);
|
|
6638
6996
|
return {
|
|
6639
|
-
ok: report.ok && smokeOk && !preflightFailed,
|
|
6997
|
+
ok: report.ok && smokeOk && !preflightFailed && !releaseBlocked,
|
|
6640
6998
|
safeToPush,
|
|
6641
6999
|
nextAction,
|
|
6642
7000
|
summary: {
|
|
@@ -6673,7 +7031,12 @@ function buildMiniVerifyAgentReport(report) {
|
|
|
6673
7031
|
count: previewUrls.length,
|
|
6674
7032
|
surfaces: previewUrls.map((target) => target.surface)
|
|
6675
7033
|
},
|
|
6676
|
-
preflight: report.preflight ? {
|
|
7034
|
+
preflight: report.preflight ? {
|
|
7035
|
+
status: report.preflight.status,
|
|
7036
|
+
sent: report.preflight.sent,
|
|
7037
|
+
issues: report.preflight.issues.length,
|
|
7038
|
+
...report.preflight.releaseIssues ? { releaseIssues: report.preflight.releaseIssues.length } : {}
|
|
7039
|
+
} : null
|
|
6677
7040
|
},
|
|
6678
7041
|
changedFiles: report.status.filter((entry) => entry.status !== "unchanged").map(
|
|
6679
7042
|
(entry) => ({
|
|
@@ -6728,6 +7091,7 @@ function chooseMiniVerifyNextAction(report, previewUrls, smoke) {
|
|
|
6728
7091
|
if (report.preflight?.status === "failed") {
|
|
6729
7092
|
return report.preflight.issues.some((issue) => issue.errCode === "WORKSPACE_FILE_CONFLICT") ? "resolve-conflict" : "fix-validation";
|
|
6730
7093
|
}
|
|
7094
|
+
if (report.preflight?.status === "release-blocked") return "fix-validation";
|
|
6731
7095
|
if (!previewUrls.length) return "inspect-preview";
|
|
6732
7096
|
return "push";
|
|
6733
7097
|
}
|
|
@@ -6773,6 +7137,9 @@ function formatMiniVerifyReport(report) {
|
|
|
6773
7137
|
for (const issue of preflight2.issues) {
|
|
6774
7138
|
lines.push(` ${issue.path ?? "(\u6574\u6279)"}: [${issue.errCode ?? "ERROR"}] ${issue.message}`);
|
|
6775
7139
|
}
|
|
7140
|
+
for (const issue of preflight2.releaseIssues ?? []) {
|
|
7141
|
+
lines.push(` release \u2717 ${issue.path ?? "(\u6574\u6279)"}: [${issue.errCode ?? "ERROR"}] ${issue.message}`);
|
|
7142
|
+
}
|
|
6776
7143
|
}
|
|
6777
7144
|
if (report.preview.length) {
|
|
6778
7145
|
lines.push(`[4/${totalSteps}] preview:`);
|
|
@@ -6889,7 +7256,7 @@ async function validateManifestObject(manifest2, context, root, errors, warnings
|
|
|
6889
7256
|
requireString(manifest2, "sdkVersion", errors, (value) => SEMVER_PATTERN.test(value));
|
|
6890
7257
|
if (typeof manifest2.sdkVersion === "string" && manifest2.sdkVersion !== MINI_RUNTIME_SDK_VERSION) {
|
|
6891
7258
|
warnings.push(
|
|
6892
|
-
`manifest sdkVersion '${manifest2.sdkVersion}' differs from the
|
|
7259
|
+
`manifest sdkVersion '${manifest2.sdkVersion}' differs from the CLI built-in default SDK version '${MINI_RUNTIME_SDK_VERSION}'; the target Core requires an exact match, and the server preflight of hcm workspace verify is authoritative. Cores older than the release-view preflight (O15 core-4e) do not check this until release-plan.`
|
|
6893
7260
|
);
|
|
6894
7261
|
}
|
|
6895
7262
|
const code = typeof manifest2.code === "string" ? manifest2.code : "";
|
|
@@ -17359,6 +17726,60 @@ async function installDataPackageArtifact(client, artifactPath, opts = {}) {
|
|
|
17359
17726
|
return { documentId: meta.documentId, view };
|
|
17360
17727
|
}
|
|
17361
17728
|
|
|
17729
|
+
// src/models/action-verification.ts
|
|
17730
|
+
async function fetchActionVerification(http, model, action3) {
|
|
17731
|
+
let rows;
|
|
17732
|
+
try {
|
|
17733
|
+
const resp = await http.get(`/api/models/${model}/actions`);
|
|
17734
|
+
rows = resp.data?.actions;
|
|
17735
|
+
} catch (e) {
|
|
17736
|
+
const err = e;
|
|
17737
|
+
const status2 = err?.response?.status;
|
|
17738
|
+
return { kind: "unreadable", detail: status2 ? `HTTP ${status2}` : err?.message ?? String(e) };
|
|
17739
|
+
}
|
|
17740
|
+
if (!Array.isArray(rows)) return { kind: "unreadable", detail: "\u56DE\u5305\u91CC\u6CA1\u6709 actions \u6570\u7EC4" };
|
|
17741
|
+
const row = rows.find((r) => r && typeof r === "object" && r.key === action3);
|
|
17742
|
+
if (!row) return { kind: "no-row" };
|
|
17743
|
+
const cell = row.verification;
|
|
17744
|
+
if (!cell || typeof cell !== "object") return { kind: "missing-cell" };
|
|
17745
|
+
const { status, note } = cell;
|
|
17746
|
+
if (typeof status !== "string" || !status) return { kind: "malformed-cell" };
|
|
17747
|
+
return { kind: "declared", status, ...typeof note === "string" && note ? { note } : {} };
|
|
17748
|
+
}
|
|
17749
|
+
function assessActionVerification(decl, ctx) {
|
|
17750
|
+
const name = `${ctx.model}.${ctx.action}`;
|
|
17751
|
+
const tail = "\u4E0B\u4E00\u6B65\uFF1A\u53BB\u8FD9\u4E2A action \u6539\u52A8\u7684\u6570\u636E\u4E0A\u6838\u4E00\u6B21\u7ED3\u679C\uFF08\u4F8B\u5982 hcm query \u67E5\u5BF9\u5E94\u8BB0\u5F55\uFF09\uFF0C\u522B\u628A\u300C\u6267\u884C\u6210\u529F\u300D\u5F53\u6210\u300C\u5DF2\u843D\u5E93\u300D";
|
|
17752
|
+
let head;
|
|
17753
|
+
let extra = [];
|
|
17754
|
+
switch (decl.kind) {
|
|
17755
|
+
case "declared":
|
|
17756
|
+
if (decl.status === "NONE") {
|
|
17757
|
+
head = `\u5199\u540E\u6838\u9A8C\uFF1A${name} \u58F0\u660E\u4E86\u6267\u884C\u5B8C\u6838\u9A8C\u4E0D\u4E86\uFF0C\u5DF2\u6267\u884C\u3001\u672A\u6838\u9A8C\u3002`;
|
|
17758
|
+
extra = decl.note ? [` \u58F0\u660E\u539F\u6587\uFF1A${decl.note}`] : [" \uFF08\u58F0\u660E\u91CC\u6CA1\u7ED9\u8BF4\u660E\uFF09"];
|
|
17759
|
+
} else if (decl.status === "UNKNOWN") {
|
|
17760
|
+
head = `\u5199\u540E\u6838\u9A8C\uFF1A${name} \u8FD9\u4E2A action \u6CA1\u6709\u58F0\u660E\u53EF\u6838\u9A8C\u56DE\u6267\uFF0C\u5DF2\u6267\u884C\u3001\u672A\u6838\u9A8C\u3002`;
|
|
17761
|
+
} else {
|
|
17762
|
+
head = `\u5199\u540E\u6838\u9A8C\uFF1A\u8FD9\u7248 CLI \u4E0D\u8BA4\u8BC6 ${name} \u7684\u6838\u9A8C\u58F0\u660E ${decl.status}\uFF0C\u5DF2\u6267\u884C\uFF0C\u6309\u300C\u672A\u6838\u9A8C\u300D\u5904\u7406\uFF1B\u5347\u7EA7 CLI \u540E\u518D\u770B\u3002`;
|
|
17763
|
+
extra = decl.note ? [` \u58F0\u660E\u539F\u6587\uFF1A${decl.note}`] : [];
|
|
17764
|
+
}
|
|
17765
|
+
break;
|
|
17766
|
+
case "missing-cell":
|
|
17767
|
+
head = `\u5199\u540E\u6838\u9A8C\uFF1A\u6CA1\u8BFB\u5230 ${name} \u7684\u6838\u9A8C\u58F0\u660E\uFF08\u5E38\u89C1\u539F\u56E0\uFF1ACore \u7248\u672C\u65E9\u4E8E action \u6838\u9A8C\u58F0\u660E\u4E0A\u7EBF\uFF09\uFF0C\u5DF2\u6267\u884C\u3001\u672A\u6838\u9A8C\u3002`;
|
|
17768
|
+
break;
|
|
17769
|
+
case "malformed-cell":
|
|
17770
|
+
head = `\u5199\u540E\u6838\u9A8C\uFF1A${name} \u7684\u6838\u9A8C\u58F0\u660E\u5F62\u72B6\u8BA4\u4E0D\u51FA\uFF08verification \u91CC\u6CA1\u6709\u53EF\u8BFB\u7684 status\uFF09\uFF0C\u5DF2\u6267\u884C\u3001\u672A\u6838\u9A8C\u3002`;
|
|
17771
|
+
break;
|
|
17772
|
+
case "no-row":
|
|
17773
|
+
head = `\u5199\u540E\u6838\u9A8C\uFF1A\u6CA1\u8BFB\u5230\u6838\u9A8C\u58F0\u660E\uFF08GET /api/models/${ctx.model}/actions \u91CC\u6CA1\u6709 ${ctx.action} \u8FD9\u4E00\u884C\uFF09\uFF0C\u5DF2\u6267\u884C\u3001\u672A\u6838\u9A8C\u3002`;
|
|
17774
|
+
extra = [" /actions \u6309\u9875\u9762\u72B6\u6001\u5217\u51FA\uFF0C\u8FD9\u4E2A action \u53EF\u80FD\u53EA\u5728\u67D0\u4E2A\u72B6\u6001\u4E0B\u51FA\u73B0\uFF1B\u4E0D\u4E00\u5B9A\u662F Core \u592A\u65E7"];
|
|
17775
|
+
break;
|
|
17776
|
+
case "unreadable":
|
|
17777
|
+
head = `\u5199\u540E\u6838\u9A8C\uFF1A\u8BFB\u4E0D\u5230 action \u7684\u6838\u9A8C\u58F0\u660E\uFF08${decl.detail}\uFF09\uFF0C\u5DF2\u6267\u884C\u3001\u672A\u6838\u9A8C\u3002`;
|
|
17778
|
+
break;
|
|
17779
|
+
}
|
|
17780
|
+
return { exitCode: 7 /* VERIFY_UNAVAILABLE */, lines: [head, ...extra, tail] };
|
|
17781
|
+
}
|
|
17782
|
+
|
|
17362
17783
|
// src/cache.ts
|
|
17363
17784
|
async function getCacheStats(http, model) {
|
|
17364
17785
|
const resp = await http.get(`/api/models/${model}/cache`);
|
|
@@ -17500,7 +17921,7 @@ var COLUMN_SLOT_REBIND_SQL_KEYS = ["moveFromSlot", "verifyMoveFromSlot", "clearF
|
|
|
17500
17921
|
function headers(opts) {
|
|
17501
17922
|
return opts.workspaceKey ? { [WORKSPACE_KEY_HEADER]: opts.workspaceKey } : void 0;
|
|
17502
17923
|
}
|
|
17503
|
-
function
|
|
17924
|
+
function isRecord3(value) {
|
|
17504
17925
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17505
17926
|
}
|
|
17506
17927
|
function unexpected(path25, body) {
|
|
@@ -17517,7 +17938,7 @@ function unexpected(path25, body) {
|
|
|
17517
17938
|
async function getColumnSlots(http, model, opts = {}) {
|
|
17518
17939
|
const resp = await http.get(COLUMN_SLOTS_PATH, { params: { model }, headers: headers(opts) });
|
|
17519
17940
|
const data = resp.data?.data;
|
|
17520
|
-
if (!
|
|
17941
|
+
if (!isRecord3(data) || !Array.isArray(data.slots) || !Array.isArray(data.occupied)) {
|
|
17521
17942
|
throw unexpected(COLUMN_SLOTS_PATH, resp.data);
|
|
17522
17943
|
}
|
|
17523
17944
|
return data;
|
|
@@ -17528,7 +17949,7 @@ async function getColumnSlotSql(http, params, opts = {}) {
|
|
|
17528
17949
|
if (params.fromSlot) query2.fromSlot = params.fromSlot;
|
|
17529
17950
|
const resp = await http.get(COLUMN_SLOT_SQL_PATH, { params: query2, headers: headers(opts) });
|
|
17530
17951
|
const data = resp.data?.data;
|
|
17531
|
-
if (!
|
|
17952
|
+
if (!isRecord3(data) || !isRecord3(data.sql)) {
|
|
17532
17953
|
throw unexpected(COLUMN_SLOT_SQL_PATH, resp.data);
|
|
17533
17954
|
}
|
|
17534
17955
|
return data;
|
|
@@ -19496,25 +19917,25 @@ function extractFieldRows(metas) {
|
|
|
19496
19917
|
key,
|
|
19497
19918
|
// 🔴 中文名的键是 `name`,**不是 `label`**(实测 2676/2676 个字段没有一个带 label)。
|
|
19498
19919
|
// 本仓字段命名规范也是「名称字段统一用 name,禁止 label」。
|
|
19499
|
-
name:
|
|
19500
|
-
type:
|
|
19920
|
+
name: str2(rec2.name),
|
|
19921
|
+
type: str2(rec2.type),
|
|
19501
19922
|
// 🔴 必填的键是 `isRequired`,**不是 `required`**(实测 required 出现 0 次)。
|
|
19502
19923
|
// 缺省一律显式 false,不用 null——null 会把「没这属性」和「值是假」混成一件事。
|
|
19503
19924
|
isRequired: Boolean(rec2.isRequired ?? false),
|
|
19504
19925
|
isFlex: Boolean(rec2.isFlex ?? false),
|
|
19505
19926
|
// `columnDefinition` 是实测存在的存储侧信息(14% 的字段有);原计划的 `storage` 键**不存在**。
|
|
19506
|
-
columnDefinition:
|
|
19927
|
+
columnDefinition: str2(rec2.columnDefinition),
|
|
19507
19928
|
// 🔴 顾问真正会 grep 的是业务话术:字段级 synonyms 与 description。
|
|
19508
19929
|
// 它们稀疏但**恒发**(空就是 [] / "")——「有这一列且为空」与「没这一列」是两个值。
|
|
19509
19930
|
synonyms: Array.isArray(rec2.synonyms) ? rec2.synonyms.filter(Boolean).map(String) : [],
|
|
19510
|
-
description:
|
|
19931
|
+
description: str2(rec2.description),
|
|
19511
19932
|
enums: enumRows(rec2)
|
|
19512
19933
|
});
|
|
19513
19934
|
});
|
|
19514
19935
|
}
|
|
19515
19936
|
return { rows, dropped };
|
|
19516
19937
|
}
|
|
19517
|
-
function
|
|
19938
|
+
function str2(v) {
|
|
19518
19939
|
return v === void 0 || v === null || v === false ? "" : String(v);
|
|
19519
19940
|
}
|
|
19520
19941
|
function writeFieldsIndex(layout, rows) {
|
|
@@ -19553,7 +19974,7 @@ function actionsPath(modelKey, state = "") {
|
|
|
19553
19974
|
if (!state) return base;
|
|
19554
19975
|
return `${base}?${new URLSearchParams({ state }).toString()}`;
|
|
19555
19976
|
}
|
|
19556
|
-
function
|
|
19977
|
+
function isRecord4(v) {
|
|
19557
19978
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
19558
19979
|
}
|
|
19559
19980
|
function keyOrNull(key) {
|
|
@@ -19595,7 +20016,7 @@ async function collectActionGates(probe, modelKeys2, state = "") {
|
|
|
19595
20016
|
continue;
|
|
19596
20017
|
}
|
|
19597
20018
|
const body = out.body;
|
|
19598
|
-
if (!
|
|
20019
|
+
if (!isRecord4(body) || !Array.isArray(body.actions)) {
|
|
19599
20020
|
unavailable.push({
|
|
19600
20021
|
modelKey: model,
|
|
19601
20022
|
status: out.status,
|
|
@@ -19611,13 +20032,13 @@ async function collectActionGates(probe, modelKeys2, state = "") {
|
|
|
19611
20032
|
else statesEchoed.add(echoed);
|
|
19612
20033
|
for (const action3 of body.actions) {
|
|
19613
20034
|
actionsSeen += 1;
|
|
19614
|
-
if (!
|
|
20035
|
+
if (!isRecord4(action3)) {
|
|
19615
20036
|
reject(rejected, model, null, "malformed-action");
|
|
19616
20037
|
continue;
|
|
19617
20038
|
}
|
|
19618
20039
|
const cands = Array.isArray(action3.candidates) ? action3.candidates : [];
|
|
19619
20040
|
for (const c of cands) {
|
|
19620
|
-
if (
|
|
20041
|
+
if (isRecord4(c) && typeof c.source === "string" && c.source) sources.add(c.source);
|
|
19621
20042
|
}
|
|
19622
20043
|
const effectClass = classifyEffect(action3.effect);
|
|
19623
20044
|
if (effectClass !== "absent") actionsWithEffect += 1;
|
|
@@ -19661,7 +20082,7 @@ async function collectActionGates(probe, modelKeys2, state = "") {
|
|
|
19661
20082
|
reject(rejected, model, key, "no-candidates");
|
|
19662
20083
|
continue;
|
|
19663
20084
|
}
|
|
19664
|
-
if (!cands.every((c) =>
|
|
20085
|
+
if (!cands.every((c) => isRecord4(c))) {
|
|
19665
20086
|
reject(rejected, model, key, "malformed-candidate");
|
|
19666
20087
|
continue;
|
|
19667
20088
|
}
|
|
@@ -19984,7 +20405,7 @@ var badSection = (t) => `\u4F20\u5165\u7684 mutation \u6BB5\u4E0D\u662F\u5BF9\u8
|
|
|
19984
20405
|
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`;
|
|
19985
20406
|
var missingCell = (op) => `\u4F20\u5165\u7684 mutation \u91CC\u6CA1\u6709 ${op} \u8FD9\u4E00\u9879`;
|
|
19986
20407
|
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';
|
|
19987
|
-
function
|
|
20408
|
+
function isRecord5(v) {
|
|
19988
20409
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
19989
20410
|
}
|
|
19990
20411
|
function typeName2(v) {
|
|
@@ -20009,7 +20430,7 @@ async function collectMutation(probe, modelKeys2) {
|
|
|
20009
20430
|
continue;
|
|
20010
20431
|
}
|
|
20011
20432
|
const body = out.error === "ok" ? out.body : null;
|
|
20012
|
-
if (!
|
|
20433
|
+
if (!isRecord5(body)) {
|
|
20013
20434
|
const reason = `\u672A\u5E94\u7B54\uFF08HTTP ${out.status} / ${out.error}\uFF09`;
|
|
20014
20435
|
problems.push(`${key}: mutation-capability ${reason}`);
|
|
20015
20436
|
mutation[key] = Object.fromEntries(MUTATION_OPS.map((op) => [op, { allowed: "unknown", reason }]));
|
|
@@ -20018,7 +20439,7 @@ async function collectMutation(probe, modelKeys2) {
|
|
|
20018
20439
|
const entry = {};
|
|
20019
20440
|
for (const op of MUTATION_OPS) {
|
|
20020
20441
|
const cell = body[op];
|
|
20021
|
-
if (!
|
|
20442
|
+
if (!isRecord5(cell) || !("allowed" in cell)) {
|
|
20022
20443
|
entry[op] = { allowed: "unknown", reason: `\u54CD\u5E94\u91CC\u6CA1\u6709 ${op} \u8FD9\u4E00\u9879` };
|
|
20023
20444
|
problems.push(`${key}: mutation-capability \u54CD\u5E94\u7F3A ${op}`);
|
|
20024
20445
|
continue;
|
|
@@ -20039,14 +20460,14 @@ function mutationSection(entry) {
|
|
|
20039
20460
|
if (entry === void 0 || entry === null) {
|
|
20040
20461
|
return Object.fromEntries(MUTATION_OPS.map((op) => [op, { allowed: "unknown", reason: NOT_QUERIED }]));
|
|
20041
20462
|
}
|
|
20042
|
-
if (!
|
|
20463
|
+
if (!isRecord5(entry)) {
|
|
20043
20464
|
const reason = badSection(typeName2(entry));
|
|
20044
20465
|
return Object.fromEntries(MUTATION_OPS.map((op) => [op, { allowed: "unknown", reason }]));
|
|
20045
20466
|
}
|
|
20046
20467
|
const section = {};
|
|
20047
20468
|
for (const op of MUTATION_OPS) {
|
|
20048
20469
|
const cell = entry[op];
|
|
20049
|
-
if (
|
|
20470
|
+
if (isRecord5(cell)) {
|
|
20050
20471
|
section[op] = cell;
|
|
20051
20472
|
} else if (op in entry) {
|
|
20052
20473
|
section[op] = { allowed: "unknown", reason: badCell(op, typeName2(cell)) };
|
|
@@ -20059,7 +20480,7 @@ function mutationSection(entry) {
|
|
|
20059
20480
|
function writability(field) {
|
|
20060
20481
|
const derived = field.derived;
|
|
20061
20482
|
if (derived) {
|
|
20062
|
-
const kind =
|
|
20483
|
+
const kind = isRecord5(derived) ? derived.kind : null;
|
|
20063
20484
|
return { writable: false, reason: `derived:${typeof kind === "string" && kind ? kind : "unknown"}` };
|
|
20064
20485
|
}
|
|
20065
20486
|
if (field.isReadonly) return { writable: false, reason: "readonly" };
|
|
@@ -20074,7 +20495,7 @@ function buildMapping(metas, edges, mutation, codeTables = []) {
|
|
|
20074
20495
|
const { fields, problem: problem6 } = metaFields(metas[modelKey]);
|
|
20075
20496
|
const rows = [];
|
|
20076
20497
|
for (const f of fields) {
|
|
20077
|
-
if (!
|
|
20498
|
+
if (!isRecord5(f)) continue;
|
|
20078
20499
|
const key = f.key;
|
|
20079
20500
|
if (typeof key !== "string" || !key) continue;
|
|
20080
20501
|
const { writable, reason } = writability(f);
|
|
@@ -20117,7 +20538,7 @@ function buildMapping(metas, edges, mutation, codeTables = []) {
|
|
|
20117
20538
|
// 「爬过且这个模型确实没有字段」必须与「没爬过」(文件不存在)区分开。
|
|
20118
20539
|
crawled: true,
|
|
20119
20540
|
wording: WORDING3,
|
|
20120
|
-
mutation: mutationSection(
|
|
20541
|
+
mutation: mutationSection(isRecord5(mutation) ? mutation[modelKey] : mutation),
|
|
20121
20542
|
fieldCount: rows.length,
|
|
20122
20543
|
// 🔴 `null` = 载荷判读正常(fieldCount=0 就是「这个模型确实没字段」);
|
|
20123
20544
|
// 非 null = **爬过、但判不出字段**,此时 fieldCount=0 不代表「没字段」。
|
|
@@ -20129,8 +20550,8 @@ function buildMapping(metas, edges, mutation, codeTables = []) {
|
|
|
20129
20550
|
}
|
|
20130
20551
|
function allowedIn(sheet, op) {
|
|
20131
20552
|
const section = sheet.mutation;
|
|
20132
|
-
const cell =
|
|
20133
|
-
return
|
|
20553
|
+
const cell = isRecord5(section) ? section[op] : void 0;
|
|
20554
|
+
return isRecord5(cell) ? cell.allowed : "unknown";
|
|
20134
20555
|
}
|
|
20135
20556
|
var PATH_SEPARATORS = ["/", String.fromCharCode(92)];
|
|
20136
20557
|
function unsafeKeyReason(modelKey) {
|
|
@@ -20312,7 +20733,7 @@ function writeModelsMd(layout, text3) {
|
|
|
20312
20733
|
// src/fde/recon/pointer-audit.ts
|
|
20313
20734
|
import { existsSync as existsSync3 } from "fs";
|
|
20314
20735
|
import * as path10 from "path";
|
|
20315
|
-
function
|
|
20736
|
+
function isRecord6(v) {
|
|
20316
20737
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
20317
20738
|
}
|
|
20318
20739
|
function auditValueDomainPointers(layout, sheets) {
|
|
@@ -20321,7 +20742,7 @@ function auditValueDomainPointers(layout, sheets) {
|
|
|
20321
20742
|
for (const sheet of sheets) {
|
|
20322
20743
|
for (const field of sheet.fields) {
|
|
20323
20744
|
const ref = field.ref;
|
|
20324
|
-
const pointer =
|
|
20745
|
+
const pointer = isRecord6(ref) ? ref.valueDomain : null;
|
|
20325
20746
|
if (typeof pointer !== "string" || pointer === "") continue;
|
|
20326
20747
|
if (!seen.has(pointer)) {
|
|
20327
20748
|
seen.set(pointer, existsSync3(path10.join(layout.dir, pointer)));
|
|
@@ -20412,18 +20833,18 @@ var WORDING4 = "rows = \u672C\u8F6E\u4EE5\u5F53\u524D\u767B\u5F55\u8EAB\u4EFD\u8
|
|
|
20412
20833
|
function listPath(modelKey) {
|
|
20413
20834
|
return `/api/models/${modelKey}/list/dsl`;
|
|
20414
20835
|
}
|
|
20415
|
-
function
|
|
20836
|
+
function isRecord7(v) {
|
|
20416
20837
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
20417
20838
|
}
|
|
20418
20839
|
function readContent(body) {
|
|
20419
|
-
if (!
|
|
20840
|
+
if (!isRecord7(body)) return { rows: null, total: null, nonDict: 0 };
|
|
20420
20841
|
const rows = body.content;
|
|
20421
20842
|
const total = body.totalElements;
|
|
20422
20843
|
if (!Array.isArray(rows)) return { rows: null, total: null, nonDict: 0 };
|
|
20423
20844
|
if (typeof total !== "number" || !Number.isInteger(total) || total < 0) {
|
|
20424
20845
|
return { rows: null, total: null, nonDict: 0 };
|
|
20425
20846
|
}
|
|
20426
|
-
const kept = rows.filter((r) =>
|
|
20847
|
+
const kept = rows.filter((r) => isRecord7(r));
|
|
20427
20848
|
return { rows: kept, total, nonDict: rows.length - kept.length };
|
|
20428
20849
|
}
|
|
20429
20850
|
async function collectCodeTables(probe, modelEntries2, opts = {}) {
|
|
@@ -20436,7 +20857,7 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
|
|
|
20436
20857
|
const problems = [];
|
|
20437
20858
|
const keys = [];
|
|
20438
20859
|
for (const entry of modelEntries2) {
|
|
20439
|
-
if (!
|
|
20860
|
+
if (!isRecord7(entry) || entry.type !== DYNAMIC_TYPE) continue;
|
|
20440
20861
|
const key = entry.modelKey;
|
|
20441
20862
|
if (typeof key !== "string" || !key) {
|
|
20442
20863
|
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`);
|
|
@@ -20570,12 +20991,12 @@ function collectEnumDomains(metas) {
|
|
|
20570
20991
|
for (const modelKey of Object.keys(metas).sort()) {
|
|
20571
20992
|
const { fields } = metaFields(metas[modelKey]);
|
|
20572
20993
|
for (const field of fields) {
|
|
20573
|
-
if (!
|
|
20994
|
+
if (!isRecord7(field)) continue;
|
|
20574
20995
|
const fieldKey = field.key;
|
|
20575
20996
|
if (typeof fieldKey !== "string" || !fieldKey) continue;
|
|
20576
20997
|
const enums = field.enums;
|
|
20577
20998
|
if (!Array.isArray(enums) || enums.length === 0) continue;
|
|
20578
|
-
const kept = enums.filter(
|
|
20999
|
+
const kept = enums.filter(isRecord7).map((e) => ({ ...e }));
|
|
20579
21000
|
rows.push({
|
|
20580
21001
|
model: modelKey,
|
|
20581
21002
|
field: fieldKey,
|
|
@@ -20586,7 +21007,7 @@ function collectEnumDomains(metas) {
|
|
|
20586
21007
|
// —— 否则「这个字段的枚举少了一项」这件事没有任何出处。
|
|
20587
21008
|
// 实测 3179 条全是对象,这一档从未观测到;**恒发空列表**而不是条件出键:
|
|
20588
21009
|
// 「有这一列且为空」与「没这一列」是两个值,后者读起来像「没检查过」。
|
|
20589
|
-
nonDictElements: enums.filter((e) => !
|
|
21010
|
+
nonDictElements: enums.filter((e) => !isRecord7(e)).map((e) => JSON.stringify(e) ?? String(e))
|
|
20590
21011
|
});
|
|
20591
21012
|
}
|
|
20592
21013
|
}
|
|
@@ -20631,7 +21052,7 @@ function writeValuedomain(layout, codeTables, enums, opts = {}) {
|
|
|
20631
21052
|
roundId: opts.roundId ?? null,
|
|
20632
21053
|
// 🔴 `identity || {}` 会把「调用方没传身份」和「身份是空的」压成同一个值,
|
|
20633
21054
|
// 而它们的下一步不同(前者去补工具的登录,后者去问服务端为什么不给 user)。
|
|
20634
|
-
identity:
|
|
21055
|
+
identity: isRecord7(opts.identity) ? opts.identity : null,
|
|
20635
21056
|
codeTableCount: Object.keys(codeTables).length,
|
|
20636
21057
|
enumFieldCount: enums.length,
|
|
20637
21058
|
// 🔴 名册里一共看到几条。上游名册加载失败给出空数组时,产物会与
|
|
@@ -20701,7 +21122,7 @@ function parseRoundStamp(stamp2) {
|
|
|
20701
21122
|
function newRoundId(started) {
|
|
20702
21123
|
return `${roundStamp(started)}-${randomBytes3(4).toString("hex")}`;
|
|
20703
21124
|
}
|
|
20704
|
-
function
|
|
21125
|
+
function isRecord8(v) {
|
|
20705
21126
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
20706
21127
|
}
|
|
20707
21128
|
function readJsonSoft(file) {
|
|
@@ -20720,8 +21141,8 @@ function readJsonSoft(file) {
|
|
|
20720
21141
|
}
|
|
20721
21142
|
function readCrawledAt(layout) {
|
|
20722
21143
|
const body = readJsonSoft(path11.join(layout.dir, KIT_CRAWLED_AT_FILE));
|
|
20723
|
-
const models =
|
|
20724
|
-
return
|
|
21144
|
+
const models = isRecord8(body) ? body.models : null;
|
|
21145
|
+
return isRecord8(models) ? models : {};
|
|
20725
21146
|
}
|
|
20726
21147
|
function writeCrawledAt(layout, freshKeys, carriedKeys, roundId, started) {
|
|
20727
21148
|
const previous = readCrawledAt(layout);
|
|
@@ -20769,14 +21190,14 @@ function productRoundId(root, rel) {
|
|
|
20769
21190
|
const p = path11.join(root, rel);
|
|
20770
21191
|
if (!existsSync4(p)) return ["missing", null];
|
|
20771
21192
|
const body = readJsonSoft(p);
|
|
20772
|
-
if (body === void 0 || !
|
|
21193
|
+
if (body === void 0 || !isRecord8(body)) return ["unreadable", null];
|
|
20773
21194
|
const rid = body.roundId;
|
|
20774
21195
|
if (typeof rid !== "string" || !rid) return ["unstamped", null];
|
|
20775
21196
|
return ["stamped", rid];
|
|
20776
21197
|
}
|
|
20777
21198
|
function inspectRound(root) {
|
|
20778
21199
|
const raw = readJsonSoft(path11.join(root, KIT_CRAWLED_AT_FILE));
|
|
20779
|
-
const ledger =
|
|
21200
|
+
const ledger = isRecord8(raw) ? raw : {};
|
|
20780
21201
|
const rid = ledger.roundId;
|
|
20781
21202
|
const roundId = typeof rid === "string" && rid ? rid : null;
|
|
20782
21203
|
const rawWritten = ledger.productsWrittenThisRound;
|
|
@@ -20881,7 +21302,7 @@ function renderRound(result) {
|
|
|
20881
21302
|
}
|
|
20882
21303
|
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";
|
|
20883
21304
|
function carriedGatesSchemaProblem(oldGates) {
|
|
20884
|
-
if (!
|
|
21305
|
+
if (!isRecord8(oldGates)) {
|
|
20885
21306
|
const shape = Array.isArray(oldGates) ? "list" : oldGates === null ? "null" : typeof oldGates;
|
|
20886
21307
|
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}`;
|
|
20887
21308
|
}
|
|
@@ -20922,7 +21343,7 @@ function collectCarryOver(layout, freshMetas) {
|
|
|
20922
21343
|
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`);
|
|
20923
21344
|
continue;
|
|
20924
21345
|
}
|
|
20925
|
-
if (
|
|
21346
|
+
if (isRecord8(body)) carriedMetas[key] = body;
|
|
20926
21347
|
else {
|
|
20927
21348
|
problems.push(
|
|
20928
21349
|
`${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`
|
|
@@ -20937,9 +21358,9 @@ function collectCarryOver(layout, freshMetas) {
|
|
|
20937
21358
|
const stale = carriedGatesSchemaProblem(oldGates);
|
|
20938
21359
|
if (stale) problems.push(stale);
|
|
20939
21360
|
}
|
|
20940
|
-
const oldList =
|
|
21361
|
+
const oldList = isRecord8(oldGates) && Array.isArray(oldGates.gates) ? oldGates.gates : [];
|
|
20941
21362
|
for (const g of oldList) {
|
|
20942
|
-
if (
|
|
21363
|
+
if (isRecord8(g) && !(String(g.model) in freshMetas)) carriedGates.push(g);
|
|
20943
21364
|
}
|
|
20944
21365
|
return { carriedMetas, carriedGates, problems };
|
|
20945
21366
|
}
|
|
@@ -21063,7 +21484,7 @@ async function runRecon(probe, layout, opts = {}) {
|
|
|
21063
21484
|
products.push(...mappingPaths.map((p) => relOf(layout, p)));
|
|
21064
21485
|
const sheetsWritten = Math.max(mappingPaths.length - 1, 0);
|
|
21065
21486
|
let previous = readJsonSoft(path11.join(layout.dir, "fingerprint.json"));
|
|
21066
|
-
if (!
|
|
21487
|
+
if (!isRecord8(previous)) previous = null;
|
|
21067
21488
|
const current = await computeFingerprint(probe);
|
|
21068
21489
|
products.push(relOf(layout, layout.writeJson("fingerprint.json", current)));
|
|
21069
21490
|
const drift = previous === null ? null : compareFingerprint(previous, current);
|
|
@@ -26173,7 +26594,7 @@ var STEP_SEND = "send";
|
|
|
26173
26594
|
var STEP_READBACK = "readback";
|
|
26174
26595
|
var STEP_NOTHING = "nothing";
|
|
26175
26596
|
var STEP_STOP = "stop";
|
|
26176
|
-
var
|
|
26597
|
+
var NEXT_STEP2 = {
|
|
26177
26598
|
// 用字符串 `'null'` 当键会与一个真叫 "null" 的状态撞;这里用 `Map` 的等价写法:
|
|
26178
26599
|
// 键就是 `String(status)`,而 `STATUSES` 里没有 `"null"` 这个值(值域守卫钉着)。
|
|
26179
26600
|
null: STEP_SEND,
|
|
@@ -26532,7 +26953,7 @@ var Journal = class _Journal {
|
|
|
26532
26953
|
* (已建好 / 已跳过 / **中毒了要人处理**),单看任何一个都读不出来。
|
|
26533
26954
|
*/
|
|
26534
26955
|
nextStep(model, key) {
|
|
26535
|
-
return
|
|
26956
|
+
return NEXT_STEP2[String(this.statusOf(model, key))];
|
|
26536
26957
|
}
|
|
26537
26958
|
/** 这一行要不要**先按业务键回读**再决定 —— 只有 `unknown` 是 true。 */
|
|
26538
26959
|
needsReadback(model, key) {
|
|
@@ -28407,7 +28828,7 @@ function indent(text3) {
|
|
|
28407
28828
|
function verifyAttention(delivery, recon) {
|
|
28408
28829
|
const agreeing = new Set(AGREEING_VERDICTS);
|
|
28409
28830
|
return [
|
|
28410
|
-
delivery.rows.filter((row) =>
|
|
28831
|
+
delivery.rows.filter((row) => NEXT_STEP2[row.status] !== STEP_NOTHING),
|
|
28411
28832
|
[...delivery.plannedWithoutRecord ?? []],
|
|
28412
28833
|
(recon.findings ?? []).filter((f) => !agreeing.has(f.verdict))
|
|
28413
28834
|
];
|
|
@@ -28489,7 +28910,7 @@ function verifyText(delivery, recon) {
|
|
|
28489
28910
|
lines.push(` \u8981\u4EBA\u770B\u7684 ${rows.length} \u884C\uFF08\u4E0B\u4E00\u6B65\u4E0D\u662F\u300C\u4E0D\u5FC5\u518D\u52A8\u300D\u7684\u90A3\u4E9B\uFF09${rows.length ? "\uFF1A" : "\u3002"}`);
|
|
28490
28911
|
for (const row of rows) {
|
|
28491
28912
|
lines.push(
|
|
28492
|
-
` - ${row.model} ${JSON.stringify(row.businessKey)} status=${row.status} \u4E0B\u4E00\u6B65=${
|
|
28913
|
+
` - ${row.model} ${JSON.stringify(row.businessKey)} status=${row.status} \u4E0B\u4E00\u6B65=${NEXT_STEP2[row.status]}`
|
|
28493
28914
|
);
|
|
28494
28915
|
}
|
|
28495
28916
|
if (delivery.plannedWithoutRecord === null) {
|
|
@@ -28787,7 +29208,7 @@ var EXACT_KEY_RANK = 1;
|
|
|
28787
29208
|
var WEAKEST_RANK = Object.keys(DIMENSION_RANK).length;
|
|
28788
29209
|
var VISIBLE_DIMENSIONS = /* @__PURE__ */ new Set(["name", "key", "model"]);
|
|
28789
29210
|
var asList = (v) => v === null || v === void 0 ? [] : Array.isArray(v) ? v : [v];
|
|
28790
|
-
var
|
|
29211
|
+
var str3 = (v) => v === null || v === void 0 ? "" : String(v);
|
|
28791
29212
|
var bytes = (s) => Buffer.byteLength(s, "utf-8");
|
|
28792
29213
|
function loadRows(text3) {
|
|
28793
29214
|
const rows = [];
|
|
@@ -28813,19 +29234,19 @@ function matchedDimensions(row, term) {
|
|
|
28813
29234
|
const t = term.toLowerCase();
|
|
28814
29235
|
const dims = [];
|
|
28815
29236
|
for (const dim of ["name", "key", "model"]) {
|
|
28816
|
-
if (
|
|
29237
|
+
if (str3(row[dim]).toLowerCase().includes(t)) dims.push(dim);
|
|
28817
29238
|
}
|
|
28818
|
-
if (asList(row.synonyms).some((s) =>
|
|
28819
|
-
if (
|
|
29239
|
+
if (asList(row.synonyms).some((s) => str3(s).toLowerCase().includes(t))) dims.push("synonyms");
|
|
29240
|
+
if (str3(row.description).toLowerCase().includes(t)) dims.push("description");
|
|
28820
29241
|
const labels = [];
|
|
28821
29242
|
const values = [];
|
|
28822
29243
|
for (const e of asList(row.enums)) {
|
|
28823
29244
|
if (e && typeof e === "object" && !Array.isArray(e)) {
|
|
28824
29245
|
const o = e;
|
|
28825
|
-
values.push(
|
|
28826
|
-
labels.push(
|
|
29246
|
+
values.push(str3(o.value));
|
|
29247
|
+
labels.push(str3(o.label));
|
|
28827
29248
|
} else {
|
|
28828
|
-
values.push(
|
|
29249
|
+
values.push(str3(e));
|
|
28829
29250
|
}
|
|
28830
29251
|
}
|
|
28831
29252
|
if (labels.some((x) => x.toLowerCase().includes(t))) dims.push("enumLabel");
|
|
@@ -28834,8 +29255,8 @@ function matchedDimensions(row, term) {
|
|
|
28834
29255
|
}
|
|
28835
29256
|
function hitRank(row, dims, term) {
|
|
28836
29257
|
const t = term.toLowerCase();
|
|
28837
|
-
if (dims.includes("name") &&
|
|
28838
|
-
if (dims.includes("key") &&
|
|
29258
|
+
if (dims.includes("name") && str3(row.name).toLowerCase() === t) return EXACT_NAME_RANK;
|
|
29259
|
+
if (dims.includes("key") && str3(row.key).toLowerCase() === t) return EXACT_KEY_RANK;
|
|
28839
29260
|
let best = WEAKEST_RANK;
|
|
28840
29261
|
for (const d of dims) best = Math.min(best, DIMENSION_RANK[d] ?? WEAKEST_RANK);
|
|
28841
29262
|
return best;
|
|
@@ -28862,16 +29283,16 @@ function enumTail(row) {
|
|
|
28862
29283
|
const o = e;
|
|
28863
29284
|
const synth = o[KIT_VALUE_SOURCE] !== void 0 && o[KIT_VALUE_SOURCE] !== null;
|
|
28864
29285
|
if (synth) hasSynth = true;
|
|
28865
|
-
shown.push(`${
|
|
29286
|
+
shown.push(`${str3(o.value)}${synth ? SYNTH_MARK : ""}`);
|
|
28866
29287
|
} else {
|
|
28867
|
-
shown.push(
|
|
29288
|
+
shown.push(str3(e));
|
|
28868
29289
|
}
|
|
28869
29290
|
}
|
|
28870
29291
|
const more = items.length > ENUM_SHOW ? `\u2026\u5171 ${items.length} \u4E2A` : "";
|
|
28871
29292
|
return { tail: ` {${shown.join("/")}${more}}`, hasSynth };
|
|
28872
29293
|
}
|
|
28873
29294
|
function matchNote(hit) {
|
|
28874
|
-
const dims = asList(hit[KIT_MATCHED_ON]).map(
|
|
29295
|
+
const dims = asList(hit[KIT_MATCHED_ON]).map(str3);
|
|
28875
29296
|
if (dims.length === 0) return "";
|
|
28876
29297
|
if (dims.some((d) => VISIBLE_DIMENSIONS.has(d))) return "";
|
|
28877
29298
|
return " \u2190\u547D\u4E2D\u4E8E" + dims.map((d) => DIMENSION_LABELS[d] ?? d).join("/");
|
|
@@ -28893,7 +29314,7 @@ function renderFind(hits, term, total, options = {}) {
|
|
|
28893
29314
|
let valueShown = false;
|
|
28894
29315
|
for (const h of hits) {
|
|
28895
29316
|
const { tail, hasSynth } = enumTail(h);
|
|
28896
|
-
const line = `- ${
|
|
29317
|
+
const line = `- ${str3(h.name)} \u2192 \`${str3(h.model)}\`.\`${str3(h.key)}\` [${str3(h.type)}]${h.isRequired ? "\u5FC5\u586B" : ""}${tail}${matchNote(h)}
|
|
28897
29318
|
`;
|
|
28898
29319
|
const hint = options.hints ? options.hints.line(h.model, h.key) : "";
|
|
28899
29320
|
const block = line + hint;
|
|
@@ -30213,6 +30634,12 @@ function redactUrlCredentials(url) {
|
|
|
30213
30634
|
}
|
|
30214
30635
|
var METHOD_REPO_DISPLAY = process.env.HCM_METHOD_REPO_URL?.trim() ? redactUrlCredentials(METHOD_REPO_URL) : METHOD_REPO_SLUG;
|
|
30215
30636
|
var repoIssueUrl = (repo, number) => `${CNB_ORIGIN}/${repo}/-/issues/${number}`;
|
|
30637
|
+
var DEFAULT_GITLAB_ORIGIN = "https://git.hcmcloud.io";
|
|
30638
|
+
var GITLAB_ORIGIN = trimSlash(env("HCM_GITLAB_ORIGIN", DEFAULT_GITLAB_ORIGIN));
|
|
30639
|
+
var hostOf = (origin) => (origin.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "").split("/")[0] ?? "").toLowerCase();
|
|
30640
|
+
var GITLAB_HOST = hostOf(GITLAB_ORIGIN);
|
|
30641
|
+
var GITLAB_REF_HOSTS = [...new Set([hostOf(DEFAULT_GITLAB_ORIGIN), GITLAB_HOST].filter(Boolean))];
|
|
30642
|
+
var gitlabIssueUrl = (repo, number) => `${GITLAB_ORIGIN}/${repo}/-/issues/${number}`;
|
|
30216
30643
|
var CNB_FAVICON_URL = `${CNB_ORIGIN}/favicon.ico`;
|
|
30217
30644
|
|
|
30218
30645
|
// src/jira/client.ts
|
|
@@ -30581,12 +31008,26 @@ async function createJiraClient(opts = {}) {
|
|
|
30581
31008
|
}
|
|
30582
31009
|
|
|
30583
31010
|
// src/jira/refs.ts
|
|
30584
|
-
var
|
|
31011
|
+
var escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31012
|
+
var HOST = `(?:${GITLAB_REF_HOSTS.map(escapeRe).join("|")})`;
|
|
31013
|
+
var GITLAB_REF_RE = new RegExp(`${HOST}\\/hcm\\/(hcm_nx_(?:core|cloud))(?:#|\\/-\\/(?:issues|work_items)\\/)(\\d+)`, "g");
|
|
31014
|
+
var CNB_REF_RE = new RegExp(`(?<!${HOST}\\/)hcm\\/(hcm_nx_(?:core|cli|cloud))(?:#|\\/-\\/issues\\/)(\\d+)`, "g");
|
|
31015
|
+
var refId = (r) => forgeOf(r) === "gitlab" ? `${GITLAB_HOST}/${r.repo}#${r.number}` : `${r.repo}#${r.number}`;
|
|
31016
|
+
var refUrl = (r) => forgeOf(r) === "gitlab" ? gitlabIssueUrl(r.repo, r.number) : repoIssueUrl(r.repo, r.number);
|
|
31017
|
+
function forgeOf(r) {
|
|
31018
|
+
if (r.forge === "gitlab" || r.forge === "cnb") return r.forge;
|
|
31019
|
+
throw new Error(`RepoRef.forge \u53EA\u80FD\u662F gitlab \u6216 cnb\uFF0C${r.repo}#${r.number} \u7ED9\u7684\u662F ${String(r.forge)}\uFF1A\u7528 linkedRepoRefs \u7684\u7ED3\u679C\uFF0C\u6216\u6784\u9020\u65F6\u5199\u660E forge`);
|
|
31020
|
+
}
|
|
31021
|
+
var JIRA_LINK_RE = /\[([^|\]\n]*)\|([^\]\n]+)\]/g;
|
|
31022
|
+
var isRefTarget = (target) => new RegExp(GITLAB_REF_RE.source).test(target) || new RegExp(CNB_REF_RE.source).test(target);
|
|
30585
31023
|
function linkedRepoRefs(text3) {
|
|
31024
|
+
const t = String(text3 ?? "").replace(JIRA_LINK_RE, (whole, _label, target) => isRefTarget(target) ? target : whole);
|
|
31025
|
+
const hits = [
|
|
31026
|
+
...[...t.matchAll(GITLAB_REF_RE)].map((m) => ({ at: m.index ?? 0, ref: { repo: `hcm/${m[1]}`, number: m[2], forge: "gitlab" } })),
|
|
31027
|
+
...[...t.matchAll(CNB_REF_RE)].map((m) => ({ at: m.index ?? 0, ref: { repo: `hcm/${m[1]}`, number: m[2], forge: "cnb" } }))
|
|
31028
|
+
].sort((a, b) => a.at - b.at);
|
|
30586
31029
|
const out = /* @__PURE__ */ new Map();
|
|
30587
|
-
for (const
|
|
30588
|
-
out.set(`hcm/${m[1]}#${m[2]}`, { repo: `hcm/${m[1]}`, number: m[2] });
|
|
30589
|
-
}
|
|
31030
|
+
for (const h of hits) if (!out.has(refId(h.ref))) out.set(refId(h.ref), h.ref);
|
|
30590
31031
|
return [...out.values()];
|
|
30591
31032
|
}
|
|
30592
31033
|
function parseRef(raw, project, casesSlug = CASES_REPO_SLUG) {
|
|
@@ -30696,6 +31137,9 @@ export {
|
|
|
30696
31137
|
FORCE_STALE_FLAG,
|
|
30697
31138
|
FORCE_STALE_FLAG_TEXT,
|
|
30698
31139
|
GATE_COMPONENTS,
|
|
31140
|
+
GITLAB_HOST,
|
|
31141
|
+
GITLAB_ORIGIN,
|
|
31142
|
+
GITLAB_REF_HOSTS,
|
|
30699
31143
|
HANDSHAKE_AUTH_ERROR_HEADER,
|
|
30700
31144
|
HANDSHAKE_CONVERSATION_QUERY_PARAM,
|
|
30701
31145
|
HANDSHAKE_TOKEN_QUERY_PARAM,
|
|
@@ -30756,7 +31200,7 @@ export {
|
|
|
30756
31200
|
MODEL_META_PATH,
|
|
30757
31201
|
MappingError,
|
|
30758
31202
|
NETWORK_GATES,
|
|
30759
|
-
NEXT_STEP,
|
|
31203
|
+
NEXT_STEP2 as NEXT_STEP,
|
|
30760
31204
|
NON_BMP_RULE_NOTE,
|
|
30761
31205
|
NOT_COVERED_LAYER1,
|
|
30762
31206
|
NOT_COVERED_LAYER2,
|
|
@@ -30863,6 +31307,8 @@ export {
|
|
|
30863
31307
|
assertSafeSkillFilePath,
|
|
30864
31308
|
assertSafeSkillId,
|
|
30865
31309
|
assertUsableEndpoint,
|
|
31310
|
+
assessActionVerification,
|
|
31311
|
+
assessWriteVerification,
|
|
30866
31312
|
baselineRoundPremise,
|
|
30867
31313
|
bootstrapTenant,
|
|
30868
31314
|
buildAnswer,
|
|
@@ -30934,6 +31380,7 @@ export {
|
|
|
30934
31380
|
exitCodeFor,
|
|
30935
31381
|
explainJacksonError,
|
|
30936
31382
|
extractNextSteps,
|
|
31383
|
+
fetchActionVerification,
|
|
30937
31384
|
fetchConversationTimeline,
|
|
30938
31385
|
fetchConversationTimelineStrict,
|
|
30939
31386
|
fetchInstallRun,
|
|
@@ -30968,6 +31415,7 @@ export {
|
|
|
30968
31415
|
getScriptTask,
|
|
30969
31416
|
getSettingDomain,
|
|
30970
31417
|
getTenantMeta,
|
|
31418
|
+
gitlabIssueUrl,
|
|
30971
31419
|
globalConfigFile,
|
|
30972
31420
|
guessMimeType,
|
|
30973
31421
|
handshakeRejectedError,
|
|
@@ -30979,6 +31427,7 @@ export {
|
|
|
30979
31427
|
identityDir,
|
|
30980
31428
|
identityKnown,
|
|
30981
31429
|
identityMetaFile,
|
|
31430
|
+
importExitCode,
|
|
30982
31431
|
inferMiniWritableTemplateOptionsFromModel,
|
|
30983
31432
|
initMiniAppProject,
|
|
30984
31433
|
inspectRound,
|
|
@@ -31081,6 +31530,8 @@ export {
|
|
|
31081
31530
|
rebindPayload,
|
|
31082
31531
|
reconcileTenant,
|
|
31083
31532
|
redactDescriptiveUuids,
|
|
31533
|
+
refId,
|
|
31534
|
+
refUrl,
|
|
31084
31535
|
refreshToken,
|
|
31085
31536
|
releasePendingImpersonationSessions,
|
|
31086
31537
|
remove,
|
|
@@ -31139,12 +31590,14 @@ export {
|
|
|
31139
31590
|
stripDefinitionIds,
|
|
31140
31591
|
stripUnknownFieldKeys,
|
|
31141
31592
|
stripUnknownFieldKeysForPath,
|
|
31593
|
+
stripVerifyEchoKeys,
|
|
31142
31594
|
tenantSegment,
|
|
31143
31595
|
toAcceptLanguage,
|
|
31144
31596
|
toJson,
|
|
31145
31597
|
toOrigin,
|
|
31146
31598
|
toPrincipal,
|
|
31147
31599
|
toTable,
|
|
31600
|
+
toWorkspacePreflightIssue,
|
|
31148
31601
|
toYaml,
|
|
31149
31602
|
truncateDisplay,
|
|
31150
31603
|
unbindPayload,
|