@jsfsi-core/ts-nodejs 1.0.15 → 1.0.19
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 +2 -2
- package/dist/index.mjs +17 -14
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("path"),W=require("url"),Q=require("fs"),H=require("os"),X=require("crypto");var U=typeof document<"u"?document.currentScript:null;function Z(h){return h&&h.__esModule&&Object.prototype.hasOwnProperty.call(h,"default")?h.default:h}var S={exports:{}};const ee="17.2.
|
|
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.3",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","📡 add observability to secrets: https://dotenvx.com/ops","👥 sync secrets across teammates & machines: https://dotenvx.com/ops","🗂️ backup and recover secrets: https://dotenvx.com/ops","✅ audit secrets and track compliance: https://dotenvx.com/ops","🔄 add secrets lifecycle management: https://dotenvx.com/ops","🔑 add access controls to secrets: https://dotenvx.com/ops","🛠️ run anywhere with `dotenvx run -- yourcommand`","⚙️ specify custom .env file path with { path: '/custom/path/.env' }","⚙️ enable debug logging with { debug: true }","⚙️ override existing env vars with { override: true }","⚙️ suppress all logs with { quiet: true }","⚙️ write to custom object with { processEnv: myObject }","⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"];function I(){return O[Math.floor(Math.random()*O.length)]}function b(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}function D(){return process.stdout.isTTY}function A(e){return D()?`\x1B[2m${e}\x1B[0m`:e}const M=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function r(e){const a={};let l=e.toString();l=l.replace(/\r\n?/mg,`
|
|
2
2
|
`);let d;for(;(d=M.exec(l))!=null;){const E=d[1];let g=d[2]||"";g=g.trim();const o=g[0];g=g.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),o==='"'&&(g=g.replace(/\\n/g,`
|
|
3
|
-
`),g=g.replace(/\\r/g,"\r")),a[E]=g}return a}function u(e){e=e||{};const a=s(e);e.path=a;const l=_.configDotenv(e);if(!l.parsed){const o=new Error(`MISSING_DATA: Cannot parse ${a} for an unknown reason`);throw o.code="MISSING_DATA",o}const d=y(e).split(","),E=d.length;let g;for(let o=0;o<E;o++)try{const w=d[o].trim(),T=v(l,w);g=_.decrypt(T.ciphertext,T.key);break}catch(w){if(o+1>=E)throw w}return _.parse(g)}function p(e){console.error(`[dotenv@${N}][WARN] ${e}`)}function i(e){console.log(`[dotenv@${N}][DEBUG] ${e}`)}function f(e){console.log(`[dotenv@${N}] ${e}`)}function y(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function v(e,a){let l;try{l=new URL(a)}catch(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 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=_._parseVault(e);let E=process.env;return e&&e.processEnv!=null&&(E=e.processEnv),_.populate(E,d,e),{parsed:d}}function x(e){const a=t.resolve(process.cwd(),".env");let l="utf8",d=process.env;e&&e.processEnv!=null&&(d=e.processEnv);let E=b(d.DOTENV_CONFIG_DEBUG||e&&e.debug),g=b(d.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?l=e.encoding:E&&i("No encoding is specified. UTF-8 is used by default");let o=[a];if(e&&e.path)if(!Array.isArray(e.path))o=[R(e.path)];else{o=[];for(const L of e.path)o.push(R(L))}let w;const T={};for(const L of o)try{const $=_.parse(h.readFileSync(L,{encoding:l}));_.populate(T,$,e)}catch($){E&&i(`Failed to load ${L} ${$.message}`),w=$}const F=_.populate(d,T,e);if(E=b(d.DOTENV_CONFIG_DEBUG||E),g=b(d.DOTENV_CONFIG_QUIET||g),E||!g){const L=Object.keys(F).length,$=[];for(const K of o)try{const C=t.relative(process.cwd(),K);$.push(C)}catch(C){E&&i(`Failed to load ${K} ${C.message}`),w=C}f(`injecting env (${L}) from ${$.join(",")} ${A(`-- tip: ${I()}`)}`)}return w?{parsed:T,error:w}:{parsed:T}}function G(e){if(y(e).length===0)return _.configDotenv(e);const a=s(e);return a?_._configVault(e):(p(`You set DOTENV_KEY but you are missing a .env.vault file at ${a}. Did you forget to build it?`),_.configDotenv(e))}function k(e,a){const l=Buffer.from(a.slice(-64),"hex");let d=Buffer.from(e,"base64");const E=d.subarray(0,12),g=d.subarray(-16);d=d.subarray(12,-16);try{const o=c.createDecipheriv("aes-256-gcm",l,E);return o.setAuthTag(g),`${o.update(d)}${o.final()}`}catch(o){const w=o instanceof RangeError,T=o.message==="Invalid key length",F=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(F){const L=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw L.code="DECRYPTION_FAILED",L}else throw o}}function z(e,a,l={}){const d=!!(l&&l.debug),E=!!(l&&l.override),g={};if(typeof a!="object"){const o=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw o.code="OBJECT_REQUIRED",o}for(const o of Object.keys(a))Object.prototype.hasOwnProperty.call(e,o)?(E===!0&&(e[o]=a[o],g[o]=a[o]),d&&i(E===!0?`"${o}" is already defined and WAS overwritten`:`"${o}" is already defined and was NOT overwritten`)):(e[o]=a[o],g[o]=a[o]);return g}const _={configDotenv:x,_configVault:V,_parseVault:u,config:G,decrypt:k,parse:r,populate:z};return S.exports.configDotenv=_.configDotenv,S.exports._configVault=_._configVault,S.exports._parseVault=_._parseVault,S.exports.config=_.config,S.exports.decrypt=_.decrypt,S.exports.parse=_.parse,S.exports.populate=_.populate,S.exports=_,S.exports}var ne=re();const oe=W.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:U&&U.tagName.toUpperCase()==="SCRIPT"&&U.src||new URL("index.cjs",document.baseURI).href),ie=Y.dirname(oe),se=(h={})=>{const{env:t,configPath:n}=h,c=Y.resolve(ie,`${n??"."}/.env${t?`.${t}`:""}`),{parsed:m}=ne.config({path:c});return m};var j,B;function ce(){if(B)return j;B=1,j=N,N.default=N,N.stable=D,N.stableStringify=D;var h="[...]",t="[Circular]",n=[],c=[];function m(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function N(r,u,p,i){typeof i>"u"&&(i=m()),I(r,"",0,[],void 0,0,i);var f;try{c.length===0?f=JSON.stringify(r,u,p):f=JSON.stringify(r,M(u),p)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;n.length!==0;){var y=n.pop();y.length===4?Object.defineProperty(y[0],y[1],y[3]):y[0][y[1]]=y[2]}}return f}function O(r,u,p,i){var f=Object.getOwnPropertyDescriptor(i,p);f.get!==void 0?f.configurable?(Object.defineProperty(i,p,{value:r}),n.push([i,p,u,f])):c.push([u,p,r]):(i[p]=r,n.push([i,p,u]))}function I(r,u,p,i,f,y,v){y+=1;var s;if(typeof r=="object"&&r!==null){for(s=0;s<i.length;s++)if(i[s]===r){O(t,r,u,f);return}if(typeof v.depthLimit<"u"&&y>v.depthLimit){O(h,r,u,f);return}if(typeof v.edgesLimit<"u"&&p+1>v.edgesLimit){O(h,r,u,f);return}if(i.push(r),Array.isArray(r))for(s=0;s<r.length;s++)I(r[s],s,s,i,r,y,v);else{var R=Object.keys(r);for(s=0;s<R.length;s++){var V=R[s];I(r[V],V,s,i,r,y,v)}}i.pop()}}function b(r,u){return r<u?-1:r>u?1:0}function D(r,u,p,i){typeof i>"u"&&(i=m());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,m,N){if(!this.levels.has(t))return;const O=this.buildLog(t,n,c,m,N),I=ue(O,this.sensitiveReplacer),b=this.mapLogLevelToConsoleMethod(t);console[b](I)}buildLog(t,n,c,m,N){const{writeMetadata:O,writeContext:I,writeError:b}=this.sanitizeLog(c,m,N),D={};return typeof n=="string"&&(D.textPayload=n),!O&&typeof n!="string"&&!(n instanceof Error)&&(D.metadata=n),n instanceof Error&&(D.error=JSON.stringify(n,Object.getOwnPropertyNames(n))),I&&(D.context=I),O&&(D.metadata=O),!D.error&&b&&(D.error=JSON.stringify(b,Object.getOwnPropertyNames(b))),{severity:fe[t],module:this.module,textPayload:D.textPayload,message:D}}sanitizeLog(t,n,c){if(n instanceof Error&&(!c||typeof c=="string"))return{writeMetadata:void 0,writeContext:t||c,writeError:n};let m=n,N=t;return typeof m=="string"&&!t&&(N=m,m=void 0),{writeMetadata:m,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,m){this.write("warn",t,m,n,c)}error(t,n,c,m){this.write("error",t,m,n,c)}fatal(t,n,c,m){this.write("fatal",t,m,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;
|
|
3
|
+
`),g=g.replace(/\\r/g,"\r")),a[E]=g}return a}function u(e){e=e||{};const a=s(e);e.path=a;const l=_.configDotenv(e);if(!l.parsed){const o=new Error(`MISSING_DATA: Cannot parse ${a} for an unknown reason`);throw o.code="MISSING_DATA",o}const d=y(e).split(","),E=d.length;let g;for(let o=0;o<E;o++)try{const m=d[o].trim(),T=v(l,m);g=_.decrypt(T.ciphertext,T.key);break}catch(m){if(o+1>=E)throw m}return _.parse(g)}function p(e){console.error(`[dotenv@${N}][WARN] ${e}`)}function i(e){console.log(`[dotenv@${N}][DEBUG] ${e}`)}function f(e){console.log(`[dotenv@${N}] ${e}`)}function y(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function v(e,a){let l;try{l=new URL(a)}catch(m){if(m.code==="ERR_INVALID_URL"){const T=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw T.code="INVALID_DOTENV_KEY",T}throw m}const d=l.password;if(!d){const m=new Error("INVALID_DOTENV_KEY: Missing key part");throw m.code="INVALID_DOTENV_KEY",m}const E=l.searchParams.get("environment");if(!E){const m=new Error("INVALID_DOTENV_KEY: Missing environment part");throw m.code="INVALID_DOTENV_KEY",m}const g=`DOTENV_VAULT_${E.toUpperCase()}`,o=e.parsed[g];if(!o){const m=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${g} in your .env.vault file.`);throw m.code="NOT_FOUND_DOTENV_ENVIRONMENT",m}return{ciphertext:o,key:d}}function s(e){let a=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(const l of e.path)h.existsSync(l)&&(a=l.endsWith(".vault")?l:`${l}.vault`);else a=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else a=t.resolve(process.cwd(),".env.vault");return h.existsSync(a)?a:null}function R(e){return e[0]==="~"?t.join(n.homedir(),e.slice(1)):e}function V(e){const a=b(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),l=b(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(a||!l)&&f("Loading env from encrypted .env.vault");const d=_._parseVault(e);let E=process.env;return e&&e.processEnv!=null&&(E=e.processEnv),_.populate(E,d,e),{parsed:d}}function $(e){const a=t.resolve(process.cwd(),".env");let l="utf8",d=process.env;e&&e.processEnv!=null&&(d=e.processEnv);let E=b(d.DOTENV_CONFIG_DEBUG||e&&e.debug),g=b(d.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?l=e.encoding:E&&i("No encoding is specified. UTF-8 is used by default");let o=[a];if(e&&e.path)if(!Array.isArray(e.path))o=[R(e.path)];else{o=[];for(const L of e.path)o.push(R(L))}let m;const T={};for(const L of o)try{const x=_.parse(h.readFileSync(L,{encoding:l}));_.populate(T,x,e)}catch(x){E&&i(`Failed to load ${L} ${x.message}`),m=x}const F=_.populate(d,T,e);if(E=b(d.DOTENV_CONFIG_DEBUG||E),g=b(d.DOTENV_CONFIG_QUIET||g),E||!g){const L=Object.keys(F).length,x=[];for(const K of o)try{const C=t.relative(process.cwd(),K);x.push(C)}catch(C){E&&i(`Failed to load ${K} ${C.message}`),m=C}f(`injecting env (${L}) from ${x.join(",")} ${A(`-- tip: ${I()}`)}`)}return m?{parsed:T,error:m}:{parsed:T}}function G(e){if(y(e).length===0)return _.configDotenv(e);const a=s(e);return a?_._configVault(e):(p(`You set DOTENV_KEY but you are missing a .env.vault file at ${a}. Did you forget to build it?`),_.configDotenv(e))}function k(e,a){const l=Buffer.from(a.slice(-64),"hex");let d=Buffer.from(e,"base64");const E=d.subarray(0,12),g=d.subarray(-16);d=d.subarray(12,-16);try{const o=c.createDecipheriv("aes-256-gcm",l,E);return o.setAuthTag(g),`${o.update(d)}${o.final()}`}catch(o){const m=o instanceof RangeError,T=o.message==="Invalid key length",F=o.message==="Unsupported state or unable to authenticate data";if(m||T){const L=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw L.code="INVALID_DOTENV_KEY",L}else if(F){const L=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw L.code="DECRYPTION_FAILED",L}else throw o}}function z(e,a,l={}){const d=!!(l&&l.debug),E=!!(l&&l.override),g={};if(typeof a!="object"){const o=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw o.code="OBJECT_REQUIRED",o}for(const o of Object.keys(a))Object.prototype.hasOwnProperty.call(e,o)?(E===!0&&(e[o]=a[o],g[o]=a[o]),d&&i(E===!0?`"${o}" is already defined and WAS overwritten`:`"${o}" is already defined and was NOT overwritten`)):(e[o]=a[o],g[o]=a[o]);return g}const _={configDotenv:$,_configVault:V,_parseVault:u,config:G,decrypt:k,parse:r,populate:z};return S.exports.configDotenv=_.configDotenv,S.exports._configVault=_._configVault,S.exports._parseVault=_._parseVault,S.exports.config=_.config,S.exports.decrypt=_.decrypt,S.exports.parse=_.parse,S.exports.populate=_.populate,S.exports=_,S.exports}var ne=re();const oe=W.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:U&&U.tagName.toUpperCase()==="SCRIPT"&&U.src||new URL("index.cjs",document.baseURI).href),ie=Y.dirname(oe),se=(h={})=>{const{env:t,configPath:n}=h,c=Y.resolve(ie,`${n??"."}/.env${t?`.${t}`:""}`),{parsed:w}=ne.config({path:c});return w};var j,B;function ce(){if(B)return j;B=1,j=N,N.default=N,N.stable=D,N.stableStringify=D;var h="[...]",t="[Circular]",n=[],c=[];function w(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function N(r,u,p,i){typeof i>"u"&&(i=w()),I(r,"",0,[],void 0,0,i);var f;try{c.length===0?f=JSON.stringify(r,u,p):f=JSON.stringify(r,M(u),p)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;n.length!==0;){var y=n.pop();y.length===4?Object.defineProperty(y[0],y[1],y[3]):y[0][y[1]]=y[2]}}return f}function O(r,u,p,i){var f=Object.getOwnPropertyDescriptor(i,p);f.get!==void 0?f.configurable?(Object.defineProperty(i,p,{value:r}),n.push([i,p,u,f])):c.push([u,p,r]):(i[p]=r,n.push([i,p,u]))}function I(r,u,p,i,f,y,v){y+=1;var s;if(typeof r=="object"&&r!==null){for(s=0;s<i.length;s++)if(i[s]===r){O(t,r,u,f);return}if(typeof v.depthLimit<"u"&&y>v.depthLimit){O(h,r,u,f);return}if(typeof v.edgesLimit<"u"&&p+1>v.edgesLimit){O(h,r,u,f);return}if(i.push(r),Array.isArray(r))for(s=0;s<r.length;s++)I(r[s],s,s,i,r,y,v);else{var R=Object.keys(r);for(s=0;s<R.length;s++){var V=R[s];I(r[V],V,s,i,r,y,v)}}i.pop()}}function b(r,u){return r<u?-1:r>u?1:0}function D(r,u,p,i){typeof i>"u"&&(i=w());var f=A(r,"",0,[],void 0,0,i)||r,y;try{c.length===0?y=JSON.stringify(f,u,p):y=JSON.stringify(f,M(u),p)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;n.length!==0;){var v=n.pop();v.length===4?Object.defineProperty(v[0],v[1],v[3]):v[0][v[1]]=v[2]}}return y}function A(r,u,p,i,f,y,v){y+=1;var s;if(typeof r=="object"&&r!==null){for(s=0;s<i.length;s++)if(i[s]===r){O(t,r,u,f);return}try{if(typeof r.toJSON=="function")return}catch{return}if(typeof v.depthLimit<"u"&&y>v.depthLimit){O(h,r,u,f);return}if(typeof v.edgesLimit<"u"&&p+1>v.edgesLimit){O(h,r,u,f);return}if(i.push(r),Array.isArray(r))for(s=0;s<r.length;s++)A(r[s],s,s,i,r,y,v);else{var R={},V=Object.keys(r).sort(b);for(s=0;s<V.length;s++){var $=V[s];A(r[$],$,s,i,r,y,v),R[$]=r[$]}if(typeof f<"u")n.push([f,u,r]),f[u]=R;else return R}i.pop()}}function M(r){return r=typeof r<"u"?r:function(u,p){return p},function(u,p){if(c.length>0)for(var i=0;i<c.length;i++){var f=c[i];if(f[1]===u&&f[0]===p){p=f[2],c.splice(i,1);break}}return r.call(this,u,p)}}return j}var ae=ce();const ue=Z(ae),J={debug:"debug",verbose:"debug",log:"log",warn:"warn",error:"error",fatal:"error"},fe={verbose:"DEFAULT",debug:"DEBUG",log:"INFO",warn:"WARNING",error:"ERROR",fatal:"CRITICAL"},le=["x-api-key","x-api-token","x-key","x-token","cookie","password","pass","psw","auth","authentication","authorization","token","access_token","client-secret","credentials","secret"];class de{constructor(t,n={}){this.module=t,n.logLevels&&(this.levels=new Set(n.logLevels))}levels=new Set(["verbose","debug","log","warn","error","fatal"]);mapLogLevelToConsoleMethod(t){return J[t]}write(t,n,c,w,N){if(!this.levels.has(t))return;const O=this.buildLog(t,n,c,w,N),I=ue(O,this.sensitiveReplacer),b=this.mapLogLevelToConsoleMethod(t);console[b](I)}buildLog(t,n,c,w,N){const{writeMetadata:O,writeContext:I,writeError:b}=this.sanitizeLog(c,w,N),D={};return typeof n=="string"&&(D.textPayload=n),!O&&typeof n!="string"&&!(n instanceof Error)&&(D.metadata=n),n instanceof Error&&(D.error=JSON.stringify(n,Object.getOwnPropertyNames(n))),I&&(D.context=I),O&&(D.metadata=O),!D.error&&b&&(D.error=JSON.stringify(b,Object.getOwnPropertyNames(b))),{severity:fe[t],module:this.module,textPayload:D.textPayload,message:D}}sanitizeLog(t,n,c){if(n instanceof Error&&(!c||typeof c=="string"))return{writeMetadata:void 0,writeContext:t||c,writeError:n};let w=n,N=t;return typeof w=="string"&&!t&&(N=w,w=void 0),{writeMetadata:w,writeContext:N,writeError:c}}sensitiveReplacer(t,n){return le.includes(t.toLowerCase())?"[HIDDEN BY LOGGER]":n}debug(t,n,c){this.write("debug",t,c,n)}verbose(t,n,c){this.write("verbose",t,c,n)}log(t,n,c){this.write("log",t,c,n)}warn(t,n,c,w){this.write("warn",t,w,n,c)}error(t,n,c,w){this.write("error",t,w,n,c)}fatal(t,n,c,w){this.write("fatal",t,w,n,c)}setLogLevels(t){this.levels=new Set(t)}}class ge{debug=()=>{};verbose=()=>{};log=()=>{};warn=()=>{};error=()=>{};fatal=()=>{};setLogLevels=()=>{}}class P{constructor(t){this.dataSource=t}em;static newInstance(t){const n=t.constructor;return new n(t.dataSource)}withEntityManager(t){return this.em=t,this}withRepositoryManager(t){return P.newInstance(this).withEntityManager(t.em)}lockInTransaction(t="pessimistic_write"){return this.em?{mode:t}:void 0}getRepository(t){return this.em?this.em.getRepository(t):this.dataSource.getRepository(t)}async withTransaction(t){let n;return await this.dataSource.transaction(async c=>{n=await t(P.newInstance(this).withEntityManager(c))}),n}}const he=h=>({...h,withTransaction:async t=>await t(h),withRepositoryManager:()=>h}),pe=(h,t)=>`unaccent(LOWER(${h})) ILIKE unaccent(LOWER(:${t}))`,ye=Object.freeze(Object.defineProperty({__proto__:null,unaccentSearch:pe},Symbol.toStringTag,{value:"Module"}));exports.GCPLogger=de;exports.LogLevelToConsoleMethodMap=J;exports.MockLogger=ge;exports.TransactionalRepository=P;exports.buildTransactionalRepositoryMock=he;exports.loadEnvConfig=se;exports.postgres=ye;
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ function H(g) {
|
|
|
7
7
|
return g && g.__esModule && Object.prototype.hasOwnProperty.call(g, "default") ? g.default : g;
|
|
8
8
|
}
|
|
9
9
|
var S = { exports: {} };
|
|
10
|
-
const X = "17.2.
|
|
10
|
+
const X = "17.2.3", Z = {
|
|
11
11
|
version: X
|
|
12
12
|
};
|
|
13
13
|
var G;
|
|
@@ -18,9 +18,12 @@ function ee() {
|
|
|
18
18
|
"🔐 encrypt with Dotenvx: https://dotenvx.com",
|
|
19
19
|
"🔐 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
20
20
|
"🔐 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
21
|
-
"📡
|
|
22
|
-
"
|
|
23
|
-
"
|
|
21
|
+
"📡 add observability to secrets: https://dotenvx.com/ops",
|
|
22
|
+
"👥 sync secrets across teammates & machines: https://dotenvx.com/ops",
|
|
23
|
+
"🗂️ backup and recover secrets: https://dotenvx.com/ops",
|
|
24
|
+
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
25
|
+
"🔄 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
26
|
+
"🔑 add access controls to secrets: https://dotenvx.com/ops",
|
|
24
27
|
"🛠️ run anywhere with `dotenvx run -- yourcommand`",
|
|
25
28
|
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
26
29
|
"⚙️ enable debug logging with { debug: true }",
|
|
@@ -135,14 +138,14 @@ function ee() {
|
|
|
135
138
|
function V(e) {
|
|
136
139
|
return e[0] === "~" ? t.join(n.homedir(), e.slice(1)) : e;
|
|
137
140
|
}
|
|
138
|
-
function
|
|
141
|
+
function x(e) {
|
|
139
142
|
const a = b(process.env.DOTENV_CONFIG_DEBUG || e && e.debug), l = b(process.env.DOTENV_CONFIG_QUIET || e && e.quiet);
|
|
140
143
|
(a || !l) && f("Loading env from encrypted .env.vault");
|
|
141
144
|
const d = _._parseVault(e);
|
|
142
145
|
let E = process.env;
|
|
143
146
|
return e && e.processEnv != null && (E = e.processEnv), _.populate(E, d, e), { parsed: d };
|
|
144
147
|
}
|
|
145
|
-
function
|
|
148
|
+
function R(e) {
|
|
146
149
|
const a = t.resolve(process.cwd(), ".env");
|
|
147
150
|
let l = "utf8", d = process.env;
|
|
148
151
|
e && e.processEnv != null && (d = e.processEnv);
|
|
@@ -217,8 +220,8 @@ function ee() {
|
|
|
217
220
|
return h;
|
|
218
221
|
}
|
|
219
222
|
const _ = {
|
|
220
|
-
configDotenv:
|
|
221
|
-
_configVault:
|
|
223
|
+
configDotenv: R,
|
|
224
|
+
_configVault: x,
|
|
222
225
|
_parseVault: u,
|
|
223
226
|
config: K,
|
|
224
227
|
decrypt: q,
|
|
@@ -285,8 +288,8 @@ function oe() {
|
|
|
285
288
|
else {
|
|
286
289
|
var V = Object.keys(r);
|
|
287
290
|
for (s = 0; s < V.length; s++) {
|
|
288
|
-
var
|
|
289
|
-
L(r[
|
|
291
|
+
var x = V[s];
|
|
292
|
+
L(r[x], x, s, i, r, y, v);
|
|
290
293
|
}
|
|
291
294
|
}
|
|
292
295
|
i.pop();
|
|
@@ -337,10 +340,10 @@ function oe() {
|
|
|
337
340
|
for (s = 0; s < r.length; s++)
|
|
338
341
|
A(r[s], s, s, i, r, y, v);
|
|
339
342
|
else {
|
|
340
|
-
var V = {},
|
|
341
|
-
for (s = 0; s <
|
|
342
|
-
var
|
|
343
|
-
A(r[
|
|
343
|
+
var V = {}, x = Object.keys(r).sort(b);
|
|
344
|
+
for (s = 0; s < x.length; s++) {
|
|
345
|
+
var R = x[s];
|
|
346
|
+
A(r[R], R, s, i, r, y, v), V[R] = r[R];
|
|
344
347
|
}
|
|
345
348
|
if (typeof f < "u")
|
|
346
349
|
n.push([f, u, r]), f[u] = V;
|
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.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@jsfsi-core/ts-crossplatform": "file:../ts-crossplatform",
|
|
33
|
-
"dotenv": "17.2.
|
|
33
|
+
"dotenv": "17.2.3",
|
|
34
34
|
"fast-safe-stringify": "2.1.1",
|
|
35
|
-
"typeorm": "0.3.
|
|
35
|
+
"typeorm": "0.3.27"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@vitest/coverage-v8": "
|
|
39
|
-
"vite": "7.1.
|
|
38
|
+
"@vitest/coverage-v8": "4.0.4",
|
|
39
|
+
"vite": "7.1.12",
|
|
40
40
|
"vite-plugin-dts": "4.5.4",
|
|
41
|
-
"vitest": "
|
|
41
|
+
"vitest": "4.0.4"
|
|
42
42
|
}
|
|
43
43
|
}
|