@infineit-nestjs/services 1.0.49 → 1.1.0-cursor-ai.0

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.
Files changed (66) hide show
  1. package/dist/cjs/index.js +2 -1
  2. package/dist/cjs/node_modules/decimal.js/decimal.js +10 -0
  3. package/dist/cjs/node_modules/tslib/tslib.es6.js +2 -0
  4. package/dist/cjs/services/argon2.service.js +2 -1
  5. package/dist/cjs/services/data.transformer.service.js +2 -1
  6. package/dist/cjs/services/decimal.utils.service.js +2 -1
  7. package/dist/cjs/services/entity.action.service.js +2 -1
  8. package/dist/cjs/services/http.client.service.js +2 -1
  9. package/dist/cjs/services/index.js +2 -1
  10. package/dist/cjs/services/kafka.microservice.js +2 -1
  11. package/dist/cjs/services/logger.service.d.ts +2 -29
  12. package/dist/cjs/services/logger.service.js +2 -1
  13. package/dist/cjs/services/merge.service.js +2 -1
  14. package/dist/cjs/services/message.formatter.service.js +2 -1
  15. package/dist/cjs/services/pagination.service.js +2 -1
  16. package/dist/cjs/services/prisma.service.d.ts +39 -2
  17. package/dist/cjs/services/prisma.service.js +2 -1
  18. package/dist/cjs/services/redis.service.js +2 -1
  19. package/dist/cjs/services/resource.fetch.service.js +2 -1
  20. package/dist/cjs/services/util.service.js +2 -1
  21. package/dist/cjs/services/validator.service.js +2 -1
  22. package/dist/es/index.mjs +2 -0
  23. package/dist/es/node_modules/decimal.js/decimal.mjs +9 -0
  24. package/dist/es/node_modules/tslib/tslib.es6.mjs +2 -0
  25. package/dist/es/services/argon2.service.mjs +2 -0
  26. package/dist/es/services/data.transformer.service.mjs +2 -0
  27. package/dist/es/services/decimal.utils.service.mjs +2 -0
  28. package/dist/es/services/entity.action.service.mjs +2 -0
  29. package/dist/es/services/http.client.service.mjs +2 -0
  30. package/dist/es/services/index.mjs +2 -0
  31. package/dist/es/services/kafka.microservice.mjs +2 -0
  32. package/dist/es/services/logger.service.d.ts +2 -29
  33. package/dist/es/services/logger.service.mjs +2 -0
  34. package/dist/es/services/merge.service.mjs +2 -0
  35. package/dist/es/services/message.formatter.service.mjs +2 -0
  36. package/dist/es/services/pagination.service.mjs +2 -0
  37. package/dist/es/services/prisma.service.d.ts +39 -2
  38. package/dist/es/services/prisma.service.mjs +2 -0
  39. package/dist/es/services/redis.service.mjs +2 -0
  40. package/dist/es/services/resource.fetch.service.mjs +2 -0
  41. package/dist/es/services/util.service.mjs +2 -0
  42. package/dist/es/services/validator.service.mjs +2 -0
  43. package/dist/types/index.d.ts +2 -2
  44. package/dist/types/services/entity.action.service.d.ts +1 -1
  45. package/dist/types/services/http.client.service.d.ts +1 -1
  46. package/dist/types/services/index.d.ts +2 -2
  47. package/dist/types/services/logger.service.d.ts +1 -33
  48. package/dist/types/services/prisma.service.d.ts +40 -2
  49. package/package.json +18 -6
  50. package/dist/es/index.js +0 -1
  51. package/dist/es/services/argon2.service.js +0 -1
  52. package/dist/es/services/data.transformer.service.js +0 -1
  53. package/dist/es/services/decimal.utils.service.js +0 -1
  54. package/dist/es/services/entity.action.service.js +0 -1
  55. package/dist/es/services/http.client.service.js +0 -1
  56. package/dist/es/services/index.js +0 -1
  57. package/dist/es/services/kafka.microservice.js +0 -1
  58. package/dist/es/services/logger.service.js +0 -1
  59. package/dist/es/services/merge.service.js +0 -1
  60. package/dist/es/services/message.formatter.service.js +0 -1
  61. package/dist/es/services/pagination.service.js +0 -1
  62. package/dist/es/services/prisma.service.js +0 -1
  63. package/dist/es/services/redis.service.js +0 -1
  64. package/dist/es/services/resource.fetch.service.js +0 -1
  65. package/dist/es/services/util.service.js +0 -1
  66. package/dist/es/services/validator.service.js +0 -1
package/dist/cjs/index.js CHANGED
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./services/argon2.service"),exports),e.__exportStar(require("./services/data.transformer.service"),exports),e.__exportStar(require("./services/entity.action.service"),exports),e.__exportStar(require("./services/http.client.service"),exports),e.__exportStar(require("./services/kafka.microservice"),exports),e.__exportStar(require("./services/logger.service"),exports),e.__exportStar(require("./services/merge.service"),exports),e.__exportStar(require("./services/message.formatter.service"),exports),e.__exportStar(require("./services/pagination.service"),exports),e.__exportStar(require("./services/prisma.service"),exports),e.__exportStar(require("./services/resource.fetch.service"),exports),e.__exportStar(require("./services/redis.service"),exports),e.__exportStar(require("./services/util.service"),exports),e.__exportStar(require("./services/validator.service"),exports),e.__exportStar(require("./services/decimal.utils.service"),exports);
1
+ "use strict";var e=require("./services/argon2.service.js"),r=require("./services/data.transformer.service.js"),t=require("./services/entity.action.service.js"),i=require("./services/http.client.service.js"),s=require("./services/kafka.microservice.js"),c=require("@infineit/winston-logger"),n=require("./services/merge.service.js"),o=require("./services/message.formatter.service.js"),u=require("./services/pagination.service.js"),a=require("./services/prisma.service.js"),v=require("./services/resource.fetch.service.js"),p=require("./services/redis.service.js"),f=require("./services/util.service.js"),g=require("./services/validator.service.js"),m=require("./services/decimal.utils.service.js");Object.defineProperty(exports,"Argon2Service",{enumerable:!0,get:function(){return e.Argon2Service}}),Object.defineProperty(exports,"DataTransformerService",{enumerable:!0,get:function(){return r.DataTransformerService}}),Object.defineProperty(exports,"EntityActionService",{enumerable:!0,get:function(){return t.EntityActionService}}),Object.defineProperty(exports,"HttpServiceClient",{enumerable:!0,get:function(){return i.HttpServiceClient}}),exports.rethrowHttpByStatus=i.rethrowHttpByStatus,exports.InitKafkaConsumer=s.InitKafkaConsumer,Object.defineProperty(exports,"LoggerService",{enumerable:!0,get:function(){return c.LoggerService}}),Object.defineProperty(exports,"MergeService",{enumerable:!0,get:function(){return n.MergeService}}),Object.defineProperty(exports,"MessageFormatterService",{enumerable:!0,get:function(){return o.MessageFormatterService}}),Object.defineProperty(exports,"PaginationService",{enumerable:!0,get:function(){return u.PaginationService}}),Object.defineProperty(exports,"PrismaService",{enumerable:!0,get:function(){return a.PrismaService}}),exports.MissingDataError=v.MissingDataError,Object.defineProperty(exports,"ResourceFetchService",{enumerable:!0,get:function(){return v.ResourceFetchService}}),Object.defineProperty(exports,"RedisService",{enumerable:!0,get:function(){return p.RedisService}}),exports.UtilsService=f.UtilsService,Object.defineProperty(exports,"ValidatorService",{enumerable:!0,get:function(){return g.ValidatorService}}),Object.defineProperty(exports,"DecimalUtilsService",{enumerable:!0,get:function(){return m.DecimalUtilsService}});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
2
+ /*!
3
+ * decimal.js v10.6.0
4
+ * An arbitrary-precision Decimal type for JavaScript.
5
+ * https://github.com/MikeMcl/decimal.js
6
+ * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
7
+ * MIT Licence
8
+ */
9
+ var n,e,i=9e15,r=1e9,t="0123456789abcdef",s="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",o="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",u={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-i,maxE:i,crypto:!1},c=!0,f="[DecimalError] ",a=f+"Invalid argument: ",h=f+"Precision limit exceeded",d=f+"crypto unavailable",l="[object Decimal]",p=Math.floor,g=Math.pow,w=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,m=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,v=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,N=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,b=1e7,x=s.length-1,E=o.length-1,y={toStringTag:l};function M(n){var e,i,r,t=n.length-1,s="",o=n[0];if(t>0){for(s+=o,e=1;e<t;e++)(i=7-(r=n[e]+"").length)&&(s+=T(i)),s+=r;(i=7-(r=(o=n[e])+"").length)&&(s+=T(i))}else if(0===o)return"0";for(;o%10==0;)o/=10;return s+o}function q(n,e,i){if(n!==~~n||n<e||n>i)throw Error(a+n)}function O(n,e,i,r){var t,s,o,u;for(s=n[0];s>=10;s/=10)--e;return--e<0?(e+=7,t=0):(t=Math.ceil((e+1)/7),e%=7),s=g(10,7-e),u=n[t]%s|0,null==r?e<3?(0==e?u=u/100|0:1==e&&(u=u/10|0),o=i<4&&99999==u||i>3&&49999==u||5e4==u||0==u):o=(i<4&&u+1==s||i>3&&u+1==s/2)&&(n[t+1]/s/100|0)==g(10,e-2)-1||(u==s/2||0==u)&&!(n[t+1]/s/100|0):e<4?(0==e?u=u/1e3|0:1==e?u=u/100|0:2==e&&(u=u/10|0),o=(r||i<4)&&9999==u||!r&&i>3&&4999==u):o=((r||i<4)&&u+1==s||!r&&i>3&&u+1==s/2)&&(n[t+1]/s/1e3|0)==g(10,e-3)-1,o}function F(n,e,i){for(var r,s,o=[0],u=0,c=n.length;u<c;){for(s=o.length;s--;)o[s]*=e;for(o[0]+=t.indexOf(n.charAt(u++)),r=0;r<o.length;r++)o[r]>i-1&&(void 0===o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/i|0,o[r]%=i)}return o.reverse()}y.absoluteValue=y.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),D(n)},y.ceil=function(){return D(new this.constructor(this),this.e+1,2)},y.clampedTo=y.clamp=function(n,e){var i=this,r=i.constructor;if(n=new r(n),e=new r(e),!n.s||!e.s)return new r(NaN);if(n.gt(e))throw Error(a+e);return i.cmp(n)<0?n:i.cmp(e)>0?e:new r(i)},y.comparedTo=y.cmp=function(n){var e,i,r,t,s=this,o=s.d,u=(n=new s.constructor(n)).d,c=s.s,f=n.s;if(!o||!u)return c&&f?c!==f?c:o===u?0:!o^c<0?1:-1:NaN;if(!o[0]||!u[0])return o[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==n.e)return s.e>n.e^c<0?1:-1;for(e=0,i=(r=o.length)<(t=u.length)?r:t;e<i;++e)if(o[e]!==u[e])return o[e]>u[e]^c<0?1:-1;return r===t?0:r>t^c<0?1:-1},y.cosine=y.cos=function(){var n,i,r=this,t=r.constructor;return r.d?r.d[0]?(n=t.precision,i=t.rounding,t.precision=n+Math.max(r.e,r.sd())+7,t.rounding=1,r=function(n,e){var i,r,t;if(e.isZero())return e;r=e.d.length,r<32?t=(1/$(4,i=Math.ceil(r/3))).toString():(i=16,t="2.3283064365386962890625e-10");n.precision+=i,e=j(n,1,e.times(t),new n(1));for(var s=i;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=i,e}(t,W(t,r)),t.precision=n,t.rounding=i,D(2==e||3==e?r.neg():r,n,i,!0)):new t(1):new t(NaN)},y.cubeRoot=y.cbrt=function(){var n,e,i,r,t,s,o,u,f,a,h=this,d=h.constructor;if(!h.isFinite()||h.isZero())return new d(h);for(c=!1,(s=h.s*g(h.s*h,1/3))&&Math.abs(s)!=1/0?r=new d(s.toString()):(i=M(h.d),(s=((n=h.e)-i.length+1)%3)&&(i+=1==s||-2==s?"0":"00"),s=g(i,1/3),n=p((n+1)/3)-(n%3==(n<0?-1:2)),(r=new d(i=s==1/0?"5e"+n:(i=s.toExponential()).slice(0,i.indexOf("e")+1)+n)).s=h.s),o=(n=d.precision)+3;;)if(a=(f=(u=r).times(u).times(u)).plus(h),r=A(a.plus(h).times(u),a.plus(f),o+2,1),M(u.d).slice(0,o)===(i=M(r.d)).slice(0,o)){if("9999"!=(i=i.slice(o-3,o+1))&&(t||"4999"!=i)){+i&&(+i.slice(1)||"5"!=i.charAt(0))||(D(r,n+1,1),e=!r.times(r).times(r).eq(h));break}if(!t&&(D(u,n+1,0),u.times(u).times(u).eq(h))){r=u;break}o+=4,t=1}return c=!0,D(r,n,d.rounding,e)},y.decimalPlaces=y.dp=function(){var n,e=this.d,i=NaN;if(e){if(i=7*((n=e.length-1)-p(this.e/7)),n=e[n])for(;n%10==0;n/=10)i--;i<0&&(i=0)}return i},y.dividedBy=y.div=function(n){return A(this,new this.constructor(n))},y.dividedToIntegerBy=y.divToInt=function(n){var e=this.constructor;return D(A(this,new e(n),0,1,1),e.precision,e.rounding)},y.equals=y.eq=function(n){return 0===this.cmp(n)},y.floor=function(){return D(new this.constructor(this),this.e+1,3)},y.greaterThan=y.gt=function(n){return this.cmp(n)>0},y.greaterThanOrEqualTo=y.gte=function(n){var e=this.cmp(n);return 1==e||0===e},y.hyperbolicCosine=y.cosh=function(){var n,e,i,r,t,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;i=o.precision,r=o.rounding,o.precision=i+Math.max(s.e,s.sd())+4,o.rounding=1,(t=s.d.length)<32?e=(1/$(4,n=Math.ceil(t/3))).toString():(n=16,e="2.3283064365386962890625e-10"),s=j(o,1,s.times(e),new o(1),!0);for(var c,f=n,a=new o(8);f--;)c=s.times(s),s=u.minus(c.times(a.minus(c.times(a))));return D(s,o.precision=i,o.rounding=r,!0)},y.hyperbolicSine=y.sinh=function(){var n,e,i,r,t=this,s=t.constructor;if(!t.isFinite()||t.isZero())return new s(t);if(e=s.precision,i=s.rounding,s.precision=e+Math.max(t.e,t.sd())+4,s.rounding=1,(r=t.d.length)<3)t=j(s,2,t,t,!0);else{n=(n=1.4*Math.sqrt(r))>16?16:0|n,t=j(s,2,t=t.times(1/$(5,n)),t,!0);for(var o,u=new s(5),c=new s(16),f=new s(20);n--;)o=t.times(t),t=t.times(u.plus(o.times(c.times(o).plus(f))))}return s.precision=e,s.rounding=i,D(t,e,i,!0)},y.hyperbolicTangent=y.tanh=function(){var n,e,i=this,r=i.constructor;return i.isFinite()?i.isZero()?new r(i):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,A(i.sinh(),i.cosh(),r.precision=n,r.rounding=e)):new r(i.s)},y.inverseCosine=y.acos=function(){var n=this,e=n.constructor,i=n.abs().cmp(1),r=e.precision,t=e.rounding;return-1!==i?0===i?n.isNeg()?_(e,r,t):new e(0):new e(NaN):n.isZero()?_(e,r+4,t).times(.5):(e.precision=r+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=r,e.rounding=t,n.times(2))},y.inverseHyperbolicCosine=y.acosh=function(){var n,e,i=this,r=i.constructor;return i.lte(1)?new r(i.eq(1)?0:NaN):i.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(i.e),i.sd())+4,r.rounding=1,c=!1,i=i.times(i).minus(1).sqrt().plus(i),c=!0,r.precision=n,r.rounding=e,i.ln()):new r(i)},y.inverseHyperbolicSine=y.asinh=function(){var n,e,i=this,r=i.constructor;return!i.isFinite()||i.isZero()?new r(i):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(i.e),i.sd())+6,r.rounding=1,c=!1,i=i.times(i).plus(1).sqrt().plus(i),c=!0,r.precision=n,r.rounding=e,i.ln())},y.inverseHyperbolicTangent=y.atanh=function(){var n,e,i,r,t=this,s=t.constructor;return t.isFinite()?t.e>=0?new s(t.abs().eq(1)?t.s/0:t.isZero()?t:NaN):(n=s.precision,e=s.rounding,r=t.sd(),Math.max(r,n)<2*-t.e-1?D(new s(t),n,e,!0):(s.precision=i=r-t.e,t=A(t.plus(1),new s(1).minus(t),i+n,1),s.precision=n+4,s.rounding=1,t=t.ln(),s.precision=n,s.rounding=e,t.times(.5))):new s(NaN)},y.inverseSine=y.asin=function(){var n,e,i,r,t=this,s=t.constructor;return t.isZero()?new s(t):(e=t.abs().cmp(1),i=s.precision,r=s.rounding,-1!==e?0===e?((n=_(s,i+4,r).times(.5)).s=t.s,n):new s(NaN):(s.precision=i+6,s.rounding=1,t=t.div(new s(1).minus(t.times(t)).sqrt().plus(1)).atan(),s.precision=i,s.rounding=r,t.times(2)))},y.inverseTangent=y.atan=function(){var n,e,i,r,t,s,o,u,f,a=this,h=a.constructor,d=h.precision,l=h.rounding;if(a.isFinite()){if(a.isZero())return new h(a);if(a.abs().eq(1)&&d+4<=E)return(o=_(h,d+4,l).times(.25)).s=a.s,o}else{if(!a.s)return new h(NaN);if(d+4<=E)return(o=_(h,d+4,l).times(.5)).s=a.s,o}for(h.precision=u=d+10,h.rounding=1,n=i=Math.min(28,u/7+2|0);n;--n)a=a.div(a.times(a).plus(1).sqrt().plus(1));for(c=!1,e=Math.ceil(u/7),r=1,f=a.times(a),o=new h(a),t=a;-1!==n;)if(t=t.times(f),s=o.minus(t.div(r+=2)),t=t.times(f),void 0!==(o=s.plus(t.div(r+=2))).d[e])for(n=e;o.d[n]===s.d[n]&&n--;);return i&&(o=o.times(2<<i-1)),c=!0,D(o,h.precision=d,h.rounding=l,!0)},y.isFinite=function(){return!!this.d},y.isInteger=y.isInt=function(){return!!this.d&&p(this.e/7)>this.d.length-2},y.isNaN=function(){return!this.s},y.isNegative=y.isNeg=function(){return this.s<0},y.isPositive=y.isPos=function(){return this.s>0},y.isZero=function(){return!!this.d&&0===this.d[0]},y.lessThan=y.lt=function(n){return this.cmp(n)<0},y.lessThanOrEqualTo=y.lte=function(n){return this.cmp(n)<1},y.logarithm=y.log=function(n){var e,i,r,t,s,o,u,f,a=this,h=a.constructor,d=h.precision,l=h.rounding;if(null==n)n=new h(10),e=!0;else{if(i=(n=new h(n)).d,n.s<0||!i||!i[0]||n.eq(1))return new h(NaN);e=n.eq(10)}if(i=a.d,a.s<0||!i||!i[0]||a.eq(1))return new h(i&&!i[0]?-1/0:1!=a.s?NaN:i?0:1/0);if(e)if(i.length>1)s=!0;else{for(t=i[0];t%10==0;)t/=10;s=1!==t}if(c=!1,o=C(a,u=d+5),r=e?P(h,u+10):C(n,u),O((f=A(o,r,u,1)).d,t=d,l))do{if(o=C(a,u+=10),r=e?P(h,u+10):C(n,u),f=A(o,r,u,1),!s){+M(f.d).slice(t+1,t+15)+1==1e14&&(f=D(f,d+1,0));break}}while(O(f.d,t+=10,l));return c=!0,D(f,d,l)},y.minus=y.sub=function(n){var e,i,r,t,s,o,u,f,a,h,d,l,g=this,w=g.constructor;if(n=new w(n),!g.d||!n.d)return g.s&&n.s?g.d?n.s=-n.s:n=new w(n.d||g.s!==n.s?g:NaN):n=new w(NaN),n;if(g.s!=n.s)return n.s=-n.s,g.plus(n);if(a=g.d,l=n.d,u=w.precision,f=w.rounding,!a[0]||!l[0]){if(l[0])n.s=-n.s;else{if(!a[0])return new w(3===f?-0:0);n=new w(g)}return c?D(n,u,f):n}if(i=p(n.e/7),h=p(g.e/7),a=a.slice(),s=h-i){for((d=s<0)?(e=a,s=-s,o=l.length):(e=l,i=h,o=a.length),s>(r=Math.max(Math.ceil(u/7),o)+2)&&(s=r,e.length=1),e.reverse(),r=s;r--;)e.push(0);e.reverse()}else{for((d=(r=a.length)<(o=l.length))&&(o=r),r=0;r<o;r++)if(a[r]!=l[r]){d=a[r]<l[r];break}s=0}for(d&&(e=a,a=l,l=e,n.s=-n.s),o=a.length,r=l.length-o;r>0;--r)a[o++]=0;for(r=l.length;r>s;){if(a[--r]<l[r]){for(t=r;t&&0===a[--t];)a[t]=b-1;--a[t],a[r]+=b}a[r]-=l[r]}for(;0===a[--o];)a.pop();for(;0===a[0];a.shift())--i;return a[0]?(n.d=a,n.e=S(a,i),c?D(n,u,f):n):new w(3===f?-0:0)},y.modulo=y.mod=function(n){var e,i=this,r=i.constructor;return n=new r(n),!i.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||i.d&&!i.d[0]?D(new r(i),r.precision,r.rounding):(c=!1,9==r.modulo?(e=A(i,n.abs(),0,3,1)).s*=n.s:e=A(i,n,0,r.modulo,1),e=e.times(n),c=!0,i.minus(e))},y.naturalExponential=y.exp=function(){return I(this)},y.naturalLogarithm=y.ln=function(){return C(this)},y.negated=y.neg=function(){var n=new this.constructor(this);return n.s=-n.s,D(n)},y.plus=y.add=function(n){var e,i,r,t,s,o,u,f,a,h,d=this,l=d.constructor;if(n=new l(n),!d.d||!n.d)return d.s&&n.s?d.d||(n=new l(n.d||d.s===n.s?d:NaN)):n=new l(NaN),n;if(d.s!=n.s)return n.s=-n.s,d.minus(n);if(a=d.d,h=n.d,u=l.precision,f=l.rounding,!a[0]||!h[0])return h[0]||(n=new l(d)),c?D(n,u,f):n;if(s=p(d.e/7),r=p(n.e/7),a=a.slice(),t=s-r){for(t<0?(i=a,t=-t,o=h.length):(i=h,r=s,o=a.length),t>(o=(s=Math.ceil(u/7))>o?s+1:o+1)&&(t=o,i.length=1),i.reverse();t--;)i.push(0);i.reverse()}for((o=a.length)-(t=h.length)<0&&(t=o,i=h,h=a,a=i),e=0;t;)e=(a[--t]=a[t]+h[t]+e)/b|0,a[t]%=b;for(e&&(a.unshift(e),++r),o=a.length;0==a[--o];)a.pop();return n.d=a,n.e=S(a,r),c?D(n,u,f):n},y.precision=y.sd=function(n){var e,i=this;if(void 0!==n&&n!==!!n&&1!==n&&0!==n)throw Error(a+n);return i.d?(e=R(i.d),n&&i.e+1>e&&(e=i.e+1)):e=NaN,e},y.round=function(){var n=this,e=n.constructor;return D(new e(n),n.e+1,e.rounding)},y.sine=y.sin=function(){var n,i,r=this,t=r.constructor;return r.isFinite()?r.isZero()?new t(r):(n=t.precision,i=t.rounding,t.precision=n+Math.max(r.e,r.sd())+7,t.rounding=1,r=function(n,e){var i,r=e.d.length;if(r<3)return e.isZero()?e:j(n,2,e,e);i=(i=1.4*Math.sqrt(r))>16?16:0|i,e=e.times(1/$(5,i)),e=j(n,2,e,e);for(var t,s=new n(5),o=new n(16),u=new n(20);i--;)t=e.times(e),e=e.times(s.plus(t.times(o.times(t).minus(u))));return e}(t,W(t,r)),t.precision=n,t.rounding=i,D(e>2?r.neg():r,n,i,!0)):new t(NaN)},y.squareRoot=y.sqrt=function(){var n,e,i,r,t,s,o=this,u=o.d,f=o.e,a=o.s,h=o.constructor;if(1!==a||!u||!u[0])return new h(!a||a<0&&(!u||u[0])?NaN:u?o:1/0);for(c=!1,0==(a=Math.sqrt(+o))||a==1/0?(((e=M(u)).length+f)%2==0&&(e+="0"),a=Math.sqrt(e),f=p((f+1)/2)-(f<0||f%2),r=new h(e=a==1/0?"5e"+f:(e=a.toExponential()).slice(0,e.indexOf("e")+1)+f)):r=new h(a.toString()),i=(f=h.precision)+3;;)if(r=(s=r).plus(A(o,s,i+2,1)).times(.5),M(s.d).slice(0,i)===(e=M(r.d)).slice(0,i)){if("9999"!=(e=e.slice(i-3,i+1))&&(t||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(D(r,f+1,1),n=!r.times(r).eq(o));break}if(!t&&(D(s,f+1,0),s.times(s).eq(o))){r=s;break}i+=4,t=1}return c=!0,D(r,f,h.rounding,n)},y.tangent=y.tan=function(){var n,i,r=this,t=r.constructor;return r.isFinite()?r.isZero()?new t(r):(n=t.precision,i=t.rounding,t.precision=n+10,t.rounding=1,(r=r.sin()).s=1,r=A(r,new t(1).minus(r.times(r)).sqrt(),n+10,0),t.precision=n,t.rounding=i,D(2==e||4==e?r.neg():r,n,i,!0)):new t(NaN)},y.times=y.mul=function(n){var e,i,r,t,s,o,u,f,a,h=this,d=h.constructor,l=h.d,g=(n=new d(n)).d;if(n.s*=h.s,!(l&&l[0]&&g&&g[0]))return new d(!n.s||l&&!l[0]&&!g||g&&!g[0]&&!l?NaN:l&&g?0*n.s:n.s/0);for(i=p(h.e/7)+p(n.e/7),(f=l.length)<(a=g.length)&&(s=l,l=g,g=s,o=f,f=a,a=o),s=[],r=o=f+a;r--;)s.push(0);for(r=a;--r>=0;){for(e=0,t=f+r;t>r;)u=s[t]+g[r]*l[t-r-1]+e,s[t--]=u%b|0,e=u/b|0;s[t]=(s[t]+e)%b|0}for(;!s[--o];)s.pop();return e?++i:s.shift(),n.d=s,n.e=S(s,i),c?D(n,d.precision,d.rounding):n},y.toBinary=function(n,e){return J(this,2,n,e)},y.toDecimalPlaces=y.toDP=function(n,e){var i=this,t=i.constructor;return i=new t(i),void 0===n?i:(q(n,0,r),void 0===e?e=t.rounding:q(e,0,8),D(i,n+i.e+1,e))},y.toExponential=function(n,e){var i,t=this,s=t.constructor;return void 0===n?i=Z(t,!0):(q(n,0,r),void 0===e?e=s.rounding:q(e,0,8),i=Z(t=D(new s(t),n+1,e),!0,n+1)),t.isNeg()&&!t.isZero()?"-"+i:i},y.toFixed=function(n,e){var i,t,s=this,o=s.constructor;return void 0===n?i=Z(s):(q(n,0,r),void 0===e?e=o.rounding:q(e,0,8),i=Z(t=D(new o(s),n+s.e+1,e),!1,n+t.e+1)),s.isNeg()&&!s.isZero()?"-"+i:i},y.toFraction=function(n){var e,i,r,t,s,o,u,f,h,d,l,p,w=this,m=w.d,v=w.constructor;if(!m)return new v(w);if(h=i=new v(1),r=f=new v(0),o=(s=(e=new v(r)).e=R(m)-w.e-1)%7,e.d[0]=g(10,o<0?7+o:o),null==n)n=s>0?e:h;else{if(!(u=new v(n)).isInt()||u.lt(h))throw Error(a+u);n=u.gt(e)?s>0?e:h:u}for(c=!1,u=new v(M(m)),d=v.precision,v.precision=s=7*m.length*2;l=A(u,e,0,1,1),1!=(t=i.plus(l.times(r))).cmp(n);)i=r,r=t,t=h,h=f.plus(l.times(t)),f=t,t=e,e=u.minus(l.times(t)),u=t;return t=A(n.minus(i),r,0,1,1),f=f.plus(t.times(h)),i=i.plus(t.times(r)),f.s=h.s=w.s,p=A(h,r,s,1).minus(w).abs().cmp(A(f,i,s,1).minus(w).abs())<1?[h,r]:[f,i],v.precision=d,c=!0,p},y.toHexadecimal=y.toHex=function(n,e){return J(this,16,n,e)},y.toNearest=function(n,e){var i=this,r=i.constructor;if(i=new r(i),null==n){if(!i.d)return i;n=new r(1),e=r.rounding}else{if(n=new r(n),void 0===e?e=r.rounding:q(e,0,8),!i.d)return n.s?i:n;if(!n.d)return n.s&&(n.s=i.s),n}return n.d[0]?(c=!1,i=A(i,n,0,e,1).times(n),c=!0,D(i)):(n.s=i.s,i=n),i},y.toNumber=function(){return+this},y.toOctal=function(n,e){return J(this,8,n,e)},y.toPower=y.pow=function(n){var e,i,r,t,s,o,u=this,f=u.constructor,a=+(n=new f(n));if(!(u.d&&n.d&&u.d[0]&&n.d[0]))return new f(g(+u,a));if((u=new f(u)).eq(1))return u;if(r=f.precision,s=f.rounding,n.eq(1))return D(u,r,s);if((e=p(n.e/7))>=n.d.length-1&&(i=a<0?-a:a)<=9007199254740991)return t=L(f,u,i,r),n.s<0?new f(1).div(t):D(t,r,s);if((o=u.s)<0){if(e<n.d.length-1)return new f(NaN);if(1&n.d[e]||(o=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=o,u}return(e=0!=(i=g(+u,a))&&isFinite(i)?new f(i+"").e:p(a*(Math.log("0."+M(u.d))/Math.LN10+u.e+1)))>f.maxE+1||e<f.minE-1?new f(e>0?o/0:0):(c=!1,f.rounding=u.s=1,i=Math.min(12,(e+"").length),(t=I(n.times(C(u,r+i)),r)).d&&O((t=D(t,r+5,1)).d,r,s)&&(e=r+10,+M((t=D(I(n.times(C(u,e+i)),e),e+5,1)).d).slice(r+1,r+15)+1==1e14&&(t=D(t,r+1,0))),t.s=o,c=!0,f.rounding=s,D(t,r,s))},y.toPrecision=function(n,e){var i,t=this,s=t.constructor;return void 0===n?i=Z(t,t.e<=s.toExpNeg||t.e>=s.toExpPos):(q(n,1,r),void 0===e?e=s.rounding:q(e,0,8),i=Z(t=D(new s(t),n,e),n<=t.e||t.e<=s.toExpNeg,n)),t.isNeg()&&!t.isZero()?"-"+i:i},y.toSignificantDigits=y.toSD=function(n,e){var i=this.constructor;return void 0===n?(n=i.precision,e=i.rounding):(q(n,1,r),void 0===e?e=i.rounding:q(e,0,8)),D(new i(this),n,e)},y.toString=function(){var n=this,e=n.constructor,i=Z(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+i:i},y.truncated=y.trunc=function(){return D(new this.constructor(this),this.e+1,1)},y.valueOf=y.toJSON=function(){var n=this,e=n.constructor,i=Z(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+i:i};var A=function(){function e(n,e,i){var r,t=0,s=n.length;for(n=n.slice();s--;)r=n[s]*e+t,n[s]=r%i|0,t=r/i|0;return t&&n.unshift(t),n}function i(n,e,i,r){var t,s;if(i!=r)s=i>r?1:-1;else for(t=s=0;t<i;t++)if(n[t]!=e[t]){s=n[t]>e[t]?1:-1;break}return s}function r(n,e,i,r){for(var t=0;i--;)n[i]-=t,t=n[i]<e[i]?1:0,n[i]=t*r+n[i]-e[i];for(;!n[0]&&n.length>1;)n.shift()}return function(t,s,o,u,c,f){var a,h,d,l,g,w,m,v,N,x,E,y,M,q,O,F,A,Z,S,P,_=t.constructor,R=t.s==s.s?1:-1,T=t.d,L=s.d;if(!(T&&T[0]&&L&&L[0]))return new _(t.s&&s.s&&(T?!L||T[0]!=L[0]:L)?T&&0==T[0]||!L?0*R:R/0:NaN);for(f?(g=1,h=t.e-s.e):(f=b,g=7,h=p(t.e/g)-p(s.e/g)),S=L.length,A=T.length,x=(N=new _(R)).d=[],d=0;L[d]==(T[d]||0);d++);if(L[d]>(T[d]||0)&&h--,null==o?(q=o=_.precision,u=_.rounding):q=c?o+(t.e-s.e)+1:o,q<0)x.push(1),w=!0;else{if(q=q/g+2|0,d=0,1==S){for(l=0,L=L[0],q++;(d<A||l)&&q--;d++)O=l*f+(T[d]||0),x[d]=O/L|0,l=O%L|0;w=l||d<A}else{for((l=f/(L[0]+1)|0)>1&&(L=e(L,l,f),T=e(T,l,f),S=L.length,A=T.length),F=S,y=(E=T.slice(0,S)).length;y<S;)E[y++]=0;(P=L.slice()).unshift(0),Z=L[0],L[1]>=f/2&&++Z;do{l=0,(a=i(L,E,S,y))<0?(M=E[0],S!=y&&(M=M*f+(E[1]||0)),(l=M/Z|0)>1?(l>=f&&(l=f-1),1==(a=i(m=e(L,l,f),E,v=m.length,y=E.length))&&(l--,r(m,S<v?P:L,v,f))):(0==l&&(a=l=1),m=L.slice()),(v=m.length)<y&&m.unshift(0),r(E,m,y,f),-1==a&&(a=i(L,E,S,y=E.length))<1&&(l++,r(E,S<y?P:L,y,f)),y=E.length):0===a&&(l++,E=[0]),x[d++]=l,a&&E[0]?E[y++]=T[F]||0:(E=[T[F]],y=1)}while((F++<A||void 0!==E[0])&&q--);w=void 0!==E[0]}x[0]||x.shift()}if(1==g)N.e=h,n=w;else{for(d=1,l=x[0];l>=10;l/=10)d++;N.e=d+h*g-1,D(N,c?o+N.e+1:o,u,w)}return N}}();function D(n,e,i,r){var t,s,o,u,f,a,h,d,l,p=n.constructor;n:if(null!=e){if(!(d=n.d))return n;for(t=1,u=d[0];u>=10;u/=10)t++;if((s=e-t)<0)s+=7,o=e,f=(h=d[l=0])/g(10,t-o-1)%10|0;else if((l=Math.ceil((s+1)/7))>=(u=d.length)){if(!r)break n;for(;u++<=l;)d.push(0);h=f=0,t=1,o=(s%=7)-7+1}else{for(h=u=d[l],t=1;u>=10;u/=10)t++;f=(o=(s%=7)-7+t)<0?0:h/g(10,t-o-1)%10|0}if(r=r||e<0||void 0!==d[l+1]||(o<0?h:h%g(10,t-o-1)),a=i<4?(f||r)&&(0==i||i==(n.s<0?3:2)):f>5||5==f&&(4==i||r||6==i&&(s>0?o>0?h/g(10,t-o):0:d[l-1])%10&1||i==(n.s<0?8:7)),e<1||!d[0])return d.length=0,a?(e-=n.e+1,d[0]=g(10,(7-e%7)%7),n.e=-e||0):d[0]=n.e=0,n;if(0==s?(d.length=l,u=1,l--):(d.length=l+1,u=g(10,7-s),d[l]=o>0?(h/g(10,t-o)%g(10,o)|0)*u:0),a)for(;;){if(0==l){for(s=1,o=d[0];o>=10;o/=10)s++;for(o=d[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(n.e++,d[0]==b&&(d[0]=1));break}if(d[l]+=u,d[l]!=b)break;d[l--]=0,u=1}for(s=d.length;0===d[--s];)d.pop()}return c&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function Z(n,e,i){if(!n.isFinite())return H(n);var r,t=n.e,s=M(n.d),o=s.length;return e?(i&&(r=i-o)>0?s=s.charAt(0)+"."+s.slice(1)+T(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):t<0?(s="0."+T(-t-1)+s,i&&(r=i-o)>0&&(s+=T(r))):t>=o?(s+=T(t+1-o),i&&(r=i-t-1)>0&&(s=s+"."+T(r))):((r=t+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),i&&(r=i-o)>0&&(t+1===o&&(s+="."),s+=T(r))),s}function S(n,e){var i=n[0];for(e*=7;i>=10;i/=10)e++;return e}function P(n,e,i){if(e>x)throw c=!0,i&&(n.precision=i),Error(h);return D(new n(s),e,1,!0)}function _(n,e,i){if(e>E)throw Error(h);return D(new n(o),e,i,!0)}function R(n){var e=n.length-1,i=7*e+1;if(e=n[e]){for(;e%10==0;e/=10)i--;for(e=n[0];e>=10;e/=10)i++}return i}function T(n){for(var e="";n--;)e+="0";return e}function L(n,e,i,r){var t,s=new n(1),o=Math.ceil(r/7+4);for(c=!1;;){if(i%2&&z((s=s.times(e)).d,o)&&(t=!0),0===(i=p(i/2))){i=s.d.length-1,t&&0===s.d[i]&&++s.d[i];break}z((e=e.times(e)).d,o)}return c=!0,s}function U(n){return 1&n.d[n.d.length-1]}function k(n,e,i){for(var r,t,s=new n(e[0]),o=0;++o<e.length;){if(!(t=new n(e[o])).s){s=t;break}((r=s.cmp(t))===i||0===r&&s.s===i)&&(s=t)}return s}function I(n,e){var i,r,t,s,o,u,f,a=0,h=0,d=0,l=n.constructor,p=l.rounding,w=l.precision;if(!n.d||!n.d[0]||n.e>17)return new l(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(null==e?(c=!1,f=w):f=e,u=new l(.03125);n.e>-2;)n=n.times(u),d+=5;for(f+=r=Math.log(g(2,d))/Math.LN10*2+5|0,i=s=o=new l(1),l.precision=f;;){if(s=D(s.times(n),f,1),i=i.times(++h),M((u=o.plus(A(s,i,f,1))).d).slice(0,f)===M(o.d).slice(0,f)){for(t=d;t--;)o=D(o.times(o),f,1);if(null!=e)return l.precision=w,o;if(!(a<3&&O(o.d,f-r,p,a)))return D(o,l.precision=w,p,c=!0);l.precision=f+=10,i=s=u=new l(1),h=0,a++}o=u}}function C(n,e){var i,r,t,s,o,u,f,a,h,d,l,p=1,g=n,w=g.d,m=g.constructor,v=m.rounding,N=m.precision;if(g.s<0||!w||!w[0]||!g.e&&1==w[0]&&1==w.length)return new m(w&&!w[0]?-1/0:1!=g.s?NaN:w?0:g);if(null==e?(c=!1,h=N):h=e,m.precision=h+=10,r=(i=M(w)).charAt(0),!(Math.abs(s=g.e)<15e14))return a=P(m,h+2,N).times(s+""),g=C(new m(r+"."+i.slice(1)),h-10).plus(a),m.precision=N,null==e?D(g,N,v,c=!0):g;for(;r<7&&1!=r||1==r&&i.charAt(1)>3;)r=(i=M((g=g.times(n)).d)).charAt(0),p++;for(s=g.e,r>1?(g=new m("0."+i),s++):g=new m(r+"."+i.slice(1)),d=g,f=o=g=A(g.minus(1),g.plus(1),h,1),l=D(g.times(g),h,1),t=3;;){if(o=D(o.times(l),h,1),M((a=f.plus(A(o,new m(t),h,1))).d).slice(0,h)===M(f.d).slice(0,h)){if(f=f.times(2),0!==s&&(f=f.plus(P(m,h+2,N).times(s+""))),f=A(f,new m(p),h,1),null!=e)return m.precision=N,f;if(!O(f.d,h-10,v,u))return D(f,m.precision=N,v,c=!0);m.precision=h+=10,a=o=g=A(d.minus(1),d.plus(1),h,1),l=D(g.times(g),h,1),t=u=1}f=a,t+=2}}function H(n){return String(n.s*n.s/0)}function B(n,e){var i,r,t;for((i=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(i<0&&(i=r),i+=+e.slice(r+1),e=e.substring(0,r)):i<0&&(i=e.length),r=0;48===e.charCodeAt(r);r++);for(t=e.length;48===e.charCodeAt(t-1);--t);if(e=e.slice(r,t)){if(t-=r,n.e=i=i-r-1,n.d=[],r=(i+1)%7,i<0&&(r+=7),r<t){for(r&&n.d.push(+e.slice(0,r)),t-=7;r<t;)n.d.push(+e.slice(r,r+=7));r=7-(e=e.slice(r)).length}else r-=t;for(;r--;)e+="0";n.d.push(+e),c&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function V(n,e){var i,r,t,s,o,u,f,h,d;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),N.test(e))return B(n,e)}else if("Infinity"===e||"NaN"===e)return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(m.test(e))i=16,e=e.toLowerCase();else if(w.test(e))i=2;else{if(!v.test(e))throw Error(a+e);i=8}for((s=e.search(/p/i))>0?(f=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),o=(s=e.indexOf("."))>=0,r=n.constructor,o&&(s=(u=(e=e.replace(".","")).length)-s,t=L(r,new r(i),s,2*s)),s=d=(h=F(e,i,b)).length-1;0===h[s];--s)h.pop();return s<0?new r(0*n.s):(n.e=S(h,d),n.d=h,c=!1,o&&(n=A(n,t,4*u)),f&&(n=n.times(Math.abs(f)<54?g(2,f):Ln.pow(2,f))),c=!0,n)}function j(n,e,i,r,t){var s,o,u,f,a=n.precision,h=Math.ceil(a/7);for(c=!1,f=i.times(i),u=new n(r);;){if(o=A(u.times(f),new n(e++*e++),a,1),u=t?r.plus(o):r.minus(o),r=A(o.times(f),new n(e++*e++),a,1),void 0!==(o=u.plus(r)).d[h]){for(s=h;o.d[s]===u.d[s]&&s--;);if(-1==s)break}s=u,u=r,r=o,o=s}return c=!0,o.d.length=h+1,o}function $(n,e){for(var i=n;--e;)i*=n;return i}function W(n,i){var r,t=i.s<0,s=_(n,n.precision,1),o=s.times(.5);if((i=i.abs()).lte(o))return e=t?4:1,i;if((r=i.divToInt(s)).isZero())e=t?3:2;else{if((i=i.minus(r.times(s))).lte(o))return e=U(r)?t?2:3:t?4:1,i;e=U(r)?t?1:4:t?3:2}return i.minus(s).abs()}function J(e,i,s,o){var u,c,f,a,h,d,l,p,g,w=e.constructor,m=void 0!==s;if(m?(q(s,1,r),void 0===o?o=w.rounding:q(o,0,8)):(s=w.precision,o=w.rounding),e.isFinite()){for(m?(u=2,16==i?s=4*s-3:8==i&&(s=3*s-2)):u=i,(f=(l=Z(e)).indexOf("."))>=0&&(l=l.replace(".",""),(g=new w(1)).e=l.length-f,g.d=F(Z(g),10,u),g.e=g.d.length),c=h=(p=F(l,10,u)).length;0==p[--h];)p.pop();if(p[0]){if(f<0?c--:((e=new w(e)).d=p,e.e=c,p=(e=A(e,g,s,o,0,u)).d,c=e.e,d=n),f=p[s],a=u/2,d=d||void 0!==p[s+1],d=o<4?(void 0!==f||d)&&(0===o||o===(e.s<0?3:2)):f>a||f===a&&(4===o||d||6===o&&1&p[s-1]||o===(e.s<0?8:7)),p.length=s,d)for(;++p[--s]>u-1;)p[s]=0,s||(++c,p.unshift(1));for(h=p.length;!p[h-1];--h);for(f=0,l="";f<h;f++)l+=t.charAt(p[f]);if(m){if(h>1)if(16==i||8==i){for(f=16==i?4:3,--h;h%f;h++)l+="0";for(h=(p=F(l,u,i)).length;!p[h-1];--h);for(f=1,l="1.";f<h;f++)l+=t.charAt(p[f])}else l=l.charAt(0)+"."+l.slice(1);l=l+(c<0?"p":"p+")+c}else if(c<0){for(;++c;)l="0"+l;l="0."+l}else if(++c>h)for(c-=h;c--;)l+="0";else c<h&&(l=l.slice(0,c)+"."+l.slice(c))}else l=m?"0p+0":"0";l=(16==i?"0x":2==i?"0b":8==i?"0o":"")+l}else l=H(e);return e.s<0?"-"+l:l}function z(n,e){if(n.length>e)return n.length=e,!0}function G(n){return new this(n).abs()}function K(n){return new this(n).acos()}function Q(n){return new this(n).acosh()}function X(n,e){return new this(n).plus(e)}function Y(n){return new this(n).asin()}function nn(n){return new this(n).asinh()}function en(n){return new this(n).atan()}function rn(n){return new this(n).atanh()}function tn(n,e){n=new this(n),e=new this(e);var i,r=this.precision,t=this.rounding,s=r+4;return n.s&&e.s?n.d||e.d?!e.d||n.isZero()?(i=e.s<0?_(this,r,t):new this(0)).s=n.s:!n.d||e.isZero()?(i=_(this,s,1).times(.5)).s=n.s:e.s<0?(this.precision=s,this.rounding=1,i=this.atan(A(n,e,s,1)),e=_(this,s,1),this.precision=r,this.rounding=t,i=n.s<0?i.minus(e):i.plus(e)):i=this.atan(A(n,e,s,1)):(i=_(this,s,1).times(e.s>0?.25:.75)).s=n.s:i=new this(NaN),i}function sn(n){return new this(n).cbrt()}function on(n){return D(n=new this(n),n.e+1,2)}function un(n,e,i){return new this(n).clamp(e,i)}function cn(n){if(!n||"object"!=typeof n)throw Error(f+"Object expected");var e,t,s,o=!0===n.defaults,c=["precision",1,r,"rounding",0,8,"toExpNeg",-i,0,"toExpPos",0,i,"maxE",0,i,"minE",-i,0,"modulo",0,9];for(e=0;e<c.length;e+=3)if(t=c[e],o&&(this[t]=u[t]),void 0!==(s=n[t])){if(!(p(s)===s&&s>=c[e+1]&&s<=c[e+2]))throw Error(a+t+": "+s);this[t]=s}if(t="crypto",o&&(this[t]=u[t]),void 0!==(s=n[t])){if(!0!==s&&!1!==s&&0!==s&&1!==s)throw Error(a+t+": "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[t]=!0}else this[t]=!1}return this}function fn(n){return new this(n).cos()}function an(n){return new this(n).cosh()}function hn(n,e){return new this(n).div(e)}function dn(n){return new this(n).exp()}function ln(n){return D(n=new this(n),n.e+1,3)}function pn(){var n,e,i=new this(0);for(c=!1,n=0;n<arguments.length;)if((e=new this(arguments[n++])).d)i.d&&(i=i.plus(e.times(e)));else{if(e.s)return c=!0,new this(1/0);i=e}return c=!0,i.sqrt()}function gn(n){return n instanceof Ln||n&&n.toStringTag===l||!1}function wn(n){return new this(n).ln()}function mn(n,e){return new this(n).log(e)}function vn(n){return new this(n).log(2)}function Nn(n){return new this(n).log(10)}function bn(){return k(this,arguments,-1)}function xn(){return k(this,arguments,1)}function En(n,e){return new this(n).mod(e)}function yn(n,e){return new this(n).mul(e)}function Mn(n,e){return new this(n).pow(e)}function qn(n){var e,i,t,s,o=0,u=new this(1),c=[];if(void 0===n?n=this.precision:q(n,1,r),t=Math.ceil(n/7),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(t));o<t;)(s=e[o])>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:c[o++]=s%1e7;else{if(!crypto.randomBytes)throw Error(d);for(e=crypto.randomBytes(t*=4);o<t;)(s=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((127&e[o+3])<<24))>=214e7?crypto.randomBytes(4).copy(e,o):(c.push(s%1e7),o+=4);o=t/4}else for(;o<t;)c[o++]=1e7*Math.random()|0;for(n%=7,(t=c[--o])&&n&&(s=g(10,7-n),c[o]=(t/s|0)*s);0===c[o];o--)c.pop();if(o<0)i=0,c=[0];else{for(i=-1;0===c[0];i-=7)c.shift();for(t=1,s=c[0];s>=10;s/=10)t++;t<7&&(i-=7-t)}return u.e=i,u.d=c,u}function On(n){return D(n=new this(n),n.e+1,this.rounding)}function Fn(n){return(n=new this(n)).d?n.d[0]?n.s:0*n.s:n.s||NaN}function An(n){return new this(n).sin()}function Dn(n){return new this(n).sinh()}function Zn(n){return new this(n).sqrt()}function Sn(n,e){return new this(n).sub(e)}function Pn(){var n=0,e=arguments,i=new this(e[n]);for(c=!1;i.s&&++n<e.length;)i=i.plus(e[n]);return c=!0,D(i,this.precision,this.rounding)}function _n(n){return new this(n).tan()}function Rn(n){return new this(n).tanh()}function Tn(n){return D(n=new this(n),n.e+1,1)}y[Symbol.for("nodejs.util.inspect.custom")]=y.toString,y[Symbol.toStringTag]="Decimal";var Ln=y.constructor=function n(e){var i,r,t;function s(n){var e,i,r,t=this;if(!(t instanceof s))return new s(n);if(t.constructor=s,gn(n))return t.s=n.s,void(c?!n.d||n.e>s.maxE?(t.e=NaN,t.d=null):n.e<s.minE?(t.e=0,t.d=[0]):(t.e=n.e,t.d=n.d.slice()):(t.e=n.e,t.d=n.d?n.d.slice():n.d));if("number"===(r=typeof n)){if(0===n)return t.s=1/n<0?-1:1,t.e=0,void(t.d=[0]);if(n<0?(n=-n,t.s=-1):t.s=1,n===~~n&&n<1e7){for(e=0,i=n;i>=10;i/=10)e++;return void(c?e>s.maxE?(t.e=NaN,t.d=null):e<s.minE?(t.e=0,t.d=[0]):(t.e=e,t.d=[n]):(t.e=e,t.d=[n]))}return 0*n!=0?(n||(t.s=NaN),t.e=NaN,void(t.d=null)):B(t,n.toString())}if("string"===r)return 45===(i=n.charCodeAt(0))?(n=n.slice(1),t.s=-1):(43===i&&(n=n.slice(1)),t.s=1),N.test(n)?B(t,n):V(t,n);if("bigint"===r)return n<0?(n=-n,t.s=-1):t.s=1,B(t,n.toString());throw Error(a+n)}if(s.prototype=y,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=cn,s.clone=n,s.isDecimal=gn,s.abs=G,s.acos=K,s.acosh=Q,s.add=X,s.asin=Y,s.asinh=nn,s.atan=en,s.atanh=rn,s.atan2=tn,s.cbrt=sn,s.ceil=on,s.clamp=un,s.cos=fn,s.cosh=an,s.div=hn,s.exp=dn,s.floor=ln,s.hypot=pn,s.ln=wn,s.log=mn,s.log10=Nn,s.log2=vn,s.max=bn,s.min=xn,s.mod=En,s.mul=yn,s.pow=Mn,s.random=qn,s.round=On,s.sign=Fn,s.sin=An,s.sinh=Dn,s.sqrt=Zn,s.sub=Sn,s.sum=Pn,s.tan=_n,s.tanh=Rn,s.trunc=Tn,void 0===e&&(e={}),e&&!0!==e.defaults)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],i=0;i<t.length;)e.hasOwnProperty(r=t[i++])||(e[r]=this[r]);return s.config(e),s}(u);s=new Ln(s),o=new Ln(o),exports.Decimal=Ln,exports.default=Ln;
10
+ //# sourceMappingURL=decimal.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";"function"==typeof SuppressedError&&SuppressedError,exports.__decorate=function(e,t,r,o){var c,f=arguments.length,n=f<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,o);else for(var a=e.length-1;a>=0;a--)(c=e[a])&&(n=(f<3?c(n):f>3?c(t,r,n):c(t,r))||n);return f>3&&n&&Object.defineProperty(t,r,n),n},exports.__metadata=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};
2
+ //# sourceMappingURL=tslib.es6.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Argon2Service=void 0;const r=require("tslib"),e=require("@nestjs/common"),t=r.__importStar(require("argon2"));let s=class{constructor(){}async hashPassword(r){try{return await t.hash(r,{type:t.argon2id,hashLength:32,timeCost:3,memoryCost:65536,parallelism:1})}catch(r){throw new Error(`Password hashing failed: ${r instanceof Error?r.message:String(r)}`)}}async verifyPassword(r,e){try{return await t.verify(e,r)}catch(r){throw new Error(`Password verification failed: ${r.message}`)}}};exports.Argon2Service=s,exports.Argon2Service=s=r.__decorate([(0,e.Injectable)(),r.__metadata("design:paramtypes",[])],s);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),r=require("@nestjs/common");function t(e){var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,Object.freeze(r)}var a=t(require("argon2"));exports.Argon2Service=class{constructor(){}async hashPassword(e){try{return await a.hash(e,{type:a.argon2id,hashLength:32,timeCost:3,memoryCost:65536,parallelism:1})}catch(e){throw new Error(`Password hashing failed: ${e instanceof Error?e.message:String(e)}`)}}async verifyPassword(e,r){try{return await a.verify(r,e)}catch(e){throw new Error(`Password verification failed: ${e.message}`)}}},exports.Argon2Service=e.__decorate([r.Injectable(),e.__metadata("design:paramtypes",[])],exports.Argon2Service);
2
+ //# sourceMappingURL=argon2.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataTransformerService=void 0;const e=require("tslib"),r=require("worker_threads"),n=require("@nestjs/common");let a=class{async processData(e,r){const n=1e3,a=Math.ceil(e.length/n),t=[],s=[];for(let t=0;t<a;t++){const a=e.slice(t*n,(t+1)*n);s.push(this.processChunkWithWorker(a,r))}return(await Promise.all(s)).forEach(e=>t.push(...e)),t}async processChunkWithWorker(e,n){return new Promise((a,t)=>{const s=new r.Worker("\n const { parentPort, workerData } = require('worker_threads');\n const { chunk, fieldsToInclude } = workerData;\n\n function transformProcessData(data, fieldsToInclude) {\n return fieldsToInclude.reduce((acc, field) => {\n if (field in data) {\n acc[field] = data[field];\n }\n return acc;\n }, {});\n }\n\n function transformData(chunk, fieldsToInclude) {\n return chunk.map((data) => transformProcessData(data, fieldsToInclude));\n }\n\n const transformedData = transformData(chunk, fieldsToInclude);\n parentPort.postMessage(transformedData);\n\n ",{eval:!0,workerData:{chunk:e,fieldsToInclude:n}});s.on("message",a),s.on("error",t)})}};exports.DataTransformerService=a,exports.DataTransformerService=a=e.__decorate([(0,n.Injectable)()],a);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),r=require("worker_threads"),n=require("@nestjs/common");exports.DataTransformerService=class{async processData(e,r){const n=1e3,a=Math.ceil(e.length/n),s=[],t=[];for(let s=0;s<a;s++){const a=e.slice(s*n,(s+1)*n);t.push(this.processChunkWithWorker(a,r))}return(await Promise.all(t)).forEach(e=>s.push(...e)),s}async processChunkWithWorker(e,n){return new Promise((a,s)=>{const t=new r.Worker("\n const { parentPort, workerData } = require('worker_threads');\n const { chunk, fieldsToInclude } = workerData;\n\n function transformProcessData(data, fieldsToInclude) {\n return fieldsToInclude.reduce((acc, field) => {\n if (field in data) {\n acc[field] = data[field];\n }\n return acc;\n }, {});\n }\n\n function transformData(chunk, fieldsToInclude) {\n return chunk.map((data) => transformProcessData(data, fieldsToInclude));\n }\n\n const transformedData = transformData(chunk, fieldsToInclude);\n parentPort.postMessage(transformedData);\n\n ",{eval:!0,workerData:{chunk:e,fieldsToInclude:n}});t.on("message",a),t.on("error",s)})}},exports.DataTransformerService=e.__decorate([n.Injectable()],exports.DataTransformerService);
2
+ //# sourceMappingURL=data.transformer.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DecimalUtilsService=void 0;const e=require("tslib"),t=require("@nestjs/common"),r=e.__importDefault(require("decimal.js"));let i=class{constructor(e={}){this.precisionMap=e}toDecimal(e){if(e instanceof r.default)return e;if(null==e)return new r.default(0);if("object"==typeof e){const t=e;if("value"in t&&null!=t.value)return new r.default(t.value);if("d"in t){if(Array.isArray(t.d)&&2===t.d.length){const[e,i]=t.d,a=`${e}.${String(i).padStart(String(i).length,"0").replace(/0+$/,"")}`;return new r.default(a)}if("string"==typeof t.d||"number"==typeof t.d)return new r.default(t.d)}return new r.default(0)}return"string"==typeof e||"number"==typeof e?new r.default(e):new r.default(0)}isDecimalObject(e){if(e instanceof r.default)return!0;if("object"==typeof e&&null!==e){return"d"in e||"value"in e}return!1}normalizeValue(e,t){const r=this.toDecimal(t),i=this.precisionMap[e]??2;return r.toDecimalPlaces(i).toNumber()}normalizeRow(e){if(null==e)return e;if("object"!=typeof e)return e;if(e instanceof Date)return e;if(Array.isArray(e))return e.map(e=>this.normalizeRow(e));const t={};for(const r of Object.keys(e)){const i=e[r];null==i?t[r]=i:Array.isArray(i)?t[r]=i.map(e=>this.normalizeRow(e)):i instanceof Date?t[r]=i:this.isDecimalObject(i)||"number"==typeof i||"string"==typeof i?t[r]=this.normalizeValue(r,i):t[r]="object"==typeof i?this.normalizeRow(i):i}return t}normalize(e){return e?Array.isArray(e)?e.map(e=>this.normalizeRow(e)):this.normalizeRow(e):e}zeroSafeDecimal(e){const t=this.toDecimal(e);return t.isNaN()?new r.default(0):t}add(e,t,r=8){return this.zeroSafeDecimal(e).add(this.zeroSafeDecimal(t)).toDecimalPlaces(r).toNumber()}subtract(e,t,r=8){return this.zeroSafeDecimal(e).sub(this.zeroSafeDecimal(t)).toDecimalPlaces(r).toNumber()}multiply(e,t,r=8){return this.zeroSafeDecimal(e).mul(this.zeroSafeDecimal(t)).toDecimalPlaces(r).toNumber()}divide(e,t,i=8){const a=this.zeroSafeDecimal(t).equals(0)?new r.default(1):this.zeroSafeDecimal(t);return this.zeroSafeDecimal(e).div(a).toDecimalPlaces(i).toNumber()}};exports.DecimalUtilsService=i,exports.DecimalUtilsService=i=e.__decorate([(0,t.Injectable)(),e.__metadata("design:paramtypes",[Object])],i);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),i=require("@nestjs/common"),t=require("../node_modules/decimal.js/decimal.js");exports.DecimalUtilsService=class{constructor(e={}){this.precisionMap=e}toDecimal(e){if(e instanceof t.Decimal)return e;if(null==e)return new t.Decimal(0);if("object"==typeof e){const i=e;if("value"in i&&null!=i.value)return new t.Decimal(i.value);if("d"in i){if(Array.isArray(i.d)&&2===i.d.length){const[e,r]=i.d,a=`${e}.${String(r).padStart(String(r).length,"0").replace(/0+$/,"")}`;return new t.Decimal(a)}if("string"==typeof i.d||"number"==typeof i.d)return new t.Decimal(i.d)}return new t.Decimal(0)}return"string"==typeof e||"number"==typeof e?new t.Decimal(e):new t.Decimal(0)}isDecimalObject(e){if(e instanceof t.Decimal)return!0;if("object"==typeof e&&null!==e){return"d"in e||"value"in e}return!1}normalizeValue(e,i){const t=this.toDecimal(i),r=this.precisionMap[e]??2;return t.toDecimalPlaces(r).toNumber()}normalizeRow(e){if(null==e)return e;if("object"!=typeof e)return e;if(e instanceof Date)return e;if(Array.isArray(e))return e.map(e=>this.normalizeRow(e));const i={};for(const t of Object.keys(e)){const r=e[t];null==r?i[t]=r:Array.isArray(r)?i[t]=r.map(e=>this.normalizeRow(e)):r instanceof Date?i[t]=r:this.isDecimalObject(r)||"number"==typeof r||"string"==typeof r?i[t]=this.normalizeValue(t,r):i[t]="object"==typeof r?this.normalizeRow(r):r}return i}normalize(e){return e?Array.isArray(e)?e.map(e=>this.normalizeRow(e)):this.normalizeRow(e):e}zeroSafeDecimal(e){const i=this.toDecimal(e);return i.isNaN()?new t.Decimal(0):i}add(e,i,t=8){return this.zeroSafeDecimal(e).add(this.zeroSafeDecimal(i)).toDecimalPlaces(t).toNumber()}subtract(e,i,t=8){return this.zeroSafeDecimal(e).sub(this.zeroSafeDecimal(i)).toDecimalPlaces(t).toNumber()}multiply(e,i,t=8){return this.zeroSafeDecimal(e).mul(this.zeroSafeDecimal(i)).toDecimalPlaces(t).toNumber()}divide(e,i,r=8){const a=this.zeroSafeDecimal(i).equals(0)?new t.Decimal(1):this.zeroSafeDecimal(i);return this.zeroSafeDecimal(e).div(a).toDecimalPlaces(r).toNumber()}},exports.DecimalUtilsService=e.__decorate([i.Injectable(),e.__metadata("design:paramtypes",[Object])],exports.DecimalUtilsService);
2
+ //# sourceMappingURL=decimal.utils.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EntityActionService=void 0;const e=require("tslib"),r=require("@nestjs/common"),t=e.__importDefault(require("p-limit")),i=require("./logger.service"),s=require("./prisma.service");let n=class{constructor(e,r){this.prismaService=e,this.loggerService=r,this.batchSize=parseInt(process.env.BATCH_SIZE??"100",10),this.concurrencyLimit=parseInt(process.env.CONCURRENCY_LIMIT??"3",10)}async handleEntityActions(e,r,i,s){const n=this.capitalize(e),c=(0,t.default)(this.concurrencyLimit);try{const t=[];for(let e=0;e<r.length;e+=this.batchSize){const o=r.slice(e,e+this.batchSize);t.push(c(async()=>{this.loggerService.info(`Processing batch ${e/this.batchSize+1} for ${n}`);return await Promise.all(o.map(async(r,t)=>{const c=e+t;try{r[i.id]=i.value,"edit"===r.action&&(r.id=r[i.id_table_primary_key]);return{success:!0,id_return:(await this.executeQuery(r.action,n,"delete"===r.action?r[i.id_table_primary_key]:r,s[0][r.action])).id_return,data:r,index:c}}catch(e){return this.loggerService.error(`Error in batch operation for ${n}`,{error:e instanceof Error?e:new Error(String(e))}),{success:!1,error:e instanceof Error?e.message:String(e),data:r,index:c,retunrn_entity_name:i.id_return||"unknown_return_entity"}}}))}))}const o=(await Promise.all(t)).flat(),a=o.filter(e=>e.success),u=o.filter(e=>!e.success);return{entity:e,message:`${n} operations completed.`,success:0===u.length,totalProcessed:r.length,totalFailed:u.length,totalSucceeded:a.length,failedOperations:u,succeededOperations:a}}catch(r){return this.loggerService.error(`Error during ${n} operations`,{error:r instanceof Error?r:new Error(String(r))}),{entity:e,message:"An unexpected error occurred during the operations.",success:!1}}}async processEntities(e){const r=e.filter(e=>!e.success).reduce((e,r)=>{const t=r.failedOperations.map(e=>({[e.retunrn_entity_name]:e.id_return,message:e.error,index:e.index}));return e.push({field:r.entity,errors:t}),e},[]);return r.length>0?{success:!1,errorsByEntity:r}:{success:!0}}async executeQuery(e,r,t,i){try{const e=await this.prismaService.executeRawQuery(i,t);return{success:!0,id_return:e?.id??e?.[0].id??null}}catch(t){throw this.loggerService.error(`Error in ${e} operation for ${r}`,{error:t instanceof Error?t:new Error(String(t))}),new Error(`Error executing ${e} operation: ${r}`)}}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}};exports.EntityActionService=n,exports.EntityActionService=n=e.__decorate([(0,r.Injectable)(),e.__metadata("design:paramtypes",[s.PrismaService,i.LoggerService])],n);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),r=require("@nestjs/common"),t=require("p-limit"),i=require("@infineit/winston-logger"),s=require("./prisma.service.js");exports.EntityActionService=class{constructor(e,r){this.prismaService=e,this.loggerService=r,this.batchSize=parseInt(process.env.BATCH_SIZE??"100",10),this.concurrencyLimit=parseInt(process.env.CONCURRENCY_LIMIT??"3",10)}async handleEntityActions(e,r,i,s){const n=this.capitalize(e),c=t(this.concurrencyLimit);try{const t=[];for(let e=0;e<r.length;e+=this.batchSize){const o=r.slice(e,e+this.batchSize);t.push(c(async()=>{this.loggerService.info(`Processing batch ${e/this.batchSize+1} for ${n}`);return await Promise.all(o.map(async(r,t)=>{const c=e+t;try{r[i.id]=i.value,"edit"===r.action&&(r.id=r[i.id_table_primary_key]);return{success:!0,id_return:(await this.executeQuery(r.action,n,"delete"===r.action?r[i.id_table_primary_key]:r,s[0][r.action])).id_return,data:r,index:c}}catch(e){return this.loggerService.error(`Error in batch operation for ${n}`,{error:e instanceof Error?e:new Error(String(e))}),{success:!1,error:e instanceof Error?e.message:String(e),data:r,index:c,retunrn_entity_name:i.id_return||"unknown_return_entity"}}}))}))}const o=(await Promise.all(t)).flat(),a=o.filter(e=>e.success),u=o.filter(e=>!e.success);return{entity:e,message:`${n} operations completed.`,success:0===u.length,totalProcessed:r.length,totalFailed:u.length,totalSucceeded:a.length,failedOperations:u,succeededOperations:a}}catch(r){return this.loggerService.error(`Error during ${n} operations`,{error:r instanceof Error?r:new Error(String(r))}),{entity:e,message:"An unexpected error occurred during the operations.",success:!1}}}async processEntities(e){const r=e.filter(e=>!e.success).reduce((e,r)=>{const t=r.failedOperations.map(e=>({[e.retunrn_entity_name]:e.id_return,message:e.error,index:e.index}));return e.push({field:r.entity,errors:t}),e},[]);return r.length>0?{success:!1,errorsByEntity:r}:{success:!0}}async executeQuery(e,r,t,i){try{const e=await this.prismaService.executeRawQuery(i,t);return{success:!0,id_return:e?.id??e?.[0].id??null}}catch(t){throw this.loggerService.error(`Error in ${e} operation for ${r}`,{error:t instanceof Error?t:new Error(String(t))}),new Error(`Error executing ${e} operation: ${r}`)}}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}},exports.EntityActionService=e.__decorate([r.Injectable(),e.__metadata("design:paramtypes",[s.PrismaService,i.LoggerService])],exports.EntityActionService);
2
+ //# sourceMappingURL=entity.action.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpServiceClient=void 0,exports.rethrowHttpByStatus=u;const e=require("tslib"),t=require("@nestjs/common"),r=require("@nestjs/config"),s=e.__importDefault(require("axios")),o=e.__importStar(require("axios-retry")),i=e.__importDefault(require("opossum")),c=require("prom-client"),n=require("./logger.service");let a=class{constructor(e,t){this.configService=e,this.loggerService=t,this.configureMetrics(),this.configureAxiosRetry(),this.configureCircuitBreaker()}configureMetrics(){this.requestCounter=new c.Counter({name:"service_client_requests_total",help:"Total number of requests made by the service client",labelNames:["service","method","status"]}),this.responseTimeHistogram=new c.Histogram({name:"service_client_response_time_seconds",help:"Response times of service client requests",labelNames:["service","method","status"],buckets:[.1,.5,1,2,5,10]})}configureAxiosRetry(){(0,o.default)(s.default,{retries:this.configService.getOrThrow("httpmicroservice.axios_retry_count"),retryDelay:e=>1e3*Math.pow(2,e),retryCondition:e=>{const t=e?.response?.status;return(0,o.isNetworkError)(e)||"number"==typeof t&&t>=500&&t<600},onRetry:(e,t,r)=>{this.loggerService.warn(`Retry attempt #${e} for request to ${r.url}`,{sourceClass:this.constructor.name})}})}configureCircuitBreaker(){this.circuitBreaker=new i.default(this.callService.bind(this),{timeout:this.configService.getOrThrow("httpmicroservice.circuit_breaker_timeout"),errorThresholdPercentage:this.configService.getOrThrow("httpmicroservice.circuit_breaker_error_threshold"),resetTimeout:this.configService.getOrThrow("httpmicroservice.circuit_breaker_reset_timeout"),errorFilter:e=>e instanceof t.HttpException?e.getStatus()<500:!(!e?.response?.status||"number"!=typeof e.response.status)&&e.response.status<500}),this.circuitBreaker.fallback((...e)=>{const r=e[e.length-1];if(this.loggerService.warn("Circuit breaker open. Fallback activated.",{sourceClass:this.constructor.name}),r instanceof t.HttpException)throw r;throw new t.ServiceUnavailableException({message:r?.message||"Service is currently unavailable",error:r})})}async callService(e,r,o,i){const c={method:r,url:`${e}/${o}`,timeout:this.configService.getOrThrow("httpmicroservice.request_timeout")};"get"===r?c.params=i:c.data=i,this.requestCounter?.labels(e,r,"pending").inc();const n=Date.now();try{const t=await(0,s.default)(c),i=Date.now()-n;return this.responseTimeHistogram?.labels(e,r,"success").observe(i/1e3),this.requestCounter?.labels(e,r,"success").inc(),this.loggerService.info(`Successfully retrieved data from ${o} at ${e} in ${i}ms.`,{sourceClass:this.constructor.name}),t.data}catch(s){const o=Date.now()-n;this.responseTimeHistogram?.labels(e,r,"failure").observe(o/1e3),this.loggerService.error(`Error calling service at ${e}: ${s.message}`,{sourceClass:this.constructor.name});const i=s instanceof t.HttpException?s.getStatus():s?.response?.status;throw"number"==typeof i&&i<500&&u(s),this.handleServiceError(s)}}handleServiceError(e){if(e.response){const{status:r,data:s}=e.response;return new t.HttpException(s||"Service Error",r)}return e.request?new t.HttpException("Service is currently unavailable",t.HttpStatus.SERVICE_UNAVAILABLE):e instanceof t.HttpException?e:new t.HttpException(e?.message||"Unexpected Error",t.HttpStatus.INTERNAL_SERVER_ERROR)}async getResource(e,r,s,o){const i=this.getServiceBaseURL(e);try{return await(this.circuitBreaker?.fire(i,r,s,o))}catch(r){const o=r;if(this.loggerService.error(`Error occurred while calling ${e} service at ${i}/${s}: ${o.message||o}`,{sourceClass:this.constructor.name}),r instanceof t.HttpException)throw r;throw new t.HttpException(`Service call to ${e} failed: ${o.message||"Service temporarily unavailable"}`,t.HttpStatus.SERVICE_UNAVAILABLE)}}getServiceBaseURL(e){const t=`httpmicroservice.${e}_microservice_url`,r=this.configService.getOrThrow(t);if(!r)throw new Error(`Service URL not found for service: ${e}. Please check your configuration.`);return r}async getMultipleResources(e,t,r,s){const o=e.map(e=>this.getResource(e,t,r,s));return await Promise.all(o)}async getMultipleResourcesInBatch(e,r,s,o){let i=[];for(let c=0;c<e.length;c+=5){const n=e.slice(c,c+5);try{const e=n.map(e=>this.getResource(e,r,s,o)),t=await Promise.all(e);i=[...i,...t]}catch(e){throw this.loggerService.error("Error fetching data for batch",{sourceClass:this.constructor.name,error:e instanceof Error?e:new Error(String(e))}),new t.HttpException("Batch request failed",t.HttpStatus.INTERNAL_SERVER_ERROR)}}return i}};function u(e){let r,s;if(e instanceof t.HttpException)r=e.getStatus(),s=e.getResponse();else{if("object"!=typeof e||null===e||!("response"in e)||"number"!=typeof e.response?.status)throw new t.InternalServerErrorException(e?.message||"Unexpected error");{const t=e;r=t.response.status,s=t.response.data||"Unknown error"}}switch(r){case t.HttpStatus.BAD_REQUEST:throw new t.BadRequestException(s);case t.HttpStatus.UNAUTHORIZED:throw new t.UnauthorizedException(s);case t.HttpStatus.FORBIDDEN:throw new t.ForbiddenException(s);case t.HttpStatus.NOT_FOUND:throw new t.NotFoundException(s);case t.HttpStatus.CONFLICT:throw new t.ConflictException(s);case t.HttpStatus.METHOD_NOT_ALLOWED:throw new t.MethodNotAllowedException(s);case t.HttpStatus.REQUEST_TIMEOUT:throw new t.RequestTimeoutException(s);case t.HttpStatus.SERVICE_UNAVAILABLE:throw new t.ServiceUnavailableException(s);case t.HttpStatus.GATEWAY_TIMEOUT:throw new t.GatewayTimeoutException(s);case t.HttpStatus.INTERNAL_SERVER_ERROR:throw new t.InternalServerErrorException(s);default:throw new t.HttpException(s,r)}}exports.HttpServiceClient=a,exports.HttpServiceClient=a=e.__decorate([(0,t.Injectable)(),e.__metadata("design:paramtypes",[r.ConfigService,n.LoggerService])],a);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),t=require("@nestjs/common"),r=require("@nestjs/config"),s=require("axios"),i=require("axios-retry"),o=require("opossum"),c=require("prom-client"),n=require("@infineit/winston-logger");function a(e){let r,s;if(e instanceof t.HttpException)r=e.getStatus(),s=e.getResponse();else{if("object"!=typeof e||null===e||!("response"in e)||"number"!=typeof e.response?.status)throw new t.InternalServerErrorException(e?.message||"Unexpected error");{const t=e;r=t.response.status,s=t.response.data||"Unknown error"}}switch(r){case t.HttpStatus.BAD_REQUEST:throw new t.BadRequestException(s);case t.HttpStatus.UNAUTHORIZED:throw new t.UnauthorizedException(s);case t.HttpStatus.FORBIDDEN:throw new t.ForbiddenException(s);case t.HttpStatus.NOT_FOUND:throw new t.NotFoundException(s);case t.HttpStatus.CONFLICT:throw new t.ConflictException(s);case t.HttpStatus.METHOD_NOT_ALLOWED:throw new t.MethodNotAllowedException(s);case t.HttpStatus.REQUEST_TIMEOUT:throw new t.RequestTimeoutException(s);case t.HttpStatus.SERVICE_UNAVAILABLE:throw new t.ServiceUnavailableException(s);case t.HttpStatus.GATEWAY_TIMEOUT:throw new t.GatewayTimeoutException(s);case t.HttpStatus.INTERNAL_SERVER_ERROR:throw new t.InternalServerErrorException(s);default:throw new t.HttpException(s,r)}}exports.HttpServiceClient=class{constructor(e,t){this.configService=e,this.loggerService=t,this.configureMetrics(),this.configureAxiosRetry(),this.configureCircuitBreaker()}configureMetrics(){this.requestCounter=new c.Counter({name:"service_client_requests_total",help:"Total number of requests made by the service client",labelNames:["service","method","status"]}),this.responseTimeHistogram=new c.Histogram({name:"service_client_response_time_seconds",help:"Response times of service client requests",labelNames:["service","method","status"],buckets:[.1,.5,1,2,5,10]})}configureAxiosRetry(){i(s,{retries:this.configService.getOrThrow("httpmicroservice.axios_retry_count"),retryDelay:e=>1e3*Math.pow(2,e),retryCondition:e=>{const t=e?.response?.status;return i.isNetworkError(e)||"number"==typeof t&&t>=500&&t<600},onRetry:(e,t,r)=>{this.loggerService.warn(`Retry attempt #${e} for request to ${r.url}`,{sourceClass:this.constructor.name})}})}configureCircuitBreaker(){this.circuitBreaker=new o(this.callService.bind(this),{timeout:this.configService.getOrThrow("httpmicroservice.circuit_breaker_timeout"),errorThresholdPercentage:this.configService.getOrThrow("httpmicroservice.circuit_breaker_error_threshold"),resetTimeout:this.configService.getOrThrow("httpmicroservice.circuit_breaker_reset_timeout"),errorFilter:e=>e instanceof t.HttpException?e.getStatus()<500:!(!e?.response?.status||"number"!=typeof e.response.status)&&e.response.status<500}),this.circuitBreaker.fallback((...e)=>{const r=e[e.length-1];if(this.loggerService.warn("Circuit breaker open. Fallback activated.",{sourceClass:this.constructor.name}),r instanceof t.HttpException)throw r;throw new t.ServiceUnavailableException({message:r?.message||"Service is currently unavailable",error:r})})}async callService(e,r,i,o){const c={method:r,url:`${e}/${i}`,timeout:this.configService.getOrThrow("httpmicroservice.request_timeout")};"get"===r?c.params=o:c.data=o,this.requestCounter?.labels(e,r,"pending").inc();const n=Date.now();try{const t=await s(c),o=Date.now()-n;return this.responseTimeHistogram?.labels(e,r,"success").observe(o/1e3),this.requestCounter?.labels(e,r,"success").inc(),this.loggerService.info(`Successfully retrieved data from ${i} at ${e} in ${o}ms.`,{sourceClass:this.constructor.name}),t.data}catch(s){const i=Date.now()-n;this.responseTimeHistogram?.labels(e,r,"failure").observe(i/1e3),this.loggerService.error(`Error calling service at ${e}: ${s.message}`,{sourceClass:this.constructor.name});const o=s instanceof t.HttpException?s.getStatus():s?.response?.status;throw"number"==typeof o&&o<500&&a(s),this.handleServiceError(s)}}handleServiceError(e){if(e.response){const{status:r,data:s}=e.response;return new t.HttpException(s||"Service Error",r)}return e.request?new t.HttpException("Service is currently unavailable",t.HttpStatus.SERVICE_UNAVAILABLE):e instanceof t.HttpException?e:new t.HttpException(e?.message||"Unexpected Error",t.HttpStatus.INTERNAL_SERVER_ERROR)}async getResource(e,r,s,i){const o=this.getServiceBaseURL(e);try{return await(this.circuitBreaker?.fire(o,r,s,i))}catch(r){const i=r;if(this.loggerService.error(`Error occurred while calling ${e} service at ${o}/${s}: ${i.message||i}`,{sourceClass:this.constructor.name}),r instanceof t.HttpException)throw r;throw new t.HttpException(`Service call to ${e} failed: ${i.message||"Service temporarily unavailable"}`,t.HttpStatus.SERVICE_UNAVAILABLE)}}getServiceBaseURL(e){const t=`httpmicroservice.${e}_microservice_url`,r=this.configService.getOrThrow(t);if(!r)throw new Error(`Service URL not found for service: ${e}. Please check your configuration.`);return r}async getMultipleResources(e,t,r,s){const i=e.map(e=>this.getResource(e,t,r,s));return await Promise.all(i)}async getMultipleResourcesInBatch(e,r,s,i){let o=[];for(let c=0;c<e.length;c+=5){const n=e.slice(c,c+5);try{const e=n.map(e=>this.getResource(e,r,s,i)),t=await Promise.all(e);o=[...o,...t]}catch(e){throw this.loggerService.error("Error fetching data for batch",{sourceClass:this.constructor.name,error:e instanceof Error?e:new Error(String(e))}),new t.HttpException("Batch request failed",t.HttpStatus.INTERNAL_SERVER_ERROR)}}return o}},exports.HttpServiceClient=e.__decorate([t.Injectable(),e.__metadata("design:paramtypes",[r.ConfigService,n.LoggerService])],exports.HttpServiceClient),exports.rethrowHttpByStatus=a;
2
+ //# sourceMappingURL=http.client.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./argon2.service"),exports),e.__exportStar(require("./data.transformer.service"),exports),e.__exportStar(require("./entity.action.service"),exports),e.__exportStar(require("./http.client.service"),exports),e.__exportStar(require("./kafka.microservice"),exports),e.__exportStar(require("./logger.service"),exports),e.__exportStar(require("./merge.service"),exports),e.__exportStar(require("./message.formatter.service"),exports),e.__exportStar(require("./pagination.service"),exports),e.__exportStar(require("./prisma.service"),exports),e.__exportStar(require("./resource.fetch.service"),exports),e.__exportStar(require("./redis.service"),exports),e.__exportStar(require("./util.service"),exports),e.__exportStar(require("./validator.service"),exports),e.__exportStar(require("./decimal.utils.service"),exports);
1
+ "use strict";var e=require("./argon2.service.js"),r=require("./data.transformer.service.js"),t=require("./entity.action.service.js"),i=require("./http.client.service.js"),n=require("./kafka.microservice.js"),c=require("@infineit/winston-logger"),s=require("./merge.service.js"),o=require("./message.formatter.service.js"),u=require("./pagination.service.js"),a=require("./prisma.service.js"),v=require("./resource.fetch.service.js"),p=require("./redis.service.js"),f=require("./util.service.js"),g=require("./validator.service.js"),m=require("./decimal.utils.service.js");Object.defineProperty(exports,"Argon2Service",{enumerable:!0,get:function(){return e.Argon2Service}}),Object.defineProperty(exports,"DataTransformerService",{enumerable:!0,get:function(){return r.DataTransformerService}}),Object.defineProperty(exports,"EntityActionService",{enumerable:!0,get:function(){return t.EntityActionService}}),Object.defineProperty(exports,"HttpServiceClient",{enumerable:!0,get:function(){return i.HttpServiceClient}}),exports.rethrowHttpByStatus=i.rethrowHttpByStatus,exports.InitKafkaConsumer=n.InitKafkaConsumer,Object.defineProperty(exports,"LoggerService",{enumerable:!0,get:function(){return c.LoggerService}}),Object.defineProperty(exports,"MergeService",{enumerable:!0,get:function(){return s.MergeService}}),Object.defineProperty(exports,"MessageFormatterService",{enumerable:!0,get:function(){return o.MessageFormatterService}}),Object.defineProperty(exports,"PaginationService",{enumerable:!0,get:function(){return u.PaginationService}}),Object.defineProperty(exports,"PrismaService",{enumerable:!0,get:function(){return a.PrismaService}}),exports.MissingDataError=v.MissingDataError,Object.defineProperty(exports,"ResourceFetchService",{enumerable:!0,get:function(){return v.ResourceFetchService}}),Object.defineProperty(exports,"RedisService",{enumerable:!0,get:function(){return p.RedisService}}),exports.UtilsService=f.UtilsService,Object.defineProperty(exports,"ValidatorService",{enumerable:!0,get:function(){return g.ValidatorService}}),Object.defineProperty(exports,"DecimalUtilsService",{enumerable:!0,get:function(){return m.DecimalUtilsService}});
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.InitKafkaConsumer=async function(o){const t=o.get(r.ConfigService),n=t.getOrThrow("kafka.consumerEnable",{infer:!0}),s=t.getOrThrow("kafka.brokers",{infer:!0}),i=t.getOrThrow("kafka.consumerClientId",{infer:!0}),a=t.getOrThrow("kafka.consumer.groupId",{infer:!0}),c=t.getOrThrow("kafka.autoCommit",{infer:!0}),f=t.getOrThrow("kafka.consumer",{infer:!0});try{n&&o.connectMicroservice({transport:e.Transport.KAFKA,options:{client:{clientId:i,brokers:s},consumer:{...f,groupId:a},run:{autoCommit:c}}})}catch(r){console.error("Failed to start Kafka microservice:",r),process.exit(1)}await o.startAllMicroservices()};const r=require("@nestjs/config"),e=require("@nestjs/microservices");
1
+ "use strict";var r=require("@nestjs/config"),e=require("@nestjs/microservices");exports.InitKafkaConsumer=async function(o){const t=o.get(r.ConfigService),n=t.getOrThrow("kafka.consumerEnable",{infer:!0}),i=t.getOrThrow("kafka.brokers",{infer:!0}),s=t.getOrThrow("kafka.consumerClientId",{infer:!0}),a=t.getOrThrow("kafka.consumer.groupId",{infer:!0}),c=t.getOrThrow("kafka.autoCommit",{infer:!0}),f=t.getOrThrow("kafka.consumer",{infer:!0});try{n&&o.connectMicroservice({transport:e.Transport.KAFKA,options:{client:{clientId:s,brokers:i},consumer:{...f,groupId:a},run:{autoCommit:c}}})}catch(r){console.error("Failed to start Kafka microservice:",r),process.exit(1)}await o.startAllMicroservices()};
2
+ //# sourceMappingURL=kafka.microservice.js.map
@@ -1,29 +1,2 @@
1
- import type Logger from '@infineit/winston-logger/logger/domain/logger';
2
- export interface ILogData {
3
- organization?: string;
4
- context?: string;
5
- app?: string;
6
- sourceClass?: string;
7
- correlationId?: string;
8
- error?: Error;
9
- props?: NodeJS.Dict<any>;
10
- }
11
- export declare enum LogLevel {
12
- Emergency = "emergency",
13
- Fatal = "fatal",
14
- Error = "error",
15
- Warn = "warn",
16
- Info = "info",
17
- Debug = "debug"
18
- }
19
- export declare class LoggerService {
20
- private logger;
21
- constructor(logger: Logger);
22
- log(level: LogLevel, message: string | Error, data?: ILogData, profile?: string): void;
23
- debug(message: string, data?: ILogData, profile?: string): void;
24
- info(message: string, data?: ILogData, profile?: string): void;
25
- warn(message: string | Error, data?: ILogData, profile?: string): void;
26
- error(message: string | Error, data?: ILogData, profile?: string): void;
27
- fatal(message: string | Error, data?: ILogData, profile?: string): void;
28
- emergency(message: string | Error, data?: ILogData, profile?: string): void;
29
- }
1
+ export { LoggerService } from '@infineit/winston-logger';
2
+ export type { Logger } from '@infineit/winston-logger';
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LoggerService=exports.LogLevel=void 0;const e=require("tslib"),r=require("@nestjs/common"),o=require("@infineit/winston-logger/logger/domain/logger");var g;!function(e){e.Emergency="emergency",e.Fatal="fatal",e.Error="error",e.Warn="warn",e.Info="info",e.Debug="debug"}(g||(exports.LogLevel=g={}));let t=class{constructor(e){this.logger=e}log(e,r,o,g){this.logger.log(e,r,o,g)}debug(e,r,o){this.logger.debug(e,r,o)}info(e,r,o){this.logger.info(e,r,o)}warn(e,r,o){this.logger.warn(e,r,o)}error(e,r,o){this.logger.error(e,r,o)}fatal(e,r,o){this.logger.fatal(e,r,o)}emergency(e,r,o){this.logger.emergency(e,r,o)}};exports.LoggerService=t,exports.LoggerService=t=e.__decorate([(0,r.Injectable)(),e.__param(0,(0,r.Inject)(o.LoggerKey)),e.__metadata("design:paramtypes",[Object])],t);
1
+ "use strict";var e=require("@infineit/winston-logger");Object.defineProperty(exports,"LoggerService",{enumerable:!0,get:function(){return e.LoggerService}});
2
+ //# sourceMappingURL=logger.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MergeService=void 0;const e=require("tslib"),t=require("@nestjs/common");let r=class{async mergeEntities(e,t,r,n={}){const s={};for(const[e,n]of Object.entries(t)){const t=r[e]?.foreignKey;t&&(s[e]=new Map(n.map(e=>[String(e[t]),e])))}const o=[];for(const i of e){let e={...i};for(const[o,c]of Object.entries(r)){const{foreignKey:r,nestedRelationships:f,filters:a}=c,l=String(i[r]);let y=s[o]?.get(l);if(a){Object.keys(a).every(e=>{const t=a[e];return Array.isArray(t)?t.includes(y?.[e]):"function"==typeof t?t(y?.[e]):y?.[e]===t})||(y=void 0)}if(y&&(n.flatten?e={...e,...y}:e[o]={...y},f))for(const[r,s]of Object.entries(f))try{const i=String(y[s.foreignKey]),c=new Map(t[r].map(e=>[e.id_timezone,e])).get(i);if(s.filters){if(!Object.keys(s.filters).every(e=>{const t=s.filters?.[e]??void 0,r=c?.[e];return Array.isArray(t)?t.includes(r):"function"==typeof t?t(r):r===t}))continue}c&&(n.flatten?e={...e,...c}:e[o][r]=c)}catch(e){}}o.push(e)}return o}};exports.MergeService=r,exports.MergeService=r=e.__decorate([(0,t.Injectable)()],r);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),t=require("@nestjs/common");exports.MergeService=class{async mergeEntities(e,t,r,n={}){const s={};for(const[e,n]of Object.entries(t)){const t=r[e]?.foreignKey;t&&(s[e]=new Map(n.map(e=>[String(e[t]),e])))}const i=[];for(const o of e){let e={...o};for(const[i,c]of Object.entries(r)){const{foreignKey:r,nestedRelationships:f,filters:a}=c,l=String(o[r]);let y=s[i]?.get(l);if(a){Object.keys(a).every(e=>{const t=a[e];return Array.isArray(t)?t.includes(y?.[e]):"function"==typeof t?t(y?.[e]):y?.[e]===t})||(y=void 0)}if(y&&(n.flatten?e={...e,...y}:e[i]={...y},f))for(const[r,s]of Object.entries(f))try{const o=String(y[s.foreignKey]),c=new Map(t[r].map(e=>[e.id_timezone,e])).get(o);if(s.filters){if(!Object.keys(s.filters).every(e=>{const t=s.filters?.[e]??void 0,r=c?.[e];return Array.isArray(t)?t.includes(r):"function"==typeof t?t(r):r===t}))continue}c&&(n.flatten?e={...e,...c}:e[i][r]=c)}catch(e){}}i.push(e)}return i}},exports.MergeService=e.__decorate([t.Injectable()],exports.MergeService);
2
+ //# sourceMappingURL=merge.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MessageFormatterService=void 0;const e=require("tslib"),t=require("@nestjs/common");let r=class{static capitalizeFirstLetter(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}static toLowerCase(e){return e.toLowerCase()}static formatMessage(e,t){if("string"==typeof t)return e.replace(/{{module_label}}/gi,t);let r=e;for(const[e,s]of Object.entries(t)){const t=`{{${e}}}`;r=r.replace(new RegExp(t,"gi"),s)}return r}static toSingularOrPlural(e,t){return 1===t?e:`${e}s`}static prepareMessage(e,t,r=!1){const s=r?this.capitalizeFirstLetter(t):this.toLowerCase(t);return this.formatMessage(e,s)}};exports.MessageFormatterService=r,exports.MessageFormatterService=r=e.__decorate([(0,t.Injectable)()],r);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),t=require("@nestjs/common");exports.MessageFormatterService=class{static capitalizeFirstLetter(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}static toLowerCase(e){return e.toLowerCase()}static formatMessage(e,t){if("string"==typeof t)return e.replace(/{{module_label}}/gi,t);let r=e;for(const[e,s]of Object.entries(t)){const t=`{{${e}}}`;r=r.replace(new RegExp(t,"gi"),s)}return r}static toSingularOrPlural(e,t){return 1===t?e:`${e}s`}static prepareMessage(e,t,r=!1){const s=r?this.capitalizeFirstLetter(t):this.toLowerCase(t);return this.formatMessage(e,s)}},exports.MessageFormatterService=e.__decorate([t.Injectable()],exports.MessageFormatterService);
2
+ //# sourceMappingURL=message.formatter.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaginationService=void 0;const e=require("tslib"),t=require("@nestjs/common"),i=require("@infineit-nestjs/utils/dto"),a=require("./prisma.service");let n=class{constructor(e){this.prisma=e}async paginate(e,t,a){const{page:n=1,limit:r=10,pagination:s}=a,o=`${e} LIMIT ${r} OFFSET ${(n-1)*r}`,c="all"===s||"paginate"===s,[p,l]=await Promise.all([this.prisma.$queryRawUnsafe(o),c?this.prisma.$queryRawUnsafe(t):[{count:0}]]);return{data:p,meta:c?new i.PaginationMetaDto({paginationQueryDto:a,totalItems:Number(l[0].count)}):void 0,has_next_page:"all"===s||"infinity"===s?p.length===r:void 0}}};exports.PaginationService=n,exports.PaginationService=n=e.__decorate([(0,t.Injectable)(),e.__metadata("design:paramtypes",[a.PrismaService])],n);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),a=require("@nestjs/common"),i=require("@infineit-nestjs/utils/dto"),t=require("./prisma.service.js");exports.PaginationService=class{constructor(e){this.prisma=e}async paginate(e,a,t){const{page:s=1,limit:n=10,pagination:r}=t,o=`${e} LIMIT ${n} OFFSET ${(s-1)*n}`,c="all"===r||"paginate"===r,[l,m]=await Promise.all([this.prisma.$queryRawUnsafe(o),c?this.prisma.$queryRawUnsafe(a):[{count:0}]]);return{data:l,meta:c?new i.PaginationMetaDto({paginationQueryDto:t,totalItems:Number(m[0].count)}):void 0,has_next_page:"all"===r||"infinity"===r?l.length===n:void 0}}},exports.PaginationService=e.__decorate([a.Injectable(),e.__metadata("design:paramtypes",[t.PrismaService])],exports.PaginationService);
2
+ //# sourceMappingURL=pagination.service.js.map
@@ -3,15 +3,52 @@ import { ConfigService } from '@nestjs/config';
3
3
  import { HealthIndicatorResult } from '@nestjs/terminus';
4
4
  import { AllConfigType } from '@infineit-nestjs/types';
5
5
  import { Prisma, PrismaClient } from '@prisma/client';
6
+ export interface IQueryObject<_T = unknown> {
7
+ name: string;
8
+ type: 'SELECT' | 'SELECT_ONE' | 'SELECT_MANY' | 'INSERT' | 'UPDATE' | 'DELETE';
9
+ syntax: (...args: any[]) => string;
10
+ params: (...args: any[]) => any[];
11
+ }
12
+ export interface IRawTransactionQuery {
13
+ sql: string;
14
+ params?: any[];
15
+ fieldsToEscape?: string[];
16
+ }
17
+ export interface ITransactionOptions {
18
+ timeout?: number;
19
+ isolationLevel?: 'ReadUncommitted' | 'ReadCommitted' | 'RepeatableRead' | 'Serializable';
20
+ maxWait?: number;
21
+ }
22
+ export interface IRawTransactionClient {
23
+ execute: (sql: string, ...params: any[]) => Promise<any[]>;
24
+ commit: () => Promise<void>;
25
+ rollback: () => Promise<void>;
26
+ cleanup?: () => void;
27
+ }
28
+ export type QueryMethod<_T = unknown> = (...args: any[]) => IQueryObject<any>;
6
29
  export declare class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
7
30
  private readonly configService;
31
+ private readonly logger;
32
+ private readonly defaultQueryTimeout;
33
+ private readonly slowQueryThreshold;
34
+ private readonly defaultTransactionTimeout;
35
+ private readonly maxQueryResultSize;
36
+ private readonly maxSqlLength;
37
+ private static readonly QUERY_TYPES;
8
38
  constructor(configService: ConfigService<AllConfigType>);
9
39
  onModuleInit(): Promise<void>;
10
40
  onModuleDestroy(): Promise<void>;
11
- executeRawQuery<T>(queryMethod: Function, ...args: any[]): Promise<T | T[] | null>;
41
+ executeRawQuery<T>(queryMethod: QueryMethod<T>, ...args: any[]): Promise<T | T[] | null>;
12
42
  private getQueryDetails;
13
43
  private sanitizeData;
14
44
  executeRawQueryOld(queryObj?: any, data?: any, fields?: string[]): Promise<any>;
15
- executeTransaction(actions: (prisma: Prisma.TransactionClient) => Promise<any>): Promise<any>;
45
+ executeTransaction(actions: (prisma: Prisma.TransactionClient) => Promise<any>, options?: ITransactionOptions): Promise<any>;
46
+ beginTransaction(options?: ITransactionOptions): Promise<IRawTransactionClient>;
47
+ executeRawTransaction(queries: IRawTransactionQuery[], options?: ITransactionOptions): Promise<any[]>;
48
+ executeRawTransactionWithQueries(queryMethods: Array<{
49
+ queryMethod: Function;
50
+ args: any[];
51
+ fieldsToEscape?: string[];
52
+ }>, options?: ITransactionOptions): Promise<any[]>;
16
53
  isHealthy(): Promise<HealthIndicatorResult>;
17
54
  }
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PrismaService=void 0;const e=require("tslib"),t=require("@nestjs/common"),r=require("@nestjs/config"),s=require("@prisma/client"),a=e.__importStar(require("lodash"));let n=class extends s.PrismaClient{constructor(e){super({datasources:{db:{url:e.get("database.url",{infer:!0})}}}),this.configService=e}async onModuleInit(){await this.$connect()}async onModuleDestroy(){await this.$disconnect()}async executeRawQuery(e,...t){try{let r=[],s=[];Array.isArray(t[t.length-1])&&(r=t.pop()),s=t;const{queryObj:a,sql:n,queryParams:i}=this.getQueryDetails(e,...s),c=r.length>0?this.sanitizeData(i,r):i,o=await this.$queryRawUnsafe(n,...c);let u;return u="SELECT_ONE"===a.type||"INSERT"===a.type?o.length>0?o[0]:null:o,u}catch(e){throw e}}getQueryDetails(e,...t){const r=e(),s=r.syntax(...t),a=r.params(...t);return{queryObj:r,sql:s,queryParams:a}}sanitizeData(e,t){if("object"==typeof e&&null!==e&&!(e instanceof Array)){const r={...e};for(const[e,s]of Object.entries(r))t.includes(e)&&"string"==typeof s&&(r[e]=s.replace(/'/g,"''"));return r}return e}async executeRawQueryOld(e=null,t=null,r=[]){const s=Object.assign({},t);if("object"==typeof t&&t instanceof Object&&!(t instanceof Array))for(const[e,t]of Object.entries(s)){if(r.includes(e)){const r=t;s[e]=r.replace(/'/g,"''")}}let n;n=t?e.syntax("object"==typeof t&&t instanceof Object&&!(t instanceof Array)?s:t):e.syntax();const i=await this.$queryRawUnsafe(n);let c;return c="SELECT_ONE"==e.type||"INSERT"==e.type?a.isEmpty(i)?null:i[0]:i,c}async executeTransaction(e){return this.$transaction(e)}async isHealthy(){try{return await(this.$queryRaw`SELECT 1`),{prisma:{status:"up"}}}catch(e){return{prisma:{status:"down",error:e instanceof Error?e.message:"Unknown error"}}}}};exports.PrismaService=n,exports.PrismaService=n=e.__decorate([(0,t.Injectable)(),e.__metadata("design:paramtypes",[r.ConfigService])],n);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),t=require("@nestjs/common"),r=require("@nestjs/config"),a=require("@prisma/client");function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var o,s=n(require("lodash"));exports.PrismaService=class extends a.PrismaClient{static{o=this}static{this.QUERY_TYPES={SELECT:"SELECT",SELECT_ONE:"SELECT_ONE",SELECT_MANY:"SELECT_MANY",INSERT:"INSERT",UPDATE:"UPDATE",DELETE:"DELETE"}}constructor(e){const r=e.get("database.url",{infer:!0});if(!r)throw new Error("Database URL is required but not configured");super({datasources:{db:{url:r}}}),this.configService=e,this.logger=new t.Logger(o.name),this.defaultQueryTimeout=e.get("database.queryTimeout",{infer:!0})??3e4,this.slowQueryThreshold=e.get("database.slowQueryThreshold",{infer:!0})??1e3,this.defaultTransactionTimeout=e.get("database.transactionTimeout",{infer:!0})??6e4,this.maxQueryResultSize=e.get("database.maxQueryResultSize",{infer:!0})??1e5,this.maxSqlLength=e.get("database.maxSqlLength",{infer:!0})??1e6}async onModuleInit(){try{await this.$connect(),this.logger.log("Database connection established")}catch(e){throw this.logger.error("Failed to connect to database",{error:e instanceof Error?e:new Error(String(e))}),e}}async onModuleDestroy(){try{await this.$disconnect(),this.logger.log("Database connection closed")}catch(e){this.logger.error("Error closing database connection",{error:e instanceof Error?e:new Error(String(e))})}}async executeRawQuery(e,...t){const r=Date.now();let a=null,n="",s="unknown";try{if("function"!=typeof e)throw new Error("Query method must be a function");let i=[],c=[];if(t.length>0&&Array.isArray(t[t.length-1])){const e=t[t.length-1];e.length>0&&"string"==typeof e[0]&&(i=t.pop())}c=t;const{queryObj:l,sql:u,queryParams:h}=this.getQueryDetails(e,...c);if(a=l,n=u,s=a.name,n.length>this.maxSqlLength)throw new Error(`SQL query exceeds maximum length of ${this.maxSqlLength} characters. Query length: ${n.length}`);const g=i.length>0?this.sanitizeData(h,i):h,m=this.$queryRawUnsafe(n,...g);let y=null;const d=new Promise((e,t)=>{y=setTimeout(()=>{t(new Error(`Query timeout after ${this.defaultQueryTimeout}ms`))},this.defaultQueryTimeout)});let w;try{w=await Promise.race([m,d])}finally{y&&(clearTimeout(y),y=null)}const E=Date.now()-r;if(E>this.slowQueryThreshold&&this.logger.warn(`Slow query detected: ${s}`,{queryName:s,executionTime:E,threshold:this.slowQueryThreshold}),(a.type===o.QUERY_TYPES.SELECT||a.type===o.QUERY_TYPES.SELECT_MANY)&&w.length>this.maxQueryResultSize)throw this.logger.warn(`Query result exceeds maximum size: ${s}`,{queryName:s,resultSize:w.length,maxSize:this.maxQueryResultSize}),new Error(`Query result exceeds maximum size of ${this.maxQueryResultSize} rows. Consider using pagination.`);let f;return f=a.type===o.QUERY_TYPES.SELECT_ONE||a.type===o.QUERY_TYPES.INSERT?w.length>0?w[0]:null:(a.type===o.QUERY_TYPES.SELECT||(a.type,o.QUERY_TYPES.SELECT_MANY),w),f}catch(e){const t=Date.now()-r,a=e instanceof Error?e:new Error(String(e));throw a instanceof Error&&"unknown"!==s&&(a.message=`${a.message} (Query: ${s})`),this.logger.error(`Query execution failed: ${s}`,{queryName:s,executionTime:t,sql:n.substring(0,200),error:a}),a}}getQueryDetails(e,...t){try{const r=e();if(!r||"function"!=typeof r.syntax||"function"!=typeof r.params)throw new Error("Invalid query object: missing syntax or params methods");const a=r.syntax(...t),n=r.params(...t);if("string"!=typeof a)throw new Error("Query syntax must return a string");if(0===a.trim().length)throw new Error("Query syntax must return a non-empty SQL string");if(!Array.isArray(n))throw new Error("Query params must return an array");return{queryObj:r,sql:a,queryParams:n}}catch(e){throw new Error(`Failed to get query details: ${e instanceof Error?e.message:"Unknown error"}`)}}sanitizeData(e,t){if("object"==typeof e&&null!==e&&!(e instanceof Array)){const r={...e};for(const[e,a]of Object.entries(r))t.includes(e)&&"string"==typeof a&&(r[e]=a.replace(/'/g,"''"));return r}return e}async executeRawQueryOld(e=null,t=null,r=[]){const a=Object.assign({},t);if("object"==typeof t&&t instanceof Object&&!(t instanceof Array))for(const[e,t]of Object.entries(a)){if(r.includes(e)){const r=t;a[e]=r.replace(/'/g,"''")}}let n;n=t?e.syntax("object"==typeof t&&t instanceof Object&&!(t instanceof Array)?a:t):e.syntax();const o=await this.$queryRawUnsafe(n);let i;return i="SELECT_ONE"==e.type||"INSERT"==e.type?s.isEmpty(o)?null:o[0]:o,i}async executeTransaction(e,t){const r=Date.now(),a=t?.timeout??this.defaultTransactionTimeout;try{const n={maxWait:t?.maxWait??1e4,timeout:a};t?.isolationLevel&&(n.isolationLevel=t.isolationLevel);const o=this.$transaction(e,n),s=new Promise((e,t)=>{setTimeout(()=>t(new Error(`Transaction timeout after ${a}ms`)),a)}),i=await Promise.race([o,s]),c=Date.now()-r;return c>5*this.slowQueryThreshold&&this.logger.warn("Slow transaction detected",{executionTime:c,threshold:5*this.slowQueryThreshold}),i}catch(e){const t=Date.now()-r;throw this.logger.error("Transaction failed",{executionTime:t,error:e instanceof Error?e:new Error(String(e))}),e}}async beginTransaction(e){const t=e?.timeout??this.defaultTransactionTimeout;let r=e?.isolationLevel??"ReadCommitted";"ReadUncommitted"===r&&(this.logger.warn("PostgreSQL does not support READ UNCOMMITTED isolation level. Using READ COMMITTED instead.",{transactionId:"pending"}),r="ReadCommitted");const a={ReadCommitted:"READ COMMITTED",RepeatableRead:"REPEATABLE READ",Serializable:"SERIALIZABLE"}[r]||"READ COMMITTED";let n=null,o=!1,s=!1,i=null;const c=()=>{i&&(clearTimeout(i),i=null)};try{await this.$executeRawUnsafe(`BEGIN TRANSACTION ISOLATION LEVEL ${a}`),n=`tx_${Date.now()}_${Math.random().toString(36).slice(2,11)}`,this.logger.debug(`Transaction started: ${n}`,{transactionId:n,isolationLevel:r});const e={execute:async(e,...t)=>{if(o||s)throw new Error("Cannot execute query: transaction already committed or rolled back");if(e.length>this.maxSqlLength)throw new Error(`SQL query exceeds maximum length of ${this.maxSqlLength} characters. Length: ${e.length}`);try{const r=await this.$queryRawUnsafe(e,...t),a=Array.isArray(r)?r:[r];if(a.length>this.maxQueryResultSize)throw this.logger.warn(`Transaction query result exceeds maximum size: ${n}`,{transactionId:n,resultSize:a.length,maxSize:this.maxQueryResultSize}),new Error(`Query result exceeds maximum size of ${this.maxQueryResultSize} rows. Consider using pagination.`);return a}catch(t){throw this.logger.error(`Query failed in transaction ${n}`,{transactionId:n,sql:e.substring(0,200),error:t instanceof Error?t:new Error(String(t))}),t}},commit:async()=>{if(o)throw new Error("Transaction already committed");if(s)throw new Error("Transaction already rolled back");try{c(),await this.$executeRawUnsafe("COMMIT"),o=!0,this.logger.debug(`Transaction committed: ${n}`,{transactionId:n})}catch(e){throw this.logger.error(`Failed to commit transaction ${n}`,{transactionId:n,error:e instanceof Error?e:new Error(String(e))}),e}},rollback:async()=>{if(!s){if(o)throw new Error("Cannot rollback: transaction already committed");try{c(),await this.$executeRawUnsafe("ROLLBACK"),s=!0,this.logger.debug(`Transaction rolled back: ${n}`,{transactionId:n})}catch(e){throw this.logger.error(`Failed to rollback transaction ${n}`,{transactionId:n,error:e instanceof Error?e:new Error(String(e))}),e}}},cleanup:c};return i=setTimeout(()=>{setImmediate(async()=>{if(!o&&!s){c(),this.logger.warn(`Transaction timeout: ${n}`,{transactionId:n,timeout:t});try{await this.$executeRawUnsafe("ROLLBACK"),s=!0}catch(e){this.logger.error(`Auto-rollback failed for transaction ${n}`,{transactionId:n,error:e instanceof Error?e:new Error(String(e))})}}})},t),e}catch(e){throw this.logger.error(`Failed to begin transaction: ${n}`,{transactionId:n,error:e instanceof Error?e:new Error(String(e))}),e}}async executeRawTransaction(e,t){const r=Date.now();if(!Array.isArray(e)||0===e.length)throw new Error("Queries array must contain at least one query");e.forEach((e,t)=>{if(!e||"object"!=typeof e)throw new Error(`Query at index ${t} must be an object`);if(!e.sql||"string"!=typeof e.sql||0===e.sql.trim().length)throw new Error(`Query at index ${t} must have a non-empty SQL string`);if(e.sql.length>this.maxSqlLength)throw new Error(`Query at index ${t} SQL exceeds maximum length of ${this.maxSqlLength} characters. Length: ${e.sql.length}`);if(e.params&&!Array.isArray(e.params))throw new Error(`Query at index ${t} params must be an array`);if(e.params&&e.params.length>0){const r=(e.sql.match(/\$\d+/g)||[]).length;r>0&&e.params.length!==r&&this.logger.warn(`Query at index ${t} parameter count mismatch: ${e.params.length} params, ${r} placeholders`,{queryIndex:t,paramCount:e.params.length,placeholderCount:r})}});const a=await this.beginTransaction(t),n=[];try{for(let t=0;t<e.length;t++){const r=e[t];let o=r.params||[];if(r.fieldsToEscape&&r.fieldsToEscape.length>0){const e={};r.fieldsToEscape.forEach((t,r)=>{void 0!==o[r]&&(e[t]=o[r])});const t=this.sanitizeData(e,r.fieldsToEscape);if(!r.fieldsToEscape||0===r.fieldsToEscape.length)return o;o=r.fieldsToEscape.map((e,r)=>t[e]??o[r])}const s=await a.execute(r.sql,...o);n.push(s)}await a.commit();const t=Date.now()-r;return t>5*this.slowQueryThreshold&&this.logger.warn("Slow raw SQL transaction detected",{queryCount:e.length,executionTime:t,threshold:5*this.slowQueryThreshold}),this.logger.debug("Raw SQL transaction completed successfully",{queryCount:e.length,executionTime:t}),n}catch(t){try{await a.rollback()}catch(e){this.logger.error("Failed to rollback transaction",{error:e instanceof Error?e:new Error(String(e))})}const n=Date.now()-r;throw this.logger.error("Raw SQL transaction failed",{queryCount:e.length,executionTime:n,error:t instanceof Error?t:new Error(String(t))}),t}}async executeRawTransactionWithQueries(e,t){const r=Date.now();if(!Array.isArray(e)||0===e.length)throw new Error("Query methods array must contain at least one query method");try{const a=e.map((e,t)=>{if("function"!=typeof e.queryMethod)throw new Error(`Query method at index ${t} must be a function`);if(!e.args||!Array.isArray(e.args))throw new Error(`Query method at index ${t} args must be an array`);const{sql:r,queryParams:a}=this.getQueryDetails(e.queryMethod,...e.args);return{sql:r,params:a,fieldsToEscape:e.fieldsToEscape}}),n=await this.executeRawTransaction(a,t),o=Date.now()-r;return this.logger.debug("Transaction with query methods completed",{queryCount:e.length,executionTime:o}),n}catch(t){const a=Date.now()-r;throw this.logger.error("Transaction with query methods failed",{queryCount:e.length,executionTime:a,error:t instanceof Error?t:new Error(String(t))}),t}}async isHealthy(){const e=Date.now();try{await(this.$queryRaw`SELECT 1`);const t=Date.now()-e;let r;t>100&&this.logger.warn("Slow health check detected",{executionTime:t,threshold:100});try{r={note:"Pool metrics require Prisma metrics API (not yet available in 6.x)"}}catch(e){this.logger.debug("Could not extract pool metrics",{error:e instanceof Error?e.message:String(e)})}return{prisma:{status:"up",responseTime:t,...r&&{poolMetrics:r}}}}catch(t){const r=Date.now()-e;return this.logger.error("Health check failed",{executionTime:r,error:t instanceof Error?t:new Error(String(t))}),{prisma:{status:"down",error:t instanceof Error?t.message:"Unknown error",responseTime:r}}}}},exports.PrismaService=o=e.__decorate([t.Injectable(),e.__metadata("design:paramtypes",[r.ConfigService])],exports.PrismaService);
2
+ //# sourceMappingURL=prisma.service.js.map
@@ -1 +1,2 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),exports.RedisService=void 0;const t=require("tslib"),i=require("@nestjs/common"),s=require("@nestjs/config"),r=t.__importDefault(require("ioredis"));let n=e=class{constructor(t){this.configService=t,this.logger=new i.Logger(e.name)}async onModuleInit(){const e=this.configService.getOrThrow("redis",{infer:!0}),t=e.clusterNodes||"",i={password:e.password||void 0,db:e.db??0,connectTimeout:1e4,maxRetriesPerRequest:null,enableReadyCheck:!0,retryStrategy:e=>Math.min(100*e,2e3),reconnectOnError:e=>!!["ECONNRESET","ETIMEDOUT","EHOSTUNREACH","ECONNREFUSED"].some(t=>e.message.includes(t)),keepAlive:3e4};if(t){const s=(e.clusterNodes??[]).map(e=>{const[t,i]=e.split(":");return{host:t,port:parseInt(i,10)}});this.logger.log(`Starting Redis Cluster with nodes: ${t}`),this.publisherClient=new r.default.Cluster(s,{redisOptions:i,scaleReads:"slave",slotsRefreshTimeout:2e3}),this.subscriberClient=new r.default.Cluster(s,{redisOptions:i,scaleReads:"slave",slotsRefreshTimeout:2e3})}else{const t=e.host||"127.0.0.1",s=e.port??6379;this.publisherClient=new r.default({host:t,port:s,...i}),this.subscriberClient=new r.default({host:t,port:s,...i})}this.registerEventListeners(this.publisherClient,"Publisher"),this.registerEventListeners(this.subscriberClient,"Subscriber"),await Promise.all([this.waitUntilReady(this.publisherClient),this.waitUntilReady(this.subscriberClient)])}registerEventListeners(e,t){e.on("connect",()=>this.logger.log(`${t} Redis client connecting...`)),e.on("ready",()=>this.logger.log(`${t} Redis client ready.`)),e.on("error",e=>this.logger.error(`${t} Redis client error`,e)),e.on("close",()=>this.logger.warn(`${t} Redis connection closed`)),e.on("reconnecting",e=>this.logger.warn(`${t} Redis reconnecting in ${e}ms`)),e.on("end",()=>this.logger.warn(`${t} Redis connection ended`))}waitUntilReady(e){return new Promise((t,i)=>{if("ready"===e.status)return t();const s=setTimeout(()=>{i(new Error("Redis client failed to connect within timeout"))},15e3);e.once("ready",()=>{clearTimeout(s),t()})})}getPublisherClient(){return this.publisherClient}getSubscriberClient(){return this.subscriberClient}async onModuleDestroy(){this.logger.log("Shutting down Redis clients");const e=[];this.publisherClient&&e.push(this.publisherClient.quit().catch(e=>this.logger.warn("Error quitting publisher client",e))),this.subscriberClient&&e.push(this.subscriberClient.quit().catch(e=>this.logger.warn("Error quitting subscriber client",e))),await Promise.all(e)}};exports.RedisService=n,exports.RedisService=n=e=t.__decorate([(0,i.Injectable)(),t.__metadata("design:paramtypes",[s.ConfigService])],n);
1
+ "use strict";var e,s=require("../node_modules/tslib/tslib.es6.js"),i=require("@nestjs/common"),t=require("@nestjs/config"),r=require("ioredis");exports.RedisService=e=class{constructor(s){this.configService=s,this.logger=new i.Logger(e.name)}async onModuleInit(){const e=this.configService.getOrThrow("redis",{infer:!0}),s=e.clusterNodes||"",i={password:e.password||void 0,db:e.db??0,connectTimeout:1e4,maxRetriesPerRequest:null,enableReadyCheck:!0,retryStrategy:e=>Math.min(100*e,2e3),reconnectOnError:e=>!!["ECONNRESET","ETIMEDOUT","EHOSTUNREACH","ECONNREFUSED"].some(s=>e.message.includes(s)),keepAlive:3e4};if(s){const t=(e.clusterNodes??[]).map(e=>{const[s,i]=e.split(":");return{host:s,port:parseInt(i,10)}});this.logger.log(`Starting Redis Cluster with nodes: ${s}`),this.publisherClient=new r.Cluster(t,{redisOptions:i,scaleReads:"slave",slotsRefreshTimeout:2e3}),this.subscriberClient=new r.Cluster(t,{redisOptions:i,scaleReads:"slave",slotsRefreshTimeout:2e3})}else{const s=e.host||"127.0.0.1",t=e.port??6379;this.publisherClient=new r({host:s,port:t,...i}),this.subscriberClient=new r({host:s,port:t,...i})}this.registerEventListeners(this.publisherClient,"Publisher"),this.registerEventListeners(this.subscriberClient,"Subscriber"),await Promise.all([this.waitUntilReady(this.publisherClient),this.waitUntilReady(this.subscriberClient)])}registerEventListeners(e,s){e.on("connect",()=>this.logger.log(`${s} Redis client connecting...`)),e.on("ready",()=>this.logger.log(`${s} Redis client ready.`)),e.on("error",e=>this.logger.error(`${s} Redis client error`,e)),e.on("close",()=>this.logger.warn(`${s} Redis connection closed`)),e.on("reconnecting",e=>this.logger.warn(`${s} Redis reconnecting in ${e}ms`)),e.on("end",()=>this.logger.warn(`${s} Redis connection ended`))}waitUntilReady(e){return new Promise((s,i)=>{if("ready"===e.status)return s();const t=setTimeout(()=>{i(new Error("Redis client failed to connect within timeout"))},15e3);e.once("ready",()=>{clearTimeout(t),s()})})}getPublisherClient(){return this.publisherClient}getSubscriberClient(){return this.subscriberClient}async onModuleDestroy(){this.logger.log("Shutting down Redis clients");const e=[];this.publisherClient&&e.push(this.publisherClient.quit().catch(e=>this.logger.warn("Error quitting publisher client",e))),this.subscriberClient&&e.push(this.subscriberClient.quit().catch(e=>this.logger.warn("Error quitting subscriber client",e))),await Promise.all(e)}},exports.RedisService=e=s.__decorate([i.Injectable(),s.__metadata("design:paramtypes",[t.ConfigService])],exports.RedisService);
2
+ //# sourceMappingURL=redis.service.js.map
@@ -1 +1,2 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ResourceFetchService=exports.MissingDataError=void 0;const t=require("tslib"),r=require("@nestjs/common"),a=require("./data.transformer.service"),i=require("./http.client.service");class s extends Error{constructor(e){super(`No distinct values found for the requested field: ${e}`),this.field=e,this.name="MissingDataError",this.field=e}formatFieldName(){const e=this.field.startsWith("id_")?this.field.slice(3):this.field;return e.charAt(0).toUpperCase()+e.slice(1)}}exports.MissingDataError=s;let n=e=class{constructor(t,a){this.dataTransformerService=t,this.httpServiceClient=a,this.logger=new r.Logger(e.name)}async fetchResourcesDynamic(e){const t=e.map(e=>{const{resource:t,type:r,page:a=1,limit:i=10,version:s="v1",filters:n=[],sort:o=[],pagination:c="all"}=e,l=this.constructRelativePath({resource:t,type:r,page:a,limit:i,version:s,filters:n,sort:o,pagination:c});return this.fetchResources(t,l).then(e=>({[r]:e})).catch(e=>{throw this.logger.error(`Error fetching resource ${r}: ${e.message}`),e})});return(await Promise.all(t)).reduce((e,t)=>Object.assign(e,t),{})}async transformMultipleDataSets(e){const t=e.map(({name:e,data:t,fields:r})=>t?this.dataTransformerService.processData(t,r).then(t=>({[e]:t})):Promise.resolve({[e]:{error:`${e} data is undefined`}}));return(await Promise.all(t)).reduce((e,t)=>Object.assign(e,t),{})}async getUniqueFieldValues(e,t){return t.reduce((t,r)=>(t[r]=[...new Set(e.map(e=>e[r]))],t),{})}async mergeData(e,t){return e.map(e=>t.reduce((t,{field:r,data:a,field_name:i,removeField:s})=>{const n=this.getFieldValue(a,r,e[r],{[r]:e[r],name:`Default ${r.charAt(0).toUpperCase()+r.slice(1)}`});return t[i]=n,s&&delete t[r],t},{...e}))}async generateQueryFunctions(e,t){return e.reduce((e,{field:r,query:a})=>(e[r]=async e=>{const r=await t(a,e);return Array.isArray(r)?r:[r]},e),{})}async applyDataTransformations(e,t,r,a){const i=await this.getUniqueFieldValues(e,t),s=await this.fetchAssociatedData(i,r),n=this.mapDataForTransformation(s,a);return this.mergeEnrichedData(e,n)}async fetchAssociatedData(e,t){const r={};return await Promise.all(Object.entries(t).map(async([t,a])=>{const i=e[t];if(!Array.isArray(i)||0===i.length)throw new s(t);try{const e=await a(i.join(","));r[t]=Array.isArray(e)?e:[e]}catch(e){throw new Error(`Failed to fetch associated data for field: ${t}`,e)}})),r}mapDataForTransformation(e,t){return t.map(({field:t,field_name:r,removeField:a})=>({field:t,data:e[t],field_name:r,removeField:a??!0}))}async mergeEnrichedData(e,t){const r=t.reduce((e,{field:t,data:r,field_name:a})=>(e[a]=new Map(r.map(e=>[e[t],e])),e),{});return e.map(e=>{const a={...e};return t.forEach(({field:t,field_name:i,removeField:s})=>{const n=r[i],o=e[t],c=n?.get(o)||{[t]:o,name:`unknown-id-${o}`};a[i]=c,s&&delete a[t]}),a})}constructRelativePath({resource:e,type:t,page:r,limit:a,version:i,filters:s,sort:n,pagination:o}){let c=`api/${i}/${t}`;const l=this.constructFilters(s),d=this.constructSort(n);return c+=`?pagination=${o}&page=${r}&limit=${a}`,l.length>0&&(c+=`&filters=[${l.join(",")}]`),d.length>0&&(c+=`&sort=[${d.join(",")}]`),this.logger.debug(`Constructed relative URL: ${c}`),c}constructFilters(e){return e.map(e=>`{"field":"${e.field}","operator":"${e.operator}","value":"${e.value}"}`)}constructSort(e){return e.map(e=>`{"field":"${e.field}","direction":"${e.direction}"}`)}fetchResources(e,t){return this.httpServiceClient.getResource(e,"get",t)}getFieldValue(e,t,r,a){return e.find(e=>e[t]===r)||a}};exports.ResourceFetchService=n,exports.ResourceFetchService=n=e=t.__decorate([(0,r.Injectable)(),t.__metadata("design:paramtypes",[a.DataTransformerService,i.HttpServiceClient])],n);
1
+ "use strict";var e,t=require("../node_modules/tslib/tslib.es6.js"),r=require("@nestjs/common"),a=require("./data.transformer.service.js"),i=require("./http.client.service.js");class s extends Error{constructor(e){super(`No distinct values found for the requested field: ${e}`),this.field=e,this.name="MissingDataError",this.field=e}formatFieldName(){const e=this.field.startsWith("id_")?this.field.slice(3):this.field;return e.charAt(0).toUpperCase()+e.slice(1)}}exports.ResourceFetchService=e=class{constructor(t,a){this.dataTransformerService=t,this.httpServiceClient=a,this.logger=new r.Logger(e.name)}async fetchResourcesDynamic(e){const t=e.map(e=>{const{resource:t,type:r,page:a=1,limit:i=10,version:s="v1",filters:n=[],sort:o=[],pagination:c="all"}=e,l=this.constructRelativePath({resource:t,type:r,page:a,limit:i,version:s,filters:n,sort:o,pagination:c});return this.fetchResources(t,l).then(e=>({[r]:e})).catch(e=>{throw this.logger.error(`Error fetching resource ${r}: ${e.message}`),e})});return(await Promise.all(t)).reduce((e,t)=>Object.assign(e,t),{})}async transformMultipleDataSets(e){const t=e.map(({name:e,data:t,fields:r})=>t?this.dataTransformerService.processData(t,r).then(t=>({[e]:t})):Promise.resolve({[e]:{error:`${e} data is undefined`}}));return(await Promise.all(t)).reduce((e,t)=>Object.assign(e,t),{})}async getUniqueFieldValues(e,t){return t.reduce((t,r)=>(t[r]=[...new Set(e.map(e=>e[r]))],t),{})}async mergeData(e,t){return e.map(e=>t.reduce((t,{field:r,data:a,field_name:i,removeField:s})=>{const n=this.getFieldValue(a,r,e[r],{[r]:e[r],name:`Default ${r.charAt(0).toUpperCase()+r.slice(1)}`});return t[i]=n,s&&delete t[r],t},{...e}))}async generateQueryFunctions(e,t){return e.reduce((e,{field:r,query:a})=>(e[r]=async e=>{const r=await t(a,e);return Array.isArray(r)?r:[r]},e),{})}async applyDataTransformations(e,t,r,a){const i=await this.getUniqueFieldValues(e,t),s=await this.fetchAssociatedData(i,r),n=this.mapDataForTransformation(s,a);return this.mergeEnrichedData(e,n)}async fetchAssociatedData(e,t){const r={};return await Promise.all(Object.entries(t).map(async([t,a])=>{const i=e[t];if(!Array.isArray(i)||0===i.length)throw new s(t);try{const e=await a(i.join(","));r[t]=Array.isArray(e)?e:[e]}catch(e){throw new Error(`Failed to fetch associated data for field: ${t}`,e)}})),r}mapDataForTransformation(e,t){return t.map(({field:t,field_name:r,removeField:a})=>({field:t,data:e[t],field_name:r,removeField:a??!0}))}async mergeEnrichedData(e,t){const r=t.reduce((e,{field:t,data:r,field_name:a})=>(e[a]=new Map(r.map(e=>[e[t],e])),e),{});return e.map(e=>{const a={...e};return t.forEach(({field:t,field_name:i,removeField:s})=>{const n=r[i],o=e[t],c=n?.get(o)||{[t]:o,name:`unknown-id-${o}`};a[i]=c,s&&delete a[t]}),a})}constructRelativePath({resource:e,type:t,page:r,limit:a,version:i,filters:s,sort:n,pagination:o}){let c=`api/${i}/${t}`;const l=this.constructFilters(s),d=this.constructSort(n);return c+=`?pagination=${o}&page=${r}&limit=${a}`,l.length>0&&(c+=`&filters=[${l.join(",")}]`),d.length>0&&(c+=`&sort=[${d.join(",")}]`),this.logger.debug(`Constructed relative URL: ${c}`),c}constructFilters(e){return e.map(e=>`{"field":"${e.field}","operator":"${e.operator}","value":"${e.value}"}`)}constructSort(e){return e.map(e=>`{"field":"${e.field}","direction":"${e.direction}"}`)}fetchResources(e,t){return this.httpServiceClient.getResource(e,"get",t)}getFieldValue(e,t,r,a){return e.find(e=>e[t]===r)||a}},exports.ResourceFetchService=e=t.__decorate([r.Injectable(),t.__metadata("design:paramtypes",[a.DataTransformerService,i.HttpServiceClient])],exports.ResourceFetchService),exports.MissingDataError=s;
2
+ //# sourceMappingURL=resource.fetch.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UtilsService=void 0;const e=require("tslib"),t=e.__importStar(require("url")),r=e.__importStar(require("samlify")),s=require("uuid");exports.UtilsService=class{buildDynamicQuery(e,t,r,s,n="*"){let i="",o="";const a=[],l=[],c=[],u=e.filters,d=e.sort,f=new Set;if(t&&Object.keys(t).forEach(e=>{const r=t[e],s=r.alias();f.has(s)||(f.add(s),l.push(r.joinTable(s))),c.push(...r.selectFields(s))}),u&&u.length>0){i=`WHERE ${u.map((e,r)=>{const s=e.field.toLowerCase();let n="ptbl";if(t&&t[s]){const e=t[s];n=e.alias(),f.has(n)||(f.add(n),l.push(e.joinTable(n))),c.push(...e.selectFields(n))}const i=`"${n}"."${e.field}"`,o=e.operator.toUpperCase(),u=e.value;if(null===u||"null"===u)return["=","IS"].includes(o)?`${i} IS NULL`:["!=","<>","IS NOT"].includes(o)?`${i} IS NOT NULL`:"";if(["IN","NOT IN"].includes(o)){const e=u.split(",").map(e=>`'${e.trim().replace(/'/g,"''")}'`).join(", ");return`${i} ${o} (${e})`}if(["LIKE","NOT LIKE"].includes(o)){return`(${u.split(",").map(e=>{const t=e.trim().replace(/'/g,"''");return`UPPER(CAST(${i} AS TEXT)) ${o} UPPER('%${t}%')`}).join(" OR ")})`}if("BETWEEN"===o){const e=u.split(",");if(2===e.length){const[t,r]=e.map(e=>e.trim().replace(/'/g,"''"));return`${i} BETWEEN '${t}' AND '${r}'`}return""}a.push(e.value);const d=String(u).replace(/'/g,"''");return"number"==typeof u?`${i} ${o} ${u}`:`${i} ${o} '${d}'`}).join(" AND ")}`}d&&d.length>0&&(o="ORDER BY ",o+=d.map(e=>{const r=e.field.toLowerCase();let s="ptbl";if(t&&t[r]){s=t[r].alias()}return`${s}.${e.field} ${e.direction}`}).join(", "));const S=c.length>0?`, ${c.join(", ")}`:[],{selectQuery:p,countQuery:$}=this.queryStatements(r,S,s,l,i,o,n);return{selectQuery:p,countQuery:$}}queryStatements(e,t,r,s,n,i,o="*"){return{selectQuery:`SELECT ${e.join(", ")} ${t} ${r} ${s.join(" ")} ${n} ${i}`,countQuery:`SELECT count(${o}) ${r} ${s.join(" ")} ${n}`}}mergeFilters(e,t,r){return e.filter(e=>![...t,...r].some(t=>e.field===t.field)).concat(t,r)}addFiltersToPaginationQuery(e,t,r=(e,t)=>e.field===t.field&&e.operator===t.operator&&e.value===t.value){e.filters||(e.filters=[]),t.forEach(t=>{const s=e.filters?.some(e=>r(e,t));s||e.filters?.push(t)})}base64Encode(e){return Buffer.from(e).toString("base64")}base64Decode(e,t=!1){const r=Buffer.from(e,"base64");return t?r:r.toString("ascii")}createSsoTemplateCallback(e,t,n,i){return o=>{const a=(0,s.v4)(),l=new Date,c=new Date(l.getTime());c.setMinutes(c.getMinutes()+5);const u=t.entityMeta.getEntityID(),d=e.entitySetting,f={ID:a,AssertionID:d.generateID?d.generateID():(0,s.v4)(),Destination:t.entityMeta.getAssertionConsumerService(n),Audience:u,SubjectRecipient:u,NameIDFormat:"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",NameID:i.Email,Issuer:e.entityMeta.getEntityID(),IssueInstant:l.toISOString(),ConditionsNotBefore:l.toISOString(),ConditionsNotOnOrAfter:c.toISOString(),SubjectConfirmationDataNotOnOrAfter:c.toISOString(),AssertionConsumerServiceURL:t.entityMeta.getAssertionConsumerService(n),EntityID:u,InResponseTo:"_4606cc1f427fa981e6ffd653ee8d6972fc5ce398c4",StatusCode:"urn:oasis:names:tc:SAML:2.0:status:Success",attrUserEmail:i.Email,attrUserIdUser:i.idUser,attrUserAccessToken:i.AccessToken,attrUserRefreshToken:i.RefreshToken,attrUserIdToken:i.idToken,attrUserAccessTokenExpiresAt:i.AccessTokenExpiresAt};return{id:a,context:r.SamlLib.replaceTagsByValue(o,f)}}}parseRedirectUrlContextCallBack(e){const r=t.parse(e,!0),{SAMLResponse:s,Signature:n,SigAlg:i}=r.query;delete r.query.Signature;return{query:{SAMLResponse:s,Signature:n,SigAlg:i},octetString:Object.keys(r.query).map(e=>`${e}=${encodeURIComponent(r.query[e])}`).join("&")}}generateFieldConfigs(e,t,r,s){const n={};return t.forEach(t=>{n[t]={alias:()=>r,joinTable:t=>`JOIN ${e} ${t} ON ${t}.${s} = ptbl.${s}`,selectFields:e=>[`${e}.${t}`]}}),n}};
1
+ "use strict";var e=require("url"),t=require("samlify"),r=require("uuid");function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var s=n(e),i=n(t);exports.UtilsService=class{buildDynamicQuery(e,t,r,n,s="*"){let i="",o="";const a=[],c=[],u=[],l=e.filters,f=e.sort,d=new Set;if(t&&Object.keys(t).forEach(e=>{const r=t[e],n=r.alias();d.has(n)||(d.add(n),c.push(r.joinTable(n))),u.push(...r.selectFields(n))}),l&&l.length>0){i=`WHERE ${l.map((e,r)=>{const n=e.field.toLowerCase();let s="ptbl";if(t&&t[n]){const e=t[n];s=e.alias(),d.has(s)||(d.add(s),c.push(e.joinTable(s))),u.push(...e.selectFields(s))}const i=`"${s}"."${e.field}"`,o=e.operator.toUpperCase(),l=e.value;if(null===l||"null"===l)return["=","IS"].includes(o)?`${i} IS NULL`:["!=","<>","IS NOT"].includes(o)?`${i} IS NOT NULL`:"";if(["IN","NOT IN"].includes(o)){const e=l.split(",").map(e=>`'${e.trim().replace(/'/g,"''")}'`).join(", ");return`${i} ${o} (${e})`}if(["LIKE","NOT LIKE"].includes(o)){return`(${l.split(",").map(e=>{const t=e.trim().replace(/'/g,"''");return`UPPER(CAST(${i} AS TEXT)) ${o} UPPER('%${t}%')`}).join(" OR ")})`}if("BETWEEN"===o){const e=l.split(",");if(2===e.length){const[t,r]=e.map(e=>e.trim().replace(/'/g,"''"));return`${i} BETWEEN '${t}' AND '${r}'`}return""}a.push(e.value);const f=String(l).replace(/'/g,"''");return"number"==typeof l?`${i} ${o} ${l}`:`${i} ${o} '${f}'`}).join(" AND ")}`}f&&f.length>0&&(o="ORDER BY ",o+=f.map(e=>{const r=e.field.toLowerCase();let n="ptbl";if(t&&t[r]){n=t[r].alias()}return`${n}.${e.field} ${e.direction}`}).join(", "));const $=u.length>0?`, ${u.join(", ")}`:[],{selectQuery:p,countQuery:S}=this.queryStatements(r,$,n,c,i,o,s);return{selectQuery:p,countQuery:S}}queryStatements(e,t,r,n,s,i,o="*"){return{selectQuery:`SELECT ${e.join(", ")} ${t} ${r} ${n.join(" ")} ${s} ${i}`,countQuery:`SELECT count(${o}) ${r} ${n.join(" ")} ${s}`}}mergeFilters(e,t,r){return e.filter(e=>![...t,...r].some(t=>e.field===t.field)).concat(t,r)}addFiltersToPaginationQuery(e,t,r=(e,t)=>e.field===t.field&&e.operator===t.operator&&e.value===t.value){e.filters||(e.filters=[]),t.forEach(t=>{const n=e.filters?.some(e=>r(e,t));n||e.filters?.push(t)})}base64Encode(e){return Buffer.from(e).toString("base64")}base64Decode(e,t=!1){const r=Buffer.from(e,"base64");return t?r:r.toString("ascii")}createSsoTemplateCallback(e,t,n,s){return o=>{const a=r.v4(),c=new Date,u=new Date(c.getTime());u.setMinutes(u.getMinutes()+5);const l=t.entityMeta.getEntityID(),f=e.entitySetting,d={ID:a,AssertionID:f.generateID?f.generateID():r.v4(),Destination:t.entityMeta.getAssertionConsumerService(n),Audience:l,SubjectRecipient:l,NameIDFormat:"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",NameID:s.Email,Issuer:e.entityMeta.getEntityID(),IssueInstant:c.toISOString(),ConditionsNotBefore:c.toISOString(),ConditionsNotOnOrAfter:u.toISOString(),SubjectConfirmationDataNotOnOrAfter:u.toISOString(),AssertionConsumerServiceURL:t.entityMeta.getAssertionConsumerService(n),EntityID:l,InResponseTo:"_4606cc1f427fa981e6ffd653ee8d6972fc5ce398c4",StatusCode:"urn:oasis:names:tc:SAML:2.0:status:Success",attrUserEmail:s.Email,attrUserIdUser:s.idUser,attrUserAccessToken:s.AccessToken,attrUserRefreshToken:s.RefreshToken,attrUserIdToken:s.idToken,attrUserAccessTokenExpiresAt:s.AccessTokenExpiresAt};return{id:a,context:i.SamlLib.replaceTagsByValue(o,d)}}}parseRedirectUrlContextCallBack(e){const t=s.parse(e,!0),{SAMLResponse:r,Signature:n,SigAlg:i}=t.query;delete t.query.Signature;return{query:{SAMLResponse:r,Signature:n,SigAlg:i},octetString:Object.keys(t.query).map(e=>`${e}=${encodeURIComponent(t.query[e])}`).join("&")}}generateFieldConfigs(e,t,r,n){const s={};return t.forEach(t=>{s[t]={alias:()=>r,joinTable:t=>`JOIN ${e} ${t} ON ${t}.${n} = ptbl.${n}`,selectFields:e=>[`${e}.${t}`]}}),s}};
2
+ //# sourceMappingURL=util.service.js.map
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ValidatorService=void 0;const e=require("tslib"),r=require("@nestjs/common"),i=require("class-validator"),t=e.__importStar(require("lodash"));let s=class{isImage(e){return t.includes(["image/jpeg","image/png"],e)}isEmail(e){return(0,i.isEmail)(e)}isNumber(e){return/^\d+$/.test(e)}};exports.ValidatorService=s,exports.ValidatorService=s=e.__decorate([(0,r.Injectable)()],s);
1
+ "use strict";var e=require("../node_modules/tslib/tslib.es6.js"),r=require("@nestjs/common"),t=require("class-validator");function i(e){var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,Object.freeze(r)}var a=i(require("lodash"));exports.ValidatorService=class{isImage(e){return a.includes(["image/jpeg","image/png"],e)}isEmail(e){return t.isEmail(e)}isNumber(e){return/^\d+$/.test(e)}},exports.ValidatorService=e.__decorate([r.Injectable()],exports.ValidatorService);
2
+ //# sourceMappingURL=validator.service.js.map
@@ -0,0 +1,2 @@
1
+ export{Argon2Service}from"./services/argon2.service.mjs";export{DataTransformerService}from"./services/data.transformer.service.mjs";export{EntityActionService}from"./services/entity.action.service.mjs";export{HttpServiceClient,rethrowHttpByStatus}from"./services/http.client.service.mjs";export{InitKafkaConsumer}from"./services/kafka.microservice.mjs";export{LoggerService}from"@infineit/winston-logger";export{MergeService}from"./services/merge.service.mjs";export{MessageFormatterService}from"./services/message.formatter.service.mjs";export{PaginationService}from"./services/pagination.service.mjs";export{PrismaService}from"./services/prisma.service.mjs";export{MissingDataError,ResourceFetchService}from"./services/resource.fetch.service.mjs";export{RedisService}from"./services/redis.service.mjs";export{UtilsService}from"./services/util.service.mjs";export{ValidatorService}from"./services/validator.service.mjs";export{DecimalUtilsService}from"./services/decimal.utils.service.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * decimal.js v10.6.0
3
+ * An arbitrary-precision Decimal type for JavaScript.
4
+ * https://github.com/MikeMcl/decimal.js
5
+ * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
6
+ * MIT Licence
7
+ */
8
+ var n,e,i=9e15,r=1e9,t="0123456789abcdef",s="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",o="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",u={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-i,maxE:i,crypto:!1},c=!0,f="[DecimalError] ",a=f+"Invalid argument: ",h=f+"Precision limit exceeded",d=f+"crypto unavailable",l="[object Decimal]",g=Math.floor,p=Math.pow,w=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,m=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,v=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,N=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,b=1e7,E=s.length-1,x=o.length-1,y={toStringTag:l};function M(n){var e,i,r,t=n.length-1,s="",o=n[0];if(t>0){for(s+=o,e=1;e<t;e++)(i=7-(r=n[e]+"").length)&&(s+=_(i)),s+=r;(i=7-(r=(o=n[e])+"").length)&&(s+=_(i))}else if(0===o)return"0";for(;o%10==0;)o/=10;return s+o}function q(n,e,i){if(n!==~~n||n<e||n>i)throw Error(a+n)}function O(n,e,i,r){var t,s,o,u;for(s=n[0];s>=10;s/=10)--e;return--e<0?(e+=7,t=0):(t=Math.ceil((e+1)/7),e%=7),s=p(10,7-e),u=n[t]%s|0,null==r?e<3?(0==e?u=u/100|0:1==e&&(u=u/10|0),o=i<4&&99999==u||i>3&&49999==u||5e4==u||0==u):o=(i<4&&u+1==s||i>3&&u+1==s/2)&&(n[t+1]/s/100|0)==p(10,e-2)-1||(u==s/2||0==u)&&!(n[t+1]/s/100|0):e<4?(0==e?u=u/1e3|0:1==e?u=u/100|0:2==e&&(u=u/10|0),o=(r||i<4)&&9999==u||!r&&i>3&&4999==u):o=((r||i<4)&&u+1==s||!r&&i>3&&u+1==s/2)&&(n[t+1]/s/1e3|0)==p(10,e-3)-1,o}function F(n,e,i){for(var r,s,o=[0],u=0,c=n.length;u<c;){for(s=o.length;s--;)o[s]*=e;for(o[0]+=t.indexOf(n.charAt(u++)),r=0;r<o.length;r++)o[r]>i-1&&(void 0===o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/i|0,o[r]%=i)}return o.reverse()}y.absoluteValue=y.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),Z(n)},y.ceil=function(){return Z(new this.constructor(this),this.e+1,2)},y.clampedTo=y.clamp=function(n,e){var i=this,r=i.constructor;if(n=new r(n),e=new r(e),!n.s||!e.s)return new r(NaN);if(n.gt(e))throw Error(a+e);return i.cmp(n)<0?n:i.cmp(e)>0?e:new r(i)},y.comparedTo=y.cmp=function(n){var e,i,r,t,s=this,o=s.d,u=(n=new s.constructor(n)).d,c=s.s,f=n.s;if(!o||!u)return c&&f?c!==f?c:o===u?0:!o^c<0?1:-1:NaN;if(!o[0]||!u[0])return o[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==n.e)return s.e>n.e^c<0?1:-1;for(e=0,i=(r=o.length)<(t=u.length)?r:t;e<i;++e)if(o[e]!==u[e])return o[e]>u[e]^c<0?1:-1;return r===t?0:r>t^c<0?1:-1},y.cosine=y.cos=function(){var n,i,r=this,t=r.constructor;return r.d?r.d[0]?(n=t.precision,i=t.rounding,t.precision=n+Math.max(r.e,r.sd())+7,t.rounding=1,r=function(n,e){var i,r,t;if(e.isZero())return e;r=e.d.length,r<32?t=(1/j(4,i=Math.ceil(r/3))).toString():(i=16,t="2.3283064365386962890625e-10");n.precision+=i,e=$(n,1,e.times(t),new n(1));for(var s=i;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=i,e}(t,W(t,r)),t.precision=n,t.rounding=i,Z(2==e||3==e?r.neg():r,n,i,!0)):new t(1):new t(NaN)},y.cubeRoot=y.cbrt=function(){var n,e,i,r,t,s,o,u,f,a,h=this,d=h.constructor;if(!h.isFinite()||h.isZero())return new d(h);for(c=!1,(s=h.s*p(h.s*h,1/3))&&Math.abs(s)!=1/0?r=new d(s.toString()):(i=M(h.d),(s=((n=h.e)-i.length+1)%3)&&(i+=1==s||-2==s?"0":"00"),s=p(i,1/3),n=g((n+1)/3)-(n%3==(n<0?-1:2)),(r=new d(i=s==1/0?"5e"+n:(i=s.toExponential()).slice(0,i.indexOf("e")+1)+n)).s=h.s),o=(n=d.precision)+3;;)if(a=(f=(u=r).times(u).times(u)).plus(h),r=A(a.plus(h).times(u),a.plus(f),o+2,1),M(u.d).slice(0,o)===(i=M(r.d)).slice(0,o)){if("9999"!=(i=i.slice(o-3,o+1))&&(t||"4999"!=i)){+i&&(+i.slice(1)||"5"!=i.charAt(0))||(Z(r,n+1,1),e=!r.times(r).times(r).eq(h));break}if(!t&&(Z(u,n+1,0),u.times(u).times(u).eq(h))){r=u;break}o+=4,t=1}return c=!0,Z(r,n,d.rounding,e)},y.decimalPlaces=y.dp=function(){var n,e=this.d,i=NaN;if(e){if(i=7*((n=e.length-1)-g(this.e/7)),n=e[n])for(;n%10==0;n/=10)i--;i<0&&(i=0)}return i},y.dividedBy=y.div=function(n){return A(this,new this.constructor(n))},y.dividedToIntegerBy=y.divToInt=function(n){var e=this.constructor;return Z(A(this,new e(n),0,1,1),e.precision,e.rounding)},y.equals=y.eq=function(n){return 0===this.cmp(n)},y.floor=function(){return Z(new this.constructor(this),this.e+1,3)},y.greaterThan=y.gt=function(n){return this.cmp(n)>0},y.greaterThanOrEqualTo=y.gte=function(n){var e=this.cmp(n);return 1==e||0===e},y.hyperbolicCosine=y.cosh=function(){var n,e,i,r,t,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;i=o.precision,r=o.rounding,o.precision=i+Math.max(s.e,s.sd())+4,o.rounding=1,(t=s.d.length)<32?e=(1/j(4,n=Math.ceil(t/3))).toString():(n=16,e="2.3283064365386962890625e-10"),s=$(o,1,s.times(e),new o(1),!0);for(var c,f=n,a=new o(8);f--;)c=s.times(s),s=u.minus(c.times(a.minus(c.times(a))));return Z(s,o.precision=i,o.rounding=r,!0)},y.hyperbolicSine=y.sinh=function(){var n,e,i,r,t=this,s=t.constructor;if(!t.isFinite()||t.isZero())return new s(t);if(e=s.precision,i=s.rounding,s.precision=e+Math.max(t.e,t.sd())+4,s.rounding=1,(r=t.d.length)<3)t=$(s,2,t,t,!0);else{n=(n=1.4*Math.sqrt(r))>16?16:0|n,t=$(s,2,t=t.times(1/j(5,n)),t,!0);for(var o,u=new s(5),c=new s(16),f=new s(20);n--;)o=t.times(t),t=t.times(u.plus(o.times(c.times(o).plus(f))))}return s.precision=e,s.rounding=i,Z(t,e,i,!0)},y.hyperbolicTangent=y.tanh=function(){var n,e,i=this,r=i.constructor;return i.isFinite()?i.isZero()?new r(i):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,A(i.sinh(),i.cosh(),r.precision=n,r.rounding=e)):new r(i.s)},y.inverseCosine=y.acos=function(){var n=this,e=n.constructor,i=n.abs().cmp(1),r=e.precision,t=e.rounding;return-1!==i?0===i?n.isNeg()?R(e,r,t):new e(0):new e(NaN):n.isZero()?R(e,r+4,t).times(.5):(e.precision=r+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=r,e.rounding=t,n.times(2))},y.inverseHyperbolicCosine=y.acosh=function(){var n,e,i=this,r=i.constructor;return i.lte(1)?new r(i.eq(1)?0:NaN):i.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(i.e),i.sd())+4,r.rounding=1,c=!1,i=i.times(i).minus(1).sqrt().plus(i),c=!0,r.precision=n,r.rounding=e,i.ln()):new r(i)},y.inverseHyperbolicSine=y.asinh=function(){var n,e,i=this,r=i.constructor;return!i.isFinite()||i.isZero()?new r(i):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(i.e),i.sd())+6,r.rounding=1,c=!1,i=i.times(i).plus(1).sqrt().plus(i),c=!0,r.precision=n,r.rounding=e,i.ln())},y.inverseHyperbolicTangent=y.atanh=function(){var n,e,i,r,t=this,s=t.constructor;return t.isFinite()?t.e>=0?new s(t.abs().eq(1)?t.s/0:t.isZero()?t:NaN):(n=s.precision,e=s.rounding,r=t.sd(),Math.max(r,n)<2*-t.e-1?Z(new s(t),n,e,!0):(s.precision=i=r-t.e,t=A(t.plus(1),new s(1).minus(t),i+n,1),s.precision=n+4,s.rounding=1,t=t.ln(),s.precision=n,s.rounding=e,t.times(.5))):new s(NaN)},y.inverseSine=y.asin=function(){var n,e,i,r,t=this,s=t.constructor;return t.isZero()?new s(t):(e=t.abs().cmp(1),i=s.precision,r=s.rounding,-1!==e?0===e?((n=R(s,i+4,r).times(.5)).s=t.s,n):new s(NaN):(s.precision=i+6,s.rounding=1,t=t.div(new s(1).minus(t.times(t)).sqrt().plus(1)).atan(),s.precision=i,s.rounding=r,t.times(2)))},y.inverseTangent=y.atan=function(){var n,e,i,r,t,s,o,u,f,a=this,h=a.constructor,d=h.precision,l=h.rounding;if(a.isFinite()){if(a.isZero())return new h(a);if(a.abs().eq(1)&&d+4<=x)return(o=R(h,d+4,l).times(.25)).s=a.s,o}else{if(!a.s)return new h(NaN);if(d+4<=x)return(o=R(h,d+4,l).times(.5)).s=a.s,o}for(h.precision=u=d+10,h.rounding=1,n=i=Math.min(28,u/7+2|0);n;--n)a=a.div(a.times(a).plus(1).sqrt().plus(1));for(c=!1,e=Math.ceil(u/7),r=1,f=a.times(a),o=new h(a),t=a;-1!==n;)if(t=t.times(f),s=o.minus(t.div(r+=2)),t=t.times(f),void 0!==(o=s.plus(t.div(r+=2))).d[e])for(n=e;o.d[n]===s.d[n]&&n--;);return i&&(o=o.times(2<<i-1)),c=!0,Z(o,h.precision=d,h.rounding=l,!0)},y.isFinite=function(){return!!this.d},y.isInteger=y.isInt=function(){return!!this.d&&g(this.e/7)>this.d.length-2},y.isNaN=function(){return!this.s},y.isNegative=y.isNeg=function(){return this.s<0},y.isPositive=y.isPos=function(){return this.s>0},y.isZero=function(){return!!this.d&&0===this.d[0]},y.lessThan=y.lt=function(n){return this.cmp(n)<0},y.lessThanOrEqualTo=y.lte=function(n){return this.cmp(n)<1},y.logarithm=y.log=function(n){var e,i,r,t,s,o,u,f,a=this,h=a.constructor,d=h.precision,l=h.rounding;if(null==n)n=new h(10),e=!0;else{if(i=(n=new h(n)).d,n.s<0||!i||!i[0]||n.eq(1))return new h(NaN);e=n.eq(10)}if(i=a.d,a.s<0||!i||!i[0]||a.eq(1))return new h(i&&!i[0]?-1/0:1!=a.s?NaN:i?0:1/0);if(e)if(i.length>1)s=!0;else{for(t=i[0];t%10==0;)t/=10;s=1!==t}if(c=!1,o=C(a,u=d+5),r=e?P(h,u+10):C(n,u),O((f=A(o,r,u,1)).d,t=d,l))do{if(o=C(a,u+=10),r=e?P(h,u+10):C(n,u),f=A(o,r,u,1),!s){+M(f.d).slice(t+1,t+15)+1==1e14&&(f=Z(f,d+1,0));break}}while(O(f.d,t+=10,l));return c=!0,Z(f,d,l)},y.minus=y.sub=function(n){var e,i,r,t,s,o,u,f,a,h,d,l,p=this,w=p.constructor;if(n=new w(n),!p.d||!n.d)return p.s&&n.s?p.d?n.s=-n.s:n=new w(n.d||p.s!==n.s?p:NaN):n=new w(NaN),n;if(p.s!=n.s)return n.s=-n.s,p.plus(n);if(a=p.d,l=n.d,u=w.precision,f=w.rounding,!a[0]||!l[0]){if(l[0])n.s=-n.s;else{if(!a[0])return new w(3===f?-0:0);n=new w(p)}return c?Z(n,u,f):n}if(i=g(n.e/7),h=g(p.e/7),a=a.slice(),s=h-i){for((d=s<0)?(e=a,s=-s,o=l.length):(e=l,i=h,o=a.length),s>(r=Math.max(Math.ceil(u/7),o)+2)&&(s=r,e.length=1),e.reverse(),r=s;r--;)e.push(0);e.reverse()}else{for((d=(r=a.length)<(o=l.length))&&(o=r),r=0;r<o;r++)if(a[r]!=l[r]){d=a[r]<l[r];break}s=0}for(d&&(e=a,a=l,l=e,n.s=-n.s),o=a.length,r=l.length-o;r>0;--r)a[o++]=0;for(r=l.length;r>s;){if(a[--r]<l[r]){for(t=r;t&&0===a[--t];)a[t]=b-1;--a[t],a[r]+=b}a[r]-=l[r]}for(;0===a[--o];)a.pop();for(;0===a[0];a.shift())--i;return a[0]?(n.d=a,n.e=S(a,i),c?Z(n,u,f):n):new w(3===f?-0:0)},y.modulo=y.mod=function(n){var e,i=this,r=i.constructor;return n=new r(n),!i.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||i.d&&!i.d[0]?Z(new r(i),r.precision,r.rounding):(c=!1,9==r.modulo?(e=A(i,n.abs(),0,3,1)).s*=n.s:e=A(i,n,0,r.modulo,1),e=e.times(n),c=!0,i.minus(e))},y.naturalExponential=y.exp=function(){return I(this)},y.naturalLogarithm=y.ln=function(){return C(this)},y.negated=y.neg=function(){var n=new this.constructor(this);return n.s=-n.s,Z(n)},y.plus=y.add=function(n){var e,i,r,t,s,o,u,f,a,h,d=this,l=d.constructor;if(n=new l(n),!d.d||!n.d)return d.s&&n.s?d.d||(n=new l(n.d||d.s===n.s?d:NaN)):n=new l(NaN),n;if(d.s!=n.s)return n.s=-n.s,d.minus(n);if(a=d.d,h=n.d,u=l.precision,f=l.rounding,!a[0]||!h[0])return h[0]||(n=new l(d)),c?Z(n,u,f):n;if(s=g(d.e/7),r=g(n.e/7),a=a.slice(),t=s-r){for(t<0?(i=a,t=-t,o=h.length):(i=h,r=s,o=a.length),t>(o=(s=Math.ceil(u/7))>o?s+1:o+1)&&(t=o,i.length=1),i.reverse();t--;)i.push(0);i.reverse()}for((o=a.length)-(t=h.length)<0&&(t=o,i=h,h=a,a=i),e=0;t;)e=(a[--t]=a[t]+h[t]+e)/b|0,a[t]%=b;for(e&&(a.unshift(e),++r),o=a.length;0==a[--o];)a.pop();return n.d=a,n.e=S(a,r),c?Z(n,u,f):n},y.precision=y.sd=function(n){var e,i=this;if(void 0!==n&&n!==!!n&&1!==n&&0!==n)throw Error(a+n);return i.d?(e=T(i.d),n&&i.e+1>e&&(e=i.e+1)):e=NaN,e},y.round=function(){var n=this,e=n.constructor;return Z(new e(n),n.e+1,e.rounding)},y.sine=y.sin=function(){var n,i,r=this,t=r.constructor;return r.isFinite()?r.isZero()?new t(r):(n=t.precision,i=t.rounding,t.precision=n+Math.max(r.e,r.sd())+7,t.rounding=1,r=function(n,e){var i,r=e.d.length;if(r<3)return e.isZero()?e:$(n,2,e,e);i=(i=1.4*Math.sqrt(r))>16?16:0|i,e=e.times(1/j(5,i)),e=$(n,2,e,e);for(var t,s=new n(5),o=new n(16),u=new n(20);i--;)t=e.times(e),e=e.times(s.plus(t.times(o.times(t).minus(u))));return e}(t,W(t,r)),t.precision=n,t.rounding=i,Z(e>2?r.neg():r,n,i,!0)):new t(NaN)},y.squareRoot=y.sqrt=function(){var n,e,i,r,t,s,o=this,u=o.d,f=o.e,a=o.s,h=o.constructor;if(1!==a||!u||!u[0])return new h(!a||a<0&&(!u||u[0])?NaN:u?o:1/0);for(c=!1,0==(a=Math.sqrt(+o))||a==1/0?(((e=M(u)).length+f)%2==0&&(e+="0"),a=Math.sqrt(e),f=g((f+1)/2)-(f<0||f%2),r=new h(e=a==1/0?"5e"+f:(e=a.toExponential()).slice(0,e.indexOf("e")+1)+f)):r=new h(a.toString()),i=(f=h.precision)+3;;)if(r=(s=r).plus(A(o,s,i+2,1)).times(.5),M(s.d).slice(0,i)===(e=M(r.d)).slice(0,i)){if("9999"!=(e=e.slice(i-3,i+1))&&(t||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(Z(r,f+1,1),n=!r.times(r).eq(o));break}if(!t&&(Z(s,f+1,0),s.times(s).eq(o))){r=s;break}i+=4,t=1}return c=!0,Z(r,f,h.rounding,n)},y.tangent=y.tan=function(){var n,i,r=this,t=r.constructor;return r.isFinite()?r.isZero()?new t(r):(n=t.precision,i=t.rounding,t.precision=n+10,t.rounding=1,(r=r.sin()).s=1,r=A(r,new t(1).minus(r.times(r)).sqrt(),n+10,0),t.precision=n,t.rounding=i,Z(2==e||4==e?r.neg():r,n,i,!0)):new t(NaN)},y.times=y.mul=function(n){var e,i,r,t,s,o,u,f,a,h=this,d=h.constructor,l=h.d,p=(n=new d(n)).d;if(n.s*=h.s,!(l&&l[0]&&p&&p[0]))return new d(!n.s||l&&!l[0]&&!p||p&&!p[0]&&!l?NaN:l&&p?0*n.s:n.s/0);for(i=g(h.e/7)+g(n.e/7),(f=l.length)<(a=p.length)&&(s=l,l=p,p=s,o=f,f=a,a=o),s=[],r=o=f+a;r--;)s.push(0);for(r=a;--r>=0;){for(e=0,t=f+r;t>r;)u=s[t]+p[r]*l[t-r-1]+e,s[t--]=u%b|0,e=u/b|0;s[t]=(s[t]+e)%b|0}for(;!s[--o];)s.pop();return e?++i:s.shift(),n.d=s,n.e=S(s,i),c?Z(n,d.precision,d.rounding):n},y.toBinary=function(n,e){return J(this,2,n,e)},y.toDecimalPlaces=y.toDP=function(n,e){var i=this,t=i.constructor;return i=new t(i),void 0===n?i:(q(n,0,r),void 0===e?e=t.rounding:q(e,0,8),Z(i,n+i.e+1,e))},y.toExponential=function(n,e){var i,t=this,s=t.constructor;return void 0===n?i=D(t,!0):(q(n,0,r),void 0===e?e=s.rounding:q(e,0,8),i=D(t=Z(new s(t),n+1,e),!0,n+1)),t.isNeg()&&!t.isZero()?"-"+i:i},y.toFixed=function(n,e){var i,t,s=this,o=s.constructor;return void 0===n?i=D(s):(q(n,0,r),void 0===e?e=o.rounding:q(e,0,8),i=D(t=Z(new o(s),n+s.e+1,e),!1,n+t.e+1)),s.isNeg()&&!s.isZero()?"-"+i:i},y.toFraction=function(n){var e,i,r,t,s,o,u,f,h,d,l,g,w=this,m=w.d,v=w.constructor;if(!m)return new v(w);if(h=i=new v(1),r=f=new v(0),o=(s=(e=new v(r)).e=T(m)-w.e-1)%7,e.d[0]=p(10,o<0?7+o:o),null==n)n=s>0?e:h;else{if(!(u=new v(n)).isInt()||u.lt(h))throw Error(a+u);n=u.gt(e)?s>0?e:h:u}for(c=!1,u=new v(M(m)),d=v.precision,v.precision=s=7*m.length*2;l=A(u,e,0,1,1),1!=(t=i.plus(l.times(r))).cmp(n);)i=r,r=t,t=h,h=f.plus(l.times(t)),f=t,t=e,e=u.minus(l.times(t)),u=t;return t=A(n.minus(i),r,0,1,1),f=f.plus(t.times(h)),i=i.plus(t.times(r)),f.s=h.s=w.s,g=A(h,r,s,1).minus(w).abs().cmp(A(f,i,s,1).minus(w).abs())<1?[h,r]:[f,i],v.precision=d,c=!0,g},y.toHexadecimal=y.toHex=function(n,e){return J(this,16,n,e)},y.toNearest=function(n,e){var i=this,r=i.constructor;if(i=new r(i),null==n){if(!i.d)return i;n=new r(1),e=r.rounding}else{if(n=new r(n),void 0===e?e=r.rounding:q(e,0,8),!i.d)return n.s?i:n;if(!n.d)return n.s&&(n.s=i.s),n}return n.d[0]?(c=!1,i=A(i,n,0,e,1).times(n),c=!0,Z(i)):(n.s=i.s,i=n),i},y.toNumber=function(){return+this},y.toOctal=function(n,e){return J(this,8,n,e)},y.toPower=y.pow=function(n){var e,i,r,t,s,o,u=this,f=u.constructor,a=+(n=new f(n));if(!(u.d&&n.d&&u.d[0]&&n.d[0]))return new f(p(+u,a));if((u=new f(u)).eq(1))return u;if(r=f.precision,s=f.rounding,n.eq(1))return Z(u,r,s);if((e=g(n.e/7))>=n.d.length-1&&(i=a<0?-a:a)<=9007199254740991)return t=L(f,u,i,r),n.s<0?new f(1).div(t):Z(t,r,s);if((o=u.s)<0){if(e<n.d.length-1)return new f(NaN);if(1&n.d[e]||(o=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=o,u}return(e=0!=(i=p(+u,a))&&isFinite(i)?new f(i+"").e:g(a*(Math.log("0."+M(u.d))/Math.LN10+u.e+1)))>f.maxE+1||e<f.minE-1?new f(e>0?o/0:0):(c=!1,f.rounding=u.s=1,i=Math.min(12,(e+"").length),(t=I(n.times(C(u,r+i)),r)).d&&O((t=Z(t,r+5,1)).d,r,s)&&(e=r+10,+M((t=Z(I(n.times(C(u,e+i)),e),e+5,1)).d).slice(r+1,r+15)+1==1e14&&(t=Z(t,r+1,0))),t.s=o,c=!0,f.rounding=s,Z(t,r,s))},y.toPrecision=function(n,e){var i,t=this,s=t.constructor;return void 0===n?i=D(t,t.e<=s.toExpNeg||t.e>=s.toExpPos):(q(n,1,r),void 0===e?e=s.rounding:q(e,0,8),i=D(t=Z(new s(t),n,e),n<=t.e||t.e<=s.toExpNeg,n)),t.isNeg()&&!t.isZero()?"-"+i:i},y.toSignificantDigits=y.toSD=function(n,e){var i=this.constructor;return void 0===n?(n=i.precision,e=i.rounding):(q(n,1,r),void 0===e?e=i.rounding:q(e,0,8)),Z(new i(this),n,e)},y.toString=function(){var n=this,e=n.constructor,i=D(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+i:i},y.truncated=y.trunc=function(){return Z(new this.constructor(this),this.e+1,1)},y.valueOf=y.toJSON=function(){var n=this,e=n.constructor,i=D(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+i:i};var A=function(){function e(n,e,i){var r,t=0,s=n.length;for(n=n.slice();s--;)r=n[s]*e+t,n[s]=r%i|0,t=r/i|0;return t&&n.unshift(t),n}function i(n,e,i,r){var t,s;if(i!=r)s=i>r?1:-1;else for(t=s=0;t<i;t++)if(n[t]!=e[t]){s=n[t]>e[t]?1:-1;break}return s}function r(n,e,i,r){for(var t=0;i--;)n[i]-=t,t=n[i]<e[i]?1:0,n[i]=t*r+n[i]-e[i];for(;!n[0]&&n.length>1;)n.shift()}return function(t,s,o,u,c,f){var a,h,d,l,p,w,m,v,N,E,x,y,M,q,O,F,A,D,S,P,R=t.constructor,T=t.s==s.s?1:-1,_=t.d,L=s.d;if(!(_&&_[0]&&L&&L[0]))return new R(t.s&&s.s&&(_?!L||_[0]!=L[0]:L)?_&&0==_[0]||!L?0*T:T/0:NaN);for(f?(p=1,h=t.e-s.e):(f=b,p=7,h=g(t.e/p)-g(s.e/p)),S=L.length,A=_.length,E=(N=new R(T)).d=[],d=0;L[d]==(_[d]||0);d++);if(L[d]>(_[d]||0)&&h--,null==o?(q=o=R.precision,u=R.rounding):q=c?o+(t.e-s.e)+1:o,q<0)E.push(1),w=!0;else{if(q=q/p+2|0,d=0,1==S){for(l=0,L=L[0],q++;(d<A||l)&&q--;d++)O=l*f+(_[d]||0),E[d]=O/L|0,l=O%L|0;w=l||d<A}else{for((l=f/(L[0]+1)|0)>1&&(L=e(L,l,f),_=e(_,l,f),S=L.length,A=_.length),F=S,y=(x=_.slice(0,S)).length;y<S;)x[y++]=0;(P=L.slice()).unshift(0),D=L[0],L[1]>=f/2&&++D;do{l=0,(a=i(L,x,S,y))<0?(M=x[0],S!=y&&(M=M*f+(x[1]||0)),(l=M/D|0)>1?(l>=f&&(l=f-1),1==(a=i(m=e(L,l,f),x,v=m.length,y=x.length))&&(l--,r(m,S<v?P:L,v,f))):(0==l&&(a=l=1),m=L.slice()),(v=m.length)<y&&m.unshift(0),r(x,m,y,f),-1==a&&(a=i(L,x,S,y=x.length))<1&&(l++,r(x,S<y?P:L,y,f)),y=x.length):0===a&&(l++,x=[0]),E[d++]=l,a&&x[0]?x[y++]=_[F]||0:(x=[_[F]],y=1)}while((F++<A||void 0!==x[0])&&q--);w=void 0!==x[0]}E[0]||E.shift()}if(1==p)N.e=h,n=w;else{for(d=1,l=E[0];l>=10;l/=10)d++;N.e=d+h*p-1,Z(N,c?o+N.e+1:o,u,w)}return N}}();function Z(n,e,i,r){var t,s,o,u,f,a,h,d,l,g=n.constructor;n:if(null!=e){if(!(d=n.d))return n;for(t=1,u=d[0];u>=10;u/=10)t++;if((s=e-t)<0)s+=7,o=e,f=(h=d[l=0])/p(10,t-o-1)%10|0;else if((l=Math.ceil((s+1)/7))>=(u=d.length)){if(!r)break n;for(;u++<=l;)d.push(0);h=f=0,t=1,o=(s%=7)-7+1}else{for(h=u=d[l],t=1;u>=10;u/=10)t++;f=(o=(s%=7)-7+t)<0?0:h/p(10,t-o-1)%10|0}if(r=r||e<0||void 0!==d[l+1]||(o<0?h:h%p(10,t-o-1)),a=i<4?(f||r)&&(0==i||i==(n.s<0?3:2)):f>5||5==f&&(4==i||r||6==i&&(s>0?o>0?h/p(10,t-o):0:d[l-1])%10&1||i==(n.s<0?8:7)),e<1||!d[0])return d.length=0,a?(e-=n.e+1,d[0]=p(10,(7-e%7)%7),n.e=-e||0):d[0]=n.e=0,n;if(0==s?(d.length=l,u=1,l--):(d.length=l+1,u=p(10,7-s),d[l]=o>0?(h/p(10,t-o)%p(10,o)|0)*u:0),a)for(;;){if(0==l){for(s=1,o=d[0];o>=10;o/=10)s++;for(o=d[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(n.e++,d[0]==b&&(d[0]=1));break}if(d[l]+=u,d[l]!=b)break;d[l--]=0,u=1}for(s=d.length;0===d[--s];)d.pop()}return c&&(n.e>g.maxE?(n.d=null,n.e=NaN):n.e<g.minE&&(n.e=0,n.d=[0])),n}function D(n,e,i){if(!n.isFinite())return H(n);var r,t=n.e,s=M(n.d),o=s.length;return e?(i&&(r=i-o)>0?s=s.charAt(0)+"."+s.slice(1)+_(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):t<0?(s="0."+_(-t-1)+s,i&&(r=i-o)>0&&(s+=_(r))):t>=o?(s+=_(t+1-o),i&&(r=i-t-1)>0&&(s=s+"."+_(r))):((r=t+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),i&&(r=i-o)>0&&(t+1===o&&(s+="."),s+=_(r))),s}function S(n,e){var i=n[0];for(e*=7;i>=10;i/=10)e++;return e}function P(n,e,i){if(e>E)throw c=!0,i&&(n.precision=i),Error(h);return Z(new n(s),e,1,!0)}function R(n,e,i){if(e>x)throw Error(h);return Z(new n(o),e,i,!0)}function T(n){var e=n.length-1,i=7*e+1;if(e=n[e]){for(;e%10==0;e/=10)i--;for(e=n[0];e>=10;e/=10)i++}return i}function _(n){for(var e="";n--;)e+="0";return e}function L(n,e,i,r){var t,s=new n(1),o=Math.ceil(r/7+4);for(c=!1;;){if(i%2&&z((s=s.times(e)).d,o)&&(t=!0),0===(i=g(i/2))){i=s.d.length-1,t&&0===s.d[i]&&++s.d[i];break}z((e=e.times(e)).d,o)}return c=!0,s}function U(n){return 1&n.d[n.d.length-1]}function k(n,e,i){for(var r,t,s=new n(e[0]),o=0;++o<e.length;){if(!(t=new n(e[o])).s){s=t;break}((r=s.cmp(t))===i||0===r&&s.s===i)&&(s=t)}return s}function I(n,e){var i,r,t,s,o,u,f,a=0,h=0,d=0,l=n.constructor,g=l.rounding,w=l.precision;if(!n.d||!n.d[0]||n.e>17)return new l(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(null==e?(c=!1,f=w):f=e,u=new l(.03125);n.e>-2;)n=n.times(u),d+=5;for(f+=r=Math.log(p(2,d))/Math.LN10*2+5|0,i=s=o=new l(1),l.precision=f;;){if(s=Z(s.times(n),f,1),i=i.times(++h),M((u=o.plus(A(s,i,f,1))).d).slice(0,f)===M(o.d).slice(0,f)){for(t=d;t--;)o=Z(o.times(o),f,1);if(null!=e)return l.precision=w,o;if(!(a<3&&O(o.d,f-r,g,a)))return Z(o,l.precision=w,g,c=!0);l.precision=f+=10,i=s=u=new l(1),h=0,a++}o=u}}function C(n,e){var i,r,t,s,o,u,f,a,h,d,l,g=1,p=n,w=p.d,m=p.constructor,v=m.rounding,N=m.precision;if(p.s<0||!w||!w[0]||!p.e&&1==w[0]&&1==w.length)return new m(w&&!w[0]?-1/0:1!=p.s?NaN:w?0:p);if(null==e?(c=!1,h=N):h=e,m.precision=h+=10,r=(i=M(w)).charAt(0),!(Math.abs(s=p.e)<15e14))return a=P(m,h+2,N).times(s+""),p=C(new m(r+"."+i.slice(1)),h-10).plus(a),m.precision=N,null==e?Z(p,N,v,c=!0):p;for(;r<7&&1!=r||1==r&&i.charAt(1)>3;)r=(i=M((p=p.times(n)).d)).charAt(0),g++;for(s=p.e,r>1?(p=new m("0."+i),s++):p=new m(r+"."+i.slice(1)),d=p,f=o=p=A(p.minus(1),p.plus(1),h,1),l=Z(p.times(p),h,1),t=3;;){if(o=Z(o.times(l),h,1),M((a=f.plus(A(o,new m(t),h,1))).d).slice(0,h)===M(f.d).slice(0,h)){if(f=f.times(2),0!==s&&(f=f.plus(P(m,h+2,N).times(s+""))),f=A(f,new m(g),h,1),null!=e)return m.precision=N,f;if(!O(f.d,h-10,v,u))return Z(f,m.precision=N,v,c=!0);m.precision=h+=10,a=o=p=A(d.minus(1),d.plus(1),h,1),l=Z(p.times(p),h,1),t=u=1}f=a,t+=2}}function H(n){return String(n.s*n.s/0)}function B(n,e){var i,r,t;for((i=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(i<0&&(i=r),i+=+e.slice(r+1),e=e.substring(0,r)):i<0&&(i=e.length),r=0;48===e.charCodeAt(r);r++);for(t=e.length;48===e.charCodeAt(t-1);--t);if(e=e.slice(r,t)){if(t-=r,n.e=i=i-r-1,n.d=[],r=(i+1)%7,i<0&&(r+=7),r<t){for(r&&n.d.push(+e.slice(0,r)),t-=7;r<t;)n.d.push(+e.slice(r,r+=7));r=7-(e=e.slice(r)).length}else r-=t;for(;r--;)e+="0";n.d.push(+e),c&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function V(n,e){var i,r,t,s,o,u,f,h,d;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),N.test(e))return B(n,e)}else if("Infinity"===e||"NaN"===e)return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(m.test(e))i=16,e=e.toLowerCase();else if(w.test(e))i=2;else{if(!v.test(e))throw Error(a+e);i=8}for((s=e.search(/p/i))>0?(f=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),o=(s=e.indexOf("."))>=0,r=n.constructor,o&&(s=(u=(e=e.replace(".","")).length)-s,t=L(r,new r(i),s,2*s)),s=d=(h=F(e,i,b)).length-1;0===h[s];--s)h.pop();return s<0?new r(0*n.s):(n.e=S(h,d),n.d=h,c=!1,o&&(n=A(n,t,4*u)),f&&(n=n.times(Math.abs(f)<54?p(2,f):Ln.pow(2,f))),c=!0,n)}function $(n,e,i,r,t){var s,o,u,f,a=n.precision,h=Math.ceil(a/7);for(c=!1,f=i.times(i),u=new n(r);;){if(o=A(u.times(f),new n(e++*e++),a,1),u=t?r.plus(o):r.minus(o),r=A(o.times(f),new n(e++*e++),a,1),void 0!==(o=u.plus(r)).d[h]){for(s=h;o.d[s]===u.d[s]&&s--;);if(-1==s)break}s=u,u=r,r=o,o=s}return c=!0,o.d.length=h+1,o}function j(n,e){for(var i=n;--e;)i*=n;return i}function W(n,i){var r,t=i.s<0,s=R(n,n.precision,1),o=s.times(.5);if((i=i.abs()).lte(o))return e=t?4:1,i;if((r=i.divToInt(s)).isZero())e=t?3:2;else{if((i=i.minus(r.times(s))).lte(o))return e=U(r)?t?2:3:t?4:1,i;e=U(r)?t?1:4:t?3:2}return i.minus(s).abs()}function J(e,i,s,o){var u,c,f,a,h,d,l,g,p,w=e.constructor,m=void 0!==s;if(m?(q(s,1,r),void 0===o?o=w.rounding:q(o,0,8)):(s=w.precision,o=w.rounding),e.isFinite()){for(m?(u=2,16==i?s=4*s-3:8==i&&(s=3*s-2)):u=i,(f=(l=D(e)).indexOf("."))>=0&&(l=l.replace(".",""),(p=new w(1)).e=l.length-f,p.d=F(D(p),10,u),p.e=p.d.length),c=h=(g=F(l,10,u)).length;0==g[--h];)g.pop();if(g[0]){if(f<0?c--:((e=new w(e)).d=g,e.e=c,g=(e=A(e,p,s,o,0,u)).d,c=e.e,d=n),f=g[s],a=u/2,d=d||void 0!==g[s+1],d=o<4?(void 0!==f||d)&&(0===o||o===(e.s<0?3:2)):f>a||f===a&&(4===o||d||6===o&&1&g[s-1]||o===(e.s<0?8:7)),g.length=s,d)for(;++g[--s]>u-1;)g[s]=0,s||(++c,g.unshift(1));for(h=g.length;!g[h-1];--h);for(f=0,l="";f<h;f++)l+=t.charAt(g[f]);if(m){if(h>1)if(16==i||8==i){for(f=16==i?4:3,--h;h%f;h++)l+="0";for(h=(g=F(l,u,i)).length;!g[h-1];--h);for(f=1,l="1.";f<h;f++)l+=t.charAt(g[f])}else l=l.charAt(0)+"."+l.slice(1);l=l+(c<0?"p":"p+")+c}else if(c<0){for(;++c;)l="0"+l;l="0."+l}else if(++c>h)for(c-=h;c--;)l+="0";else c<h&&(l=l.slice(0,c)+"."+l.slice(c))}else l=m?"0p+0":"0";l=(16==i?"0x":2==i?"0b":8==i?"0o":"")+l}else l=H(e);return e.s<0?"-"+l:l}function z(n,e){if(n.length>e)return n.length=e,!0}function G(n){return new this(n).abs()}function K(n){return new this(n).acos()}function Q(n){return new this(n).acosh()}function X(n,e){return new this(n).plus(e)}function Y(n){return new this(n).asin()}function nn(n){return new this(n).asinh()}function en(n){return new this(n).atan()}function rn(n){return new this(n).atanh()}function tn(n,e){n=new this(n),e=new this(e);var i,r=this.precision,t=this.rounding,s=r+4;return n.s&&e.s?n.d||e.d?!e.d||n.isZero()?(i=e.s<0?R(this,r,t):new this(0)).s=n.s:!n.d||e.isZero()?(i=R(this,s,1).times(.5)).s=n.s:e.s<0?(this.precision=s,this.rounding=1,i=this.atan(A(n,e,s,1)),e=R(this,s,1),this.precision=r,this.rounding=t,i=n.s<0?i.minus(e):i.plus(e)):i=this.atan(A(n,e,s,1)):(i=R(this,s,1).times(e.s>0?.25:.75)).s=n.s:i=new this(NaN),i}function sn(n){return new this(n).cbrt()}function on(n){return Z(n=new this(n),n.e+1,2)}function un(n,e,i){return new this(n).clamp(e,i)}function cn(n){if(!n||"object"!=typeof n)throw Error(f+"Object expected");var e,t,s,o=!0===n.defaults,c=["precision",1,r,"rounding",0,8,"toExpNeg",-i,0,"toExpPos",0,i,"maxE",0,i,"minE",-i,0,"modulo",0,9];for(e=0;e<c.length;e+=3)if(t=c[e],o&&(this[t]=u[t]),void 0!==(s=n[t])){if(!(g(s)===s&&s>=c[e+1]&&s<=c[e+2]))throw Error(a+t+": "+s);this[t]=s}if(t="crypto",o&&(this[t]=u[t]),void 0!==(s=n[t])){if(!0!==s&&!1!==s&&0!==s&&1!==s)throw Error(a+t+": "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[t]=!0}else this[t]=!1}return this}function fn(n){return new this(n).cos()}function an(n){return new this(n).cosh()}function hn(n,e){return new this(n).div(e)}function dn(n){return new this(n).exp()}function ln(n){return Z(n=new this(n),n.e+1,3)}function gn(){var n,e,i=new this(0);for(c=!1,n=0;n<arguments.length;)if((e=new this(arguments[n++])).d)i.d&&(i=i.plus(e.times(e)));else{if(e.s)return c=!0,new this(1/0);i=e}return c=!0,i.sqrt()}function pn(n){return n instanceof Ln||n&&n.toStringTag===l||!1}function wn(n){return new this(n).ln()}function mn(n,e){return new this(n).log(e)}function vn(n){return new this(n).log(2)}function Nn(n){return new this(n).log(10)}function bn(){return k(this,arguments,-1)}function En(){return k(this,arguments,1)}function xn(n,e){return new this(n).mod(e)}function yn(n,e){return new this(n).mul(e)}function Mn(n,e){return new this(n).pow(e)}function qn(n){var e,i,t,s,o=0,u=new this(1),c=[];if(void 0===n?n=this.precision:q(n,1,r),t=Math.ceil(n/7),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(t));o<t;)(s=e[o])>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:c[o++]=s%1e7;else{if(!crypto.randomBytes)throw Error(d);for(e=crypto.randomBytes(t*=4);o<t;)(s=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((127&e[o+3])<<24))>=214e7?crypto.randomBytes(4).copy(e,o):(c.push(s%1e7),o+=4);o=t/4}else for(;o<t;)c[o++]=1e7*Math.random()|0;for(n%=7,(t=c[--o])&&n&&(s=p(10,7-n),c[o]=(t/s|0)*s);0===c[o];o--)c.pop();if(o<0)i=0,c=[0];else{for(i=-1;0===c[0];i-=7)c.shift();for(t=1,s=c[0];s>=10;s/=10)t++;t<7&&(i-=7-t)}return u.e=i,u.d=c,u}function On(n){return Z(n=new this(n),n.e+1,this.rounding)}function Fn(n){return(n=new this(n)).d?n.d[0]?n.s:0*n.s:n.s||NaN}function An(n){return new this(n).sin()}function Zn(n){return new this(n).sinh()}function Dn(n){return new this(n).sqrt()}function Sn(n,e){return new this(n).sub(e)}function Pn(){var n=0,e=arguments,i=new this(e[n]);for(c=!1;i.s&&++n<e.length;)i=i.plus(e[n]);return c=!0,Z(i,this.precision,this.rounding)}function Rn(n){return new this(n).tan()}function Tn(n){return new this(n).tanh()}function _n(n){return Z(n=new this(n),n.e+1,1)}y[Symbol.for("nodejs.util.inspect.custom")]=y.toString,y[Symbol.toStringTag]="Decimal";var Ln=y.constructor=function n(e){var i,r,t;function s(n){var e,i,r,t=this;if(!(t instanceof s))return new s(n);if(t.constructor=s,pn(n))return t.s=n.s,void(c?!n.d||n.e>s.maxE?(t.e=NaN,t.d=null):n.e<s.minE?(t.e=0,t.d=[0]):(t.e=n.e,t.d=n.d.slice()):(t.e=n.e,t.d=n.d?n.d.slice():n.d));if("number"===(r=typeof n)){if(0===n)return t.s=1/n<0?-1:1,t.e=0,void(t.d=[0]);if(n<0?(n=-n,t.s=-1):t.s=1,n===~~n&&n<1e7){for(e=0,i=n;i>=10;i/=10)e++;return void(c?e>s.maxE?(t.e=NaN,t.d=null):e<s.minE?(t.e=0,t.d=[0]):(t.e=e,t.d=[n]):(t.e=e,t.d=[n]))}return 0*n!=0?(n||(t.s=NaN),t.e=NaN,void(t.d=null)):B(t,n.toString())}if("string"===r)return 45===(i=n.charCodeAt(0))?(n=n.slice(1),t.s=-1):(43===i&&(n=n.slice(1)),t.s=1),N.test(n)?B(t,n):V(t,n);if("bigint"===r)return n<0?(n=-n,t.s=-1):t.s=1,B(t,n.toString());throw Error(a+n)}if(s.prototype=y,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=cn,s.clone=n,s.isDecimal=pn,s.abs=G,s.acos=K,s.acosh=Q,s.add=X,s.asin=Y,s.asinh=nn,s.atan=en,s.atanh=rn,s.atan2=tn,s.cbrt=sn,s.ceil=on,s.clamp=un,s.cos=fn,s.cosh=an,s.div=hn,s.exp=dn,s.floor=ln,s.hypot=gn,s.ln=wn,s.log=mn,s.log10=Nn,s.log2=vn,s.max=bn,s.min=En,s.mod=xn,s.mul=yn,s.pow=Mn,s.random=qn,s.round=On,s.sign=Fn,s.sin=An,s.sinh=Zn,s.sqrt=Dn,s.sub=Sn,s.sum=Pn,s.tan=Rn,s.tanh=Tn,s.trunc=_n,void 0===e&&(e={}),e&&!0!==e.defaults)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],i=0;i<t.length;)e.hasOwnProperty(r=t[i++])||(e[r]=this[r]);return s.config(e),s}(u);s=new Ln(s),o=new Ln(o);export{Ln as Decimal,Ln as default};
9
+ //# sourceMappingURL=decimal.mjs.map
@@ -0,0 +1,2 @@
1
+ function e(e,t,r,o){var f,c=arguments.length,n=c<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,o);else for(var p=e.length-1;p>=0;p--)(f=e[p])&&(n=(c<3?f(n):c>3?f(t,r,n):f(t,r))||n);return c>3&&n&&Object.defineProperty(t,r,n),n}function t(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;export{e as __decorate,t as __metadata};
2
+ //# sourceMappingURL=tslib.es6.mjs.map
@@ -0,0 +1,2 @@
1
+ import{__decorate as r,__metadata as s}from"../node_modules/tslib/tslib.es6.mjs";import{Injectable as a}from"@nestjs/common";import*as o from"argon2";let t=class{constructor(){}async hashPassword(r){try{return await o.hash(r,{type:o.argon2id,hashLength:32,timeCost:3,memoryCost:65536,parallelism:1})}catch(r){throw new Error(`Password hashing failed: ${r instanceof Error?r.message:String(r)}`)}}async verifyPassword(r,s){try{return await o.verify(s,r)}catch(r){throw new Error(`Password verification failed: ${r.message}`)}}};t=r([a(),s("design:paramtypes",[])],t);export{t as Argon2Service};
2
+ //# sourceMappingURL=argon2.service.mjs.map