From b681a64ca9f4ec72f1de911d0a3758419e9a3a33 Mon Sep 17 00:00:00 2001 From: Lucas Ansei Date: Wed, 25 Feb 2026 14:05:23 -0300 Subject: [PATCH] =?UTF-8?q?Upgrade=20de=20vers=C3=A3o=20do=20prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package-lock.json | 368 +++++++++++++++--- backend/package.json | 10 +- backend/prisma/schema.prisma | 34 +- .../src/api-logs/backup-scheduler.service.ts | 6 +- backend/src/prisma/prisma.service.ts | 152 +++----- 5 files changed, 402 insertions(+), 168 deletions(-) diff --git a/backend/package-lock.json b/backend/package-lock.json index 40b718564e..b4bcce37c0 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -23,7 +23,7 @@ "@nestjs/schedule": "^6.0.0", "@nestjs/serve-static": "^5.0.3", "@nestjs/swagger": "^11.2.0", - "@prisma/client": "^6.12.0", + "@prisma/client": "^6.19.2", "@ts-graphviz/adapter": "^2.0.6", "@turf/simplify": "^7.2.0", "@types/geojson": "^7946.0.16", @@ -99,7 +99,7 @@ "jest": "30.0.4", "mjml": "^4.15.3", "prettier": "^3.6.2", - "prisma": "^6.12.0", + "prisma": "^6.19.2", "source-map-support": "^0.5.21", "supertest": "^7.1.3", "ts-jest": "29.4.0", @@ -108,6 +108,10 @@ "tsconfig-paths": "4.2.0", "typescript": "^5.8.3", "yargs": "17.7.2" + }, + "engines": { + "node": ">=18.18.0", + "npm": ">=9.0.0" } }, "node_modules/@47ng/cloak": { @@ -3968,9 +3972,9 @@ } }, "node_modules/@prisma/client": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.12.0.tgz", - "integrity": "sha512-wn98bJ3Cj6edlF4jjpgXwbnQIo/fQLqqQHPk2POrZPxTlhY3+n90SSIF3LMRVa8VzRFC/Gec3YKJRxRu+AIGVA==", + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.19.2.tgz", + "integrity": "sha512-gR2EMvfK/aTxsuooaDA32D8v+us/8AAet+C3J1cc04SW35FPdZYgLF+iN4NDLUgAaUGTKdAB0CYenu1TAgGdMg==", "hasInstallScript": true, "license": "Apache-2.0", "engines": { @@ -3990,13 +3994,16 @@ } }, "node_modules/@prisma/config": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.12.0.tgz", - "integrity": "sha512-HovZWzhWEMedHxmjefQBRZa40P81N7/+74khKFz9e1AFjakcIQdXgMWKgt20HaACzY+d1LRBC+L4tiz71t9fkg==", + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.19.2.tgz", + "integrity": "sha512-kadBGDl+aUswv/zZMk9Mx0C8UZs1kjao8H9/JpI4Wh4SHZaM7zkTwiKn/iFLfRg+XtOAo/Z/c6pAYhijKl0nzQ==", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "jiti": "2.4.2" + "c12": "3.1.0", + "deepmerge-ts": "7.1.5", + "effect": "3.18.4", + "empathic": "2.0.0" } }, "node_modules/@prisma/debug": { @@ -4005,49 +4012,49 @@ "integrity": "sha512-wK3fQLxPLMqf5riT5ZIhl8NffPSzFUwtzFX5CH7z/oI9Swmo9UhQlUgZABIVgdXSJ5OAlmRcDZtDKaMApIl8sg==" }, "node_modules/@prisma/engines": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.12.0.tgz", - "integrity": "sha512-4BRZZUaAuB4p0XhTauxelvFs7IllhPmNLvmla0bO1nkECs8n/o1pUvAVbQ/VOrZR5DnF4HED0PrGai+rIOVePA==", + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.19.2.tgz", + "integrity": "sha512-TTkJ8r+uk/uqczX40wb+ODG0E0icVsMgwCTyTHXehaEfb0uo80M9g1aW1tEJrxmFHeOZFXdI2sTA1j1AgcHi4A==", "devOptional": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "6.12.0", - "@prisma/engines-version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", - "@prisma/fetch-engine": "6.12.0", - "@prisma/get-platform": "6.12.0" + "@prisma/debug": "6.19.2", + "@prisma/engines-version": "7.1.1-3.c2990dca591cba766e3b7ef5d9e8a84796e47ab7", + "@prisma/fetch-engine": "6.19.2", + "@prisma/get-platform": "6.19.2" } }, "node_modules/@prisma/engines-version": { - "version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc.tgz", - "integrity": "sha512-70vhecxBJlRr06VfahDzk9ow4k1HIaSfVUT3X0/kZoHCMl9zbabut4gEXAyzJZxaCGi5igAA7SyyfBI//mmkbQ==", + "version": "7.1.1-3.c2990dca591cba766e3b7ef5d9e8a84796e47ab7", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-7.1.1-3.c2990dca591cba766e3b7ef5d9e8a84796e47ab7.tgz", + "integrity": "sha512-03bgb1VD5gvuumNf+7fVGBzfpJPjmqV423l/WxsWk2cNQ42JD0/SsFBPhN6z8iAvdHs07/7ei77SKu7aZfq8bA==", "devOptional": true, "license": "Apache-2.0" }, "node_modules/@prisma/engines/node_modules/@prisma/debug": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.12.0.tgz", - "integrity": "sha512-plbz6z72orcqr0eeio7zgUrZj5EudZUpAeWkFTA/DDdXEj28YHDXuiakvR6S7sD6tZi+jiwQEJAPeV6J6m/tEQ==", + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.19.2.tgz", + "integrity": "sha512-lFnEZsLdFLmEVCVNdskLDCL8Uup41GDfU0LUfquw+ercJC8ODTuL0WNKgOKmYxCJVvFwf0OuZBzW99DuWmoH2A==", "devOptional": true, "license": "Apache-2.0" }, "node_modules/@prisma/fetch-engine": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.12.0.tgz", - "integrity": "sha512-EamoiwrK46rpWaEbLX9aqKDPOd8IyLnZAkiYXFNuq0YsU0Z8K09/rH8S7feOWAVJ3xzeSgcEJtBlVDrajM9Sag==", + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.19.2.tgz", + "integrity": "sha512-h4Ff4Pho+SR1S8XerMCC12X//oY2bG3Iug/fUnudfcXEUnIeRiBdXHFdGlGOgQ3HqKgosTEhkZMvGM9tWtYC+Q==", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "6.12.0", - "@prisma/engines-version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", - "@prisma/get-platform": "6.12.0" + "@prisma/debug": "6.19.2", + "@prisma/engines-version": "7.1.1-3.c2990dca591cba766e3b7ef5d9e8a84796e47ab7", + "@prisma/get-platform": "6.19.2" } }, "node_modules/@prisma/fetch-engine/node_modules/@prisma/debug": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.12.0.tgz", - "integrity": "sha512-plbz6z72orcqr0eeio7zgUrZj5EudZUpAeWkFTA/DDdXEj28YHDXuiakvR6S7sD6tZi+jiwQEJAPeV6J6m/tEQ==", + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.19.2.tgz", + "integrity": "sha512-lFnEZsLdFLmEVCVNdskLDCL8Uup41GDfU0LUfquw+ercJC8ODTuL0WNKgOKmYxCJVvFwf0OuZBzW99DuWmoH2A==", "devOptional": true, "license": "Apache-2.0" }, @@ -4060,19 +4067,19 @@ } }, "node_modules/@prisma/get-platform": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.12.0.tgz", - "integrity": "sha512-nRerTGhTlgyvcBlyWgt8OLNIV7QgJS2XYXMJD1hysorMCuLAjuDDuoxmVt7C2nLxbuxbWPp7OuFRHC23HqD9dA==", + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.19.2.tgz", + "integrity": "sha512-PGLr06JUSTqIvztJtAzIxOwtWKtJm5WwOG6xpsgD37Rc84FpfUBGLKz65YpJBGtkRQGXTYEFie7pYALocC3MtA==", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "6.12.0" + "@prisma/debug": "6.19.2" } }, "node_modules/@prisma/get-platform/node_modules/@prisma/debug": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.12.0.tgz", - "integrity": "sha512-plbz6z72orcqr0eeio7zgUrZj5EudZUpAeWkFTA/DDdXEj28YHDXuiakvR6S7sD6tZi+jiwQEJAPeV6J6m/tEQ==", + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.19.2.tgz", + "integrity": "sha512-lFnEZsLdFLmEVCVNdskLDCL8Uup41GDfU0LUfquw+ercJC8ODTuL0WNKgOKmYxCJVvFwf0OuZBzW99DuWmoH2A==", "devOptional": true, "license": "Apache-2.0" }, @@ -4139,6 +4146,13 @@ "integrity": "sha512-sDL1aB2U8FIpj7SjQJMxbOFIFkKvDKQGPHSrYejHZhtLNSK3qHe6ZIfa0woWkOiaJsdYslFzrc0VWXJZHmSIQQ==", "license": "MIT" }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "devOptional": true, + "license": "MIT" + }, "node_modules/@streamparser/json": { "version": "0.0.20", "resolved": "https://registry.npmjs.org/@streamparser/json/-/json-0.0.20.tgz", @@ -6285,6 +6299,48 @@ "node": ">= 0.8" } }, + "node_modules/c12": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/c12/-/c12-3.1.0.tgz", + "integrity": "sha512-uWoS8OU1MEIsOv8p/5a82c3H31LsWVR5qiyXVfBNOzfffjUWtPnhAb4BYI2uG2HfGmZmFjCtui5XNWaps+iFuw==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "chokidar": "^4.0.3", + "confbox": "^0.2.2", + "defu": "^6.1.4", + "dotenv": "^16.6.1", + "exsolve": "^1.0.7", + "giget": "^2.0.0", + "jiti": "^2.4.2", + "ohash": "^2.0.11", + "pathe": "^2.0.3", + "perfect-debounce": "^1.0.0", + "pkg-types": "^2.2.0", + "rc9": "^2.1.2" + }, + "peerDependencies": { + "magicast": "^0.3.5" + }, + "peerDependenciesMeta": { + "magicast": { + "optional": true + } + } + }, + "node_modules/c12/node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "devOptional": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/cacache": { "version": "16.1.3", "resolved": "https://registry.npmjs.org/cacache/-/cacache-16.1.3.tgz", @@ -6682,7 +6738,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", - "dev": true, + "devOptional": true, "license": "MIT", "dependencies": { "readdirp": "^4.0.1" @@ -6728,6 +6784,16 @@ "node": ">=8" } }, + "node_modules/citty": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/citty/-/citty-0.1.6.tgz", + "integrity": "sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "consola": "^3.2.3" + } + }, "node_modules/cjs-module-lexer": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-2.1.0.tgz", @@ -7040,6 +7106,13 @@ "typedarray": "^0.0.6" } }, + "node_modules/confbox": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.2.4.tgz", + "integrity": "sha512-ysOGlgTFbN2/Y6Cg3Iye8YKulHw+R2fNXHrgSmXISQdMnomY6eNDprVdW9R5xBguEqI954+S6709UyiO7B+6OQ==", + "devOptional": true, + "license": "MIT" + }, "node_modules/config-chain": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz", @@ -7356,6 +7429,16 @@ "node": ">=0.10.0" } }, + "node_modules/deepmerge-ts": { + "version": "7.1.5", + "resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-7.1.5.tgz", + "integrity": "sha512-HOJkrhaYsweh+W+e74Yn7YStZOilkoPb6fycpwNLKzSPtruFs48nYis0zy5yJz1+ktUhHxoRDJ27RQAWLIJVJw==", + "devOptional": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", @@ -7393,6 +7476,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/defu": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", + "integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==", + "devOptional": true, + "license": "MIT" + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -7418,6 +7508,13 @@ "node": ">= 0.8" } }, + "node_modules/destr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.5.tgz", + "integrity": "sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==", + "devOptional": true, + "license": "MIT" + }, "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", @@ -7663,6 +7760,17 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "license": "MIT" }, + "node_modules/effect": { + "version": "3.18.4", + "resolved": "https://registry.npmjs.org/effect/-/effect-3.18.4.tgz", + "integrity": "sha512-b1LXQJLe9D11wfnOKAk3PKxuqYshQ0Heez+y5pnkd3jLj1yx9QhM72zZ9uUrOQyNvrs2GZZd/3maL0ZV18YuDA==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.0.0", + "fast-check": "^3.23.1" + } + }, "node_modules/ejs": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", @@ -7702,6 +7810,16 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, + "node_modules/empathic": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/empathic/-/empathic-2.0.0.tgz", + "integrity": "sha512-i6UzDscO/XfAcNYD75CfICkmfLedpyPDdozrLMmQc5ORaQcdMoc21OnlEylMIqI7U8eniKrPMxxtj8k0vhmJhA==", + "devOptional": true, + "license": "MIT", + "engines": { + "node": ">=14" + } + }, "node_modules/enabled": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", @@ -8475,6 +8593,53 @@ "node": ">= 0.6" } }, + "node_modules/exsolve": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/exsolve/-/exsolve-1.0.8.tgz", + "integrity": "sha512-LmDxfWXwcTArk8fUEnOfSZpHOJ6zOMUJKOtFLFqJLoKJetuQG874Uc7/Kki7zFLzYybmZhp1M7+98pfMqeX8yA==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/fast-check": { + "version": "3.23.2", + "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-3.23.2.tgz", + "integrity": "sha512-h5+1OzzfCC3Ef7VbtKdcv7zsstUQwUDlYpUTvjeUsJAssPgLn7QzbboPtL5ro04Mq0rPOsMzl7q5hIbRs2wD1A==", + "devOptional": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ], + "license": "MIT", + "dependencies": { + "pure-rand": "^6.1.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/fast-check/node_modules/pure-rand": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", + "devOptional": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ], + "license": "MIT" + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -8729,11 +8894,12 @@ } }, "node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "license": "ISC", "dependencies": { - "cross-spawn": "^7.0.0", + "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" }, "engines": { @@ -9049,6 +9215,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/giget": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/giget/-/giget-2.0.0.tgz", + "integrity": "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "citty": "^0.1.6", + "consola": "^3.4.0", + "defu": "^6.1.4", + "node-fetch-native": "^1.6.6", + "nypm": "^0.6.0", + "pathe": "^2.0.3" + }, + "bin": { + "giget": "dist/cli.mjs" + } + }, "node_modules/glob": { "version": "10.4.2", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", @@ -12193,6 +12377,13 @@ } } }, + "node_modules/node-fetch-native": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.7.tgz", + "integrity": "sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==", + "devOptional": true, + "license": "MIT" + }, "node_modules/node-fetch/node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -12468,6 +12659,31 @@ "integrity": "sha512-/ieB+mDe4MrrKMT8z+mQL8klXydZWGR5Dowt4RAGKbJ3kIGEx3X4ljUo+6V73IXtUPWgfOlU5B9MlGxFO5T+cA==", "license": "MIT" }, + "node_modules/nypm": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/nypm/-/nypm-0.6.5.tgz", + "integrity": "sha512-K6AJy1GMVyfyMXRVB88700BJqNUkByijGJM8kEHpLdcAt+vSQAVfkWWHYzuRXHSY6xA2sNc5RjTj0p9rE2izVQ==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "citty": "^0.2.0", + "pathe": "^2.0.3", + "tinyexec": "^1.0.2" + }, + "bin": { + "nypm": "dist/cli.mjs" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/nypm/node_modules/citty": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/citty/-/citty-0.2.1.tgz", + "integrity": "sha512-kEV95lFBhQgtogAPlQfJJ0WGVSokvLr/UEoFPiKKOXF7pl98HfUVUD0ejsuTCld/9xH9vogSywZ5KqHzXrZpqg==", + "devOptional": true, + "license": "MIT" + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -12496,6 +12712,13 @@ "node": ">= 10.12.0" } }, + "node_modules/ohash": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/ohash/-/ohash-2.0.11.tgz", + "integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==", + "devOptional": true, + "license": "MIT" + }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -12850,6 +13073,13 @@ "node": ">=8" } }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "devOptional": true, + "license": "MIT" + }, "node_modules/pause": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", @@ -12860,6 +13090,13 @@ "resolved": "https://registry.npmjs.org/percentile/-/percentile-1.6.0.tgz", "integrity": "sha512-8vSyjdzwxGDHHwH+cSGch3A9Uj2On3UpgOWxWXMKwUvoAbnujx6DaqmV1duWXNiH/oEWpyVd6nSQccix6DM3Ng==" }, + "node_modules/perfect-debounce": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz", + "integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==", + "devOptional": true, + "license": "MIT" + }, "node_modules/pg": { "version": "8.16.3", "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz", @@ -13048,6 +13285,18 @@ "node": ">=8" } }, + "node_modules/pkg-types": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-2.3.0.tgz", + "integrity": "sha512-SIqCzDRg0s9npO5XQ3tNZioRY1uK06lA41ynBC1YmFTmnY6FjUjVt6s4LoADmwoig1qqD0oK8h1p/8mlMx8Oig==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "confbox": "^0.2.2", + "exsolve": "^1.0.7", + "pathe": "^2.0.3" + } + }, "node_modules/pluralize": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", @@ -13183,15 +13432,15 @@ } }, "node_modules/prisma": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.12.0.tgz", - "integrity": "sha512-pmV7NEqQej9WjizN6RSNIwf7Y+jeh9mY1JEX2WjGxJi4YZWexClhde1yz/FuvAM+cTwzchcMytu2m4I6wPkIzg==", + "version": "6.19.2", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.19.2.tgz", + "integrity": "sha512-XTKeKxtQElcq3U9/jHyxSPgiRgeYDKxWTPOf6NkXA0dNj5j40MfEsZkMbyNpwDWCUv7YBFUl7I2VK/6ALbmhEg==", "devOptional": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@prisma/config": "6.12.0", - "@prisma/engines": "6.12.0" + "@prisma/config": "6.19.2", + "@prisma/engines": "6.19.2" }, "bin": { "prisma": "build/index.js" @@ -13406,6 +13655,17 @@ "node": ">= 0.8" } }, + "node_modules/rc9": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/rc9/-/rc9-2.1.2.tgz", + "integrity": "sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "defu": "^6.1.4", + "destr": "^2.0.3" + } + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", @@ -13430,7 +13690,7 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", - "dev": true, + "devOptional": true, "license": "MIT", "engines": { "node": ">= 14.18.0" @@ -14851,6 +15111,16 @@ "readable-stream": "3" } }, + "node_modules/tinyexec": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", + "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "devOptional": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/tldts": { "version": "6.1.86", "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.86.tgz", diff --git a/backend/package.json b/backend/package.json index 43143e92ab..be581f30f7 100644 --- a/backend/package.json +++ b/backend/package.json @@ -5,6 +5,10 @@ "author": "", "private": true, "license": "UNLICENSED", + "engines": { + "node": ">=18.18.0", + "npm": ">=9.0.0" + }, "scripts": { "db:migrate:gen": "./bin/db-migrate-gen", "db:migrate:up": "prisma migrate dev", @@ -51,7 +55,7 @@ "@nestjs/schedule": "^6.0.0", "@nestjs/serve-static": "^5.0.3", "@nestjs/swagger": "^11.2.0", - "@prisma/client": "^6.12.0", + "@prisma/client": "^6.19.2", "@ts-graphviz/adapter": "^2.0.6", "@turf/simplify": "^7.2.0", "@types/geojson": "^7946.0.16", @@ -127,7 +131,7 @@ "jest": "30.0.4", "mjml": "^4.15.3", "prettier": "^3.6.2", - "prisma": "^6.12.0", + "prisma": "^6.19.2", "source-map-support": "^0.5.21", "supertest": "^7.1.3", "ts-jest": "29.4.0", @@ -157,4 +161,4 @@ "coverageDirectory": "../coverage", "testEnvironment": "node" } -} +} \ No newline at end of file diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index 7886a69728..8a3558ae7e 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -4103,7 +4103,7 @@ model CompromissoOrigem { } view ViewProjetoMDO { - id Int @id + id Int nome String codigo String? portfolio_id Int @@ -4138,7 +4138,7 @@ view ViewProjetoMDO { } view ViewProjetoV2 { - id Int @id + id Int nome String codigo String? portfolio_id Int @@ -4183,7 +4183,7 @@ view ViewProjetoV2 { } view ViewVariavelGlobal { - id Int @id + id Int variavel Variavel @relation(fields: [id], references: [id]) titulo String codigo String @@ -4963,7 +4963,7 @@ view view_api_request_log { // view que já faz o join dos registros da meta_orgao onde responsavel=true view view_meta_pessoa_responsavel { - id Int @id @default(autoincrement()) + id Int meta_id Int pessoa_id Int @@ -4973,7 +4973,7 @@ view view_meta_pessoa_responsavel { } view view_atividade_pessoa_responsavel { - id Int @id @default(autoincrement()) + id Int atividade_id Int iniciativa_id Int @@ -4984,7 +4984,7 @@ view view_atividade_pessoa_responsavel { } view view_iniciativa_pessoa_responsavel { - id Int @id @default(autoincrement()) + id Int iniciativa_id Int meta_id Int @@ -4995,7 +4995,7 @@ view view_iniciativa_pessoa_responsavel { // view que já faz o join o filtro onde PDM.coordenador_responsavel_cp=true view view_meta_pessoa_responsavel_na_cp { - id Int @id @default(autoincrement()) + id Int meta_id Int pessoa_id Int @@ -5289,7 +5289,7 @@ model MetaStatusAtrasoVariavel { } view view_pdm_meta_iniciativa_atividade { - meta_id Int @id + meta_id Int pdm_id Int iniciativa_id Int? atividade_id Int? @@ -5304,13 +5304,13 @@ view view_pdm_meta_iniciativa_atividade { // helper para subir atividade/iniciativa -> meta_id view view_meta_cronograma { - cronograma_id Int @id + cronograma_id Int meta_id Int } // helper para subir etapa com atividade/iniciativa -> meta_id view view_etapa_rel_meta { - etapa_id Int @id + etapa_id Int meta_id Int atividade_id Int? iniciativa_id Int? @@ -5319,7 +5319,7 @@ view view_etapa_rel_meta { } view view_etapa_rel_meta_indicador { - etapa_id Int @id @default(autoincrement()) + etapa_id Int tipo String meta_id Int? @@ -6798,7 +6798,7 @@ model Nota { } view ViewNotas { - id Int @id @default(autoincrement()) + id Int bloco_nota_id Int tipo_nota_id Int @@ -6833,7 +6833,7 @@ view ViewNotas { } view ViewNotasTransferencias { - id Int @id @default(autoincrement()) + id Int bloco_nota_id Int data_nota DateTime @db.Date @@ -6930,7 +6930,7 @@ model TransferenciaStatusConsolidado { } view ViewTransferenciaAnalise { - transferencia_id Int @id + transferencia_id Int transferencia Transferencia @relation(fields: [transferencia_id], references: [id]) workflow_finalizado Boolean @@ -6951,7 +6951,7 @@ view ViewTransferenciaAnalise { } view ViewRankingTransferenciaParlamentar { - parlamentar_id Int @id + parlamentar_id Int parlamentar Parlamentar @relation(fields: [parlamentar_id], references: [id]) nome_popular String @@ -7743,7 +7743,7 @@ model SerieVariavelHistorico { } view ViewPainelEstrategicoProjetos { - projeto_id Int @id + projeto_id Int projeto Projeto @relation(fields: [projeto_id], references: [id]) orgao_responsavel_id Int? orgao_responsavel Orgao? @relation(fields: [orgao_responsavel_id], references: [id]) @@ -7819,7 +7819,7 @@ model PsDashboardConsolidado { } view view_ps_dashboard_consolidado { - id Int @id + id Int item_id Int tipo PsDashboardConsolidadoTipo pdm_id Int diff --git a/backend/src/api-logs/backup-scheduler.service.ts b/backend/src/api-logs/backup-scheduler.service.ts index 8505d92ec1..c75e814003 100644 --- a/backend/src/api-logs/backup-scheduler.service.ts +++ b/backend/src/api-logs/backup-scheduler.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; import { Cron, CronExpression } from '@nestjs/schedule'; -import { task_type } from '@prisma/client'; +import { Prisma, task_type } from '@prisma/client'; import { DateTime } from 'luxon'; import { SmaeConfigService } from 'src/common/services/smae-config.service'; import { PrismaService } from 'src/prisma/prisma.service'; @@ -55,9 +55,7 @@ export class BackupSchedulerService { } } - private async scheduleApiLogBackupTasks( - tx: Omit - ) { + private async scheduleApiLogBackupTasks(tx: Prisma.TransactionClient) { await tx.apiRequestLogControl.updateMany({ where: { status: 'BACKING_UP', diff --git a/backend/src/prisma/prisma.service.ts b/backend/src/prisma/prisma.service.ts index a3c81fde22..89b8da3055 100644 --- a/backend/src/prisma/prisma.service.ts +++ b/backend/src/prisma/prisma.service.ts @@ -1,107 +1,69 @@ import { Injectable, OnModuleInit } from '@nestjs/common'; import { Prisma, PrismaClient } from '@prisma/client'; import { UnwrapTuple } from '@prisma/client/runtime/library'; -import { fieldEncryptionMiddleware } from 'prisma-field-encryption'; +import { fieldEncryptionExtension } from 'prisma-field-encryption'; import { RetryPromise } from '../common/retryPromise'; -class PrismaServiceBase extends PrismaClient implements OnModuleInit { - constructor() { - super({ - log: [ - { - emit: 'event', - level: 'query', - }, - { - emit: 'stdout', - level: 'error', - }, - { - emit: 'stdout', - level: 'info', - }, - { - emit: 'stdout', - level: 'warn', - }, - ], - }); - // ta deprecated, mas o extensions ta um caos no nestjs: - // ver https://github.com/prisma/prisma/issues/18628 - this.$use(fieldEncryptionMiddleware()); - } - - async onModuleInit() { - await this.$connect(); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - this.$on('query', async (e: any) => { - if (process.env.NODE_ENV == 'test' && !process.env.DEBUG) return; - if (process.env.DISABLE_QUERY_LOG) return; - // se ta diferente de 1, entao ta ligado sempre - // já faz o log - if (process.env.INTERNAL_DISABLE_QUERY_LOG !== '1' && e.query != 'SELECT 1' && e.query != 'COMMIT') { - console.log(`${e.query} ${e.params} took ${e.duration}ms`); - } else { - // aqui apenas algumas queries que não queremos o log - // as outras queries, se por acaso acontecer de ter um evento - // entre o await a mudança do INTERNAL_DISABLE_QUERY_LOG - // esse if vai pegar pra tratar - const query = e.query as string; - - if ( - query && - query !== 'BEGIN' && - query !== 'COMMIT' && - query !== 'SELECT 1' && - query !== 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED' && - /(?:pg_try_advisory_xact_lock|task_queue|org_device_activation_data_pending_sync_queue|formula_composta|relatorio_fila)/.test( - query - ) !== true - ) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - console.log(`${e.query} ${e.params} took ${e.duration}ms`); - } - }); - } -} +const logConfig = [ + { + emit: 'event' as const, + level: 'query' as const, + }, + { + emit: 'stdout' as const, + level: 'error' as const, + }, + { + emit: 'stdout' as const, + level: 'info' as const, + }, + { + emit: 'stdout' as const, + level: 'warn' as const, + }, +]; @Injectable() -export class PrismaService extends PrismaServiceBase { - constructor() { - super(); - } - - async $transaction

[]>( - arg: [...P], - options?: { isolationLevel?: Prisma.TransactionIsolationLevel } - ): Promise>; - async $transaction( - fn: (prisma: Omit) => Promise, - options?: { maxWait?: number; timeout?: number; isolationLevel?: Prisma.TransactionIsolationLevel } - ): Promise; - - async $transaction(arg: any, options?: any): Promise { - if (Array.isArray(arg)) { - const transactionPromiseFn = async () => { - return super.$transaction(arg, options); - }; +export class PrismaService extends PrismaClient implements OnModuleInit { + // Stub method - will be replaced by Proxy + async onModuleInit() {} - return RetryPromise(transactionPromiseFn, 10, 10000, 2000); - } else if (typeof arg === 'function') { - if (!options) options = {}; - - if (options.timeout === undefined) options.timeout = 60 * 1000; - if (options.maxWait === undefined) options.maxWait = 45 * 1000; - - const transactionPromiseFn = async () => { - return super.$transaction(arg, options); - }; + constructor() { + super({ log: logConfig }); + // Apply field encryption extension immediately + const extended = this.$extends(fieldEncryptionExtension()); - return RetryPromise(transactionPromiseFn, 10, 10000, 2000); - } + // Proxy to intercept onModuleInit and $transaction while delegating everything else + return new Proxy(extended, { + get(target, prop, receiver) { + if (prop === 'onModuleInit') { + return async function (this: any) { + await target.$connect(); + }; + } + if (prop === '$transaction') { + return async function (arg: any, options?: any) { + if (Array.isArray(arg)) { + const transactionPromiseFn = async () => { + return target.$transaction(arg, options); + }; + return RetryPromise(transactionPromiseFn, 10, 10000, 2000); + } else if (typeof arg === 'function') { + if (!options) options = {}; + if (options.timeout === undefined) options.timeout = 60 * 1000; + if (options.maxWait === undefined) options.maxWait = 45 * 1000; - throw new Error('Invalid arguments passed to $transaction'); + const transactionPromiseFn = async () => { + return target.$transaction(arg, options); + }; + return RetryPromise(transactionPromiseFn, 10, 10000, 2000); + } + throw new Error('Invalid arguments passed to $transaction'); + }; + } + // Delegate everything else to the extended client + return Reflect.get(target, prop, receiver); + }, + }) as any; } }