@jsfsi-core/ts-nodejs 1.1.42 → 1.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require(`path`);u=l(u);var d=l(o(((e,t)=>{var n=require(`fs`),r=require(`path`),i=require(`os`),a=require(`crypto`),o=[`◈ encrypted .env [www.dotenvx.com]`,`◈ secrets for agents [www.dotenvx.com]`,`⌁ auth for agents [www.vestauth.com]`,`⌘ custom filepath { path: '/custom/path/.env' }`,`⌘ enable debugging { debug: true }`,`⌘ override existing { override: true }`,`⌘ suppress logs { quiet: true }`,`⌘ multiple files { path: ['.env.local', '.env'] }`];function s(){return o[Math.floor(Math.random()*o.length)]}function c(e){return typeof e==`string`?![`false`,`0`,`no`,`off`,``].includes(e.toLowerCase()):!!e}function l(){return process.stdout.isTTY}function u(e){return l()?`\x1b[2m${e}\x1b[0m`:e}var d=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function f(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
2
2
  `);let r;for(;(r=d.exec(n))!=null;){let e=r[1],n=r[2]||``;n=n.trim();let i=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),i===`"`&&(n=n.replace(/\\n/g,`
3
- `),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function p(e){e||={};let t=y(e);e.path=t;let n=E.configDotenv(e);if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=_(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=v(n,r[e].trim());a=E.decrypt(t.ciphertext,t.key);break}catch(t){if(e+1>=i)throw t}return E.parse(a)}function m(e){console.error(`⚠ ${e}`)}function h(e){console.log(`┆ ${e}`)}function g(e){console.log(`◇ ${e}`)}function _(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,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function y(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)n.existsSync(r)&&(t=r.endsWith(`.vault`)?r:`${r}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=r.resolve(process.cwd(),`.env.vault`);return n.existsSync(t)?t:null}function b(e){return e[0]===`~`?r.join(i.homedir(),e.slice(1)):e}function x(e){let t=c(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),n=c(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!n)&&g(`loading env from encrypted .env.vault`);let r=E._parseVault(e),i=process.env;return e&&e.processEnv!=null&&(i=e.processEnv),E.populate(i,r,e),{parsed:r}}function S(e){let t=r.resolve(process.cwd(),`.env`),i=`utf8`,a=process.env;e&&e.processEnv!=null&&(a=e.processEnv);let o=c(a.DOTENV_CONFIG_DEBUG||e&&e.debug),l=c(a.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?i=e.encoding:o&&h(`no encoding is specified (UTF-8 is used by default)`);let d=[t];if(e&&e.path)if(!Array.isArray(e.path))d=[b(e.path)];else{d=[];for(let t of e.path)d.push(b(t))}let f,p={};for(let t of d)try{let r=E.parse(n.readFileSync(t,{encoding:i}));E.populate(p,r,e)}catch(e){o&&h(`failed to load ${t} ${e.message}`),f=e}let m=E.populate(a,p,e);if(o=c(a.DOTENV_CONFIG_DEBUG||o),l=c(a.DOTENV_CONFIG_QUIET||l),o||!l){let e=Object.keys(m).length,t=[];for(let e of d)try{let n=r.relative(process.cwd(),e);t.push(n)}catch(t){o&&h(`failed to load ${e} ${t.message}`),f=t}g(`injected env (${e}) from ${t.join(`,`)} ${u(`// tip: ${s()}`)}`)}return f?{parsed:p,error:f}:{parsed:p}}function C(e){if(_(e).length===0)return E.configDotenv(e);let t=y(e);return t?E._configVault(e):(m(`you set DOTENV_KEY but you are missing a .env.vault file at ${t}`),E.configDotenv(e))}function w(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),o=r.subarray(-16);r=r.subarray(12,-16);try{let e=a.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(o),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function T(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override),a={};if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n],a[n]=t[n]),r&&h(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):(e[n]=t[n],a[n]=t[n]);return a}var E={configDotenv:S,_configVault:x,_parseVault:p,config:C,decrypt:w,parse:f,populate:T};t.exports.configDotenv=E.configDotenv,t.exports._configVault=E._configVault,t.exports._parseVault=E._parseVault,t.exports.config=E.config,t.exports.decrypt=E.decrypt,t.exports.parse=E.parse,t.exports.populate=E.populate,t.exports=E}))(),1),f=(e={})=>{let{env:t,configPath:n}=e,r=u.default.resolve(n??process.cwd(),`.env${t?`.${t}`:``}`),{parsed:i}=d.config({path:r});return i},p=l(o(((e,t)=>{t.exports=s,s.default=s,s.stable=d,s.stableStringify=d;var n=`[...]`,r=`[Circular]`,i=[],a=[];function o(){return{depthLimit:2**53-1,edgesLimit:2**53-1}}function s(e,t,n,r){r===void 0&&(r=o()),l(e,``,0,[],void 0,0,r);var s;try{s=a.length===0?JSON.stringify(e,t,n):JSON.stringify(e,p(t),n)}catch{return JSON.stringify(`[unable to serialize, circular reference is too complex to analyze]`)}finally{for(;i.length!==0;){var c=i.pop();c.length===4?Object.defineProperty(c[0],c[1],c[3]):c[0][c[1]]=c[2]}}return s}function c(e,t,n,r){var o=Object.getOwnPropertyDescriptor(r,n);o.get===void 0?(r[n]=e,i.push([r,n,t])):o.configurable?(Object.defineProperty(r,n,{value:e}),i.push([r,n,t,o])):a.push([t,n,e])}function l(e,t,i,a,o,s,u){s+=1;var d;if(typeof e==`object`&&e){for(d=0;d<a.length;d++)if(a[d]===e){c(r,e,t,o);return}if(u.depthLimit!==void 0&&s>u.depthLimit){c(n,e,t,o);return}if(u.edgesLimit!==void 0&&i+1>u.edgesLimit){c(n,e,t,o);return}if(a.push(e),Array.isArray(e))for(d=0;d<e.length;d++)l(e[d],d,d,a,e,s,u);else{var f=Object.keys(e);for(d=0;d<f.length;d++){var p=f[d];l(e[p],p,d,a,e,s,u)}}a.pop()}}function u(e,t){return e<t?-1:e>t?1:0}function d(e,t,n,r){r===void 0&&(r=o());var s=f(e,``,0,[],void 0,0,r)||e,c;try{c=a.length===0?JSON.stringify(s,t,n):JSON.stringify(s,p(t),n)}catch{return JSON.stringify(`[unable to serialize, circular reference is too complex to analyze]`)}finally{for(;i.length!==0;){var l=i.pop();l.length===4?Object.defineProperty(l[0],l[1],l[3]):l[0][l[1]]=l[2]}}return c}function f(e,t,a,o,s,l,d){l+=1;var p;if(typeof e==`object`&&e){for(p=0;p<o.length;p++)if(o[p]===e){c(r,e,t,s);return}try{if(typeof e.toJSON==`function`)return}catch{return}if(d.depthLimit!==void 0&&l>d.depthLimit){c(n,e,t,s);return}if(d.edgesLimit!==void 0&&a+1>d.edgesLimit){c(n,e,t,s);return}if(o.push(e),Array.isArray(e))for(p=0;p<e.length;p++)f(e[p],p,p,o,e,l,d);else{var m={},h=Object.keys(e).sort(u);for(p=0;p<h.length;p++){var g=h[p];f(e[g],g,p,o,e,l,d),m[g]=e[g]}if(s!==void 0)i.push([s,t,e]),s[t]=m;else return m}o.pop()}}function p(e){return e=e===void 0?function(e,t){return t}:e,function(t,n){if(a.length>0)for(var r=0;r<a.length;r++){var i=a[r];if(i[1]===t&&i[0]===n){n=i[2],a.splice(r,1);break}}return e.call(this,t,n)}}}))(),1),m={debug:`debug`,verbose:`debug`,log:`log`,warn:`warn`,error:`error`,fatal:`error`},h={verbose:`DEFAULT`,debug:`DEBUG`,log:`INFO`,warn:`WARNING`,error:`ERROR`,fatal:`CRITICAL`},g=[`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{levels=new Set([`verbose`,`debug`,`log`,`warn`,`error`,`fatal`]);constructor(e,t={}){this.module=e,t.logLevels&&(this.levels=new Set(t.logLevels))}mapLogLevelToConsoleMethod(e){return m[e]}write(e,t,n,r,i){if(!this.levels.has(e))return;let a=(0,p.default)(this.buildLog(e,t,n,r,i),this.sensitiveReplacer),o=this.mapLogLevelToConsoleMethod(e);console[o](a)}buildLog(e,t,n,r,i){let{writeMetadata:a,writeContext:o,writeError:s}=this.sanitizeLog(n,r,i),c={};return typeof t==`string`&&(c.textPayload=t),!a&&typeof t!=`string`&&!(t instanceof Error)&&(c.metadata=t),t instanceof Error&&(c.error=JSON.stringify(t,Object.getOwnPropertyNames(t))),o&&(c.context=o),a&&(c.metadata=a),!c.error&&s&&(c.error=JSON.stringify(s,Object.getOwnPropertyNames(s))),{severity:h[e],module:this.module,textPayload:c.textPayload,message:c}}sanitizeLog(e,t,n){if(t instanceof Error&&(!n||typeof n==`string`))return{writeMetadata:void 0,writeContext:e||n,writeError:t};let r=t,i=e;return typeof r==`string`&&!e&&(i=r,r=void 0),{writeMetadata:r,writeContext:i,writeError:n}}sensitiveReplacer(e,t){return g.includes(e.toLowerCase())?`[HIDDEN BY LOGGER]`:t}debug(e,t,n){this.write(`debug`,e,n,t)}verbose(e,t,n){this.write(`verbose`,e,n,t)}log(e,t,n){this.write(`log`,e,n,t)}warn(e,t,n,r){this.write(`warn`,e,r,t,n)}error(e,t,n,r){this.write(`error`,e,r,t,n)}fatal(e,t,n,r){this.write(`fatal`,e,r,t,n)}setLogLevels(e){this.levels=new Set(e)}},v=class{debug=()=>void 0;verbose=()=>void 0;log=()=>void 0;warn=()=>void 0;error=()=>void 0;fatal=()=>void 0;setLogLevels=()=>void 0},y=class e{em;constructor(e){this.dataSource=e}static newInstance(e){let t=e.constructor;return new t(e.dataSource)}withEntityManager(e){return this.em=e,this}withRepositoryManager(t){return e.newInstance(this).withEntityManager(t.em)}lockInTransaction(e=`pessimistic_write`){return this.em?{mode:e}:void 0}getRepository(e){return this.em?this.em.getRepository(e):this.dataSource.getRepository(e)}async withTransaction(t){let n;return await this.dataSource.transaction(async r=>{n=await t(e.newInstance(this).withEntityManager(r))}),n}},b=e=>({...e,withTransaction:async t=>await t(e),withRepositoryManager:()=>e}),x=(e,t)=>`unaccent(LOWER(${e})) ILIKE unaccent(LOWER(:${t}))`,S=s({unaccentSearch:()=>x});exports.GCPLogger=_,exports.LogLevelToConsoleMethodMap=m,exports.MockLogger=v,exports.TransactionalRepository=y,exports.buildTransactionalRepositoryMock=b,exports.loadEnvConfig=f,Object.defineProperty(exports,`postgres`,{enumerable:!0,get:function(){return S}});
3
+ `),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function p(e){e||={};let t=y(e);e.path=t;let n=E.configDotenv(e);if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=_(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=v(n,r[e].trim());a=E.decrypt(t.ciphertext,t.key);break}catch(t){if(e+1>=i)throw t}return E.parse(a)}function m(e){console.error(`⚠ ${e}`)}function h(e){console.log(`┆ ${e}`)}function g(e){console.log(`◇ ${e}`)}function _(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,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function y(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)n.existsSync(r)&&(t=r.endsWith(`.vault`)?r:`${r}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=r.resolve(process.cwd(),`.env.vault`);return n.existsSync(t)?t:null}function b(e){return e[0]===`~`?r.join(i.homedir(),e.slice(1)):e}function x(e){let t=c(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),n=c(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!n)&&g(`loading env from encrypted .env.vault`);let r=E._parseVault(e),i=process.env;return e&&e.processEnv!=null&&(i=e.processEnv),E.populate(i,r,e),{parsed:r}}function S(e){let t=r.resolve(process.cwd(),`.env`),i=`utf8`,a=process.env;e&&e.processEnv!=null&&(a=e.processEnv);let o=c(a.DOTENV_CONFIG_DEBUG||e&&e.debug),l=c(a.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?i=e.encoding:o&&h(`no encoding is specified (UTF-8 is used by default)`);let d=[t];if(e&&e.path)if(!Array.isArray(e.path))d=[b(e.path)];else{d=[];for(let t of e.path)d.push(b(t))}let f,p={};for(let t of d)try{let r=E.parse(n.readFileSync(t,{encoding:i}));E.populate(p,r,e)}catch(e){o&&h(`failed to load ${t} ${e.message}`),f=e}let m=E.populate(a,p,e);if(o=c(a.DOTENV_CONFIG_DEBUG||o),l=c(a.DOTENV_CONFIG_QUIET||l),o||!l){let e=Object.keys(m).length,t=[];for(let e of d)try{let n=r.relative(process.cwd(),e);t.push(n)}catch(t){o&&h(`failed to load ${e} ${t.message}`),f=t}g(`injected env (${e}) from ${t.join(`,`)} ${u(`// tip: ${s()}`)}`)}return f?{parsed:p,error:f}:{parsed:p}}function C(e){if(_(e).length===0)return E.configDotenv(e);let t=y(e);return t?E._configVault(e):(m(`you set DOTENV_KEY but you are missing a .env.vault file at ${t}`),E.configDotenv(e))}function w(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),o=r.subarray(-16);r=r.subarray(12,-16);try{let e=a.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(o),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function T(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override),a={};if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n],a[n]=t[n]),r&&h(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):(e[n]=t[n],a[n]=t[n]);return a}var E={configDotenv:S,_configVault:x,_parseVault:p,config:C,decrypt:w,parse:f,populate:T};t.exports.configDotenv=E.configDotenv,t.exports._configVault=E._configVault,t.exports._parseVault=E._parseVault,t.exports.config=E.config,t.exports.decrypt=E.decrypt,t.exports.parse=E.parse,t.exports.populate=E.populate,t.exports=E}))(),1),f=(e={})=>{let{env:t,configPath:n}=e,r=u.default.resolve(n??process.cwd(),`.env${t?`.${t}`:``}`),{parsed:i}=d.config({path:r});return i},p=l(o(((e,t)=>{t.exports=s,s.default=s,s.stable=d,s.stableStringify=d;var n=`[...]`,r=`[Circular]`,i=[],a=[];function o(){return{depthLimit:2**53-1,edgesLimit:2**53-1}}function s(e,t,n,r){r===void 0&&(r=o()),l(e,``,0,[],void 0,0,r);var s;try{s=a.length===0?JSON.stringify(e,t,n):JSON.stringify(e,p(t),n)}catch{return JSON.stringify(`[unable to serialize, circular reference is too complex to analyze]`)}finally{for(;i.length!==0;){var c=i.pop();c.length===4?Object.defineProperty(c[0],c[1],c[3]):c[0][c[1]]=c[2]}}return s}function c(e,t,n,r){var o=Object.getOwnPropertyDescriptor(r,n);o.get===void 0?(r[n]=e,i.push([r,n,t])):o.configurable?(Object.defineProperty(r,n,{value:e}),i.push([r,n,t,o])):a.push([t,n,e])}function l(e,t,i,a,o,s,u){s+=1;var d;if(typeof e==`object`&&e){for(d=0;d<a.length;d++)if(a[d]===e){c(r,e,t,o);return}if(u.depthLimit!==void 0&&s>u.depthLimit){c(n,e,t,o);return}if(u.edgesLimit!==void 0&&i+1>u.edgesLimit){c(n,e,t,o);return}if(a.push(e),Array.isArray(e))for(d=0;d<e.length;d++)l(e[d],d,d,a,e,s,u);else{var f=Object.keys(e);for(d=0;d<f.length;d++){var p=f[d];l(e[p],p,d,a,e,s,u)}}a.pop()}}function u(e,t){return e<t?-1:+(e>t)}function d(e,t,n,r){r===void 0&&(r=o());var s=f(e,``,0,[],void 0,0,r)||e,c;try{c=a.length===0?JSON.stringify(s,t,n):JSON.stringify(s,p(t),n)}catch{return JSON.stringify(`[unable to serialize, circular reference is too complex to analyze]`)}finally{for(;i.length!==0;){var l=i.pop();l.length===4?Object.defineProperty(l[0],l[1],l[3]):l[0][l[1]]=l[2]}}return c}function f(e,t,a,o,s,l,d){l+=1;var p;if(typeof e==`object`&&e){for(p=0;p<o.length;p++)if(o[p]===e){c(r,e,t,s);return}try{if(typeof e.toJSON==`function`)return}catch{return}if(d.depthLimit!==void 0&&l>d.depthLimit){c(n,e,t,s);return}if(d.edgesLimit!==void 0&&a+1>d.edgesLimit){c(n,e,t,s);return}if(o.push(e),Array.isArray(e))for(p=0;p<e.length;p++)f(e[p],p,p,o,e,l,d);else{var m={},h=Object.keys(e).sort(u);for(p=0;p<h.length;p++){var g=h[p];f(e[g],g,p,o,e,l,d),m[g]=e[g]}if(s!==void 0)i.push([s,t,e]),s[t]=m;else return m}o.pop()}}function p(e){return e=e===void 0?function(e,t){return t}:e,function(t,n){if(a.length>0)for(var r=0;r<a.length;r++){var i=a[r];if(i[1]===t&&i[0]===n){n=i[2],a.splice(r,1);break}}return e.call(this,t,n)}}}))(),1),m={debug:`debug`,verbose:`debug`,log:`log`,warn:`warn`,error:`error`,fatal:`error`},h={verbose:`DEFAULT`,debug:`DEBUG`,log:`INFO`,warn:`WARNING`,error:`ERROR`,fatal:`CRITICAL`},g=[`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{levels=new Set([`verbose`,`debug`,`log`,`warn`,`error`,`fatal`]);constructor(e,t={}){this.module=e,t.logLevels&&(this.levels=new Set(t.logLevels))}mapLogLevelToConsoleMethod(e){return m[e]}write(e,t,n,r,i){if(!this.levels.has(e))return;let a=(0,p.default)(this.buildLog(e,t,n,r,i),this.sensitiveReplacer),o=this.mapLogLevelToConsoleMethod(e);console[o](a)}buildLog(e,t,n,r,i){let{writeMetadata:a,writeContext:o,writeError:s}=this.sanitizeLog(n,r,i),c={};return typeof t==`string`&&(c.textPayload=t),!a&&typeof t!=`string`&&!(t instanceof Error)&&(c.metadata=t),t instanceof Error&&(c.error=JSON.stringify(t,Object.getOwnPropertyNames(t))),o&&(c.context=o),a&&(c.metadata=a),!c.error&&s&&(c.error=JSON.stringify(s,Object.getOwnPropertyNames(s))),{severity:h[e],module:this.module,textPayload:c.textPayload,message:c}}sanitizeLog(e,t,n){if(t instanceof Error&&(!n||typeof n==`string`))return{writeMetadata:void 0,writeContext:e||n,writeError:t};let r=t,i=e;return typeof r==`string`&&!e&&(i=r,r=void 0),{writeMetadata:r,writeContext:i,writeError:n}}sensitiveReplacer(e,t){return g.includes(e.toLowerCase())?`[HIDDEN BY LOGGER]`:t}debug(e,t,n){this.write(`debug`,e,n,t)}verbose(e,t,n){this.write(`verbose`,e,n,t)}log(e,t,n){this.write(`log`,e,n,t)}warn(e,t,n,r){this.write(`warn`,e,r,t,n)}error(e,t,n,r){this.write(`error`,e,r,t,n)}fatal(e,t,n,r){this.write(`fatal`,e,r,t,n)}setLogLevels(e){this.levels=new Set(e)}},v=class{debug=()=>void 0;verbose=()=>void 0;log=()=>void 0;warn=()=>void 0;error=()=>void 0;fatal=()=>void 0;setLogLevels=()=>void 0},y=class e{em;constructor(e){this.dataSource=e}static newInstance(e){let t=e.constructor;return new t(e.dataSource)}withEntityManager(e){return this.em=e,this}withRepositoryManager(t){return e.newInstance(this).withEntityManager(t.em)}lockInTransaction(e=`pessimistic_write`){return this.em?{mode:e}:void 0}getRepository(e){return this.em?this.em.getRepository(e):this.dataSource.getRepository(e)}async withTransaction(t){let n;return await this.dataSource.transaction(async r=>{n=await t(e.newInstance(this).withEntityManager(r))}),n}},b=e=>({...e,withTransaction:async t=>await t(e),withRepositoryManager:()=>e}),x=(e,t)=>`unaccent(LOWER(${e})) ILIKE unaccent(LOWER(:${t}))`,S=s({unaccentSearch:()=>x});exports.GCPLogger=_,exports.LogLevelToConsoleMethodMap=m,exports.MockLogger=v,exports.TransactionalRepository=y,exports.buildTransactionalRepositoryMock=b,exports.loadEnvConfig=f,Object.defineProperty(exports,`postgres`,{enumerable:!0,get:function(){return S}});
package/dist/index.mjs CHANGED
@@ -286,7 +286,7 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr
286
286
  }
287
287
  }
288
288
  function u(e, t) {
289
- return e < t ? -1 : e > t ? 1 : 0;
289
+ return e < t ? -1 : +(e > t);
290
290
  }
291
291
  function d(e, t, n, r) {
292
292
  r === void 0 && (r = o());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsfsi-core/ts-nodejs",
3
- "version": "1.1.42",
3
+ "version": "1.1.43",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,9 +40,9 @@
40
40
  "typeorm": "0.3.28"
41
41
  },
42
42
  "devDependencies": {
43
- "@vitest/coverage-v8": "4.1.2",
43
+ "@vitest/coverage-v8": "4.1.3",
44
44
  "vite": "^8.0.5",
45
45
  "vite-plugin-dts": "4.5.4",
46
- "vitest": "4.1.2"
46
+ "vitest": "4.1.3"
47
47
  }
48
48
  }