build
This commit is contained in:
commit
2cedd41095
19 changed files with 760 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
node_modules
|
||||
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "biomejs.biome"
|
||||
}
|
||||
}
|
||||
1
README.md
Normal file
1
README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
# drivers
|
||||
7
biome.json
Normal file
7
biome.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
|
||||
"extends": ["node_modules/~comuns/Documentos/biome.json"],
|
||||
"files": {
|
||||
"ignore": []
|
||||
}
|
||||
}
|
||||
1
dist-import/index.d.ts
vendored
Normal file
1
dist-import/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./respostas";
|
||||
1
dist-import/index.js
Normal file
1
dist-import/index.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./respostas";
|
||||
34
dist-import/respostas.d.ts
vendored
Normal file
34
dist-import/respostas.d.ts
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
export type tipoRespostaSucesso<T> = {
|
||||
cod: 200;
|
||||
valor: T;
|
||||
mensagem: undefined;
|
||||
eErro: false;
|
||||
eCerto: true;
|
||||
detalhe?: undefined;
|
||||
};
|
||||
export type tipoRespostaErro = {
|
||||
cod: 400 | 401 | 500;
|
||||
valor: undefined;
|
||||
mensagem: string;
|
||||
eErro: true;
|
||||
eCerto: false;
|
||||
detalhe?: string[];
|
||||
};
|
||||
export type tipoResposta<T> = tipoRespostaSucesso<T> | tipoRespostaErro;
|
||||
export declare const gerarRespostas: <T>(registrarErroInterno: (erro: T) => Partial<tipoRespostaErro>) => {
|
||||
valor: <T_1>(valor: T_1) => tipoRespostaSucesso<T_1>;
|
||||
valorTrue: () => tipoRespostaSucesso<true>;
|
||||
erro: (mensagem: string) => tipoRespostaErro;
|
||||
erroPermissao: (mensagem?: string) => tipoRespostaErro;
|
||||
erroInterno: (parametros: T, mensagem?: string) => tipoRespostaErro;
|
||||
};
|
||||
/**
|
||||
* Uso de respostas em comuns
|
||||
*/
|
||||
export declare const respostaComuns: {
|
||||
valor: <T>(valor: T) => tipoRespostaSucesso<T>;
|
||||
valorTrue: () => tipoRespostaSucesso<true>;
|
||||
erro: (mensagem: string) => tipoRespostaErro;
|
||||
erroPermissao: (mensagem?: string) => tipoRespostaErro;
|
||||
erroInterno: (parametros: unknown, mensagem?: string) => tipoRespostaErro;
|
||||
};
|
||||
76
dist-import/respostas.js
Normal file
76
dist-import/respostas.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
export const gerarRespostas = (registrarErroInterno) => {
|
||||
/**
|
||||
* Gera uma resposta de sucesso
|
||||
*/
|
||||
const valor = (valor) => {
|
||||
return {
|
||||
cod: 200,
|
||||
valor,
|
||||
mensagem: undefined,
|
||||
eErro: false,
|
||||
eCerto: true,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Gera uma resposta de sucesso com valor true
|
||||
*/
|
||||
const valorTrue = () => {
|
||||
return {
|
||||
cod: 200,
|
||||
valor: true,
|
||||
mensagem: undefined,
|
||||
eErro: false,
|
||||
eCerto: true,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Gera uma resposta de erro conhecido
|
||||
*/
|
||||
const erro = (mensagem) => {
|
||||
return {
|
||||
cod: 400,
|
||||
valor: undefined,
|
||||
mensagem,
|
||||
eErro: true,
|
||||
eCerto: false,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Gera uma resposta de erro de permissão,será necessário fazer o login novamente
|
||||
*/
|
||||
const erroPermissao = (mensagem) => {
|
||||
return {
|
||||
cod: 401,
|
||||
valor: undefined,
|
||||
mensagem: mensagem || "Sem permissão para esse recurso.",
|
||||
eErro: true,
|
||||
eCerto: false,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Gera uma resposta de erro desconhecido, geralmente tem origem de um exception
|
||||
*/
|
||||
const erroInterno = (parametros, mensagem) => {
|
||||
const resRegistro = registrarErroInterno(parametros);
|
||||
const mensagemFim = `${mensagem || "Erro interno"}`;
|
||||
return {
|
||||
cod: 500,
|
||||
valor: undefined,
|
||||
mensagem: mensagemFim,
|
||||
eErro: true,
|
||||
eCerto: false,
|
||||
...resRegistro,
|
||||
};
|
||||
};
|
||||
return {
|
||||
valor,
|
||||
valorTrue,
|
||||
erro,
|
||||
erroPermissao,
|
||||
erroInterno,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Uso de respostas em comuns
|
||||
*/
|
||||
export const respostaComuns = gerarRespostas(() => ({}));
|
||||
1
dist-require/index.d.ts
vendored
Normal file
1
dist-require/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./respostas";
|
||||
17
dist-require/index.js
Normal file
17
dist-require/index.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./respostas"), exports);
|
||||
34
dist-require/respostas.d.ts
vendored
Normal file
34
dist-require/respostas.d.ts
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
export type tipoRespostaSucesso<T> = {
|
||||
cod: 200;
|
||||
valor: T;
|
||||
mensagem: undefined;
|
||||
eErro: false;
|
||||
eCerto: true;
|
||||
detalhe?: undefined;
|
||||
};
|
||||
export type tipoRespostaErro = {
|
||||
cod: 400 | 401 | 500;
|
||||
valor: undefined;
|
||||
mensagem: string;
|
||||
eErro: true;
|
||||
eCerto: false;
|
||||
detalhe?: string[];
|
||||
};
|
||||
export type tipoResposta<T> = tipoRespostaSucesso<T> | tipoRespostaErro;
|
||||
export declare const gerarRespostas: <T>(registrarErroInterno: (erro: T) => Partial<tipoRespostaErro>) => {
|
||||
valor: <T_1>(valor: T_1) => tipoRespostaSucesso<T_1>;
|
||||
valorTrue: () => tipoRespostaSucesso<true>;
|
||||
erro: (mensagem: string) => tipoRespostaErro;
|
||||
erroPermissao: (mensagem?: string) => tipoRespostaErro;
|
||||
erroInterno: (parametros: T, mensagem?: string) => tipoRespostaErro;
|
||||
};
|
||||
/**
|
||||
* Uso de respostas em comuns
|
||||
*/
|
||||
export declare const respostaComuns: {
|
||||
valor: <T>(valor: T) => tipoRespostaSucesso<T>;
|
||||
valorTrue: () => tipoRespostaSucesso<true>;
|
||||
erro: (mensagem: string) => tipoRespostaErro;
|
||||
erroPermissao: (mensagem?: string) => tipoRespostaErro;
|
||||
erroInterno: (parametros: unknown, mensagem?: string) => tipoRespostaErro;
|
||||
};
|
||||
80
dist-require/respostas.js
Normal file
80
dist-require/respostas.js
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.respostaComuns = exports.gerarRespostas = void 0;
|
||||
const gerarRespostas = (registrarErroInterno) => {
|
||||
/**
|
||||
* Gera uma resposta de sucesso
|
||||
*/
|
||||
const valor = (valor) => {
|
||||
return {
|
||||
cod: 200,
|
||||
valor,
|
||||
mensagem: undefined,
|
||||
eErro: false,
|
||||
eCerto: true,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Gera uma resposta de sucesso com valor true
|
||||
*/
|
||||
const valorTrue = () => {
|
||||
return {
|
||||
cod: 200,
|
||||
valor: true,
|
||||
mensagem: undefined,
|
||||
eErro: false,
|
||||
eCerto: true,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Gera uma resposta de erro conhecido
|
||||
*/
|
||||
const erro = (mensagem) => {
|
||||
return {
|
||||
cod: 400,
|
||||
valor: undefined,
|
||||
mensagem,
|
||||
eErro: true,
|
||||
eCerto: false,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Gera uma resposta de erro de permissão,será necessário fazer o login novamente
|
||||
*/
|
||||
const erroPermissao = (mensagem) => {
|
||||
return {
|
||||
cod: 401,
|
||||
valor: undefined,
|
||||
mensagem: mensagem || "Sem permissão para esse recurso.",
|
||||
eErro: true,
|
||||
eCerto: false,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Gera uma resposta de erro desconhecido, geralmente tem origem de um exception
|
||||
*/
|
||||
const erroInterno = (parametros, mensagem) => {
|
||||
const resRegistro = registrarErroInterno(parametros);
|
||||
const mensagemFim = `${mensagem || "Erro interno"}`;
|
||||
return {
|
||||
cod: 500,
|
||||
valor: undefined,
|
||||
mensagem: mensagemFim,
|
||||
eErro: true,
|
||||
eCerto: false,
|
||||
...resRegistro,
|
||||
};
|
||||
};
|
||||
return {
|
||||
valor,
|
||||
valorTrue,
|
||||
erro,
|
||||
erroPermissao,
|
||||
erroInterno,
|
||||
};
|
||||
};
|
||||
exports.gerarRespostas = gerarRespostas;
|
||||
/**
|
||||
* Uso de respostas em comuns
|
||||
*/
|
||||
exports.respostaComuns = (0, exports.gerarRespostas)(() => ({}));
|
||||
32
package.json
Normal file
32
package.json
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "~respostas",
|
||||
"version": "0.2.0",
|
||||
"description": "",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist-import/index.js",
|
||||
"require": "./dist-require/index.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build-back": "rm -fr dist-require && tsc --project ./tsconfig-back.json",
|
||||
"build-front": "rm -fr dist-import && tsc --project ./tsconfig-front.json",
|
||||
"build": "pnpm run biome && npm --no-git-tag-version version minor && pnpm run build-back && pnpm run build-front",
|
||||
"biome": "npx @biomejs/biome check --apply ./src",
|
||||
"nodev": "check-node-version --node '>= 20'"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.7.3",
|
||||
"@types/node": "^20.12.7",
|
||||
"check-node-version": "^4.2.1",
|
||||
"~comuns": "git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#producao",
|
||||
"typescript": "^4.8.4"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"zod": "3.23.8"
|
||||
}
|
||||
}
|
||||
247
pnpm-lock.yaml
generated
Normal file
247
pnpm-lock.yaml
generated
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
zod:
|
||||
specifier: 3.23.8
|
||||
version: 3.23.8
|
||||
devDependencies:
|
||||
'@biomejs/biome':
|
||||
specifier: 1.7.3
|
||||
version: 1.7.3
|
||||
'@types/node':
|
||||
specifier: ^20.12.7
|
||||
version: 20.14.0
|
||||
check-node-version:
|
||||
specifier: ^4.2.1
|
||||
version: 4.2.1
|
||||
typescript:
|
||||
specifier: ^4.8.4
|
||||
version: 4.9.5
|
||||
~comuns:
|
||||
specifier: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#producao
|
||||
version: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#0482d3c102440334a120afd0327234a888892534(typescript@4.9.5)
|
||||
|
||||
packages:
|
||||
|
||||
'@biomejs/biome@1.7.3':
|
||||
resolution: {integrity: sha512-ogFQI+fpXftr+tiahA6bIXwZ7CSikygASdqMtH07J2cUzrpjyTMVc9Y97v23c7/tL1xCZhM+W9k4hYIBm7Q6cQ==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
hasBin: true
|
||||
|
||||
'@biomejs/cli-darwin-arm64@1.7.3':
|
||||
resolution: {integrity: sha512-eDvLQWmGRqrPIRY7AIrkPHkQ3visEItJKkPYSHCscSDdGvKzYjmBJwG1Gu8+QC5ed6R7eiU63LEC0APFBobmfQ==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@biomejs/cli-darwin-x64@1.7.3':
|
||||
resolution: {integrity: sha512-JXCaIseKRER7dIURsVlAJacnm8SG5I0RpxZ4ya3dudASYUc68WGl4+FEN03ABY3KMIq7hcK1tzsJiWlmXyosZg==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@biomejs/cli-linux-arm64-musl@1.7.3':
|
||||
resolution: {integrity: sha512-c8AlO45PNFZ1BYcwaKzdt46kYbuP6xPGuGQ6h4j3XiEDpyseRRUy/h+6gxj07XovmyxKnSX9GSZ6nVbZvcVUAw==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-linux-arm64@1.7.3':
|
||||
resolution: {integrity: sha512-phNTBpo7joDFastnmZsFjYcDYobLTx4qR4oPvc9tJ486Bd1SfEVPHEvJdNJrMwUQK56T+TRClOQd/8X1nnjA9w==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-linux-x64-musl@1.7.3':
|
||||
resolution: {integrity: sha512-UdEHKtYGWEX3eDmVWvQeT+z05T9/Sdt2+F/7zmMOFQ7boANeX8pcO6EkJPK3wxMudrApsNEKT26rzqK6sZRTRA==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-linux-x64@1.7.3':
|
||||
resolution: {integrity: sha512-vnedYcd5p4keT3iD48oSKjOIRPYcjSNNbd8MO1bKo9ajg3GwQXZLAH+0Cvlr+eMsO67/HddWmscSQwTFrC/uPA==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@biomejs/cli-win32-arm64@1.7.3':
|
||||
resolution: {integrity: sha512-unNCDqUKjujYkkSxs7gFIfdasttbDC4+z0kYmcqzRk6yWVoQBL4dNLcCbdnJS+qvVDNdI9rHp2NwpQ0WAdla4Q==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@biomejs/cli-win32-x64@1.7.3':
|
||||
resolution: {integrity: sha512-ZmByhbrnmz/UUFYB622CECwhKIPjJLLPr5zr3edhu04LzbfcOrz16VYeNq5dpO1ADG70FORhAJkaIGdaVBG00w==}
|
||||
engines: {node: '>=14.21.3'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@types/node@20.14.0':
|
||||
resolution: {integrity: sha512-5cHBxFGJx6L4s56Bubp4fglrEpmyJypsqI6RgzMfBHWUJQGWAAi8cWcgetEbZXHYXo9C2Fa4EEds/uSyS4cxmA==}
|
||||
|
||||
ansi-styles@4.3.0:
|
||||
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
chalk@3.0.0:
|
||||
resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
check-node-version@4.2.1:
|
||||
resolution: {integrity: sha512-YYmFYHV/X7kSJhuN/QYHUu998n/TRuDe8UenM3+m5NrkiH670lb9ILqHIvBencvJc4SDh+XcbXMR4b+TtubJiw==}
|
||||
engines: {node: '>=8.3.0'}
|
||||
hasBin: true
|
||||
|
||||
color-convert@2.0.1:
|
||||
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
||||
engines: {node: '>=7.0.0'}
|
||||
|
||||
color-name@1.1.4:
|
||||
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||
|
||||
has-flag@4.0.0:
|
||||
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
map-values@1.0.1:
|
||||
resolution: {integrity: sha512-BbShUnr5OartXJe1GeccAWtfro11hhgNJg6G9/UtWKjVGvV5U4C09cg5nk8JUevhXODaXY+hQ3xxMUKSs62ONQ==}
|
||||
|
||||
minimist@1.2.8:
|
||||
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
||||
|
||||
object-filter@1.0.2:
|
||||
resolution: {integrity: sha512-NahvP2vZcy1ZiiYah30CEPw0FpDcSkSePJBMpzl5EQgCmISijiGuJm3SPYp7U+Lf2TljyaIw3E5EgkEx/TNEVA==}
|
||||
|
||||
queue-microtask@1.2.3:
|
||||
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
|
||||
|
||||
run-parallel@1.2.0:
|
||||
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
|
||||
|
||||
semver@6.3.1:
|
||||
resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==}
|
||||
hasBin: true
|
||||
|
||||
supports-color@7.2.0:
|
||||
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
typescript@4.9.5:
|
||||
resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
|
||||
engines: {node: '>=4.2.0'}
|
||||
hasBin: true
|
||||
|
||||
undici-types@5.26.5:
|
||||
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
|
||||
|
||||
zod@3.23.8:
|
||||
resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==}
|
||||
|
||||
~comuns@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#0482d3c102440334a120afd0327234a888892534:
|
||||
resolution: {commit: 0482d3c102440334a120afd0327234a888892534, repo: http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git, type: git}
|
||||
version: 0.21.0
|
||||
peerDependencies:
|
||||
typescript: ^5.0.0
|
||||
|
||||
snapshots:
|
||||
|
||||
'@biomejs/biome@1.7.3':
|
||||
optionalDependencies:
|
||||
'@biomejs/cli-darwin-arm64': 1.7.3
|
||||
'@biomejs/cli-darwin-x64': 1.7.3
|
||||
'@biomejs/cli-linux-arm64': 1.7.3
|
||||
'@biomejs/cli-linux-arm64-musl': 1.7.3
|
||||
'@biomejs/cli-linux-x64': 1.7.3
|
||||
'@biomejs/cli-linux-x64-musl': 1.7.3
|
||||
'@biomejs/cli-win32-arm64': 1.7.3
|
||||
'@biomejs/cli-win32-x64': 1.7.3
|
||||
|
||||
'@biomejs/cli-darwin-arm64@1.7.3':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-darwin-x64@1.7.3':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-arm64-musl@1.7.3':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-arm64@1.7.3':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-x64-musl@1.7.3':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-linux-x64@1.7.3':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-win32-arm64@1.7.3':
|
||||
optional: true
|
||||
|
||||
'@biomejs/cli-win32-x64@1.7.3':
|
||||
optional: true
|
||||
|
||||
'@types/node@20.14.0':
|
||||
dependencies:
|
||||
undici-types: 5.26.5
|
||||
|
||||
ansi-styles@4.3.0:
|
||||
dependencies:
|
||||
color-convert: 2.0.1
|
||||
|
||||
chalk@3.0.0:
|
||||
dependencies:
|
||||
ansi-styles: 4.3.0
|
||||
supports-color: 7.2.0
|
||||
|
||||
check-node-version@4.2.1:
|
||||
dependencies:
|
||||
chalk: 3.0.0
|
||||
map-values: 1.0.1
|
||||
minimist: 1.2.8
|
||||
object-filter: 1.0.2
|
||||
run-parallel: 1.2.0
|
||||
semver: 6.3.1
|
||||
|
||||
color-convert@2.0.1:
|
||||
dependencies:
|
||||
color-name: 1.1.4
|
||||
|
||||
color-name@1.1.4: {}
|
||||
|
||||
has-flag@4.0.0: {}
|
||||
|
||||
map-values@1.0.1: {}
|
||||
|
||||
minimist@1.2.8: {}
|
||||
|
||||
object-filter@1.0.2: {}
|
||||
|
||||
queue-microtask@1.2.3: {}
|
||||
|
||||
run-parallel@1.2.0:
|
||||
dependencies:
|
||||
queue-microtask: 1.2.3
|
||||
|
||||
semver@6.3.1: {}
|
||||
|
||||
supports-color@7.2.0:
|
||||
dependencies:
|
||||
has-flag: 4.0.0
|
||||
|
||||
typescript@4.9.5: {}
|
||||
|
||||
undici-types@5.26.5: {}
|
||||
|
||||
zod@3.23.8: {}
|
||||
|
||||
~comuns@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#0482d3c102440334a120afd0327234a888892534(typescript@4.9.5):
|
||||
dependencies:
|
||||
typescript: 4.9.5
|
||||
zod: 3.23.8
|
||||
1
src/index.ts
Normal file
1
src/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./respostas"
|
||||
108
src/respostas.ts
Normal file
108
src/respostas.ts
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
export type tipoRespostaSucesso<T> = {
|
||||
cod: 200
|
||||
valor: T
|
||||
mensagem: undefined
|
||||
eErro: false
|
||||
eCerto: true
|
||||
detalhe?: undefined
|
||||
}
|
||||
|
||||
export type tipoRespostaErro = {
|
||||
//400 é um erro conhecido,
|
||||
//500 é um erro desconhecido, geralmente tem origem de um exception
|
||||
cod: 400 | 401 | 500
|
||||
valor: undefined
|
||||
mensagem: string
|
||||
eErro: true
|
||||
eCerto: false
|
||||
detalhe?: string[]
|
||||
}
|
||||
|
||||
export type tipoResposta<T> = tipoRespostaSucesso<T> | tipoRespostaErro
|
||||
|
||||
export const gerarRespostas = <T>(
|
||||
registrarErroInterno: (erro: T) => Partial<tipoRespostaErro>,
|
||||
) => {
|
||||
/**
|
||||
* Gera uma resposta de sucesso
|
||||
*/
|
||||
const valor = <T>(valor: T): tipoRespostaSucesso<T> => {
|
||||
return {
|
||||
cod: 200,
|
||||
valor,
|
||||
mensagem: undefined,
|
||||
eErro: false,
|
||||
eCerto: true,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gera uma resposta de sucesso com valor true
|
||||
*/
|
||||
const valorTrue = (): tipoRespostaSucesso<true> => {
|
||||
return {
|
||||
cod: 200,
|
||||
valor: true,
|
||||
mensagem: undefined,
|
||||
eErro: false,
|
||||
eCerto: true,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gera uma resposta de erro conhecido
|
||||
*/
|
||||
const erro = (mensagem: string): tipoRespostaErro => {
|
||||
return {
|
||||
cod: 400,
|
||||
valor: undefined,
|
||||
mensagem,
|
||||
eErro: true,
|
||||
eCerto: false,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gera uma resposta de erro de permissão,será necessário fazer o login novamente
|
||||
*/
|
||||
const erroPermissao = (mensagem?: string): tipoRespostaErro => {
|
||||
return {
|
||||
cod: 401,
|
||||
valor: undefined,
|
||||
mensagem: mensagem || "Sem permissão para esse recurso.",
|
||||
eErro: true,
|
||||
eCerto: false,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gera uma resposta de erro desconhecido, geralmente tem origem de um exception
|
||||
*/
|
||||
const erroInterno = (parametros: T, mensagem?: string): tipoRespostaErro => {
|
||||
const resRegistro = registrarErroInterno(parametros)
|
||||
|
||||
const mensagemFim = `${mensagem || "Erro interno"}`
|
||||
|
||||
return {
|
||||
cod: 500,
|
||||
valor: undefined,
|
||||
mensagem: mensagemFim,
|
||||
eErro: true,
|
||||
eCerto: false,
|
||||
...resRegistro,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
valor,
|
||||
valorTrue,
|
||||
erro,
|
||||
erroPermissao,
|
||||
erroInterno,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uso de respostas em comuns
|
||||
*/
|
||||
export const respostaComuns = gerarRespostas(() => ({}))
|
||||
7
tsconfig-back.json
Normal file
7
tsconfig-back.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"extends": "./tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist-require",
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
7
tsconfig-front.json
Normal file
7
tsconfig-front.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"extends": "./tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist-import",
|
||||
"module": "ES6"
|
||||
}
|
||||
}
|
||||
100
tsconfig.json
Normal file
100
tsconfig.json
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||
|
||||
/* Projects */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
|
||||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
|
||||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "ES2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
||||
"lib": ["dom.iterable"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
"experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */,
|
||||
"emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
|
||||
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
|
||||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||
|
||||
/* Modules */
|
||||
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
||||
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
// "resolveJsonModule": true, /* Enable importing .json files */
|
||||
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
|
||||
|
||||
/* JavaScript Support */
|
||||
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
|
||||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
|
||||
|
||||
/* Emit */
|
||||
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
|
||||
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
|
||||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
|
||||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
||||
|
||||
/* Interop Constraints */
|
||||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true /* Enable all strict type-checking options. */,
|
||||
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
||||
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
|
||||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
|
||||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
|
||||
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
|
||||
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
|
||||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
|
||||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
|
||||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||
|
||||
/* Completeness */
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue