@jsfsi-core/ts-nodejs 1.0.7 → 1.0.9

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