@jsfsi-core/ts-nodejs 1.1.39 → 1.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("path"),W=require("url"),Q=require("fs"),H=require("os"),X=require("crypto");var U=typeof document<"u"?document.currentScript:null;function Z(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var S={exports:{}};const ee="17.3.1",te={version:ee};var q;function re(){if(q)return S.exports;q=1;const h=Q,t=Y,n=H,c=X,N=te.version,O=["🔐 encrypt with Dotenvx: https://dotenvx.com","🔐 prevent committing .env to code: https://dotenvx.com/precommit","🔐 prevent building .env in docker: https://dotenvx.com/prebuild","🤖 agentic secret storage: https://dotenvx.com/as2","⚡️ secrets for agents: https://dotenvx.com/as2","🛡️ auth for agents: https://vestauth.com","🛠️ run anywhere with `dotenvx run -- yourcommand`","⚙️ specify custom .env file path with { path: '/custom/path/.env' }","⚙️ enable debug logging with { debug: true }","⚙️ override existing env vars with { override: true }","⚙️ suppress all logs with { quiet: true }","⚙️ write to custom object with { processEnv: myObject }","⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"];function I(){return O[Math.floor(Math.random()*O.length)]}function b(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}function D(){return process.stdout.isTTY}function A(e){return D()?`\x1B[2m${e}\x1B[0m`:e}const M=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function r(e){const a={};let l=e.toString();l=l.replace(/\r\n?/mg,`
2
- `);let d;for(;(d=M.exec(l))!=null;){const E=d[1];let g=d[2]||"";g=g.trim();const o=g[0];g=g.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),o==='"'&&(g=g.replace(/\\n/g,`
3
- `),g=g.replace(/\\r/g,"\r")),a[E]=g}return a}function u(e){e=e||{};const a=s(e);e.path=a;const l=_.configDotenv(e);if(!l.parsed){const o=new Error(`MISSING_DATA: Cannot parse ${a} for an unknown reason`);throw o.code="MISSING_DATA",o}const d=y(e).split(","),E=d.length;let g;for(let o=0;o<E;o++)try{const m=d[o].trim(),T=v(l,m);g=_.decrypt(T.ciphertext,T.key);break}catch(m){if(o+1>=E)throw m}return _.parse(g)}function p(e){console.error(`[dotenv@${N}][WARN] ${e}`)}function i(e){console.log(`[dotenv@${N}][DEBUG] ${e}`)}function f(e){console.log(`[dotenv@${N}] ${e}`)}function y(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function v(e,a){let l;try{l=new URL(a)}catch(m){if(m.code==="ERR_INVALID_URL"){const T=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw T.code="INVALID_DOTENV_KEY",T}throw m}const d=l.password;if(!d){const m=new Error("INVALID_DOTENV_KEY: Missing key part");throw m.code="INVALID_DOTENV_KEY",m}const E=l.searchParams.get("environment");if(!E){const m=new Error("INVALID_DOTENV_KEY: Missing environment part");throw m.code="INVALID_DOTENV_KEY",m}const g=`DOTENV_VAULT_${E.toUpperCase()}`,o=e.parsed[g];if(!o){const m=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${g} in your .env.vault file.`);throw m.code="NOT_FOUND_DOTENV_ENVIRONMENT",m}return{ciphertext:o,key:d}}function s(e){let a=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(const l of e.path)h.existsSync(l)&&(a=l.endsWith(".vault")?l:`${l}.vault`);else a=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else a=t.resolve(process.cwd(),".env.vault");return h.existsSync(a)?a:null}function R(e){return e[0]==="~"?t.join(n.homedir(),e.slice(1)):e}function V(e){const a=b(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),l=b(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(a||!l)&&f("Loading env from encrypted .env.vault");const d=_._parseVault(e);let E=process.env;return e&&e.processEnv!=null&&(E=e.processEnv),_.populate(E,d,e),{parsed:d}}function x(e){const a=t.resolve(process.cwd(),".env");let l="utf8",d=process.env;e&&e.processEnv!=null&&(d=e.processEnv);let E=b(d.DOTENV_CONFIG_DEBUG||e&&e.debug),g=b(d.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?l=e.encoding:E&&i("No encoding is specified. UTF-8 is used by default");let o=[a];if(e&&e.path)if(!Array.isArray(e.path))o=[R(e.path)];else{o=[];for(const L of e.path)o.push(R(L))}let m;const T={};for(const L of o)try{const $=_.parse(h.readFileSync(L,{encoding:l}));_.populate(T,$,e)}catch($){E&&i(`Failed to load ${L} ${$.message}`),m=$}const F=_.populate(d,T,e);if(E=b(d.DOTENV_CONFIG_DEBUG||E),g=b(d.DOTENV_CONFIG_QUIET||g),E||!g){const L=Object.keys(F).length,$=[];for(const K of o)try{const C=t.relative(process.cwd(),K);$.push(C)}catch(C){E&&i(`Failed to load ${K} ${C.message}`),m=C}f(`injecting env (${L}) from ${$.join(",")} ${A(`-- tip: ${I()}`)}`)}return m?{parsed:T,error:m}:{parsed:T}}function G(e){if(y(e).length===0)return _.configDotenv(e);const a=s(e);return a?_._configVault(e):(p(`You set DOTENV_KEY but you are missing a .env.vault file at ${a}. Did you forget to build it?`),_.configDotenv(e))}function k(e,a){const l=Buffer.from(a.slice(-64),"hex");let d=Buffer.from(e,"base64");const E=d.subarray(0,12),g=d.subarray(-16);d=d.subarray(12,-16);try{const o=c.createDecipheriv("aes-256-gcm",l,E);return o.setAuthTag(g),`${o.update(d)}${o.final()}`}catch(o){const m=o instanceof RangeError,T=o.message==="Invalid key length",F=o.message==="Unsupported state or unable to authenticate data";if(m||T){const L=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw L.code="INVALID_DOTENV_KEY",L}else if(F){const L=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw L.code="DECRYPTION_FAILED",L}else throw o}}function z(e,a,l={}){const d=!!(l&&l.debug),E=!!(l&&l.override),g={};if(typeof a!="object"){const o=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw o.code="OBJECT_REQUIRED",o}for(const o of Object.keys(a))Object.prototype.hasOwnProperty.call(e,o)?(E===!0&&(e[o]=a[o],g[o]=a[o]),d&&i(E===!0?`"${o}" is already defined and WAS overwritten`:`"${o}" is already defined and was NOT overwritten`)):(e[o]=a[o],g[o]=a[o]);return g}const _={configDotenv:x,_configVault:V,_parseVault:u,config:G,decrypt:k,parse:r,populate:z};return S.exports.configDotenv=_.configDotenv,S.exports._configVault=_._configVault,S.exports._parseVault=_._parseVault,S.exports.config=_.config,S.exports.decrypt=_.decrypt,S.exports.parse=_.parse,S.exports.populate=_.populate,S.exports=_,S.exports}var ne=re();const oe=W.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:U&&U.tagName.toUpperCase()==="SCRIPT"&&U.src||new URL("index.cjs",document.baseURI).href),ie=Y.dirname(oe),se=(h={})=>{const{env:t,configPath:n}=h,c=Y.resolve(ie,`${n??"."}/.env${t?`.${t}`:""}`),{parsed:w}=ne.config({path:c});return w};var j,B;function ce(){if(B)return j;B=1,j=N,N.default=N,N.stable=D,N.stableStringify=D;var h="[...]",t="[Circular]",n=[],c=[];function w(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function N(r,u,p,i){typeof i>"u"&&(i=w()),I(r,"",0,[],void 0,0,i);var f;try{c.length===0?f=JSON.stringify(r,u,p):f=JSON.stringify(r,M(u),p)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;n.length!==0;){var y=n.pop();y.length===4?Object.defineProperty(y[0],y[1],y[3]):y[0][y[1]]=y[2]}}return f}function O(r,u,p,i){var f=Object.getOwnPropertyDescriptor(i,p);f.get!==void 0?f.configurable?(Object.defineProperty(i,p,{value:r}),n.push([i,p,u,f])):c.push([u,p,r]):(i[p]=r,n.push([i,p,u]))}function I(r,u,p,i,f,y,v){y+=1;var s;if(typeof r=="object"&&r!==null){for(s=0;s<i.length;s++)if(i[s]===r){O(t,r,u,f);return}if(typeof v.depthLimit<"u"&&y>v.depthLimit){O(h,r,u,f);return}if(typeof v.edgesLimit<"u"&&p+1>v.edgesLimit){O(h,r,u,f);return}if(i.push(r),Array.isArray(r))for(s=0;s<r.length;s++)I(r[s],s,s,i,r,y,v);else{var R=Object.keys(r);for(s=0;s<R.length;s++){var V=R[s];I(r[V],V,s,i,r,y,v)}}i.pop()}}function b(r,u){return r<u?-1:r>u?1:0}function D(r,u,p,i){typeof i>"u"&&(i=w());var f=A(r,"",0,[],void 0,0,i)||r,y;try{c.length===0?y=JSON.stringify(f,u,p):y=JSON.stringify(f,M(u),p)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;n.length!==0;){var v=n.pop();v.length===4?Object.defineProperty(v[0],v[1],v[3]):v[0][v[1]]=v[2]}}return y}function A(r,u,p,i,f,y,v){y+=1;var s;if(typeof r=="object"&&r!==null){for(s=0;s<i.length;s++)if(i[s]===r){O(t,r,u,f);return}try{if(typeof r.toJSON=="function")return}catch{return}if(typeof v.depthLimit<"u"&&y>v.depthLimit){O(h,r,u,f);return}if(typeof v.edgesLimit<"u"&&p+1>v.edgesLimit){O(h,r,u,f);return}if(i.push(r),Array.isArray(r))for(s=0;s<r.length;s++)A(r[s],s,s,i,r,y,v);else{var R={},V=Object.keys(r).sort(b);for(s=0;s<V.length;s++){var x=V[s];A(r[x],x,s,i,r,y,v),R[x]=r[x]}if(typeof f<"u")n.push([f,u,r]),f[u]=R;else return R}i.pop()}}function M(r){return r=typeof r<"u"?r:function(u,p){return p},function(u,p){if(c.length>0)for(var i=0;i<c.length;i++){var f=c[i];if(f[1]===u&&f[0]===p){p=f[2],c.splice(i,1);break}}return r.call(this,u,p)}}return j}var ae=ce();const ue=Z(ae),J={debug:"debug",verbose:"debug",log:"log",warn:"warn",error:"error",fatal:"error"},fe={verbose:"DEFAULT",debug:"DEBUG",log:"INFO",warn:"WARNING",error:"ERROR",fatal:"CRITICAL"},le=["x-api-key","x-api-token","x-key","x-token","cookie","password","pass","psw","auth","authentication","authorization","token","access_token","client-secret","credentials","secret"];class de{constructor(t,n={}){this.module=t,n.logLevels&&(this.levels=new Set(n.logLevels))}levels=new Set(["verbose","debug","log","warn","error","fatal"]);mapLogLevelToConsoleMethod(t){return J[t]}write(t,n,c,w,N){if(!this.levels.has(t))return;const O=this.buildLog(t,n,c,w,N),I=ue(O,this.sensitiveReplacer),b=this.mapLogLevelToConsoleMethod(t);console[b](I)}buildLog(t,n,c,w,N){const{writeMetadata:O,writeContext:I,writeError:b}=this.sanitizeLog(c,w,N),D={};return typeof n=="string"&&(D.textPayload=n),!O&&typeof n!="string"&&!(n instanceof Error)&&(D.metadata=n),n instanceof Error&&(D.error=JSON.stringify(n,Object.getOwnPropertyNames(n))),I&&(D.context=I),O&&(D.metadata=O),!D.error&&b&&(D.error=JSON.stringify(b,Object.getOwnPropertyNames(b))),{severity:fe[t],module:this.module,textPayload:D.textPayload,message:D}}sanitizeLog(t,n,c){if(n instanceof Error&&(!c||typeof c=="string"))return{writeMetadata:void 0,writeContext:t||c,writeError:n};let w=n,N=t;return typeof w=="string"&&!t&&(N=w,w=void 0),{writeMetadata:w,writeContext:N,writeError:c}}sensitiveReplacer(t,n){return le.includes(t.toLowerCase())?"[HIDDEN BY LOGGER]":n}debug(t,n,c){this.write("debug",t,c,n)}verbose(t,n,c){this.write("verbose",t,c,n)}log(t,n,c){this.write("log",t,c,n)}warn(t,n,c,w){this.write("warn",t,w,n,c)}error(t,n,c,w){this.write("error",t,w,n,c)}fatal(t,n,c,w){this.write("fatal",t,w,n,c)}setLogLevels(t){this.levels=new Set(t)}}class ge{debug=()=>{};verbose=()=>{};log=()=>{};warn=()=>{};error=()=>{};fatal=()=>{};setLogLevels=()=>{}}class P{constructor(t){this.dataSource=t}em;static newInstance(t){const n=t.constructor;return new n(t.dataSource)}withEntityManager(t){return this.em=t,this}withRepositoryManager(t){return P.newInstance(this).withEntityManager(t.em)}lockInTransaction(t="pessimistic_write"){return this.em?{mode:t}:void 0}getRepository(t){return this.em?this.em.getRepository(t):this.dataSource.getRepository(t)}async withTransaction(t){let n;return await this.dataSource.transaction(async c=>{n=await t(P.newInstance(this).withEntityManager(c))}),n}}const he=h=>({...h,withTransaction:async t=>await t(h),withRepositoryManager:()=>h}),pe=(h,t)=>`unaccent(LOWER(${h})) ILIKE unaccent(LOWER(:${t}))`,ye=Object.freeze(Object.defineProperty({__proto__:null,unaccentSearch:pe},Symbol.toStringTag,{value:"Module"}));exports.GCPLogger=de;exports.LogLevelToConsoleMethodMap=J;exports.MockLogger=ge;exports.TransactionalRepository=P;exports.buildTransactionalRepositoryMock=he;exports.loadEnvConfig=se;exports.postgres=ye;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require(`path`);u=l(u);let d=require(`url`);var f=l(o(((e,t)=>{var n=require(`fs`),r=require(`path`),i=require(`os`),a=require(`crypto`),o=[`◈ encrypted .env [www.dotenvx.com]`,`◈ secrets for agents [www.dotenvx.com]`,`⌁ auth for agents [www.vestauth.com]`,`⌘ custom filepath { path: '/custom/path/.env' }`,`⌘ enable debugging { debug: true }`,`⌘ override existing { override: true }`,`⌘ suppress logs { quiet: true }`,`⌘ multiple files { path: ['.env.local', '.env'] }`];function s(){return o[Math.floor(Math.random()*o.length)]}function c(e){return typeof e==`string`?![`false`,`0`,`no`,`off`,``].includes(e.toLowerCase()):!!e}function l(){return process.stdout.isTTY}function u(e){return l()?`\x1b[2m${e}\x1b[0m`:e}var d=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function f(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
2
+ `);let r;for(;(r=d.exec(n))!=null;){let e=r[1],n=r[2]||``;n=n.trim();let i=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),i===`"`&&(n=n.replace(/\\n/g,`
3
+ `),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function p(e){e||={};let t=y(e);e.path=t;let n=E.configDotenv(e);if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=_(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=v(n,r[e].trim());a=E.decrypt(t.ciphertext,t.key);break}catch(t){if(e+1>=i)throw t}return E.parse(a)}function m(e){console.error(`⚠ ${e}`)}function h(e){console.log(`┆ ${e}`)}function g(e){console.log(`◇ ${e}`)}function _(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function v(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function y(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)n.existsSync(r)&&(t=r.endsWith(`.vault`)?r:`${r}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=r.resolve(process.cwd(),`.env.vault`);return n.existsSync(t)?t:null}function b(e){return e[0]===`~`?r.join(i.homedir(),e.slice(1)):e}function x(e){let t=c(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),n=c(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!n)&&g(`loading env from encrypted .env.vault`);let r=E._parseVault(e),i=process.env;return e&&e.processEnv!=null&&(i=e.processEnv),E.populate(i,r,e),{parsed:r}}function S(e){let t=r.resolve(process.cwd(),`.env`),i=`utf8`,a=process.env;e&&e.processEnv!=null&&(a=e.processEnv);let o=c(a.DOTENV_CONFIG_DEBUG||e&&e.debug),l=c(a.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?i=e.encoding:o&&h(`no encoding is specified (UTF-8 is used by default)`);let d=[t];if(e&&e.path)if(!Array.isArray(e.path))d=[b(e.path)];else{d=[];for(let t of e.path)d.push(b(t))}let f,p={};for(let t of d)try{let r=E.parse(n.readFileSync(t,{encoding:i}));E.populate(p,r,e)}catch(e){o&&h(`failed to load ${t} ${e.message}`),f=e}let m=E.populate(a,p,e);if(o=c(a.DOTENV_CONFIG_DEBUG||o),l=c(a.DOTENV_CONFIG_QUIET||l),o||!l){let e=Object.keys(m).length,t=[];for(let e of d)try{let n=r.relative(process.cwd(),e);t.push(n)}catch(t){o&&h(`failed to load ${e} ${t.message}`),f=t}g(`injected env (${e}) from ${t.join(`,`)} ${u(`// tip: ${s()}`)}`)}return f?{parsed:p,error:f}:{parsed:p}}function C(e){if(_(e).length===0)return E.configDotenv(e);let t=y(e);return t?E._configVault(e):(m(`you set DOTENV_KEY but you are missing a .env.vault file at ${t}`),E.configDotenv(e))}function w(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),o=r.subarray(-16);r=r.subarray(12,-16);try{let e=a.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(o),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function T(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override),a={};if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n],a[n]=t[n]),r&&h(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):(e[n]=t[n],a[n]=t[n]);return a}var E={configDotenv:S,_configVault:x,_parseVault:p,config:C,decrypt:w,parse:f,populate:T};t.exports.configDotenv=E.configDotenv,t.exports._configVault=E._configVault,t.exports._parseVault=E._parseVault,t.exports.config=E.config,t.exports.decrypt=E.decrypt,t.exports.parse=E.parse,t.exports.populate=E.populate,t.exports=E}))(),1),p=(0,d.fileURLToPath)({}.url),m=u.default.dirname(p),h=(e={})=>{let{env:t,configPath:n}=e,r=u.default.resolve(m,`${n??`.`}/.env${t?`.${t}`:``}`),{parsed:i}=f.config({path:r});return i},g=l(o(((e,t)=>{t.exports=s,s.default=s,s.stable=d,s.stableStringify=d;var n=`[...]`,r=`[Circular]`,i=[],a=[];function o(){return{depthLimit:2**53-1,edgesLimit:2**53-1}}function s(e,t,n,r){r===void 0&&(r=o()),l(e,``,0,[],void 0,0,r);var s;try{s=a.length===0?JSON.stringify(e,t,n):JSON.stringify(e,p(t),n)}catch{return JSON.stringify(`[unable to serialize, circular reference is too complex to analyze]`)}finally{for(;i.length!==0;){var c=i.pop();c.length===4?Object.defineProperty(c[0],c[1],c[3]):c[0][c[1]]=c[2]}}return s}function c(e,t,n,r){var o=Object.getOwnPropertyDescriptor(r,n);o.get===void 0?(r[n]=e,i.push([r,n,t])):o.configurable?(Object.defineProperty(r,n,{value:e}),i.push([r,n,t,o])):a.push([t,n,e])}function l(e,t,i,a,o,s,u){s+=1;var d;if(typeof e==`object`&&e){for(d=0;d<a.length;d++)if(a[d]===e){c(r,e,t,o);return}if(u.depthLimit!==void 0&&s>u.depthLimit){c(n,e,t,o);return}if(u.edgesLimit!==void 0&&i+1>u.edgesLimit){c(n,e,t,o);return}if(a.push(e),Array.isArray(e))for(d=0;d<e.length;d++)l(e[d],d,d,a,e,s,u);else{var f=Object.keys(e);for(d=0;d<f.length;d++){var p=f[d];l(e[p],p,d,a,e,s,u)}}a.pop()}}function u(e,t){return e<t?-1:e>t?1:0}function d(e,t,n,r){r===void 0&&(r=o());var s=f(e,``,0,[],void 0,0,r)||e,c;try{c=a.length===0?JSON.stringify(s,t,n):JSON.stringify(s,p(t),n)}catch{return JSON.stringify(`[unable to serialize, circular reference is too complex to analyze]`)}finally{for(;i.length!==0;){var l=i.pop();l.length===4?Object.defineProperty(l[0],l[1],l[3]):l[0][l[1]]=l[2]}}return c}function f(e,t,a,o,s,l,d){l+=1;var p;if(typeof e==`object`&&e){for(p=0;p<o.length;p++)if(o[p]===e){c(r,e,t,s);return}try{if(typeof e.toJSON==`function`)return}catch{return}if(d.depthLimit!==void 0&&l>d.depthLimit){c(n,e,t,s);return}if(d.edgesLimit!==void 0&&a+1>d.edgesLimit){c(n,e,t,s);return}if(o.push(e),Array.isArray(e))for(p=0;p<e.length;p++)f(e[p],p,p,o,e,l,d);else{var m={},h=Object.keys(e).sort(u);for(p=0;p<h.length;p++){var g=h[p];f(e[g],g,p,o,e,l,d),m[g]=e[g]}if(s!==void 0)i.push([s,t,e]),s[t]=m;else return m}o.pop()}}function p(e){return e=e===void 0?function(e,t){return t}:e,function(t,n){if(a.length>0)for(var r=0;r<a.length;r++){var i=a[r];if(i[1]===t&&i[0]===n){n=i[2],a.splice(r,1);break}}return e.call(this,t,n)}}}))(),1),_={debug:`debug`,verbose:`debug`,log:`log`,warn:`warn`,error:`error`,fatal:`error`},v={verbose:`DEFAULT`,debug:`DEBUG`,log:`INFO`,warn:`WARNING`,error:`ERROR`,fatal:`CRITICAL`},y=[`x-api-key`,`x-api-token`,`x-key`,`x-token`,`cookie`,`password`,`pass`,`psw`,`auth`,`authentication`,`authorization`,`token`,`access_token`,`client-secret`,`credentials`,`secret`],b=class{levels=new Set([`verbose`,`debug`,`log`,`warn`,`error`,`fatal`]);constructor(e,t={}){this.module=e,t.logLevels&&(this.levels=new Set(t.logLevels))}mapLogLevelToConsoleMethod(e){return _[e]}write(e,t,n,r,i){if(!this.levels.has(e))return;let a=(0,g.default)(this.buildLog(e,t,n,r,i),this.sensitiveReplacer),o=this.mapLogLevelToConsoleMethod(e);console[o](a)}buildLog(e,t,n,r,i){let{writeMetadata:a,writeContext:o,writeError:s}=this.sanitizeLog(n,r,i),c={};return typeof t==`string`&&(c.textPayload=t),!a&&typeof t!=`string`&&!(t instanceof Error)&&(c.metadata=t),t instanceof Error&&(c.error=JSON.stringify(t,Object.getOwnPropertyNames(t))),o&&(c.context=o),a&&(c.metadata=a),!c.error&&s&&(c.error=JSON.stringify(s,Object.getOwnPropertyNames(s))),{severity:v[e],module:this.module,textPayload:c.textPayload,message:c}}sanitizeLog(e,t,n){if(t instanceof Error&&(!n||typeof n==`string`))return{writeMetadata:void 0,writeContext:e||n,writeError:t};let r=t,i=e;return typeof r==`string`&&!e&&(i=r,r=void 0),{writeMetadata:r,writeContext:i,writeError:n}}sensitiveReplacer(e,t){return y.includes(e.toLowerCase())?`[HIDDEN BY LOGGER]`:t}debug(e,t,n){this.write(`debug`,e,n,t)}verbose(e,t,n){this.write(`verbose`,e,n,t)}log(e,t,n){this.write(`log`,e,n,t)}warn(e,t,n,r){this.write(`warn`,e,r,t,n)}error(e,t,n,r){this.write(`error`,e,r,t,n)}fatal(e,t,n,r){this.write(`fatal`,e,r,t,n)}setLogLevels(e){this.levels=new Set(e)}},x=class{debug=()=>void 0;verbose=()=>void 0;log=()=>void 0;warn=()=>void 0;error=()=>void 0;fatal=()=>void 0;setLogLevels=()=>void 0},S=class e{em;constructor(e){this.dataSource=e}static newInstance(e){let t=e.constructor;return new t(e.dataSource)}withEntityManager(e){return this.em=e,this}withRepositoryManager(t){return e.newInstance(this).withEntityManager(t.em)}lockInTransaction(e=`pessimistic_write`){return this.em?{mode:e}:void 0}getRepository(e){return this.em?this.em.getRepository(e):this.dataSource.getRepository(e)}async withTransaction(t){let n;return await this.dataSource.transaction(async r=>{n=await t(e.newInstance(this).withEntityManager(r))}),n}},C=e=>({...e,withTransaction:async t=>await t(e),withRepositoryManager:()=>e}),w=(e,t)=>`unaccent(LOWER(${e})) ILIKE unaccent(LOWER(:${t}))`,T=s({unaccentSearch:()=>w});exports.GCPLogger=b,exports.LogLevelToConsoleMethodMap=_,exports.MockLogger=x,exports.TransactionalRepository=S,exports.buildTransactionalRepositoryMock=C,exports.loadEnvConfig=h,Object.defineProperty(exports,`postgres`,{enumerable:!0,get:function(){return T}});
package/dist/index.mjs CHANGED
@@ -1,531 +1,497 @@
1
- import j from "path";
2
- import { fileURLToPath as k } from "url";
3
- import z from "fs";
4
- import W from "os";
5
- import Q from "crypto";
6
- function H(h) {
7
- return h && h.__esModule && Object.prototype.hasOwnProperty.call(h, "default") ? h.default : h;
8
- }
9
- var S = { exports: {} };
10
- const X = "17.3.1", Z = {
11
- version: X
12
- };
13
- var G;
14
- function ee() {
15
- if (G) return S.exports;
16
- G = 1;
17
- const h = z, t = j, n = W, c = Q, N = Z.version, O = [
18
- "🔐 encrypt with Dotenvx: https://dotenvx.com",
19
- "🔐 prevent committing .env to code: https://dotenvx.com/precommit",
20
- "🔐 prevent building .env in docker: https://dotenvx.com/prebuild",
21
- "🤖 agentic secret storage: https://dotenvx.com/as2",
22
- "⚡️ secrets for agents: https://dotenvx.com/as2",
23
- "🛡️ auth for agents: https://vestauth.com",
24
- "🛠️ run anywhere with `dotenvx run -- yourcommand`",
25
- "⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
26
- "⚙️ enable debug logging with { debug: true }",
27
- "⚙️ override existing env vars with { override: true }",
28
- "⚙️ suppress all logs with { quiet: true }",
29
- "⚙️ write to custom object with { processEnv: myObject }",
30
- "⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
31
- ];
32
- function L() {
33
- return O[Math.floor(Math.random() * O.length)];
34
- }
35
- function b(e) {
36
- return typeof e == "string" ? !["false", "0", "no", "off", ""].includes(e.toLowerCase()) : !!e;
37
- }
38
- function D() {
39
- return process.stdout.isTTY;
40
- }
41
- function A(e) {
42
- return D() ? `\x1B[2m${e}\x1B[0m` : e;
43
- }
44
- const M = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
45
- function r(e) {
46
- const a = {};
47
- let l = e.toString();
48
- l = l.replace(/\r\n?/mg, `
49
- `);
50
- let d;
51
- for (; (d = M.exec(l)) != null; ) {
52
- const E = d[1];
53
- let g = d[2] || "";
54
- g = g.trim();
55
- const o = g[0];
56
- g = g.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), o === '"' && (g = g.replace(/\\n/g, `
57
- `), g = g.replace(/\\r/g, "\r")), a[E] = g;
58
- }
59
- return a;
60
- }
61
- function u(e) {
62
- e = e || {};
63
- const a = s(e);
64
- e.path = a;
65
- const l = _.configDotenv(e);
66
- if (!l.parsed) {
67
- const o = new Error(`MISSING_DATA: Cannot parse ${a} for an unknown reason`);
68
- throw o.code = "MISSING_DATA", o;
69
- }
70
- const d = y(e).split(","), E = d.length;
71
- let g;
72
- for (let o = 0; o < E; o++)
73
- try {
74
- const m = d[o].trim(), T = v(l, m);
75
- g = _.decrypt(T.ciphertext, T.key);
76
- break;
77
- } catch (m) {
78
- if (o + 1 >= E)
79
- throw m;
80
- }
81
- return _.parse(g);
82
- }
83
- function p(e) {
84
- console.error(`[dotenv@${N}][WARN] ${e}`);
85
- }
86
- function i(e) {
87
- console.log(`[dotenv@${N}][DEBUG] ${e}`);
88
- }
89
- function f(e) {
90
- console.log(`[dotenv@${N}] ${e}`);
91
- }
92
- function y(e) {
93
- return e && e.DOTENV_KEY && e.DOTENV_KEY.length > 0 ? e.DOTENV_KEY : process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0 ? process.env.DOTENV_KEY : "";
94
- }
95
- function v(e, a) {
96
- let l;
97
- try {
98
- l = new URL(a);
99
- } catch (m) {
100
- if (m.code === "ERR_INVALID_URL") {
101
- const T = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
102
- throw T.code = "INVALID_DOTENV_KEY", T;
103
- }
104
- throw m;
105
- }
106
- const d = l.password;
107
- if (!d) {
108
- const m = new Error("INVALID_DOTENV_KEY: Missing key part");
109
- throw m.code = "INVALID_DOTENV_KEY", m;
110
- }
111
- const E = l.searchParams.get("environment");
112
- if (!E) {
113
- const m = new Error("INVALID_DOTENV_KEY: Missing environment part");
114
- throw m.code = "INVALID_DOTENV_KEY", m;
115
- }
116
- const g = `DOTENV_VAULT_${E.toUpperCase()}`, o = e.parsed[g];
117
- if (!o) {
118
- const m = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${g} in your .env.vault file.`);
119
- throw m.code = "NOT_FOUND_DOTENV_ENVIRONMENT", m;
120
- }
121
- return { ciphertext: o, key: d };
122
- }
123
- function s(e) {
124
- let a = null;
125
- if (e && e.path && e.path.length > 0)
126
- if (Array.isArray(e.path))
127
- for (const l of e.path)
128
- h.existsSync(l) && (a = l.endsWith(".vault") ? l : `${l}.vault`);
129
- else
130
- a = e.path.endsWith(".vault") ? e.path : `${e.path}.vault`;
131
- else
132
- a = t.resolve(process.cwd(), ".env.vault");
133
- return h.existsSync(a) ? a : null;
134
- }
135
- function V(e) {
136
- return e[0] === "~" ? t.join(n.homedir(), e.slice(1)) : e;
137
- }
138
- function $(e) {
139
- const a = b(process.env.DOTENV_CONFIG_DEBUG || e && e.debug), l = b(process.env.DOTENV_CONFIG_QUIET || e && e.quiet);
140
- (a || !l) && f("Loading env from encrypted .env.vault");
141
- const d = _._parseVault(e);
142
- let E = process.env;
143
- return e && e.processEnv != null && (E = e.processEnv), _.populate(E, d, e), { parsed: d };
144
- }
145
- function x(e) {
146
- const a = t.resolve(process.cwd(), ".env");
147
- let l = "utf8", d = process.env;
148
- e && e.processEnv != null && (d = e.processEnv);
149
- let E = b(d.DOTENV_CONFIG_DEBUG || e && e.debug), g = b(d.DOTENV_CONFIG_QUIET || e && e.quiet);
150
- e && e.encoding ? l = e.encoding : E && i("No encoding is specified. UTF-8 is used by default");
151
- let o = [a];
152
- if (e && e.path)
153
- if (!Array.isArray(e.path))
154
- o = [V(e.path)];
155
- else {
156
- o = [];
157
- for (const I of e.path)
158
- o.push(V(I));
159
- }
160
- let m;
161
- const T = {};
162
- for (const I of o)
163
- try {
164
- const R = _.parse(h.readFileSync(I, { encoding: l }));
165
- _.populate(T, R, e);
166
- } catch (R) {
167
- E && i(`Failed to load ${I} ${R.message}`), m = R;
168
- }
169
- const P = _.populate(d, T, e);
170
- if (E = b(d.DOTENV_CONFIG_DEBUG || E), g = b(d.DOTENV_CONFIG_QUIET || g), E || !g) {
171
- const I = Object.keys(P).length, R = [];
172
- for (const U of o)
173
- try {
174
- const C = t.relative(process.cwd(), U);
175
- R.push(C);
176
- } catch (C) {
177
- E && i(`Failed to load ${U} ${C.message}`), m = C;
178
- }
179
- f(`injecting env (${I}) from ${R.join(",")} ${A(`-- tip: ${L()}`)}`);
180
- }
181
- return m ? { parsed: T, error: m } : { parsed: T };
182
- }
183
- function K(e) {
184
- if (y(e).length === 0)
185
- return _.configDotenv(e);
186
- const a = s(e);
187
- return a ? _._configVault(e) : (p(`You set DOTENV_KEY but you are missing a .env.vault file at ${a}. Did you forget to build it?`), _.configDotenv(e));
188
- }
189
- function q(e, a) {
190
- const l = Buffer.from(a.slice(-64), "hex");
191
- let d = Buffer.from(e, "base64");
192
- const E = d.subarray(0, 12), g = d.subarray(-16);
193
- d = d.subarray(12, -16);
194
- try {
195
- const o = c.createDecipheriv("aes-256-gcm", l, E);
196
- return o.setAuthTag(g), `${o.update(d)}${o.final()}`;
197
- } catch (o) {
198
- const m = o instanceof RangeError, T = o.message === "Invalid key length", P = o.message === "Unsupported state or unable to authenticate data";
199
- if (m || T) {
200
- const I = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
201
- throw I.code = "INVALID_DOTENV_KEY", I;
202
- } else if (P) {
203
- const I = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
204
- throw I.code = "DECRYPTION_FAILED", I;
205
- } else
206
- throw o;
207
- }
208
- }
209
- function J(e, a, l = {}) {
210
- const d = !!(l && l.debug), E = !!(l && l.override), g = {};
211
- if (typeof a != "object") {
212
- const o = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
213
- throw o.code = "OBJECT_REQUIRED", o;
214
- }
215
- for (const o of Object.keys(a))
216
- Object.prototype.hasOwnProperty.call(e, o) ? (E === !0 && (e[o] = a[o], g[o] = a[o]), d && i(E === !0 ? `"${o}" is already defined and WAS overwritten` : `"${o}" is already defined and was NOT overwritten`)) : (e[o] = a[o], g[o] = a[o]);
217
- return g;
218
- }
219
- const _ = {
220
- configDotenv: x,
221
- _configVault: $,
222
- _parseVault: u,
223
- config: K,
224
- decrypt: q,
225
- parse: r,
226
- populate: J
227
- };
228
- return S.exports.configDotenv = _.configDotenv, S.exports._configVault = _._configVault, S.exports._parseVault = _._parseVault, S.exports.config = _.config, S.exports.decrypt = _.decrypt, S.exports.parse = _.parse, S.exports.populate = _.populate, S.exports = _, S.exports;
229
- }
230
- var te = ee();
231
- const re = k(import.meta.url), ne = j.dirname(re), ye = (h = {}) => {
232
- const { env: t, configPath: n } = h, c = j.resolve(ne, `${n ?? "."}/.env${t ? `.${t}` : ""}`), { parsed: w } = te.config({ path: c });
233
- return w;
234
- };
235
- var F, B;
236
- function oe() {
237
- if (B) return F;
238
- B = 1, F = N, N.default = N, N.stable = D, N.stableStringify = D;
239
- var h = "[...]", t = "[Circular]", n = [], c = [];
240
- function w() {
241
- return {
242
- depthLimit: Number.MAX_SAFE_INTEGER,
243
- edgesLimit: Number.MAX_SAFE_INTEGER
244
- };
245
- }
246
- function N(r, u, p, i) {
247
- typeof i > "u" && (i = w()), L(r, "", 0, [], void 0, 0, i);
248
- var f;
249
- try {
250
- c.length === 0 ? f = JSON.stringify(r, u, p) : f = JSON.stringify(r, M(u), p);
251
- } catch {
252
- return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]");
253
- } finally {
254
- for (; n.length !== 0; ) {
255
- var y = n.pop();
256
- y.length === 4 ? Object.defineProperty(y[0], y[1], y[3]) : y[0][y[1]] = y[2];
257
- }
258
- }
259
- return f;
260
- }
261
- function O(r, u, p, i) {
262
- var f = Object.getOwnPropertyDescriptor(i, p);
263
- f.get !== void 0 ? f.configurable ? (Object.defineProperty(i, p, { value: r }), n.push([i, p, u, f])) : c.push([u, p, r]) : (i[p] = r, n.push([i, p, u]));
264
- }
265
- function L(r, u, p, i, f, y, v) {
266
- y += 1;
267
- var s;
268
- if (typeof r == "object" && r !== null) {
269
- for (s = 0; s < i.length; s++)
270
- if (i[s] === r) {
271
- O(t, r, u, f);
272
- return;
273
- }
274
- if (typeof v.depthLimit < "u" && y > v.depthLimit) {
275
- O(h, r, u, f);
276
- return;
277
- }
278
- if (typeof v.edgesLimit < "u" && p + 1 > v.edgesLimit) {
279
- O(h, r, u, f);
280
- return;
281
- }
282
- if (i.push(r), Array.isArray(r))
283
- for (s = 0; s < r.length; s++)
284
- L(r[s], s, s, i, r, y, v);
285
- else {
286
- var V = Object.keys(r);
287
- for (s = 0; s < V.length; s++) {
288
- var $ = V[s];
289
- L(r[$], $, s, i, r, y, v);
290
- }
291
- }
292
- i.pop();
293
- }
294
- }
295
- function b(r, u) {
296
- return r < u ? -1 : r > u ? 1 : 0;
297
- }
298
- function D(r, u, p, i) {
299
- typeof i > "u" && (i = w());
300
- var f = A(r, "", 0, [], void 0, 0, i) || r, y;
301
- try {
302
- c.length === 0 ? y = JSON.stringify(f, u, p) : y = JSON.stringify(f, M(u), p);
303
- } catch {
304
- return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]");
305
- } finally {
306
- for (; n.length !== 0; ) {
307
- var v = n.pop();
308
- v.length === 4 ? Object.defineProperty(v[0], v[1], v[3]) : v[0][v[1]] = v[2];
309
- }
310
- }
311
- return y;
312
- }
313
- function A(r, u, p, i, f, y, v) {
314
- y += 1;
315
- var s;
316
- if (typeof r == "object" && r !== null) {
317
- for (s = 0; s < i.length; s++)
318
- if (i[s] === r) {
319
- O(t, r, u, f);
320
- return;
321
- }
322
- try {
323
- if (typeof r.toJSON == "function")
324
- return;
325
- } catch {
326
- return;
327
- }
328
- if (typeof v.depthLimit < "u" && y > v.depthLimit) {
329
- O(h, r, u, f);
330
- return;
331
- }
332
- if (typeof v.edgesLimit < "u" && p + 1 > v.edgesLimit) {
333
- O(h, r, u, f);
334
- return;
335
- }
336
- if (i.push(r), Array.isArray(r))
337
- for (s = 0; s < r.length; s++)
338
- A(r[s], s, s, i, r, y, v);
339
- else {
340
- var V = {}, $ = Object.keys(r).sort(b);
341
- for (s = 0; s < $.length; s++) {
342
- var x = $[s];
343
- A(r[x], x, s, i, r, y, v), V[x] = r[x];
344
- }
345
- if (typeof f < "u")
346
- n.push([f, u, r]), f[u] = V;
347
- else
348
- return V;
349
- }
350
- i.pop();
351
- }
352
- }
353
- function M(r) {
354
- return r = typeof r < "u" ? r : function(u, p) {
355
- return p;
356
- }, function(u, p) {
357
- if (c.length > 0)
358
- for (var i = 0; i < c.length; i++) {
359
- var f = c[i];
360
- if (f[1] === u && f[0] === p) {
361
- p = f[2], c.splice(i, 1);
362
- break;
363
- }
364
- }
365
- return r.call(this, u, p);
366
- };
367
- }
368
- return F;
369
- }
370
- var ie = oe();
371
- const se = /* @__PURE__ */ H(ie), ce = {
372
- debug: "debug",
373
- verbose: "debug",
374
- log: "log",
375
- warn: "warn",
376
- error: "error",
377
- fatal: "error"
378
- }, ae = {
379
- verbose: "DEFAULT",
380
- debug: "DEBUG",
381
- log: "INFO",
382
- warn: "WARNING",
383
- error: "ERROR",
384
- fatal: "CRITICAL"
385
- }, ue = [
386
- "x-api-key",
387
- "x-api-token",
388
- "x-key",
389
- "x-token",
390
- "cookie",
391
- "password",
392
- "pass",
393
- "psw",
394
- "auth",
395
- "authentication",
396
- "authorization",
397
- "token",
398
- "access_token",
399
- "client-secret",
400
- "credentials",
401
- "secret"
402
- ];
403
- class ve {
404
- constructor(t, n = {}) {
405
- this.module = t, n.logLevels && (this.levels = new Set(n.logLevels));
406
- }
407
- levels = /* @__PURE__ */ new Set(["verbose", "debug", "log", "warn", "error", "fatal"]);
408
- mapLogLevelToConsoleMethod(t) {
409
- return ce[t];
410
- }
411
- write(t, n, c, w, N) {
412
- if (!this.levels.has(t))
413
- return;
414
- const O = this.buildLog(t, n, c, w, N), L = se(O, this.sensitiveReplacer), b = this.mapLogLevelToConsoleMethod(t);
415
- console[b](L);
416
- }
417
- buildLog(t, n, c, w, N) {
418
- const { writeMetadata: O, writeContext: L, writeError: b } = this.sanitizeLog(c, w, N), D = {};
419
- return typeof n == "string" && (D.textPayload = n), !O && typeof n != "string" && !(n instanceof Error) && (D.metadata = n), n instanceof Error && (D.error = JSON.stringify(n, Object.getOwnPropertyNames(n))), L && (D.context = L), O && (D.metadata = O), !D.error && b && (D.error = JSON.stringify(b, Object.getOwnPropertyNames(b))), {
420
- severity: ae[t],
421
- module: this.module,
422
- textPayload: D.textPayload,
423
- message: D
424
- };
425
- }
426
- sanitizeLog(t, n, c) {
427
- if (n instanceof Error && (!c || typeof c == "string"))
428
- return {
429
- writeMetadata: void 0,
430
- writeContext: t || c,
431
- writeError: n
432
- };
433
- let w = n, N = t;
434
- return typeof w == "string" && !t && (N = w, w = void 0), {
435
- writeMetadata: w,
436
- writeContext: N,
437
- writeError: c
438
- };
439
- }
440
- sensitiveReplacer(t, n) {
441
- return ue.includes(t.toLowerCase()) ? "[HIDDEN BY LOGGER]" : n;
442
- }
443
- debug(t, n, c) {
444
- this.write("debug", t, c, n);
445
- }
446
- verbose(t, n, c) {
447
- this.write("verbose", t, c, n);
448
- }
449
- log(t, n, c) {
450
- this.write("log", t, c, n);
451
- }
452
- warn(t, n, c, w) {
453
- this.write("warn", t, w, n, c);
454
- }
455
- error(t, n, c, w) {
456
- this.write("error", t, w, n, c);
457
- }
458
- fatal(t, n, c, w) {
459
- this.write("fatal", t, w, n, c);
460
- }
461
- setLogLevels(t) {
462
- this.levels = new Set(t);
463
- }
464
- }
465
- class Ee {
466
- debug = () => {
467
- };
468
- verbose = () => {
469
- };
470
- log = () => {
471
- };
472
- warn = () => {
473
- };
474
- error = () => {
475
- };
476
- fatal = () => {
477
- };
478
- setLogLevels = () => {
479
- };
480
- }
481
- class Y {
482
- constructor(t) {
483
- this.dataSource = t;
484
- }
485
- em;
486
- static newInstance(t) {
487
- const n = t.constructor;
488
- return new n(t.dataSource);
489
- }
490
- withEntityManager(t) {
491
- return this.em = t, this;
492
- }
493
- withRepositoryManager(t) {
494
- return Y.newInstance(this).withEntityManager(
495
- t.em
496
- );
497
- }
498
- lockInTransaction(t = "pessimistic_write") {
499
- return this.em ? {
500
- mode: t
501
- } : void 0;
502
- }
503
- getRepository(t) {
504
- return this.em ? this.em.getRepository(t) : this.dataSource.getRepository(t);
505
- }
506
- async withTransaction(t) {
507
- let n;
508
- return await this.dataSource.transaction(async (c) => {
509
- n = await t(
510
- Y.newInstance(this).withEntityManager(c)
511
- );
512
- }), n;
513
- }
514
- }
515
- const me = (h) => ({
516
- ...h,
517
- withTransaction: async (t) => await t(h),
518
- withRepositoryManager: () => h
519
- }), fe = (h, t) => `unaccent(LOWER(${h})) ILIKE unaccent(LOWER(:${t}))`, we = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
520
- __proto__: null,
521
- unaccentSearch: fe
522
- }, Symbol.toStringTag, { value: "Module" }));
523
- export {
524
- ve as GCPLogger,
525
- ce as LogLevelToConsoleMethodMap,
526
- Ee as MockLogger,
527
- Y as TransactionalRepository,
528
- me as buildTransactionalRepositoryMock,
529
- ye as loadEnvConfig,
530
- we as postgres
531
- };
1
+ import e from "path";
2
+ import { fileURLToPath as t } from "url";
3
+ //#region \0rolldown/runtime.js
4
+ var n = Object.create, r = Object.defineProperty, i = Object.getOwnPropertyDescriptor, a = Object.getOwnPropertyNames, o = Object.getPrototypeOf, s = Object.prototype.hasOwnProperty, c = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), l = (e, t) => {
5
+ let n = {};
6
+ for (var i in e) r(n, i, {
7
+ get: e[i],
8
+ enumerable: !0
9
+ });
10
+ return t || r(n, Symbol.toStringTag, { value: "Module" }), n;
11
+ }, u = (e, t, n, o) => {
12
+ if (t && typeof t == "object" || typeof t == "function") for (var c = a(t), l = 0, u = c.length, d; l < u; l++) d = c[l], !s.call(e, d) && d !== n && r(e, d, {
13
+ get: ((e) => t[e]).bind(null, d),
14
+ enumerable: !(o = i(t, d)) || o.enumerable
15
+ });
16
+ return e;
17
+ }, d = (e, t, i) => (i = e == null ? {} : n(o(e)), u(t || !e || !e.__esModule ? r(i, "default", {
18
+ value: e,
19
+ enumerable: !0
20
+ }) : i, e)), f = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
21
+ if (typeof require < "u") return require.apply(this, arguments);
22
+ throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
23
+ }), p = /* @__PURE__ */ d((/* @__PURE__ */ c(((e, t) => {
24
+ var n = f("fs"), r = f("path"), i = f("os"), a = f("crypto"), o = [
25
+ " encrypted .env [www.dotenvx.com]",
26
+ " secrets for agents [www.dotenvx.com]",
27
+ " auth for agents [www.vestauth.com]",
28
+ " custom filepath { path: '/custom/path/.env' }",
29
+ " enable debugging { debug: true }",
30
+ " override existing { override: true }",
31
+ "⌘ suppress logs { quiet: true }",
32
+ "⌘ multiple files { path: ['.env.local', '.env'] }"
33
+ ];
34
+ function s() {
35
+ return o[Math.floor(Math.random() * o.length)];
36
+ }
37
+ function c(e) {
38
+ return typeof e == "string" ? ![
39
+ "false",
40
+ "0",
41
+ "no",
42
+ "off",
43
+ ""
44
+ ].includes(e.toLowerCase()) : !!e;
45
+ }
46
+ function l() {
47
+ return process.stdout.isTTY;
48
+ }
49
+ function u(e) {
50
+ return l() ? `\x1b[2m${e}\x1b[0m` : e;
51
+ }
52
+ var d = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
53
+ function p(e) {
54
+ let t = {}, n = e.toString();
55
+ n = n.replace(/\r\n?/gm, "\n");
56
+ let r;
57
+ for (; (r = d.exec(n)) != null;) {
58
+ let e = r[1], n = r[2] || "";
59
+ n = n.trim();
60
+ let i = n[0];
61
+ n = n.replace(/^(['"`])([\s\S]*)\1$/gm, "$2"), i === "\"" && (n = n.replace(/\\n/g, "\n"), n = n.replace(/\\r/g, "\r")), t[e] = n;
62
+ }
63
+ return t;
64
+ }
65
+ function m(e) {
66
+ e ||= {};
67
+ let t = b(e);
68
+ e.path = t;
69
+ let n = D.configDotenv(e);
70
+ if (!n.parsed) {
71
+ let e = /* @__PURE__ */ Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);
72
+ throw e.code = "MISSING_DATA", e;
73
+ }
74
+ let r = v(e).split(","), i = r.length, a;
75
+ for (let e = 0; e < i; e++) try {
76
+ let t = y(n, r[e].trim());
77
+ a = D.decrypt(t.ciphertext, t.key);
78
+ break;
79
+ } catch (t) {
80
+ if (e + 1 >= i) throw t;
81
+ }
82
+ return D.parse(a);
83
+ }
84
+ function h(e) {
85
+ console.error(`⚠ ${e}`);
86
+ }
87
+ function g(e) {
88
+ console.log(`┆ ${e}`);
89
+ }
90
+ function _(e) {
91
+ console.log(`◇ ${e}`);
92
+ }
93
+ function v(e) {
94
+ return e && e.DOTENV_KEY && e.DOTENV_KEY.length > 0 ? e.DOTENV_KEY : process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0 ? process.env.DOTENV_KEY : "";
95
+ }
96
+ function y(e, t) {
97
+ let n;
98
+ try {
99
+ n = new URL(t);
100
+ } catch (e) {
101
+ if (e.code === "ERR_INVALID_URL") {
102
+ let e = /* @__PURE__ */ Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
103
+ throw e.code = "INVALID_DOTENV_KEY", e;
104
+ }
105
+ throw e;
106
+ }
107
+ let r = n.password;
108
+ if (!r) {
109
+ let e = /* @__PURE__ */ Error("INVALID_DOTENV_KEY: Missing key part");
110
+ throw e.code = "INVALID_DOTENV_KEY", e;
111
+ }
112
+ let i = n.searchParams.get("environment");
113
+ if (!i) {
114
+ let e = /* @__PURE__ */ Error("INVALID_DOTENV_KEY: Missing environment part");
115
+ throw e.code = "INVALID_DOTENV_KEY", e;
116
+ }
117
+ let a = `DOTENV_VAULT_${i.toUpperCase()}`, o = e.parsed[a];
118
+ if (!o) {
119
+ let e = /* @__PURE__ */ Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);
120
+ throw e.code = "NOT_FOUND_DOTENV_ENVIRONMENT", e;
121
+ }
122
+ return {
123
+ ciphertext: o,
124
+ key: r
125
+ };
126
+ }
127
+ function b(e) {
128
+ let t = null;
129
+ if (e && e.path && e.path.length > 0) if (Array.isArray(e.path)) for (let r of e.path) n.existsSync(r) && (t = r.endsWith(".vault") ? r : `${r}.vault`);
130
+ else t = e.path.endsWith(".vault") ? e.path : `${e.path}.vault`;
131
+ else t = r.resolve(process.cwd(), ".env.vault");
132
+ return n.existsSync(t) ? t : null;
133
+ }
134
+ function x(e) {
135
+ return e[0] === "~" ? r.join(i.homedir(), e.slice(1)) : e;
136
+ }
137
+ function S(e) {
138
+ let t = c(process.env.DOTENV_CONFIG_DEBUG || e && e.debug), n = c(process.env.DOTENV_CONFIG_QUIET || e && e.quiet);
139
+ (t || !n) && _("loading env from encrypted .env.vault");
140
+ let r = D._parseVault(e), i = process.env;
141
+ return e && e.processEnv != null && (i = e.processEnv), D.populate(i, r, e), { parsed: r };
142
+ }
143
+ function C(e) {
144
+ let t = r.resolve(process.cwd(), ".env"), i = "utf8", a = process.env;
145
+ e && e.processEnv != null && (a = e.processEnv);
146
+ let o = c(a.DOTENV_CONFIG_DEBUG || e && e.debug), l = c(a.DOTENV_CONFIG_QUIET || e && e.quiet);
147
+ e && e.encoding ? i = e.encoding : o && g("no encoding is specified (UTF-8 is used by default)");
148
+ let d = [t];
149
+ if (e && e.path) if (!Array.isArray(e.path)) d = [x(e.path)];
150
+ else {
151
+ d = [];
152
+ for (let t of e.path) d.push(x(t));
153
+ }
154
+ let f, p = {};
155
+ for (let t of d) try {
156
+ let r = D.parse(n.readFileSync(t, { encoding: i }));
157
+ D.populate(p, r, e);
158
+ } catch (e) {
159
+ o && g(`failed to load ${t} ${e.message}`), f = e;
160
+ }
161
+ let m = D.populate(a, p, e);
162
+ if (o = c(a.DOTENV_CONFIG_DEBUG || o), l = c(a.DOTENV_CONFIG_QUIET || l), o || !l) {
163
+ let e = Object.keys(m).length, t = [];
164
+ for (let e of d) try {
165
+ let n = r.relative(process.cwd(), e);
166
+ t.push(n);
167
+ } catch (t) {
168
+ o && g(`failed to load ${e} ${t.message}`), f = t;
169
+ }
170
+ _(`injected env (${e}) from ${t.join(",")} ${u(`// tip: ${s()}`)}`);
171
+ }
172
+ return f ? {
173
+ parsed: p,
174
+ error: f
175
+ } : { parsed: p };
176
+ }
177
+ function w(e) {
178
+ if (v(e).length === 0) return D.configDotenv(e);
179
+ let t = b(e);
180
+ return t ? D._configVault(e) : (h(`you set DOTENV_KEY but you are missing a .env.vault file at ${t}`), D.configDotenv(e));
181
+ }
182
+ function T(e, t) {
183
+ let n = Buffer.from(t.slice(-64), "hex"), r = Buffer.from(e, "base64"), i = r.subarray(0, 12), o = r.subarray(-16);
184
+ r = r.subarray(12, -16);
185
+ try {
186
+ let e = a.createDecipheriv("aes-256-gcm", n, i);
187
+ return e.setAuthTag(o), `${e.update(r)}${e.final()}`;
188
+ } catch (e) {
189
+ let t = e instanceof RangeError, n = e.message === "Invalid key length", r = e.message === "Unsupported state or unable to authenticate data";
190
+ if (t || n) {
191
+ let e = /* @__PURE__ */ Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
192
+ throw e.code = "INVALID_DOTENV_KEY", e;
193
+ } else if (r) {
194
+ let e = /* @__PURE__ */ Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
195
+ throw e.code = "DECRYPTION_FAILED", e;
196
+ } else throw e;
197
+ }
198
+ }
199
+ function E(e, t, n = {}) {
200
+ let r = !!(n && n.debug), i = !!(n && n.override), a = {};
201
+ if (typeof t != "object") {
202
+ let e = /* @__PURE__ */ Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
203
+ throw e.code = "OBJECT_REQUIRED", e;
204
+ }
205
+ for (let n of Object.keys(t)) Object.prototype.hasOwnProperty.call(e, n) ? (i === !0 && (e[n] = t[n], a[n] = t[n]), r && g(i === !0 ? `"${n}" is already defined and WAS overwritten` : `"${n}" is already defined and was NOT overwritten`)) : (e[n] = t[n], a[n] = t[n]);
206
+ return a;
207
+ }
208
+ var D = {
209
+ configDotenv: C,
210
+ _configVault: S,
211
+ _parseVault: m,
212
+ config: w,
213
+ decrypt: T,
214
+ parse: p,
215
+ populate: E
216
+ };
217
+ t.exports.configDotenv = D.configDotenv, t.exports._configVault = D._configVault, t.exports._parseVault = D._parseVault, t.exports.config = D.config, t.exports.decrypt = D.decrypt, t.exports.parse = D.parse, t.exports.populate = D.populate, t.exports = D;
218
+ })))(), 1), m = t(import.meta.url), h = e.dirname(m), g = (t = {}) => {
219
+ let { env: n, configPath: r } = t, i = e.resolve(h, `${r ?? "."}/.env${n ? `.${n}` : ""}`), { parsed: a } = p.config({ path: i });
220
+ return a;
221
+ }, _ = /* @__PURE__ */ d((/* @__PURE__ */ c(((e, t) => {
222
+ t.exports = s, s.default = s, s.stable = d, s.stableStringify = d;
223
+ var n = "[...]", r = "[Circular]", i = [], a = [];
224
+ function o() {
225
+ return {
226
+ depthLimit: 2 ** 53 - 1,
227
+ edgesLimit: 2 ** 53 - 1
228
+ };
229
+ }
230
+ function s(e, t, n, r) {
231
+ r === void 0 && (r = o()), l(e, "", 0, [], void 0, 0, r);
232
+ var s;
233
+ try {
234
+ s = a.length === 0 ? JSON.stringify(e, t, n) : JSON.stringify(e, p(t), n);
235
+ } catch {
236
+ return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]");
237
+ } finally {
238
+ for (; i.length !== 0;) {
239
+ var c = i.pop();
240
+ c.length === 4 ? Object.defineProperty(c[0], c[1], c[3]) : c[0][c[1]] = c[2];
241
+ }
242
+ }
243
+ return s;
244
+ }
245
+ function c(e, t, n, r) {
246
+ var o = Object.getOwnPropertyDescriptor(r, n);
247
+ o.get === void 0 ? (r[n] = e, i.push([
248
+ r,
249
+ n,
250
+ t
251
+ ])) : o.configurable ? (Object.defineProperty(r, n, { value: e }), i.push([
252
+ r,
253
+ n,
254
+ t,
255
+ o
256
+ ])) : a.push([
257
+ t,
258
+ n,
259
+ e
260
+ ]);
261
+ }
262
+ function l(e, t, i, a, o, s, u) {
263
+ s += 1;
264
+ var d;
265
+ if (typeof e == "object" && e) {
266
+ for (d = 0; d < a.length; d++) if (a[d] === e) {
267
+ c(r, e, t, o);
268
+ return;
269
+ }
270
+ if (u.depthLimit !== void 0 && s > u.depthLimit) {
271
+ c(n, e, t, o);
272
+ return;
273
+ }
274
+ if (u.edgesLimit !== void 0 && i + 1 > u.edgesLimit) {
275
+ c(n, e, t, o);
276
+ return;
277
+ }
278
+ if (a.push(e), Array.isArray(e)) for (d = 0; d < e.length; d++) l(e[d], d, d, a, e, s, u);
279
+ else {
280
+ var f = Object.keys(e);
281
+ for (d = 0; d < f.length; d++) {
282
+ var p = f[d];
283
+ l(e[p], p, d, a, e, s, u);
284
+ }
285
+ }
286
+ a.pop();
287
+ }
288
+ }
289
+ function u(e, t) {
290
+ return e < t ? -1 : e > t ? 1 : 0;
291
+ }
292
+ function d(e, t, n, r) {
293
+ r === void 0 && (r = o());
294
+ var s = f(e, "", 0, [], void 0, 0, r) || e, c;
295
+ try {
296
+ c = a.length === 0 ? JSON.stringify(s, t, n) : JSON.stringify(s, p(t), n);
297
+ } catch {
298
+ return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]");
299
+ } finally {
300
+ for (; i.length !== 0;) {
301
+ var l = i.pop();
302
+ l.length === 4 ? Object.defineProperty(l[0], l[1], l[3]) : l[0][l[1]] = l[2];
303
+ }
304
+ }
305
+ return c;
306
+ }
307
+ function f(e, t, a, o, s, l, d) {
308
+ l += 1;
309
+ var p;
310
+ if (typeof e == "object" && e) {
311
+ for (p = 0; p < o.length; p++) if (o[p] === e) {
312
+ c(r, e, t, s);
313
+ return;
314
+ }
315
+ try {
316
+ if (typeof e.toJSON == "function") return;
317
+ } catch {
318
+ return;
319
+ }
320
+ if (d.depthLimit !== void 0 && l > d.depthLimit) {
321
+ c(n, e, t, s);
322
+ return;
323
+ }
324
+ if (d.edgesLimit !== void 0 && a + 1 > d.edgesLimit) {
325
+ c(n, e, t, s);
326
+ return;
327
+ }
328
+ if (o.push(e), Array.isArray(e)) for (p = 0; p < e.length; p++) f(e[p], p, p, o, e, l, d);
329
+ else {
330
+ var m = {}, h = Object.keys(e).sort(u);
331
+ for (p = 0; p < h.length; p++) {
332
+ var g = h[p];
333
+ f(e[g], g, p, o, e, l, d), m[g] = e[g];
334
+ }
335
+ if (s !== void 0) i.push([
336
+ s,
337
+ t,
338
+ e
339
+ ]), s[t] = m;
340
+ else return m;
341
+ }
342
+ o.pop();
343
+ }
344
+ }
345
+ function p(e) {
346
+ return e = e === void 0 ? function(e, t) {
347
+ return t;
348
+ } : e, function(t, n) {
349
+ if (a.length > 0) for (var r = 0; r < a.length; r++) {
350
+ var i = a[r];
351
+ if (i[1] === t && i[0] === n) {
352
+ n = i[2], a.splice(r, 1);
353
+ break;
354
+ }
355
+ }
356
+ return e.call(this, t, n);
357
+ };
358
+ }
359
+ })))(), 1), v = {
360
+ debug: "debug",
361
+ verbose: "debug",
362
+ log: "log",
363
+ warn: "warn",
364
+ error: "error",
365
+ fatal: "error"
366
+ }, y = {
367
+ verbose: "DEFAULT",
368
+ debug: "DEBUG",
369
+ log: "INFO",
370
+ warn: "WARNING",
371
+ error: "ERROR",
372
+ fatal: "CRITICAL"
373
+ }, b = [
374
+ "x-api-key",
375
+ "x-api-token",
376
+ "x-key",
377
+ "x-token",
378
+ "cookie",
379
+ "password",
380
+ "pass",
381
+ "psw",
382
+ "auth",
383
+ "authentication",
384
+ "authorization",
385
+ "token",
386
+ "access_token",
387
+ "client-secret",
388
+ "credentials",
389
+ "secret"
390
+ ], x = class {
391
+ levels = new Set([
392
+ "verbose",
393
+ "debug",
394
+ "log",
395
+ "warn",
396
+ "error",
397
+ "fatal"
398
+ ]);
399
+ constructor(e, t = {}) {
400
+ this.module = e, t.logLevels && (this.levels = new Set(t.logLevels));
401
+ }
402
+ mapLogLevelToConsoleMethod(e) {
403
+ return v[e];
404
+ }
405
+ write(e, t, n, r, i) {
406
+ if (!this.levels.has(e)) return;
407
+ let a = (0, _.default)(this.buildLog(e, t, n, r, i), this.sensitiveReplacer), o = this.mapLogLevelToConsoleMethod(e);
408
+ console[o](a);
409
+ }
410
+ buildLog(e, t, n, r, i) {
411
+ let { writeMetadata: a, writeContext: o, writeError: s } = this.sanitizeLog(n, r, i), c = {};
412
+ return typeof t == "string" && (c.textPayload = t), !a && typeof t != "string" && !(t instanceof Error) && (c.metadata = t), t instanceof Error && (c.error = JSON.stringify(t, Object.getOwnPropertyNames(t))), o && (c.context = o), a && (c.metadata = a), !c.error && s && (c.error = JSON.stringify(s, Object.getOwnPropertyNames(s))), {
413
+ severity: y[e],
414
+ module: this.module,
415
+ textPayload: c.textPayload,
416
+ message: c
417
+ };
418
+ }
419
+ sanitizeLog(e, t, n) {
420
+ if (t instanceof Error && (!n || typeof n == "string")) return {
421
+ writeMetadata: void 0,
422
+ writeContext: e || n,
423
+ writeError: t
424
+ };
425
+ let r = t, i = e;
426
+ return typeof r == "string" && !e && (i = r, r = void 0), {
427
+ writeMetadata: r,
428
+ writeContext: i,
429
+ writeError: n
430
+ };
431
+ }
432
+ sensitiveReplacer(e, t) {
433
+ return b.includes(e.toLowerCase()) ? "[HIDDEN BY LOGGER]" : t;
434
+ }
435
+ debug(e, t, n) {
436
+ this.write("debug", e, n, t);
437
+ }
438
+ verbose(e, t, n) {
439
+ this.write("verbose", e, n, t);
440
+ }
441
+ log(e, t, n) {
442
+ this.write("log", e, n, t);
443
+ }
444
+ warn(e, t, n, r) {
445
+ this.write("warn", e, r, t, n);
446
+ }
447
+ error(e, t, n, r) {
448
+ this.write("error", e, r, t, n);
449
+ }
450
+ fatal(e, t, n, r) {
451
+ this.write("fatal", e, r, t, n);
452
+ }
453
+ setLogLevels(e) {
454
+ this.levels = new Set(e);
455
+ }
456
+ }, S = class {
457
+ debug = () => void 0;
458
+ verbose = () => void 0;
459
+ log = () => void 0;
460
+ warn = () => void 0;
461
+ error = () => void 0;
462
+ fatal = () => void 0;
463
+ setLogLevels = () => void 0;
464
+ }, C = class e {
465
+ em;
466
+ constructor(e) {
467
+ this.dataSource = e;
468
+ }
469
+ static newInstance(e) {
470
+ let t = e.constructor;
471
+ return new t(e.dataSource);
472
+ }
473
+ withEntityManager(e) {
474
+ return this.em = e, this;
475
+ }
476
+ withRepositoryManager(t) {
477
+ return e.newInstance(this).withEntityManager(t.em);
478
+ }
479
+ lockInTransaction(e = "pessimistic_write") {
480
+ return this.em ? { mode: e } : void 0;
481
+ }
482
+ getRepository(e) {
483
+ return this.em ? this.em.getRepository(e) : this.dataSource.getRepository(e);
484
+ }
485
+ async withTransaction(t) {
486
+ let n;
487
+ return await this.dataSource.transaction(async (r) => {
488
+ n = await t(e.newInstance(this).withEntityManager(r));
489
+ }), n;
490
+ }
491
+ }, w = (e) => ({
492
+ ...e,
493
+ withTransaction: async (t) => await t(e),
494
+ withRepositoryManager: () => e
495
+ }), T = (e, t) => `unaccent(LOWER(${e})) ILIKE unaccent(LOWER(:${t}))`, E = /* @__PURE__ */ l({ unaccentSearch: () => T });
496
+ //#endregion
497
+ export { x as GCPLogger, v as LogLevelToConsoleMethodMap, S as MockLogger, C as TransactionalRepository, w as buildTransactionalRepositoryMock, g as loadEnvConfig, E as postgres };
@@ -1,4 +1,4 @@
1
1
  export interface TransactionalEntity<T = unknown> {
2
2
  withTransaction: (executer: (entity: T) => Promise<void>) => Promise<void>;
3
- withRepositoryManager: (repositoryManager: TransactionalEntity) => this;
3
+ withRepositoryManager: (repositoryManager: T) => this;
4
4
  }
@@ -1,2 +1,3 @@
1
- export * from '../ts-nodejs/src/index'
2
- export {}
1
+ export * from './env/env.loader';
2
+ export * from './logger';
3
+ export * from './database';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsfsi-core/ts-nodejs",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "scripts": {
26
- "build": "npm run lint && tsc && vite build",
26
+ "build": "npm run lint && tsc --noEmit && vite build",
27
27
  "build:watch": "tsc && (tsc --watch & vite build --watch)",
28
28
  "clean": "rm -rf dist && rm -rf node_modules && rm -rf coverage",
29
29
  "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@jsfsi-core/ts-crossplatform": "file:../ts-crossplatform",
38
- "dotenv": "17.3.1",
38
+ "dotenv": "17.4.1",
39
39
  "fast-safe-stringify": "2.1.1",
40
40
  "typeorm": "0.3.28"
41
41
  },
42
42
  "devDependencies": {
43
- "@vitest/coverage-v8": "4.0.18",
44
- "vite": "7.3.1",
43
+ "@vitest/coverage-v8": "4.1.2",
44
+ "vite": "^8.0.5",
45
45
  "vite-plugin-dts": "4.5.4",
46
- "vitest": "4.0.18"
46
+ "vitest": "4.1.2"
47
47
  }
48
48
  }
@@ -1,3 +0,0 @@
1
- export * from './env/env.loader';
2
- export * from './logger';
3
- export * from './database';
File without changes
File without changes
File without changes
File without changes