build
This commit is contained in:
parent
aa7953e452
commit
f8dabeb40c
75 changed files with 712 additions and 57 deletions
1
dist-require/aleatorio.d.ts
vendored
Normal file
1
dist-require/aleatorio.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare const aleatorio: (tamanho?: number) => string;
|
||||
8
dist-require/aleatorio.js
Normal file
8
dist-require/aleatorio.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
"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;
|
||||
19
dist-require/constantes.d.ts
vendored
Normal file
19
dist-require/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"
|
||||
}
|
||||
25
dist-require/constantes.js
Normal file
25
dist-require/constantes.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"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 = {}));
|
||||
26
dist-require/consulta.d.ts
vendored
Normal file
26
dist-require/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;
|
||||
};
|
||||
14
dist-require/consulta.js
Normal file
14
dist-require/consulta.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
"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 = {}));
|
||||
1
dist-require/ecosistema/index.d.ts
vendored
Normal file
1
dist-require/ecosistema/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from "./urls";
|
||||
17
dist-require/ecosistema/index.js
Normal file
17
dist-require/ecosistema/index.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./urls"), exports);
|
||||
1
dist-require/ecosistema/urls.d.ts
vendored
Normal file
1
dist-require/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";
|
||||
4
dist-require/ecosistema/urls.js
Normal file
4
dist-require/ecosistema/urls.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
"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";
|
||||
13
dist-require/extensoes.d.ts
vendored
Normal file
13
dist-require/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 {};
|
||||
172
dist-require/extensoes.js
Normal file
172
dist-require/extensoes.js
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
"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;
|
||||
11
dist-require/index.d.ts
vendored
Normal file
11
dist-require/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
export * from "./aleatorio";
|
||||
export * from "./constantes";
|
||||
export * from "./consulta";
|
||||
export * from "./ecosistema";
|
||||
export * from "./extensoes";
|
||||
export * from "./logger";
|
||||
export * from "./texto_busca";
|
||||
export * from "./tipagemRotas";
|
||||
export * from "./unidades_medida";
|
||||
export * from "./uuid";
|
||||
export * from "./variaveisComuns";
|
||||
27
dist-require/index.js
Normal file
27
dist-require/index.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"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("./aleatorio"), exports);
|
||||
__exportStar(require("./constantes"), exports);
|
||||
__exportStar(require("./consulta"), exports);
|
||||
__exportStar(require("./ecosistema"), exports);
|
||||
__exportStar(require("./extensoes"), exports);
|
||||
__exportStar(require("./logger"), exports);
|
||||
__exportStar(require("./texto_busca"), exports);
|
||||
__exportStar(require("./tipagemRotas"), exports);
|
||||
__exportStar(require("./unidades_medida"), exports);
|
||||
__exportStar(require("./uuid"), exports);
|
||||
__exportStar(require("./variaveisComuns"), exports);
|
||||
40
dist-require/logger.d.ts
vendored
Normal file
40
dist-require/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 {};
|
||||
69
dist-require/logger.js
Normal file
69
dist-require/logger.js
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
"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?.()}`];
|
||||
}
|
||||
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;
|
||||
1
dist-require/teste.d.ts
vendored
Normal file
1
dist-require/teste.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export {};
|
||||
10
dist-require/teste.js
Normal file
10
dist-require/teste.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
"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)));
|
||||
2
dist-require/texto_busca.d.ts
vendored
Normal file
2
dist-require/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;
|
||||
14
dist-require/texto_busca.js
Normal file
14
dist-require/texto_busca.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
"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")
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
.replace(/\s+/g, " ")
|
||||
.toLowerCase())
|
||||
.join(" ");
|
||||
exports.texto_busca = texto_busca;
|
||||
49
dist-require/tipagemRotas.d.ts
vendored
Normal file
49
dist-require/tipagemRotas.d.ts
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/** 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[];
|
||||
_acaoIr?: (endereco: 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, }: {
|
||||
caminho: string[] | string;
|
||||
acaoIr?: undefined | ((endereco: string) => undefined);
|
||||
});
|
||||
/** 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>;
|
||||
}
|
||||
91
dist-require/tipagemRotas.js
Normal file
91
dist-require/tipagemRotas.js
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
"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({ caminho, acaoIr, }) {
|
||||
this._partesCaminho = [];
|
||||
this._acaoIr = acaoIr;
|
||||
this._partesCaminho = (Array.isArray(caminho) ? caminho : [caminho])
|
||||
.flatMap((a) => a.split("/"))
|
||||
.filter(Boolean);
|
||||
}
|
||||
/** 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), 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 (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"}
|
||||
*/
|
||||
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;
|
||||
23
dist-require/unidades_medida.d.ts
vendored
Normal file
23
dist-require/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";
|
||||
}[];
|
||||
64
dist-require/unidades_medida.js
Normal file
64
dist-require/unidades_medida.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
"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",
|
||||
},
|
||||
];
|
||||
1
dist-require/uuid.d.ts
vendored
Normal file
1
dist-require/uuid.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare const uuid: () => string;
|
||||
16
dist-require/uuid.js
Normal file
16
dist-require/uuid.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"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;
|
||||
11
dist-require/variaveisComuns.d.ts
vendored
Normal file
11
dist-require/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;
|
||||
14
dist-require/variaveisComuns.js
Normal file
14
dist-require/variaveisComuns.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
"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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue