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