48 lines
1.8 KiB
JavaScript
48 lines
1.8 KiB
JavaScript
"use strict";
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
var uuid_exports = {};
|
|
__export(uuid_exports, {
|
|
erUuid: () => erUuid,
|
|
uuidV3: () => uuidV3,
|
|
uuidV4: () => uuidV4,
|
|
validarUuid: () => validarUuid
|
|
});
|
|
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 validarUuid = (uuid) => {
|
|
const retorno = erUuid.test(String(uuid || ""));
|
|
return retorno;
|
|
};
|
|
const uuidV3 = (chave, grupo) => {
|
|
return (0, import_uuid.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 ? typeof grupo == "string" && validarUuid(grupo) ? grupo : uuidV3(grupo) : import_uuid.NIL
|
|
);
|
|
};
|
|
const uuidV4 = import_uuid.v4;
|
|
// Annotate the CommonJS export names for ESM import in node:
|
|
0 && (module.exports = {
|
|
erUuid,
|
|
uuidV3,
|
|
uuidV4,
|
|
validarUuid
|
|
});
|