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