@jsfsi-core/ts-nodejs 1.0.7 → 1.0.11
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 +3 -3
- package/dist/index.mjs +287 -264
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`);let
|
|
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
|
|
2
|
-
import { fileURLToPath as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
function
|
|
7
|
-
return
|
|
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
|
|
10
|
-
const
|
|
11
|
-
version:
|
|
9
|
+
var S = { exports: {} };
|
|
10
|
+
const X = "17.2.0", Z = {
|
|
11
|
+
version: X
|
|
12
12
|
};
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
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
|
|
21
|
-
|
|
44
|
+
let l = e.toString();
|
|
45
|
+
l = l.replace(/\r\n?/mg, `
|
|
22
46
|
`);
|
|
23
|
-
let
|
|
24
|
-
for (; (
|
|
25
|
-
const
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
const o =
|
|
29
|
-
|
|
30
|
-
`),
|
|
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
|
|
58
|
+
function u(e) {
|
|
35
59
|
e = e || {};
|
|
36
|
-
const a =
|
|
60
|
+
const a = s(e);
|
|
37
61
|
e.path = a;
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
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
|
|
44
|
-
let
|
|
45
|
-
for (let o = 0; 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
|
|
48
|
-
|
|
71
|
+
const m = d[o].trim(), T = E(l, m);
|
|
72
|
+
g = _.decrypt(T.ciphertext, T.key);
|
|
49
73
|
break;
|
|
50
|
-
} catch (
|
|
51
|
-
if (o + 1 >=
|
|
52
|
-
throw
|
|
74
|
+
} catch (m) {
|
|
75
|
+
if (o + 1 >= v)
|
|
76
|
+
throw m;
|
|
53
77
|
}
|
|
54
|
-
return
|
|
78
|
+
return _.parse(g);
|
|
55
79
|
}
|
|
56
|
-
function
|
|
80
|
+
function p(e) {
|
|
57
81
|
console.error(`[dotenv@${N}][WARN] ${e}`);
|
|
58
82
|
}
|
|
59
|
-
function
|
|
83
|
+
function i(e) {
|
|
60
84
|
console.log(`[dotenv@${N}][DEBUG] ${e}`);
|
|
61
85
|
}
|
|
62
|
-
function
|
|
86
|
+
function f(e) {
|
|
63
87
|
console.log(`[dotenv@${N}] ${e}`);
|
|
64
88
|
}
|
|
65
|
-
function
|
|
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
|
|
69
|
-
let
|
|
92
|
+
function E(e, a) {
|
|
93
|
+
let l;
|
|
70
94
|
try {
|
|
71
|
-
|
|
72
|
-
} catch (
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
throw
|
|
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
|
|
101
|
+
throw m;
|
|
78
102
|
}
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const
|
|
82
|
-
throw
|
|
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
|
|
85
|
-
if (!
|
|
86
|
-
const
|
|
87
|
-
throw
|
|
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
|
|
113
|
+
const g = `DOTENV_VAULT_${v.toUpperCase()}`, o = e.parsed[g];
|
|
90
114
|
if (!o) {
|
|
91
|
-
const
|
|
92
|
-
throw
|
|
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:
|
|
118
|
+
return { ciphertext: o, key: d };
|
|
95
119
|
}
|
|
96
|
-
function
|
|
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
|
|
101
|
-
|
|
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
|
|
130
|
+
return h.existsSync(a) ? a : null;
|
|
107
131
|
}
|
|
108
|
-
function
|
|
132
|
+
function V(e) {
|
|
109
133
|
return e[0] === "~" ? t.join(n.homedir(), e.slice(1)) : e;
|
|
110
134
|
}
|
|
111
|
-
function
|
|
112
|
-
const a =
|
|
113
|
-
(a || !
|
|
114
|
-
const
|
|
115
|
-
let
|
|
116
|
-
return e && e.processEnv != null && (
|
|
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
|
|
142
|
+
function x(e) {
|
|
119
143
|
const a = t.resolve(process.cwd(), ".env");
|
|
120
|
-
let
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
151
|
+
o = [V(e.path)];
|
|
127
152
|
else {
|
|
128
|
-
|
|
129
|
-
for (const
|
|
130
|
-
|
|
153
|
+
o = [];
|
|
154
|
+
for (const I of e.path)
|
|
155
|
+
o.push(V(I));
|
|
131
156
|
}
|
|
132
|
-
let
|
|
133
|
-
const
|
|
134
|
-
for (const
|
|
157
|
+
let m;
|
|
158
|
+
const T = {};
|
|
159
|
+
for (const I of o)
|
|
135
160
|
try {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
} catch (
|
|
139
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
149
|
-
|
|
150
|
-
} catch (
|
|
151
|
-
|
|
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
|
-
|
|
176
|
+
f(`injecting env (${I}) from ${R.join(",")} ${A(`(tip: ${L()})`)}`);
|
|
154
177
|
}
|
|
155
|
-
return
|
|
156
|
-
}
|
|
157
|
-
function
|
|
158
|
-
if (
|
|
159
|
-
return
|
|
160
|
-
const a =
|
|
161
|
-
return a ?
|
|
162
|
-
}
|
|
163
|
-
function
|
|
164
|
-
const
|
|
165
|
-
let
|
|
166
|
-
const
|
|
167
|
-
|
|
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 =
|
|
170
|
-
return o.setAuthTag(
|
|
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
|
|
173
|
-
if (
|
|
174
|
-
const
|
|
175
|
-
throw
|
|
176
|
-
} else if (
|
|
177
|
-
const
|
|
178
|
-
throw
|
|
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
|
|
184
|
-
const
|
|
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) ? (
|
|
191
|
-
return
|
|
192
|
-
}
|
|
193
|
-
const
|
|
194
|
-
configDotenv:
|
|
195
|
-
_configVault:
|
|
196
|
-
_parseVault:
|
|
197
|
-
config:
|
|
198
|
-
decrypt:
|
|
199
|
-
parse:
|
|
200
|
-
populate:
|
|
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
|
|
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
|
|
205
|
-
const
|
|
206
|
-
const { env: t, configPath: n } =
|
|
207
|
-
return
|
|
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
|
|
210
|
-
function
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
var
|
|
214
|
-
function
|
|
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,
|
|
221
|
-
typeof i > "u" && (i =
|
|
222
|
-
var
|
|
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
|
-
|
|
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
|
|
230
|
-
|
|
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
|
|
256
|
+
return f;
|
|
234
257
|
}
|
|
235
|
-
function O(r, u,
|
|
236
|
-
var
|
|
237
|
-
|
|
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
|
|
240
|
-
|
|
241
|
-
var
|
|
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 (
|
|
244
|
-
if (i[
|
|
245
|
-
O(t, r, u,
|
|
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
|
|
249
|
-
O(
|
|
271
|
+
if (typeof E.depthLimit < "u" && y > E.depthLimit) {
|
|
272
|
+
O(h, r, u, f);
|
|
250
273
|
return;
|
|
251
274
|
}
|
|
252
|
-
if (typeof
|
|
253
|
-
O(
|
|
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 (
|
|
258
|
-
|
|
280
|
+
for (s = 0; s < r.length; s++)
|
|
281
|
+
L(r[s], s, s, i, r, y, E);
|
|
259
282
|
else {
|
|
260
|
-
var
|
|
261
|
-
for (
|
|
262
|
-
var
|
|
263
|
-
|
|
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
|
|
292
|
+
function b(r, u) {
|
|
270
293
|
return r < u ? -1 : r > u ? 1 : 0;
|
|
271
294
|
}
|
|
272
|
-
function
|
|
273
|
-
typeof i > "u" && (i =
|
|
274
|
-
var
|
|
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
|
-
|
|
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
|
|
282
|
-
|
|
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
|
|
308
|
+
return y;
|
|
286
309
|
}
|
|
287
|
-
function
|
|
288
|
-
|
|
289
|
-
var
|
|
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 (
|
|
292
|
-
if (i[
|
|
293
|
-
O(t, r, u,
|
|
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
|
|
303
|
-
O(
|
|
325
|
+
if (typeof E.depthLimit < "u" && y > E.depthLimit) {
|
|
326
|
+
O(h, r, u, f);
|
|
304
327
|
return;
|
|
305
328
|
}
|
|
306
|
-
if (typeof
|
|
307
|
-
O(
|
|
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 (
|
|
312
|
-
|
|
334
|
+
for (s = 0; s < r.length; s++)
|
|
335
|
+
A(r[s], s, s, i, r, y, E);
|
|
313
336
|
else {
|
|
314
|
-
var
|
|
315
|
-
for (
|
|
316
|
-
var
|
|
317
|
-
|
|
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
|
|
320
|
-
n.push([
|
|
342
|
+
if (typeof f < "u")
|
|
343
|
+
n.push([f, u, r]), f[u] = V;
|
|
321
344
|
else
|
|
322
|
-
return
|
|
345
|
+
return V;
|
|
323
346
|
}
|
|
324
347
|
i.pop();
|
|
325
348
|
}
|
|
326
349
|
}
|
|
327
|
-
function
|
|
328
|
-
return r = typeof r < "u" ? r : function(u,
|
|
329
|
-
return
|
|
330
|
-
}, function(u,
|
|
331
|
-
if (
|
|
332
|
-
for (var i = 0; i <
|
|
333
|
-
var
|
|
334
|
-
if (
|
|
335
|
-
|
|
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,
|
|
362
|
+
return r.call(this, u, p);
|
|
340
363
|
};
|
|
341
364
|
}
|
|
342
|
-
return
|
|
365
|
+
return F;
|
|
343
366
|
}
|
|
344
|
-
var
|
|
345
|
-
const
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
|
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
|
|
406
|
+
return ce[t];
|
|
384
407
|
}
|
|
385
|
-
write(t, 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,
|
|
389
|
-
console[
|
|
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,
|
|
392
|
-
const { writeMetadata: O, writeContext:
|
|
393
|
-
return typeof n == "string" && (
|
|
394
|
-
severity:
|
|
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:
|
|
397
|
-
message:
|
|
419
|
+
textPayload: D.textPayload,
|
|
420
|
+
message: D
|
|
398
421
|
};
|
|
399
422
|
}
|
|
400
|
-
sanitizeLog(t, n,
|
|
401
|
-
if (n instanceof Error && (!
|
|
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 ||
|
|
427
|
+
writeContext: t || c,
|
|
405
428
|
writeError: n
|
|
406
429
|
};
|
|
407
|
-
let
|
|
408
|
-
return typeof
|
|
409
|
-
writeMetadata:
|
|
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:
|
|
434
|
+
writeError: c
|
|
412
435
|
};
|
|
413
436
|
}
|
|
414
437
|
sensitiveReplacer(t, n) {
|
|
415
|
-
return
|
|
438
|
+
return ue.includes(t.toLowerCase()) ? "[HIDDEN BY LOGGER]" : n;
|
|
416
439
|
}
|
|
417
|
-
debug(t, n,
|
|
418
|
-
this.write("debug", t,
|
|
440
|
+
debug(t, n, c) {
|
|
441
|
+
this.write("debug", t, c, n);
|
|
419
442
|
}
|
|
420
|
-
verbose(t, n,
|
|
421
|
-
this.write("verbose", t,
|
|
443
|
+
verbose(t, n, c) {
|
|
444
|
+
this.write("verbose", t, c, n);
|
|
422
445
|
}
|
|
423
|
-
log(t, n,
|
|
424
|
-
this.write("log", t,
|
|
446
|
+
log(t, n, c) {
|
|
447
|
+
this.write("log", t, c, n);
|
|
425
448
|
}
|
|
426
|
-
warn(t, n,
|
|
427
|
-
this.write("warn", t,
|
|
449
|
+
warn(t, n, c, w) {
|
|
450
|
+
this.write("warn", t, w, n, c);
|
|
428
451
|
}
|
|
429
|
-
error(t, n,
|
|
430
|
-
this.write("error", t,
|
|
452
|
+
error(t, n, c, w) {
|
|
453
|
+
this.write("error", t, w, n, c);
|
|
431
454
|
}
|
|
432
|
-
fatal(t, n,
|
|
433
|
-
this.write("fatal", t,
|
|
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
|
|
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
|
|
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
|
|
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 (
|
|
505
|
+
return await this.dataSource.transaction(async (c) => {
|
|
483
506
|
n = await t(
|
|
484
|
-
|
|
507
|
+
Y.newInstance(this).withEntityManager(c)
|
|
485
508
|
);
|
|
486
509
|
}), n;
|
|
487
510
|
}
|
|
488
511
|
}
|
|
489
|
-
const
|
|
490
|
-
...
|
|
491
|
-
withTransaction: async (t) => await t(
|
|
492
|
-
withRepositoryManager: () =>
|
|
493
|
-
}),
|
|
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:
|
|
518
|
+
unaccentSearch: fe
|
|
496
519
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
497
520
|
export {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
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.
|
|
3
|
+
"version": "1.0.11",
|
|
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
|
|
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.
|
|
39
|
+
"vite": "7.0.5",
|
|
40
40
|
"vite-plugin-dts": "4.5.4",
|
|
41
41
|
"vitest": "3.2.4"
|
|
42
42
|
}
|