Compare commits

...
Sign in to create a new pull request.

4 commits
bun ... master

10 changed files with 345 additions and 206 deletions

View file

@ -44,9 +44,21 @@ var operadores = /* @__PURE__ */ ((operadores2) => {
operadores2["like"] = "like"; operadores2["like"] = "like";
operadores2["in"] = "in"; operadores2["in"] = "in";
operadores2["isNull"] = "isNull"; operadores2["isNull"] = "isNull";
operadores2["notIn"] = "notIn";
return operadores2; return operadores2;
})(operadores || {}); })(operadores || {});
const zOperadores = import_zod.default.enum(["=", "!=", ">", ">=", "<", "<=", "like", "in", "isNull"]); const zOperadores = import_zod.default.enum([
"=",
"!=",
">",
">=",
"<",
"<=",
"like",
"in",
"isNull",
"notIn"
]);
const zFiltro = import_zod.default.object({ const zFiltro = import_zod.default.object({
coluna: import_zod.default.string(), coluna: import_zod.default.string(),
valor: import_zod.default.any(), valor: import_zod.default.any(),

View file

@ -25,22 +25,143 @@ __export(uuid_exports, {
validarUuid: () => validarUuid validarUuid: () => validarUuid
}); });
module.exports = __toCommonJS(uuid_exports); module.exports = __toCommonJS(uuid_exports);
var import_uuid = require("uuid");
const erUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; 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 validarUuid = (uuid2) => {
const retorno = erUuid.test(String(uuid2 || "")); return erUuid.test(String(uuid2 || ""));
return retorno; };
const uuidV4 = () => globalThis.crypto.randomUUID();
const uuid = uuidV4;
const NIL_UUID = "00000000-0000-0000-0000-000000000000";
const rotL = (x, n) => x << n | x >>> 32 - n;
const md5 = (str) => {
const msg = new TextEncoder().encode(str);
const len = msg.length;
const bits = len * 8;
const padLen = len % 64 < 56 ? 56 - len % 64 : 120 - len % 64;
const padded = new Uint8Array(len + padLen + 8);
padded.set(msg);
padded[len] = 128;
const dv = new DataView(padded.buffer);
dv.setUint32(len + padLen, bits >>> 0, true);
dv.setUint32(len + padLen + 4, Math.floor(bits / 2 ** 32), true);
const T = Array.from(
{ length: 64 },
(_, i) => Math.abs(Math.sin(i + 1)) * 2 ** 32 >>> 0
);
const S = [
7,
12,
17,
22,
7,
12,
17,
22,
7,
12,
17,
22,
7,
12,
17,
22,
5,
9,
14,
20,
5,
9,
14,
20,
5,
9,
14,
20,
5,
9,
14,
20,
4,
11,
16,
23,
4,
11,
16,
23,
4,
11,
16,
23,
4,
11,
16,
23,
6,
10,
15,
21,
6,
10,
15,
21,
6,
10,
15,
21,
6,
10,
15,
21
];
let a0 = 1732584193, b0 = 4023233417, c0 = 2562383102, d0 = 271733878;
for (let off = 0; off < padded.length; off += 64) {
const M = [];
for (let j = 0; j < 16; j++) M[j] = dv.getUint32(off + j * 4, true);
let [A, B, C, D] = [a0, b0, c0, d0];
for (let i = 0; i < 64; i++) {
let F, g;
if (i < 16) {
F = B & C | ~B & D;
g = i;
} else if (i < 32) {
F = D & B | ~D & C;
g = (5 * i + 1) % 16;
} else if (i < 48) {
F = B ^ C ^ D;
g = (3 * i + 5) % 16;
} else {
F = C ^ (B | ~D);
g = 7 * i % 16;
}
F = F + A + T[i] + M[g] >>> 0;
A = D;
D = C;
C = B;
B = B + rotL(F, S[i]) >>> 0;
}
a0 = a0 + A >>> 0;
b0 = b0 + B >>> 0;
c0 = c0 + C >>> 0;
d0 = d0 + D >>> 0;
}
const toHexLE = (n) => {
let s = "";
for (let i = 0; i < 4; i++) s += (n >>> i * 8 & 255).toString(16).padStart(2, "0");
return s;
};
return toHexLE(a0) + toHexLE(b0) + toHexLE(c0) + toHexLE(d0);
};
const formatarUuidV3 = (hash) => {
const c = hash.slice(0, 32);
const v = (Number.parseInt(c[16], 16) & 3 | 8).toString(16);
return `${c.slice(0, 8)}-${c.slice(8, 12)}-3${c.slice(13, 16)}-${v}${c.slice(17, 20)}-${c.slice(20, 32)}`;
}; };
const uuidV3 = (chave, grupo) => { const uuidV3 = (chave, grupo) => {
return (0, import_uuid.v3)( const namespace = grupo ? uuidV3(grupo) : NIL_UUID;
// Converte a chave para string (de forma segura) const input = typeof chave === "string" ? chave : typeof chave === "number" ? String(chave) : JSON.stringify(chave);
typeof chave === "string" ? chave : typeof chave === "number" ? String(chave) : JSON.stringify(chave), return formatarUuidV3(md5(namespace + input));
// Se um grupo foi fornecido, gera um UUID v3 recursivamente com base nele, senão usa NIL
grupo ? uuidV3(grupo) : import_uuid.NIL
);
}; };
const uuidV4 = import_uuid.v4;
const uuid = uuidV4;
// Annotate the CommonJS export names for ESM import in node: // Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = { 0 && (module.exports = {
erUuid, erUuid,

View file

@ -9,7 +9,6 @@ import _relativeTime from 'dayjs/plugin/relativeTime';
import _timezone from 'dayjs/plugin/timezone'; import _timezone from 'dayjs/plugin/timezone';
import _utc from 'dayjs/plugin/utc'; import _utc from 'dayjs/plugin/utc';
import _weekOfYear from 'dayjs/plugin/weekOfYear'; import _weekOfYear from 'dayjs/plugin/weekOfYear';
import { v4 } from 'uuid';
declare const aleatorio: (tamanho?: number) => string; declare const aleatorio: (tamanho?: number) => string;
@ -78,7 +77,8 @@ declare enum operadores {
"<=" = "<=", "<=" = "<=",
like = "like", like = "like",
in = "in", in = "in",
isNull = "isNull" isNull = "isNull",
notIn = "notIn"
} }
type tipoFiltro = { type tipoFiltro = {
coluna: string; coluna: string;
@ -106,6 +106,7 @@ declare const zOperadores: z.ZodEnum<{
like: "like"; like: "like";
in: "in"; in: "in";
isNull: "isNull"; isNull: "isNull";
notIn: "notIn";
}>; }>;
declare const zFiltro: z.ZodObject<{ declare const zFiltro: z.ZodObject<{
coluna: z.ZodString; coluna: z.ZodString;
@ -120,6 +121,7 @@ declare const zFiltro: z.ZodObject<{
like: "like"; like: "like";
in: "in"; in: "in";
isNull: "isNull"; isNull: "isNull";
notIn: "notIn";
}>; }>;
ou: z.ZodOptional<z.ZodBoolean>; ou: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strip>; }, z.core.$strip>;
@ -617,35 +619,26 @@ declare const unidades_medida: {
/** /**
* Valida se uma string é um UUID válido (qualquer versão). * 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 erUuid: RegExp;
declare const validarUuid: (uuid: string | number | undefined | null) => boolean; 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). * Gera um UUID v4 (aleatório, não determinístico).
* * Usa `globalThis.crypto.randomUUID()` — disponível em Node 19+, Bun e browsers modernos.
* - Usado quando unicidade é necessária, mas não se exige que seja previsível.
*/ */
declare const uuidV4: typeof v4; declare const uuidV4: () => string;
/** /**
* @deprecated Esta variável será descontinuada em versões futuras. * @deprecated Use uuidV4() diretamente.
* Use a função `uuidV4()` diretamente.
*/ */
declare const uuid: typeof v4; declare const uuid: () => string;
/**
* Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace).
* Implementação pura JS (MD5), sem dependência de Node.js — funciona em browser e server.
*
* @param chave - Valor a serializar (string, number ou objeto).
* @param grupo - Namespace opcional; se omitido, usa UUID nil.
*/
declare const uuidV3: (chave: unknown, grupo?: unknown) => string;
declare const esperar: (ms: number) => Promise<true>; declare const esperar: (ms: number) => Promise<true>;
/** /**
@ -688,8 +681,8 @@ declare const zDocumento: z.ZodUnion<[z.ZodString, z.ZodString]>;
* - `1.000,1` → milhar com ponto + vírgula decimal (BR) * - `1.000,1` → milhar com ponto + vírgula decimal (BR)
* - `R$ 10,01` → prefixo monetário legado * - `R$ 10,01` → prefixo monetário legado
*/ */
declare const zNumero: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>; declare const zNumero: z.ZodPreprocess<z.ZodNumber>;
declare const zNumeroPositivo: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>; declare const zNumeroPositivo: z.ZodPreprocess<z.ZodNumber>;
declare const zNumeroInteiro: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>; declare const zNumeroInteiro: z.ZodPreprocess<z.ZodNumber>;
export { type ArquivamentoLog, type ELogger, type EntradaLog, NivelLog, NivelLogDetalhes, type OpoesELogger, Produtos, TipagemRotas, type TipoPayloadAuditoria, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, criarFiltroDelta, defineDayjsBr, erUuid, esperar, extensoes, iniciarDayjsBr, iniciarELog, iniciarFiltroDelta, type interfaceConsulta, link_paiol, localValor, nomeVariavel, objetoPg, operadorFiltroDeltaDetalhes, operadores, paraObjetoRegistroPg, pgObjeto, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoColunaFiltroDelta, type tipoCondicaoFiltroDelta, type tipoCondicaoFiltroDeltaTipado, type tipoFiltro, type tipoFiltroDelta, type tipoFiltroDeltaColunaTipada, type tipoOperadorFiltroDelta, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zColunaFiltroDelta, zCondicaoFiltroDelta, zCoordenadas, zDocCnpj, zDocCpf, zDocumento, zFiltro, zFiltroDelta, zNumero, zNumeroInteiro, zNumeroPositivo, zOperadorFiltroDelta, zOperadores }; export { type ArquivamentoLog, type ELogger, type EntradaLog, NivelLog, NivelLogDetalhes, type OpoesELogger, Produtos, TipagemRotas, type TipoPayloadAuditoria, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, criarFiltroDelta, defineDayjsBr, erUuid, esperar, extensoes, iniciarDayjsBr, iniciarELog, iniciarFiltroDelta, type interfaceConsulta, link_paiol, localValor, nomeVariavel, objetoPg, operadorFiltroDeltaDetalhes, operadores, paraObjetoRegistroPg, pgObjeto, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoColunaFiltroDelta, type tipoCondicaoFiltroDelta, type tipoCondicaoFiltroDeltaTipado, type tipoFiltro, type tipoFiltroDelta, type tipoFiltroDeltaColunaTipada, type tipoOperadorFiltroDelta, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zColunaFiltroDelta, zCondicaoFiltroDelta, zCoordenadas, zDocCnpj, zDocCpf, zDocumento, zFiltro, zFiltroDelta, zNumero, zNumeroInteiro, zNumeroPositivo, zOperadorFiltroDelta, zOperadores };

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "p-comuns", "name": "p-comuns",
"version": "0.350.0", "version": "0.355.0",
"description": "", "description": "",
"main": "./dist-front/index.mjs", "main": "./dist-front/index.mjs",
"module": "./dist-front/index.mjs", "module": "./dist-front/index.mjs",

Binary file not shown.

182
pnpm-lock.yaml generated
View file

@ -12,32 +12,29 @@ importers:
specifier: 2.4.12 specifier: 2.4.12
version: 2.4.12 version: 2.4.12
'@types/node': '@types/node':
specifier: ^20.19.39 specifier: ^22
version: 20.19.39 version: 22.20.1
cross-fetch:
specifier: 4.1.0
version: 4.1.0
dayjs: dayjs:
specifier: ^1.11.20 specifier: ^1.11.18
version: 1.11.20 version: 1.11.20
tsup: tsup:
specifier: 8.5.0 specifier: 8.5.1
version: 8.5.0(jiti@2.6.1)(postcss@8.5.9)(typescript@5.9.3) version: 8.5.1(jiti@2.6.1)(postcss@8.5.9)(typescript@6.0.3)
typescript: typescript:
specifier: ~5.9.3 specifier: ^6
version: 5.9.3 version: 6.0.3
unbuild: unbuild:
specifier: ^3.6.1 specifier: ^3.6.1
version: 3.6.1(typescript@5.9.3) version: 3.6.1(typescript@6.0.3)
uuid: uuid:
specifier: ^11.1.0 specifier: ^11.1.0
version: 11.1.0 version: 11.1.0
vitest: vitest:
specifier: ^3.2.4 specifier: ^3.2.4
version: 3.2.4(@types/node@20.19.39)(jiti@2.6.1) version: 3.2.4(@types/node@22.20.1)(jiti@2.6.1)
zod: zod:
specifier: 4.1.4 specifier: 4.4.3
version: 4.1.4 version: 4.4.3
packages: packages:
@ -621,8 +618,8 @@ packages:
'@types/estree@1.0.8': '@types/estree@1.0.8':
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
'@types/node@20.19.39': '@types/node@22.20.1':
resolution: {integrity: sha512-orrrD74MBUyK8jOAD/r0+lfa1I2MO6I+vAkmAWzMYbCcgrN4lCrmK52gRFQq/JRxfYPfonkr4b0jcY7Olqdqbw==} resolution: {integrity: sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==}
'@types/resolve@1.20.2': '@types/resolve@1.20.2':
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
@ -743,9 +740,6 @@ packages:
convert-source-map@2.0.0: convert-source-map@2.0.0:
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
cross-fetch@4.1.0:
resolution: {integrity: sha512-uKm5PU+MHTootlWEY+mZ4vvXoCn4fLQxT9dSc1sXVMSFkINTJVN8cAQROpwcKm8bJ/c7rgZVIBWzH5T78sNZZw==}
css-declaration-sorter@7.4.0: css-declaration-sorter@7.4.0:
resolution: {integrity: sha512-LTuzjPoyA2vMGKKcaOqKSp7Ub2eGrNfKiZH4LpezxpNrsICGCSFvsQOI29psISxNZtaXibkC2CXzrQ5enMeGGw==} resolution: {integrity: sha512-LTuzjPoyA2vMGKKcaOqKSp7Ub2eGrNfKiZH4LpezxpNrsICGCSFvsQOI29psISxNZtaXibkC2CXzrQ5enMeGGw==}
engines: {node: ^14 || ^16 || >=18} engines: {node: ^14 || ^16 || >=18}
@ -946,9 +940,6 @@ packages:
lodash.memoize@4.1.2: lodash.memoize@4.1.2:
resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==} resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==}
lodash.sortby@4.7.0:
resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==}
lodash.uniq@4.5.0: lodash.uniq@4.5.0:
resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==} resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==}
@ -999,15 +990,6 @@ packages:
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true hasBin: true
node-fetch@2.7.0:
resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==}
engines: {node: 4.x || >=6.0.0}
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
node-releases@2.0.37: node-releases@2.0.37:
resolution: {integrity: sha512-1h5gKZCF+pO/o3Iqt5Jp7wc9rH3eJJ0+nh/CIoiRwjRxde/hAHyLPXYN4V3CqKAbiZPSeJFSWHmJsbkicta0Eg==} resolution: {integrity: sha512-1h5gKZCF+pO/o3Iqt5Jp7wc9rH3eJJ0+nh/CIoiRwjRxde/hAHyLPXYN4V3CqKAbiZPSeJFSWHmJsbkicta0Eg==}
@ -1246,10 +1228,6 @@ packages:
resolution: {integrity: sha512-nODzvTiYVRGRqAOvE84Vk5JDPyyxsVk0/fbA/bq7RqlnhksGpset09XTxbpvLTIjoaF7K8Z8DG8yHtKGTPSYRw==} resolution: {integrity: sha512-nODzvTiYVRGRqAOvE84Vk5JDPyyxsVk0/fbA/bq7RqlnhksGpset09XTxbpvLTIjoaF7K8Z8DG8yHtKGTPSYRw==}
engines: {node: '>=20'} engines: {node: '>=20'}
punycode@2.3.1:
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
engines: {node: '>=6'}
readdirp@4.1.2: readdirp@4.1.2:
resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==} resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==}
engines: {node: '>= 14.18.0'} engines: {node: '>= 14.18.0'}
@ -1294,10 +1272,9 @@ packages:
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
source-map@0.8.0-beta.0: source-map@0.7.6:
resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==} resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==}
engines: {node: '>= 8'} engines: {node: '>= 12'}
deprecated: The work that was done in this beta branch won't be included in future versions
stackback@0.0.2: stackback@0.0.2:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
@ -1357,12 +1334,6 @@ packages:
resolution: {integrity: sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==} resolution: {integrity: sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
tr46@0.0.3:
resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
tr46@1.0.1:
resolution: {integrity: sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==}
tree-kill@1.2.2: tree-kill@1.2.2:
resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
hasBin: true hasBin: true
@ -1370,8 +1341,8 @@ packages:
ts-interface-checker@0.1.13: ts-interface-checker@0.1.13:
resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==}
tsup@8.5.0: tsup@8.5.1:
resolution: {integrity: sha512-VmBp77lWNQq6PfuMqCHD3xWl22vEoWsKajkF8t+yMBawlUS8JzEI+vOVMeuNZIuMML8qXRizFKi9oD5glKQVcQ==} resolution: {integrity: sha512-xtgkqwdhpKWr3tKPmCkvYmS9xnQK3m3XgxZHwSUjvfTjp7YfXe5tT3GgWi0F2N+ZSMsOeWeZFh7ZZFg5iPhing==}
engines: {node: '>=18'} engines: {node: '>=18'}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
@ -1389,8 +1360,8 @@ packages:
typescript: typescript:
optional: true optional: true
typescript@5.9.3: typescript@6.0.3:
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} resolution: {integrity: sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==}
engines: {node: '>=14.17'} engines: {node: '>=14.17'}
hasBin: true hasBin: true
@ -1499,25 +1470,13 @@ packages:
jsdom: jsdom:
optional: true optional: true
webidl-conversions@3.0.1:
resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==}
webidl-conversions@4.0.2:
resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==}
whatwg-url@5.0.0:
resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==}
whatwg-url@7.1.0:
resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==}
why-is-node-running@2.3.0: why-is-node-running@2.3.0:
resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
engines: {node: '>=8'} engines: {node: '>=8'}
hasBin: true hasBin: true
zod@4.1.4: zod@4.4.3:
resolution: {integrity: sha512-2YqJuWkU6IIK9qcE4k1lLLhyZ6zFw7XVRdQGpV97jEIZwTrscUw+DY31Xczd8nwaoksyJUIxCojZXwckJovWxA==} resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==}
snapshots: snapshots:
@ -1874,7 +1833,7 @@ snapshots:
'@types/estree@1.0.8': {} '@types/estree@1.0.8': {}
'@types/node@20.19.39': '@types/node@22.20.1':
dependencies: dependencies:
undici-types: 6.21.0 undici-types: 6.21.0
@ -1888,13 +1847,13 @@ snapshots:
chai: 5.3.3 chai: 5.3.3
tinyrainbow: 2.0.0 tinyrainbow: 2.0.0
'@vitest/mocker@3.2.4(vite@7.3.2(@types/node@20.19.39)(jiti@2.6.1))': '@vitest/mocker@3.2.4(vite@7.3.2(@types/node@22.20.1)(jiti@2.6.1))':
dependencies: dependencies:
'@vitest/spy': 3.2.4 '@vitest/spy': 3.2.4
estree-walker: 3.0.3 estree-walker: 3.0.3
magic-string: 0.30.21 magic-string: 0.30.21
optionalDependencies: optionalDependencies:
vite: 7.3.2(@types/node@20.19.39)(jiti@2.6.1) vite: 7.3.2(@types/node@22.20.1)(jiti@2.6.1)
'@vitest/pretty-format@3.2.4': '@vitest/pretty-format@3.2.4':
dependencies: dependencies:
@ -1949,9 +1908,9 @@ snapshots:
node-releases: 2.0.37 node-releases: 2.0.37
update-browserslist-db: 1.2.3(browserslist@4.28.2) update-browserslist-db: 1.2.3(browserslist@4.28.2)
bundle-require@5.1.0(esbuild@0.25.12): bundle-require@5.1.0(esbuild@0.27.7):
dependencies: dependencies:
esbuild: 0.25.12 esbuild: 0.27.7
load-tsconfig: 0.2.5 load-tsconfig: 0.2.5
cac@6.7.14: {} cac@6.7.14: {}
@ -1997,12 +1956,6 @@ snapshots:
convert-source-map@2.0.0: {} convert-source-map@2.0.0: {}
cross-fetch@4.1.0:
dependencies:
node-fetch: 2.7.0
transitivePeerDependencies:
- encoding
css-declaration-sorter@7.4.0(postcss@8.5.9): css-declaration-sorter@7.4.0(postcss@8.5.9):
dependencies: dependencies:
postcss: 8.5.9 postcss: 8.5.9
@ -2239,8 +2192,6 @@ snapshots:
lodash.memoize@4.1.2: {} lodash.memoize@4.1.2: {}
lodash.sortby@4.7.0: {}
lodash.uniq@4.5.0: {} lodash.uniq@4.5.0: {}
loupe@3.2.1: {} loupe@3.2.1: {}
@ -2253,7 +2204,7 @@ snapshots:
mdn-data@2.27.1: {} mdn-data@2.27.1: {}
mkdist@2.4.1(typescript@5.9.3): mkdist@2.4.1(typescript@6.0.3):
dependencies: dependencies:
autoprefixer: 10.5.0(postcss@8.5.9) autoprefixer: 10.5.0(postcss@8.5.9)
citty: 0.1.6 citty: 0.1.6
@ -2269,7 +2220,7 @@ snapshots:
semver: 7.7.4 semver: 7.7.4
tinyglobby: 0.2.16 tinyglobby: 0.2.16
optionalDependencies: optionalDependencies:
typescript: 5.9.3 typescript: 6.0.3
mlly@1.8.2: mlly@1.8.2:
dependencies: dependencies:
@ -2288,10 +2239,6 @@ snapshots:
nanoid@3.3.11: {} nanoid@3.3.11: {}
node-fetch@2.7.0:
dependencies:
whatwg-url: 5.0.0
node-releases@2.0.37: {} node-releases@2.0.37: {}
nth-check@2.1.1: nth-check@2.1.1:
@ -2500,8 +2447,6 @@ snapshots:
pretty-bytes@7.1.0: {} pretty-bytes@7.1.0: {}
punycode@2.3.1: {}
readdirp@4.1.2: {} readdirp@4.1.2: {}
resolve-from@5.0.0: {} resolve-from@5.0.0: {}
@ -2513,14 +2458,14 @@ snapshots:
path-parse: 1.0.7 path-parse: 1.0.7
supports-preserve-symlinks-flag: 1.0.0 supports-preserve-symlinks-flag: 1.0.0
rollup-plugin-dts@6.4.1(rollup@4.60.1)(typescript@5.9.3): rollup-plugin-dts@6.4.1(rollup@4.60.1)(typescript@6.0.3):
dependencies: dependencies:
'@jridgewell/remapping': 2.3.5 '@jridgewell/remapping': 2.3.5
'@jridgewell/sourcemap-codec': 1.5.5 '@jridgewell/sourcemap-codec': 1.5.5
convert-source-map: 2.0.0 convert-source-map: 2.0.0
magic-string: 0.30.21 magic-string: 0.30.21
rollup: 4.60.1 rollup: 4.60.1
typescript: 5.9.3 typescript: 6.0.3
optionalDependencies: optionalDependencies:
'@babel/code-frame': 7.29.0 '@babel/code-frame': 7.29.0
@ -2565,9 +2510,7 @@ snapshots:
source-map-js@1.2.1: {} source-map-js@1.2.1: {}
source-map@0.8.0-beta.0: source-map@0.7.6: {}
dependencies:
whatwg-url: 7.1.0
stackback@0.0.2: {} stackback@0.0.2: {}
@ -2628,49 +2571,43 @@ snapshots:
tinyspy@4.0.4: {} tinyspy@4.0.4: {}
tr46@0.0.3: {}
tr46@1.0.1:
dependencies:
punycode: 2.3.1
tree-kill@1.2.2: {} tree-kill@1.2.2: {}
ts-interface-checker@0.1.13: {} ts-interface-checker@0.1.13: {}
tsup@8.5.0(jiti@2.6.1)(postcss@8.5.9)(typescript@5.9.3): tsup@8.5.1(jiti@2.6.1)(postcss@8.5.9)(typescript@6.0.3):
dependencies: dependencies:
bundle-require: 5.1.0(esbuild@0.25.12) bundle-require: 5.1.0(esbuild@0.27.7)
cac: 6.7.14 cac: 6.7.14
chokidar: 4.0.3 chokidar: 4.0.3
consola: 3.4.2 consola: 3.4.2
debug: 4.4.3 debug: 4.4.3
esbuild: 0.25.12 esbuild: 0.27.7
fix-dts-default-cjs-exports: 1.0.1 fix-dts-default-cjs-exports: 1.0.1
joycon: 3.1.1 joycon: 3.1.1
picocolors: 1.1.1 picocolors: 1.1.1
postcss-load-config: 6.0.1(jiti@2.6.1)(postcss@8.5.9) postcss-load-config: 6.0.1(jiti@2.6.1)(postcss@8.5.9)
resolve-from: 5.0.0 resolve-from: 5.0.0
rollup: 4.60.1 rollup: 4.60.1
source-map: 0.8.0-beta.0 source-map: 0.7.6
sucrase: 3.35.1 sucrase: 3.35.1
tinyexec: 0.3.2 tinyexec: 0.3.2
tinyglobby: 0.2.16 tinyglobby: 0.2.16
tree-kill: 1.2.2 tree-kill: 1.2.2
optionalDependencies: optionalDependencies:
postcss: 8.5.9 postcss: 8.5.9
typescript: 5.9.3 typescript: 6.0.3
transitivePeerDependencies: transitivePeerDependencies:
- jiti - jiti
- supports-color - supports-color
- tsx - tsx
- yaml - yaml
typescript@5.9.3: {} typescript@6.0.3: {}
ufo@1.6.3: {} ufo@1.6.3: {}
unbuild@3.6.1(typescript@5.9.3): unbuild@3.6.1(typescript@6.0.3):
dependencies: dependencies:
'@rollup/plugin-alias': 5.1.1(rollup@4.60.1) '@rollup/plugin-alias': 5.1.1(rollup@4.60.1)
'@rollup/plugin-commonjs': 28.0.9(rollup@4.60.1) '@rollup/plugin-commonjs': 28.0.9(rollup@4.60.1)
@ -2686,18 +2623,18 @@ snapshots:
hookable: 5.5.3 hookable: 5.5.3
jiti: 2.6.1 jiti: 2.6.1
magic-string: 0.30.21 magic-string: 0.30.21
mkdist: 2.4.1(typescript@5.9.3) mkdist: 2.4.1(typescript@6.0.3)
mlly: 1.8.2 mlly: 1.8.2
pathe: 2.0.3 pathe: 2.0.3
pkg-types: 2.3.0 pkg-types: 2.3.0
pretty-bytes: 7.1.0 pretty-bytes: 7.1.0
rollup: 4.60.1 rollup: 4.60.1
rollup-plugin-dts: 6.4.1(rollup@4.60.1)(typescript@5.9.3) rollup-plugin-dts: 6.4.1(rollup@4.60.1)(typescript@6.0.3)
scule: 1.3.0 scule: 1.3.0
tinyglobby: 0.2.16 tinyglobby: 0.2.16
untyped: 2.0.0 untyped: 2.0.0
optionalDependencies: optionalDependencies:
typescript: 5.9.3 typescript: 6.0.3
transitivePeerDependencies: transitivePeerDependencies:
- sass - sass
- vue - vue
@ -2724,13 +2661,13 @@ snapshots:
uuid@11.1.0: {} uuid@11.1.0: {}
vite-node@3.2.4(@types/node@20.19.39)(jiti@2.6.1): vite-node@3.2.4(@types/node@22.20.1)(jiti@2.6.1):
dependencies: dependencies:
cac: 6.7.14 cac: 6.7.14
debug: 4.4.3 debug: 4.4.3
es-module-lexer: 1.7.0 es-module-lexer: 1.7.0
pathe: 2.0.3 pathe: 2.0.3
vite: 7.3.2(@types/node@20.19.39)(jiti@2.6.1) vite: 7.3.2(@types/node@22.20.1)(jiti@2.6.1)
transitivePeerDependencies: transitivePeerDependencies:
- '@types/node' - '@types/node'
- jiti - jiti
@ -2745,7 +2682,7 @@ snapshots:
- tsx - tsx
- yaml - yaml
vite@7.3.2(@types/node@20.19.39)(jiti@2.6.1): vite@7.3.2(@types/node@22.20.1)(jiti@2.6.1):
dependencies: dependencies:
esbuild: 0.27.7 esbuild: 0.27.7
fdir: 6.5.0(picomatch@4.0.4) fdir: 6.5.0(picomatch@4.0.4)
@ -2754,15 +2691,15 @@ snapshots:
rollup: 4.60.1 rollup: 4.60.1
tinyglobby: 0.2.16 tinyglobby: 0.2.16
optionalDependencies: optionalDependencies:
'@types/node': 20.19.39 '@types/node': 22.20.1
fsevents: 2.3.3 fsevents: 2.3.3
jiti: 2.6.1 jiti: 2.6.1
vitest@3.2.4(@types/node@20.19.39)(jiti@2.6.1): vitest@3.2.4(@types/node@22.20.1)(jiti@2.6.1):
dependencies: dependencies:
'@types/chai': 5.2.3 '@types/chai': 5.2.3
'@vitest/expect': 3.2.4 '@vitest/expect': 3.2.4
'@vitest/mocker': 3.2.4(vite@7.3.2(@types/node@20.19.39)(jiti@2.6.1)) '@vitest/mocker': 3.2.4(vite@7.3.2(@types/node@22.20.1)(jiti@2.6.1))
'@vitest/pretty-format': 3.2.4 '@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4 '@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4 '@vitest/snapshot': 3.2.4
@ -2780,11 +2717,11 @@ snapshots:
tinyglobby: 0.2.16 tinyglobby: 0.2.16
tinypool: 1.1.1 tinypool: 1.1.1
tinyrainbow: 2.0.0 tinyrainbow: 2.0.0
vite: 7.3.2(@types/node@20.19.39)(jiti@2.6.1) vite: 7.3.2(@types/node@22.20.1)(jiti@2.6.1)
vite-node: 3.2.4(@types/node@20.19.39)(jiti@2.6.1) vite-node: 3.2.4(@types/node@22.20.1)(jiti@2.6.1)
why-is-node-running: 2.3.0 why-is-node-running: 2.3.0
optionalDependencies: optionalDependencies:
'@types/node': 20.19.39 '@types/node': 22.20.1
transitivePeerDependencies: transitivePeerDependencies:
- jiti - jiti
- less - less
@ -2799,24 +2736,9 @@ snapshots:
- tsx - tsx
- yaml - yaml
webidl-conversions@3.0.1: {}
webidl-conversions@4.0.2: {}
whatwg-url@5.0.0:
dependencies:
tr46: 0.0.3
webidl-conversions: 3.0.1
whatwg-url@7.1.0:
dependencies:
lodash.sortby: 4.7.0
tr46: 1.0.1
webidl-conversions: 4.0.2
why-is-node-running@2.3.0: why-is-node-running@2.3.0:
dependencies: dependencies:
siginfo: 2.0.0 siginfo: 2.0.0
stackback: 0.0.2 stackback: 0.0.2
zod@4.1.4: {} zod@4.4.3: {}

View file

@ -10,6 +10,7 @@ export enum operadores {
like = "like", like = "like",
in = "in", in = "in",
isNull = "isNull", isNull = "isNull",
notIn = "notIn",
} }
export type tipoFiltro = { export type tipoFiltro = {
@ -30,7 +31,18 @@ export type interfaceConsulta = {
apenasContagem?: boolean apenasContagem?: boolean
} }
export const zOperadores = z.enum(["=", "!=", ">", ">=", "<", "<=", "like", "in", "isNull"]) export const zOperadores = z.enum([
"=",
"!=",
">",
">=",
"<",
"<=",
"like",
"in",
"isNull",
"notIn",
])
export const zFiltro = z.object({ export const zFiltro = z.object({
coluna: z.string(), coluna: z.string(),

View file

@ -1,52 +1,130 @@
import { NIL, v3, v4 } from "uuid"
/** /**
* Valida se uma string é um UUID válido (qualquer versão). * 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 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) => { export const validarUuid = (uuid: string | number | undefined | null) => {
const retorno = erUuid.test(String(uuid || "")) return erUuid.test(String(uuid || ""))
return retorno }
// ── UUID v4 ──────────────────────────────────────────────────────────────────
// Usa Web Crypto API (globalThis.crypto), disponível em Node 19+, Bun e browsers.
/**
* Gera um UUID v4 (aleatório, não determinístico).
* Usa `globalThis.crypto.randomUUID()` — disponível em Node 19+, Bun e browsers modernos.
*/
export const uuidV4 = (): string => globalThis.crypto.randomUUID()
/**
* @deprecated Use uuidV4() diretamente.
*/
export const uuid = uuidV4
// ── UUID v3 (MD5 determinístico) ──────────────────────────────────────────────
// Implementação pura sem dependência de Node.js para compatibilidade front+back.
const NIL_UUID = "00000000-0000-0000-0000-000000000000"
// Rotação de 32 bits à esquerda
const rotL = (x: number, n: number) => (x << n) | (x >>> (32 - n))
// MD5 — implementação pura JS compatível com browser e Node
const md5 = (str: string): string => {
const msg = new TextEncoder().encode(str)
const len = msg.length
const bits = len * 8
// Padding
const padLen = len % 64 < 56 ? 56 - (len % 64) : 120 - (len % 64)
const padded = new Uint8Array(len + padLen + 8)
padded.set(msg)
padded[len] = 0x80
const dv = new DataView(padded.buffer)
dv.setUint32(len + padLen, bits >>> 0, true)
dv.setUint32(len + padLen + 4, Math.floor(bits / 2 ** 32), true)
// Tabela de senos
const T: number[] = Array.from(
{ length: 64 },
(_, i) => (Math.abs(Math.sin(i + 1)) * 2 ** 32) >>> 0,
)
const S = [
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4,
11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6,
10, 15, 21,
]
let a0 = 0x67452301,
b0 = 0xefcdab89,
c0 = 0x98badcfe,
d0 = 0x10325476
for (let off = 0; off < padded.length; off += 64) {
const M: number[] = []
for (let j = 0; j < 16; j++) M[j] = dv.getUint32(off + j * 4, true)
let [A, B, C, D] = [a0, b0, c0, d0]
for (let i = 0; i < 64; i++) {
let F: number, g: number
if (i < 16) {
F = (B & C) | (~B & D)
g = i
} else if (i < 32) {
F = (D & B) | (~D & C)
g = (5 * i + 1) % 16
} else if (i < 48) {
F = B ^ C ^ D
g = (3 * i + 5) % 16
} else {
F = C ^ (B | ~D)
g = (7 * i) % 16
}
F = (F + A + T[i] + M[g]) >>> 0
A = D
D = C
C = B
B = (B + rotL(F, S[i])) >>> 0
}
a0 = (a0 + A) >>> 0
b0 = (b0 + B) >>> 0
c0 = (c0 + C) >>> 0
d0 = (d0 + D) >>> 0
}
const toHexLE = (n: number) => {
let s = ""
for (let i = 0; i < 4; i++) s += ((n >>> (i * 8)) & 0xff).toString(16).padStart(2, "0")
return s
}
return toHexLE(a0) + toHexLE(b0) + toHexLE(c0) + toHexLE(d0)
}
const formatarUuidV3 = (hash: string): string => {
const c = hash.slice(0, 32)
const v = ((Number.parseInt(c[16], 16) & 0x3) | 0x8).toString(16)
return `${c.slice(0, 8)}-${c.slice(8, 12)}-3${c.slice(13, 16)}-${v}${c.slice(17, 20)}-${c.slice(20, 32)}`
} }
/** /**
* Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace). * Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace).
* Implementação pura JS (MD5), sem dependência de Node.js — funciona em browser e server.
* *
* - Usa o algoritmo MD5 (RFC 4122). * @param chave - Valor a serializar (string, number ou objeto).
* - Sempre retorna o mesmo UUID para a mesma combinação chave + grupo. * @param grupo - Namespace opcional; se omitido, usa UUID nil.
* - 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 => { export const uuidV3 = (chave: unknown, grupo?: unknown): string => {
return v3( const namespace = grupo ? uuidV3(grupo) : NIL_UUID
// Converte a chave para string (de forma segura) const input =
typeof chave === "string" typeof chave === "string"
? chave ? chave
: typeof chave === "number" : typeof chave === "number"
? String(chave) ? String(chave)
: JSON.stringify(chave), : JSON.stringify(chave)
return formatarUuidV3(md5(namespace + input))
// 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

View file

@ -24,5 +24,6 @@ export const tsup_config_back: Options = {
}, },
} }
// Exporta a configuração padrão usando defineConfig // Exporta a configuração padrão usando defineConfig
export default defineConfig(tsup_config_back) export default defineConfig(tsup_config_back)