Compare commits
No commits in common. "e6fa9640bca97f735c2ce517dbaea76dd2333608" and "8674c1b8da3f9d8f7dfbf547fd6b7475a16bd437" have entirely different histories.
e6fa9640bc
...
8674c1b8da
83 changed files with 950 additions and 5461 deletions
2
.env
Normal file
2
.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
PORTA = '5020'
|
||||
PREFIXO = '/estaticos'
|
||||
|
|
@ -1 +0,0 @@
|
|||
*.tgz
|
||||
28
.vscode/settings.json
vendored
28
.vscode/settings.json
vendored
|
|
@ -1,28 +0,0 @@
|
|||
{
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports.biome": "always",
|
||||
"source.fixAll.biome": "always"
|
||||
},
|
||||
"editor.defaultFormatter": "biomejs.biome",
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "vscode.typescript-language-features"
|
||||
},
|
||||
"[javascriptreact]": {
|
||||
"editor.defaultFormatter": "biomejs.biome"
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "biomejs.biome"
|
||||
},
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": "biomejs.biome"
|
||||
},
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "biomejs.biome"
|
||||
},
|
||||
"[jsonc]": {
|
||||
"editor.defaultFormatter": "biomejs.biome"
|
||||
},
|
||||
"[vue]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +1,34 @@
|
|||
{
|
||||
"$schema": "../node_modules/@biomejs/biome/configuration_schema.json",
|
||||
"root": false,
|
||||
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"correctness": {
|
||||
"noUnusedVariables": "error",
|
||||
"noUnusedImports": "error",
|
||||
"noEmptyPattern": "off",
|
||||
"useExhaustiveDependencies": "off"
|
||||
},
|
||||
"style": {
|
||||
"noParameterAssign": "error",
|
||||
"useAsConstAssertion": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useEnumInitializers": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"noUnusedTemplateLiteral": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noInferrableTypes": "error"
|
||||
},
|
||||
"suspicious": {
|
||||
"noDebugger": "off",
|
||||
"noDoubleEquals": "off",
|
||||
"noExplicitAny": "off",
|
||||
"noDebugger": "off",
|
||||
"noApproximativeNumericConstant": "off",
|
||||
"noAsyncPromiseExecutor": "off"
|
||||
},
|
||||
"style": {
|
||||
"noUselessElse": "off"
|
||||
},
|
||||
"complexity": {
|
||||
"noUselessConstructor": "off",
|
||||
"noBannedTypes": "off",
|
||||
"noForEach": "off",
|
||||
"useLiteralKeys": "off",
|
||||
"useArrowFunction": "warn",
|
||||
"useDateNow": "off",
|
||||
"noUselessFragments":"off"
|
||||
"noUselessConstructor": "off",
|
||||
"useArrowFunction": "off"
|
||||
},
|
||||
"correctness": {
|
||||
"noEmptyPattern": "off",
|
||||
"noUnusedVariables": "error",
|
||||
"noUnusedImports": "error"
|
||||
},
|
||||
"performance": {
|
||||
"noAccumulatingSpread": "off"
|
||||
|
|
@ -47,15 +39,15 @@
|
|||
}
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentWidth": 2,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2
|
||||
"enabled": true
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"semicolons": "asNeeded",
|
||||
"arrowParentheses": "always",
|
||||
"enabled": true,
|
||||
"bracketSameLine": false,
|
||||
"trailingCommas": "all",
|
||||
"attributePosition": "multiline"
|
||||
|
|
|
|||
91
README.md
91
README.md
|
|
@ -1,90 +1 @@
|
|||
## ✅ Uso do BiomeJS para Autoformatação
|
||||
|
||||
Este guia mostra como configurar o [BiomeJS](https://biomejs.dev) para formatar e analisar código JavaScript/TypeScript no seu projeto.
|
||||
|
||||
---
|
||||
|
||||
### 1. Incluir o pacote de configuração comum
|
||||
|
||||
Certifique-se de que o pacote `p-comuns` (ou outro com a configuração compartilhada) esteja disponível no seu projeto. Ele deve conter o arquivo `Documentos/biome.json`.
|
||||
|
||||
pnpm up p-comuns
|
||||
|
||||
---
|
||||
|
||||
### 2. Instalar o Biome com `pnpm`
|
||||
|
||||
```bash
|
||||
pnpm add --save-dev --save-exact @biomejs/biome@2.1.4
|
||||
```
|
||||
|
||||
> 🎯 Use `--save-exact` para garantir consistência de versões entre ambientes.
|
||||
|
||||
---
|
||||
|
||||
### 3. Criar o arquivo de configuração na raiz do projeto
|
||||
|
||||
Crie um arquivo chamado `biome.json` com o seguinte conteúdo:
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
|
||||
"extends": ["./node_modules/p-comuns/Documentos/biome.json"],
|
||||
"files": {
|
||||
"includes": ["src/**/*.{js,ts,jsx,tsx}"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> ⚠️ Verifique o caminho correto do `extends` relativo à raiz do seu projeto. Use `./` sempre que possível para evitar erros de resolução.
|
||||
|
||||
---
|
||||
|
||||
### 4. Adicionar script no `package.json`
|
||||
|
||||
Inclua o comando abaixo em `"scripts"`:
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"biome": "pnpm exec biome check --write",
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Isso permite executar:
|
||||
|
||||
```bash
|
||||
pnpm biome
|
||||
```
|
||||
|
||||
> O comando irá **formatar e aplicar as regras de lint** nos arquivos do diretório `src/`.
|
||||
|
||||
---
|
||||
|
||||
### ✅ Dica extra: formatar todos os arquivos
|
||||
|
||||
Se quiser aplicar o Biome a todo o projeto (não só `src/`), altere o include:
|
||||
|
||||
```json
|
||||
"includes": ["**/*.{js,ts,jsx,tsx}"]
|
||||
```
|
||||
|
||||
|
||||
|
||||
adicionar em .vscode/settings.json
|
||||
|
||||
{
|
||||
"editor.defaultFormatter": "biomejs.biome",
|
||||
"[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[javascriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[json]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[jsonc]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[vue]": {"editor.defaultFormatter": "octref.vetur"},
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports.biome": "always",
|
||||
"source.fixAll.biome": "always"
|
||||
}
|
||||
}
|
||||
# comuns
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
"$schema": "node_modules/@biomejs/biome/configuration_schema.json",
|
||||
"extends": ["Documentos/biome.json"],
|
||||
"files": {
|
||||
"includes": ["src/**/*.{js,ts,jsx,tsx}"]
|
||||
"ignore": []
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
import { defineBuildConfig } from 'unbuild'
|
||||
|
||||
// pnpm exec unbuild
|
||||
|
||||
export default defineBuildConfig({
|
||||
entries: ['src/index'],
|
||||
clean: true,
|
||||
declaration: true,
|
||||
rollup: {
|
||||
emitCJS: true,
|
||||
},
|
||||
})
|
||||
1
dist/aleatorio.d.ts
vendored
Normal file
1
dist/aleatorio.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare const aleatorio: (tamanho?: number) => string;
|
||||
9
dist/aleatorio.js
vendored
Normal file
9
dist/aleatorio.js
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.aleatorio = void 0;
|
||||
const alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
||||
const aleatorio = (tamanho) => `eli-${Array.from({ length: tamanho || 8 })
|
||||
.map(() => alfabeto[((999 * Math.random()) | 0) % alfabeto.length])
|
||||
.join("")}`;
|
||||
exports.aleatorio = aleatorio;
|
||||
//# sourceMappingURL=aleatorio.js.map
|
||||
1
dist/aleatorio.js.map
vendored
Normal file
1
dist/aleatorio.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"aleatorio.js","sourceRoot":"","sources":["../src/aleatorio.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAG,4BAA4B,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AAEhD,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,EAAE,CAC5C,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;KACxC,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;KAClE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;AAHF,QAAA,SAAS,aAGP"}
|
||||
19
dist/constantes.d.ts
vendored
Normal file
19
dist/constantes.d.ts
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
export declare const uuid_null = "00000000-0000-0000-0000-000000000000";
|
||||
/** Colunas Presentes n maioria das tabelas */
|
||||
export declare enum camposComuns {
|
||||
codigo = "codigo",
|
||||
excluido = "excluido",
|
||||
data_hora_criacao = "data_hora_criacao",
|
||||
data_hora_atualizacao = "data_hora_atualizacao",
|
||||
codigo_usuario_criacao = "codigo_usuario_criacao",
|
||||
codigo_usuario_atualizacao = "codigo_usuario_atualizacao",
|
||||
versao = "__versao"
|
||||
}
|
||||
/** Palavras comumente usadas */
|
||||
export declare enum tx {
|
||||
token = "token"
|
||||
}
|
||||
export declare enum tipoUsuarioResiduos {
|
||||
Usuario = "usuario",
|
||||
Fornecedor = "fornecedor"
|
||||
}
|
||||
26
dist/constantes.js
vendored
Normal file
26
dist/constantes.js
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.tipoUsuarioResiduos = exports.tx = exports.camposComuns = exports.uuid_null = void 0;
|
||||
exports.uuid_null = "00000000-0000-0000-0000-000000000000";
|
||||
/** Colunas Presentes n maioria das tabelas */
|
||||
var camposComuns;
|
||||
(function (camposComuns) {
|
||||
camposComuns["codigo"] = "codigo";
|
||||
camposComuns["excluido"] = "excluido";
|
||||
camposComuns["data_hora_criacao"] = "data_hora_criacao";
|
||||
camposComuns["data_hora_atualizacao"] = "data_hora_atualizacao";
|
||||
camposComuns["codigo_usuario_criacao"] = "codigo_usuario_criacao";
|
||||
camposComuns["codigo_usuario_atualizacao"] = "codigo_usuario_atualizacao";
|
||||
camposComuns["versao"] = "__versao";
|
||||
})(camposComuns || (exports.camposComuns = camposComuns = {}));
|
||||
/** Palavras comumente usadas */
|
||||
var tx;
|
||||
(function (tx) {
|
||||
tx["token"] = "token";
|
||||
})(tx || (exports.tx = tx = {}));
|
||||
var tipoUsuarioResiduos;
|
||||
(function (tipoUsuarioResiduos) {
|
||||
tipoUsuarioResiduos["Usuario"] = "usuario";
|
||||
tipoUsuarioResiduos["Fornecedor"] = "fornecedor";
|
||||
})(tipoUsuarioResiduos || (exports.tipoUsuarioResiduos = tipoUsuarioResiduos = {}));
|
||||
//# sourceMappingURL=constantes.js.map
|
||||
1
dist/constantes.js.map
vendored
Normal file
1
dist/constantes.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"constantes.js","sourceRoot":"","sources":["../src/constantes.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,sCAAsC,CAAA;AAE/D,8CAA8C;AAC9C,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,qCAAqB,CAAA;IACrB,uDAAuC,CAAA;IACvC,+DAA+C,CAAA;IAC/C,iEAAiD,CAAA;IACjD,yEAAyD,CAAA;IACzD,mCAAmB,CAAA;AACrB,CAAC,EARW,YAAY,4BAAZ,YAAY,QAQvB;AAED,gCAAgC;AAChC,IAAY,EAEX;AAFD,WAAY,EAAE;IACZ,qBAAe,CAAA;AACjB,CAAC,EAFW,EAAE,kBAAF,EAAE,QAEb;AAED,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,gDAAyB,CAAA;AAC3B,CAAC,EAHW,mBAAmB,mCAAnB,mBAAmB,QAG9B"}
|
||||
26
dist/consulta.d.ts
vendored
Normal file
26
dist/consulta.d.ts
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
export declare enum operadores {
|
||||
"=" = "=",
|
||||
"!=" = "!=",
|
||||
">" = ">",
|
||||
">=" = ">=",
|
||||
"<" = "<",
|
||||
"<=" = "<=",
|
||||
like = "like",
|
||||
in = "in"
|
||||
}
|
||||
export type tipoFiltro = {
|
||||
coluna: string;
|
||||
valor: any;
|
||||
operador: keyof typeof operadores | operadores;
|
||||
ou?: boolean;
|
||||
};
|
||||
export type interfaceConsulta = {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
filtros?: tipoFiltro[];
|
||||
ordem?: string;
|
||||
ordemTipo?: "asc" | "desc";
|
||||
colunas?: string[];
|
||||
apenasConsulta?: boolean;
|
||||
apenasContagem?: boolean;
|
||||
};
|
||||
15
dist/consulta.js
vendored
Normal file
15
dist/consulta.js
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.operadores = void 0;
|
||||
var operadores;
|
||||
(function (operadores) {
|
||||
operadores["="] = "=";
|
||||
operadores["!="] = "!=";
|
||||
operadores[">"] = ">";
|
||||
operadores[">="] = ">=";
|
||||
operadores["<"] = "<";
|
||||
operadores["<="] = "<=";
|
||||
operadores["like"] = "like";
|
||||
operadores["in"] = "in";
|
||||
})(operadores || (exports.operadores = operadores = {}));
|
||||
//# sourceMappingURL=consulta.js.map
|
||||
1
dist/consulta.js.map
vendored
Normal file
1
dist/consulta.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"consulta.js","sourceRoot":"","sources":["../src/consulta.ts"],"names":[],"mappings":";;;AAAA,IAAY,UASX;AATD,WAAY,UAAU;IACpB,qBAAS,CAAA;IACT,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,uBAAW,CAAA;IACX,2BAAa,CAAA;IACb,uBAAS,CAAA;AACX,CAAC,EATW,UAAU,0BAAV,UAAU,QASrB"}
|
||||
1
dist/ecosistema/index.d.ts
vendored
Normal file
1
dist/ecosistema/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./urls";
|
||||
18
dist/ecosistema/index.js
vendored
Normal file
18
dist/ecosistema/index.js
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
"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("./urls"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dist/ecosistema/index.js.map
vendored
Normal file
1
dist/ecosistema/index.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ecosistema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAsB"}
|
||||
1
dist/ecosistema/urls.d.ts
vendored
Normal file
1
dist/ecosistema/urls.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
||||
5
dist/ecosistema/urls.js
vendored
Normal file
5
dist/ecosistema/urls.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cdn_carro_de_boi = void 0;
|
||||
exports.cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
||||
//# sourceMappingURL=urls.js.map
|
||||
1
dist/ecosistema/urls.js.map
vendored
Normal file
1
dist/ecosistema/urls.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../src/ecosistema/urls.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,wCAAwC,CAAA"}
|
||||
13
dist/extensoes.d.ts
vendored
Normal file
13
dist/extensoes.d.ts
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
type tiposArquivo = "imagem" | "documento" | "vídeo" | "outros";
|
||||
export declare const extensoes: {
|
||||
ext: string;
|
||||
tipo: tiposArquivo;
|
||||
mime: string;
|
||||
}[];
|
||||
/**
|
||||
* Função que retorna o tipo do arquivo
|
||||
* @param nomeArquivo
|
||||
* @returns
|
||||
*/
|
||||
export declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArquivo;
|
||||
export {};
|
||||
173
dist/extensoes.js
vendored
Normal file
173
dist/extensoes.js
vendored
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.tipoArquivo = exports.extensoes = void 0;
|
||||
exports.extensoes = [
|
||||
{
|
||||
ext: "gif",
|
||||
tipo: "imagem",
|
||||
mime: "image/gif",
|
||||
},
|
||||
{
|
||||
ext: "jpg",
|
||||
tipo: "imagem",
|
||||
mime: "image/jpeg",
|
||||
},
|
||||
{
|
||||
ext: "jpeg",
|
||||
tipo: "imagem",
|
||||
mime: "image/jpeg",
|
||||
},
|
||||
{
|
||||
ext: "png",
|
||||
tipo: "imagem",
|
||||
mime: "image/png",
|
||||
},
|
||||
{
|
||||
ext: "bmp",
|
||||
tipo: "imagem",
|
||||
mime: "image/bmp",
|
||||
},
|
||||
{
|
||||
ext: "webp",
|
||||
tipo: "imagem",
|
||||
mime: "image/webp",
|
||||
},
|
||||
{
|
||||
ext: "tiff",
|
||||
tipo: "imagem",
|
||||
mime: "image/tiff",
|
||||
},
|
||||
{
|
||||
ext: "svg",
|
||||
tipo: "imagem",
|
||||
mime: "image/svg+xml",
|
||||
},
|
||||
{
|
||||
ext: "ico",
|
||||
tipo: "imagem",
|
||||
mime: "image/x-icon",
|
||||
},
|
||||
{
|
||||
ext: "pdf",
|
||||
tipo: "documento",
|
||||
mime: "application/pdf",
|
||||
},
|
||||
{
|
||||
ext: "doc",
|
||||
tipo: "documento",
|
||||
mime: "application/msword",
|
||||
},
|
||||
{
|
||||
ext: "docx",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
},
|
||||
{
|
||||
ext: "xls",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.ms-excel",
|
||||
},
|
||||
{
|
||||
ext: "xlsx",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
},
|
||||
{
|
||||
ext: "ppt",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.ms-powerpoint",
|
||||
},
|
||||
{
|
||||
ext: "pptx",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
},
|
||||
{
|
||||
ext: "txt",
|
||||
tipo: "documento",
|
||||
mime: "text/plain",
|
||||
},
|
||||
{
|
||||
ext: "odt",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.oasis.opendocument.text",
|
||||
},
|
||||
{
|
||||
ext: "ods",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.oasis.opendocument.spreadsheet",
|
||||
},
|
||||
{
|
||||
ext: "rtf",
|
||||
tipo: "documento",
|
||||
mime: "application/rtf",
|
||||
},
|
||||
{
|
||||
ext: "csv",
|
||||
tipo: "documento",
|
||||
mime: "text/csv",
|
||||
},
|
||||
{
|
||||
ext: "mp4",
|
||||
tipo: "vídeo",
|
||||
mime: "video/mp4",
|
||||
},
|
||||
{
|
||||
ext: "avi",
|
||||
tipo: "vídeo",
|
||||
mime: "video/x-msvideo",
|
||||
},
|
||||
{
|
||||
ext: "mkv",
|
||||
tipo: "vídeo",
|
||||
mime: "video/x-matroska",
|
||||
},
|
||||
{
|
||||
ext: "mov",
|
||||
tipo: "vídeo",
|
||||
mime: "video/quicktime",
|
||||
},
|
||||
{
|
||||
ext: "wmv",
|
||||
tipo: "vídeo",
|
||||
mime: "video/x-ms-wmv",
|
||||
},
|
||||
{
|
||||
ext: "flv",
|
||||
tipo: "vídeo",
|
||||
mime: "video/x-flv",
|
||||
},
|
||||
{
|
||||
ext: "webm",
|
||||
tipo: "vídeo",
|
||||
mime: "video/webm",
|
||||
},
|
||||
{
|
||||
ext: "3gp",
|
||||
tipo: "vídeo",
|
||||
mime: "video/3gpp",
|
||||
},
|
||||
{
|
||||
ext: "mpeg",
|
||||
tipo: "vídeo",
|
||||
mime: "video/mpeg",
|
||||
},
|
||||
];
|
||||
/**
|
||||
* Função que retorna o tipo do arquivo
|
||||
* @param nomeArquivo
|
||||
* @returns
|
||||
*/
|
||||
const tipoArquivo = (nomeArquivo) => {
|
||||
// extenssão do arquivo
|
||||
const extArquivo = String(nomeArquivo || "")
|
||||
.toLocaleLowerCase()
|
||||
.split(".")
|
||||
.pop();
|
||||
// procura a extensão do arquivo na lista de extensões
|
||||
const extensao = exports.extensoes.find((extensao) => extensao.ext === extArquivo);
|
||||
// retorna o tipo do arquivo
|
||||
return extensao?.tipo || "outros";
|
||||
};
|
||||
exports.tipoArquivo = tipoArquivo;
|
||||
//# sourceMappingURL=extensoes.js.map
|
||||
1
dist/extensoes.js.map
vendored
Normal file
1
dist/extensoes.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"extensoes.js","sourceRoot":"","sources":["../src/extensoes.ts"],"names":[],"mappings":"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"}
|
||||
600
dist/index.cjs
vendored
600
dist/index.cjs
vendored
|
|
@ -1,600 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const z = require('zod');
|
||||
const dayjs = require('dayjs');
|
||||
const duration = require('dayjs/plugin/duration.js');
|
||||
const isSameOrAfter = require('dayjs/plugin/isSameOrAfter.js');
|
||||
const isSameOrBefore = require('dayjs/plugin/isSameOrBefore.js');
|
||||
const minMax = require('dayjs/plugin/minMax.js');
|
||||
const relativeTime = require('dayjs/plugin/relativeTime.js');
|
||||
const timezone = require('dayjs/plugin/timezone.js');
|
||||
const utc = require('dayjs/plugin/utc.js');
|
||||
const weekOfYear = require('dayjs/plugin/weekOfYear.js');
|
||||
require('dayjs/locale/pt-br.js');
|
||||
const crossFetch = require('cross-fetch');
|
||||
const uuid$1 = require('uuid');
|
||||
|
||||
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
||||
|
||||
const z__default = /*#__PURE__*/_interopDefaultCompat(z);
|
||||
const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
|
||||
const duration__default = /*#__PURE__*/_interopDefaultCompat(duration);
|
||||
const isSameOrAfter__default = /*#__PURE__*/_interopDefaultCompat(isSameOrAfter);
|
||||
const isSameOrBefore__default = /*#__PURE__*/_interopDefaultCompat(isSameOrBefore);
|
||||
const minMax__default = /*#__PURE__*/_interopDefaultCompat(minMax);
|
||||
const relativeTime__default = /*#__PURE__*/_interopDefaultCompat(relativeTime);
|
||||
const timezone__default = /*#__PURE__*/_interopDefaultCompat(timezone);
|
||||
const utc__default = /*#__PURE__*/_interopDefaultCompat(utc);
|
||||
const weekOfYear__default = /*#__PURE__*/_interopDefaultCompat(weekOfYear);
|
||||
const crossFetch__default = /*#__PURE__*/_interopDefaultCompat(crossFetch);
|
||||
|
||||
const alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
||||
const aleatorio = (tamanho) => `eli-${Array.from({ length: tamanho || 8 }).map(() => alfabeto[(999 * Math.random() | 0) % alfabeto.length]).join("")}`;
|
||||
|
||||
const _cache = {};
|
||||
globalThis.cacheMemoria_cache = _cache;
|
||||
const cacheM = (chave, valor, validadeSeg) => {
|
||||
const txChave = typeof chave == "string" ? chave : typeof chave == "number" ? String(chave) : encodeURIComponent(JSON.stringify(chave));
|
||||
const validade = validadeSeg && (/* @__PURE__ */ new Date()).getTime() + validadeSeg * 1e3;
|
||||
if (valor !== void 0) {
|
||||
_cache[txChave] = {
|
||||
valor,
|
||||
validade
|
||||
};
|
||||
}
|
||||
const busca = _cache[txChave];
|
||||
if (busca?.validade && busca.validade < (/* @__PURE__ */ new Date()).getTime()) {
|
||||
return void 0;
|
||||
}
|
||||
return busca?.valor;
|
||||
};
|
||||
const verCacheM = () => _cache;
|
||||
const cacheMemoria = cacheM;
|
||||
const cacheMFixo = (chave) => (valor) => cacheM(chave, valor);
|
||||
|
||||
const uuid_null = "00000000-0000-0000-0000-000000000000";
|
||||
var camposComuns = /* @__PURE__ */ ((camposComuns2) => {
|
||||
camposComuns2["codigo"] = "codigo";
|
||||
camposComuns2["excluido"] = "excluido";
|
||||
camposComuns2["data_hora_criacao"] = "data_hora_criacao";
|
||||
camposComuns2["data_hora_atualizacao"] = "data_hora_atualizacao";
|
||||
camposComuns2["codigo_usuario_criacao"] = "codigo_usuario_criacao";
|
||||
camposComuns2["codigo_usuario_atualizacao"] = "codigo_usuario_atualizacao";
|
||||
camposComuns2["versao"] = "versao";
|
||||
return camposComuns2;
|
||||
})(camposComuns || {});
|
||||
var tx = /* @__PURE__ */ ((tx2) => {
|
||||
tx2["token"] = "token";
|
||||
return tx2;
|
||||
})(tx || {});
|
||||
var tipoUsuarioResiduos = /* @__PURE__ */ ((tipoUsuarioResiduos2) => {
|
||||
tipoUsuarioResiduos2["Usuario"] = "usuario";
|
||||
tipoUsuarioResiduos2["Fornecedor"] = "fornecedor";
|
||||
return tipoUsuarioResiduos2;
|
||||
})(tipoUsuarioResiduos || {});
|
||||
|
||||
var operadores = /* @__PURE__ */ ((operadores2) => {
|
||||
operadores2["="] = "=";
|
||||
operadores2["!="] = "!=";
|
||||
operadores2[">"] = ">";
|
||||
operadores2[">="] = ">=";
|
||||
operadores2["<"] = "<";
|
||||
operadores2["<="] = "<=";
|
||||
operadores2["like"] = "like";
|
||||
operadores2["in"] = "in";
|
||||
return operadores2;
|
||||
})(operadores || {});
|
||||
const zOperadores = z__default.enum([
|
||||
"=",
|
||||
"!=",
|
||||
">",
|
||||
">=",
|
||||
"<",
|
||||
"<=",
|
||||
"like",
|
||||
"in"
|
||||
]);
|
||||
const zFiltro = z__default.object({
|
||||
coluna: z__default.string(),
|
||||
valor: z__default.any(),
|
||||
operador: zOperadores,
|
||||
ou: z__default.boolean().optional()
|
||||
});
|
||||
|
||||
dayjs__default.locale("pt-br");
|
||||
dayjs__default.extend(utc__default);
|
||||
dayjs__default.extend(timezone__default);
|
||||
dayjs__default.extend(weekOfYear__default);
|
||||
dayjs__default.extend(isSameOrBefore__default);
|
||||
dayjs__default.extend(isSameOrAfter__default);
|
||||
dayjs__default.extend(minMax__default);
|
||||
dayjs__default.extend(relativeTime__default);
|
||||
dayjs__default.extend(duration__default);
|
||||
const dayjsbr = dayjs__default;
|
||||
|
||||
const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
||||
|
||||
const extensoes = [
|
||||
{
|
||||
ext: "gif",
|
||||
tipo: "imagem",
|
||||
mime: "image/gif"
|
||||
},
|
||||
{
|
||||
ext: "jpg",
|
||||
tipo: "imagem",
|
||||
mime: "image/jpeg"
|
||||
},
|
||||
{
|
||||
ext: "jpeg",
|
||||
tipo: "imagem",
|
||||
mime: "image/jpeg"
|
||||
},
|
||||
{
|
||||
ext: "png",
|
||||
tipo: "imagem",
|
||||
mime: "image/png"
|
||||
},
|
||||
{
|
||||
ext: "bmp",
|
||||
tipo: "imagem",
|
||||
mime: "image/bmp"
|
||||
},
|
||||
{
|
||||
ext: "webp",
|
||||
tipo: "imagem",
|
||||
mime: "image/webp"
|
||||
},
|
||||
{
|
||||
ext: "tiff",
|
||||
tipo: "imagem",
|
||||
mime: "image/tiff"
|
||||
},
|
||||
{
|
||||
ext: "svg",
|
||||
tipo: "imagem",
|
||||
mime: "image/svg+xml"
|
||||
},
|
||||
{
|
||||
ext: "ico",
|
||||
tipo: "imagem",
|
||||
mime: "image/x-icon"
|
||||
},
|
||||
{
|
||||
ext: "pdf",
|
||||
tipo: "documento",
|
||||
mime: "application/pdf"
|
||||
},
|
||||
{
|
||||
ext: "doc",
|
||||
tipo: "documento",
|
||||
mime: "application/msword"
|
||||
},
|
||||
{
|
||||
ext: "docx",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
||||
},
|
||||
{
|
||||
ext: "xls",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.ms-excel"
|
||||
},
|
||||
{
|
||||
ext: "xlsx",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
},
|
||||
{
|
||||
ext: "ppt",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.ms-powerpoint"
|
||||
},
|
||||
{
|
||||
ext: "pptx",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
||||
},
|
||||
{
|
||||
ext: "txt",
|
||||
tipo: "documento",
|
||||
mime: "text/plain"
|
||||
},
|
||||
{
|
||||
ext: "odt",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.oasis.opendocument.text"
|
||||
},
|
||||
{
|
||||
ext: "ods",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.oasis.opendocument.spreadsheet"
|
||||
},
|
||||
{
|
||||
ext: "rtf",
|
||||
tipo: "documento",
|
||||
mime: "application/rtf"
|
||||
},
|
||||
{
|
||||
ext: "csv",
|
||||
tipo: "documento",
|
||||
mime: "text/csv"
|
||||
},
|
||||
{
|
||||
ext: "mp4",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/mp4"
|
||||
},
|
||||
{
|
||||
ext: "avi",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/x-msvideo"
|
||||
},
|
||||
{
|
||||
ext: "mkv",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/x-matroska"
|
||||
},
|
||||
{
|
||||
ext: "mov",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/quicktime"
|
||||
},
|
||||
{
|
||||
ext: "wmv",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/x-ms-wmv"
|
||||
},
|
||||
{
|
||||
ext: "flv",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/x-flv"
|
||||
},
|
||||
{
|
||||
ext: "webm",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/webm"
|
||||
},
|
||||
{
|
||||
ext: "3gp",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/3gpp"
|
||||
},
|
||||
{
|
||||
ext: "mpeg",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/mpeg"
|
||||
}
|
||||
];
|
||||
const tipoArquivo = (nomeArquivo) => {
|
||||
const extArquivo = String(nomeArquivo || "").toLocaleLowerCase().split(".").pop();
|
||||
const extensao = extensoes.find((extensao2) => extensao2.ext === extArquivo);
|
||||
return extensao?.tipo || "outros";
|
||||
};
|
||||
|
||||
const graficos_pilao = {
|
||||
Condicionantes: {
|
||||
grafico: "condicionantes-criadas",
|
||||
titulo: "Condicionantes Criadas"
|
||||
},
|
||||
Licen\u00E7as: {
|
||||
grafico: "licencas-criadas",
|
||||
titulo: "Licen\xE7as Criadas"
|
||||
}
|
||||
};
|
||||
|
||||
const localValor = (chave_, valor) => {
|
||||
const localStorage = globalThis.localStorage;
|
||||
if (typeof localStorage == "undefined") return null;
|
||||
const chave = typeof chave_ === "string" ? chave_ : encodeURIComponent(JSON.stringify(chave_));
|
||||
try {
|
||||
if (valor !== void 0) {
|
||||
localStorage.setItem(chave, JSON.stringify(valor));
|
||||
}
|
||||
const v2 = localStorage.getItem(chave);
|
||||
if (v2 === null) return null;
|
||||
try {
|
||||
return JSON.parse(v2);
|
||||
} catch {
|
||||
return v2;
|
||||
}
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const esperar = (ms) => new Promise(
|
||||
(resolve) => setTimeout(() => resolve(true), ms)
|
||||
);
|
||||
const nomeVariavel = (v) => Object.keys(v).join("/");
|
||||
|
||||
const LOKI_BASE_URL = "https://log.idz.one";
|
||||
const LOKI_ENDPOINT = "/loki/api/v1/push";
|
||||
const postLogger = async ({
|
||||
objeto
|
||||
}) => {
|
||||
const response = await crossFetch__default(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(objeto)
|
||||
}).catch((a) => a);
|
||||
if (!response.ok) {
|
||||
return [objeto, `Erro ${response.status}: ${await response?.text?.()}`];
|
||||
}
|
||||
return [objeto];
|
||||
};
|
||||
let cwd = "";
|
||||
const defineCwd = (novoCwd) => {
|
||||
cwd = novoCwd;
|
||||
};
|
||||
const logger = ({ app: app_e, eProducao, parametros: parametrosAmbiente }) => ({ inquilino, usuario, parametros: parametrosSessao }) => async (level, mensagem, op_tipoLog) => {
|
||||
let {
|
||||
__filename,
|
||||
detalhes,
|
||||
local,
|
||||
parametros: parametrosLog
|
||||
} = op_tipoLog || {};
|
||||
const app = `${eProducao ? "" : "DEV-"}${app_e}`;
|
||||
if (cwd && __filename) {
|
||||
__filename = __filename.replace(cwd, "");
|
||||
}
|
||||
if (local) {
|
||||
detalhes = [`${nomeVariavel({ local })}="${local}"`, ...detalhes || []];
|
||||
}
|
||||
if (__filename) {
|
||||
detalhes = [
|
||||
`${nomeVariavel({ __filename })}="${__filename}"`,
|
||||
...detalhes || []
|
||||
];
|
||||
}
|
||||
const timestamp = `${Date.now()}000000`;
|
||||
const mainLog = detalhes?.length ? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" | ")}` : mensagem;
|
||||
const payload = {
|
||||
stream: {
|
||||
app,
|
||||
inquilino,
|
||||
usuario,
|
||||
level,
|
||||
...parametrosAmbiente || {},
|
||||
...parametrosSessao || {},
|
||||
...parametrosLog || {}
|
||||
},
|
||||
values: [
|
||||
[
|
||||
timestamp,
|
||||
mainLog
|
||||
// Linha de log direta
|
||||
]
|
||||
]
|
||||
};
|
||||
const objeto = { streams: [payload] };
|
||||
const response = await postLogger({ objeto });
|
||||
return response;
|
||||
};
|
||||
|
||||
const paraObjetoRegistroPg = (entrada) => {
|
||||
try {
|
||||
return Object.fromEntries(
|
||||
Object.entries(entrada).map(([k, v]) => [
|
||||
k,
|
||||
v === void 0 || v == null ? v : typeof v == "string" || typeof v == "number" || typeof v == "boolean" ? v : JSON.stringify(v, null, 2)
|
||||
])
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Erro na fun\xE7\xE3o paraObjetoRegistroPg: ${error.message} ${error.stack}`
|
||||
);
|
||||
}
|
||||
};
|
||||
const pgObjeto = paraObjetoRegistroPg;
|
||||
const objetoPg = paraObjetoRegistroPg;
|
||||
|
||||
const umaFuncao = () => "Ol\xE1 Mundo! (fun\xE7\xE3o)";
|
||||
|
||||
const umaVariavel = "Ol\xE1 Mundo! (vari\xE1vel)";
|
||||
|
||||
const texto_busca = (...texto) => texto.map(
|
||||
(txt) => txt === null || txt === void 0 ? "" : String(txt).normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, " ").toLowerCase()
|
||||
).join(" ");
|
||||
|
||||
class TipagemRotas {
|
||||
_partesCaminho = [];
|
||||
_acaoIr;
|
||||
rotulo;
|
||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
||||
*/
|
||||
constructor({
|
||||
caminho,
|
||||
acaoIr,
|
||||
rotulo
|
||||
}) {
|
||||
this._acaoIr = acaoIr;
|
||||
this._partesCaminho = (Array.isArray(caminho) ? caminho : [caminho]).filter(Boolean).map((a) => String(a)).flatMap((a) => a.split("/")).filter(Boolean);
|
||||
this.rotulo = rotulo;
|
||||
}
|
||||
/** Retorna o caminho completo da rota
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/caminho"
|
||||
*/
|
||||
get caminho() {
|
||||
const ret = `/${this._partesCaminho.join("/")}`;
|
||||
return ret;
|
||||
}
|
||||
/** Define o caminho completo da rota
|
||||
** mCaminho.caminho = "/novoCaminho"
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/novoCaminho"
|
||||
** */
|
||||
set caminho(caminhoParcial) {
|
||||
this._partesCaminho = caminhoParcial.split("/").filter((parte) => parte);
|
||||
}
|
||||
/** Retorna o caminho completo da rota com a query
|
||||
** console.log(mCaminho.resolve({q:"query"}))
|
||||
** "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
endereco(query, usarComoHash) {
|
||||
const url = new URL(
|
||||
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
||||
);
|
||||
url.pathname = this.caminho;
|
||||
url.search = "";
|
||||
const queryKeys = Object.entries(query);
|
||||
for (const [key, value] of queryKeys) {
|
||||
url.searchParams.set(String(key), JSON.stringify(value));
|
||||
}
|
||||
url.hash = "";
|
||||
if (usarComoHash) {
|
||||
url.hash = `#${url.search}`;
|
||||
url.search = "";
|
||||
}
|
||||
return url.href;
|
||||
}
|
||||
/** Vai para a url
|
||||
** mCaminho.ir({q:"query"})
|
||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
ir(query) {
|
||||
if (this._acaoIr) {
|
||||
this._acaoIr(this.endereco({ ...query }));
|
||||
} else {
|
||||
if (typeof window != "undefined") {
|
||||
window.location.href = this.endereco({ ...query });
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Retorna os parametros da url
|
||||
** console.log(mCaminho.parametros())
|
||||
** {q:"query"}
|
||||
*/
|
||||
parametros(urlEntrada) {
|
||||
const url = urlEntrada ? new URL(urlEntrada) : new URL(
|
||||
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
||||
);
|
||||
const query = url.searchParams;
|
||||
let queryObj = Object.fromEntries(query.entries());
|
||||
const hash = url.hash;
|
||||
if (hash) {
|
||||
const hashObj = Object.fromEntries(
|
||||
new URLSearchParams(hash.slice(1)).entries()
|
||||
);
|
||||
queryObj = { ...queryObj, ...hashObj };
|
||||
}
|
||||
for (const chave in queryObj) {
|
||||
try {
|
||||
queryObj[chave] = JSON.parse(queryObj[chave]);
|
||||
} catch {
|
||||
console.log(`[${chave}|${queryObj[chave]}] n\xE3o \xE9 um json v\xE1lido.`);
|
||||
}
|
||||
}
|
||||
return queryObj;
|
||||
}
|
||||
}
|
||||
|
||||
var siglas_unidades_medida = /* @__PURE__ */ ((siglas_unidades_medida2) => {
|
||||
siglas_unidades_medida2["UN"] = "UN";
|
||||
siglas_unidades_medida2["KG"] = "KG";
|
||||
siglas_unidades_medida2["TON"] = "TON";
|
||||
siglas_unidades_medida2["g"] = "g";
|
||||
siglas_unidades_medida2["M\xB3"] = "M\xB3";
|
||||
siglas_unidades_medida2["Lt"] = "Lt";
|
||||
return siglas_unidades_medida2;
|
||||
})(siglas_unidades_medida || {});
|
||||
const unidades_medida = [
|
||||
{
|
||||
sigla_unidade: "KG",
|
||||
nome: "Quilograma",
|
||||
sigla_normalizada: "KG",
|
||||
normalizar: (valor) => valor,
|
||||
tipo: "massa"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "g",
|
||||
nome: "Grama",
|
||||
sigla_normalizada: "KG",
|
||||
normalizar: (valor) => valor / 1e3,
|
||||
tipo: "massa"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "TON",
|
||||
nome: "Tonelada",
|
||||
sigla_normalizada: "KG",
|
||||
normalizar: (valor) => valor * 1e3,
|
||||
tipo: "massa"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "Lt",
|
||||
nome: "Litro",
|
||||
sigla_normalizada: "Lt",
|
||||
normalizar: (valor) => valor,
|
||||
tipo: "volume"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "M\xB3",
|
||||
nome: "Metro C\xFAbico",
|
||||
sigla_normalizada: "Lt",
|
||||
normalizar: (valor) => valor * 1e3,
|
||||
tipo: "volume"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "UN",
|
||||
nome: "Unidade",
|
||||
sigla_normalizada: "UN",
|
||||
normalizar: (valor) => valor,
|
||||
tipo: "unidade"
|
||||
}
|
||||
];
|
||||
|
||||
const erUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
const validarUuid = (uuid2) => {
|
||||
const retorno = erUuid.test(String(uuid2 || ""));
|
||||
return retorno;
|
||||
};
|
||||
const uuidV3 = (chave, grupo) => {
|
||||
return uuid$1.v3(
|
||||
// Converte a chave para string (de forma segura)
|
||||
typeof chave === "string" ? chave : typeof chave === "number" ? String(chave) : JSON.stringify(chave),
|
||||
// Se um grupo foi fornecido, gera um UUID v3 recursivamente com base nele, senão usa NIL
|
||||
grupo ? uuidV3(grupo) : uuid$1.NIL
|
||||
);
|
||||
};
|
||||
const uuidV4 = uuid$1.v4;
|
||||
const uuid = uuidV4;
|
||||
|
||||
exports.TipagemRotas = TipagemRotas;
|
||||
exports.aleatorio = aleatorio;
|
||||
exports.cacheM = cacheM;
|
||||
exports.cacheMFixo = cacheMFixo;
|
||||
exports.cacheMemoria = cacheMemoria;
|
||||
exports.camposComuns = camposComuns;
|
||||
exports.cdn_carro_de_boi = cdn_carro_de_boi;
|
||||
exports.dayjsbr = dayjsbr;
|
||||
exports.defineCwd = defineCwd;
|
||||
exports.erUuid = erUuid;
|
||||
exports.esperar = esperar;
|
||||
exports.extensoes = extensoes;
|
||||
exports.graficos_pilao = graficos_pilao;
|
||||
exports.localValor = localValor;
|
||||
exports.logger = logger;
|
||||
exports.nomeVariavel = nomeVariavel;
|
||||
exports.objetoPg = objetoPg;
|
||||
exports.operadores = operadores;
|
||||
exports.paraObjetoRegistroPg = paraObjetoRegistroPg;
|
||||
exports.pgObjeto = pgObjeto;
|
||||
exports.postLogger = postLogger;
|
||||
exports.siglas_unidades_medida = siglas_unidades_medida;
|
||||
exports.texto_busca = texto_busca;
|
||||
exports.tipoArquivo = tipoArquivo;
|
||||
exports.tipoUsuarioResiduos = tipoUsuarioResiduos;
|
||||
exports.tx = tx;
|
||||
exports.umaFuncao = umaFuncao;
|
||||
exports.umaVariavel = umaVariavel;
|
||||
exports.unidades_medida = unidades_medida;
|
||||
exports.uuid = uuid;
|
||||
exports.uuidV3 = uuidV3;
|
||||
exports.uuidV4 = uuidV4;
|
||||
exports.uuid_null = uuid_null;
|
||||
exports.validarUuid = validarUuid;
|
||||
exports.verCacheM = verCacheM;
|
||||
exports.zFiltro = zFiltro;
|
||||
exports.zOperadores = zOperadores;
|
||||
315
dist/index.d.cts
vendored
315
dist/index.d.cts
vendored
|
|
@ -1,315 +0,0 @@
|
|||
import z from 'zod';
|
||||
import dayjs from 'dayjs';
|
||||
export { ManipulateType } from 'dayjs';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
declare const aleatorio: (tamanho?: number) => string;
|
||||
|
||||
/** gerar uma função de cache para uso em memoria */
|
||||
declare const cacheM: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
||||
declare const verCacheM: () => {
|
||||
[k: string]: {
|
||||
/** new Date().getTime() */
|
||||
validade?: number | undefined;
|
||||
valor: any;
|
||||
} | undefined;
|
||||
};
|
||||
declare const cacheMemoria: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
||||
/** para uso fixo dentro de uma função, trava a chave */
|
||||
declare const cacheMFixo: (chave: any) => <T>(valor?: T) => T | undefined;
|
||||
|
||||
declare const uuid_null = "00000000-0000-0000-0000-000000000000";
|
||||
/** Colunas Presentes n maioria das tabelas */
|
||||
declare enum camposComuns {
|
||||
codigo = "codigo",
|
||||
excluido = "excluido",
|
||||
data_hora_criacao = "data_hora_criacao",
|
||||
data_hora_atualizacao = "data_hora_atualizacao",
|
||||
codigo_usuario_criacao = "codigo_usuario_criacao",
|
||||
codigo_usuario_atualizacao = "codigo_usuario_atualizacao",
|
||||
versao = "versao"
|
||||
}
|
||||
/** Palavras comumente usadas */
|
||||
declare enum tx {
|
||||
token = "token"
|
||||
}
|
||||
declare enum tipoUsuarioResiduos {
|
||||
Usuario = "usuario",
|
||||
Fornecedor = "fornecedor"
|
||||
}
|
||||
|
||||
declare enum operadores {
|
||||
"=" = "=",
|
||||
"!=" = "!=",
|
||||
">" = ">",
|
||||
">=" = ">=",
|
||||
"<" = "<",
|
||||
"<=" = "<=",
|
||||
like = "like",
|
||||
in = "in"
|
||||
}
|
||||
type tipoFiltro = {
|
||||
coluna: string;
|
||||
valor: any;
|
||||
operador: keyof typeof operadores | operadores;
|
||||
ou?: boolean;
|
||||
};
|
||||
type interfaceConsulta = {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
filtros?: tipoFiltro[];
|
||||
ordem?: string;
|
||||
ordemTipo?: "asc" | "desc";
|
||||
colunas?: string[];
|
||||
apenasConsulta?: boolean;
|
||||
apenasContagem?: boolean;
|
||||
};
|
||||
declare const zOperadores: z.ZodEnum<{
|
||||
"=": "=";
|
||||
"!=": "!=";
|
||||
">": ">";
|
||||
">=": ">=";
|
||||
"<": "<";
|
||||
"<=": "<=";
|
||||
like: "like";
|
||||
in: "in";
|
||||
}>;
|
||||
declare const zFiltro: z.ZodObject<{
|
||||
coluna: z.ZodString;
|
||||
valor: z.ZodAny;
|
||||
operador: z.ZodEnum<{
|
||||
"=": "=";
|
||||
"!=": "!=";
|
||||
">": ">";
|
||||
">=": ">=";
|
||||
"<": "<";
|
||||
"<=": "<=";
|
||||
like: "like";
|
||||
in: "in";
|
||||
}>;
|
||||
ou: z.ZodOptional<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
|
||||
declare const dayjsbr: typeof dayjs;
|
||||
|
||||
declare const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
||||
|
||||
type tiposArquivo = "imagem" | "documento" | "vídeo" | "outros";
|
||||
declare const extensoes: {
|
||||
ext: string;
|
||||
tipo: tiposArquivo;
|
||||
mime: string;
|
||||
}[];
|
||||
/**
|
||||
* Função que retorna o tipo do arquivo
|
||||
* @param nomeArquivo
|
||||
* @returns
|
||||
*/
|
||||
declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArquivo;
|
||||
|
||||
declare const graficos_pilao: {
|
||||
[k: string]: {
|
||||
grafico: string;
|
||||
titulo: string;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* LocalStorage Tipado
|
||||
* Lê ou grava um valor no localStorage, mantendo o tipo genérico <T>.
|
||||
*/
|
||||
declare const localValor: <T>(chave_: string | any, valor?: T | null) => T | null;
|
||||
|
||||
type tipoLokiObjeto = {
|
||||
streams: {
|
||||
stream: {
|
||||
[k: string]: string;
|
||||
};
|
||||
values: [string, string][];
|
||||
}[];
|
||||
};
|
||||
declare const postLogger: ({ objeto, }: {
|
||||
objeto: tipoLokiObjeto;
|
||||
}) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
/** define a localização da pasta do projeto */
|
||||
declare const defineCwd: (novoCwd: string) => void;
|
||||
type tipoLevel = "info" | "warn" | "error";
|
||||
type tipoOpSessao = {
|
||||
inquilino: string;
|
||||
usuario: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
type tipoLog = {
|
||||
detalhes?: unknown[];
|
||||
__filename?: string;
|
||||
local?: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
type tipoLoggerLog = (level: tipoLevel, mensagem: string, op_tipoLog?: tipoLog) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
type TipoLoggerSessao = (sess: tipoOpSessao) => tipoLoggerLog;
|
||||
type tipoLogger = (amb: {
|
||||
app: string;
|
||||
eProducao: boolean;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
}) => TipoLoggerSessao;
|
||||
declare const logger: tipoLogger;
|
||||
|
||||
/**
|
||||
* Trata um objeto para ser imput para postgres
|
||||
* @param entrada
|
||||
* @returns
|
||||
*/
|
||||
declare const paraObjetoRegistroPg: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
declare const pgObjeto: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
declare const objetoPg: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
|
||||
declare const umaFuncao: () => string;
|
||||
|
||||
declare const umaVariavel = "Ol\u00E1 Mundo! (vari\u00E1vel)";
|
||||
|
||||
/** gerar o texto de busca removendo caracteres especies e caixa alta */
|
||||
declare const texto_busca: (...texto: any[]) => string;
|
||||
|
||||
/** Gerar uma classe que facilita a gestão de rotas com a tipagem das querys
|
||||
*
|
||||
* Definições:
|
||||
*
|
||||
* caminho = "/aplicacao/funcionalidade"
|
||||
*
|
||||
* endereco = "http://localhost:3000/aplicacao/funcionalidade"
|
||||
*
|
||||
* parametros = {nome:"José"}
|
||||
*/
|
||||
declare class TipagemRotas<T extends {
|
||||
[q: string]: any;
|
||||
}> {
|
||||
_partesCaminho: string[];
|
||||
_acaoIr?: (endereco: string) => undefined;
|
||||
rotulo: string | undefined;
|
||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
||||
*/
|
||||
constructor({ caminho, acaoIr, rotulo, }: {
|
||||
caminho: (string | null | undefined)[] | string;
|
||||
acaoIr?: undefined | ((endereco: string) => undefined);
|
||||
/** Rotulo da página
|
||||
* Inicio | Controle
|
||||
*/
|
||||
rotulo?: string;
|
||||
});
|
||||
/** Retorna o caminho completo da rota
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/caminho"
|
||||
*/
|
||||
get caminho(): string;
|
||||
/** Define o caminho completo da rota
|
||||
** mCaminho.caminho = "/novoCaminho"
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/novoCaminho"
|
||||
** */
|
||||
set caminho(caminhoParcial: string);
|
||||
/** Retorna o caminho completo da rota com a query
|
||||
** console.log(mCaminho.resolve({q:"query"}))
|
||||
** "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
endereco(query: T, usarComoHash?: boolean): string;
|
||||
/** Vai para a url
|
||||
** mCaminho.ir({q:"query"})
|
||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
ir(query: T): void;
|
||||
/** Retorna os parametros da url
|
||||
** console.log(mCaminho.parametros())
|
||||
** {q:"query"}
|
||||
*/
|
||||
parametros(urlEntrada?: string): Partial<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Essa variável se conecta a tabela_lidades
|
||||
*
|
||||
* onde sigla se conecta com sigla
|
||||
*
|
||||
* Usuário terá mais opções de unidades, quando fazer o envio para o mtr, usar a opção fornecida pelo usuarios, caso não tenha
|
||||
* usar a normalizada
|
||||
*/
|
||||
declare enum siglas_unidades_medida {
|
||||
UN = "UN",
|
||||
KG = "KG",
|
||||
TON = "TON",
|
||||
g = "g",
|
||||
"M³" = "M\u00B3",
|
||||
Lt = "Lt"
|
||||
}
|
||||
declare const unidades_medida: {
|
||||
sigla_unidade: keyof typeof siglas_unidades_medida;
|
||||
nome: string;
|
||||
sigla_normalizada: keyof typeof siglas_unidades_medida;
|
||||
normalizar: (valor: number) => number;
|
||||
tipo: "massa" | "volume" | "comprimento" | "unidade";
|
||||
}[];
|
||||
|
||||
/**
|
||||
* Valida se uma string é um UUID válido (qualquer versão).
|
||||
*
|
||||
* @param valor - A string que será validada.
|
||||
* @returns booleano indicando se é um UUID válido.
|
||||
*/
|
||||
declare const erUuid: RegExp;
|
||||
declare const validarUuid: (uuid: string | number | undefined | null) => boolean;
|
||||
/**
|
||||
* Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace).
|
||||
*
|
||||
* - Usa o algoritmo MD5 (RFC 4122).
|
||||
* - Sempre retorna o mesmo UUID para a mesma combinação chave + grupo.
|
||||
* - Caso o grupo não seja informado, usa o UUID "nil" como namespace.
|
||||
*
|
||||
* @param chave - Qualquer valor que será convertido em string para gerar o UUID (ex: número, string ou objeto).
|
||||
* @param grupo - Opcional. Namespace para separar domínios diferentes de UUIDs.
|
||||
* @returns UUID v3 (determinístico)
|
||||
*/
|
||||
declare const uuidV3: (chave: any, grupo?: any) => string;
|
||||
/**
|
||||
* Gera um UUID v4 (aleatório, não determinístico).
|
||||
*
|
||||
* - Usado quando unicidade é necessária, mas não se exige que seja previsível.
|
||||
*/
|
||||
declare const uuidV4: typeof v4;
|
||||
/**
|
||||
* @deprecated Esta variável será descontinuada em versões futuras.
|
||||
* Use a função `uuidV4()` diretamente.
|
||||
*/
|
||||
declare const uuid: typeof v4;
|
||||
|
||||
declare const esperar: (ms: number) => Promise<true>;
|
||||
/**
|
||||
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
|
||||
* const nomex = {a: 1, b: 2}
|
||||
* nomeVariavel({nomex}) // retorna "nomex"
|
||||
* @param v
|
||||
* @returns
|
||||
*/
|
||||
declare const nomeVariavel: (v: {
|
||||
[key: string]: any;
|
||||
}) => string;
|
||||
|
||||
export { TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, defineCwd, erUuid, esperar, extensoes, graficos_pilao, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
||||
export type { TipoLoggerSessao, interfaceConsulta, tipoFiltro, tipoLogger, tipoLoggerLog, tipoLokiObjeto };
|
||||
315
dist/index.d.mts
vendored
315
dist/index.d.mts
vendored
|
|
@ -1,315 +0,0 @@
|
|||
import z from 'zod';
|
||||
import dayjs from 'dayjs';
|
||||
export { ManipulateType } from 'dayjs';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
declare const aleatorio: (tamanho?: number) => string;
|
||||
|
||||
/** gerar uma função de cache para uso em memoria */
|
||||
declare const cacheM: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
||||
declare const verCacheM: () => {
|
||||
[k: string]: {
|
||||
/** new Date().getTime() */
|
||||
validade?: number | undefined;
|
||||
valor: any;
|
||||
} | undefined;
|
||||
};
|
||||
declare const cacheMemoria: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
||||
/** para uso fixo dentro de uma função, trava a chave */
|
||||
declare const cacheMFixo: (chave: any) => <T>(valor?: T) => T | undefined;
|
||||
|
||||
declare const uuid_null = "00000000-0000-0000-0000-000000000000";
|
||||
/** Colunas Presentes n maioria das tabelas */
|
||||
declare enum camposComuns {
|
||||
codigo = "codigo",
|
||||
excluido = "excluido",
|
||||
data_hora_criacao = "data_hora_criacao",
|
||||
data_hora_atualizacao = "data_hora_atualizacao",
|
||||
codigo_usuario_criacao = "codigo_usuario_criacao",
|
||||
codigo_usuario_atualizacao = "codigo_usuario_atualizacao",
|
||||
versao = "versao"
|
||||
}
|
||||
/** Palavras comumente usadas */
|
||||
declare enum tx {
|
||||
token = "token"
|
||||
}
|
||||
declare enum tipoUsuarioResiduos {
|
||||
Usuario = "usuario",
|
||||
Fornecedor = "fornecedor"
|
||||
}
|
||||
|
||||
declare enum operadores {
|
||||
"=" = "=",
|
||||
"!=" = "!=",
|
||||
">" = ">",
|
||||
">=" = ">=",
|
||||
"<" = "<",
|
||||
"<=" = "<=",
|
||||
like = "like",
|
||||
in = "in"
|
||||
}
|
||||
type tipoFiltro = {
|
||||
coluna: string;
|
||||
valor: any;
|
||||
operador: keyof typeof operadores | operadores;
|
||||
ou?: boolean;
|
||||
};
|
||||
type interfaceConsulta = {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
filtros?: tipoFiltro[];
|
||||
ordem?: string;
|
||||
ordemTipo?: "asc" | "desc";
|
||||
colunas?: string[];
|
||||
apenasConsulta?: boolean;
|
||||
apenasContagem?: boolean;
|
||||
};
|
||||
declare const zOperadores: z.ZodEnum<{
|
||||
"=": "=";
|
||||
"!=": "!=";
|
||||
">": ">";
|
||||
">=": ">=";
|
||||
"<": "<";
|
||||
"<=": "<=";
|
||||
like: "like";
|
||||
in: "in";
|
||||
}>;
|
||||
declare const zFiltro: z.ZodObject<{
|
||||
coluna: z.ZodString;
|
||||
valor: z.ZodAny;
|
||||
operador: z.ZodEnum<{
|
||||
"=": "=";
|
||||
"!=": "!=";
|
||||
">": ">";
|
||||
">=": ">=";
|
||||
"<": "<";
|
||||
"<=": "<=";
|
||||
like: "like";
|
||||
in: "in";
|
||||
}>;
|
||||
ou: z.ZodOptional<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
|
||||
declare const dayjsbr: typeof dayjs;
|
||||
|
||||
declare const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
||||
|
||||
type tiposArquivo = "imagem" | "documento" | "vídeo" | "outros";
|
||||
declare const extensoes: {
|
||||
ext: string;
|
||||
tipo: tiposArquivo;
|
||||
mime: string;
|
||||
}[];
|
||||
/**
|
||||
* Função que retorna o tipo do arquivo
|
||||
* @param nomeArquivo
|
||||
* @returns
|
||||
*/
|
||||
declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArquivo;
|
||||
|
||||
declare const graficos_pilao: {
|
||||
[k: string]: {
|
||||
grafico: string;
|
||||
titulo: string;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* LocalStorage Tipado
|
||||
* Lê ou grava um valor no localStorage, mantendo o tipo genérico <T>.
|
||||
*/
|
||||
declare const localValor: <T>(chave_: string | any, valor?: T | null) => T | null;
|
||||
|
||||
type tipoLokiObjeto = {
|
||||
streams: {
|
||||
stream: {
|
||||
[k: string]: string;
|
||||
};
|
||||
values: [string, string][];
|
||||
}[];
|
||||
};
|
||||
declare const postLogger: ({ objeto, }: {
|
||||
objeto: tipoLokiObjeto;
|
||||
}) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
/** define a localização da pasta do projeto */
|
||||
declare const defineCwd: (novoCwd: string) => void;
|
||||
type tipoLevel = "info" | "warn" | "error";
|
||||
type tipoOpSessao = {
|
||||
inquilino: string;
|
||||
usuario: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
type tipoLog = {
|
||||
detalhes?: unknown[];
|
||||
__filename?: string;
|
||||
local?: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
type tipoLoggerLog = (level: tipoLevel, mensagem: string, op_tipoLog?: tipoLog) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
type TipoLoggerSessao = (sess: tipoOpSessao) => tipoLoggerLog;
|
||||
type tipoLogger = (amb: {
|
||||
app: string;
|
||||
eProducao: boolean;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
}) => TipoLoggerSessao;
|
||||
declare const logger: tipoLogger;
|
||||
|
||||
/**
|
||||
* Trata um objeto para ser imput para postgres
|
||||
* @param entrada
|
||||
* @returns
|
||||
*/
|
||||
declare const paraObjetoRegistroPg: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
declare const pgObjeto: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
declare const objetoPg: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
|
||||
declare const umaFuncao: () => string;
|
||||
|
||||
declare const umaVariavel = "Ol\u00E1 Mundo! (vari\u00E1vel)";
|
||||
|
||||
/** gerar o texto de busca removendo caracteres especies e caixa alta */
|
||||
declare const texto_busca: (...texto: any[]) => string;
|
||||
|
||||
/** Gerar uma classe que facilita a gestão de rotas com a tipagem das querys
|
||||
*
|
||||
* Definições:
|
||||
*
|
||||
* caminho = "/aplicacao/funcionalidade"
|
||||
*
|
||||
* endereco = "http://localhost:3000/aplicacao/funcionalidade"
|
||||
*
|
||||
* parametros = {nome:"José"}
|
||||
*/
|
||||
declare class TipagemRotas<T extends {
|
||||
[q: string]: any;
|
||||
}> {
|
||||
_partesCaminho: string[];
|
||||
_acaoIr?: (endereco: string) => undefined;
|
||||
rotulo: string | undefined;
|
||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
||||
*/
|
||||
constructor({ caminho, acaoIr, rotulo, }: {
|
||||
caminho: (string | null | undefined)[] | string;
|
||||
acaoIr?: undefined | ((endereco: string) => undefined);
|
||||
/** Rotulo da página
|
||||
* Inicio | Controle
|
||||
*/
|
||||
rotulo?: string;
|
||||
});
|
||||
/** Retorna o caminho completo da rota
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/caminho"
|
||||
*/
|
||||
get caminho(): string;
|
||||
/** Define o caminho completo da rota
|
||||
** mCaminho.caminho = "/novoCaminho"
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/novoCaminho"
|
||||
** */
|
||||
set caminho(caminhoParcial: string);
|
||||
/** Retorna o caminho completo da rota com a query
|
||||
** console.log(mCaminho.resolve({q:"query"}))
|
||||
** "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
endereco(query: T, usarComoHash?: boolean): string;
|
||||
/** Vai para a url
|
||||
** mCaminho.ir({q:"query"})
|
||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
ir(query: T): void;
|
||||
/** Retorna os parametros da url
|
||||
** console.log(mCaminho.parametros())
|
||||
** {q:"query"}
|
||||
*/
|
||||
parametros(urlEntrada?: string): Partial<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Essa variável se conecta a tabela_lidades
|
||||
*
|
||||
* onde sigla se conecta com sigla
|
||||
*
|
||||
* Usuário terá mais opções de unidades, quando fazer o envio para o mtr, usar a opção fornecida pelo usuarios, caso não tenha
|
||||
* usar a normalizada
|
||||
*/
|
||||
declare enum siglas_unidades_medida {
|
||||
UN = "UN",
|
||||
KG = "KG",
|
||||
TON = "TON",
|
||||
g = "g",
|
||||
"M³" = "M\u00B3",
|
||||
Lt = "Lt"
|
||||
}
|
||||
declare const unidades_medida: {
|
||||
sigla_unidade: keyof typeof siglas_unidades_medida;
|
||||
nome: string;
|
||||
sigla_normalizada: keyof typeof siglas_unidades_medida;
|
||||
normalizar: (valor: number) => number;
|
||||
tipo: "massa" | "volume" | "comprimento" | "unidade";
|
||||
}[];
|
||||
|
||||
/**
|
||||
* Valida se uma string é um UUID válido (qualquer versão).
|
||||
*
|
||||
* @param valor - A string que será validada.
|
||||
* @returns booleano indicando se é um UUID válido.
|
||||
*/
|
||||
declare const erUuid: RegExp;
|
||||
declare const validarUuid: (uuid: string | number | undefined | null) => boolean;
|
||||
/**
|
||||
* Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace).
|
||||
*
|
||||
* - Usa o algoritmo MD5 (RFC 4122).
|
||||
* - Sempre retorna o mesmo UUID para a mesma combinação chave + grupo.
|
||||
* - Caso o grupo não seja informado, usa o UUID "nil" como namespace.
|
||||
*
|
||||
* @param chave - Qualquer valor que será convertido em string para gerar o UUID (ex: número, string ou objeto).
|
||||
* @param grupo - Opcional. Namespace para separar domínios diferentes de UUIDs.
|
||||
* @returns UUID v3 (determinístico)
|
||||
*/
|
||||
declare const uuidV3: (chave: any, grupo?: any) => string;
|
||||
/**
|
||||
* Gera um UUID v4 (aleatório, não determinístico).
|
||||
*
|
||||
* - Usado quando unicidade é necessária, mas não se exige que seja previsível.
|
||||
*/
|
||||
declare const uuidV4: typeof v4;
|
||||
/**
|
||||
* @deprecated Esta variável será descontinuada em versões futuras.
|
||||
* Use a função `uuidV4()` diretamente.
|
||||
*/
|
||||
declare const uuid: typeof v4;
|
||||
|
||||
declare const esperar: (ms: number) => Promise<true>;
|
||||
/**
|
||||
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
|
||||
* const nomex = {a: 1, b: 2}
|
||||
* nomeVariavel({nomex}) // retorna "nomex"
|
||||
* @param v
|
||||
* @returns
|
||||
*/
|
||||
declare const nomeVariavel: (v: {
|
||||
[key: string]: any;
|
||||
}) => string;
|
||||
|
||||
export { TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, defineCwd, erUuid, esperar, extensoes, graficos_pilao, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
||||
export type { TipoLoggerSessao, interfaceConsulta, tipoFiltro, tipoLogger, tipoLoggerLog, tipoLokiObjeto };
|
||||
327
dist/index.d.ts
vendored
327
dist/index.d.ts
vendored
|
|
@ -1,315 +1,12 @@
|
|||
import z from 'zod';
|
||||
import dayjs from 'dayjs';
|
||||
export { ManipulateType } from 'dayjs';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
declare const aleatorio: (tamanho?: number) => string;
|
||||
|
||||
/** gerar uma função de cache para uso em memoria */
|
||||
declare const cacheM: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
||||
declare const verCacheM: () => {
|
||||
[k: string]: {
|
||||
/** new Date().getTime() */
|
||||
validade?: number | undefined;
|
||||
valor: any;
|
||||
} | undefined;
|
||||
};
|
||||
declare const cacheMemoria: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
||||
/** para uso fixo dentro de uma função, trava a chave */
|
||||
declare const cacheMFixo: (chave: any) => <T>(valor?: T) => T | undefined;
|
||||
|
||||
declare const uuid_null = "00000000-0000-0000-0000-000000000000";
|
||||
/** Colunas Presentes n maioria das tabelas */
|
||||
declare enum camposComuns {
|
||||
codigo = "codigo",
|
||||
excluido = "excluido",
|
||||
data_hora_criacao = "data_hora_criacao",
|
||||
data_hora_atualizacao = "data_hora_atualizacao",
|
||||
codigo_usuario_criacao = "codigo_usuario_criacao",
|
||||
codigo_usuario_atualizacao = "codigo_usuario_atualizacao",
|
||||
versao = "versao"
|
||||
}
|
||||
/** Palavras comumente usadas */
|
||||
declare enum tx {
|
||||
token = "token"
|
||||
}
|
||||
declare enum tipoUsuarioResiduos {
|
||||
Usuario = "usuario",
|
||||
Fornecedor = "fornecedor"
|
||||
}
|
||||
|
||||
declare enum operadores {
|
||||
"=" = "=",
|
||||
"!=" = "!=",
|
||||
">" = ">",
|
||||
">=" = ">=",
|
||||
"<" = "<",
|
||||
"<=" = "<=",
|
||||
like = "like",
|
||||
in = "in"
|
||||
}
|
||||
type tipoFiltro = {
|
||||
coluna: string;
|
||||
valor: any;
|
||||
operador: keyof typeof operadores | operadores;
|
||||
ou?: boolean;
|
||||
};
|
||||
type interfaceConsulta = {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
filtros?: tipoFiltro[];
|
||||
ordem?: string;
|
||||
ordemTipo?: "asc" | "desc";
|
||||
colunas?: string[];
|
||||
apenasConsulta?: boolean;
|
||||
apenasContagem?: boolean;
|
||||
};
|
||||
declare const zOperadores: z.ZodEnum<{
|
||||
"=": "=";
|
||||
"!=": "!=";
|
||||
">": ">";
|
||||
">=": ">=";
|
||||
"<": "<";
|
||||
"<=": "<=";
|
||||
like: "like";
|
||||
in: "in";
|
||||
}>;
|
||||
declare const zFiltro: z.ZodObject<{
|
||||
coluna: z.ZodString;
|
||||
valor: z.ZodAny;
|
||||
operador: z.ZodEnum<{
|
||||
"=": "=";
|
||||
"!=": "!=";
|
||||
">": ">";
|
||||
">=": ">=";
|
||||
"<": "<";
|
||||
"<=": "<=";
|
||||
like: "like";
|
||||
in: "in";
|
||||
}>;
|
||||
ou: z.ZodOptional<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
|
||||
declare const dayjsbr: typeof dayjs;
|
||||
|
||||
declare const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
||||
|
||||
type tiposArquivo = "imagem" | "documento" | "vídeo" | "outros";
|
||||
declare const extensoes: {
|
||||
ext: string;
|
||||
tipo: tiposArquivo;
|
||||
mime: string;
|
||||
}[];
|
||||
/**
|
||||
* Função que retorna o tipo do arquivo
|
||||
* @param nomeArquivo
|
||||
* @returns
|
||||
*/
|
||||
declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArquivo;
|
||||
|
||||
declare const graficos_pilao: {
|
||||
[k: string]: {
|
||||
grafico: string;
|
||||
titulo: string;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* LocalStorage Tipado
|
||||
* Lê ou grava um valor no localStorage, mantendo o tipo genérico <T>.
|
||||
*/
|
||||
declare const localValor: <T>(chave_: string | any, valor?: T | null) => T | null;
|
||||
|
||||
type tipoLokiObjeto = {
|
||||
streams: {
|
||||
stream: {
|
||||
[k: string]: string;
|
||||
};
|
||||
values: [string, string][];
|
||||
}[];
|
||||
};
|
||||
declare const postLogger: ({ objeto, }: {
|
||||
objeto: tipoLokiObjeto;
|
||||
}) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
/** define a localização da pasta do projeto */
|
||||
declare const defineCwd: (novoCwd: string) => void;
|
||||
type tipoLevel = "info" | "warn" | "error";
|
||||
type tipoOpSessao = {
|
||||
inquilino: string;
|
||||
usuario: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
type tipoLog = {
|
||||
detalhes?: unknown[];
|
||||
__filename?: string;
|
||||
local?: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
type tipoLoggerLog = (level: tipoLevel, mensagem: string, op_tipoLog?: tipoLog) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
type TipoLoggerSessao = (sess: tipoOpSessao) => tipoLoggerLog;
|
||||
type tipoLogger = (amb: {
|
||||
app: string;
|
||||
eProducao: boolean;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
}) => TipoLoggerSessao;
|
||||
declare const logger: tipoLogger;
|
||||
|
||||
/**
|
||||
* Trata um objeto para ser imput para postgres
|
||||
* @param entrada
|
||||
* @returns
|
||||
*/
|
||||
declare const paraObjetoRegistroPg: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
declare const pgObjeto: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
declare const objetoPg: (entrada: {
|
||||
[k: string]: any;
|
||||
}) => {
|
||||
[k: string]: string | boolean | null | undefined | number;
|
||||
};
|
||||
|
||||
declare const umaFuncao: () => string;
|
||||
|
||||
declare const umaVariavel = "Ol\u00E1 Mundo! (vari\u00E1vel)";
|
||||
|
||||
/** gerar o texto de busca removendo caracteres especies e caixa alta */
|
||||
declare const texto_busca: (...texto: any[]) => string;
|
||||
|
||||
/** Gerar uma classe que facilita a gestão de rotas com a tipagem das querys
|
||||
*
|
||||
* Definições:
|
||||
*
|
||||
* caminho = "/aplicacao/funcionalidade"
|
||||
*
|
||||
* endereco = "http://localhost:3000/aplicacao/funcionalidade"
|
||||
*
|
||||
* parametros = {nome:"José"}
|
||||
*/
|
||||
declare class TipagemRotas<T extends {
|
||||
[q: string]: any;
|
||||
}> {
|
||||
_partesCaminho: string[];
|
||||
_acaoIr?: (endereco: string) => undefined;
|
||||
rotulo: string | undefined;
|
||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
||||
*/
|
||||
constructor({ caminho, acaoIr, rotulo, }: {
|
||||
caminho: (string | null | undefined)[] | string;
|
||||
acaoIr?: undefined | ((endereco: string) => undefined);
|
||||
/** Rotulo da página
|
||||
* Inicio | Controle
|
||||
*/
|
||||
rotulo?: string;
|
||||
});
|
||||
/** Retorna o caminho completo da rota
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/caminho"
|
||||
*/
|
||||
get caminho(): string;
|
||||
/** Define o caminho completo da rota
|
||||
** mCaminho.caminho = "/novoCaminho"
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/novoCaminho"
|
||||
** */
|
||||
set caminho(caminhoParcial: string);
|
||||
/** Retorna o caminho completo da rota com a query
|
||||
** console.log(mCaminho.resolve({q:"query"}))
|
||||
** "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
endereco(query: T, usarComoHash?: boolean): string;
|
||||
/** Vai para a url
|
||||
** mCaminho.ir({q:"query"})
|
||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
ir(query: T): void;
|
||||
/** Retorna os parametros da url
|
||||
** console.log(mCaminho.parametros())
|
||||
** {q:"query"}
|
||||
*/
|
||||
parametros(urlEntrada?: string): Partial<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Essa variável se conecta a tabela_lidades
|
||||
*
|
||||
* onde sigla se conecta com sigla
|
||||
*
|
||||
* Usuário terá mais opções de unidades, quando fazer o envio para o mtr, usar a opção fornecida pelo usuarios, caso não tenha
|
||||
* usar a normalizada
|
||||
*/
|
||||
declare enum siglas_unidades_medida {
|
||||
UN = "UN",
|
||||
KG = "KG",
|
||||
TON = "TON",
|
||||
g = "g",
|
||||
"M³" = "M\u00B3",
|
||||
Lt = "Lt"
|
||||
}
|
||||
declare const unidades_medida: {
|
||||
sigla_unidade: keyof typeof siglas_unidades_medida;
|
||||
nome: string;
|
||||
sigla_normalizada: keyof typeof siglas_unidades_medida;
|
||||
normalizar: (valor: number) => number;
|
||||
tipo: "massa" | "volume" | "comprimento" | "unidade";
|
||||
}[];
|
||||
|
||||
/**
|
||||
* Valida se uma string é um UUID válido (qualquer versão).
|
||||
*
|
||||
* @param valor - A string que será validada.
|
||||
* @returns booleano indicando se é um UUID válido.
|
||||
*/
|
||||
declare const erUuid: RegExp;
|
||||
declare const validarUuid: (uuid: string | number | undefined | null) => boolean;
|
||||
/**
|
||||
* Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace).
|
||||
*
|
||||
* - Usa o algoritmo MD5 (RFC 4122).
|
||||
* - Sempre retorna o mesmo UUID para a mesma combinação chave + grupo.
|
||||
* - Caso o grupo não seja informado, usa o UUID "nil" como namespace.
|
||||
*
|
||||
* @param chave - Qualquer valor que será convertido em string para gerar o UUID (ex: número, string ou objeto).
|
||||
* @param grupo - Opcional. Namespace para separar domínios diferentes de UUIDs.
|
||||
* @returns UUID v3 (determinístico)
|
||||
*/
|
||||
declare const uuidV3: (chave: any, grupo?: any) => string;
|
||||
/**
|
||||
* Gera um UUID v4 (aleatório, não determinístico).
|
||||
*
|
||||
* - Usado quando unicidade é necessária, mas não se exige que seja previsível.
|
||||
*/
|
||||
declare const uuidV4: typeof v4;
|
||||
/**
|
||||
* @deprecated Esta variável será descontinuada em versões futuras.
|
||||
* Use a função `uuidV4()` diretamente.
|
||||
*/
|
||||
declare const uuid: typeof v4;
|
||||
|
||||
declare const esperar: (ms: number) => Promise<true>;
|
||||
/**
|
||||
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
|
||||
* const nomex = {a: 1, b: 2}
|
||||
* nomeVariavel({nomex}) // retorna "nomex"
|
||||
* @param v
|
||||
* @returns
|
||||
*/
|
||||
declare const nomeVariavel: (v: {
|
||||
[key: string]: any;
|
||||
}) => string;
|
||||
|
||||
export { TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, defineCwd, erUuid, esperar, extensoes, graficos_pilao, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
||||
export type { TipoLoggerSessao, interfaceConsulta, tipoFiltro, tipoLogger, tipoLoggerLog, tipoLokiObjeto };
|
||||
export * from "./constantes";
|
||||
export * from "./consulta";
|
||||
export * from "./aleatorio";
|
||||
export * from "./texto_busca";
|
||||
export * from "./unidades_medida";
|
||||
export * from "./uuid";
|
||||
export * from "./ecosistema";
|
||||
export * from "./variaveisComuns";
|
||||
export * from "./tipagemRotas";
|
||||
export * from "./extensoes";
|
||||
export * from "./logger";
|
||||
export * from "./situacoes";
|
||||
|
|
|
|||
29
dist/index.js
vendored
Normal file
29
dist/index.js
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"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("./constantes"), exports);
|
||||
__exportStar(require("./consulta"), exports);
|
||||
__exportStar(require("./aleatorio"), exports);
|
||||
__exportStar(require("./texto_busca"), exports);
|
||||
__exportStar(require("./unidades_medida"), exports);
|
||||
__exportStar(require("./uuid"), exports);
|
||||
__exportStar(require("./ecosistema"), exports);
|
||||
__exportStar(require("./variaveisComuns"), exports);
|
||||
__exportStar(require("./tipagemRotas"), exports);
|
||||
__exportStar(require("./extensoes"), exports);
|
||||
__exportStar(require("./logger"), exports);
|
||||
__exportStar(require("./situacoes"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,6CAA0B;AAC1B,8CAA2B;AAC3B,gDAA6B;AAC7B,oDAAiC;AACjC,yCAAsB;AACtB,+CAA4B;AAC5B,oDAAiC;AACjC,iDAA8B;AAC9B,8CAA2B;AAC3B,2CAAwB;AACxB,8CAA2B"}
|
||||
548
dist/index.mjs
vendored
548
dist/index.mjs
vendored
|
|
@ -1,548 +0,0 @@
|
|||
import z from 'zod';
|
||||
import dayjs from 'dayjs';
|
||||
import duration from 'dayjs/plugin/duration.js';
|
||||
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter.js';
|
||||
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';
|
||||
import minMax from 'dayjs/plugin/minMax.js';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
||||
import timezone from 'dayjs/plugin/timezone.js';
|
||||
import utc from 'dayjs/plugin/utc.js';
|
||||
import weekOfYear from 'dayjs/plugin/weekOfYear.js';
|
||||
import 'dayjs/locale/pt-br.js';
|
||||
import crossFetch from 'cross-fetch';
|
||||
import { v4, v3, NIL } from 'uuid';
|
||||
|
||||
const alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
||||
const aleatorio = (tamanho) => `eli-${Array.from({ length: tamanho || 8 }).map(() => alfabeto[(999 * Math.random() | 0) % alfabeto.length]).join("")}`;
|
||||
|
||||
const _cache = {};
|
||||
globalThis.cacheMemoria_cache = _cache;
|
||||
const cacheM = (chave, valor, validadeSeg) => {
|
||||
const txChave = typeof chave == "string" ? chave : typeof chave == "number" ? String(chave) : encodeURIComponent(JSON.stringify(chave));
|
||||
const validade = validadeSeg && (/* @__PURE__ */ new Date()).getTime() + validadeSeg * 1e3;
|
||||
if (valor !== void 0) {
|
||||
_cache[txChave] = {
|
||||
valor,
|
||||
validade
|
||||
};
|
||||
}
|
||||
const busca = _cache[txChave];
|
||||
if (busca?.validade && busca.validade < (/* @__PURE__ */ new Date()).getTime()) {
|
||||
return void 0;
|
||||
}
|
||||
return busca?.valor;
|
||||
};
|
||||
const verCacheM = () => _cache;
|
||||
const cacheMemoria = cacheM;
|
||||
const cacheMFixo = (chave) => (valor) => cacheM(chave, valor);
|
||||
|
||||
const uuid_null = "00000000-0000-0000-0000-000000000000";
|
||||
var camposComuns = /* @__PURE__ */ ((camposComuns2) => {
|
||||
camposComuns2["codigo"] = "codigo";
|
||||
camposComuns2["excluido"] = "excluido";
|
||||
camposComuns2["data_hora_criacao"] = "data_hora_criacao";
|
||||
camposComuns2["data_hora_atualizacao"] = "data_hora_atualizacao";
|
||||
camposComuns2["codigo_usuario_criacao"] = "codigo_usuario_criacao";
|
||||
camposComuns2["codigo_usuario_atualizacao"] = "codigo_usuario_atualizacao";
|
||||
camposComuns2["versao"] = "versao";
|
||||
return camposComuns2;
|
||||
})(camposComuns || {});
|
||||
var tx = /* @__PURE__ */ ((tx2) => {
|
||||
tx2["token"] = "token";
|
||||
return tx2;
|
||||
})(tx || {});
|
||||
var tipoUsuarioResiduos = /* @__PURE__ */ ((tipoUsuarioResiduos2) => {
|
||||
tipoUsuarioResiduos2["Usuario"] = "usuario";
|
||||
tipoUsuarioResiduos2["Fornecedor"] = "fornecedor";
|
||||
return tipoUsuarioResiduos2;
|
||||
})(tipoUsuarioResiduos || {});
|
||||
|
||||
var operadores = /* @__PURE__ */ ((operadores2) => {
|
||||
operadores2["="] = "=";
|
||||
operadores2["!="] = "!=";
|
||||
operadores2[">"] = ">";
|
||||
operadores2[">="] = ">=";
|
||||
operadores2["<"] = "<";
|
||||
operadores2["<="] = "<=";
|
||||
operadores2["like"] = "like";
|
||||
operadores2["in"] = "in";
|
||||
return operadores2;
|
||||
})(operadores || {});
|
||||
const zOperadores = z.enum([
|
||||
"=",
|
||||
"!=",
|
||||
">",
|
||||
">=",
|
||||
"<",
|
||||
"<=",
|
||||
"like",
|
||||
"in"
|
||||
]);
|
||||
const zFiltro = z.object({
|
||||
coluna: z.string(),
|
||||
valor: z.any(),
|
||||
operador: zOperadores,
|
||||
ou: z.boolean().optional()
|
||||
});
|
||||
|
||||
dayjs.locale("pt-br");
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(weekOfYear);
|
||||
dayjs.extend(isSameOrBefore);
|
||||
dayjs.extend(isSameOrAfter);
|
||||
dayjs.extend(minMax);
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.extend(duration);
|
||||
const dayjsbr = dayjs;
|
||||
|
||||
const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
||||
|
||||
const extensoes = [
|
||||
{
|
||||
ext: "gif",
|
||||
tipo: "imagem",
|
||||
mime: "image/gif"
|
||||
},
|
||||
{
|
||||
ext: "jpg",
|
||||
tipo: "imagem",
|
||||
mime: "image/jpeg"
|
||||
},
|
||||
{
|
||||
ext: "jpeg",
|
||||
tipo: "imagem",
|
||||
mime: "image/jpeg"
|
||||
},
|
||||
{
|
||||
ext: "png",
|
||||
tipo: "imagem",
|
||||
mime: "image/png"
|
||||
},
|
||||
{
|
||||
ext: "bmp",
|
||||
tipo: "imagem",
|
||||
mime: "image/bmp"
|
||||
},
|
||||
{
|
||||
ext: "webp",
|
||||
tipo: "imagem",
|
||||
mime: "image/webp"
|
||||
},
|
||||
{
|
||||
ext: "tiff",
|
||||
tipo: "imagem",
|
||||
mime: "image/tiff"
|
||||
},
|
||||
{
|
||||
ext: "svg",
|
||||
tipo: "imagem",
|
||||
mime: "image/svg+xml"
|
||||
},
|
||||
{
|
||||
ext: "ico",
|
||||
tipo: "imagem",
|
||||
mime: "image/x-icon"
|
||||
},
|
||||
{
|
||||
ext: "pdf",
|
||||
tipo: "documento",
|
||||
mime: "application/pdf"
|
||||
},
|
||||
{
|
||||
ext: "doc",
|
||||
tipo: "documento",
|
||||
mime: "application/msword"
|
||||
},
|
||||
{
|
||||
ext: "docx",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
||||
},
|
||||
{
|
||||
ext: "xls",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.ms-excel"
|
||||
},
|
||||
{
|
||||
ext: "xlsx",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
},
|
||||
{
|
||||
ext: "ppt",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.ms-powerpoint"
|
||||
},
|
||||
{
|
||||
ext: "pptx",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
||||
},
|
||||
{
|
||||
ext: "txt",
|
||||
tipo: "documento",
|
||||
mime: "text/plain"
|
||||
},
|
||||
{
|
||||
ext: "odt",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.oasis.opendocument.text"
|
||||
},
|
||||
{
|
||||
ext: "ods",
|
||||
tipo: "documento",
|
||||
mime: "application/vnd.oasis.opendocument.spreadsheet"
|
||||
},
|
||||
{
|
||||
ext: "rtf",
|
||||
tipo: "documento",
|
||||
mime: "application/rtf"
|
||||
},
|
||||
{
|
||||
ext: "csv",
|
||||
tipo: "documento",
|
||||
mime: "text/csv"
|
||||
},
|
||||
{
|
||||
ext: "mp4",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/mp4"
|
||||
},
|
||||
{
|
||||
ext: "avi",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/x-msvideo"
|
||||
},
|
||||
{
|
||||
ext: "mkv",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/x-matroska"
|
||||
},
|
||||
{
|
||||
ext: "mov",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/quicktime"
|
||||
},
|
||||
{
|
||||
ext: "wmv",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/x-ms-wmv"
|
||||
},
|
||||
{
|
||||
ext: "flv",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/x-flv"
|
||||
},
|
||||
{
|
||||
ext: "webm",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/webm"
|
||||
},
|
||||
{
|
||||
ext: "3gp",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/3gpp"
|
||||
},
|
||||
{
|
||||
ext: "mpeg",
|
||||
tipo: "v\xEDdeo",
|
||||
mime: "video/mpeg"
|
||||
}
|
||||
];
|
||||
const tipoArquivo = (nomeArquivo) => {
|
||||
const extArquivo = String(nomeArquivo || "").toLocaleLowerCase().split(".").pop();
|
||||
const extensao = extensoes.find((extensao2) => extensao2.ext === extArquivo);
|
||||
return extensao?.tipo || "outros";
|
||||
};
|
||||
|
||||
const graficos_pilao = {
|
||||
Condicionantes: {
|
||||
grafico: "condicionantes-criadas",
|
||||
titulo: "Condicionantes Criadas"
|
||||
},
|
||||
Licen\u00E7as: {
|
||||
grafico: "licencas-criadas",
|
||||
titulo: "Licen\xE7as Criadas"
|
||||
}
|
||||
};
|
||||
|
||||
const localValor = (chave_, valor) => {
|
||||
const localStorage = globalThis.localStorage;
|
||||
if (typeof localStorage == "undefined") return null;
|
||||
const chave = typeof chave_ === "string" ? chave_ : encodeURIComponent(JSON.stringify(chave_));
|
||||
try {
|
||||
if (valor !== void 0) {
|
||||
localStorage.setItem(chave, JSON.stringify(valor));
|
||||
}
|
||||
const v2 = localStorage.getItem(chave);
|
||||
if (v2 === null) return null;
|
||||
try {
|
||||
return JSON.parse(v2);
|
||||
} catch {
|
||||
return v2;
|
||||
}
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const esperar = (ms) => new Promise(
|
||||
(resolve) => setTimeout(() => resolve(true), ms)
|
||||
);
|
||||
const nomeVariavel = (v) => Object.keys(v).join("/");
|
||||
|
||||
const LOKI_BASE_URL = "https://log.idz.one";
|
||||
const LOKI_ENDPOINT = "/loki/api/v1/push";
|
||||
const postLogger = async ({
|
||||
objeto
|
||||
}) => {
|
||||
const response = await crossFetch(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(objeto)
|
||||
}).catch((a) => a);
|
||||
if (!response.ok) {
|
||||
return [objeto, `Erro ${response.status}: ${await response?.text?.()}`];
|
||||
}
|
||||
return [objeto];
|
||||
};
|
||||
let cwd = "";
|
||||
const defineCwd = (novoCwd) => {
|
||||
cwd = novoCwd;
|
||||
};
|
||||
const logger = ({ app: app_e, eProducao, parametros: parametrosAmbiente }) => ({ inquilino, usuario, parametros: parametrosSessao }) => async (level, mensagem, op_tipoLog) => {
|
||||
let {
|
||||
__filename,
|
||||
detalhes,
|
||||
local,
|
||||
parametros: parametrosLog
|
||||
} = op_tipoLog || {};
|
||||
const app = `${eProducao ? "" : "DEV-"}${app_e}`;
|
||||
if (cwd && __filename) {
|
||||
__filename = __filename.replace(cwd, "");
|
||||
}
|
||||
if (local) {
|
||||
detalhes = [`${nomeVariavel({ local })}="${local}"`, ...detalhes || []];
|
||||
}
|
||||
if (__filename) {
|
||||
detalhes = [
|
||||
`${nomeVariavel({ __filename })}="${__filename}"`,
|
||||
...detalhes || []
|
||||
];
|
||||
}
|
||||
const timestamp = `${Date.now()}000000`;
|
||||
const mainLog = detalhes?.length ? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" | ")}` : mensagem;
|
||||
const payload = {
|
||||
stream: {
|
||||
app,
|
||||
inquilino,
|
||||
usuario,
|
||||
level,
|
||||
...parametrosAmbiente || {},
|
||||
...parametrosSessao || {},
|
||||
...parametrosLog || {}
|
||||
},
|
||||
values: [
|
||||
[
|
||||
timestamp,
|
||||
mainLog
|
||||
// Linha de log direta
|
||||
]
|
||||
]
|
||||
};
|
||||
const objeto = { streams: [payload] };
|
||||
const response = await postLogger({ objeto });
|
||||
return response;
|
||||
};
|
||||
|
||||
const paraObjetoRegistroPg = (entrada) => {
|
||||
try {
|
||||
return Object.fromEntries(
|
||||
Object.entries(entrada).map(([k, v]) => [
|
||||
k,
|
||||
v === void 0 || v == null ? v : typeof v == "string" || typeof v == "number" || typeof v == "boolean" ? v : JSON.stringify(v, null, 2)
|
||||
])
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Erro na fun\xE7\xE3o paraObjetoRegistroPg: ${error.message} ${error.stack}`
|
||||
);
|
||||
}
|
||||
};
|
||||
const pgObjeto = paraObjetoRegistroPg;
|
||||
const objetoPg = paraObjetoRegistroPg;
|
||||
|
||||
const umaFuncao = () => "Ol\xE1 Mundo! (fun\xE7\xE3o)";
|
||||
|
||||
const umaVariavel = "Ol\xE1 Mundo! (vari\xE1vel)";
|
||||
|
||||
const texto_busca = (...texto) => texto.map(
|
||||
(txt) => txt === null || txt === void 0 ? "" : String(txt).normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, " ").toLowerCase()
|
||||
).join(" ");
|
||||
|
||||
class TipagemRotas {
|
||||
_partesCaminho = [];
|
||||
_acaoIr;
|
||||
rotulo;
|
||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
||||
*/
|
||||
constructor({
|
||||
caminho,
|
||||
acaoIr,
|
||||
rotulo
|
||||
}) {
|
||||
this._acaoIr = acaoIr;
|
||||
this._partesCaminho = (Array.isArray(caminho) ? caminho : [caminho]).filter(Boolean).map((a) => String(a)).flatMap((a) => a.split("/")).filter(Boolean);
|
||||
this.rotulo = rotulo;
|
||||
}
|
||||
/** Retorna o caminho completo da rota
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/caminho"
|
||||
*/
|
||||
get caminho() {
|
||||
const ret = `/${this._partesCaminho.join("/")}`;
|
||||
return ret;
|
||||
}
|
||||
/** Define o caminho completo da rota
|
||||
** mCaminho.caminho = "/novoCaminho"
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/novoCaminho"
|
||||
** */
|
||||
set caminho(caminhoParcial) {
|
||||
this._partesCaminho = caminhoParcial.split("/").filter((parte) => parte);
|
||||
}
|
||||
/** Retorna o caminho completo da rota com a query
|
||||
** console.log(mCaminho.resolve({q:"query"}))
|
||||
** "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
endereco(query, usarComoHash) {
|
||||
const url = new URL(
|
||||
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
||||
);
|
||||
url.pathname = this.caminho;
|
||||
url.search = "";
|
||||
const queryKeys = Object.entries(query);
|
||||
for (const [key, value] of queryKeys) {
|
||||
url.searchParams.set(String(key), JSON.stringify(value));
|
||||
}
|
||||
url.hash = "";
|
||||
if (usarComoHash) {
|
||||
url.hash = `#${url.search}`;
|
||||
url.search = "";
|
||||
}
|
||||
return url.href;
|
||||
}
|
||||
/** Vai para a url
|
||||
** mCaminho.ir({q:"query"})
|
||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
ir(query) {
|
||||
if (this._acaoIr) {
|
||||
this._acaoIr(this.endereco({ ...query }));
|
||||
} else {
|
||||
if (typeof window != "undefined") {
|
||||
window.location.href = this.endereco({ ...query });
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Retorna os parametros da url
|
||||
** console.log(mCaminho.parametros())
|
||||
** {q:"query"}
|
||||
*/
|
||||
parametros(urlEntrada) {
|
||||
const url = urlEntrada ? new URL(urlEntrada) : new URL(
|
||||
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
||||
);
|
||||
const query = url.searchParams;
|
||||
let queryObj = Object.fromEntries(query.entries());
|
||||
const hash = url.hash;
|
||||
if (hash) {
|
||||
const hashObj = Object.fromEntries(
|
||||
new URLSearchParams(hash.slice(1)).entries()
|
||||
);
|
||||
queryObj = { ...queryObj, ...hashObj };
|
||||
}
|
||||
for (const chave in queryObj) {
|
||||
try {
|
||||
queryObj[chave] = JSON.parse(queryObj[chave]);
|
||||
} catch {
|
||||
console.log(`[${chave}|${queryObj[chave]}] n\xE3o \xE9 um json v\xE1lido.`);
|
||||
}
|
||||
}
|
||||
return queryObj;
|
||||
}
|
||||
}
|
||||
|
||||
var siglas_unidades_medida = /* @__PURE__ */ ((siglas_unidades_medida2) => {
|
||||
siglas_unidades_medida2["UN"] = "UN";
|
||||
siglas_unidades_medida2["KG"] = "KG";
|
||||
siglas_unidades_medida2["TON"] = "TON";
|
||||
siglas_unidades_medida2["g"] = "g";
|
||||
siglas_unidades_medida2["M\xB3"] = "M\xB3";
|
||||
siglas_unidades_medida2["Lt"] = "Lt";
|
||||
return siglas_unidades_medida2;
|
||||
})(siglas_unidades_medida || {});
|
||||
const unidades_medida = [
|
||||
{
|
||||
sigla_unidade: "KG",
|
||||
nome: "Quilograma",
|
||||
sigla_normalizada: "KG",
|
||||
normalizar: (valor) => valor,
|
||||
tipo: "massa"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "g",
|
||||
nome: "Grama",
|
||||
sigla_normalizada: "KG",
|
||||
normalizar: (valor) => valor / 1e3,
|
||||
tipo: "massa"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "TON",
|
||||
nome: "Tonelada",
|
||||
sigla_normalizada: "KG",
|
||||
normalizar: (valor) => valor * 1e3,
|
||||
tipo: "massa"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "Lt",
|
||||
nome: "Litro",
|
||||
sigla_normalizada: "Lt",
|
||||
normalizar: (valor) => valor,
|
||||
tipo: "volume"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "M\xB3",
|
||||
nome: "Metro C\xFAbico",
|
||||
sigla_normalizada: "Lt",
|
||||
normalizar: (valor) => valor * 1e3,
|
||||
tipo: "volume"
|
||||
},
|
||||
{
|
||||
sigla_unidade: "UN",
|
||||
nome: "Unidade",
|
||||
sigla_normalizada: "UN",
|
||||
normalizar: (valor) => valor,
|
||||
tipo: "unidade"
|
||||
}
|
||||
];
|
||||
|
||||
const erUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
const validarUuid = (uuid2) => {
|
||||
const retorno = erUuid.test(String(uuid2 || ""));
|
||||
return retorno;
|
||||
};
|
||||
const uuidV3 = (chave, grupo) => {
|
||||
return v3(
|
||||
// Converte a chave para string (de forma segura)
|
||||
typeof chave === "string" ? chave : typeof chave === "number" ? String(chave) : JSON.stringify(chave),
|
||||
// Se um grupo foi fornecido, gera um UUID v3 recursivamente com base nele, senão usa NIL
|
||||
grupo ? uuidV3(grupo) : NIL
|
||||
);
|
||||
};
|
||||
const uuidV4 = v4;
|
||||
const uuid = uuidV4;
|
||||
|
||||
export { TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, defineCwd, erUuid, esperar, extensoes, graficos_pilao, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
||||
40
dist/logger.d.ts
vendored
Normal file
40
dist/logger.d.ts
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
export type tipoLokiObjeto = {
|
||||
streams: {
|
||||
stream: {
|
||||
[k: string]: string;
|
||||
};
|
||||
values: [string, string][];
|
||||
}[];
|
||||
};
|
||||
export declare const postLogger: ({ objeto, }: {
|
||||
objeto: tipoLokiObjeto;
|
||||
}) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
/** define a localização da pasta do projeto */
|
||||
export declare const defineCwd: (novoCwd: string) => void;
|
||||
type tipoLevel = "info" | "warn" | "error";
|
||||
type tipoOpSessao = {
|
||||
inquilino: string;
|
||||
usuario: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
type tipoLog = {
|
||||
detalhes?: unknown[];
|
||||
__filename?: string;
|
||||
local?: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
export type tipoLoggerLog = (level: tipoLevel, mensagem: string, op_tipoLog?: tipoLog) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
export type TipoLoggerSessao = (sess: tipoOpSessao) => tipoLoggerLog;
|
||||
export type tipoLogger = (amb: {
|
||||
app: string;
|
||||
eProducao: boolean;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
}) => TipoLoggerSessao;
|
||||
export declare const logger: tipoLogger;
|
||||
export {};
|
||||
72
dist/logger.js
vendored
Normal file
72
dist/logger.js
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.logger = exports.defineCwd = exports.postLogger = void 0;
|
||||
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
||||
const variaveisComuns_1 = require("./variaveisComuns");
|
||||
const LOKI_BASE_URL = "https://log.idz.one";
|
||||
const LOKI_ENDPOINT = "/loki/api/v1/push";
|
||||
const postLogger = async ({ objeto, }) => {
|
||||
const response = await (0, cross_fetch_1.default)(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(objeto),
|
||||
}).catch((a) => a);
|
||||
if (!response.ok) {
|
||||
return [objeto, `Erro ${response.status}: ${await response?.text?.()}`];
|
||||
}
|
||||
else {
|
||||
return [objeto];
|
||||
}
|
||||
};
|
||||
exports.postLogger = postLogger;
|
||||
let cwd = "";
|
||||
/** define a localização da pasta do projeto */
|
||||
const defineCwd = (novoCwd) => {
|
||||
cwd = novoCwd;
|
||||
};
|
||||
exports.defineCwd = defineCwd;
|
||||
const logger = ({ app: app_e, eProducao, parametros: parametrosAmbiente }) => ({ inquilino, usuario, parametros: parametrosSessao }) => async (level, mensagem, op_tipoLog) => {
|
||||
let { __filename, detalhes, local, parametros: parametrosLog, } = op_tipoLog || {};
|
||||
const app = `${eProducao ? "" : "DEV-"}${app_e}`;
|
||||
if (cwd && __filename) {
|
||||
__filename = __filename.replace(cwd, "");
|
||||
}
|
||||
if (local) {
|
||||
detalhes = [`${(0, variaveisComuns_1.nomeVariavel)({ local })}="${local}"`, ...(detalhes || [])];
|
||||
}
|
||||
if (__filename) {
|
||||
detalhes = [
|
||||
`${(0, variaveisComuns_1.nomeVariavel)({ __filename })}="${__filename}"`,
|
||||
...(detalhes || []),
|
||||
];
|
||||
}
|
||||
const timestamp = `${Date.now()}000000`;
|
||||
const mainLog = detalhes?.length
|
||||
? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" | ")}`
|
||||
: mensagem;
|
||||
const payload = {
|
||||
stream: {
|
||||
app,
|
||||
inquilino,
|
||||
usuario,
|
||||
level,
|
||||
...(parametrosAmbiente || {}),
|
||||
...(parametrosSessao || {}),
|
||||
...(parametrosLog || {}),
|
||||
},
|
||||
values: [
|
||||
[
|
||||
timestamp,
|
||||
mainLog, // Linha de log direta
|
||||
],
|
||||
],
|
||||
};
|
||||
const objeto = { streams: [payload] };
|
||||
const response = await (0, exports.postLogger)({ objeto });
|
||||
return response;
|
||||
};
|
||||
exports.logger = logger;
|
||||
//# sourceMappingURL=logger.js.map
|
||||
1
dist/logger.js.map
vendored
Normal file
1
dist/logger.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"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"}
|
||||
1
dist/teste.d.ts
vendored
Normal file
1
dist/teste.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export {};
|
||||
11
dist/teste.js
vendored
Normal file
11
dist/teste.js
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const logger_1 = require("./logger");
|
||||
const l = (0, logger_1.logger)({ app: "teste", eProducao: true });
|
||||
const lg = l({
|
||||
inquilino: "conta_1",
|
||||
usuario: "pedrinho",
|
||||
});
|
||||
lg("error", "Deu Ruim").then((a) => console.log(JSON.stringify(a)));
|
||||
lg("info", "Deu Bom", { __filename }).then((a) => console.log(JSON.stringify(a)));
|
||||
//# sourceMappingURL=teste.js.map
|
||||
1
dist/teste.js.map
vendored
Normal file
1
dist/teste.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"teste.js","sourceRoot":"","sources":["../src/teste.ts"],"names":[],"mappings":";;AAAA,qCAAiC;AAEjC,MAAM,CAAC,GAAG,IAAA,eAAM,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;AAEnD,MAAM,EAAE,GAAG,CAAC,CAAC;IACX,SAAS,EAAE,SAAS;IACpB,OAAO,EAAE,UAAU;CACpB,CAAC,CAAA;AAEF,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACnE,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAC/B,CAAA"}
|
||||
2
dist/texto_busca.d.ts
vendored
Normal file
2
dist/texto_busca.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/** gerar o texto de busca removendo caracteres especies e caixa alta */
|
||||
export declare const texto_busca: (...texto: any[]) => string;
|
||||
16
dist/texto_busca.js
vendored
Normal file
16
dist/texto_busca.js
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
/** gerar o texto de busca removendo caracteres especies e caixa alta */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.texto_busca = void 0;
|
||||
const texto_busca = (...texto) => texto
|
||||
.map((txt) => txt === null || txt === undefined
|
||||
? ""
|
||||
: String(txt)
|
||||
.normalize("NFD")
|
||||
// biome-ignore lint/suspicious/noMisleadingCharacterClass: <explanation>
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
.replace(/\s+/g, " ")
|
||||
.toLowerCase())
|
||||
.join(" ");
|
||||
exports.texto_busca = texto_busca;
|
||||
//# sourceMappingURL=texto_busca.js.map
|
||||
1
dist/texto_busca.js.map
vendored
Normal file
1
dist/texto_busca.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"texto_busca.js","sourceRoot":"","sources":["../src/texto_busca.ts"],"names":[],"mappings":";AAAA,wEAAwE;;;AAEjE,MAAM,WAAW,GAAG,CAAC,GAAG,KAAY,EAAU,EAAE,CACrD,KAAK;KACF,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACX,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;IAC/B,CAAC,CAAC,EAAE;IACJ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACR,SAAS,CAAC,KAAK,CAAC;QACjB,yEAAyE;SACxE,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;SAC/B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,WAAW,EAAE,CACrB;KACA,IAAI,CAAC,GAAG,CAAC,CAAA;AAZD,QAAA,WAAW,eAYV"}
|
||||
45
dist/tipagemRotas.d.ts
vendored
Normal file
45
dist/tipagemRotas.d.ts
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/** Gerar uma classe que facilita a gestão de rotas com a tipagem das querys
|
||||
*
|
||||
* Definições:
|
||||
*
|
||||
* caminho = "/aplicacao/funcionalidade"
|
||||
*
|
||||
* endereco = "http://localhost:3000/aplicacao/funcionalidade"
|
||||
*
|
||||
* parametros = {nome:"José"}
|
||||
*/
|
||||
export declare class TipagemRotas<T extends {
|
||||
[q: string]: string | undefined;
|
||||
}> {
|
||||
_partesCaminho: string[];
|
||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
||||
*/
|
||||
constructor(...caminhos: string[]);
|
||||
/** Retorna o caminho completo da rota
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/caminho"
|
||||
*/
|
||||
get caminho(): string;
|
||||
/** Define o caminho completo da rota
|
||||
** mCaminho.caminho = "/novoCaminho"
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/novoCaminho"
|
||||
** */
|
||||
set caminho(caminhoParcial: string);
|
||||
/** Retorna o caminho completo da rota com a query
|
||||
** console.log(mCaminho.resolve({q:"query"}))
|
||||
** "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
endereco(query: T, usarComoHash?: boolean): string;
|
||||
/** Vai para a url
|
||||
** mCaminho.ir({q:"query"})
|
||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
ir(query: T): void;
|
||||
/** Retorna os parametros da url
|
||||
** console.log(mCaminho.parametros())
|
||||
** {q:"query"}
|
||||
*/
|
||||
get parametros(): Partial<T>;
|
||||
}
|
||||
96
dist/tipagemRotas.js
vendored
Normal file
96
dist/tipagemRotas.js
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
"use strict";
|
||||
/** Gerar uma classe que facilita a gestão de rotas com a tipagem das querys
|
||||
*
|
||||
* Definições:
|
||||
*
|
||||
* caminho = "/aplicacao/funcionalidade"
|
||||
*
|
||||
* endereco = "http://localhost:3000/aplicacao/funcionalidade"
|
||||
*
|
||||
* parametros = {nome:"José"}
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TipagemRotas = void 0;
|
||||
class TipagemRotas {
|
||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
||||
*/
|
||||
constructor(...caminhos) {
|
||||
this._partesCaminho = [];
|
||||
caminhos.forEach((caminho) => {
|
||||
String(caminho)
|
||||
.split("/")
|
||||
.forEach((parte) => {
|
||||
if (parte) {
|
||||
this._partesCaminho.push(parte);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/** Retorna o caminho completo da rota
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/caminho"
|
||||
*/
|
||||
get caminho() {
|
||||
let ret = `/${this._partesCaminho.join("/")}`;
|
||||
ret = ret.replace(/\/+/g, "/");
|
||||
if (ret.length > 1 && ret.endsWith("/")) {
|
||||
ret = ret.slice(0, -1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/** Define o caminho completo da rota
|
||||
** mCaminho.caminho = "/novoCaminho"
|
||||
** console.log(mCaminho.caminho)
|
||||
** "/novoCaminho"
|
||||
** */
|
||||
set caminho(caminhoParcial) {
|
||||
this._partesCaminho = caminhoParcial.split("/").filter((parte) => parte);
|
||||
}
|
||||
/** Retorna o caminho completo da rota com a query
|
||||
** console.log(mCaminho.resolve({q:"query"}))
|
||||
** "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
endereco(query, usarComoHash) {
|
||||
const url = new URL(typeof window !== "undefined" ? window.location.href : "http://localhost");
|
||||
url.pathname = this.caminho;
|
||||
url.search = "";
|
||||
const queryKeys = Object.entries(query);
|
||||
for (const [key, value] of queryKeys) {
|
||||
url.searchParams.set(String(key), value === undefined || value === null ? "" : value);
|
||||
}
|
||||
url.hash = "";
|
||||
if (usarComoHash) {
|
||||
url.hash = `#${url.search}`;
|
||||
url.search = "";
|
||||
}
|
||||
return url.href;
|
||||
}
|
||||
/** Vai para a url
|
||||
** mCaminho.ir({q:"query"})
|
||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
ir(query) {
|
||||
if (typeof window != "undefined") {
|
||||
window.location.href = this.endereco(query);
|
||||
}
|
||||
}
|
||||
/** Retorna os parametros da url
|
||||
** console.log(mCaminho.parametros())
|
||||
** {q:"query"}
|
||||
*/
|
||||
get parametros() {
|
||||
const url = new URL(typeof window !== "undefined" ? window.location.href : "http://localhost");
|
||||
const query = url.searchParams;
|
||||
const queryObj = Object.fromEntries(query.entries());
|
||||
// pegar hash
|
||||
const hash = url.hash;
|
||||
if (hash) {
|
||||
const hashObj = Object.fromEntries(new URLSearchParams(hash.slice(1)).entries());
|
||||
return { ...queryObj, ...hashObj };
|
||||
}
|
||||
return queryObj;
|
||||
}
|
||||
}
|
||||
exports.TipagemRotas = TipagemRotas;
|
||||
//# sourceMappingURL=tipagemRotas.js.map
|
||||
1
dist/tipagemRotas.js.map
vendored
Normal file
1
dist/tipagemRotas.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"tipagemRotas.js","sourceRoot":"","sources":["../src/tipagemRotas.ts"],"names":[],"mappings":"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"}
|
||||
23
dist/unidades_medida.d.ts
vendored
Normal file
23
dist/unidades_medida.d.ts
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Essa variável se conecta a tabela_lidades
|
||||
*
|
||||
* onde sigla se conecta com sigla
|
||||
*
|
||||
* Usuário terá mais opções de unidades, quando fazer o envio para o mtr, usar a opção fornecida pelo usuarios, caso não tenha
|
||||
* usar a normalizada
|
||||
*/
|
||||
export declare enum siglas_unidades_medida {
|
||||
UN = "UN",
|
||||
KG = "KG",
|
||||
TON = "TON",
|
||||
g = "g",
|
||||
"M³" = "M\u00B3",
|
||||
Lt = "Lt"
|
||||
}
|
||||
export declare const unidades_medida: {
|
||||
sigla_unidade: keyof typeof siglas_unidades_medida;
|
||||
nome: string;
|
||||
sigla_normalizada: keyof typeof siglas_unidades_medida;
|
||||
normalizar: (valor: number) => number;
|
||||
tipo: "massa" | "volume" | "comprimento" | "unidade";
|
||||
}[];
|
||||
65
dist/unidades_medida.js
vendored
Normal file
65
dist/unidades_medida.js
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
"use strict";
|
||||
/**
|
||||
* Essa variável se conecta a tabela_lidades
|
||||
*
|
||||
* onde sigla se conecta com sigla
|
||||
*
|
||||
* Usuário terá mais opções de unidades, quando fazer o envio para o mtr, usar a opção fornecida pelo usuarios, caso não tenha
|
||||
* usar a normalizada
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.unidades_medida = exports.siglas_unidades_medida = void 0;
|
||||
var siglas_unidades_medida;
|
||||
(function (siglas_unidades_medida) {
|
||||
siglas_unidades_medida["UN"] = "UN";
|
||||
siglas_unidades_medida["KG"] = "KG";
|
||||
siglas_unidades_medida["TON"] = "TON";
|
||||
siglas_unidades_medida["g"] = "g";
|
||||
siglas_unidades_medida["M\u00B3"] = "M\u00B3";
|
||||
siglas_unidades_medida["Lt"] = "Lt";
|
||||
})(siglas_unidades_medida || (exports.siglas_unidades_medida = siglas_unidades_medida = {}));
|
||||
exports.unidades_medida = [
|
||||
{
|
||||
sigla_unidade: "KG",
|
||||
nome: "Quilograma",
|
||||
sigla_normalizada: "KG",
|
||||
normalizar: (valor) => valor,
|
||||
tipo: "massa",
|
||||
},
|
||||
{
|
||||
sigla_unidade: "g",
|
||||
nome: "Grama",
|
||||
sigla_normalizada: "KG",
|
||||
normalizar: (valor) => valor / 1000,
|
||||
tipo: "massa",
|
||||
},
|
||||
{
|
||||
sigla_unidade: "TON",
|
||||
nome: "Tonelada",
|
||||
sigla_normalizada: "KG",
|
||||
normalizar: (valor) => valor * 1000,
|
||||
tipo: "massa",
|
||||
},
|
||||
{
|
||||
sigla_unidade: "Lt",
|
||||
nome: "Litro",
|
||||
sigla_normalizada: "Lt",
|
||||
normalizar: (valor) => valor,
|
||||
tipo: "volume",
|
||||
},
|
||||
{
|
||||
sigla_unidade: "M³",
|
||||
nome: "Metro Cúbico",
|
||||
sigla_normalizada: "Lt",
|
||||
normalizar: (valor) => valor * 1000,
|
||||
tipo: "volume",
|
||||
},
|
||||
{
|
||||
sigla_unidade: "UN",
|
||||
nome: "Unidade",
|
||||
sigla_normalizada: "UN",
|
||||
normalizar: (valor) => valor,
|
||||
tipo: "unidade",
|
||||
},
|
||||
];
|
||||
//# sourceMappingURL=unidades_medida.js.map
|
||||
1
dist/unidades_medida.js.map
vendored
Normal file
1
dist/unidades_medida.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"unidades_medida.js","sourceRoot":"","sources":["../src/unidades_medida.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,IAAY,sBASX;AATD,WAAY,sBAAsB;IAChC,mCAAS,CAAA;IAET,mCAAS,CAAA;IACT,qCAAW,CAAA;IACX,iCAAO,CAAA;IAEP,6CAAW,CAAA;IACX,mCAAS,CAAA;AACX,CAAC,EATW,sBAAsB,sCAAtB,sBAAsB,QASjC;AAEY,QAAA,eAAe,GAMtB;IACJ;QACE,aAAa,EAAE,IAAI;QACnB,IAAI,EAAE,YAAY;QAClB,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK;QACpC,IAAI,EAAE,OAAO;KACd;IACD;QACE,aAAa,EAAE,GAAG;QAClB,IAAI,EAAE,OAAO;QACb,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI;QAC3C,IAAI,EAAE,OAAO;KACd;IACD;QACE,aAAa,EAAE,KAAK;QACpB,IAAI,EAAE,UAAU;QAChB,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI;QAC3C,IAAI,EAAE,OAAO;KACd;IACD;QACE,aAAa,EAAE,IAAI;QACnB,IAAI,EAAE,OAAO;QACb,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK;QACpC,IAAI,EAAE,QAAQ;KACf;IACD;QACE,aAAa,EAAE,IAAI;QACnB,IAAI,EAAE,cAAc;QACpB,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI;QAC3C,IAAI,EAAE,QAAQ;KACf;IACD;QACE,aAAa,EAAE,IAAI;QACnB,IAAI,EAAE,SAAS;QACf,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK;QACpC,IAAI,EAAE,SAAS;KAChB;CACF,CAAA"}
|
||||
1
dist/uuid.d.ts
vendored
Normal file
1
dist/uuid.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare const uuid: () => string;
|
||||
17
dist/uuid.js
vendored
Normal file
17
dist/uuid.js
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uuid = void 0;
|
||||
//Gerar uma uuid V4
|
||||
const letras = "0123456789abcdef".split("");
|
||||
const uuid = () => {
|
||||
letras.sort(() => Math.random() - 0.5);
|
||||
const modelo = "xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx".split("");
|
||||
const retorno = modelo
|
||||
.map((letra) => letra === "x"
|
||||
? letras[((1000 * Math.random()) | 0) % letras.length]
|
||||
: letra)
|
||||
.join("");
|
||||
return retorno;
|
||||
};
|
||||
exports.uuid = uuid;
|
||||
//# sourceMappingURL=uuid.js.map
|
||||
1
dist/uuid.js.map
vendored
Normal file
1
dist/uuid.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AACpC,MAAM,IAAI,GAAG,GAAG,EAAE;IACvB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,sCAAsC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC/D,MAAM,OAAO,GAAG,MAAM;SACnB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACb,KAAK,KAAK,GAAG;QACX,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QACtD,CAAC,CAAC,KAAK,CACV;SACA,IAAI,CAAC,EAAE,CAAC,CAAA;IAEX,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAZY,QAAA,IAAI,QAYhB"}
|
||||
11
dist/variaveisComuns.d.ts
vendored
Normal file
11
dist/variaveisComuns.d.ts
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
export declare const esperar: (ms: number) => Promise<true>;
|
||||
/**
|
||||
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
|
||||
* const nomex = {a: 1, b: 2}
|
||||
* nomeVariavel({nomex}) // retorna "nomex"
|
||||
* @param v
|
||||
* @returns
|
||||
*/
|
||||
export declare const nomeVariavel: (v: {
|
||||
[key: string]: any;
|
||||
}) => string;
|
||||
15
dist/variaveisComuns.js
vendored
Normal file
15
dist/variaveisComuns.js
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.nomeVariavel = exports.esperar = void 0;
|
||||
const esperar = (ms) => new Promise((resolve) => setTimeout(() => resolve(true), ms));
|
||||
exports.esperar = esperar;
|
||||
/**
|
||||
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
|
||||
* const nomex = {a: 1, b: 2}
|
||||
* nomeVariavel({nomex}) // retorna "nomex"
|
||||
* @param v
|
||||
* @returns
|
||||
*/
|
||||
const nomeVariavel = (v) => Object.keys(v).join("/");
|
||||
exports.nomeVariavel = nomeVariavel;
|
||||
//# sourceMappingURL=variaveisComuns.js.map
|
||||
1
dist/variaveisComuns.js.map
vendored
Normal file
1
dist/variaveisComuns.js.map
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"variaveisComuns.js","sourceRoot":"","sources":["../src/variaveisComuns.ts"],"names":[],"mappings":";;;AAAO,MAAM,OAAO,GAAG,CAAC,EAAU,EAAiB,EAAE,CACnD,IAAI,OAAO,CAAC,CAAC,OAA0B,EAAE,EAAE,CACzC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CACpC,CAAA;AAHU,QAAA,OAAO,WAGjB;AACH;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,CAAC,CAAyB,EAAE,EAAE,CACxD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AADb,QAAA,YAAY,gBACC"}
|
||||
47
package.json
47
package.json
|
|
@ -1,28 +1,12 @@
|
|||
{
|
||||
"name": "p-comuns",
|
||||
"version": "0.276.0",
|
||||
"version": "0.103.0",
|
||||
"description": "",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"type": "module",
|
||||
|
||||
|
||||
|
||||
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"biome": "pnpm exec biome check --write",
|
||||
"check": "pnpm run biome && npx tsc --noEmit",
|
||||
"build": "npm --no-git-tag-version version minor && pnpm run biome && tsup --config ./tsup/tsup.config.ts && pnpm run pacote",
|
||||
"teste": "npx vitest run src/testes/TipagemRotas.test.ts",
|
||||
"pacote": "npm pack && npm pack && mv $(npm pack --silent) pacote.tgz"
|
||||
"build": "rm -rf ./dist && pnpm run biome && npm --no-git-tag-version version minor && tsc",
|
||||
"biome": "npx @biomejs/biome check --write ./src",
|
||||
"at": "pnpm up @biomejs/biome typescript"
|
||||
},
|
||||
"author": {
|
||||
"name": "AZTECA SOFTWARE LTDA",
|
||||
|
|
@ -31,23 +15,12 @@
|
|||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cross-fetch": "4.1.0",
|
||||
"dayjs": "^1.11.18",
|
||||
"uuid": "^11.1.0",
|
||||
"zod": "4.1.4"
|
||||
"cross-fetch": "^4.1.0",
|
||||
"zod": "3.24.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "2.1.4",
|
||||
"@types/node": "^20.19.22",
|
||||
"tsup": "8.5.0",
|
||||
"typescript": "~5.9.3",
|
||||
"unbuild": "^3.6.1",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"cross-fetch": "4.1.0",
|
||||
"dayjs": "^1.11.18",
|
||||
"uuid": "^11.1.0",
|
||||
"zod": "4.1.4"
|
||||
"@biomejs/biome": "^1.9.4",
|
||||
"@types/node": "^20.16.10",
|
||||
"typescript": "^5.7.2"
|
||||
}
|
||||
}
|
||||
BIN
pacote.tgz
BIN
pacote.tgz
Binary file not shown.
2703
pnpm-lock.yaml
generated
2703
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,53 +0,0 @@
|
|||
/** gerar uma função de cache para uso em memoria */
|
||||
|
||||
const _cache: {
|
||||
[k: string]:
|
||||
| {
|
||||
/** new Date().getTime() */
|
||||
validade?: number | undefined
|
||||
valor: any
|
||||
}
|
||||
| undefined
|
||||
} = {}
|
||||
|
||||
;(globalThis as any).cacheMemoria_cache = _cache
|
||||
|
||||
export const cacheM = <T>(
|
||||
chave: any,
|
||||
valor?: T,
|
||||
validadeSeg?: number,
|
||||
): T | undefined => {
|
||||
// converte a chave e string
|
||||
const txChave: string =
|
||||
typeof chave == "string"
|
||||
? chave
|
||||
: typeof chave == "number"
|
||||
? String(chave)
|
||||
: encodeURIComponent(JSON.stringify(chave))
|
||||
|
||||
const validade = validadeSeg && new Date().getTime() + validadeSeg * 1000
|
||||
|
||||
if (valor !== undefined) {
|
||||
_cache[txChave] = {
|
||||
valor,
|
||||
validade,
|
||||
}
|
||||
}
|
||||
|
||||
const busca = _cache[txChave]
|
||||
|
||||
if (busca?.validade && busca.validade < new Date().getTime()) {
|
||||
return undefined
|
||||
}
|
||||
return busca?.valor
|
||||
}
|
||||
|
||||
export const verCacheM = () => _cache
|
||||
|
||||
export const cacheMemoria = cacheM
|
||||
|
||||
/** para uso fixo dentro de uma função, trava a chave */
|
||||
export const cacheMFixo =
|
||||
(chave: any) =>
|
||||
<T>(valor?: T) =>
|
||||
cacheM(chave, valor)
|
||||
|
|
@ -8,7 +8,7 @@ export enum camposComuns {
|
|||
data_hora_atualizacao = "data_hora_atualizacao",
|
||||
codigo_usuario_criacao = "codigo_usuario_criacao",
|
||||
codigo_usuario_atualizacao = "codigo_usuario_atualizacao",
|
||||
versao = "versao",
|
||||
versao = "__versao",
|
||||
}
|
||||
|
||||
/** Palavras comumente usadas */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import z from "zod"
|
||||
|
||||
export enum operadores {
|
||||
"=" = "=",
|
||||
"!=" = "!=",
|
||||
|
|
@ -28,21 +26,3 @@ export type interfaceConsulta = {
|
|||
apenasConsulta?: boolean
|
||||
apenasContagem?: boolean
|
||||
}
|
||||
|
||||
export const zOperadores = z.enum([
|
||||
"=",
|
||||
"!=",
|
||||
">",
|
||||
">=",
|
||||
"<",
|
||||
"<=",
|
||||
"like",
|
||||
"in",
|
||||
])
|
||||
|
||||
export const zFiltro = z.object({
|
||||
coluna: z.string(),
|
||||
valor: z.any(),
|
||||
operador: zOperadores,
|
||||
ou: z.boolean().optional(),
|
||||
})
|
||||
|
|
|
|||
25
src/dayjs.ts
25
src/dayjs.ts
|
|
@ -1,25 +0,0 @@
|
|||
import dayjs from "dayjs"
|
||||
|
||||
export type { ManipulateType } from "dayjs"
|
||||
|
||||
import duration from "dayjs/plugin/duration.js"
|
||||
import isSameOrAfter from "dayjs/plugin/isSameOrAfter.js"
|
||||
import isSameOrBefore from "dayjs/plugin/isSameOrBefore.js"
|
||||
import minMax from "dayjs/plugin/minMax.js"
|
||||
import relativeTime from "dayjs/plugin/relativeTime.js"
|
||||
import timezone from "dayjs/plugin/timezone.js"
|
||||
import utc from "dayjs/plugin/utc.js"
|
||||
import weekOfYear from "dayjs/plugin/weekOfYear.js"
|
||||
import "dayjs/locale/pt-br.js"
|
||||
dayjs.locale("pt-br")
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(weekOfYear)
|
||||
dayjs.extend(isSameOrBefore)
|
||||
dayjs.extend(isSameOrAfter)
|
||||
dayjs.extend(minMax)
|
||||
dayjs.extend(relativeTime)
|
||||
dayjs.extend(duration)
|
||||
|
||||
export const dayjsbr = dayjs
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
export const graficos_pilao: {
|
||||
[k: string]: { grafico: string; titulo: string }
|
||||
} = {
|
||||
Condicionantes: {
|
||||
grafico: "condicionantes-criadas",
|
||||
titulo: "Condicionantes Criadas",
|
||||
},
|
||||
Licenças: {
|
||||
grafico: "licencas-criadas",
|
||||
titulo: "Licenças Criadas",
|
||||
},
|
||||
}
|
||||
13
src/index.ts
13
src/index.ts
|
|
@ -1,19 +1,10 @@
|
|||
export * from "./aleatorio"
|
||||
export * from "./cacheMemoria"
|
||||
export * from "./constantes"
|
||||
export * from "./consulta"
|
||||
export * from "./dayjs"
|
||||
export * from "./ecosistema"
|
||||
export * from "./extensoes"
|
||||
export * from "./graficosPilao"
|
||||
export * from "./local"
|
||||
export * from "./logger"
|
||||
export * from "./postgres"
|
||||
export * from "./testes-de-variaveis"
|
||||
export * from "./aleatorio"
|
||||
export * from "./texto_busca"
|
||||
export * from "./tipagemRotas"
|
||||
export * from "./unidades_medida"
|
||||
export * from "./uuid"
|
||||
export * from "./ecosistema"
|
||||
export * from "./variaveisComuns"
|
||||
export * from "./tipagemRotas"
|
||||
export * from "./extensoes"
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
import fs from "node:fs"
|
||||
import path from "node:path"
|
||||
|
||||
/**
|
||||
* Mescla objetos recursivamente.
|
||||
* - Adiciona chaves novas
|
||||
* - Sobrescreve valores primitivos
|
||||
* - Mescla objetos aninhados
|
||||
*/
|
||||
const mesclar = (entrada: any, novo: any): any => {
|
||||
const saida = { ...(entrada || {}) }
|
||||
for (const [k, v] of Object.entries(novo)) {
|
||||
if (v && typeof v === "object" && !Array.isArray(v)) {
|
||||
saida[k] = mesclar(saida[k], v)
|
||||
} else {
|
||||
saida[k] = v
|
||||
}
|
||||
}
|
||||
return saida
|
||||
}
|
||||
|
||||
/** Lê JSON ou retorna objeto vazio */
|
||||
const abrirJson = (caminho: string) => {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(caminho, "utf-8"))
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
const settings_json = {
|
||||
"editor.defaultFormatter": "biomejs.biome",
|
||||
"[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[javascriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[json]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[jsonc]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||
"[vue]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports.biome": "always",
|
||||
"source.fixAll.biome": "always",
|
||||
},
|
||||
}
|
||||
|
||||
const caminhoSeting = path.join(process.cwd(), ".vscode/settings.json")
|
||||
|
||||
// Garante a pasta .vscode
|
||||
fs.mkdirSync(path.dirname(caminhoSeting), { recursive: true })
|
||||
|
||||
// Mescla e grava
|
||||
const atual = abrirJson(caminhoSeting)
|
||||
const final = mesclar(atual, settings_json)
|
||||
|
||||
fs.writeFileSync(caminhoSeting, JSON.stringify(final, null, 2), "utf8")
|
||||
|
||||
console.log(`✅ Configurações salvas em ${caminhoSeting}`)
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/**
|
||||
* LocalStorage Tipado
|
||||
* Lê ou grava um valor no localStorage, mantendo o tipo genérico <T>.
|
||||
*/
|
||||
export const localValor = <T>(
|
||||
chave_: string | any,
|
||||
valor?: T | null,
|
||||
): T | null => {
|
||||
const localStorage = globalThis.localStorage
|
||||
|
||||
if (typeof localStorage == "undefined") return null
|
||||
|
||||
const chave =
|
||||
typeof chave_ === "string"
|
||||
? chave_
|
||||
: encodeURIComponent(JSON.stringify(chave_))
|
||||
|
||||
try {
|
||||
// Grava valor se fornecido
|
||||
if (valor !== undefined) {
|
||||
localStorage.setItem(chave, JSON.stringify(valor))
|
||||
}
|
||||
|
||||
// Lê valor
|
||||
const v2 = localStorage.getItem(chave)
|
||||
if (v2 === null) return null
|
||||
|
||||
try {
|
||||
return JSON.parse(v2) as T
|
||||
} catch {
|
||||
// Caso o valor não seja JSON válido
|
||||
return v2 as unknown as T
|
||||
}
|
||||
} catch {
|
||||
// Em caso de erro de acesso ao localStorage
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
@ -14,9 +14,9 @@ export type tipoLokiObjeto = {
|
|||
|
||||
export const postLogger = async ({
|
||||
objeto,
|
||||
}: {
|
||||
objeto: tipoLokiObjeto
|
||||
}): Promise<[objeto: tipoLokiObjeto, erro?: string]> => {
|
||||
}: { objeto: tipoLokiObjeto }): Promise<
|
||||
[objeto: tipoLokiObjeto, erro?: string]
|
||||
> => {
|
||||
const response = await crossFetch(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
|
@ -24,8 +24,9 @@ export const postLogger = async ({
|
|||
}).catch((a) => a)
|
||||
if (!response.ok) {
|
||||
return [objeto, `Erro ${response.status}: ${await response?.text?.()}`]
|
||||
}
|
||||
} else {
|
||||
return [objeto]
|
||||
}
|
||||
}
|
||||
|
||||
let cwd = ""
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* Trata um objeto para ser imput para postgres
|
||||
* @param entrada
|
||||
* @returns
|
||||
*/
|
||||
export const paraObjetoRegistroPg = (entrada: {
|
||||
[k: string]: any
|
||||
}): {
|
||||
[k: string]: string | boolean | null | undefined | number
|
||||
} => {
|
||||
try {
|
||||
return Object.fromEntries(
|
||||
Object.entries(entrada).map(([k, v]) => [
|
||||
k,
|
||||
v === undefined || v == null
|
||||
? v
|
||||
: typeof v == "string" ||
|
||||
typeof v == "number" ||
|
||||
typeof v == "boolean"
|
||||
? v
|
||||
: JSON.stringify(v, null, 2),
|
||||
]),
|
||||
)
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Erro na função paraObjetoRegistroPg: ${(error as Error).message} ${(error as Error).stack}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const pgObjeto = paraObjetoRegistroPg
|
||||
export const objetoPg = paraObjetoRegistroPg
|
||||
17
src/teste.ts
17
src/teste.ts
|
|
@ -1,8 +1,13 @@
|
|||
import { cacheM } from "./cacheMemoria"
|
||||
import { texto_busca } from "./texto_busca"
|
||||
import { logger } from "./logger"
|
||||
|
||||
// node dist-back/teste.mjs
|
||||
console.log("Variáveis funcionando", texto_busca)
|
||||
const l = logger({ app: "teste", eProducao: true })
|
||||
|
||||
cacheM(1, { Jaca: Promise.resolve() })
|
||||
console.log("cache:", cacheM(1))
|
||||
const lg = l({
|
||||
inquilino: "conta_1",
|
||||
usuario: "pedrinho",
|
||||
})
|
||||
|
||||
lg("error", "Deu Ruim").then((a) => console.log(JSON.stringify(a)))
|
||||
lg("info", "Deu Bom", { __filename }).then((a) =>
|
||||
console.log(JSON.stringify(a)),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
export * from "./umaFuncao"
|
||||
export * from "./umaVariavel"
|
||||
|
|
@ -1 +0,0 @@
|
|||
export const umaFuncao = () => "Olá Mundo! (função)"
|
||||
|
|
@ -1 +0,0 @@
|
|||
export const umaVariavel = "Olá Mundo! (variável)"
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
import { describe, expect, it } from "vitest"
|
||||
import { TipagemRotas } from "../tipagemRotas"
|
||||
|
||||
describe("TipagemRotas", () => {
|
||||
it("deve montar _partesCaminho a partir de string ou array, normalizando barras", () => {
|
||||
const r1 = new TipagemRotas<{ q: string }>({ caminho: "aplicacao/func" })
|
||||
expect(r1.caminho).toBe("/aplicacao/func")
|
||||
|
||||
const r2 = new TipagemRotas<{ q: string }>({
|
||||
caminho: ["aplicacao", "func"],
|
||||
})
|
||||
expect(r2.caminho).toBe("/aplicacao/func")
|
||||
|
||||
const r3 = new TipagemRotas<{ q: string }>({ caminho: "/a//b///c/" })
|
||||
expect(r3.caminho).toBe("/a/b/c")
|
||||
})
|
||||
|
||||
it("Valores de entrada com mesmo valor dos valores de saída", () => {
|
||||
type tipagem = { nome: string; idade: number }
|
||||
const r1 = new TipagemRotas<tipagem>({ caminho: "aplicacao/func" })
|
||||
const objetoEntrada: tipagem = { idade: 21, nome: "João" }
|
||||
|
||||
const rota = r1.endereco(objetoEntrada)
|
||||
|
||||
const parametros = r1.parametros(rota)
|
||||
|
||||
expect(parametros.nome).toBe(objetoEntrada.nome)
|
||||
})
|
||||
})
|
||||
|
|
@ -7,6 +7,7 @@ export const texto_busca = (...texto: any[]): string =>
|
|||
? ""
|
||||
: String(txt)
|
||||
.normalize("NFD")
|
||||
// biome-ignore lint/suspicious/noMisleadingCharacterClass: <explanation>
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
.replace(/\s+/g, " ")
|
||||
.toLowerCase(),
|
||||
|
|
|
|||
|
|
@ -9,35 +9,22 @@
|
|||
* parametros = {nome:"José"}
|
||||
*/
|
||||
|
||||
export class TipagemRotas<T extends { [q: string]: any }> {
|
||||
export class TipagemRotas<T extends { [q: string]: string | undefined }> {
|
||||
_partesCaminho: string[] = []
|
||||
_acaoIr?: (endereco: string) => undefined
|
||||
rotulo: string | undefined
|
||||
|
||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
||||
*/
|
||||
constructor({
|
||||
caminho,
|
||||
acaoIr,
|
||||
rotulo,
|
||||
}: {
|
||||
caminho: (string | null | undefined)[] | string
|
||||
acaoIr?: undefined | ((endereco: string) => undefined)
|
||||
|
||||
/** Rotulo da página
|
||||
* Inicio | Controle
|
||||
*/
|
||||
rotulo?: string
|
||||
}) {
|
||||
this._acaoIr = acaoIr
|
||||
|
||||
this._partesCaminho = (Array.isArray(caminho) ? caminho : [caminho])
|
||||
.filter(Boolean)
|
||||
.map((a) => String(a))
|
||||
.flatMap((a) => a.split("/"))
|
||||
.filter(Boolean)
|
||||
this.rotulo = rotulo
|
||||
constructor(...caminhos: string[]) {
|
||||
caminhos.forEach((caminho) => {
|
||||
String(caminho)
|
||||
.split("/")
|
||||
.forEach((parte) => {
|
||||
if (parte) {
|
||||
this._partesCaminho.push(parte)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/** Retorna o caminho completo da rota
|
||||
|
|
@ -45,7 +32,11 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
|||
** "/caminho"
|
||||
*/
|
||||
get caminho() {
|
||||
const ret = `/${this._partesCaminho.join("/")}`
|
||||
let ret = `/${this._partesCaminho.join("/")}`
|
||||
ret = ret.replace(/\/+/g, "/")
|
||||
if (ret.length > 1 && ret.endsWith("/")) {
|
||||
ret = ret.slice(0, -1)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
/** Define o caminho completo da rota
|
||||
|
|
@ -74,7 +65,10 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
|||
const queryKeys = Object.entries(query)
|
||||
|
||||
for (const [key, value] of queryKeys) {
|
||||
url.searchParams.set(String(key), JSON.stringify(value))
|
||||
url.searchParams.set(
|
||||
String(key),
|
||||
value === undefined || value === null ? "" : value,
|
||||
)
|
||||
}
|
||||
|
||||
url.hash = ""
|
||||
|
|
@ -92,12 +86,8 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
|||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
||||
*/
|
||||
ir(query: T) {
|
||||
if (this._acaoIr) {
|
||||
this._acaoIr(this.endereco({ ...query }))
|
||||
} else {
|
||||
if (typeof window != "undefined") {
|
||||
window.location.href = this.endereco({ ...query })
|
||||
}
|
||||
window.location.href = this.endereco(query)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,16 +96,12 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
|||
** {q:"query"}
|
||||
*/
|
||||
|
||||
parametros(urlEntrada?: string) {
|
||||
const url = urlEntrada
|
||||
? new URL(urlEntrada)
|
||||
: new URL(
|
||||
typeof window !== "undefined"
|
||||
? window.location.href
|
||||
: "http://localhost",
|
||||
get parametros() {
|
||||
const url = new URL(
|
||||
typeof window !== "undefined" ? window.location.href : "http://localhost",
|
||||
)
|
||||
const query = url.searchParams
|
||||
let queryObj = Object.fromEntries(query.entries())
|
||||
const queryObj = Object.fromEntries(query.entries())
|
||||
|
||||
// pegar hash
|
||||
const hash = url.hash
|
||||
|
|
@ -123,15 +109,7 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
|||
const hashObj = Object.fromEntries(
|
||||
new URLSearchParams(hash.slice(1)).entries(),
|
||||
)
|
||||
queryObj = { ...queryObj, ...hashObj } as T
|
||||
}
|
||||
|
||||
for (const chave in queryObj) {
|
||||
try {
|
||||
queryObj[chave] = JSON.parse(queryObj[chave])
|
||||
} catch {
|
||||
console.log(`[${chave}|${queryObj[chave]}] não é um json válido.`)
|
||||
}
|
||||
return { ...queryObj, ...hashObj } as T
|
||||
}
|
||||
|
||||
return queryObj as Partial<T>
|
||||
|
|
|
|||
62
src/uuid.ts
62
src/uuid.ts
|
|
@ -1,53 +1,15 @@
|
|||
import { NIL, v3, v4 } from "uuid"
|
||||
//Gerar uma uuid V4
|
||||
const letras = "0123456789abcdef".split("")
|
||||
export const uuid = () => {
|
||||
letras.sort(() => Math.random() - 0.5)
|
||||
const modelo = "xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx".split("")
|
||||
const retorno = modelo
|
||||
.map((letra) =>
|
||||
letra === "x"
|
||||
? letras[((1000 * Math.random()) | 0) % letras.length]
|
||||
: letra,
|
||||
)
|
||||
.join("")
|
||||
|
||||
/**
|
||||
* Valida se uma string é um UUID válido (qualquer versão).
|
||||
*
|
||||
* @param valor - A string que será validada.
|
||||
* @returns booleano indicando se é um UUID válido.
|
||||
*/
|
||||
export const erUuid =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||
|
||||
export const validarUuid = (uuid: string | number | undefined | null) => {
|
||||
const retorno = erUuid.test(String(uuid || ""))
|
||||
return retorno
|
||||
}
|
||||
|
||||
/**
|
||||
* Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace).
|
||||
*
|
||||
* - Usa o algoritmo MD5 (RFC 4122).
|
||||
* - Sempre retorna o mesmo UUID para a mesma combinação chave + grupo.
|
||||
* - Caso o grupo não seja informado, usa o UUID "nil" como namespace.
|
||||
*
|
||||
* @param chave - Qualquer valor que será convertido em string para gerar o UUID (ex: número, string ou objeto).
|
||||
* @param grupo - Opcional. Namespace para separar domínios diferentes de UUIDs.
|
||||
* @returns UUID v3 (determinístico)
|
||||
*/
|
||||
export const uuidV3 = (chave: any, grupo?: any): string => {
|
||||
return v3(
|
||||
// Converte a chave para string (de forma segura)
|
||||
typeof chave === "string"
|
||||
? chave
|
||||
: typeof chave === "number"
|
||||
? String(chave)
|
||||
: JSON.stringify(chave),
|
||||
|
||||
// Se um grupo foi fornecido, gera um UUID v3 recursivamente com base nele, senão usa NIL
|
||||
grupo ? uuidV3(grupo) : NIL,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gera um UUID v4 (aleatório, não determinístico).
|
||||
*
|
||||
* - Usado quando unicidade é necessária, mas não se exige que seja previsível.
|
||||
*/
|
||||
export const uuidV4 = v4
|
||||
|
||||
/**
|
||||
* @deprecated Esta variável será descontinuada em versões futuras.
|
||||
* Use a função `uuidV4()` diretamente.
|
||||
*/
|
||||
export const uuid = uuidV4
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist-require",
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist-import",
|
||||
"module": "ES6"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +1,21 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
|
||||
/* Linguagem e Ambiente */
|
||||
"target": "ES2020" /* Define a versão do JavaScript para o código emitido. */,
|
||||
"lib": [
|
||||
"dom.iterable"
|
||||
] /* Especifica as bibliotecas padrão a serem incluídas, como DOM para iteradores. */,
|
||||
"experimentalDecorators": true /* Habilita o suporte experimental a decoradores. */,
|
||||
"emitDecoratorMetadata": true /* Emite metadados de tipos de design para declarações decoradas. */,
|
||||
|
||||
/* Módulos */
|
||||
"moduleResolution": "node" /* Define como o TypeScript resolve módulos. */,
|
||||
"rootDir": "./src" /* Define a pasta raiz para os arquivos de origem. */,
|
||||
|
||||
/* Emissão */
|
||||
"declaration": true /* Gera arquivos .d.ts para os arquivos TypeScript. */,
|
||||
|
||||
/* Interoperabilidade de Módulos */
|
||||
"forceConsistentCasingInFileNames": true /* Garante consistência na diferenciação entre maiúsculas e minúsculas em nomes de arquivos. */,
|
||||
|
||||
/* Verificação de Tipos */
|
||||
"strict": true /* Habilita todas as opções de verificação estrita de tipos. */,
|
||||
"skipLibCheck": true /* Ignora a verificação de tipos em arquivos de declaração de bibliotecas. */
|
||||
"noImplicitAny": true,
|
||||
"target": "ES2020",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"declarationDir": "dist",
|
||||
"sourceMap": true,
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
] /* Inclui todos os arquivos TypeScript dentro da pasta src. */
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
"tsup --config tsup.config.ts"
|
||||
|
||||
tsup --config ./node_modules/p-comuns/tsup/tsup.config.ts
|
||||
|
||||
"main": "./dist-back/index.js",
|
||||
"module": "./dist-front/index.mjs",
|
||||
"types": "./dist-front/index.d.mts",,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist-front/index.d.mts",,
|
||||
"import": "./dist-front/index.mjs",
|
||||
"require": "./dist-back/index.js"
|
||||
}
|
||||
},
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
// tsup.config.ts (Configuração Ajustada para Back-end)
|
||||
import { defineConfig, type Options } from "tsup"
|
||||
|
||||
// Definimos as opções em uma constante para clareza, como você fez.
|
||||
// Exportamos para que possam ser reutilizadas ou inspecionadas.
|
||||
export const tsup_config_back: Options = {
|
||||
/** Não mecher aqui */
|
||||
entry: ["src/**/*.ts", "src/**/*.tsx"], // Adicionado .tsx para compatibilidade, se aplicável
|
||||
format: "cjs", // Gera módulos CommonJS, padrão para Node.js
|
||||
target: "node20", // Compila para o ambiente Node.js versão 20 (ou sua versão alvo)
|
||||
outDir: "dist-back", // Diretório de saída para os arquivos transpilados
|
||||
clean: true, // Limpa o diretório de saída antes de cada build
|
||||
bundle: false, // ESSENCIAL: Mantém a estrutura de arquivos e pastas original
|
||||
splitting: false, // Desnecessário quando bundle é false
|
||||
dts: false, // RECOMENDADO: Gera arquivos de declaração TypeScript (.d.ts)
|
||||
// legacyOutput e outExtension foram removidos por não serem necessários
|
||||
sourcemap: false,
|
||||
minify: false, // Geralmente não minificamos o código do backend em produção, mas você pode mudar
|
||||
platform: "node",
|
||||
outExtension: () => ({ js: ".js" }),
|
||||
}
|
||||
|
||||
// Exporta a configuração padrão usando defineConfig
|
||||
export default defineConfig(tsup_config_back)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
// tsup.config.ts (Configuração Ajustada para Back-end)
|
||||
import { defineConfig, type Options } from "tsup"
|
||||
import { tsup_config_front } from "./tsup.config.front"
|
||||
|
||||
tsup_config_front. noExternal= [/./]
|
||||
|
||||
export {tsup_config_front}
|
||||
|
||||
// Exporta a configuração padrão usando defineConfig
|
||||
export default defineConfig(tsup_config_front)
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
// tsup.config.ts (Configuração Ajustada para Back-end)
|
||||
import { defineConfig, type Options } from "tsup"
|
||||
|
||||
// Definimos as opções em uma constante para clareza, como você fez.
|
||||
// Exportamos para que possam ser reutilizadas ou inspecionadas.
|
||||
export const tsup_config_front: Options = {
|
||||
entry: ["src/index.ts"], // Adicionado .tsx para compatibilidade, se aplicável
|
||||
format: "esm", // Gera módulos ES para import/export no navegador
|
||||
target: "es2022", // Ou 'esnext' para os recursos mais recentes
|
||||
outDir: "dist-front", // Diretório de saída para os arquivos transpilados
|
||||
clean: true, // Limpa o diretório de saída antes de cada build
|
||||
bundle: true, // ESSENCIAL: Mantém a estrutura de arquivos e pastas original
|
||||
splitting: false, // Desnecessário quando bundle é false
|
||||
dts: true, // Gera arquivos de declaração TypeScript (.d.ts) para uso em front-end JS
|
||||
// legacyOutput e outExtension foram removidos por não serem necessários
|
||||
sourcemap: false,
|
||||
minify: true, // Recomendado para builds de produção
|
||||
platform: "browser",
|
||||
external: ['dayjs'],
|
||||
outExtension: () => ({ js: ".mjs" }),
|
||||
shims: false,
|
||||
}
|
||||
|
||||
// Exporta a configuração padrão usando defineConfig
|
||||
export default defineConfig(tsup_config_front)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
// tsup.config.ts (Configuração Ajustada para Back-end)
|
||||
import { defineConfig } from "tsup"
|
||||
import { tsup_config_back } from "./tsup.config.back"
|
||||
import { tsup_config_front } from "./tsup.config.front.interno"
|
||||
|
||||
// Exporta a configuração padrão usando defineConfig
|
||||
export default defineConfig([tsup_config_back, tsup_config_front])
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
// tsup.config.ts (Configuração Ajustada para Back-end)
|
||||
import { defineConfig } from "tsup"
|
||||
import { tsup_config_back } from "./tsup.config.back"
|
||||
import { tsup_config_front } from "./tsup.config.front"
|
||||
|
||||
// Exporta a configuração padrão usando defineConfig
|
||||
export default defineConfig([tsup_config_back, tsup_config_front])
|
||||
Loading…
Add table
Add a link
Reference in a new issue