opencroc 1.4.0 → 1.4.2

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,118 @@ var init_croc_office = __esm({
3666
3666
  const nodes = [];
3667
3667
  const edges = [];
3668
3668
  const moduleSet = /* @__PURE__ */ new Set();
3669
+ const KNOWN_PREFIXES = [
3670
+ "notification",
3671
+ "department",
3672
+ "application",
3673
+ "permission",
3674
+ "computed",
3675
+ "delegation",
3676
+ "dictionary",
3677
+ "validation",
3678
+ "simulation",
3679
+ "statistics",
3680
+ "inference",
3681
+ "panorama",
3682
+ "designer",
3683
+ "workflow",
3684
+ "template",
3685
+ "relation",
3686
+ "recycle",
3687
+ "monitor",
3688
+ "timeout",
3689
+ "column",
3690
+ "export",
3691
+ "import",
3692
+ "batch",
3693
+ "field",
3694
+ "chain",
3695
+ "tenant",
3696
+ "model",
3697
+ "data",
3698
+ "user",
3699
+ "role",
3700
+ "menu",
3701
+ "auth",
3702
+ "dept",
3703
+ "page",
3704
+ "app",
3705
+ "api",
3706
+ "org",
3707
+ "log",
3708
+ "er"
3709
+ ];
3710
+ const DOMAIN_GROUPS = {
3711
+ app: "app",
3712
+ api: "api",
3713
+ data: "data",
3714
+ auth: "auth",
3715
+ user: "user",
3716
+ role: "user",
3717
+ menu: "app",
3718
+ dept: "org",
3719
+ department: "org",
3720
+ org: "org",
3721
+ chain: "workflow",
3722
+ workflow: "workflow",
3723
+ batch: "batch",
3724
+ column: "data",
3725
+ computed: "data",
3726
+ designer: "designer",
3727
+ monitor: "monitor",
3728
+ notification: "notification",
3729
+ permission: "permission",
3730
+ template: "template",
3731
+ validation: "validation",
3732
+ field: "data",
3733
+ delegation: "workflow",
3734
+ import: "data",
3735
+ export: "data",
3736
+ dictionary: "data",
3737
+ panorama: "panorama",
3738
+ inference: "inference",
3739
+ simulation: "simulation",
3740
+ er: "data",
3741
+ relation: "data",
3742
+ recycle: "data",
3743
+ statistics: "statistics",
3744
+ operation: "system",
3745
+ log: "system",
3746
+ timeout: "workflow",
3747
+ tenant: "system",
3748
+ model: "data",
3749
+ page: "app",
3750
+ application: "app"
3751
+ };
3752
+ const inferModule = (filePath, type) => {
3753
+ const parts = filePath.replace(/\\/g, "/").split("/");
3754
+ const typeDir = type === "model" ? "models" : "controllers";
3755
+ const typeDirIdx = parts.indexOf(typeDir);
3756
+ if (typeDirIdx >= 0 && parts.length - typeDirIdx > 2) {
3757
+ return parts[typeDirIdx + 1];
3758
+ }
3759
+ const baseName = parts[parts.length - 1].replace(/\.(ts|js)$/, "").replace(/Controller$/i, "");
3760
+ const lc = baseName.toLowerCase();
3761
+ for (const prefix of KNOWN_PREFIXES) {
3762
+ if (lc.startsWith(prefix)) {
3763
+ return DOMAIN_GROUPS[prefix] || prefix;
3764
+ }
3765
+ }
3766
+ const camelMatch = baseName.match(/^([A-Z]?[a-z]+)/);
3767
+ if (camelMatch) {
3768
+ const w = camelMatch[1].toLowerCase();
3769
+ return DOMAIN_GROUPS[w] || w;
3770
+ }
3771
+ return "other";
3772
+ };
3669
3773
  this.updateAgent("parser-croc", { progress: 40, currentTask: "Scanning models..." });
3670
3774
  const modelFiles = await glob("**/models/**/*.{ts,js}", {
3671
3775
  cwd: backendRoot,
3672
- ignore: ["**/node_modules/**", "**/*.test.*", "**/*.spec.*", "**/index.*"]
3776
+ ignore: ["**/node_modules/**", "**/*.test.*", "**/*.spec.*", "**/index.*", "**/dist/**"]
3673
3777
  });
3674
3778
  for (const file of modelFiles) {
3675
- const parts = file.split("/");
3676
- const moduleName = parts.length >= 3 ? parts[parts.length - 3] : "default";
3779
+ const parts = file.replace(/\\/g, "/").split("/");
3780
+ const moduleName = inferModule(file, "model");
3677
3781
  const fileName = parts[parts.length - 1].replace(/\.(ts|js)$/, "");
3678
3782
  const nodeId = `model:${fileName}`;
3679
3783
  moduleSet.add(moduleName);
@@ -3688,12 +3792,12 @@ var init_croc_office = __esm({
3688
3792
  this.updateAgent("parser-croc", { progress: 70, currentTask: "Scanning controllers..." });
3689
3793
  const controllerFiles = await glob("**/controllers/**/*.{ts,js}", {
3690
3794
  cwd: backendRoot,
3691
- ignore: ["**/node_modules/**", "**/*.test.*", "**/*.spec.*", "**/index.*"]
3795
+ ignore: ["**/node_modules/**", "**/*.test.*", "**/*.spec.*", "**/index.*", "**/dist/**"]
3692
3796
  });
3693
3797
  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", "");
3798
+ const parts = file.replace(/\\/g, "/").split("/");
3799
+ const moduleName = inferModule(file, "controller");
3800
+ const fileName = parts[parts.length - 1].replace(/\.(ts|js)$/, "").replace(/Controller$/, "");
3697
3801
  const nodeId = `controller:${fileName}`;
3698
3802
  moduleSet.add(moduleName);
3699
3803
  nodes.push({
@@ -3703,7 +3807,8 @@ var init_croc_office = __esm({
3703
3807
  status: "idle",
3704
3808
  module: moduleName
3705
3809
  });
3706
- const modelNode = nodes.find((n) => n.type === "model" && n.label.toLowerCase() === fileName.toLowerCase());
3810
+ const lcName = fileName.toLowerCase();
3811
+ const modelNode = nodes.find((n) => n.type === "model" && n.label.toLowerCase() === lcName);
3707
3812
  if (modelNode) {
3708
3813
  edges.push({ source: nodeId, target: modelNode.id, relation: "uses" });
3709
3814
  }