opencroc 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -3666,14 +3666,67 @@ var init_croc_office = __esm({
3666
3666
  const nodes = [];
3667
3667
  const edges = [];
3668
3668
  const moduleSet = /* @__PURE__ */ new Set();
3669
+ const inferModule = (filePath, type) => {
3670
+ const parts = filePath.replace(/\\/g, "/").split("/");
3671
+ const typeDir = type === "model" ? "models" : "controllers";
3672
+ const typeDirIdx = parts.indexOf(typeDir);
3673
+ if (typeDirIdx >= 0 && parts.length - typeDirIdx > 2) {
3674
+ return parts[typeDirIdx + 1];
3675
+ }
3676
+ const baseName = parts[parts.length - 1].replace(/\.(ts|js)$/, "").replace(/Controller$/, "");
3677
+ const prefixMatch = baseName.match(/^([a-z]+)/i);
3678
+ if (prefixMatch) {
3679
+ const prefix = prefixMatch[1].toLowerCase();
3680
+ const groupMap = {
3681
+ app: "app",
3682
+ api: "api",
3683
+ data: "data",
3684
+ auth: "auth",
3685
+ user: "user",
3686
+ role: "role",
3687
+ menu: "menu",
3688
+ dept: "org",
3689
+ department: "org",
3690
+ org: "org",
3691
+ chain: "workflow",
3692
+ workflow: "workflow",
3693
+ batch: "batch",
3694
+ column: "data",
3695
+ computed: "data",
3696
+ designer: "designer",
3697
+ monitor: "monitor",
3698
+ notification: "notification",
3699
+ permission: "permission",
3700
+ template: "template",
3701
+ validation: "validation",
3702
+ field: "field",
3703
+ delegation: "workflow",
3704
+ import: "import-export",
3705
+ export: "import-export",
3706
+ dictionary: "data",
3707
+ panorama: "panorama",
3708
+ inference: "inference",
3709
+ simulation: "simulation",
3710
+ er: "data",
3711
+ relation: "data",
3712
+ recycle: "data",
3713
+ statistics: "statistics",
3714
+ operation: "log",
3715
+ log: "log",
3716
+ timeout: "workflow"
3717
+ };
3718
+ return groupMap[prefix] || prefix;
3719
+ }
3720
+ return "other";
3721
+ };
3669
3722
  this.updateAgent("parser-croc", { progress: 40, currentTask: "Scanning models..." });
3670
3723
  const modelFiles = await glob("**/models/**/*.{ts,js}", {
3671
3724
  cwd: backendRoot,
3672
- ignore: ["**/node_modules/**", "**/*.test.*", "**/*.spec.*", "**/index.*"]
3725
+ ignore: ["**/node_modules/**", "**/*.test.*", "**/*.spec.*", "**/index.*", "**/dist/**"]
3673
3726
  });
3674
3727
  for (const file of modelFiles) {
3675
- const parts = file.split("/");
3676
- const moduleName = parts.length >= 3 ? parts[parts.length - 3] : "default";
3728
+ const parts = file.replace(/\\/g, "/").split("/");
3729
+ const moduleName = inferModule(file, "model");
3677
3730
  const fileName = parts[parts.length - 1].replace(/\.(ts|js)$/, "");
3678
3731
  const nodeId = `model:${fileName}`;
3679
3732
  moduleSet.add(moduleName);
@@ -3688,12 +3741,12 @@ var init_croc_office = __esm({
3688
3741
  this.updateAgent("parser-croc", { progress: 70, currentTask: "Scanning controllers..." });
3689
3742
  const controllerFiles = await glob("**/controllers/**/*.{ts,js}", {
3690
3743
  cwd: backendRoot,
3691
- ignore: ["**/node_modules/**", "**/*.test.*", "**/*.spec.*", "**/index.*"]
3744
+ ignore: ["**/node_modules/**", "**/*.test.*", "**/*.spec.*", "**/index.*", "**/dist/**"]
3692
3745
  });
3693
3746
  for (const file of controllerFiles) {
3694
- const parts = file.split("/");
3695
- const moduleName = parts.length >= 3 ? parts[parts.length - 3] : "default";
3696
- const fileName = parts[parts.length - 1].replace(/\.(ts|js)$/, "").replace(".controller", "");
3747
+ const parts = file.replace(/\\/g, "/").split("/");
3748
+ const moduleName = inferModule(file, "controller");
3749
+ const fileName = parts[parts.length - 1].replace(/\.(ts|js)$/, "").replace(/Controller$/, "");
3697
3750
  const nodeId = `controller:${fileName}`;
3698
3751
  moduleSet.add(moduleName);
3699
3752
  nodes.push({
@@ -3703,7 +3756,8 @@ var init_croc_office = __esm({
3703
3756
  status: "idle",
3704
3757
  module: moduleName
3705
3758
  });
3706
- const modelNode = nodes.find((n) => n.type === "model" && n.label.toLowerCase() === fileName.toLowerCase());
3759
+ const lcName = fileName.toLowerCase();
3760
+ const modelNode = nodes.find((n) => n.type === "model" && n.label.toLowerCase() === lcName);
3707
3761
  if (modelNode) {
3708
3762
  edges.push({ source: nodeId, target: modelNode.id, relation: "uses" });
3709
3763
  }