c2-clinical 1.0.117 → 1.0.119

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.
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // import { randomUUID } from "node:crypto";
4
- const crypto_1 = require("crypto");
6
+ const GenerateUUIDFlowItem_1 = __importDefault(require("./GenerateUUIDFlowItem"));
5
7
  class BuildTreeFlowItem {
6
8
  bank = [];
7
9
  execute(questions) {
@@ -31,7 +33,7 @@ class BuildTreeFlowItem {
31
33
  const lines = parent.children.reduce((acc, item) => {
32
34
  if (!acc.some((a) => a.line === item.line)) {
33
35
  acc.push({
34
- id: (0, crypto_1.randomUUID)(),
36
+ id: GenerateUUIDFlowItem_1.default.execute(),
35
37
  line: item.line,
36
38
  collumns: []
37
39
  });
@@ -60,7 +62,7 @@ class BuildTreeFlowItem {
60
62
  const lines = config.children.reduce((acc, item) => {
61
63
  if (!acc.some((a) => a.line === item.line)) {
62
64
  acc.push({
63
- id: (0, crypto_1.randomUUID)(),
65
+ id: GenerateUUIDFlowItem_1.default.execute(),
64
66
  line: item.line,
65
67
  collumns: []
66
68
  });
@@ -71,7 +73,11 @@ class BuildTreeFlowItem {
71
73
  lines?.forEach((line, index) => {
72
74
  line.collumns?.sort((a, b) => a.column - b.column);
73
75
  line.collumns?.forEach((collumn) => {
74
- const newChildren = this.bank.filter((child) => child.parent?._id?.toString() === collumn?._id?.toString());
76
+ const newChildren = this.bank.filter((child) => {
77
+ const parentId = child.parent?._id?.toString() ?? child.parent;
78
+ const _id = collumn?._id?.toString() ?? collumn._id;
79
+ return parentId === _id;
80
+ });
75
81
  if (newChildren?.length) {
76
82
  collumn.lines = this.buildRows({ parent: collumn, children: newChildren });
77
83
  }
@@ -0,0 +1,5 @@
1
+ declare class GenerateUUIDFlowItem {
2
+ execute(): string;
3
+ }
4
+ declare const _default: GenerateUUIDFlowItem;
5
+ export default _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class GenerateUUIDFlowItem {
4
+ execute() {
5
+ if (typeof globalThis.crypto?.randomUUID === "function") {
6
+ return globalThis.crypto.randomUUID();
7
+ }
8
+ // fallback se não houver suporte
9
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
10
+ const r = (Math.random() * 16) | 0;
11
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
12
+ return v.toString(16);
13
+ });
14
+ }
15
+ }
16
+ exports.default = new GenerateUUIDFlowItem();
@@ -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.117",
3
+ "version": "1.0.119",
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
  }