@hcmai/sdk 0.27.3 → 0.28.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.js CHANGED
@@ -1018,8 +1018,8 @@ async function resolveEnvContext(args, env2, global) {
1018
1018
  }
1019
1019
  function printResolvedEnvironment(context, identity, tenantId) {
1020
1020
  const file = context.project?.path;
1021
- const relative3 = file ? path2.relative(process.cwd(), file) : void 0;
1022
- const source = context.source === "env.yaml" && relative3 ? relative3.startsWith(".") ? relative3 : `./${relative3}` : `${context.source}${relative3 ? ` \u2192 ${relative3.startsWith(".") ? relative3 : `./${relative3}`}` : ""}`;
1021
+ const relative4 = file ? path2.relative(process.cwd(), file) : void 0;
1022
+ const source = context.source === "env.yaml" && relative4 ? relative4.startsWith(".") ? relative4 : `./${relative4}` : `${context.source}${relative4 ? ` \u2192 ${relative4.startsWith(".") ? relative4 : `./${relative4}`}` : ""}`;
1023
1023
  process.stderr.write(`\u2192 ${context.project?.name ?? context.name}${context.project ? `\uFF08\u672C\u673A\u69FD ${context.name}\uFF09` : ""} \xB7 ${context.config.endpoint} \xB7 \u79DF\u6237 ${tenantId ?? context.project?.environment.tenant ?? context.config.tenantId ?? "\u672A\u6307\u5B9A"} \xB7 \u8EAB\u4EFD ${identity ?? "\u672A\u8BA4\u8BC1"}${context.danger ? " \xB7 danger" : ""}\uFF08\u6765\u81EA ${source}\uFF09
1024
1024
  `);
1025
1025
  }
@@ -1773,18 +1773,18 @@ async function action(http, model, actionName, input) {
1773
1773
  if (scope === "object" && !input.id) {
1774
1774
  throw new Error(`object action ${model}.${actionName} requires id`);
1775
1775
  }
1776
- const path24 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
1776
+ const path25 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
1777
1777
  const resp = await (async () => {
1778
1778
  if (method === "GET") {
1779
- return http.get(path24, { params: queryParams(input) });
1779
+ return http.get(path25, { params: queryParams(input) });
1780
1780
  }
1781
1781
  if (method === "DELETE") {
1782
- return http.delete(path24, { params: queryParams(input) });
1782
+ return http.delete(path25, { params: queryParams(input) });
1783
1783
  }
1784
1784
  if (method === "PUT") {
1785
- return http.put(path24, scope === "object" ? objectBody(input) : classBody(input));
1785
+ return http.put(path25, scope === "object" ? objectBody(input) : classBody(input));
1786
1786
  }
1787
- return http.post(path24, scope === "object" ? objectBody(input) : classBody(input));
1787
+ return http.post(path25, scope === "object" ? objectBody(input) : classBody(input));
1788
1788
  })();
1789
1789
  return resp.data;
1790
1790
  }
@@ -1931,8 +1931,8 @@ function compareFingerprint(recorded, current) {
1931
1931
  continue;
1932
1932
  }
1933
1933
  const raw = notes.fetchFailures;
1934
- const list = Array.isArray(raw) ? raw : [];
1935
- const gateFailures = [...new Set(list.map(String))].filter((x) => GATE_SOURCES.some((s) => x.startsWith(s))).sort();
1934
+ const list2 = Array.isArray(raw) ? raw : [];
1935
+ const gateFailures = [...new Set(list2.map(String))].filter((x) => GATE_SOURCES.some((s) => x.startsWith(s))).sort();
1936
1936
  for (const f of gateFailures) diffs.push(`incomplete:${tag}:${f}`);
1937
1937
  }
1938
1938
  return diffs;
@@ -2124,7 +2124,7 @@ function parseFixture(yamlText, sourcePath) {
2124
2124
  if (hasLegacyKey) {
2125
2125
  const keys = doc.key;
2126
2126
  if (Array.isArray(keys) && keys.length > DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key.maxItems) {
2127
- return fail2("hcm import v1 \u4E0D\u652F\u6301\u590D\u5408\u4E1A\u52A1\u952E\uFF1B\u8BF7\u58F0\u660E\u5355\u4E00\u771F\u5B9E\u552F\u4E00\u7684 key_field\uFF0C\u6216\u5728\u5B8C\u6574 DataPackage manifest \u4E2D\u58F0\u660E models[].keys \u5E76\u8D70 hcm datapackage install");
2127
+ return fail2("hcm import v1 \u4E0D\u652F\u6301\u590D\u5408\u4E1A\u52A1\u952E\uFF1B\u8BF7\u58F0\u660E\u5355\u4E00\u771F\u5B9E\u552F\u4E00\u7684 key_field\uFF0C\u6216\u5728\u5B8C\u6574\u5B89\u88C5\u5305 manifest \u4E2D\u58F0\u660E models[].keys \u5E76\u8D70 hcm package install");
2128
2128
  }
2129
2129
  if (!Array.isArray(keys) || keys.length !== DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key.minItems || !nonEmptyString(keys[0])) {
2130
2130
  return fail2('"key" \u5FC5\u987B\u662F\u5355\u5143\u7D20\u6570\u7EC4\uFF0C\u5143\u7D20\u987B\u4E3A\u975E\u7A7A\u5B57\u7B26\u4E32\uFF1B\u8BF7\u4F7F\u7528 key_field: code');
@@ -2283,7 +2283,7 @@ function unresolvedError(unresolved, dryRun) {
2283
2283
  if (dryRun) {
2284
2284
  return `${head}\uFF1Bdry-run \u4E0D\u56DE\u67E5\u76EE\u6807\u73AF\u5883\uFF0C\u771F\u8DD1\u65F6\u53EF\u80FD\u89E3\u6790\u5F97\u5230`;
2285
2285
  }
2286
- return `${head}\uFF1B\u5DF2\u6309\u4E1A\u52A1\u952E\u56DE\u67E5\u76EE\u6807\u73AF\u5883\u4ECD\u672A\u547D\u4E2D\u3002\u4E0B\u4E00\u6B65\uFF1A\u786E\u8BA4\u88AB\u5F15\u7528\u7684\u884C\u662F\u5426\u771F\u5728\u76EE\u6807\u73AF\u5883\uFF08\u5148\u5BFC\u5165\u88AB\u5F15\u7528\u7684\u76EE\u5F55\uFF09\uFF0C\u6216\u6574\u5305\u8D70 hcm datapackage install\uFF08\u670D\u52A1\u7AEF FixtureRefResolver \u540C\u6837\u4F1A\u56DE\u67E5\u5DF2\u6709\u884C\uFF09`;
2286
+ return `${head}\uFF1B\u5DF2\u6309\u4E1A\u52A1\u952E\u56DE\u67E5\u76EE\u6807\u73AF\u5883\u4ECD\u672A\u547D\u4E2D\u3002\u4E0B\u4E00\u6B65\uFF1A\u786E\u8BA4\u88AB\u5F15\u7528\u7684\u884C\u662F\u5426\u771F\u5728\u76EE\u6807\u73AF\u5883\uFF08\u5148\u5BFC\u5165\u88AB\u5F15\u7528\u7684\u76EE\u5F55\uFF09\uFF0C\u6216\u6574\u5305\u8D70 hcm package install\uFF08\u670D\u52A1\u7AEF FixtureRefResolver \u540C\u6837\u4F1A\u56DE\u67E5\u5DF2\u6709\u884C\uFF09`;
2287
2287
  }
2288
2288
 
2289
2289
  // src/client.ts
@@ -2892,10 +2892,10 @@ function validateCliAuthorizationUrl(raw, label) {
2892
2892
  }
2893
2893
  return url;
2894
2894
  }
2895
- async function post(input, path24, body, timeout = 3e4) {
2895
+ async function post(input, path25, body, timeout = 3e4) {
2896
2896
  checkCancelled(input.signal);
2897
2897
  try {
2898
- const { data } = await input.httpClient.post(`${input.endpoint.replace(/\/+$/, "")}${path24}`, body, {
2898
+ const { data } = await input.httpClient.post(`${input.endpoint.replace(/\/+$/, "")}${path25}`, body, {
2899
2899
  timeout,
2900
2900
  maxRedirects: 0,
2901
2901
  signal: input.signal,
@@ -3031,10 +3031,9 @@ function watchBrowserAuthorization(input) {
3031
3031
  let lastStatus;
3032
3032
  void (async () => {
3033
3033
  while (!stopped) {
3034
- const remaining = input.deadline - Date.now();
3035
- if (remaining <= 0) return;
3034
+ if (input.deadline - Date.now() <= interval) return;
3036
3035
  try {
3037
- await delay(Math.min(interval, remaining), void 0, { signal: input.signal });
3036
+ await delay(interval, void 0, { signal: input.signal });
3038
3037
  } catch {
3039
3038
  return;
3040
3039
  }
@@ -4384,12 +4383,12 @@ function buildResumeSummary(conversationId, items, maxRounds = 2, maxWidth = 76)
4384
4383
  }
4385
4384
  var isDeliveredAssistant = (it) => it.kind === "chat-text" && !isSupersededItem(it) && Number.isInteger(it.seq);
4386
4385
  function findLastAssistantTarget(items) {
4387
- const list = [...items ?? []].reverse();
4388
- if (list.length === 0) return { seq: null, reason: "empty" };
4386
+ const list2 = [...items ?? []].reverse();
4387
+ if (list2.length === 0) return { seq: null, reason: "empty" };
4389
4388
  let crossedTurn = false;
4390
4389
  let sawSuperseded = false;
4391
4390
  let earlierSeq;
4392
- for (const it of list) {
4391
+ for (const it of list2) {
4393
4392
  if (it.kind === "user-msg") {
4394
4393
  if (crossedTurn) break;
4395
4394
  crossedTurn = true;
@@ -4712,7 +4711,21 @@ function toWorkspacePreflightResult(value) {
4712
4711
  field: stringOrUndefined(issue.field),
4713
4712
  data: issue.data
4714
4713
  };
4715
- })
4714
+ }),
4715
+ warnings: Array.isArray(obj.warnings) ? obj.warnings.map(toWorkspacePreflightWarning) : void 0
4716
+ };
4717
+ }
4718
+ function toWorkspacePreflightWarning(raw) {
4719
+ const warning = asRecord(raw);
4720
+ const nextStep = stringOrUndefined(warning.next_step) ?? stringOrUndefined(warning.nextStep);
4721
+ return {
4722
+ warnCode: stringOrUndefined(warning.warnCode),
4723
+ path: warning.path == null ? null : stringOr(warning.path),
4724
+ message: stringOr(warning.message),
4725
+ ...nextStep ? { nextStep } : {},
4726
+ ...typeof warning.model === "string" ? { model: warning.model } : {},
4727
+ ...typeof warning.versionModel === "string" ? { versionModel: warning.versionModel } : {},
4728
+ ...Array.isArray(warning.fields) ? { fields: warning.fields.map((f) => stringOr(f)) } : {}
4716
4729
  };
4717
4730
  }
4718
4731
  function asRecord(value) {
@@ -7090,9 +7103,9 @@ function computeStatusEntries(context, manifest2, localFiles) {
7090
7103
  }
7091
7104
  async function loadRemoteMiniAppFiles(http, workspaceKey, appCode) {
7092
7105
  const prefix = miniRemotePrefix(appCode) + "/";
7093
- const list = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
7106
+ const list2 = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
7094
7107
  const result = [];
7095
- for (const item of list.data) {
7108
+ for (const item of list2.data) {
7096
7109
  if (!item.relativePath.startsWith(prefix) || isDirectoryMarkerPath(item.relativePath)) continue;
7097
7110
  const content = await loadWorkspaceFileContent(http, item.id);
7098
7111
  result.push({ item, content });
@@ -7401,44 +7414,367 @@ function nonnegativeInteger(value) {
7401
7414
  // src/datapackage/pack.ts
7402
7415
  import * as fsp2 from "fs/promises";
7403
7416
  import * as fs11 from "fs";
7404
- import * as path7 from "path";
7405
- import yaml8, { JSON_SCHEMA as JSON_SCHEMA2 } from "js-yaml";
7417
+ import * as path8 from "path";
7406
7418
  import * as yazl from "yazl";
7407
- function fail(message) {
7408
- throw new CliError({ code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */, message: `datapackage pack: ${message}` });
7419
+
7420
+ // src/datapackage/manifest.ts
7421
+ import * as path7 from "path";
7422
+ import { stringify } from "yaml";
7423
+
7424
+ // src/datapackage/validation.ts
7425
+ import { parseDocument, LineCounter } from "yaml";
7426
+ var PackageErrorCode = {
7427
+ VALIDATION_ERROR: "VALIDATION_ERROR",
7428
+ FILE_MISSING: "DATA_PACKAGE_FILE_MISSING",
7429
+ PATH_TRAVERSAL: "DATA_PACKAGE_PATH_TRAVERSAL",
7430
+ SECTIONS_CONFLICT: "PACKAGE_EXTENSION_SECTIONS_CONFLICT",
7431
+ MANIFEST_INVALID: "PACKAGE_EXTENSION_MANIFEST_INVALID",
7432
+ FILE_TYPE_UNSUPPORTED: "PACKAGE_EXTENSION_FILE_TYPE_UNSUPPORTED",
7433
+ SIZE_EXCEEDED: "PACKAGE_EXTENSION_SIZE_EXCEEDED",
7434
+ BARE_UUID: "PACKAGE_BARE_UUID",
7435
+ OPAQUE_FIELD_IS_REFERENCE: "PACKAGE_OPAQUE_FIELD_IS_REFERENCE",
7436
+ MODEL_MISMATCH: "PACKAGE_MODEL_MISMATCH",
7437
+ DEFINITION_ID_PRESENT: "PACKAGE_EXTENSION_DEFINITION_ID_PRESENT",
7438
+ REFERENCE_SCAN_FAILED: "PACKAGE_REFERENCE_SCAN_FAILED"
7439
+ };
7440
+ function fail(message, code) {
7441
+ throw new CliError({
7442
+ code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */,
7443
+ message: `\u5B89\u88C5\u5305 pack: ${code ? `${code}: ` : ""}${message}`,
7444
+ context: code ? { packageErrorCode: code } : void 0
7445
+ });
7409
7446
  }
7410
- function parseManifest(text3, manifestPath) {
7411
- let parsed;
7447
+ function parseYaml(text3, file, onWarning, code) {
7448
+ const lines = new LineCounter();
7449
+ const doc = parseDocument(text3, { lineCounter: lines, merge: true, keepSourceTokens: true });
7450
+ doc.errors = doc.errors.filter((error) => {
7451
+ if (error.code !== "DUPLICATE_KEY") return true;
7452
+ onWarning?.(`${file}:${error.linePos?.[0]?.line ?? 1} YAML_DUPLICATE_KEY: ${error.message.split("\n")[0]}\uFF08\u91C7\u7528\u6700\u540E\u4E00\u4E2A\u503C\uFF09`);
7453
+ return false;
7454
+ });
7455
+ const errors = [...doc.errors, ...doc.warnings];
7456
+ if (errors.length) fail(`${file}: ${errors.map((e) => e.message).join("\n")}`, code);
7457
+ return { doc, lines };
7458
+ }
7459
+ function mapping(value, label, code) {
7460
+ if (!value || typeof value !== "object" || Array.isArray(value)) fail(`${label} \u5FC5\u987B\u662F mapping`, code);
7461
+ return value;
7462
+ }
7463
+ function list(value, label, code) {
7464
+ if (value === void 0) return [];
7465
+ if (!Array.isArray(value)) fail(`${label} \u5FC5\u987B\u662F list`, code);
7466
+ return value;
7467
+ }
7468
+ function safePath(value, code = PackageErrorCode.MANIFEST_INVALID) {
7469
+ if (typeof value === "string") value = value.trim();
7470
+ if (typeof value !== "string" || !value || value.includes("\\") || value.includes("\0") || value.startsWith("/") || /^[A-Za-z]:/.test(value) || value.replace(/\/$/, "").split("/").some((p) => !p || p === "." || p === "..")) {
7471
+ fail(`\u4E0D\u5B89\u5168\u7684\u76F8\u5BF9\u8DEF\u5F84: ${String(value)}`, code);
7472
+ }
7473
+ return value;
7474
+ }
7475
+ function assetPath(value, directory = false) {
7476
+ const p = safePath(value);
7477
+ const parts = p.replace(/\/$/, "").split("/");
7478
+ const kind = parts[0] ?? "";
7479
+ const suffixes = {
7480
+ metas: [".yml", ".yaml", ".properties"],
7481
+ scripts: [".js"],
7482
+ menus: [".yml", ".yaml"],
7483
+ mini_apps: [".js", ".json", ".html", ".css"]
7484
+ };
7485
+ const allowed = suffixes[kind];
7486
+ if (!allowed || !directory && ((kind === "scripts" || kind === "menus") && parts.length !== 2) || !directory && kind === "scripts" && p.endsWith(".js") && !parts[1]?.slice(0, -3).trim() || kind === "mini_apps" && parts.length < (directory ? 2 : 3) || directory && (kind === "scripts" || kind === "menus") && parts.length !== 1) {
7487
+ fail(`\u4E0D\u5728\u6269\u5C55\u8D44\u4EA7\u8FD0\u884C\u65F6\u6587\u672C\u767D\u540D\u5355: ${p}\uFF08\u5141\u8BB8 metas/\u3001scripts/\u3001menus/\u3001mini_apps/ \u4E0B\u7684\u8FD0\u884C\u65F6\u6587\u672C\uFF1Bapps/ \u4E0D\u8FDB\u5B89\u88C5\u5305\uFF09`, PackageErrorCode.FILE_TYPE_UNSUPPORTED);
7488
+ }
7489
+ if (!directory && !allowed.some((ext) => p.endsWith(ext))) {
7490
+ fail(`${p}\uFF1B\u56FE\u7247/\u5B57\u4F53\u8BF7\u5185\u8054\u4E3A data URI \u6216\u8D70\u770B\u677F/\u6587\u6863\u80FD\u529B`, PackageErrorCode.FILE_TYPE_UNSUPPORTED);
7491
+ }
7492
+ return p;
7493
+ }
7494
+ function utf8(bytes2, file) {
7495
+ const text3 = decodeUtf8(bytes2);
7496
+ if (text3 === void 0 || text3.includes("\0")) {
7497
+ return fail(
7498
+ `${file} \u4E0D\u662F UTF-8 \u6587\u672C\u6216\u542B NUL\uFF1B\u56FE\u7247/\u5B57\u4F53\u8BF7\u5185\u8054\u4E3A data URI \u6216\u8D70\u770B\u677F/\u6587\u6863\u80FD\u529B`,
7499
+ PackageErrorCode.FILE_TYPE_UNSUPPORTED
7500
+ );
7501
+ }
7502
+ return text3;
7503
+ }
7504
+ function decodeUtf8(bytes2) {
7412
7505
  try {
7413
- parsed = yaml8.load(text3, { schema: JSON_SCHEMA2 });
7414
- } catch (e) {
7415
- return fail(`package.yml \u89E3\u6790\u5931\u8D25: ${e.message} (${manifestPath})`);
7506
+ return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes2);
7507
+ } catch {
7508
+ return void 0;
7416
7509
  }
7417
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
7418
- return fail(`package.yml \u4E3A\u7A7A\u6216\u4E0D\u662F mapping (${manifestPath})`);
7510
+ }
7511
+
7512
+ // src/datapackage/manifest.ts
7513
+ function parseManifest(text3, onWarning) {
7514
+ const { VALIDATION_ERROR, MANIFEST_INVALID } = PackageErrorCode;
7515
+ const doc = mapping(parseYaml(text3, "package.yml", onWarning, VALIDATION_ERROR).doc.toJS(), "package.yml", VALIDATION_ERROR);
7516
+ let trimmed = false;
7517
+ const trimPaths = (entry) => {
7518
+ for (const key of ["file", "dir", "path"]) {
7519
+ const value = entry[key];
7520
+ if (typeof value === "string" && value !== value.trim()) {
7521
+ entry[key] = value.trim();
7522
+ trimmed = true;
7523
+ }
7524
+ }
7525
+ };
7526
+ const dropFields = (entry) => {
7527
+ if (entry.drop_fields !== void 0 && (!Array.isArray(entry.drop_fields) || entry.drop_fields.some((f) => typeof f !== "string" || !f.trim()))) fail("drop_fields \u5FC5\u987B\u662F\u5B57\u6BB5\u540D list", MANIFEST_INVALID);
7528
+ };
7529
+ if (typeof doc.name !== "string" || !doc.name.trim()) fail("package.yml \u7F3A name", VALIDATION_ERROR);
7530
+ if (typeof doc.version !== "string" || !doc.version.trim()) fail("package.yml \u7F3A version", VALIDATION_ERROR);
7531
+ if ((doc.metas !== void 0 || doc.metas_delete !== void 0) && (doc.extensions !== void 0 || doc.extensions_delete !== void 0)) {
7532
+ fail("metas/metas_delete \u4E0E extensions/extensions_delete \u4E0D\u80FD\u540C\u65F6\u51FA\u73B0", PackageErrorCode.SECTIONS_CONFLICT);
7533
+ }
7534
+ const models = /* @__PURE__ */ new Map();
7535
+ for (const [i, value] of list(doc.models, "models", VALIDATION_ERROR).entries()) {
7536
+ const m = mapping(value, `models[${i}]`, VALIDATION_ERROR);
7537
+ trimPaths(m);
7538
+ if (typeof m.name !== "string" || !m.name.trim()) fail(`models[${i}] \u7F3A name`, VALIDATION_ERROR);
7539
+ if (typeof m.file !== "string" || !m.file.trim()) fail(`models[${i}] \u7F3A file`, VALIDATION_ERROR);
7540
+ if (!Array.isArray(m.keys) || !m.keys.length) fail(`models[${i}] \u7F3A keys`, VALIDATION_ERROR);
7541
+ models.set(safePath(m.file, PackageErrorCode.PATH_TRAVERSAL), m.name);
7542
+ }
7543
+ const legacy = doc.metas !== void 0 || doc.metas_delete !== void 0;
7544
+ const extensions = list(doc.extensions ?? doc.metas, legacy ? "metas" : "extensions", MANIFEST_INVALID).map((value, i) => {
7545
+ const e = mapping(value, `extensions[${i}]`, MANIFEST_INVALID);
7546
+ trimPaths(e);
7547
+ if (e.file === void 0 === (e.dir === void 0)) fail(`extensions[${i}] \u5FC5\u987B\u4E14\u53EA\u80FD\u6709 file \u6216 dir`, MANIFEST_INVALID);
7548
+ if (e.adopt !== void 0 && typeof e.adopt !== "boolean") fail(`extensions[${i}].adopt \u5FC5\u987B\u662F boolean`, VALIDATION_ERROR);
7549
+ const source = safePath(e.file ?? e.dir).replace(/\/$/, "");
7550
+ const directory = e.dir !== void 0;
7551
+ const stripped = source.startsWith("extensions/") ? source.slice(11) : void 0;
7552
+ const declared = typeof e.path === "string" && e.path.trim() ? e.path : void 0;
7553
+ const target = assetPath(declared ?? (!legacy && e.path == null ? stripped ?? source : stripped ?? `metas/${path7.posix.basename(source)}`), directory).replace(/\/$/, "");
7554
+ dropFields(e);
7555
+ return { source, target, directory };
7556
+ });
7557
+ const targets = /* @__PURE__ */ new Set();
7558
+ for (const entry of extensions) {
7559
+ if (targets.has(entry.target)) fail(`\u6269\u5C55\u76EE\u6807\u8DEF\u5F84\u91CD\u590D: ${entry.target}`, MANIFEST_INVALID);
7560
+ targets.add(entry.target);
7561
+ if (extensions.some((other) => other !== entry && other.directory && entry.target.startsWith(other.target + "/"))) {
7562
+ fail(`\u6269\u5C55\u76EE\u5F55\u4E0E\u6761\u76EE\u91CD\u53E0: ${entry.target}`, MANIFEST_INVALID);
7563
+ }
7564
+ }
7565
+ const deletes = list(doc.extensions_delete ?? doc.metas_delete, "extensions_delete", MANIFEST_INVALID).map((value, i) => {
7566
+ if (typeof value === "string") {
7567
+ const values = doc.extensions_delete ?? doc.metas_delete;
7568
+ values[i] = value = { path: value };
7569
+ }
7570
+ const e = mapping(value, `extensions_delete[${i}]`, MANIFEST_INVALID);
7571
+ trimPaths(e);
7572
+ if (typeof e.path !== "string" || !e.path) fail(`extensions_delete[${i}].path \u5FC5\u586B`, MANIFEST_INVALID);
7573
+ const p = assetPath(e.path, typeof e.path === "string" && e.path.endsWith("/"));
7574
+ const plain = p.replace(/\/$/, "");
7575
+ if (extensions.some((e2) => plain === e2.target || p.endsWith("/") && e2.target.startsWith(p) || e2.directory && plain.startsWith(e2.target + "/"))) fail(`\u540C\u4E00\u6587\u4EF6\u4E0D\u80FD\u65E2\u5199\u53C8\u5220\uFF0C\u76EE\u6807\u91CD\u53E0: ${p}`, MANIFEST_INVALID);
7576
+ dropFields(e);
7577
+ return p;
7578
+ });
7579
+ if (!models.size && !extensions.length && !deletes.length) fail("models \u4E0E extensions\uFF08\u542B\u5220\u9664\u6761\u76EE\uFF09\u4E0D\u80FD\u540C\u65F6\u4E3A\u7A7A", VALIDATION_ERROR);
7580
+ const opaqueFields = /* @__PURE__ */ new Set();
7581
+ const { OPAQUE_FIELD_IS_REFERENCE } = PackageErrorCode;
7582
+ for (const field of list(doc.opaque_uuid_fields, "opaque_uuid_fields", OPAQUE_FIELD_IS_REFERENCE)) {
7583
+ if (typeof field !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*$/.test(field)) {
7584
+ fail(`opaque_uuid_fields \u5FC5\u987B\u4F7F\u7528 \u6A21\u578B.\u5B57\u6BB5\uFF08\u5B57\u6BCD\u6570\u5B57\u4E0B\u5212\u7EBF\uFF09: ${String(field)}`, OPAQUE_FIELD_IS_REFERENCE);
7585
+ }
7586
+ if (/(?:_id|Id)$/.test(field)) fail(`${field} \u662F\u5F15\u7528\u7C7B\u5B57\u6BB5\uFF0C\u4E0D\u80FD\u58F0\u660E\u4E3A opaque_uuid_fields`, OPAQUE_FIELD_IS_REFERENCE);
7587
+ opaqueFields.add(field);
7419
7588
  }
7420
- const doc = parsed;
7421
- if (typeof doc.name !== "string" || !doc.name.trim()) return fail("package.yml \u7F3A name");
7422
- if (typeof doc.version !== "string" || !doc.version.trim()) return fail("package.yml \u7F3A version");
7423
- if (!Array.isArray(doc.models) || doc.models.length === 0) return fail("package.yml \u7F3A models \u5217\u8868");
7424
- const referenced = [];
7425
- for (const [i, m] of doc.models.entries()) {
7426
- const entry = m;
7427
- if (typeof entry.name !== "string" || !entry.name) return fail(`models[${i}] \u7F3A name`);
7428
- if (typeof entry.file !== "string" || !entry.file) return fail(`models[${i}] \u7F3A file`);
7429
- if (!Array.isArray(entry.keys) || entry.keys.length === 0) return fail(`models[${i}] \u7F3A keys`);
7430
- referenced.push(entry.file);
7431
- }
7432
- if (doc.metas !== void 0) {
7433
- if (!Array.isArray(doc.metas)) return fail("metas \u5FC5\u987B\u662F list");
7434
- for (const [i, m] of doc.metas.entries()) {
7435
- const entry = m;
7436
- if (typeof entry.file !== "string" || !entry.file) return fail(`metas[${i}] \u7F3A file`);
7437
- referenced.push(entry.file);
7438
- }
7439
- }
7440
- return { name: doc.name.trim(), version: doc.version.trim(), referenced };
7589
+ return {
7590
+ name: doc.name.trim(),
7591
+ version: doc.version.trim(),
7592
+ models,
7593
+ extensions,
7594
+ deletes,
7595
+ opaqueFields,
7596
+ artifactText: trimmed ? stringify(doc) : text3
7597
+ };
7598
+ }
7599
+
7600
+ // src/datapackage/uuid.ts
7601
+ import { isAlias, isMap, isNode, isScalar, isSeq, Parser } from "yaml";
7602
+ var UUID2 = /[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}/gi;
7603
+ var isUuid = (value) => typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
7604
+ function validateUuids(files, opaqueFields, onWarning) {
7605
+ const parsed = files.map((file) => ({
7606
+ ...file,
7607
+ yaml: !file.extension && (file.model || /\.ya?ml$|\.json$/.test(file.file)) ? parseYaml(file.text, file.file, onWarning) : void 0
7608
+ }));
7609
+ const ownIds = /* @__PURE__ */ new Set();
7610
+ for (const file of parsed) {
7611
+ if (file.model === void 0 && !/^data\/.*\.ya?ml$/.test(file.file)) continue;
7612
+ const data = file.yaml?.doc.toJS();
7613
+ if (data && Array.isArray(data.items)) {
7614
+ for (const row of data.items) if (isUuid(row?.id)) ownIds.add(row.id.toLowerCase());
7615
+ }
7616
+ }
7617
+ for (const file of parsed) {
7618
+ if (file.model === void 0 || !file.yaml) continue;
7619
+ const node = file.yaml.doc.get("model", true);
7620
+ const authored = isScalar(node) ? String(node.source ?? node.value ?? "") : "";
7621
+ if (authored && authored !== file.model) {
7622
+ fail(
7623
+ `${file.file}:1 ${file.model}\uFF1B\u6587\u4EF6 model=${authored} \u4E0E\u6E05\u5355\u76EE\u6807\u6A21\u578B\u4E0D\u4E00\u81F4\uFF1B\u5C06\u6587\u4EF6 model \u4E0E manifest models[].name \u5BF9\u9F50\u540E\u91CD\u65B0\u6253\u5305`,
7624
+ PackageErrorCode.MODEL_MISMATCH
7625
+ );
7626
+ }
7627
+ }
7628
+ const violations = [];
7629
+ for (const file of parsed) {
7630
+ const comments = commentRanges(file);
7631
+ const modelNode = file.yaml?.doc.get("model");
7632
+ const model = file.model ?? (typeof modelNode === "string" ? modelNode : "?");
7633
+ const spans = [];
7634
+ const decoded = [];
7635
+ const collect = (node, field, visited = /* @__PURE__ */ new Set(), aliasOffset) => {
7636
+ if (!isNode(node) || visited.has(node)) return;
7637
+ const next = new Set(visited).add(node);
7638
+ const offset = aliasOffset ?? node.range?.[0] ?? 0;
7639
+ if (isScalar(node)) {
7640
+ if (typeof node.value === "string") decoded.push({ value: node.value, offset, field });
7641
+ } else if (isAlias(node) && file.yaml) {
7642
+ collect(node.resolve(file.yaml.doc), field, next, offset);
7643
+ } else if (isMap(node)) {
7644
+ node.items.forEach((pair) => {
7645
+ collect(pair.key, field, next, aliasOffset);
7646
+ collect(pair.value, field, next, aliasOffset);
7647
+ });
7648
+ } else if (isSeq(node)) node.items.forEach((child) => collect(child, field, next, aliasOffset));
7649
+ };
7650
+ const items = file.yaml?.doc.get("items", true);
7651
+ if (isSeq(items)) {
7652
+ for (const item of items.items) {
7653
+ if (!isMap(item)) {
7654
+ collect(item, `${model}.?`);
7655
+ continue;
7656
+ }
7657
+ for (const pair of item.items) {
7658
+ const field = `${model}.${isScalar(pair.key) ? String(pair.key.value) : "?"}`;
7659
+ if (isNode(pair.key) && pair.key.range && isNode(pair.value) && pair.value.range) {
7660
+ spans.push({ start: pair.key.range[0], end: pair.value.range[1], field });
7661
+ }
7662
+ collect(pair.value, field);
7663
+ }
7664
+ }
7665
+ }
7666
+ const seen = /* @__PURE__ */ new Set();
7667
+ const report = (uuid, offset, field) => {
7668
+ if (!file.extension && (ownIds.has(uuid.toLowerCase()) || opaqueFields.has(field))) return;
7669
+ const line = file.text.slice(0, offset).split("\n").length;
7670
+ const key = `${offset}:${field}:${uuid}`;
7671
+ if (seen.has(key)) return;
7672
+ seen.add(key);
7673
+ const advice = file.extension ? "\u6269\u5C55\u8D44\u4EA7\u4E0D\u66FF\u6362\u5F15\u7528\uFF0C\u8BF7\u6539\u4E3A\u6309\u7F16\u7801\u53D6\u6570" : "\u8BF7\u6539\u4E3A ${Model:key} \u6216 ${ref:Model:key}";
7674
+ const comment = comments.some(([start, end]) => offset >= start && offset < end) ? "\uFF08\u6CE8\u91CA\uFF09" : "";
7675
+ violations.push(`${file.file}:${line} ${field}${comment}: ${uuid}\uFF1B${advice}`);
7676
+ };
7677
+ for (const match of file.text.matchAll(UUID2)) {
7678
+ const field = file.extension ? "\u6269\u5C55\u8D44\u4EA7.\u6587\u672C" : spans.find((s) => match.index >= s.start && match.index < s.end)?.field ?? `${model}.?`;
7679
+ report(match[0], match.index, field);
7680
+ }
7681
+ for (const value of decoded) {
7682
+ for (const match of value.value.matchAll(UUID2)) {
7683
+ const span = spans.find((s) => value.offset >= s.start && value.offset < s.end);
7684
+ if (span && [...file.text.slice(value.offset, span.end).matchAll(UUID2)].some((raw) => raw[0] === match[0])) continue;
7685
+ report(match[0], value.offset, value.field);
7686
+ }
7687
+ }
7688
+ }
7689
+ if (violations.length) fail(`${violations.length} \u5904\u88F8 UUID \u8FDD\u89C4
7690
+ ${violations.join("\n")}`, PackageErrorCode.BARE_UUID);
7691
+ }
7692
+ function commentRanges(file) {
7693
+ const ranges = [];
7694
+ if (file.model || /\.ya?ml$/.test(file.file)) {
7695
+ const visit = (value) => {
7696
+ if (!value || typeof value !== "object") return;
7697
+ const token = value;
7698
+ if (token.type === "comment" && token.offset !== void 0 && token.source) ranges.push([token.offset, token.offset + token.source.length]);
7699
+ else Object.values(value).forEach(visit);
7700
+ };
7701
+ for (const token of new Parser().parse(file.text)) visit(token);
7702
+ } else {
7703
+ const pattern = /\.properties$/.test(file.file) ? /^[ \t]*[#!].*$/gm : /\.html$/.test(file.file) ? /<!--[\s\S]*?-->/g : /\.(js|css)$/.test(file.file) ? /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|(\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/g : void 0;
7704
+ if (pattern) for (const match of file.text.matchAll(pattern)) {
7705
+ if (!/\.(js|css)$/.test(file.file) || match[1]) ranges.push([match.index, match.index + match[0].length]);
7706
+ }
7707
+ }
7708
+ return ranges;
7709
+ }
7710
+ function definitionIdLine(text3, file, onWarning) {
7711
+ const { doc, lines } = parseYaml(text3, file, onWarning);
7712
+ const fields = doc.get("fields", true);
7713
+ if (!isSeq(fields)) return void 0;
7714
+ for (const field of fields.items) {
7715
+ if (!isMap(field)) continue;
7716
+ const pair = field.items.find((p) => isScalar(p.key) && p.key.value === "definitionId");
7717
+ if (pair) return lines.linePos(isNode(pair.key) ? pair.key.range?.[0] ?? 0 : 0).line;
7718
+ }
7719
+ return void 0;
7720
+ }
7721
+ function stripDefinitionIds(text3, file, onWarning) {
7722
+ const { doc } = parseYaml(text3, file, onWarning);
7723
+ const fields = doc.get("fields", true);
7724
+ let count = 0;
7725
+ const ranges = [];
7726
+ if (isSeq(fields)) {
7727
+ for (const field of fields.items) {
7728
+ if (!isMap(field)) continue;
7729
+ const removable = field.items.map((pair) => isScalar(pair.key) && pair.key.value === "definitionId");
7730
+ for (let i = 0; i < field.items.length; i++) {
7731
+ if (!removable[i]) continue;
7732
+ const first = field.items[i];
7733
+ let last = first;
7734
+ const keyStart = isNode(first.key) ? first.key.range?.[0] : void 0;
7735
+ if (keyStart === void 0) continue;
7736
+ count++;
7737
+ if (field.flow) {
7738
+ while (removable[i + 1]) {
7739
+ last = field.items[++i];
7740
+ count++;
7741
+ }
7742
+ const next = field.items[i + 1];
7743
+ const comma = first.srcToken?.start.find((token) => token.type === "comma");
7744
+ const valueEnd = isNode(last.value) ? last.value.range?.[1] : void 0;
7745
+ const end = valueEnd ?? last.srcToken?.sep?.reduce((end2, token) => token.offset + token.source.length, keyStart) ?? keyStart;
7746
+ if (comma) ranges.push([comma.offset, end]);
7747
+ else {
7748
+ ranges.push([keyStart, end]);
7749
+ const separator = next?.srcToken?.start ?? (field.srcToken?.type === "flow-collection" ? field.srcToken.items.at(-1)?.start : void 0);
7750
+ const commaIndex = separator?.findIndex((token) => token.type === "comma" && token.offset >= end) ?? -1;
7751
+ if (separator && commaIndex >= 0) {
7752
+ const comma2 = separator[commaIndex];
7753
+ let end2 = comma2.offset + comma2.source.length;
7754
+ for (let i2 = commaIndex + 1; separator[i2]?.type === "space"; i2++) end2 += separator[i2].source.length;
7755
+ ranges.push([comma2.offset, end2]);
7756
+ }
7757
+ }
7758
+ } else {
7759
+ const lineStart = text3.lastIndexOf("\n", keyStart - 1) + 1;
7760
+ const valueEnd = isNode(last.value) ? last.value.range?.[2] : void 0;
7761
+ const newline = text3.indexOf("\n", valueEnd ?? keyStart);
7762
+ const end = valueEnd && text3[valueEnd - 1] === "\n" ? valueEnd : newline < 0 ? text3.length : newline + 1;
7763
+ const dash = text3.slice(lineStart, keyStart).indexOf("-");
7764
+ ranges.push(dash < 0 ? [lineStart, end] : [lineStart + dash + 1, end - (text3[end - 2] === "\r" ? 2 : text3[end - 1] === "\n" ? 1 : 0)]);
7765
+ }
7766
+ }
7767
+ }
7768
+ }
7769
+ let stripped = text3, scanText = text3;
7770
+ for (const [start, end] of ranges.sort((a, b) => b[0] - a[0])) {
7771
+ stripped = stripped.slice(0, start) + stripped.slice(end);
7772
+ scanText = scanText.slice(0, start) + scanText.slice(start, end).replace(/[^\n\r]/g, " ") + scanText.slice(end);
7773
+ }
7774
+ return { text: stripped, scanText, count };
7441
7775
  }
7776
+
7777
+ // src/datapackage/pack.ts
7442
7778
  async function collectFiles(root, skipAbs) {
7443
7779
  const out = [];
7444
7780
  async function walk4(dir, rel) {
@@ -7446,44 +7782,130 @@ async function collectFiles(root, skipAbs) {
7446
7782
  entries.sort((a, b) => a.name.localeCompare(b.name));
7447
7783
  for (const e of entries) {
7448
7784
  if (e.name.startsWith(".")) continue;
7449
- const abs = path7.join(dir, e.name);
7785
+ const abs = path8.join(dir, e.name);
7450
7786
  const relPath = rel ? `${rel}/${e.name}` : e.name;
7451
- if (e.isDirectory()) {
7452
- await walk4(abs, relPath);
7453
- } else if (e.isFile() && !skipAbs.has(path7.resolve(abs))) {
7454
- out.push(relPath);
7455
- }
7787
+ if (e.isSymbolicLink()) fail(`\u5B89\u88C5\u5305\u4E0D\u6536\u5F55\u7B26\u53F7\u94FE\u63A5: ${relPath}`, PackageErrorCode.PATH_TRAVERSAL);
7788
+ if (e.isDirectory()) await walk4(abs, relPath);
7789
+ else if (e.isFile() && !skipAbs.has(path8.resolve(abs))) out.push(relPath);
7456
7790
  }
7457
7791
  }
7458
7792
  await walk4(root, "");
7459
7793
  return out;
7460
7794
  }
7461
7795
  async function packDataPackage(packageDir, outPath, opts = {}) {
7462
- const root = path7.resolve(packageDir);
7463
- const manifestPath = path7.join(root, "package.yml");
7796
+ const root = path8.resolve(packageDir);
7464
7797
  let manifestText;
7465
7798
  try {
7466
- manifestText = await fsp2.readFile(manifestPath, "utf8");
7799
+ manifestText = await fsp2.readFile(path8.join(root, "package.yml"), "utf8");
7467
7800
  } catch {
7468
- return fail(`\u76EE\u5F55\u91CC\u6CA1\u6709 package.yml\uFF1A${root}\uFF08\u8981\u4F20\u5305\u7248\u672C\u76EE\u5F55\uFF0C\u5982 fixtures/scenario/<pkg>/v1.0.0\uFF09`);
7469
- }
7470
- const { name, version, referenced } = parseManifest(manifestText, manifestPath);
7471
- for (const relFile of referenced) {
7472
- const abs = path7.resolve(root, relFile);
7473
- if (!abs.startsWith(root + path7.sep)) return fail(`\u5F15\u7528\u8DEF\u5F84\u8D8A\u51FA\u5305\u76EE\u5F55: ${relFile}`);
7474
- if (!fs11.existsSync(abs) || !fs11.statSync(abs).isFile()) {
7475
- return fail(`manifest \u5F15\u7528\u7684\u6587\u4EF6\u4E0D\u5B58\u5728: ${relFile}`);
7476
- }
7801
+ return fail(`\u76EE\u5F55\u91CC\u6CA1\u6709 package.yml\uFF1A${root}\uFF08\u8981\u4F20\u5305\u7248\u672C\u76EE\u5F55\uFF0C\u5982 fixtures/scenario/<pkg>/v1.0.0\uFF09`, PackageErrorCode.FILE_MISSING);
7477
7802
  }
7803
+ const warnings = [];
7804
+ const onWarning = (message) => {
7805
+ warnings.push(message);
7806
+ opts.onWarning?.(message);
7807
+ };
7808
+ const manifest2 = parseManifest(manifestText, onWarning);
7809
+ const { name, version } = manifest2;
7478
7810
  const lastSegment = name.includes("/") ? name.slice(name.lastIndexOf("/") + 1) : name;
7479
- const artifactPath = path7.resolve(outPath ?? `${lastSegment}-${version}.hcmpkg`);
7811
+ const artifactPath = path8.resolve(outPath ?? `${lastSegment}-${version}.hcmpkg`);
7812
+ const outputRel = path8.relative(root, artifactPath).split(path8.sep).join("/");
7813
+ if (outputRel === "package.yml" || /^(data|extensions)\//.test(outputRel) || manifest2.models.has(outputRel) || manifest2.extensions.some((e) => outputRel === e.source || e.directory && outputRel.startsWith(e.source + "/"))) {
7814
+ fail("\u4EA7\u7269\u8DEF\u5F84\u4E0D\u80FD\u8986\u76D6\u5B89\u88C5\u5305\u4F5C\u8005\u6587\u4EF6\u6216\u4F4D\u4E8E\u6570\u636E\u3001\u6269\u5C55\u6765\u6E90\u76EE\u5F55\u5185");
7815
+ }
7480
7816
  const files = await collectFiles(root, /* @__PURE__ */ new Set([artifactPath]));
7481
- if (!files.includes("package.yml")) return fail("\u6536\u96C6\u4E0D\u5230 package.yml\uFF08\u4E0D\u5E94\u53D1\u751F\uFF09");
7482
- await fsp2.mkdir(path7.dirname(artifactPath), { recursive: true });
7817
+ if (!files.includes("package.yml")) fail("\u6536\u96C6\u4E0D\u5230 package.yml\uFF1B\u4EA7\u7269\u8DEF\u5F84\u4E0D\u80FD\u8986\u76D6\u4F5C\u8005\u6587\u4EF6");
7818
+ for (const file of manifest2.models.keys()) {
7819
+ if (!files.includes(file)) fail(`manifest \u5F15\u7528\u7684\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u672A\u6536\u5F55: ${file}`, PackageErrorCode.FILE_MISSING);
7820
+ }
7821
+ const targets = /* @__PURE__ */ new Map();
7822
+ const sources = /* @__PURE__ */ new Map();
7823
+ for (const entry of manifest2.extensions) {
7824
+ const selected = entry.directory ? files.filter((f) => f.startsWith(entry.source + "/")) : [entry.source];
7825
+ if (entry.directory) {
7826
+ const stat2 = await fsp2.stat(path8.join(root, entry.source)).catch(() => void 0);
7827
+ if (!stat2?.isDirectory()) fail(`manifest \u5F15\u7528\u7684\u76EE\u5F55\u4E0D\u5B58\u5728: ${entry.source}`, PackageErrorCode.MANIFEST_INVALID);
7828
+ if (!selected.length) fail(`\u6269\u5C55\u76EE\u5F55\u6CA1\u6709\u6587\u4EF6: ${entry.source}\uFF1B\u786E\u5B9E\u8981\u5220\u8BF7\u7528 extensions_delete`, PackageErrorCode.MANIFEST_INVALID);
7829
+ }
7830
+ for (const file of selected) {
7831
+ if (!files.includes(file)) fail(`manifest \u5F15\u7528\u7684\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u672A\u6536\u5F55: ${file}`, PackageErrorCode.FILE_MISSING);
7832
+ const target = assetPath(entry.directory ? entry.target + file.slice(entry.source.length) : entry.target);
7833
+ if (!/\.(yml|yaml|properties|js|json|html|css)$/.test(file)) fail(file, PackageErrorCode.FILE_TYPE_UNSUPPORTED);
7834
+ if (targets.has(target)) fail(`\u6269\u5C55\u76EE\u6807\u8DEF\u5F84\u91CD\u590D: ${target}`, PackageErrorCode.MANIFEST_INVALID);
7835
+ if (sources.has(file)) fail(`\u6269\u5C55\u6765\u6E90\u91CD\u590D: ${file}`);
7836
+ if (manifest2.models.has(file)) fail(`\u6587\u4EF6\u4E0D\u80FD\u540C\u65F6\u4F5C\u4E3A\u6A21\u578B\u6570\u636E\u548C\u6269\u5C55\u8D44\u4EA7: ${file}`);
7837
+ targets.set(target, file);
7838
+ sources.set(file, target);
7839
+ }
7840
+ }
7841
+ const seenDeletes = /* @__PURE__ */ new Set();
7842
+ for (const deletion of manifest2.deletes) {
7843
+ if (seenDeletes.has(deletion)) fail(`extensions_delete \u8DEF\u5F84\u91CD\u590D: ${deletion}`, PackageErrorCode.MANIFEST_INVALID);
7844
+ seenDeletes.add(deletion);
7845
+ if ([...targets.keys()].some((t) => t === deletion || deletion.endsWith("/") && t.startsWith(deletion))) {
7846
+ fail(`extensions_delete \u4E0E\u5199\u5165\u76EE\u6807\u91CD\u53E0: ${deletion}`, PackageErrorCode.MANIFEST_INVALID);
7847
+ }
7848
+ }
7849
+ const undeclaredExtensionFiles = files.filter((f) => f.startsWith("extensions/") && !sources.has(f) && !manifest2.models.has(f));
7850
+ const skippedBinaryDataFiles = [];
7851
+ const contents = /* @__PURE__ */ new Map([["package.yml", Buffer.from(manifest2.artifactText)]]);
7852
+ const scans = [];
7853
+ let totalBytes = 0, strippedDefinitionIds = 0;
7854
+ for (const [file, target] of sources) {
7855
+ const abs = path8.join(root, file);
7856
+ const size = (await fsp2.stat(abs)).size;
7857
+ totalBytes += size;
7858
+ if (size > 4 * 1024 * 1024) fail(`${file} \u5B9E\u6D4B ${size} \u5B57\u8282\uFF0C\u5355\u6587\u4EF6\u4E0A\u9650 4MB\uFF08fileBytes=${size}, totalBytes=${totalBytes}\uFF09`, PackageErrorCode.SIZE_EXCEEDED);
7859
+ if (totalBytes > 32 * 1024 * 1024) fail(`\u6269\u5C55\u603B\u91CF\u5B9E\u6D4B ${totalBytes} \u5B57\u8282\uFF0C\u4E0A\u9650 32MB\uFF08fileBytes=${size}, totalBytes=${totalBytes}\uFF09`, PackageErrorCode.SIZE_EXCEEDED);
7860
+ const text3 = utf8(await fsp2.readFile(abs), file);
7861
+ const stripped = target.startsWith("metas/") && /\.ya?ml$/.test(target) ? stripDefinitionIds(text3, file, onWarning) : { text: text3, scanText: text3, count: 0 };
7862
+ strippedDefinitionIds += stripped.count;
7863
+ contents.set(file, Buffer.from(stripped.text));
7864
+ scans.push({ file, text: stripped.scanText, extension: true });
7865
+ }
7866
+ for (const file of undeclaredExtensionFiles) {
7867
+ const text3 = decodeUtf8(await fsp2.readFile(path8.join(root, file)));
7868
+ if (text3 === void 0) {
7869
+ fail(
7870
+ `${file} \u4E0D\u662F UTF-8 \u6587\u672C\uFF08\u672A\u5728 manifest \u58F0\u660E\uFF0C\u4F46\u670D\u52A1\u7AEF\u4ECD\u4F1A\u626B\u63CF extensions/ \u4E0B\u5168\u90E8\u6587\u4EF6\uFF09\uFF1B\u4ECE extensions/ \u79FB\u8D70\u6216\u5220\u9664\u540E\u91CD\u65B0\u6253\u5305`,
7871
+ PackageErrorCode.REFERENCE_SCAN_FAILED
7872
+ );
7873
+ }
7874
+ scans.push({ file, text: text3, extension: true });
7875
+ }
7876
+ for (const scan of scans) {
7877
+ if (!scan.extension || !scan.file.startsWith("extensions/") || !scan.file.includes("/metas/") || !/\.ya?ml$/.test(scan.file)) continue;
7878
+ const target = sources.get(scan.file);
7879
+ if (target?.startsWith("metas/") && /\.ya?ml$/.test(target)) continue;
7880
+ const line = definitionIdLine(scan.text, scan.file, onWarning);
7881
+ if (line !== void 0) {
7882
+ fail(
7883
+ `${scan.file}:${line} fields[].definitionId\uFF1B\u6269\u5C55\u5143\u6570\u636E\u643A\u5E26\u6E90\u73AF\u5883\u5B57\u6BB5\u8EAB\u4EFD\uFF1B\u5728 manifest \u58F0\u660E\u4E3A metas/ \u76EE\u6807\u8BA9 pack \u5265\u79BB\uFF0C\u6216\u4ECE\u6E90\u6587\u4EF6\u5220\u9664`,
7884
+ PackageErrorCode.DEFINITION_ID_PRESENT
7885
+ );
7886
+ }
7887
+ }
7888
+ for (const file of files) {
7889
+ if (!sources.has(file) && (file.startsWith("data/") || manifest2.models.has(file))) {
7890
+ const bytes2 = await fsp2.readFile(path8.join(root, file));
7891
+ contents.set(file, bytes2);
7892
+ const text3 = decodeUtf8(bytes2);
7893
+ if (text3 === void 0) {
7894
+ skippedBinaryDataFiles.push(file);
7895
+ continue;
7896
+ }
7897
+ scans.push({ file, text: text3, model: manifest2.models.get(file) });
7898
+ }
7899
+ }
7900
+ validateUuids(scans, manifest2.opaqueFields, onWarning);
7901
+ const uuidScannedFiles = { data: scans.filter((f) => !f.extension).length, extensions: scans.filter((f) => f.extension).length };
7902
+ await fsp2.mkdir(path8.dirname(artifactPath), { recursive: true });
7483
7903
  await new Promise((resolve6, reject2) => {
7484
7904
  const zip = new yazl.ZipFile();
7485
7905
  files.forEach((rel, i) => {
7486
- zip.addFile(path7.join(root, rel), rel);
7906
+ const content = contents.get(rel);
7907
+ if (content) zip.addBuffer(content, rel);
7908
+ else zip.addFile(path8.join(root, rel), rel);
7487
7909
  opts.onFile?.(rel, i + 1, files.length);
7488
7910
  });
7489
7911
  zip.end();
@@ -7493,7 +7915,18 @@ async function packDataPackage(packageDir, outPath, opts = {}) {
7493
7915
  ws.on("error", reject2);
7494
7916
  zip.outputStream.on("error", reject2);
7495
7917
  });
7496
- return { artifactPath, name, version, entryCount: files.length };
7918
+ return {
7919
+ artifactPath,
7920
+ name,
7921
+ version,
7922
+ entryCount: files.length,
7923
+ strippedDefinitionIds,
7924
+ bareUuidCount: 0,
7925
+ uuidScannedFiles,
7926
+ skippedBinaryDataFiles,
7927
+ undeclaredExtensionFiles,
7928
+ warnings
7929
+ };
7497
7930
  }
7498
7931
 
7499
7932
  // src/datapackage/install.ts
@@ -7510,6 +7943,24 @@ function isTerminalRunStatus(status) {
7510
7943
  if (!status) return false;
7511
7944
  return status !== "RUNNING" && status !== "QUEUED" && status !== "MAIN_COMMITTED";
7512
7945
  }
7946
+ function confirmationParams(opts) {
7947
+ return {
7948
+ ...opts.allowDowngrade ? { allowDowngrade: true } : {},
7949
+ ...opts.acceptContentChange ? { acceptContentChange: true } : {}
7950
+ };
7951
+ }
7952
+ var INSTALL_CONFIRMATION_HINTS = [
7953
+ {
7954
+ code: "DATA_PACKAGE_DOWNGRADE_REQUIRES_CONFIRMATION",
7955
+ flag: "--allow-downgrade",
7956
+ nextStep: "\u786E\u8BA4\u964D\u7EA7\u5F71\u54CD\uFF08\u65E7\u7248\u672C\u6570\u636E\u8986\u76D6\u65B0\u7248\u672C\uFF09\u540E\u52A0 --allow-downgrade \u91CD\u8DD1\uFF1B\u5426\u5219\u6539\u88C5\u4E0D\u4F4E\u4E8E\u5DF2\u88C5\u7248\u672C\u7684\u5236\u54C1"
7957
+ },
7958
+ {
7959
+ code: "DATA_PACKAGE_VERSION_DIGEST_CONFLICT",
7960
+ flag: "--accept-content-change",
7961
+ nextStep: "\u9996\u9009\u5347\u7248\u672C\u53F7\u91CD\u65B0 pack \u518D\u88C5\uFF1B\u786E\u8BA4\u540C\u7248\u672C\u8986\u76D6\u5F71\u54CD\u540E\u624D\u52A0 --accept-content-change \u5168\u91CF\u91CD\u88C5"
7962
+ }
7963
+ ];
7513
7964
  async function installDataPackageArtifactAsync(client, artifactPath, opts = {}) {
7514
7965
  const meta = await uploadDocument(
7515
7966
  client.raw(),
@@ -7521,7 +7972,7 @@ async function installDataPackageArtifactAsync(client, artifactPath, opts = {})
7521
7972
  "DataPackage",
7522
7973
  "installFromDocumentAsync",
7523
7974
  {
7524
- params: { documentId: meta.documentId, tenantId: client.tenantId }
7975
+ params: { documentId: meta.documentId, tenantId: client.tenantId, ...confirmationParams(opts) }
7525
7976
  }
7526
7977
  );
7527
7978
  const body = unwrapActionPayload(resp);
@@ -7553,8 +8004,9 @@ async function waitForInstallRun(client, runId, opts) {
7553
8004
  const deadline = now() + opts.timeoutMs;
7554
8005
  let last;
7555
8006
  for (; ; ) {
7556
- last = await fetchInstallRun(client, runId);
7557
- opts.onProgress?.(last);
8007
+ const current = await fetchInstallRun(client, runId);
8008
+ if (current) last = current;
8009
+ opts.onProgress?.(current);
7558
8010
  if (isTerminalRunStatus(last?.status)) {
7559
8011
  return { run: last, timedOut: false };
7560
8012
  }
@@ -7575,7 +8027,7 @@ async function installDataPackageArtifact(client, artifactPath, opts = {}) {
7575
8027
  "DataPackage",
7576
8028
  "installFromDocument",
7577
8029
  {
7578
- params: { documentId: meta.documentId, tenantId: client.tenantId }
8030
+ params: { documentId: meta.documentId, tenantId: client.tenantId, ...confirmationParams(opts) }
7579
8031
  }
7580
8032
  );
7581
8033
  const view = unwrapActionPayload(resp);
@@ -7688,18 +8140,18 @@ async function listTenantMeta(http, opts = {}) {
7688
8140
  const total = typeof body?.total === "number" ? body.total : payload?.total;
7689
8141
  return { items, total, raw: payload };
7690
8142
  }
7691
- async function getTenantMeta(http, path24) {
7692
- const resp = await http.get("/api/tenant-meta/meta", { params: { path: path24 } });
8143
+ async function getTenantMeta(http, path25) {
8144
+ const resp = await http.get("/api/tenant-meta/meta", { params: { path: path25 } });
7693
8145
  const payload = resp.data?.data ?? resp.data;
7694
8146
  if (typeof payload === "string") return payload;
7695
8147
  return String(payload?.content ?? "");
7696
8148
  }
7697
- async function saveTenantMeta(http, path24, content) {
7698
- const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path24 } });
8149
+ async function saveTenantMeta(http, path25, content) {
8150
+ const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path25 } });
7699
8151
  return resp.data?.data ?? resp.data;
7700
8152
  }
7701
- async function deleteTenantMeta(http, path24) {
7702
- const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path24 } });
8153
+ async function deleteTenantMeta(http, path25) {
8154
+ const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path25 } });
7703
8155
  return resp.data?.data ?? resp.data;
7704
8156
  }
7705
8157
 
@@ -7709,6 +8161,7 @@ var COLUMN_SLOTS_PATH = "/api/tenant-extension/column-slots";
7709
8161
  var COLUMN_SLOT_SQL_PATH = "/api/tenant-extension/column-slots/sql";
7710
8162
  var COLUMN_SLOT_SQL_KEYS = [
7711
8163
  "countSlot",
8164
+ "flexToSlotBatched",
7712
8165
  "flexToSlot",
7713
8166
  "verifyFlexToSlot",
7714
8167
  "slotToFlex",
@@ -7725,10 +8178,10 @@ function headers(opts) {
7725
8178
  function isRecord2(value) {
7726
8179
  return typeof value === "object" && value !== null && !Array.isArray(value);
7727
8180
  }
7728
- function unexpected(path24, body) {
8181
+ function unexpected(path25, body) {
7729
8182
  return new CliError({
7730
8183
  code: "PROTOCOL_UNSUPPORTED" /* PROTOCOL_UNSUPPORTED */,
7731
- message: `${path24} \u8FD4\u56DE\u4E86 2xx\uFF0C\u4F46\u54CD\u5E94\u91CC\u6CA1\u6709\u7EA6\u5B9A\u7684 data \u7ED3\u6784\uFF1B\u6CA1\u6709\u628A\u7F3A\u7684\u90E8\u5206\u8865\u6210\u7A7A\u5217\u8868`,
8184
+ message: `${path25} \u8FD4\u56DE\u4E86 2xx\uFF0C\u4F46\u54CD\u5E94\u91CC\u6CA1\u6709\u7EA6\u5B9A\u7684 data \u7ED3\u6784\uFF1B\u6CA1\u6709\u628A\u7F3A\u7684\u90E8\u5206\u8865\u6210\u7A7A\u5217\u8868`,
7732
8185
  context: {
7733
8186
  reasonCode: "COLUMN_SLOT_RESPONSE_UNRECOGNIZED",
7734
8187
  details: body,
@@ -7757,7 +8210,7 @@ async function getColumnSlotSql(http, params, opts = {}) {
7757
8210
  }
7758
8211
 
7759
8212
  // src/meta/validate-meta.ts
7760
- import yaml9 from "js-yaml";
8213
+ import yaml8 from "js-yaml";
7761
8214
 
7762
8215
  // src/meta/generated/meta-schemas.ts
7763
8216
  var META_SCHEMA_SOURCE_COMMIT = "6b872a5b3749147cd4fed9dd1a1598e5876c8c76";
@@ -14693,7 +15146,7 @@ function validateScriptActionNames(doc, issues) {
14693
15146
  return;
14694
15147
  const reserved = /* @__PURE__ */ new Set(["list", "get", "create", "update", "delete"]);
14695
15148
  const visited = /* @__PURE__ */ new Set();
14696
- const visit = (raw, path24) => {
15149
+ const visit = (raw, path25) => {
14697
15150
  if (!raw || typeof raw !== "object" || Array.isArray(raw) || visited.has(raw)) return;
14698
15151
  visited.add(raw);
14699
15152
  const action3 = raw;
@@ -14701,7 +15154,7 @@ function validateScriptActionNames(doc, issues) {
14701
15154
  if (type === "script" && typeof action3.key === "string" && reserved.has(action3.key.trim().toLowerCase())) {
14702
15155
  issues.push({
14703
15156
  severity: "error",
14704
- path: `${path24}.key`,
15157
+ path: `${path25}.key`,
14705
15158
  message: `E_SCRIPT_ACTION_RESERVED_KEY: \u811A\u672C Action key '${action3.key}' \u4E0E CRUD \u4FDD\u7559\u540D\u51B2\u7A81\uFF08list/get/create/update/delete\uFF09`,
14706
15159
  hint: "\u6539\u7528\u4E1A\u52A1\u8BED\u4E49 key\uFF08\u5982 createBusinessRequest\uFF09\uFF0C\u5E76\u663E\u5F0F\u6388\u6743 action:<key>\uFF1BCRUD \u6743\u9650\u4E0E\u81EA\u5B9A\u4E49 Action \u6743\u9650\u72EC\u7ACB"
14707
15160
  });
@@ -14712,7 +15165,7 @@ function validateScriptActionNames(doc, issues) {
14712
15165
  const steps = composite.steps;
14713
15166
  if (!Array.isArray(steps)) return;
14714
15167
  steps.forEach((step, index) => {
14715
- const stepPath = `${path24}.composite.steps[${index}]`;
15168
+ const stepPath = `${path25}.composite.steps[${index}]`;
14716
15169
  visit(step, stepPath);
14717
15170
  if (step && typeof step === "object" && !Object.hasOwn(step, "type")) {
14718
15171
  visit(step.action, `${stepPath}.action`);
@@ -14744,7 +15197,7 @@ function validateMetaContent(metaPath2, content) {
14744
15197
  }
14745
15198
  let doc;
14746
15199
  try {
14747
- doc = yaml9.load(content);
15200
+ doc = yaml8.load(content);
14748
15201
  } catch (e) {
14749
15202
  const y = e;
14750
15203
  issues.push({
@@ -14818,7 +15271,7 @@ function explainJacksonError(raw) {
14818
15271
  }
14819
15272
 
14820
15273
  // src/skills.ts
14821
- import yaml10, { JSON_SCHEMA as JSON_SCHEMA3 } from "js-yaml";
15274
+ import yaml9, { JSON_SCHEMA as JSON_SCHEMA2 } from "js-yaml";
14822
15275
  var CHIRON_BASE_CANDIDATES = ["/api/chiron", "/api/skills", "/chiron", "/skills"];
14823
15276
  function looksLikeManifest(data) {
14824
15277
  if (!data || typeof data !== "object") return false;
@@ -14974,14 +15427,14 @@ function resolveSkillInstallOrder(manifest2, targetId) {
14974
15427
  throw invalid2(`\u6280\u80FD\u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728 ${targetId}`);
14975
15428
  }
14976
15429
  const state = /* @__PURE__ */ new Map();
14977
- const path24 = [];
15430
+ const path25 = [];
14978
15431
  const order = [];
14979
15432
  const visit = (id, requiredBy) => {
14980
15433
  const current = state.get(id);
14981
15434
  if (current === "done") return;
14982
15435
  if (current === "visiting") {
14983
- const cycleStart = path24.indexOf(id);
14984
- const cycle = [...path24.slice(Math.max(0, cycleStart)), id];
15436
+ const cycleStart = path25.indexOf(id);
15437
+ const cycle = [...path25.slice(Math.max(0, cycleStart)), id];
14985
15438
  throw invalid2(`\u6280\u80FD\u4F9D\u8D56\u5B58\u5728\u73AF: ${cycle.join(" -> ")}`);
14986
15439
  }
14987
15440
  const skill = byId.get(id);
@@ -14990,11 +15443,11 @@ function resolveSkillInstallOrder(manifest2, targetId) {
14990
15443
  }
14991
15444
  assertSafeSkillId(skill.id);
14992
15445
  state.set(id, "visiting");
14993
- path24.push(id);
15446
+ path25.push(id);
14994
15447
  for (const required2 of normalizeRequirements(skill.requires, skill.id)) {
14995
15448
  visit(required2, skill.id);
14996
15449
  }
14997
- path24.pop();
15450
+ path25.pop();
14998
15451
  state.set(id, "done");
14999
15452
  order.push(skill);
15000
15453
  };
@@ -15016,7 +15469,7 @@ function parseSkillFrontmatter(markdown, skillId) {
15016
15469
  if (!match) return {};
15017
15470
  let frontmatter;
15018
15471
  try {
15019
- frontmatter = yaml10.load(match[1] ?? "", { schema: JSON_SCHEMA3 });
15472
+ frontmatter = yaml9.load(match[1] ?? "", { schema: JSON_SCHEMA2 });
15020
15473
  } catch (cause) {
15021
15474
  throw new CliError({
15022
15475
  code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */,
@@ -15085,18 +15538,18 @@ async function resetSettingItem(http, domain, namespace, settingKey, revision) {
15085
15538
  function parseSettingAssignment(raw) {
15086
15539
  const eq = raw.indexOf("=");
15087
15540
  if (eq <= 0) throw new Error(`--set \u9700\u8981 namespace.key=value \u5F62\u6001\uFF0C\u6536\u5230 "${raw}"`);
15088
- const path24 = raw.slice(0, eq).trim();
15541
+ const path25 = raw.slice(0, eq).trim();
15089
15542
  const value = raw.slice(eq + 1);
15090
- const dot = path24.lastIndexOf(".");
15091
- if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path24}"`);
15092
- return { namespace: path24.slice(0, dot), settingKey: path24.slice(dot + 1), value };
15543
+ const dot = path25.lastIndexOf(".");
15544
+ if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path25}"`);
15545
+ return { namespace: path25.slice(0, dot), settingKey: path25.slice(dot + 1), value };
15093
15546
  }
15094
15547
 
15095
15548
  // src/fde/layout.ts
15096
15549
  import { createHash as createHash3, randomBytes as randomBytes2 } from "crypto";
15097
15550
  import {
15098
15551
  closeSync,
15099
- existsSync as existsSync3,
15552
+ existsSync as existsSync2,
15100
15553
  fsyncSync,
15101
15554
  linkSync,
15102
15555
  mkdirSync,
@@ -15107,7 +15560,7 @@ import {
15107
15560
  writeFileSync,
15108
15561
  writeSync
15109
15562
  } from "fs";
15110
- import * as path8 from "path";
15563
+ import * as path9 from "path";
15111
15564
  var UNSAFE = /[^A-Za-z0-9._-]/g;
15112
15565
  function slug(value) {
15113
15566
  return (value || "unknown").replace(UNSAFE, "_");
@@ -15121,10 +15574,10 @@ function tenantSegment(value) {
15121
15574
  return safeSegment(value);
15122
15575
  }
15123
15576
  function isInside(p, container) {
15124
- const rel = path8.relative(container, p);
15577
+ const rel = path9.relative(container, p);
15125
15578
  if (rel === "") return true;
15126
- if (path8.isAbsolute(rel)) return false;
15127
- return !rel.split(path8.sep).includes("..");
15579
+ if (path9.isAbsolute(rel)) return false;
15580
+ return !rel.split(path9.sep).includes("..");
15128
15581
  }
15129
15582
  function hasDotDotComponent(rel) {
15130
15583
  return rel.split(/[/\\]/).includes("..");
@@ -15138,14 +15591,14 @@ var ReconLayout = class {
15138
15591
  this.root = root;
15139
15592
  this.tenantId = String(tenantId);
15140
15593
  this.sourceKey = sourceKey;
15141
- this.dir = path8.join(
15594
+ this.dir = path9.join(
15142
15595
  this.root,
15143
15596
  "recon",
15144
15597
  tenantSegment(this.tenantId),
15145
15598
  safeSegment(sourceKey)
15146
15599
  );
15147
- const container = path8.resolve(this.root, "recon");
15148
- if (!isInside(path8.resolve(this.dir), container)) {
15600
+ const container = path9.resolve(this.root, "recon");
15601
+ if (!isInside(path9.resolve(this.dir), container)) {
15149
15602
  throw new LayoutContainmentError(
15150
15603
  `\u79DF\u6237\u6BB5\u8D8A\u754C\uFF0C\u62D2\u7EDD\u6784\u9020\u4EA7\u7269\u76EE\u5F55\uFF1AtenantId=${JSON.stringify(tenantId)}\uFF08\u4EA7\u7269\u6839 ${container}\uFF09`
15151
15604
  );
@@ -15168,19 +15621,19 @@ var ReconLayout = class {
15168
15621
  * ⚠️ 拒绝而不是消毒:消毒会让 `meta/<modelKey>.json` 不再能按 modelKey grep 回去。
15169
15622
  */
15170
15623
  resolvePath(rel, createParents = true) {
15171
- const p = path8.join(this.dir, rel);
15624
+ const p = path9.join(this.dir, rel);
15172
15625
  if (hasDotDotComponent(rel)) {
15173
15626
  throw new LayoutContainmentError(
15174
15627
  `\u4EA7\u7269\u76F8\u5BF9\u8DEF\u5F84\u542B \`..\` \u5206\u91CF\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08\u4F1A\u8D8A\u51FA\u9884\u671F\u5B50\u76EE\u5F55\u3001\u9759\u9ED8\u9876\u6389\u540C\u7EA7\u4EA7\u7269\uFF1B\u4EA7\u7269\u6839 ${this.dir}\uFF09`
15175
15628
  );
15176
15629
  }
15177
- if (!isInside(path8.resolve(p), path8.resolve(this.dir))) {
15630
+ if (!isInside(path9.resolve(p), path9.resolve(this.dir))) {
15178
15631
  throw new LayoutContainmentError(
15179
15632
  `\u4EA7\u7269\u76F8\u5BF9\u8DEF\u5F84\u8D8A\u754C\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08\u4EA7\u7269\u6839 ${this.dir}\uFF09`
15180
15633
  );
15181
15634
  }
15182
15635
  if (createParents) {
15183
- mkdirSync(path8.dirname(p), { recursive: true });
15636
+ mkdirSync(path9.dirname(p), { recursive: true });
15184
15637
  }
15185
15638
  return p;
15186
15639
  }
@@ -15229,18 +15682,18 @@ var WorkLayout = class {
15229
15682
  }
15230
15683
  /** 与 {@link ReconLayout.resolvePath} 同样的两道闸,理由见那里。 */
15231
15684
  resolvePath(rel, createParents = true) {
15232
- const p = path8.join(this.dir, rel);
15685
+ const p = path9.join(this.dir, rel);
15233
15686
  if (hasDotDotComponent(rel)) {
15234
15687
  throw new LayoutContainmentError(
15235
15688
  `work \u76EE\u5F55\u76F8\u5BF9\u8DEF\u5F84\u542B \`..\` \u5206\u91CF\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08work \u6839 ${this.dir}\uFF09`
15236
15689
  );
15237
15690
  }
15238
- if (!isInside(path8.resolve(p), path8.resolve(this.dir))) {
15691
+ if (!isInside(path9.resolve(p), path9.resolve(this.dir))) {
15239
15692
  throw new LayoutContainmentError(
15240
15693
  `work \u76EE\u5F55\u76F8\u5BF9\u8DEF\u5F84\u8D8A\u754C\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08work \u6839 ${this.dir}\uFF09`
15241
15694
  );
15242
15695
  }
15243
- if (createParents) mkdirSync(path8.dirname(p), { recursive: true });
15696
+ if (createParents) mkdirSync(path9.dirname(p), { recursive: true });
15244
15697
  return p;
15245
15698
  }
15246
15699
  /** 写一份 JSON 产物。中文逐字落盘(本地 grep 才找得到),末尾带换行。 */
@@ -15348,7 +15801,7 @@ var WorkLayout = class {
15348
15801
  return readFileSync2(this.resolvePath(rel, false));
15349
15802
  }
15350
15803
  exists(rel) {
15351
- return existsSync3(this.resolvePath(rel, false));
15804
+ return existsSync2(this.resolvePath(rel, false));
15352
15805
  }
15353
15806
  };
15354
15807
  function tempPath(target) {
@@ -15423,11 +15876,11 @@ function classifyStatus(status) {
15423
15876
  return "bad-response";
15424
15877
  }
15425
15878
  var CAPABILITIES_HEADER = "x-hcm-capabilities";
15426
- function buildUrl(path24, params) {
15879
+ function buildUrl(path25, params) {
15427
15880
  const entries = Object.entries(params ?? {}).filter(([, v]) => v !== void 0 && v !== null);
15428
- if (entries.length === 0) return path24;
15881
+ if (entries.length === 0) return path25;
15429
15882
  const qs = entries.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
15430
- return `${path24}${path24.includes("?") ? "&" : "?"}${qs}`;
15883
+ return `${path25}${path25.includes("?") ? "&" : "?"}${qs}`;
15431
15884
  }
15432
15885
  function lowerHeaders(raw) {
15433
15886
  const out = {};
@@ -15482,14 +15935,14 @@ function httpProbe(http, capabilities) {
15482
15935
  const headers2 = { [CAPABILITIES_HEADER]: capabilities };
15483
15936
  const probe = {
15484
15937
  capabilities,
15485
- get(path24, params) {
15938
+ get(path25, params) {
15486
15939
  return once(
15487
- () => http.get(buildUrl(path24, params), { headers: headers2, validateStatus: () => true })
15940
+ () => http.get(buildUrl(path25, params), { headers: headers2, validateStatus: () => true })
15488
15941
  );
15489
15942
  },
15490
- post(path24, body) {
15943
+ post(path25, body) {
15491
15944
  return once(
15492
- () => http.post(path24, body, {
15945
+ () => http.post(path25, body, {
15493
15946
  headers: { ...headers2, "content-type": "application/json" },
15494
15947
  validateStatus: () => true
15495
15948
  })
@@ -15526,8 +15979,8 @@ function networkOutcome() {
15526
15979
 
15527
15980
  // src/fde/recon/runner.ts
15528
15981
  import { randomBytes as randomBytes3 } from "crypto";
15529
- import { existsSync as existsSync5, readFileSync as readFileSync3, readdirSync } from "fs";
15530
- import * as path10 from "path";
15982
+ import { existsSync as existsSync4, readFileSync as readFileSync3, readdirSync } from "fs";
15983
+ import * as path11 from "path";
15531
15984
 
15532
15985
  // src/fde/recon/carry-over.ts
15533
15986
  var KIT_CARRY_OVER_KEY = "_kitCarryOver";
@@ -15595,8 +16048,8 @@ async function crawlMeta(probe, modelKeys2, metaType = DEFAULT_META_TYPE) {
15595
16048
  const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
15596
16049
  const metas = {};
15597
16050
  const unavailable = [];
15598
- for (const [path24, key] of paths) {
15599
- const out = results[path24];
16051
+ for (const [path25, key] of paths) {
16052
+ const out = results[path25];
15600
16053
  if (out === void 0) {
15601
16054
  unavailable.push({
15602
16055
  modelKey: key,
@@ -15828,8 +16281,8 @@ async function collectActionGates(probe, modelKeys2, state = "") {
15828
16281
  const statesEchoed = /* @__PURE__ */ new Set();
15829
16282
  let noStateEcho = 0;
15830
16283
  let answered = 0;
15831
- for (const [path24, model] of paths) {
15832
- const out = results[path24];
16284
+ for (const [path25, model] of paths) {
16285
+ const out = results[path25];
15833
16286
  if (out === void 0) {
15834
16287
  unavailable.push({
15835
16288
  modelKey: model,
@@ -16248,8 +16701,8 @@ async function collectMutation(probe, modelKeys2) {
16248
16701
  const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
16249
16702
  const mutation = {};
16250
16703
  const problems = [];
16251
- for (const [path24, key] of paths) {
16252
- const out = results[path24];
16704
+ for (const [path25, key] of paths) {
16705
+ const out = results[path25];
16253
16706
  if (out === void 0) {
16254
16707
  problems.push(`${key}: mutation-capability ${BATCH_LOST}`);
16255
16708
  mutation[key] = Object.fromEntries(
@@ -16495,9 +16948,9 @@ function gateDesc(gate) {
16495
16948
  function renderModelsMd(modelsBody, metas, gates, dropped = []) {
16496
16949
  const byModel = /* @__PURE__ */ new Map();
16497
16950
  for (const g of gates) {
16498
- const list = byModel.get(g.model) ?? [];
16499
- list.push(g);
16500
- byModel.set(g.model, list);
16951
+ const list2 = byModel.get(g.model) ?? [];
16952
+ list2.push(g);
16953
+ byModel.set(g.model, list2);
16501
16954
  }
16502
16955
  const parts = [
16503
16956
  "# \u6A21\u578B\u7D22\u5F15",
@@ -16559,8 +17012,8 @@ function writeModelsMd(layout, text3) {
16559
17012
  }
16560
17013
 
16561
17014
  // src/fde/recon/pointer-audit.ts
16562
- import { existsSync as existsSync4 } from "fs";
16563
- import * as path9 from "path";
17015
+ import { existsSync as existsSync3 } from "fs";
17016
+ import * as path10 from "path";
16564
17017
  function isRecord5(v) {
16565
17018
  return Boolean(v) && typeof v === "object" && !Array.isArray(v);
16566
17019
  }
@@ -16573,7 +17026,7 @@ function auditValueDomainPointers(layout, sheets) {
16573
17026
  const pointer = isRecord5(ref) ? ref.valueDomain : null;
16574
17027
  if (typeof pointer !== "string" || pointer === "") continue;
16575
17028
  if (!seen.has(pointer)) {
16576
- seen.set(pointer, existsSync4(path9.join(layout.dir, pointer)));
17029
+ seen.set(pointer, existsSync3(path10.join(layout.dir, pointer)));
16577
17030
  }
16578
17031
  if (!seen.get(pointer)) {
16579
17032
  problems.push(
@@ -16694,11 +17147,11 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
16694
17147
  keys.push(key);
16695
17148
  }
16696
17149
  for (const key of [...new Set(keys)].sort()) {
16697
- const path24 = listPath(key);
17150
+ const path25 = listPath(key);
16698
17151
  const started = tick();
16699
17152
  let requests = 0;
16700
17153
  let truncatedBy = null;
16701
- const probeOut = await post2.call(probe, path24, { page: 0, size: 0 });
17154
+ const probeOut = await post2.call(probe, path25, { page: 0, size: 0 });
16702
17155
  requests += 1;
16703
17156
  let total = null;
16704
17157
  let reason = null;
@@ -16747,7 +17200,7 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
16747
17200
  failed = `\u89E6\u53D1\u5DE5\u5177\u7684\u6BCF\u8868${which === "requests" ? "\u8BF7\u6C42" : "\u5899\u949F"}\u4E0A\u9650\uFF08${which === "requests" ? `\u5DF2\u53D1 ${requests} \u6B21\u8BF7\u6C42` : `\u5DF2\u82B1 ${elapsed.toFixed(3)}s`}\uFF09\uFF0C\u505C\u5728\u7B2C ${page} \u9875\uFF0C\u5DF2\u6536 ${rows.length} \u884C / \u8BA1\u6570 ${total} \u884C\uFF0C\u672C\u8868\u6807 partial\u3002**\u8FD9\u662F\u5DE5\u5177\u7684\u622A\u65AD\uFF0C\u4E0D\u662F\u670D\u52A1\u7AEF\u7684\u6BDB\u75C5** \u2014\u2014 \u8C03\u5927 valuedomain.${which === "requests" ? "MAX_REQUESTS_PER_TABLE" : "MAX_SECONDS_PER_TABLE"} \u6216\u7ED9 collectCodeTables \u4F20 ${which === "requests" ? "maxRequests" : "maxSeconds"} \u540E\u91CD\u8DD1\u5C31\u80FD\u53D6\u5168`;
16748
17201
  break;
16749
17202
  }
16750
- const out = await post2.call(probe, path24, { page, size: PAGE_SIZE });
17203
+ const out = await post2.call(probe, path25, { page, size: PAGE_SIZE });
16751
17204
  requests += 1;
16752
17205
  if (out.error !== "ok") {
16753
17206
  failed = `\u7B2C ${page} \u9875\u5931\u8D25\uFF08HTTP ${out.status} / ${out.error}\uFF09`;
@@ -16968,7 +17421,7 @@ function readJsonSoft(file) {
16968
17421
  }
16969
17422
  }
16970
17423
  function readCrawledAt(layout) {
16971
- const body = readJsonSoft(path10.join(layout.dir, KIT_CRAWLED_AT_FILE));
17424
+ const body = readJsonSoft(path11.join(layout.dir, KIT_CRAWLED_AT_FILE));
16972
17425
  const models = isRecord7(body) ? body.models : null;
16973
17426
  return isRecord7(models) ? models : {};
16974
17427
  }
@@ -16998,7 +17451,7 @@ function writeCrawledAt(layout, freshKeys, carriedKeys, roundId, started) {
16998
17451
  return sorted;
16999
17452
  }
17000
17453
  function finishRound(layout, models, roundId, started, products) {
17001
- const written = [...new Set(products.filter((rel) => rel && existsSync5(path10.join(layout.dir, rel))))].sort();
17454
+ const written = [...new Set(products.filter((rel) => rel && existsSync4(path11.join(layout.dir, rel))))].sort();
17002
17455
  layout.writeJson(KIT_CRAWLED_AT_FILE, {
17003
17456
  note: CRAWLED_AT_NOTE,
17004
17457
  roundNote: ROUND_NOTE,
@@ -17010,13 +17463,13 @@ function finishRound(layout, models, roundId, started, products) {
17010
17463
  return written;
17011
17464
  }
17012
17465
  function relOf(layout, p) {
17013
- const rel = path10.relative(layout.dir, p);
17466
+ const rel = path11.relative(layout.dir, p);
17014
17467
  if (!rel || rel.startsWith("..")) return p;
17015
- return rel.split(path10.sep).join("/");
17468
+ return rel.split(path11.sep).join("/");
17016
17469
  }
17017
17470
  function productRoundId(root, rel) {
17018
- const p = path10.join(root, rel);
17019
- if (!existsSync5(p)) return ["missing", null];
17471
+ const p = path11.join(root, rel);
17472
+ if (!existsSync4(p)) return ["missing", null];
17020
17473
  const body = readJsonSoft(p);
17021
17474
  if (body === void 0 || !isRecord7(body)) return ["unreadable", null];
17022
17475
  const rid = body.roundId;
@@ -17024,7 +17477,7 @@ function productRoundId(root, rel) {
17024
17477
  return ["stamped", rid];
17025
17478
  }
17026
17479
  function inspectRound(root) {
17027
- const raw = readJsonSoft(path10.join(root, KIT_CRAWLED_AT_FILE));
17480
+ const raw = readJsonSoft(path11.join(root, KIT_CRAWLED_AT_FILE));
17028
17481
  const ledger = isRecord7(raw) ? raw : {};
17029
17482
  const rid = ledger.roundId;
17030
17483
  const roundId = typeof rid === "string" && rid ? rid : null;
@@ -17032,7 +17485,7 @@ function inspectRound(root) {
17032
17485
  const written = Array.isArray(rawWritten) ? rawWritten : null;
17033
17486
  let ledgerMissing = null;
17034
17487
  if (written !== null) {
17035
- const gone = written.filter((rel) => typeof rel === "string" && !existsSync5(path10.join(root, rel))).sort();
17488
+ const gone = written.filter((rel) => typeof rel === "string" && !existsSync4(path11.join(root, rel))).sort();
17036
17489
  ledgerMissing = { checked: written.length, count: gone.length, files: gone };
17037
17490
  }
17038
17491
  const products = [];
@@ -17152,7 +17605,7 @@ function carriedGatesSchemaProblem(oldGates) {
17152
17605
  function collectCarryOver(layout, freshMetas) {
17153
17606
  const problems = [];
17154
17607
  const carriedMetas = {};
17155
- const metaDir = path10.join(layout.dir, "meta");
17608
+ const metaDir = path11.join(layout.dir, "meta");
17156
17609
  const suffix = `.${DEFAULT_META_TYPE}.json`;
17157
17610
  let names = [];
17158
17611
  try {
@@ -17163,7 +17616,7 @@ function collectCarryOver(layout, freshMetas) {
17163
17616
  for (const name of names) {
17164
17617
  const key = name.slice(0, -suffix.length);
17165
17618
  if (key in freshMetas) continue;
17166
- const file = path10.join(metaDir, name);
17619
+ const file = path11.join(metaDir, name);
17167
17620
  let body;
17168
17621
  try {
17169
17622
  body = JSON.parse(readFileSync3(file, "utf8"));
@@ -17179,7 +17632,7 @@ function collectCarryOver(layout, freshMetas) {
17179
17632
  }
17180
17633
  }
17181
17634
  const carriedGates = [];
17182
- const oldGates = readJsonSoft(path10.join(layout.dir, "gates.json"));
17635
+ const oldGates = readJsonSoft(path11.join(layout.dir, "gates.json"));
17183
17636
  if (oldGates === void 0) {
17184
17637
  problems.push("gates.json: \u6CA1\u6709\u53EF\u6CBF\u7528\u7684\u4E0A\u4E00\u8F6E\u95F8\u8868\uFF08\u4E0D\u5B58\u5728\u6216\u8BFB\u4E0D\u51FA JSON\uFF09");
17185
17638
  } else {
@@ -17296,7 +17749,7 @@ async function runRecon(probe, layout, opts = {}) {
17296
17749
  const writtenPaths = new Set(vdWritten);
17297
17750
  const codeTableFiles = new Set(
17298
17751
  Object.keys(codeTables).filter(
17299
- (k) => unsafeTableKeyReason(k) === null && writtenPaths.has(path10.join(layout.dir, "valuedomain", `${k}.json`))
17752
+ (k) => unsafeTableKeyReason(k) === null && writtenPaths.has(path11.join(layout.dir, "valuedomain", `${k}.json`))
17300
17753
  )
17301
17754
  );
17302
17755
  const { mutation, problems: mutProblems } = await collectMutation(probe, Object.keys(metas).sort());
@@ -17311,7 +17764,7 @@ async function runRecon(probe, layout, opts = {}) {
17311
17764
  });
17312
17765
  products.push(...mappingPaths.map((p) => relOf(layout, p)));
17313
17766
  const sheetsWritten = Math.max(mappingPaths.length - 1, 0);
17314
- let previous = readJsonSoft(path10.join(layout.dir, "fingerprint.json"));
17767
+ let previous = readJsonSoft(path11.join(layout.dir, "fingerprint.json"));
17315
17768
  if (!isRecord7(previous)) previous = null;
17316
17769
  const current = await computeFingerprint(probe);
17317
17770
  products.push(relOf(layout, layout.writeJson("fingerprint.json", current)));
@@ -17406,12 +17859,12 @@ async function runRecon(probe, layout, opts = {}) {
17406
17859
  }
17407
17860
 
17408
17861
  // src/fde/seed/command.ts
17409
- import { existsSync as existsSync8, readFileSync as readFileSync7, readdirSync as readdirSync2, statSync as statSync7 } from "fs";
17410
- import * as path16 from "path";
17862
+ import { existsSync as existsSync7, readFileSync as readFileSync7, readdirSync as readdirSync2, statSync as statSync6 } from "fs";
17863
+ import * as path17 from "path";
17411
17864
 
17412
17865
  // src/fde/seed/risk.ts
17413
- import { readFileSync as readFileSync6, realpathSync, statSync as statSync6 } from "fs";
17414
- import * as path15 from "path";
17866
+ import { readFileSync as readFileSync6, realpathSync, statSync as statSync5 } from "fs";
17867
+ import * as path16 from "path";
17415
17868
 
17416
17869
  // src/fde/seed/key-index.ts
17417
17870
  var MAX_PAGE_SIZE = 1e4;
@@ -17511,7 +17964,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
17511
17964
  for (const name of ["id", ...fields]) {
17512
17965
  if (!projected.includes(name)) projected.push(name);
17513
17966
  }
17514
- const path24 = listPath2(model);
17967
+ const path25 = listPath2(model);
17515
17968
  const idx = /* @__PURE__ */ new Map();
17516
17969
  let total = null;
17517
17970
  let pages = 0;
@@ -17528,7 +17981,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
17528
17981
  let repeatedIds = 0;
17529
17982
  while (total === null || received < total) {
17530
17983
  const pageNo = pages;
17531
- const out = await client.post(path24, {
17984
+ const out = await client.post(path25, {
17532
17985
  page: pageNo,
17533
17986
  size: pageSize,
17534
17987
  fields: projected,
@@ -17692,8 +18145,8 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
17692
18145
  }
17693
18146
 
17694
18147
  // src/fde/seed/artifacts.ts
17695
- import * as path14 from "path";
17696
- import { existsSync as existsSync7, readFileSync as readFileSync5, statSync as statSync5 } from "fs";
18148
+ import * as path15 from "path";
18149
+ import { existsSync as existsSync6, readFileSync as readFileSync5, statSync as statSync4 } from "fs";
17697
18150
 
17698
18151
  // src/fde/seed/errors.ts
17699
18152
  var SourceError = class extends Error {
@@ -17711,17 +18164,17 @@ var SHEETED_SUFFIXES = [".xlsx", ".xlsm"];
17711
18164
  var TEXT_SUFFIXES = [".csv", ".tsv"];
17712
18165
 
17713
18166
  // src/fde/seed/source.ts
17714
- import { existsSync as existsSync6, openSync as openSync3, readSync as readSync2, closeSync as closeSync3, statSync as statSync4 } from "fs";
17715
- import * as path13 from "path";
18167
+ import { existsSync as existsSync5, openSync as openSync3, readSync as readSync2, closeSync as closeSync3, statSync as statSync3 } from "fs";
18168
+ import * as path14 from "path";
17716
18169
 
17717
18170
  // src/fde/seed/container.ts
17718
- import { openSync as openSync2, readSync, closeSync as closeSync2, statSync as statSync3 } from "fs";
18171
+ import { openSync as openSync2, readSync, closeSync as closeSync2, statSync as statSync2 } from "fs";
17719
18172
  var CFB_MAGIC = Buffer.from([208, 207, 17, 224, 161, 177, 26, 225]);
17720
18173
  var ENCRYPTED_PACKAGE = Buffer.from("EncryptedPackage", "utf16le");
17721
18174
  var MAX_ENTRY_BYTES = 128 * 1024 * 1024;
17722
18175
  var SCAN_CHUNK_BYTES = 1024 * 1024;
17723
- function scanFor(path24, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
17724
- const fd = openSync2(path24, "r");
18176
+ function scanFor(path25, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
18177
+ const fd = openSync2(path25, "r");
17725
18178
  try {
17726
18179
  let tail = Buffer.alloc(0);
17727
18180
  let seen = 0;
@@ -17742,9 +18195,9 @@ function scanFor(path24, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
17742
18195
  closeSync2(fd);
17743
18196
  }
17744
18197
  }
17745
- function isCfb(path24) {
17746
- if (statSync3(path24).size < CFB_MAGIC.length) return false;
17747
- const fd = openSync2(path24, "r");
18198
+ function isCfb(path25) {
18199
+ if (statSync2(path25).size < CFB_MAGIC.length) return false;
18200
+ const fd = openSync2(path25, "r");
17748
18201
  try {
17749
18202
  const head = Buffer.alloc(CFB_MAGIC.length);
17750
18203
  const n = readSync(fd, head, 0, CFB_MAGIC.length, 0);
@@ -17753,9 +18206,9 @@ function isCfb(path24) {
17753
18206
  closeSync2(fd);
17754
18207
  }
17755
18208
  }
17756
- function classifyCfb(path24, budget = MAX_ENTRY_BYTES) {
17757
- if (!isCfb(path24)) return "not-cfb";
17758
- switch (scanFor(path24, ENCRYPTED_PACKAGE, budget)) {
18209
+ function classifyCfb(path25, budget = MAX_ENTRY_BYTES) {
18210
+ if (!isCfb(path25)) return "not-cfb";
18211
+ switch (scanFor(path25, ENCRYPTED_PACKAGE, budget)) {
17759
18212
  case "found":
17760
18213
  return "encrypted";
17761
18214
  case "absent":
@@ -17767,7 +18220,7 @@ function classifyCfb(path24, budget = MAX_ENTRY_BYTES) {
17767
18220
 
17768
18221
  // src/fde/seed/delimited.ts
17769
18222
  import { readFileSync as readFileSync4 } from "fs";
17770
- import * as path11 from "path";
18223
+ import * as path12 from "path";
17771
18224
 
17772
18225
  // src/fde/seed/columns.ts
17773
18226
  function resolveColumns(headerCells, dataRows, label, origin, filename, notes) {
@@ -17934,7 +18387,7 @@ function parseDelimited(text3, delimiter) {
17934
18387
  return records;
17935
18388
  }
17936
18389
  function readDelimited(file, suffix, sheet, headerRow, notes, makeDecoder = defaultDecoderFactory) {
17937
- const filename = path11.basename(file);
18390
+ const filename = path12.basename(file);
17938
18391
  if (sheet !== null && sheet !== void 0) {
17939
18392
  throw new SourceError(
17940
18393
  "sheet-not-applicable",
@@ -18015,7 +18468,7 @@ function readDelimited(file, suffix, sheet, headerRow, notes, makeDecoder = defa
18015
18468
  }
18016
18469
 
18017
18470
  // src/fde/seed/xlsx.ts
18018
- import * as path12 from "path";
18471
+ import * as path13 from "path";
18019
18472
 
18020
18473
  // src/fde/seed/zip.ts
18021
18474
  import yauzl from "yauzl";
@@ -18456,7 +18909,7 @@ function readSheetText(text3, shared, headerRow, filename, notes) {
18456
18909
  return { header, rows: assemble(header, body, headerRow) };
18457
18910
  }
18458
18911
  async function readXlsx(file, sheet, headerRow, notes, maxEntryBytes) {
18459
- const filename = path12.basename(file);
18912
+ const filename = path13.basename(file);
18460
18913
  const parts = await openParts(file, filename, maxEntryBytes);
18461
18914
  try {
18462
18915
  if (!parts.names.has("xl/workbook.xml")) {
@@ -18534,7 +18987,7 @@ function classifyContainer(file, filename, defaultReason, budget) {
18534
18987
  );
18535
18988
  }
18536
18989
  function startsWithPk(file) {
18537
- if (statSync4(file).size < 2) return false;
18990
+ if (statSync3(file).size < 2) return false;
18538
18991
  const fd = openSync3(file, "r");
18539
18992
  try {
18540
18993
  const head = Buffer.alloc(2);
@@ -18546,7 +18999,7 @@ function startsWithPk(file) {
18546
18999
  async function readTable(file, options = {}) {
18547
19000
  const sheet = options.sheet ?? null;
18548
19001
  const headerRow = options.headerRow ?? 1;
18549
- const filename = path13.basename(file);
19002
+ const filename = path14.basename(file);
18550
19003
  if (headerRow < 1) {
18551
19004
  throw new SourceError(
18552
19005
  "bad-header-row",
@@ -18554,10 +19007,10 @@ async function readTable(file, options = {}) {
18554
19007
  "\u8868\u5934\u884C\u53F7\u4ECE 1 \u8D77\u7B97\uFF08\u7B2C 1 \u884C\u5C31\u662F 1\uFF09\uFF0C\u4E0D\u662F\u4ECE 0"
18555
19008
  );
18556
19009
  }
18557
- if (!existsSync6(file) || !statSync4(file).isFile()) {
19010
+ if (!existsSync5(file) || !statSync3(file).isFile()) {
18558
19011
  throw new SourceError("not-found", `\u627E\u4E0D\u5230\u6E90\u8868 ${file}`, "\u786E\u8BA4\u8DEF\u5F84\uFF0C\u4EE5\u53CA\u6587\u4EF6\u662F\u5426\u8FD8\u5728\u5171\u4EAB\u76D8\u4E0A\u6CA1\u540C\u6B65\u4E0B\u6765");
18559
19012
  }
18560
- const suffix = path13.extname(file).toLowerCase();
19013
+ const suffix = path14.extname(file).toLowerCase();
18561
19014
  if (suffix === ".xls") {
18562
19015
  throw classifyContainer(file, filename, "legacy-xls", options.scanBudgetBytes);
18563
19016
  }
@@ -18927,7 +19380,7 @@ var MODEL_KEYS = [
18927
19380
  "valueMap"
18928
19381
  ];
18929
19382
  function loadMapping(file) {
18930
- if (!existsSync7(file) || !statSync5(file).isFile()) {
19383
+ if (!existsSync6(file) || !statSync4(file).isFile()) {
18931
19384
  throw new MappingError("not-found", `\u627E\u4E0D\u5230\u6620\u5C04\u5DE5\u4EF6 ${file}`, "\u786E\u8BA4\u8DEF\u5F84\uFF1B\u5DE5\u4EF6\u4E00\u822C\u5728 work/mapping.json");
18932
19385
  }
18933
19386
  let text3;
@@ -19174,16 +19627,16 @@ function stamp(note, model, file) {
19174
19627
  }
19175
19628
  return { ...asRecord3, model, file };
19176
19629
  }
19177
- async function scanSources(mapping, baseDir, options = {}) {
19630
+ async function scanSources(mapping2, baseDir, options = {}) {
19178
19631
  const read = options.readTableImpl ?? readTable;
19179
- const base = baseDir ?? path14.dirname(mapping.path);
19632
+ const base = baseDir ?? path15.dirname(mapping2.path);
19180
19633
  const headers2 = /* @__PURE__ */ new Map();
19181
19634
  const rows = /* @__PURE__ */ new Map();
19182
19635
  const notes = [];
19183
19636
  const problems = [];
19184
19637
  const takenBy = /* @__PURE__ */ new Map();
19185
- for (const [index, mm] of mapping.models.entries()) {
19186
- const file = path14.join(base, mm.source.file);
19638
+ for (const [index, mm] of mapping2.models.entries()) {
19639
+ const file = path15.join(base, mm.source.file);
19187
19640
  const owner = takenBy.get(mm.model);
19188
19641
  if (owner !== void 0) {
19189
19642
  problems.push(
@@ -19225,9 +19678,9 @@ async function scanSources(mapping, baseDir, options = {}) {
19225
19678
  }
19226
19679
  return { headers: headers2, rows, notes, problems };
19227
19680
  }
19228
- function validateMapping(mapping, headers2) {
19681
+ function validateMapping(mapping2, headers2) {
19229
19682
  const declaredKeys = /* @__PURE__ */ new Map();
19230
- for (const mm of mapping.models) {
19683
+ for (const mm of mapping2.models) {
19231
19684
  const fields = mm.businessKey ? [...mm.businessKey.fields] : [];
19232
19685
  if (!declaredKeys.has(mm.model)) {
19233
19686
  declaredKeys.set(mm.model, fields);
@@ -19242,7 +19695,7 @@ function validateMapping(mapping, headers2) {
19242
19695
  }
19243
19696
  const problems = [];
19244
19697
  const positions = /* @__PURE__ */ new Map();
19245
- mapping.models.forEach((mm, i) => {
19698
+ mapping2.models.forEach((mm, i) => {
19246
19699
  const spots = positions.get(mm.model);
19247
19700
  if (spots) spots.push(i);
19248
19701
  else positions.set(mm.model, [i]);
@@ -19260,7 +19713,7 @@ function validateMapping(mapping, headers2) {
19260
19713
  )
19261
19714
  );
19262
19715
  }
19263
- mapping.models.forEach((mm, index) => {
19716
+ mapping2.models.forEach((mm, index) => {
19264
19717
  problems.push(...validateModel(mm, headers2, duplicated.has(mm.model), index, declaredKeys));
19265
19718
  });
19266
19719
  return problems;
@@ -19354,7 +19807,7 @@ function checkOnExisting(mm) {
19354
19807
  return [];
19355
19808
  }
19356
19809
  function checkSourceRef(mm) {
19357
- const suffix = path14.extname(mm.source.file).toLowerCase();
19810
+ const suffix = path15.extname(mm.source.file).toLowerCase();
19358
19811
  if (!SUPPORTED_SUFFIXES.includes(suffix)) {
19359
19812
  return [
19360
19813
  problem(
@@ -19500,8 +19953,8 @@ function assignmentMap(mm, includeBusinessKey) {
19500
19953
  const translations = (field) => mm.valueMap.get(field) ?? /* @__PURE__ */ new Map();
19501
19954
  const out = /* @__PURE__ */ new Map();
19502
19955
  const push = (a) => {
19503
- const list = out.get(a.field);
19504
- if (list) list.push(a);
19956
+ const list2 = out.get(a.field);
19957
+ if (list2) list2.push(a);
19505
19958
  else out.set(a.field, [a]);
19506
19959
  };
19507
19960
  if (includeBusinessKey && mm.businessKey !== null) {
@@ -19613,8 +20066,8 @@ function checkColumnsAgainstHeader(mm, header, includeKey, includeColumns) {
19613
20066
  }
19614
20067
  const declared = /* @__PURE__ */ new Map();
19615
20068
  const declare = (column, origin) => {
19616
- const list = declared.get(column);
19617
- if (list) list.push(origin);
20069
+ const list2 = declared.get(column);
20070
+ if (list2) list2.push(origin);
19618
20071
  else declared.set(column, [origin]);
19619
20072
  };
19620
20073
  if (includeKey && mm.businessKey !== null) {
@@ -19714,20 +20167,20 @@ var PlanInvariantError = class extends Error {
19714
20167
  this.name = "PlanInvariantError";
19715
20168
  }
19716
20169
  };
19717
- function buildImportPlan(mapping, tables, indexes, options = {}) {
20170
+ function buildImportPlan(mapping2, tables, indexes, options = {}) {
19718
20171
  const problems = [];
19719
20172
  const models = [];
19720
20173
  const keyFieldsByModel = /* @__PURE__ */ new Map();
19721
- for (const mm of mapping.models) {
20174
+ for (const mm of mapping2.models) {
19722
20175
  if (mm.businessKey && mm.businessKey.fields.length && !keyFieldsByModel.has(mm.model)) {
19723
20176
  keyFieldsByModel.set(mm.model, [...mm.businessKey.fields]);
19724
20177
  }
19725
20178
  }
19726
20179
  const resolvedKeyModels = new Set(
19727
- mapping.models.filter((mm) => mm.businessKey && mm.businessKey.resolveBy.size).map((mm) => mm.model)
20180
+ mapping2.models.filter((mm) => mm.businessKey && mm.businessKey.resolveBy.size).map((mm) => mm.model)
19728
20181
  );
19729
20182
  const indexErrors = options.indexErrors ?? /* @__PURE__ */ new Map();
19730
- mapping.models.forEach((mm, entry) => {
20183
+ mapping2.models.forEach((mm, entry) => {
19731
20184
  const [modelPlan, modelProblems] = planModel(
19732
20185
  mm,
19733
20186
  tables,
@@ -19740,7 +20193,7 @@ function buildImportPlan(mapping, tables, indexes, options = {}) {
19740
20193
  models.push(modelPlan);
19741
20194
  problems.push(...modelProblems);
19742
20195
  });
19743
- const [orderInfo, orderProblems] = crossModelOrder(mapping, models, resolvedKeyModels);
20196
+ const [orderInfo, orderProblems] = crossModelOrder(mapping2, models, resolvedKeyModels);
19744
20197
  problems.push(...orderProblems);
19745
20198
  const roundId = options.roundId ?? newRoundId(/* @__PURE__ */ new Date());
19746
20199
  return {
@@ -19756,15 +20209,15 @@ function buildImportPlan(mapping, tables, indexes, options = {}) {
19756
20209
  var CROSS_MODEL_NOTE = "\u53EA\u6838\u4E86\u8FD9\u4EFD\u5DE5\u4EF6\u81EA\u5DF1\u58F0\u660E\u7684 resolveBy \u5F15\u7528\u8FB9\uFF08\u5DE5\u4EF6\u5185\u7684\u6A21\u578B\u4E4B\u95F4\uFF09\u3002\u4EA7\u54C1\u7EA7\u7684\u6A21\u578B\u4F9D\u8D56\u56FE topology.json **\u672C\u8F6E\u6CA1\u6709\u8BFB** \u2014\u2014 \u300C\u6CA1\u62A5\u987A\u5E8F\u95EE\u9898\u300D\u53EA\u7B49\u4E8E\u300C\u5DE5\u4EF6\u5185\u58F0\u660E\u7684\u8FB9\u6CA1\u51B2\u7A81\u300D\uFF0C**\u4E0D\u7B49\u4E8E**\u300C\u8DE8\u6A21\u578B\u987A\u5E8F\u6838\u8FC7\u4E86\u300D\u3002\u5DE5\u4EF6\u4E4B\u5916\u7684\u4F9D\u8D56\uFF08\u76EE\u6807\u6A21\u578B\u4E0D\u5728\u672C\u5DE5\u4EF6\u91CC\u7684\u90A3\u4E9B\u8FB9\uFF09\u672C\u5C42\u5224\u4E0D\u4E86\uFF0C\u53EA\u5982\u5B9E\u8BB0\u5728 edges \u91CC";
19757
20210
  var WHY_ASSIGNMENTS_UNUSABLE = "\u8FD9\u4E2A\u6A21\u578B\u7684\u5DE5\u4EF6\u62FC\u4E0D\u51FA\u5B57\u6BB5\u8D4B\u503C\u96C6\u5408\uFF08[{reason}]\uFF09\u21D2 \u5B83\u6709\u54EA\u4E9B\u5F15\u7528\u8FB9**\u6839\u672C\u6CA1\u626B\u8FC7**\u3002\u672C\u8F6E problems \u91CC\u53E6\u6709\u5B83\u7684 MAPPING_NOT_USABLE\uFF08\u4E0E\u672C\u6761\u540C\u4E00\u6B21\u8C03\u7528\u53D1\u51FA\uFF0C\u4E00\u5B9A\u5728\uFF09";
19758
20211
  var WHY_DUPLICATE_ENTRIES = "\u540C\u540D\u6A21\u578B\u5728\u8FD9\u4EFD\u5DE5\u4EF6\u91CC\u6709**\u591A\u6761 entry**\uFF0C\u4E00\u6761\u5F15\u7528\u8FB9\u5C5E\u4E8E\u54EA\u4E00\u6761**\u5206\u4E0D\u51FA\u6765** \u21D2 \u6CA1\u626B\u3002\u26A0\uFE0F \u522B\u53BB problems \u91CC\u627E DUPLICATE_MODEL_ENTRY\uFF1A\u90A3\u662F**\u5DE5\u4EF6\u5C42\u6821\u9A8C**\uFF08validateMapping\uFF09\u53D1\u7684 code\uFF0C\u800C\u5B83\u7531\u95E8\u9762 planFromArtifacts \u8D1F\u8D23\u8DD1 \u2014\u2014 \u8D70\u5230\u8FD9\u6761\u5206\u652F\u8BF4\u660E\u8C03\u7528\u65B9\u662F**\u76F4\u63A5\u8C03 buildImportPlan**\uFF0C\u90A3\u6761\u8DEF\u4E0A\u5DE5\u4EF6\u5C42\u6821\u9A8C\u4ECE\u6CA1\u8DD1\u8FC7\uFF0C\u6240\u4EE5\u90A3\u6761 code \u4E0D\u4F1A\u51FA\u73B0\u3002\u6B63\u786E\u505A\u6CD5\u662F\u5148\u8DD1\u4E00\u904D validateMapping\uFF0C\u5B83\u4F1A\u62D2\u6389\u8FD9\u4EFD\u5DE5\u4EF6";
19759
- function crossModelOrder(mapping, modelPlans, resolvedKeyModels) {
20212
+ function crossModelOrder(mapping2, modelPlans, resolvedKeyModels) {
19760
20213
  const positions = /* @__PURE__ */ new Map();
19761
- mapping.models.forEach((mm, i) => {
20214
+ mapping2.models.forEach((mm, i) => {
19762
20215
  if (!positions.has(mm.model)) positions.set(mm.model, i);
19763
20216
  });
19764
20217
  const plans = /* @__PURE__ */ new Map();
19765
20218
  for (const p of modelPlans) if (!plans.has(p.model)) plans.set(p.model, p);
19766
20219
  const seen = /* @__PURE__ */ new Map();
19767
- for (const mm of mapping.models) seen.set(mm.model, (seen.get(mm.model) ?? 0) + 1);
20220
+ for (const mm of mapping2.models) seen.set(mm.model, (seen.get(mm.model) ?? 0) + 1);
19768
20221
  const duplicated = new Set([...seen].filter(([, c]) => c > 1).map(([m]) => m));
19769
20222
  const edges = [];
19770
20223
  const problems = [];
@@ -19773,7 +20226,7 @@ function crossModelOrder(mapping, modelPlans, resolvedKeyModels) {
19773
20226
  const notScan = (model, why) => {
19774
20227
  if (!notScanned.some((item) => item.model === model)) notScanned.push({ model, why });
19775
20228
  };
19776
- for (const mm of mapping.models) {
20229
+ for (const mm of mapping2.models) {
19777
20230
  if (duplicated.has(mm.model)) {
19778
20231
  notScan(mm.model, WHY_DUPLICATE_ENTRIES);
19779
20232
  continue;
@@ -19921,8 +20374,8 @@ function planModel(mm, tables, indexes, entry, indexError, keyFieldsByModel, res
19921
20374
  const blocked = /* @__PURE__ */ new Map();
19922
20375
  const block = (code) => {
19923
20376
  for (const group of PREMISE_BLOCKS2[code]) {
19924
- const list = blocked.get(group);
19925
- if (list) list.push(code);
20377
+ const list2 = blocked.get(group);
20378
+ if (list2) list2.push(code);
19926
20379
  else blocked.set(group, [code]);
19927
20380
  }
19928
20381
  };
@@ -19992,9 +20445,9 @@ function planModel(mm, tables, indexes, entry, indexError, keyFieldsByModel, res
19992
20445
  const got = rowKey(row, assign, keyFields, indexes, keyFieldsByModel, resolvedKeyModels);
19993
20446
  keys.push(got.key);
19994
20447
  if (got.key === null) {
19995
- const list = byCode.get(got.code) ?? [];
19996
- list.push(`\u7B2C ${rowNo(mm, i)} \u884C\uFF08${got.why}\uFF09`);
19997
- byCode.set(got.code, list);
20448
+ const list2 = byCode.get(got.code) ?? [];
20449
+ list2.push(`\u7B2C ${rowNo(mm, i)} \u884C\uFF08${got.why}\uFF09`);
20450
+ byCode.set(got.code, list2);
19998
20451
  }
19999
20452
  });
20000
20453
  const listed3 = (items) => items.slice(0, MAX_LISTED).join("\u3001") + (items.length > MAX_LISTED ? `\u2026\uFF08\u5171 ${items.length} \u884C\uFF09` : "");
@@ -20028,8 +20481,8 @@ function planModel(mm, tables, indexes, entry, indexError, keyFieldsByModel, res
20028
20481
  keys.forEach((key, i) => {
20029
20482
  if (key === null) return;
20030
20483
  const enc = encodeKeyTuple(key);
20031
- const list = positions.get(enc);
20032
- if (list) list.push(i);
20484
+ const list2 = positions.get(enc);
20485
+ if (list2) list2.push(i);
20033
20486
  else positions.set(enc, [i]);
20034
20487
  });
20035
20488
  const duplicated = [...positions].filter(([, spots]) => spots.length > 1).map(([enc, spots]) => ({ enc, spots, parts: keys[spots[0]] })).sort((a, b) => compareParts(a.parts, b.parts));
@@ -20295,24 +20748,24 @@ function rowCycles(parents) {
20295
20748
  const cycles = [];
20296
20749
  for (const start of [...parents.keys()].sort((a, b) => a - b)) {
20297
20750
  if (done.has(start)) continue;
20298
- const path24 = [];
20751
+ const path25 = [];
20299
20752
  const seen = /* @__PURE__ */ new Map();
20300
20753
  let node = start;
20301
20754
  while (node !== void 0 && !seen.has(node) && !done.has(node)) {
20302
- seen.set(node, path24.length);
20303
- path24.push(node);
20755
+ seen.set(node, path25.length);
20756
+ path25.push(node);
20304
20757
  node = parents.get(node);
20305
20758
  }
20306
- if (node !== void 0 && seen.has(node)) cycles.push(path24.slice(seen.get(node)));
20307
- for (const n of path24) done.add(n);
20759
+ if (node !== void 0 && seen.has(node)) cycles.push(path25.slice(seen.get(node)));
20760
+ for (const n of path25) done.add(n);
20308
20761
  }
20309
20762
  return cycles;
20310
20763
  }
20311
20764
  function withDescendants(excluded, parents) {
20312
20765
  const children = /* @__PURE__ */ new Map();
20313
20766
  for (const [child, parent] of parents) {
20314
- const list = children.get(parent);
20315
- if (list) list.push(child);
20767
+ const list2 = children.get(parent);
20768
+ if (list2) list2.push(child);
20316
20769
  else children.set(parent, [child]);
20317
20770
  }
20318
20771
  const out = new Map(excluded);
@@ -20356,8 +20809,8 @@ function waveLevels(parents, excluded, count) {
20356
20809
  function buildWaves(mm, rows, keys, levels, assign, selfRef, parentValues, parents, index, checkExistence, indexes, keyFieldsByModel, resolvedKeyModels) {
20357
20810
  const byLevel = /* @__PURE__ */ new Map();
20358
20811
  for (const [i, lv] of levels) {
20359
- const list = byLevel.get(lv);
20360
- if (list) list.push(i);
20812
+ const list2 = byLevel.get(lv);
20813
+ if (list2) list2.push(i);
20361
20814
  else byLevel.set(lv, [i]);
20362
20815
  }
20363
20816
  const waves = [];
@@ -20659,7 +21112,7 @@ var NEEDS_SHEET = [
20659
21112
  ];
20660
21113
  function whyNoSheetNoChecks(sourceFile) {
20661
21114
  const workbook = SHEETED_SUFFIXES.includes(
20662
- path15.extname(sourceFile).toLowerCase()
21115
+ path16.extname(sourceFile).toLowerCase()
20663
21116
  );
20664
21117
  let text3 = `\u{1F534} \u4F9D\u8D56\u8FD9\u4EFD sheet \u7684 ${NEEDS_SHEET.length} \u7EC4\u5224\u636E**\u4E00\u7EC4\u90FD\u6CA1\u8DD1**\uFF1A${NEEDS_SHEET.join("\uFF1B")}`;
20665
21118
  if (!workbook) {
@@ -20743,7 +21196,7 @@ function unsafeRelReason(rel) {
20743
21196
  if (hasDotDotComponent(rel)) {
20744
21197
  return `\u542B \`..\` \u5206\u91CF\uFF0C\u4F1A\u8BFB\u5230 recon \u4EA7\u7269\u76EE\u5F55\u4E4B\u5916\uFF1A${JSON.stringify(rel)}`;
20745
21198
  }
20746
- if (path15.isAbsolute(rel) || rel.startsWith("/") || rel.startsWith("\\")) {
21199
+ if (path16.isAbsolute(rel) || rel.startsWith("/") || rel.startsWith("\\")) {
20747
21200
  return `\u662F\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u662F recon \u4EA7\u7269\u91CC\u7684\u76F8\u5BF9\u4F4D\u7F6E\uFF1A${JSON.stringify(rel)}`;
20748
21201
  }
20749
21202
  return null;
@@ -20771,7 +21224,7 @@ var ReconView = class {
20771
21224
  resolve(rel) {
20772
21225
  const reason = unsafeRelReason(rel);
20773
21226
  if (reason !== null) return { file: null, reason };
20774
- const file = path15.join(this.dir, rel);
21227
+ const file = path16.join(this.dir, rel);
20775
21228
  if (!isInside(realOf(file), realOf(this.dir))) {
20776
21229
  return { file: null, reason: `\u89E3\u6790\u4E4B\u540E\u843D\u5728 recon \u4EA7\u7269\u76EE\u5F55\u4E4B\u5916\uFF1A${file}` };
20777
21230
  }
@@ -20783,7 +21236,7 @@ var ReconView = class {
20783
21236
  if (!isFile(file)) return { body: null, failure: "missing", detail: `${file} \u4E0D\u5B58\u5728` };
20784
21237
  let text3;
20785
21238
  try {
20786
- text3 = decodeUtf8(readFileSync6(file));
21239
+ text3 = decodeUtf82(readFileSync6(file));
20787
21240
  } catch (e) {
20788
21241
  const why = e instanceof Utf8Error ? `${file} \u4E0D\u662F UTF-8 \u7F16\u7801` : `${file} \u8BFB\u4E0D\u4E86\uFF1A${e.message}`;
20789
21242
  return { body: null, failure: "unreadable", detail: why };
@@ -20804,7 +21257,7 @@ var ReconView = class {
20804
21257
  const cached = this.sheets.get(modelKey);
20805
21258
  if (cached !== void 0) return cached;
20806
21259
  const rel = `${MAPPING_SUBDIR}/${modelKey}.json`;
20807
- const got = { ...this.readJson(rel), path: path15.join(this.dir, rel) };
21260
+ const got = { ...this.readJson(rel), path: path16.join(this.dir, rel) };
20808
21261
  this.sheets.set(modelKey, got);
20809
21262
  return got;
20810
21263
  }
@@ -20855,7 +21308,7 @@ var ReconView = class {
20855
21308
  if (!isFile(file)) return { index: null, failure: "missing", detail: `${file} \u4E0D\u5B58\u5728` };
20856
21309
  let text3;
20857
21310
  try {
20858
- text3 = decodeUtf8(readFileSync6(file));
21311
+ text3 = decodeUtf82(readFileSync6(file));
20859
21312
  } catch (e) {
20860
21313
  const why = e instanceof Utf8Error ? `${file} \u4E0D\u662F UTF-8 \u7F16\u7801` : `${file} \u8BFB\u4E0D\u4E86\uFF1A${e.message}`;
20861
21314
  return { index: null, failure: "unreadable", detail: why };
@@ -20890,7 +21343,7 @@ function enumKey(model, field) {
20890
21343
  }
20891
21344
  var Utf8Error = class extends Error {
20892
21345
  };
20893
- function decodeUtf8(bytes2) {
21346
+ function decodeUtf82(bytes2) {
20894
21347
  try {
20895
21348
  return new TextDecoder("utf-8", { fatal: true }).decode(bytes2).replace(/^\uFEFF/, "");
20896
21349
  } catch {
@@ -20899,21 +21352,21 @@ function decodeUtf8(bytes2) {
20899
21352
  }
20900
21353
  function isFile(p) {
20901
21354
  try {
20902
- return statSync6(p).isFile();
21355
+ return statSync5(p).isFile();
20903
21356
  } catch {
20904
21357
  return false;
20905
21358
  }
20906
21359
  }
20907
21360
  function realOf(p) {
20908
21361
  const rest = [];
20909
- let cur = path15.resolve(p);
21362
+ let cur = path16.resolve(p);
20910
21363
  for (; ; ) {
20911
21364
  try {
20912
- return path15.join(realpathSync(cur), ...rest);
21365
+ return path16.join(realpathSync(cur), ...rest);
20913
21366
  } catch {
20914
- const parent = path15.dirname(cur);
20915
- if (parent === cur) return path15.resolve(p);
20916
- rest.unshift(path15.basename(cur));
21367
+ const parent = path16.dirname(cur);
21368
+ if (parent === cur) return path16.resolve(p);
21369
+ rest.unshift(path16.basename(cur));
20917
21370
  cur = parent;
20918
21371
  }
20919
21372
  }
@@ -21511,7 +21964,7 @@ function noteProblems(notes) {
21511
21964
  const model = n.model;
21512
21965
  const file = n.file;
21513
21966
  const column = n.column;
21514
- const suffix = typeof file === "string" ? path15.extname(file).toLowerCase() : "";
21967
+ const suffix = typeof file === "string" ? path16.extname(file).toLowerCase() : "";
21515
21968
  const notation = NOTATION_BY_SUFFIX[suffix] ?? NOTATION_UNKNOWN;
21516
21969
  out.push(
21517
21970
  problem3(
@@ -21681,7 +22134,7 @@ function riskModel(mm, entry, recon, tables, plan = null) {
21681
22134
  );
21682
22135
  block("AC6_PREMISE_SOURCE_ROWS_EMPTY");
21683
22136
  }
21684
- if (!SHEETED_SUFFIXES.includes(path15.extname(mm.source.file).toLowerCase())) {
22137
+ if (!SHEETED_SUFFIXES.includes(path16.extname(mm.source.file).toLowerCase())) {
21685
22138
  notApplicable.set(CHECK_DATE_SERIAL, WHY_NOT_A_WORKBOOK);
21686
22139
  } else if (rows === void 0) {
21687
22140
  block(WHY_NO_SOURCE_ROWS, [CHECK_DATE_SERIAL]);
@@ -21892,14 +22345,14 @@ function checksSkipped(models, provided) {
21892
22345
  }
21893
22346
  return false;
21894
22347
  }
21895
- function buildRisk(mapping, reconDir, options = {}) {
22348
+ function buildRisk(mapping2, reconDir, options = {}) {
21896
22349
  const recon = new ReconView(reconDir);
21897
22350
  const notesGiven = options.notes !== void 0 && options.notes !== null;
21898
22351
  const exemptionsGiven = options.exemptions !== void 0 && options.exemptions !== null;
21899
22352
  const roundGiven = options.roundPremise !== void 0 && options.roundPremise !== null;
21900
22353
  let problems = [];
21901
22354
  const models = [];
21902
- mapping.models.forEach((mm, entry) => {
22355
+ mapping2.models.forEach((mm, entry) => {
21903
22356
  const got = riskModel(mm, entry, recon, options.tables ?? null, options.plan ?? null);
21904
22357
  models.push(got.model);
21905
22358
  problems.push(...got.problems);
@@ -21940,20 +22393,20 @@ var MAPPING_FILE = "mapping.json";
21940
22393
  var OFFLINE_COMMANDS = ["find", "values"];
21941
22394
  function seedWorkDir(args) {
21942
22395
  if (args.work) return args.work;
21943
- return path16.join(args.out, WORK_DIRNAME, tenantSegment(String(args.tenant)));
22396
+ return path17.join(args.out, WORK_DIRNAME, tenantSegment(String(args.tenant)));
21944
22397
  }
21945
22398
  function seedMappingPath(args, work) {
21946
- return args.mapping ? args.mapping : path16.join(work, MAPPING_FILE);
22399
+ return args.mapping ? args.mapping : path17.join(work, MAPPING_FILE);
21947
22400
  }
21948
22401
  function seedBaselines(out, tenant) {
21949
- const base = path16.join(out, "recon", tenantSegment(String(tenant)));
21950
- if (!existsSync8(base) || !statSync7(base).isDirectory()) return [base, []];
22402
+ const base = path17.join(out, "recon", tenantSegment(String(tenant)));
22403
+ if (!existsSync7(base) || !statSync6(base).isDirectory()) return [base, []];
21951
22404
  const found = [];
21952
22405
  for (const name of readdirSync2(base).sort()) {
21953
- const reconDir = path16.join(base, name);
21954
- if (!statSync7(reconDir).isDirectory()) continue;
21955
- const indexFile = path16.join(reconDir, "index", "fields.jsonl");
21956
- if (existsSync8(indexFile)) found.push({ indexFile, reconDir });
22406
+ const reconDir = path17.join(base, name);
22407
+ if (!statSync6(reconDir).isDirectory()) continue;
22408
+ const indexFile = path17.join(reconDir, "index", "fields.jsonl");
22409
+ if (existsSync7(indexFile)) found.push({ indexFile, reconDir });
21957
22410
  }
21958
22411
  return [base, found];
21959
22412
  }
@@ -22048,7 +22501,7 @@ var JOURNAL_STOP_UNKNOWN = [
22048
22501
  ""
22049
22502
  ];
22050
22503
  function journalNote(journalPath, whenPresent = "") {
22051
- if (!existsSync8(journalPath)) {
22504
+ if (!existsSync7(journalPath)) {
22052
22505
  return ` \u53F0\u8D26 \`${journalPath}\` **\u6B64\u523B\u4E0D\u5728\u76D8\u4E0A**\uFF08\u672C\u5C42\u521A\u67E5\u8FC7\uFF09\u2014\u2014\u6240\u4EE5\u6CA1\u6709\u300C\u5DF2\u7ECF\u8BB0\u4E0B\u6765\u7684\u5199\u300D\u53EF\u4EE5\u62FF\u3002`;
22053
22506
  }
22054
22507
  return ` \u53F0\u8D26\u5728 \`${journalPath}\`\u3002${whenPresent}`;
@@ -22084,7 +22537,7 @@ function existingJournalStop(journalPath, entries) {
22084
22537
  }
22085
22538
 
22086
22539
  // src/fde/seed/plan-io.ts
22087
- import * as path17 from "path";
22540
+ import * as path18 from "path";
22088
22541
  var PLAN_JSON_KEYS = [
22089
22542
  "version",
22090
22543
  "roundId",
@@ -22110,9 +22563,9 @@ function fromArtifactProblem(p) {
22110
22563
  async function planFromArtifacts(client, mappingPath, sourceDir, options = {}) {
22111
22564
  const baseline = options.baseline ?? null;
22112
22565
  const loadIndex = options.loadKeyIndexImpl ?? loadKeyIndex;
22113
- const mapping = loadMapping(mappingPath);
22114
- const scan = await scanSources(mapping, sourceDir);
22115
- const problems = [...scan.problems, ...validateMapping(mapping, scan.headers)];
22566
+ const mapping2 = loadMapping(mappingPath);
22567
+ const scan = await scanSources(mapping2, sourceDir);
22568
+ const problems = [...scan.problems, ...validateMapping(mapping2, scan.headers)];
22116
22569
  if (problems.length) {
22117
22570
  const converted = problems.map(fromArtifactProblem);
22118
22571
  converted.push({
@@ -22135,7 +22588,7 @@ async function planFromArtifacts(client, mappingPath, sourceDir, options = {}) {
22135
22588
  }
22136
22589
  const indexes = /* @__PURE__ */ new Map();
22137
22590
  const indexErrors = /* @__PURE__ */ new Map();
22138
- for (const mm of mapping.models) {
22591
+ for (const mm of mapping2.models) {
22139
22592
  if (mm.businessKey === null || !mm.businessKey.fields.length) continue;
22140
22593
  try {
22141
22594
  indexes.set(mm.model, await loadIndex(client, mm.model, [...mm.businessKey.fields]));
@@ -22144,7 +22597,7 @@ async function planFromArtifacts(client, mappingPath, sourceDir, options = {}) {
22144
22597
  indexErrors.set(mm.model, e.hint ? e.message : `${e.message} \u2014\u2014 \u5148\u628A\u53D6\u6570\u95EE\u9898\u89E3\u51B3\u518D\u8DD1\u4E00\u6B21`);
22145
22598
  }
22146
22599
  }
22147
- return buildImportPlan(mapping, scan.rows, indexes, {
22600
+ return buildImportPlan(mapping2, scan.rows, indexes, {
22148
22601
  notes: [...scan.notes],
22149
22602
  indexErrors,
22150
22603
  baseline
@@ -22221,7 +22674,7 @@ var PlanReadError = class extends Error {
22221
22674
  };
22222
22675
  function readImportPlan(out) {
22223
22676
  const work = new WorkLayout(out);
22224
- const target = path17.join(out, IMPORT_PLAN_FILE);
22677
+ const target = path18.join(out, IMPORT_PLAN_FILE);
22225
22678
  if (!work.exists(IMPORT_PLAN_FILE)) {
22226
22679
  throw new PlanReadError(
22227
22680
  "plan-missing",
@@ -22413,9 +22866,9 @@ function rowFromJson(r) {
22413
22866
 
22414
22867
  // src/fde/seed/journal.ts
22415
22868
  import { createHash as createHash4 } from "crypto";
22416
- import { existsSync as existsSync9, statSync as statSync8 } from "fs";
22869
+ import { existsSync as existsSync8, statSync as statSync7 } from "fs";
22417
22870
  import * as os3 from "os";
22418
- import * as path18 from "path";
22871
+ import * as path19 from "path";
22419
22872
  var JOURNAL_FILE = "journal.jsonl";
22420
22873
  var STATUSES = ["done", "skipped", "failed", "unknown", "quarantined"];
22421
22874
  var STEP_SEND = "send";
@@ -22662,7 +23115,7 @@ function waiverFromJson(row, where) {
22662
23115
  };
22663
23116
  }
22664
23117
  function workDirOf(p) {
22665
- if (existsSync9(p) && !statSync8(p).isDirectory()) {
23118
+ if (existsSync8(p) && !statSync7(p).isDirectory()) {
22666
23119
  throw new JournalError(
22667
23120
  "not-a-work-dir",
22668
23121
  `${p} \u5DF2\u5B58\u5728\uFF0C\u4F46\u5B83\u4E0D\u662F\u76EE\u5F55 \u2014\u2014 \u53F0\u8D26\u6536\u7684\u662F **work \u76EE\u5F55**\uFF0C\u4E0D\u662F\u53F0\u8D26\u6587\u4EF6`,
@@ -22689,7 +23142,7 @@ var Journal = class _Journal {
22689
23142
  constructor(workDir, entries = [], exists = false, waivers = []) {
22690
23143
  this.workDir = workDirOf(workDir);
22691
23144
  this.layout = new WorkLayout(this.workDir);
22692
- this.path = path18.join(this.workDir, JOURNAL_FILE);
23145
+ this.path = path19.join(this.workDir, JOURNAL_FILE);
22693
23146
  this.entries = [...entries];
22694
23147
  this.waivers = [...waivers];
22695
23148
  this.exists = exists;
@@ -22703,8 +23156,8 @@ var Journal = class _Journal {
22703
23156
  */
22704
23157
  static load(p) {
22705
23158
  const work = workDirOf(p);
22706
- const target = path18.join(work, JOURNAL_FILE);
22707
- if (!existsSync9(target)) return new _Journal(work, [], false);
23159
+ const target = path19.join(work, JOURNAL_FILE);
23160
+ if (!existsSync8(target)) return new _Journal(work, [], false);
22708
23161
  let text3;
22709
23162
  try {
22710
23163
  text3 = new WorkLayout(work).readText(JOURNAL_FILE);
@@ -22999,8 +23452,8 @@ function sameIdentity(a, b) {
22999
23452
  return a.length === b.length && a.every((x, i) => x === b[i]);
23000
23453
  }
23001
23454
  function readLease(layout, file = LEASE_FILE) {
23002
- const p = path18.join(layout.dir, file);
23003
- if (!existsSync9(p)) return [null, `${p} \u4E0D\u5B58\u5728`];
23455
+ const p = path19.join(layout.dir, file);
23456
+ if (!existsSync8(p)) return [null, `${p} \u4E0D\u5B58\u5728`];
23004
23457
  let text3;
23005
23458
  try {
23006
23459
  text3 = layout.readText(file);
@@ -23058,7 +23511,7 @@ var Lease = class {
23058
23511
  beatMark;
23059
23512
  constructor(layout, spec, reclaimed = null, clock = SYSTEM_CLOCK) {
23060
23513
  this.layout = layout;
23061
- this.path = path18.join(layout.dir, LEASE_FILE);
23514
+ this.path = path19.join(layout.dir, LEASE_FILE);
23062
23515
  this.host = spec.host;
23063
23516
  this.pid = spec.pid;
23064
23517
  this.roundId = spec.roundId;
@@ -23126,7 +23579,7 @@ var Lease = class {
23126
23579
  throw new LeaseViolation(
23127
23580
  "lease-unwritable",
23128
23581
  `\u76D6\u5FC3\u8DF3\u65F6\u5199\u4E0D\u8FDB\u79DF\u7EA6\u6587\u4EF6 ${this.path}\uFF1A${String(e)}`,
23129
- `**\u8FD9\u4E00\u6B21\u5FC3\u8DF3\u6CA1\u6709\u76D6\u4E0A**\uFF0C\u79DF\u7EA6\u6587\u4EF6\u7684\u5185\u5BB9**\u6CA1\u6709\u88AB\u6539\u52A8**\uFF08\u4E34\u65F6\u6587\u4EF6\u5DF2\u6536\u62FE\u6389\uFF0C\u6539\u540D\u6CA1\u9876\u4E0A\u53BB\uFF09\u3002${leaseStampNote(held.heartbeatAt, beat, attemptedAt)}\u5199\u4E4B\u524D\u521A\u6838\u5BF9\u8FC7\u8EAB\u4EFD \u2014\u2014 **\u90A3\u4E00\u6B21\u8BFB\u5230\u7684**\u79DF\u7EA6\u662F\u6211\u65B9\u7684\u3002\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u78C1\u76D8\u6EE1\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u4ECB\u8D28\u51FA\u9519\u3002**\u5148\u505C\u624B\u518D\u5904\u7406**\uFF1A\u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\u90FD\u8BB0\u5728 ${path18.dirname(this.path)} \u7684\u53F0\u8D26\u91CC\uFF08\u5199\u524D\u843D\u8D26\uFF1A\u53D1\u8BF7\u6C42\u4E4B\u524D\u5148 begin \u843D\u4E00\u6761 unknown\uFF09\u3002${LEASE_JUDGE_SIGNPOST}`
23582
+ `**\u8FD9\u4E00\u6B21\u5FC3\u8DF3\u6CA1\u6709\u76D6\u4E0A**\uFF0C\u79DF\u7EA6\u6587\u4EF6\u7684\u5185\u5BB9**\u6CA1\u6709\u88AB\u6539\u52A8**\uFF08\u4E34\u65F6\u6587\u4EF6\u5DF2\u6536\u62FE\u6389\uFF0C\u6539\u540D\u6CA1\u9876\u4E0A\u53BB\uFF09\u3002${leaseStampNote(held.heartbeatAt, beat, attemptedAt)}\u5199\u4E4B\u524D\u521A\u6838\u5BF9\u8FC7\u8EAB\u4EFD \u2014\u2014 **\u90A3\u4E00\u6B21\u8BFB\u5230\u7684**\u79DF\u7EA6\u662F\u6211\u65B9\u7684\u3002\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u78C1\u76D8\u6EE1\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u4ECB\u8D28\u51FA\u9519\u3002**\u5148\u505C\u624B\u518D\u5904\u7406**\uFF1A\u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\u90FD\u8BB0\u5728 ${path19.dirname(this.path)} \u7684\u53F0\u8D26\u91CC\uFF08\u5199\u524D\u843D\u8D26\uFF1A\u53D1\u8BF7\u6C42\u4E4B\u524D\u5148 begin \u843D\u4E00\u6761 unknown\uFF09\u3002${LEASE_JUDGE_SIGNPOST}`
23130
23583
  );
23131
23584
  }
23132
23585
  this.beatMark = this.clock.monotonic();
@@ -23172,7 +23625,7 @@ function acquireLease(workDir, roundId, clock = SYSTEM_CLOCK) {
23172
23625
  );
23173
23626
  }
23174
23627
  const layout = new WorkLayout(workDirOf(workDir));
23175
- const p = path18.join(layout.dir, LEASE_FILE);
23628
+ const p = path19.join(layout.dir, LEASE_FILE);
23176
23629
  const me = [hostname2(), process.pid, roundId];
23177
23630
  const now = clock.now();
23178
23631
  const fresh = new Lease(
@@ -23374,7 +23827,7 @@ var ACTION_HINTS = {
23374
23827
  function listed2(items, total) {
23375
23828
  return `${items.slice(0, MAX_LISTED3).join("\uFF1B")}${total > MAX_LISTED3 ? `\u2026\uFF08\u5171 ${total} \u6761\uFF09` : ""}`;
23376
23829
  }
23377
- function preflight(plan, mapping) {
23830
+ function preflight(plan, mapping2) {
23378
23831
  const out = [];
23379
23832
  if (plan.problems.length > 0) {
23380
23833
  const codes = [...new Set(plan.problems.map((p) => p.code))].sort();
@@ -23388,7 +23841,7 @@ function preflight(plan, mapping) {
23388
23841
  );
23389
23842
  }
23390
23843
  const plannedModels = plan.models.map((m) => m.model);
23391
- const artifactModels = mapping.models.map((m) => m.model);
23844
+ const artifactModels = mapping2.models.map((m) => m.model);
23392
23845
  if (JSON.stringify(plannedModels) !== JSON.stringify(artifactModels)) {
23393
23846
  out.push(
23394
23847
  problem4(
@@ -23400,7 +23853,7 @@ function preflight(plan, mapping) {
23400
23853
  );
23401
23854
  } else {
23402
23855
  plan.models.forEach((modelPlan, i) => {
23403
- const declared = mapping.models[i].businessKey?.fields ?? [];
23856
+ const declared = mapping2.models[i].businessKey?.fields ?? [];
23404
23857
  if (JSON.stringify(modelPlan.businessKeyFields) !== JSON.stringify([...declared])) {
23405
23858
  out.push(
23406
23859
  problem4(
@@ -23877,7 +24330,7 @@ async function applyRow(client, plan, modelPlan, row, journal, createdIds, tally
23877
24330
  tally.add("requests");
23878
24331
  return judgeCreate(client, out, plan, modelPlan, row, journal, createdIds, tally, problems, sample);
23879
24332
  }
23880
- async function applyPlan(client, plan, mapping, journal, options = {}) {
24333
+ async function applyPlan(client, plan, mapping2, journal, options = {}) {
23881
24334
  const dryRun = options.dryRun ?? true;
23882
24335
  const sample = options.sample ?? null;
23883
24336
  const onRequestSpent = options.onRequestSpent ?? null;
@@ -23902,7 +24355,7 @@ async function applyPlan(client, plan, mapping, journal, options = {}) {
23902
24355
  "\u5B83\u662F\u6BCF\u82B1\u6389\u4E00\u6B21\u8BF7\u6C42\u8981\u76D6\u7684\u90A3\u4E00\u6B21\u7AE0\uFF08\u751F\u4EA7\u4E0A = `Lease.heartbeatIfDue`\uFF09\u3002\u4E0D\u60F3\u76D6\u5C31\u4F20 null \u2014\u2014 \u4F20\u4E00\u4E2A\u8C03\u4E0D\u52A8\u7684\u4E1C\u897F\u4F1A\u5728\u7B2C\u4E00\u6B21\u8BF7\u6C42\u53D1\u51FA\u53BB\u4E4B\u540E\u70B8\u5728\u534A\u8DEF\u4E0A\uFF0C\u800C\u90A3\u4E00\u6B21\u8BF7\u6C42\u5DF2\u7ECF\u51FA\u53BB\u4E86"
23903
24356
  );
23904
24357
  }
23905
- const problems = preflight(plan, mapping);
24358
+ const problems = preflight(plan, mapping2);
23906
24359
  if (problems.length > 0) {
23907
24360
  return reportOf(plan, dryRun, sample, false, "preflight", [], new Tally(), problems);
23908
24361
  }
@@ -23994,8 +24447,8 @@ function applyReportText(report) {
23994
24447
  }
23995
24448
 
23996
24449
  // src/fde/seed/drift.ts
23997
- import { existsSync as existsSync10, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync9 } from "fs";
23998
- import * as path19 from "path";
24450
+ import { existsSync as existsSync9, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync8 } from "fs";
24451
+ import * as path20 from "path";
23999
24452
  var VERDICT_SAME = "same";
24000
24453
  var VERDICT_DIVERGED = "diverged";
24001
24454
  var VERDICT_INCOMPARABLE = "incomparable";
@@ -24022,21 +24475,21 @@ function resolveBaselineDir(outRoot, baselineRef) {
24022
24475
  return [null, CAUSE_PLAN_HAS_NO_BASELINE];
24023
24476
  }
24024
24477
  const ref = String(baselineRef);
24025
- const root = path19.join(outRoot, RECON_DIRNAME);
24478
+ const root = path20.join(outRoot, RECON_DIRNAME);
24026
24479
  const parts = ref.split(/[\\/]+/);
24027
- if (!ref || parts.includes("..") || path19.isAbsolute(ref) || /^[A-Za-z]:/.test(ref)) {
24480
+ if (!ref || parts.includes("..") || path20.isAbsolute(ref) || /^[A-Za-z]:/.test(ref)) {
24028
24481
  return [null, CAUSE_BASELINE_NOT_ON_DISK];
24029
24482
  }
24030
- const base = path19.join(root, ref);
24483
+ const base = path20.join(root, ref);
24031
24484
  let inside;
24032
24485
  try {
24033
24486
  const realRoot = realpathSync2(root);
24034
24487
  const realBase = realpathSync2(base);
24035
- inside = realBase === realRoot || realBase.startsWith(realRoot + path19.sep);
24488
+ inside = realBase === realRoot || realBase.startsWith(realRoot + path20.sep);
24036
24489
  } catch {
24037
24490
  inside = false;
24038
24491
  }
24039
- if (!inside || !existsSync10(base) || !statSync9(base).isDirectory()) {
24492
+ if (!inside || !existsSync9(base) || !statSync8(base).isDirectory()) {
24040
24493
  return [null, CAUSE_BASELINE_NOT_ON_DISK];
24041
24494
  }
24042
24495
  return [base, null];
@@ -24046,7 +24499,7 @@ function loadRecordedFingerprint(outRoot, baselineRef) {
24046
24499
  if (cause !== null) return [null, cause];
24047
24500
  let body;
24048
24501
  try {
24049
- body = JSON.parse(readFileSync8(path19.join(base, FINGERPRINT_FILE), "utf-8"));
24502
+ body = JSON.parse(readFileSync8(path20.join(base, FINGERPRINT_FILE), "utf-8"));
24050
24503
  } catch {
24051
24504
  return [null, CAUSE_FINGERPRINT_UNREADABLE];
24052
24505
  }
@@ -24797,11 +25250,11 @@ function fromArtifactProblem2(p) {
24797
25250
  };
24798
25251
  }
24799
25252
  async function riskFromArtifacts(mappingPath, reconDir, options = {}) {
24800
- const mapping = loadMapping(mappingPath);
24801
- const scan = await scanSources(mapping, options.sourceDir);
24802
- const problems = [...scan.problems, ...validateMapping(mapping, scan.headers)];
25253
+ const mapping2 = loadMapping(mappingPath);
25254
+ const scan = await scanSources(mapping2, options.sourceDir);
25255
+ const problems = [...scan.problems, ...validateMapping(mapping2, scan.headers)];
24803
25256
  if (problems.length === 0) {
24804
- return buildRisk(mapping, reconDir, {
25257
+ return buildRisk(mapping2, reconDir, {
24805
25258
  notes: [...scan.notes],
24806
25259
  tables: scan.rows,
24807
25260
  exemptions: options.exemptions,
@@ -24895,8 +25348,8 @@ function writeRisk(risk, out) {
24895
25348
  }
24896
25349
 
24897
25350
  // src/fde/seed/value-hints.ts
24898
- import { existsSync as existsSync11, readFileSync as readFileSync9 } from "fs";
24899
- import * as path20 from "path";
25351
+ import { existsSync as existsSync10, readFileSync as readFileSync9 } from "fs";
25352
+ import * as path21 from "path";
24900
25353
  var HINT_REF = (domain) => ` \u503C\uFF1A\u586B id\uFF08\u4E0D\u662F code\uFF09\u2190 ${domain}`;
24901
25354
  var HINT_NO_DOMAIN = (to) => ` \u503C\uFF1A\u586B ${to} \u7684 id\uFF08\u4E0D\u662F code\uFF09\uFF1B\u65E0\u5BF9\u7167\u8868\uFF0C\u6309\u4E1A\u52A1\u952E\u73B0\u67E5`;
24902
25355
  var HINT_ENUM = (n, model) => ` \u503C\uFF1A\u679A\u4E3E ${n} \u9879 \u2190 mapping/${model}.json`;
@@ -24912,7 +25365,7 @@ function isLocalName(name) {
24912
25365
  if (typeof name !== "string" || name.length === 0) return false;
24913
25366
  if (name.includes("/") || name.includes("\\")) return false;
24914
25367
  if (name === "." || name === "..") return false;
24915
- return !path20.isAbsolute(name);
25368
+ return !path21.isAbsolute(name);
24916
25369
  }
24917
25370
  var readJson = (file) => {
24918
25371
  try {
@@ -24932,7 +25385,7 @@ var ValueHints = class {
24932
25385
  /** → `{modelKey: completeness}`;**索引根本读不到时返回 `null`**(与「读到了但是空的」分开)。 */
24933
25386
  domainIndex() {
24934
25387
  if (this.domains === void 0) {
24935
- const body = readJson(path20.join(this.root, "valuedomain", "_index.json"));
25388
+ const body = readJson(path21.join(this.root, "valuedomain", "_index.json"));
24936
25389
  const by = isRec(body) ? body.byCompleteness : void 0;
24937
25390
  if (!isRec(by)) {
24938
25391
  this.domains = null;
@@ -24953,7 +25406,7 @@ var ValueHints = class {
24953
25406
  if (!this.sheets.has(key)) {
24954
25407
  let fields = null;
24955
25408
  if (isLocalName(key)) {
24956
- const body = readJson(path20.join(this.root, "mapping", `${key}.json`));
25409
+ const body = readJson(path21.join(this.root, "mapping", `${key}.json`));
24957
25410
  const rows = isRec(body) ? body.fields : void 0;
24958
25411
  if (Array.isArray(rows)) {
24959
25412
  fields = /* @__PURE__ */ new Map();
@@ -24971,7 +25424,7 @@ var ValueHints = class {
24971
25424
  const index = this.domainIndex();
24972
25425
  const completeness = index === null ? void 0 : index.get(target);
24973
25426
  const pointer = ref.valueDomain;
24974
- const landed = isLocalName(target) && existsSync11(path20.join(this.root, "valuedomain", `${target}.json`));
25427
+ const landed = isLocalName(target) && existsSync10(path21.join(this.root, "valuedomain", `${target}.json`));
24975
25428
  let line;
24976
25429
  if (pointer && completeness && completeness !== "unavailable" && landed) {
24977
25430
  line = HINT_REF(String(pointer));
@@ -25161,8 +25614,8 @@ function renderFind(hits, term, total, options = {}) {
25161
25614
  }
25162
25615
 
25163
25616
  // src/fde/seed/values.ts
25164
- import { existsSync as existsSync12, readFileSync as readFileSync10 } from "fs";
25165
- import * as path21 from "path";
25617
+ import { existsSync as existsSync11, readFileSync as readFileSync10 } from "fs";
25618
+ import * as path22 from "path";
25166
25619
  var readJson2 = (file) => {
25167
25620
  try {
25168
25621
  return JSON.parse(readFileSync10(file, "utf-8"));
@@ -25209,13 +25662,13 @@ function valuesRoundCaveat(round) {
25209
25662
  return VALUES_ROUND_MIXED(String(state ?? "unknown"));
25210
25663
  }
25211
25664
  function renderValues(root, model, options = {}) {
25212
- const indexBody = readJson2(path21.join(root, "valuedomain", "_index.json"));
25665
+ const indexBody = readJson2(path22.join(root, "valuedomain", "_index.json"));
25213
25666
  const byCompleteness = isRec2(indexBody) ? indexBody.byCompleteness : void 0;
25214
25667
  if (!isRec2(byCompleteness)) {
25215
25668
  return {
25216
25669
  ok: false,
25217
25670
  kind: "index-unreadable",
25218
- message: `\u8BFB\u4E0D\u5230 valuedomain/_index.json\uFF08${root}\uFF09\u2014\u2014 \u53EF\u80FD\u662F\uFF1A\u8FD9\u4EFD\u57FA\u7EBF\u7531\u66F4\u65E9\u7248\u672C\u722C\u7684\u3001\u4F60\u6CA1\u62F7 valuedomain/ \u76EE\u5F55\u8FC7\u6765\u3001\u6216\u8005\u90A3\u4E2A\u6587\u4EF6\u574F\u4E86\u3002\u5148 \`ls ${path21.join(root, "valuedomain")}\` \u770B\u4E00\u773C\uFF1B\u786E\u5B9E\u6CA1\u6709\u5C31\u91CD\u8DD1\u4E00\u6B21 recon\u3002`
25671
+ message: `\u8BFB\u4E0D\u5230 valuedomain/_index.json\uFF08${root}\uFF09\u2014\u2014 \u53EF\u80FD\u662F\uFF1A\u8FD9\u4EFD\u57FA\u7EBF\u7531\u66F4\u65E9\u7248\u672C\u722C\u7684\u3001\u4F60\u6CA1\u62F7 valuedomain/ \u76EE\u5F55\u8FC7\u6765\u3001\u6216\u8005\u90A3\u4E2A\u6587\u4EF6\u574F\u4E86\u3002\u5148 \`ls ${path22.join(root, "valuedomain")}\` \u770B\u4E00\u773C\uFF1B\u786E\u5B9E\u6CA1\u6709\u5C31\u91CD\u8DD1\u4E00\u6B21 recon\u3002`
25219
25672
  };
25220
25673
  }
25221
25674
  let completeness;
@@ -25226,7 +25679,7 @@ function renderValues(root, model, options = {}) {
25226
25679
  }
25227
25680
  }
25228
25681
  if (completeness === void 0) {
25229
- if (isLocalName(model) && existsSync12(path21.join(root, "mapping", `${model}.json`))) {
25682
+ if (isLocalName(model) && existsSync11(path22.join(root, "mapping", `${model}.json`))) {
25230
25683
  return {
25231
25684
  ok: false,
25232
25685
  kind: "not-a-code-table",
@@ -25236,11 +25689,11 @@ function renderValues(root, model, options = {}) {
25236
25689
  return {
25237
25690
  ok: false,
25238
25691
  kind: "model-not-in-baseline",
25239
- message: `\u57FA\u7EBF\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B\uFF1A${model}\u3002\`ls ${path21.join(root, "mapping")}\` \u770B\u6709\u54EA\u4E9B\u3002`
25692
+ message: `\u57FA\u7EBF\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B\uFF1A${model}\u3002\`ls ${path22.join(root, "mapping")}\` \u770B\u6709\u54EA\u4E9B\u3002`
25240
25693
  };
25241
25694
  }
25242
- const file = path21.join(root, "valuedomain", `${model}.json`);
25243
- if (!isLocalName(model) || !existsSync12(file)) {
25695
+ const file = path22.join(root, "valuedomain", `${model}.json`);
25696
+ if (!isLocalName(model) || !existsSync11(file)) {
25244
25697
  return {
25245
25698
  ok: false,
25246
25699
  kind: "file-missing",
@@ -25309,7 +25762,7 @@ var CARRIER_LABELS = {
25309
25762
  "graaljs-spi": "GraalJS SPI \u2014\u2014 \u5F00\u53D1\u7A7A\u95F4\u91CC\u7684\u79DF\u6237\u6269\u5C55\u811A\u672C",
25310
25763
  "flex-data": "\u5F39\u6027\u5B57\u6BB5 \u2014\u2014 \u6302\u5728\u65E2\u6709\u6A21\u578B\u4E0A\u7684\u79DF\u6237\u81EA\u5B9A\u4E49\u5B57\u6BB5",
25311
25764
  "indicator-dashboard": "\u6307\u6807/\u770B\u677F \u2014\u2014 \u6307\u6807\u5E93\u3001\u76EE\u6807\u9608\u503C\u4E0E\u770B\u677F\u5B9A\u4E49\uFF0C\u5206\u6790\u5C42\u7684\u627F\u8F7D\u7269",
25312
- "data-package": "DataPackage \u2014\u2014 \u53EF\u590D\u5236\u7684\u573A\u666F\u6570\u636E\u5305"
25765
+ "data-package": "\u5B89\u88C5\u5305 \u2014\u2014 \u6269\u5C55\u8D44\u4EA7\u4E0E\u53EF\u590D\u5236\u7684\u573A\u666F\u6570\u636E"
25313
25766
  };
25314
25767
  var CARRIER_HIT = "hit";
25315
25768
  var CARRIER_MISS = "miss";
@@ -25354,7 +25807,7 @@ function buildCarrierResult(carrier, verdict2, options = {}) {
25354
25807
 
25355
25808
  // src/fde/triage/probe.ts
25356
25809
  import { readFileSync as readFileSync11 } from "fs";
25357
- import * as path22 from "path";
25810
+ import * as path23 from "path";
25358
25811
  var WORKSPACES_PATH = "/api/tenant-extension/workspaces";
25359
25812
  var MODELS_REL = "models.json";
25360
25813
  var FIELDS_REL = "index/fields.jsonl";
@@ -25381,10 +25834,10 @@ function unavailableCell(carrier, err) {
25381
25834
  });
25382
25835
  }
25383
25836
  function readArtifactJson(dir, rel) {
25384
- return JSON.parse(readFileSync11(path22.join(dir, rel), "utf8"));
25837
+ return JSON.parse(readFileSync11(path23.join(dir, rel), "utf8"));
25385
25838
  }
25386
25839
  function readArtifactJsonl(dir, rel) {
25387
- const body = readFileSync11(path22.join(dir, rel), "utf8");
25840
+ const body = readFileSync11(path23.join(dir, rel), "utf8");
25388
25841
  const rows = [];
25389
25842
  for (const line of body.split("\n")) {
25390
25843
  const trimmed = line.trim();
@@ -25438,8 +25891,8 @@ function probeFlexModel(catalog) {
25438
25891
  }
25439
25892
  return buildCarrierResult("flex-model", CARRIER_HIT, { evidence: hits.slice(0, 20) });
25440
25893
  }
25441
- function isReadOnly(mapping) {
25442
- const mut = mapping && typeof mapping === "object" ? mapping.mutation : null;
25894
+ function isReadOnly(mapping2) {
25895
+ const mut = mapping2 && typeof mapping2 === "object" ? mapping2.mutation : null;
25443
25896
  if (!mut || typeof mut !== "object") return false;
25444
25897
  for (const op of WRITE_OPS) {
25445
25898
  const cell = mut[op];
@@ -25459,13 +25912,13 @@ function probeJsonModel(dir) {
25459
25912
  for (const row of rows) {
25460
25913
  const key = entryKey(row);
25461
25914
  if (key === null) continue;
25462
- let mapping;
25915
+ let mapping2;
25463
25916
  try {
25464
- mapping = readArtifactJson(dir, `mapping/${key}.json`);
25917
+ mapping2 = readArtifactJson(dir, `mapping/${key}.json`);
25465
25918
  } catch {
25466
25919
  continue;
25467
25920
  }
25468
- if (isReadOnly(mapping)) hits.push(key);
25921
+ if (isReadOnly(mapping2)) hits.push(key);
25469
25922
  }
25470
25923
  if (hits.length === 0) {
25471
25924
  return buildCarrierResult("json-model", CARRIER_MISS, {
@@ -25537,12 +25990,12 @@ function probeDataPackage(catalog) {
25537
25990
  const missing = DATA_PACKAGE_MODELS.filter((m) => !present.has(m));
25538
25991
  if (missing.length > 0) {
25539
25992
  return buildCarrierResult("data-package", CARRIER_MISS, {
25540
- note: `\u6A21\u578B\u6E05\u5355\u91CC\u6CA1\u6709 ${missing.join("\u3001")} \u2014\u2014 \u8FD9\u4E2A\u73AF\u5883\u4E0A\u8D70\u4E0D\u4E86\u6570\u636E\u5305\u8FD9\u6761\u8DEF`
25993
+ note: `\u6A21\u578B\u6E05\u5355\u91CC\u6CA1\u6709 ${missing.join("\u3001")} \u2014\u2014 \u8FD9\u4E2A\u73AF\u5883\u4E0A\u8D70\u4E0D\u4E86\u5B89\u88C5\u5305\u8FD9\u6761\u8DEF`
25541
25994
  });
25542
25995
  }
25543
25996
  return buildCarrierResult("data-package", CARRIER_HIT, {
25544
25997
  evidence: [...DATA_PACKAGE_MODELS],
25545
- note: "\u88C5\u5305\u8D70 `hcm datapackage pack` \u2192 `install`\uFF08Action \u901A\u9053 DataPackage.installFromDocument\uFF09\uFF0C\u88C5\u8F7D\u7ED3\u679C\u770B DataPackageInstallRun"
25998
+ note: "\u88C5\u5305\u8D70 `hcm package pack` \u2192 `install`\uFF08Action \u901A\u9053 DataPackage.installFromDocumentAsync\uFF09\uFF0C\u88C5\u8F7D\u7ED3\u679C\u770B DataPackageInstallRun"
25546
25999
  });
25547
26000
  }
25548
26001
  async function probeAll(client, artifactsDir) {
@@ -26469,19 +26922,19 @@ import { execFile } from "child_process";
26469
26922
  import { promisify } from "util";
26470
26923
  import { promises as fs12 } from "fs";
26471
26924
  import os4 from "os";
26472
- import path23 from "path";
26925
+ import path24 from "path";
26473
26926
 
26474
26927
  // src/jira/http-error.ts
26475
26928
  var JiraHttpError = class extends Error {
26476
26929
  status;
26477
26930
  method;
26478
26931
  path;
26479
- constructor(status, method, path24, message) {
26932
+ constructor(status, method, path25, message) {
26480
26933
  super(message);
26481
26934
  this.name = "JiraHttpError";
26482
26935
  this.status = status;
26483
26936
  this.method = method;
26484
- this.path = path24;
26937
+ this.path = path25;
26485
26938
  }
26486
26939
  };
26487
26940
 
@@ -26501,21 +26954,21 @@ var BMP_REPLACEMENTS = {
26501
26954
  var isIdeographic = (cp) => cp >= 131072 && cp <= 262143;
26502
26955
  var asCodePoint = (cp) => `U+${cp.toString(16).toUpperCase()}`;
26503
26956
  var NON_BMP_RULE_NOTE = "\u5224\u636E\u662F\u7801\u70B9 > U+FFFF\uFF0C\u4E0D\u662F\u300C\u662F\u4E0D\u662F emoji\u300D\uFF1A\u2705 \u26A0 \u274C \u8FD9\u4E9B BMP \u7B26\u53F7 Jira \u7167\u6536";
26504
- function findNonBmpChars(value, path24 = "") {
26957
+ function findNonBmpChars(value, path25 = "") {
26505
26958
  if (typeof value === "string") {
26506
26959
  const hits = [];
26507
26960
  let index = 0;
26508
26961
  for (const char of value) {
26509
26962
  const cp = char.codePointAt(0);
26510
- if (cp > 65535) hits.push({ path: path24, index, char, codePoint: asCodePoint(cp) });
26963
+ if (cp > 65535) hits.push({ path: path25, index, char, codePoint: asCodePoint(cp) });
26511
26964
  index += 1;
26512
26965
  }
26513
26966
  return hits;
26514
26967
  }
26515
- if (Array.isArray(value)) return value.flatMap((item, i) => findNonBmpChars(item, `${path24}[${i}]`));
26968
+ if (Array.isArray(value)) return value.flatMap((item, i) => findNonBmpChars(item, `${path25}[${i}]`));
26516
26969
  if (value && typeof value === "object") {
26517
26970
  return Object.entries(value).flatMap(
26518
- ([key, item]) => findNonBmpChars(item, path24 ? `${path24}.${key}` : key)
26971
+ ([key, item]) => findNonBmpChars(item, path25 ? `${path25}.${key}` : key)
26519
26972
  );
26520
26973
  }
26521
26974
  return [];
@@ -26545,23 +26998,23 @@ function describeNonBmpHits(hits) {
26545
26998
  }
26546
26999
  var JiraNonBmpContentError = class extends Error {
26547
27000
  hits;
26548
- constructor(hits, method, path24) {
26549
- super(`Jira ${method} ${path24} \u6CA1\u6709\u53D1\u51FA\uFF1A${describeNonBmpHits(hits)}`);
27001
+ constructor(hits, method, path25) {
27002
+ super(`Jira ${method} ${path25} \u6CA1\u6709\u53D1\u51FA\uFF1A${describeNonBmpHits(hits)}`);
26550
27003
  this.name = "JiraNonBmpContentError";
26551
27004
  this.hits = hits;
26552
27005
  }
26553
27006
  };
26554
27007
 
26555
27008
  // src/jira/client.ts
26556
- var JIRA_TOKEN_FILE = () => process.env.JIRA_TOKEN_FILE || path23.join(os4.homedir(), ".config", "hcm", "jira-token");
27009
+ var JIRA_TOKEN_FILE = () => process.env.JIRA_TOKEN_FILE || path24.join(os4.homedir(), ".config", "hcm", "jira-token");
26557
27010
  async function jiraTokenSource(opts = {}) {
26558
27011
  if (process.env.JIRA_TOKEN?.trim()) return { kind: "token", source: { token: process.env.JIRA_TOKEN.trim(), from: "\u73AF\u5883\u53D8\u91CF JIRA_TOKEN" } };
26559
27012
  const file = JIRA_TOKEN_FILE();
26560
27013
  try {
26561
- const stat = await fs12.stat(file);
27014
+ const stat2 = await fs12.stat(file);
26562
27015
  const value = (await fs12.readFile(file, "utf8")).trim();
26563
27016
  if (value) {
26564
- if (stat.mode & 63) process.stderr.write(`[jira] \u8B66\u544A\uFF1A${file} \u5BF9\u5176\u4ED6\u7528\u6237\u53EF\u8BFB\uFF08chmod 600 \u6536\u7D27\uFF09
27017
+ if (stat2.mode & 63) process.stderr.write(`[jira] \u8B66\u544A\uFF1A${file} \u5BF9\u5176\u4ED6\u7528\u6237\u53EF\u8BFB\uFF08chmod 600 \u6536\u7D27\uFF09
26565
27018
  `);
26566
27019
  return { kind: "token", source: { token: value, from: file } };
26567
27020
  }
@@ -26738,11 +27191,11 @@ var JiraClient = class {
26738
27191
  }
26739
27192
  /** 按流转 id / 流转名 / 目标状态名三种写法找;找不到把可用流转列出来,不猜。 */
26740
27193
  async transition(key, nameOrId, comment) {
26741
- const list = await this.transitions(key);
26742
- const hit = list.find((t) => t.id === String(nameOrId)) || list.find((t) => t.name === nameOrId) || list.find((t) => t.to?.name === nameOrId);
27194
+ const list2 = await this.transitions(key);
27195
+ const hit = list2.find((t) => t.id === String(nameOrId)) || list2.find((t) => t.name === nameOrId) || list2.find((t) => t.to?.name === nameOrId);
26743
27196
  if (!hit) {
26744
27197
  throw new Error(
26745
- `${key} \u4E0A\u6CA1\u6709\u5230\u300C${nameOrId}\u300D\u7684\u6D41\u8F6C\u3002\u53EF\u7528\uFF1A${list.map((t) => `${t.name}\u2192${t.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`
27198
+ `${key} \u4E0A\u6CA1\u6709\u5230\u300C${nameOrId}\u300D\u7684\u6D41\u8F6C\u3002\u53EF\u7528\uFF1A${list2.map((t) => `${t.name}\u2192${t.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`
26746
27199
  );
26747
27200
  }
26748
27201
  await this.transitionById(key, hit.id, comment);
@@ -26772,10 +27225,10 @@ var JiraClient = class {
26772
27225
  * Jira 9 起旧的 `createmeta?projectKeys=&expand=` 已移除(11.3.2 实测 404),用按 issuetype 分页的新接口。
26773
27226
  */
26774
27227
  async createMeta(project = this.project) {
26775
- const list = await this.api(
27228
+ const list2 = await this.api(
26776
27229
  `/rest/api/2/issue/createmeta/${project}/issuetypes`
26777
27230
  );
26778
- const types = list.values ?? list.issueTypes ?? [];
27231
+ const types = list2.values ?? list2.issueTypes ?? [];
26779
27232
  const out = [];
26780
27233
  for (const t of types) {
26781
27234
  if (t.subtask) continue;
@@ -26954,6 +27407,7 @@ export {
26954
27407
  IMPERSONATION_START_PATH,
26955
27408
  IMPORT_PLAN_FILE,
26956
27409
  INIT_EXIT_CODES,
27410
+ INSTALL_CONFIRMATION_HINTS,
26957
27411
  JIRA_BASE,
26958
27412
  JIRA_KEYCHAIN,
26959
27413
  JIRA_PROJECT,