c2-clinical 1.0.118 → 1.0.120

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.
@@ -2,7 +2,6 @@ import { IFormUnit, IRow } from "../../../models/form/FormUnit";
2
2
  declare class BuildTreeFlowItem {
3
3
  private bank;
4
4
  execute(questions: IFormUnit[]): IRow[];
5
- private iterate;
6
5
  private buildRows;
7
6
  }
8
7
  declare const _default: BuildTreeFlowItem;
@@ -8,55 +8,9 @@ class BuildTreeFlowItem {
8
8
  bank = [];
9
9
  execute(questions) {
10
10
  this.bank = questions;
11
- //extrai os elements raiz (sem parent)
12
- // const rootFormUnit: IFormUnit[] = questions
13
- // .filter((q: IFormUnit) => !q.parent)
14
- // .map((q: IFormUnit) => {
15
- // return {
16
- // ...q,
17
- // children: []
18
- // };
19
- // });
20
- // rootFormUnit.sort((a, b) => a.line - b.line);
21
- // //extrai os elements que tem algum parent
22
- // const children: IFormUnit[] = questions.filter((q: IFormUnit) => !!q.parent);
23
- // rootFormUnit?.forEach((q: IFormUnit) => {
24
- // this.iterate(q, children);
25
- // });
26
- // return rootFormUnit;
27
11
  const rootFormUnit = questions.filter((q) => !q.parent);
28
12
  return this.buildRows({ parent: undefined, children: rootFormUnit });
29
13
  }
30
- iterate(parent, children) {
31
- parent.children = children.filter((child) => child.parent?._id?.toString() === parent?._id?.toString());
32
- parent.children.sort((a, b) => a.line - b.line);
33
- const lines = parent.children.reduce((acc, item) => {
34
- if (!acc.some((a) => a.line === item.line)) {
35
- acc.push({
36
- id: GenerateUUIDFlowItem_1.default.execute(),
37
- line: item.line,
38
- collumns: []
39
- });
40
- }
41
- acc.find((a) => a.line === item.line)?.collumns.push(item);
42
- return acc;
43
- }, []);
44
- parent.lines?.forEach((line, index) => {
45
- line.collumns?.sort((a, b) => a.column - b.column);
46
- });
47
- if (parent.children.length > 0) {
48
- parent.children.forEach((parentPossible) => {
49
- this.iterate(parentPossible, children);
50
- });
51
- }
52
- }
53
- // private iterate2(config: { parent?: IFormUnit; children: IFormUnit[] }): IRow[] {
54
- // config.children.sort((a, b) => a.line - b.line);
55
- // if (!config.parent) {
56
- // return this.buildRows(config);
57
- // }
58
- // return this.buildRows(config);
59
- // }
60
14
  buildRows(config) {
61
15
  config.children.sort((a, b) => a.line - b.line);
62
16
  const lines = config.children.reduce((acc, item) => {
@@ -73,7 +27,11 @@ class BuildTreeFlowItem {
73
27
  lines?.forEach((line, index) => {
74
28
  line.collumns?.sort((a, b) => a.column - b.column);
75
29
  line.collumns?.forEach((collumn) => {
76
- const newChildren = this.bank.filter((child) => child.parent?._id?.toString() === collumn?._id?.toString());
30
+ const newChildren = this.bank.filter((child) => {
31
+ const parentId = child.parent?._id?.toString() ?? child.parent;
32
+ const _id = collumn?._id?.toString() ?? collumn._id;
33
+ return parentId === _id;
34
+ });
77
35
  if (newChildren?.length) {
78
36
  collumn.lines = this.buildRows({ parent: collumn, children: newChildren });
79
37
  }
@@ -8,6 +8,9 @@ const ExecFormulaFlowItem_1 = __importDefault(require("../../item/ExecFormulaFlo
8
8
  class GetEnablesFormUnitsFlowItem {
9
9
  execute(formUnits, answers) {
10
10
  return formUnits?.filter((unit) => {
11
+ if (unit._id.toString() === "68efa8f2fbcea8e6b466aed4") {
12
+ console.log("DEBUG ENABLED");
13
+ }
11
14
  // if (!unit.show) return false;
12
15
  if (!unit.active)
13
16
  return false;
package/jest.config.js ADDED
@@ -0,0 +1,20 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: "ts-jest",
4
+ testEnvironment: "node",
5
+ roots: ["<rootDir>/src"],
6
+ testMatch: ["**/*.test.ts"],
7
+ // coverageProvider: "v8",
8
+ // coverageThreshold: {
9
+ // global: {
10
+ // lines: 90,
11
+ // statements: 90
12
+ // }
13
+ // },
14
+ collectCoverageFrom: [
15
+ "src/flow/**/*.ts",
16
+ "!<rootDir>/node_modules/",
17
+ "!<rootDir>/dist/",
18
+ "!<rootDir>/resources/",
19
+ ],
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-clinical",
3
- "version": "1.0.118",
3
+ "version": "1.0.120",
4
4
  "description": "Biblioteca Typescript para API NodeJS",
5
5
  "repository": "https://github.com/cabralsilva/c2-clinical.git",
6
6
  "author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>",
@@ -8,7 +8,8 @@
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
10
10
  "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1",
11
+ "test": "jest",
12
+ "test:coverage": "jest --coverage --coverageReporters='text-summary'",
12
13
  "format": "prettier --write .",
13
14
  "build": "tsc --skipLibCheck",
14
15
  "preversion": "tsc --skipLibCheck",
@@ -22,16 +23,20 @@
22
23
  "crypto": "^1.0.1",
23
24
  "mongoose": "^8.3.4",
24
25
  "ts-node": "^10.8.1",
25
- "typescript": "^5.8.3"
26
+ "typescript": "^5.9.3"
26
27
  },
27
28
  "devDependencies": {
29
+ "@types/jest": "^30.0.0",
28
30
  "@types/mongoose": "^5.11.97",
29
31
  "@types/node": "^24.9.2",
30
32
  "@typescript-eslint/eslint-plugin": "^8.35.0",
31
33
  "@typescript-eslint/parser": "^8.35.0",
32
34
  "eslint": "^9.29.0",
33
35
  "eslint-config-prettier": "^10.1.5",
36
+ "eslint-plugin-jest": "^29.0.1",
34
37
  "eslint-plugin-prettier": "^5.5.1",
35
- "prettier": "^3.6.2"
38
+ "jest": "^30.2.0",
39
+ "prettier": "^3.6.2",
40
+ "ts-jest": "^29.4.5"
36
41
  }
37
42
  }