Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ RUN npm --loglevel=error install -g npm@11.4.2

COPY package.json ./
COPY package-lock.json ./
COPY scripts/patch-prisma-exports.js ./scripts/
COPY vendor/ ./vendor/

RUN npm ci

Expand All @@ -28,6 +30,7 @@ COPY tools/install-duckdb-extensions.js ./tools/
RUN node tools/install-duckdb-extensions.js

COPY prisma/schema.prisma ./prisma/
COPY prisma.config.ts ./

RUN npx prisma generate

Expand Down
1,051 changes: 975 additions & 76 deletions backend/package-lock.json

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -34,7 +38,8 @@
"test:e2e:watch": "jest --config ./test/jest-e2e.json --watch",
"test:e2e:cov": "jest --config ./test/jest-e2e.json --coverage --forceExit",
"test:e2e:ci": "jest --config ./test/jest-e2e.json --coverage --forceExit --ci --reporters=default --reporters=jest-junit",
"check:modules": "ts-node tools/check-module-imports.ts"
"check:modules": "ts-node tools/check-module-imports.ts",
"postinstall": "node scripts/patch-prisma-exports.js"
},
"dependencies": {
"@dagrejs/graphlib": "^2.2.4",
Expand All @@ -51,7 +56,8 @@
"@nestjs/schedule": "^6.0.0",
"@nestjs/serve-static": "^5.0.3",
"@nestjs/swagger": "^11.2.0",
"@prisma/client": "^6.12.0",
"@prisma/adapter-pg": "^7.4.2",
"@prisma/client": "^7.4.2",
"@ts-graphviz/adapter": "^2.0.6",
"@turf/simplify": "^7.2.0",
"@types/geojson": "^7946.0.16",
Expand Down Expand Up @@ -79,7 +85,7 @@
"passport-local": "^1.0.0",
"percentile": "^1.6.0",
"pg": "^8.16.3",
"prisma-field-encryption": "^1.6.0",
"prisma-field-encryption": "file:vendor/prisma-field-encryption.tgz",
"reflect-metadata": "^0.2.2",
"request-ip": "^3.3.0",
"rimraf": "^6.0.1",
Expand Down Expand Up @@ -127,7 +133,7 @@
"jest": "30.0.4",
"mjml": "^4.15.3",
"prettier": "^3.6.2",
"prisma": "^6.12.0",
"prisma": "^7.4.2",
"source-map-support": "^0.5.21",
"supertest": "^7.1.3",
"ts-jest": "29.4.0",
Expand Down
12 changes: 12 additions & 0 deletions backend/prisma.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'dotenv/config';
import { defineConfig, env } from 'prisma/config';

export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
datasource: {
url: env('DATABASE_URL'),
},
});
35 changes: 17 additions & 18 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ generator client {

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model Pessoa {
Expand Down Expand Up @@ -4103,7 +4102,7 @@ model CompromissoOrigem {
}

view ViewProjetoMDO {
id Int @id
id Int
nome String
codigo String?
portfolio_id Int
Expand Down Expand Up @@ -4138,7 +4137,7 @@ view ViewProjetoMDO {
}

view ViewProjetoV2 {
id Int @id
id Int
nome String
codigo String?
portfolio_id Int
Expand Down Expand Up @@ -4183,7 +4182,7 @@ view ViewProjetoV2 {
}

view ViewVariavelGlobal {
id Int @id
id Int
variavel Variavel @relation(fields: [id], references: [id])
titulo String
codigo String
Expand Down Expand Up @@ -4963,7 +4962,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
Expand All @@ -4973,7 +4972,7 @@ view view_meta_pessoa_responsavel {
}

view view_atividade_pessoa_responsavel {
id Int @id @default(autoincrement())
id Int

atividade_id Int
iniciativa_id Int
Expand All @@ -4984,7 +4983,7 @@ view view_atividade_pessoa_responsavel {
}

view view_iniciativa_pessoa_responsavel {
id Int @id @default(autoincrement())
id Int

iniciativa_id Int
meta_id Int
Expand All @@ -4995,7 +4994,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
Expand Down Expand Up @@ -5289,7 +5288,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?
Expand All @@ -5304,13 +5303,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?
Expand All @@ -5319,7 +5318,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?
Expand Down Expand Up @@ -6798,7 +6797,7 @@ model Nota {
}

view ViewNotas {
id Int @id @default(autoincrement())
id Int

bloco_nota_id Int
tipo_nota_id Int
Expand Down Expand Up @@ -6833,7 +6832,7 @@ view ViewNotas {
}

view ViewNotasTransferencias {
id Int @id @default(autoincrement())
id Int

bloco_nota_id Int
data_nota DateTime @db.Date
Expand Down Expand Up @@ -6930,7 +6929,7 @@ model TransferenciaStatusConsolidado {
}

view ViewTransferenciaAnalise {
transferencia_id Int @id
transferencia_id Int
transferencia Transferencia @relation(fields: [transferencia_id], references: [id])

workflow_finalizado Boolean
Expand All @@ -6951,7 +6950,7 @@ view ViewTransferenciaAnalise {
}

view ViewRankingTransferenciaParlamentar {
parlamentar_id Int @id
parlamentar_id Int
parlamentar Parlamentar @relation(fields: [parlamentar_id], references: [id])

nome_popular String
Expand Down Expand Up @@ -7743,7 +7742,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])
Expand Down Expand Up @@ -7819,7 +7818,7 @@ model PsDashboardConsolidado {
}

view view_ps_dashboard_consolidado {
id Int @id
id Int
item_id Int
tipo PsDashboardConsolidadoTipo
pdm_id Int
Expand Down
48 changes: 48 additions & 0 deletions backend/scripts/patch-prisma-exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env node
/**
* Patches @prisma/client-runtime-utils package.json to export ./dist subpath.
*
* Prisma 7's NestJS swagger plugin generates require("@prisma/client-runtime-utils/dist")
* in metadata, but the package's exports map doesn't include "./dist".
* Node 24 enforces exports strictly, causing ERR_PACKAGE_PATH_NOT_EXPORTED.
*
* This patch adds "./dist" and "./dist/*" to the exports map.
* Can be removed once Prisma fixes this upstream.
*/
const fs = require('fs');
const path = require('path');

const pkgPath = path.join(
__dirname,
'..',
'node_modules',
'@prisma',
'client-runtime-utils',
'package.json'
);

if (!fs.existsSync(pkgPath)) {
// Package not installed yet, skip
process.exit(0);
}

const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

if (pkg.exports && !pkg.exports['./dist']) {
pkg.exports['./dist'] = {
require: {
types: './dist/index.d.ts',
default: './dist/index.js',
},
import: {
types: './dist/index.d.ts',
default: './dist/index.mjs',
},
};
pkg.exports['./dist/*'] = './dist/*';

fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
console.log('[patch] Added ./dist exports to @prisma/client-runtime-utils');
} else {
console.log('[patch] @prisma/client-runtime-utils exports already patched or not needed');
}
6 changes: 2 additions & 4 deletions backend/src/api-logs/backup-scheduler.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -55,9 +55,7 @@ export class BackupSchedulerService {
}
}

private async scheduleApiLogBackupTasks(
tx: Omit<PrismaService, '$connect' | '$disconnect' | '$on' | '$transaction' | '$use'>
) {
private async scheduleApiLogBackupTasks(tx: Prisma.TransactionClient) {
await tx.apiRequestLogControl.updateMany({
where: {
status: 'BACKING_UP',
Expand Down
2 changes: 1 addition & 1 deletion backend/src/casa-civil/dash/transferencia.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from './dto/transferencia.dto';
import { TransferenciaTipoEsfera } from '@prisma/client';
import { UploadService } from 'src/upload/upload.service';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { Date2YMD } from '../../common/date2ymd';
import { Object2Hash } from 'src/common/object2hash';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { DistribuicaoStatusTipo, ParlamentarCargo } from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { IdSigla, IdSiglaDescricao } from 'src/common/dto/IdSigla.dto';
import { ParlamnetarIdNomes } from 'src/parlamentar/entities/parlamentar.entity';
import { SeiIntegracaoDto } from '../../../sei-integracao/entities/sei-entidade.entity';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
TransferenciaInterface,
TransferenciaTipoEsfera,
} from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { IdNomeDto } from 'src/common/dto/IdNome.dto';
import { IdSigla, IdSiglaDescricao } from 'src/common/dto/IdSigla.dto';
import { ParlamnetarIdNomes } from 'src/parlamentar/entities/parlamentar.entity';
Expand Down
2 changes: 1 addition & 1 deletion backend/src/casa-civil/vinculo/entities/vinculo.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { CampoVinculo, TipoPdm } from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { IdNomeDto } from 'src/common/dto/IdNome.dto';
import { IdSiglaDescricao } from 'src/common/dto/IdSigla.dto';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/indicador/entities/indicador.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IndicadorPreviaOpcao, IndicadorTipo, Periodicidade, Polaridade } from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { FormulaVariaveis } from '../dto/update-indicador.dto';
import { IsDateYMD } from '../../auth/decorators/date.decorator';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { IdCodTituloDto } from '../../common/dto/IdCodTitulo.dto';

export class OrcamentoPlanejado {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { forwardRef, HttpException, Inject, Injectable } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { PessoaFromJwt } from '../auth/models/PessoaFromJwt';
import { RecordWithId } from '../common/dto/record-with-id.dto';
import { DotacaoService } from '../dotacao/dotacao.service';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BadRequestException, HttpException, Injectable, Logger } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { Prisma } from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { DateTime } from 'luxon';
import { SmaeConfigService } from 'src/common/services/smae-config.service';
import { SYSTEM_TIMEZONE } from '../common/date2ymd';
Expand Down
2 changes: 1 addition & 1 deletion backend/src/painel/dto/detalhe-painel.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Periodicidade, Periodo, Prisma, Serie } from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';

export class DetailPainelVisualizacaoDto {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/painel/painel.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BadRequestException, HttpException, Injectable } from '@nestjs/common';
import { PainelConteudoTipoDetalhe, Periodicidade, Periodo, Prisma } from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { DateTime } from 'luxon';
import * as moment from 'moment';
import { PessoaFromJwt } from '../auth/models/PessoaFromJwt';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { ProjetoTipoAditivoDto } from 'src/tipo-aditivo/dto/tipo-aditivo.dto';
import { IsDateYMD } from '../../../auth/decorators/date.decorator';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/pp/contrato/contrato.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpException, Injectable, NotFoundException } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { Decimal } from '@prisma/client/runtime/library';
import { Decimal } from '@prisma/client/runtime/client';
import { RecordWithId } from 'src/common/dto/record-with-id.dto';

import { PessoaFromJwt } from '../../auth/models/PessoaFromJwt';
Expand Down
Loading