const assert = require("assert");
const fs = require("fs");
const path = require("path");

const apiPath = path.resolve(
  __dirname,
  "../../src/api/ccdiIntermediary.js"
);
const source = fs.readFileSync(apiPath, "utf8");

[
  "export function importPersonTemplate()",
  "export function importPersonData(data, updateSupport)",
  "export function getPersonImportStatus(taskId)",
  "export function getPersonImportFailures(taskId, pageNum, pageSize)",
  "export function importEnterpriseRelationTemplate()",
  "export function importEnterpriseRelationData(data, updateSupport)",
  "export function getEnterpriseRelationImportStatus(taskId)",
  "export function getEnterpriseRelationImportFailures(taskId, pageNum, pageSize)",
  "/ccdi/intermediary/importPersonTemplate",
  "/ccdi/intermediary/importPersonData",
  "/ccdi/intermediary/importPersonStatus/",
  "/ccdi/intermediary/importPersonFailures/",
  "/ccdi/intermediary/importEnterpriseRelationTemplate",
  "/ccdi/intermediary/importEnterpriseRelationData",
  "/ccdi/intermediary/importEnterpriseRelationStatus/",
  "/ccdi/intermediary/importEnterpriseRelationFailures/",
].forEach((token) => {
  assert(source.includes(token), `中介导入 API 缺少关键方法或路径: ${token}`);
});

[
  "export function importEntityTemplate()",
  "export function importEntityData(data, updateSupport)",
  "export function getEntityImportStatus(taskId)",
  "export function getEntityImportFailures(taskId, pageNum, pageSize)",
  "/ccdi/intermediary/importEntityTemplate",
  "/ccdi/intermediary/importEntityData",
  "/ccdi/intermediary/importEntityStatus/",
  "/ccdi/intermediary/importEntityFailures/",
].forEach((token) => {
  assert(!source.includes(token), `中介导入 API 不应继续保留旧机构导入接口: ${token}`);
});

console.log("intermediary-import-api test passed");
