@hotmeshio/hotmesh 0.3.18 → 0.3.20

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 (101) hide show
  1. package/README.md +194 -68
  2. package/build/index.d.ts +5 -1
  3. package/build/index.js +9 -1
  4. package/build/modules/key.js +1 -1
  5. package/build/modules/utils.d.ts +0 -1
  6. package/build/modules/utils.js +1 -1
  7. package/build/package.json +10 -7
  8. package/build/services/activities/activity.js +1 -1
  9. package/build/services/activities/await.js +1 -1
  10. package/build/services/activities/cycle.js +1 -1
  11. package/build/services/activities/hook.js +1 -1
  12. package/build/services/activities/index.js +1 -1
  13. package/build/services/activities/interrupt.js +1 -1
  14. package/build/services/activities/signal.js +1 -1
  15. package/build/services/activities/trigger.js +1 -1
  16. package/build/services/activities/worker.js +1 -1
  17. package/build/services/collator/index.js +1 -1
  18. package/build/services/compiler/deployer.js +1 -1
  19. package/build/services/compiler/index.js +1 -1
  20. package/build/services/compiler/validator.js +1 -1
  21. package/build/services/connector/factory.d.ts +1 -0
  22. package/build/services/connector/factory.js +22 -21
  23. package/build/services/connector/index.d.ts +4 -2
  24. package/build/services/connector/index.js +10 -5
  25. package/build/services/connector/providers/postgres.d.ts +13 -2
  26. package/build/services/connector/providers/postgres.js +54 -9
  27. package/build/services/engine/index.d.ts +1 -1
  28. package/build/services/engine/index.js +1 -1
  29. package/build/services/exporter/index.js +1 -1
  30. package/build/services/hotmesh/index.js +1 -6
  31. package/build/services/mapper/index.js +1 -1
  32. package/build/services/meshflow/connection.js +1 -0
  33. package/build/services/meshflow/exporter.js +1 -1
  34. package/build/services/pipe/functions/array.js +1 -1
  35. package/build/services/pipe/functions/bitwise.js +1 -1
  36. package/build/services/pipe/functions/conditional.js +1 -1
  37. package/build/services/pipe/functions/cron.js +1 -1
  38. package/build/services/pipe/functions/date.js +1 -1
  39. package/build/services/pipe/functions/index.js +1 -1
  40. package/build/services/pipe/functions/json.js +1 -1
  41. package/build/services/pipe/functions/logical.js +1 -1
  42. package/build/services/pipe/functions/math.js +1 -1
  43. package/build/services/pipe/functions/number.js +1 -1
  44. package/build/services/pipe/functions/object.js +1 -1
  45. package/build/services/pipe/functions/string.js +1 -1
  46. package/build/services/pipe/functions/symbol.js +1 -1
  47. package/build/services/pipe/functions/unary.js +1 -1
  48. package/build/services/pipe/index.js +1 -1
  49. package/build/services/quorum/index.d.ts +1 -1
  50. package/build/services/quorum/index.js +1 -1
  51. package/build/services/reporter/index.js +1 -1
  52. package/build/services/router/index.js +1 -1
  53. package/build/services/search/providers/postgres/postgres.js +1 -1
  54. package/build/services/search/providers/redis/ioredis.js +1 -1
  55. package/build/services/search/providers/redis/redis.js +1 -1
  56. package/build/services/serializer/index.js +1 -1
  57. package/build/services/store/providers/postgres/kvsql.js +1 -1
  58. package/build/services/store/providers/postgres/kvtables.d.ts +3 -2
  59. package/build/services/store/providers/postgres/kvtables.js +1 -1
  60. package/build/services/store/providers/postgres/kvtransaction.js +1 -1
  61. package/build/services/store/providers/postgres/kvtypes/hash.d.ts +1 -0
  62. package/build/services/store/providers/postgres/kvtypes/hash.js +1 -1
  63. package/build/services/store/providers/postgres/kvtypes/list.js +1 -1
  64. package/build/services/store/providers/postgres/kvtypes/string.js +1 -1
  65. package/build/services/store/providers/postgres/kvtypes/zset.js +1 -1
  66. package/build/services/store/providers/postgres/postgres.js +1 -1
  67. package/build/services/store/providers/redis/_base.js +1 -1
  68. package/build/services/store/providers/redis/ioredis.js +1 -1
  69. package/build/services/store/providers/redis/redis.js +1 -1
  70. package/build/services/store/providers/store-initializable.js +1 -1
  71. package/build/services/stream/providers/nats/nats.js +1 -1
  72. package/build/services/stream/providers/postgres/postgres.d.ts +1 -0
  73. package/build/services/stream/providers/postgres/postgres.js +1 -1
  74. package/build/services/stream/providers/redis/ioredis.js +1 -1
  75. package/build/services/stream/providers/redis/redis.js +1 -1
  76. package/build/services/stream/providers/stream-initializable.js +1 -1
  77. package/build/services/sub/factory.d.ts +3 -3
  78. package/build/services/sub/factory.js +14 -5
  79. package/build/services/sub/index.d.ts +3 -2
  80. package/build/services/sub/providers/nats/nats.d.ts +19 -0
  81. package/build/services/sub/providers/nats/nats.js +1 -0
  82. package/build/services/sub/providers/postgres/postgres.d.ts +19 -0
  83. package/build/services/sub/providers/postgres/postgres.js +1 -0
  84. package/build/services/sub/providers/redis/ioredis.d.ts +1 -1
  85. package/build/services/sub/providers/redis/ioredis.js +1 -1
  86. package/build/services/sub/providers/redis/redis.d.ts +1 -1
  87. package/build/services/sub/providers/redis/redis.js +1 -1
  88. package/build/services/task/index.js +1 -1
  89. package/build/services/telemetry/index.js +1 -1
  90. package/build/services/worker/index.d.ts +1 -1
  91. package/build/services/worker/index.js +1 -1
  92. package/build/types/nats.d.ts +8 -0
  93. package/build/types/postgres.d.ts +10 -1
  94. package/build/types/provider.d.ts +1 -0
  95. package/build/types/redis.d.ts +8 -8
  96. package/index.ts +20 -5
  97. package/package.json +10 -7
  98. package/types/nats.ts +34 -0
  99. package/types/postgres.ts +13 -2
  100. package/types/provider.ts +4 -0
  101. package/types/redis.ts +8 -8
@@ -1 +1 @@
1
- 'use strict';function _0x1114(_0x1a7913,_0x27aa73){const _0x2d0ec5=_0x2d0e();return _0x1114=function(_0x111446,_0x23b239){_0x111446=_0x111446-0x98;let _0x1d0759=_0x2d0ec5[_0x111446];return _0x1d0759;},_0x1114(_0x1a7913,_0x27aa73);}(function(_0xe0640c,_0x243b54){const _0x269163=_0x1114,_0x415a00=_0xe0640c();while(!![]){try{const _0x338efa=parseInt(_0x269163(0xa0))/0x1*(parseInt(_0x269163(0x98))/0x2)+parseInt(_0x269163(0x9a))/0x3*(parseInt(_0x269163(0x9e))/0x4)+parseInt(_0x269163(0xa3))/0x5*(-parseInt(_0x269163(0xa1))/0x6)+parseInt(_0x269163(0x99))/0x7+-parseInt(_0x269163(0x9c))/0x8+parseInt(_0x269163(0x9f))/0x9*(-parseInt(_0x269163(0x9b))/0xa)+-parseInt(_0x269163(0xa2))/0xb*(-parseInt(_0x269163(0x9d))/0xc);if(_0x338efa===_0x243b54)break;else _0x415a00['push'](_0x415a00['shift']());}catch(_0x65f9e4){_0x415a00['push'](_0x415a00['shift']());}}}(_0x2d0e,0x3dbc6));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['CollatorService']=void 0x0;const errors_1=require('../../modules/errors'),collator_1=require('../../types/collator');class CollatorService{static['assertJobActive'](_0x2cc81c,_0xf40c26,_0x11b09e,_0x5c2f28=0x0){if(_0x2cc81c<=_0x5c2f28)throw new errors_1['InactiveJobError'](_0xf40c26,_0x2cc81c,_0x11b09e);}static['getDimensionalAddress'](_0x22f978,_0x4521d2=![]){let _0x565561=_0x22f978['context']['metadata']['dad']||_0x22f978['metadata']['dad'];return _0x4521d2&&_0x565561&&_0x22f978['leg']===0x2&&(_0x565561=_0x565561['substring'](0x0,_0x565561['lastIndexOf'](','))+',0'),CollatorService['getDimensionsById']([..._0x22f978['config']['ancestors'],_0x22f978['metadata']['aid']],_0x565561);}static['resolveReentryDimension'](_0x1392b5){const _0x11ba77=_0x1392b5['config']['ancestor'],_0x56d3bc=_0x1392b5['config']['ancestors'],_0x286f2f=_0x56d3bc['indexOf'](_0x11ba77),_0x3abace=_0x1392b5['metadata']['dad']['split'](',');return _0x3abace['length']=_0x286f2f+0x1,_0x3abace['push']('0'),_0x3abace['join'](',');}static async['notarizeEntry'](_0x94f272,_0xc838f7){const _0x3d235c=await _0x94f272['store']['collate'](_0x94f272['context']['metadata']['jid'],_0x94f272['metadata']['aid'],-0x5af3107a4000,this['getDimensionalAddress'](_0x94f272),_0xc838f7);return this['verifyInteger'](_0x3d235c,0x1,'enter'),_0x3d235c;}static async['authorizeReentry'](_0x3699af,_0x1bfcfa){const _0x11cee6=await _0x3699af['store']['collate'](_0x3699af['context']['metadata']['jid'],_0x3699af['metadata']['aid'],-0x9184e72a000,this['getDimensionalAddress'](_0x3699af),_0x1bfcfa);return _0x11cee6;}static async['notarizeEarlyExit'](_0x1275f2,_0x140bc0){return await _0x1275f2['store']['collate'](_0x1275f2['context']['metadata']['jid'],_0x1275f2['metadata']['aid'],-0xa012317b000,this['getDimensionalAddress'](_0x1275f2),_0x140bc0);}static async['notarizeEarlyCompletion'](_0x364f27,_0x50f3e2){const _0x5df721=_0x364f27['config']['cycle']?0x9184e72a000:0xa012317b000;return await _0x364f27['store']['collate'](_0x364f27['context']['metadata']['jid'],_0x364f27['metadata']['aid'],0xf4241-_0x5df721,this['getDimensionalAddress'](_0x364f27),_0x50f3e2);}static async['notarizeInception'](_0x5b7ff9,_0x1587ed,_0x456f7f){_0x1587ed&&await _0x5b7ff9['store']['collateSynthetic'](_0x5b7ff9['context']['metadata']['jid'],_0x1587ed,0xf4240,_0x456f7f);}static async['isInceptionOverage'](_0x43993f,_0x2a2dd4){if(_0x2a2dd4){const _0x44eed0=await _0x43993f['store']['collateSynthetic'](_0x43993f['context']['metadata']['jid'],_0x2a2dd4,0xf4240);return _0x44eed0>0xf4240;}return![];}static async['notarizeReentry'](_0x501821,_0x13003b,_0x494487){const _0x38c302=_0x501821['context']['metadata']['jid'],_0x3c8d36=_0x494487||_0x501821['store']['transact']();await _0x501821['store']['collate'](_0x38c302,_0x501821['metadata']['aid'],0xf4240,this['getDimensionalAddress'](_0x501821,!![]),_0x3c8d36),await _0x501821['store']['collateSynthetic'](_0x38c302,_0x13003b,0xf4240,_0x3c8d36);const [_0x21a03b,_0x141543]=await _0x3c8d36['exec'](),_0x57fc93=Array['isArray'](_0x21a03b)?_0x21a03b[0x1]:_0x21a03b,_0x1c6307=Array['isArray'](_0x141543)?_0x141543[0x1]:_0x141543;return this['verifyInteger'](_0x57fc93,0x2,'enter'),this['verifySyntheticInteger'](_0x1c6307),_0x57fc93;}static async['notarizeContinuation'](_0x2b0f0a,_0x5386ba){return await _0x2b0f0a['store']['collate'](_0x2b0f0a['context']['metadata']['jid'],_0x2b0f0a['metadata']['aid'],0x1,this['getDimensionalAddress'](_0x2b0f0a),_0x5386ba);}static async['notarizeCompletion'](_0x4f5e4f,_0x38e390){const _0x51118f=_0x4f5e4f['config']['cycle']?0x0:0xe8d4a51000;return await _0x4f5e4f['store']['collate'](_0x4f5e4f['context']['metadata']['jid'],_0x4f5e4f['metadata']['aid'],0x1-_0x51118f,this['getDimensionalAddress'](_0x4f5e4f),_0x38e390);}static['getDigitAtIndex'](_0x13d6b0,_0x282e67){const _0x49077d=_0x13d6b0['toString']();if(_0x282e67<0x0||_0x282e67>=_0x49077d['length'])return null;const _0x120721=parseInt(_0x49077d[_0x282e67],0xa);return _0x120721;}static['getDimensionalIndex'](_0x4185a0){const _0x2cc84b=_0x4185a0['toString']();if(_0x2cc84b['length']<0x9)return null;const _0x329df0=_0x2cc84b['substring'](0x3,0x9),_0x1a6441=parseInt(_0x329df0,0xa);return _0x1a6441-0x1;}static['isDuplicate'](_0x44ba92,_0x39ba06){return this['getDigitAtIndex'](_0x44ba92,_0x39ba06)<0x8;}static['isInactive'](_0x33ea14){return this['getDigitAtIndex'](_0x33ea14,0x2)<0x9;}static['isPrimed'](_0x19da1e,_0xc5634c){return _0xc5634c==0x1?_0x19da1e!=-0x5af3107a4000:this['getDigitAtIndex'](_0x19da1e,0x0)<0x9&&this['getDigitAtIndex'](_0x19da1e,0x1)<0x9;}static['verifySyntheticInteger'](_0x59da83){const _0x9e6fa4=_0x59da83['toString'](),_0x160425=parseInt(_0x9e6fa4[_0x9e6fa4['length']-0x1],0xa);if(_0x160425>0x0)throw new errors_1['CollationError'](_0x59da83,0x2,'enter',collator_1['CollationFaultType']['INACTIVE']);else{if(_0x59da83>=0x1e8480)throw new errors_1['CollationError'](_0x59da83,0x2,'enter',collator_1['CollationFaultType']['DUPLICATE']);}}static['verifyInteger'](_0x42fab7,_0x39c6d5,_0x3a4ea7){let _0x51c106;if(_0x39c6d5===0x1&&_0x3a4ea7==='enter'){if(!this['isPrimed'](_0x42fab7,0x1))_0x51c106=collator_1['CollationFaultType']['MISSING'];else{if(this['isDuplicate'](_0x42fab7,0x0))_0x51c106=collator_1['CollationFaultType']['DUPLICATE'];else _0x42fab7!=0x331a2bfa73000&&(_0x51c106=collator_1['CollationFaultType']['INVALID']);}}else{if(_0x39c6d5===0x1&&_0x3a4ea7==='exit'){if(_0x42fab7===-0x9184e72a000)_0x51c106=collator_1['CollationFaultType']['MISSING'];else this['isDuplicate'](_0x42fab7,0x1)&&(_0x51c106=collator_1['CollationFaultType']['DUPLICATE']);}else{if(_0x39c6d5===0x2&&_0x3a4ea7==='enter'){if(!this['isPrimed'](_0x42fab7,0x2))_0x51c106=collator_1['CollationFaultType']['FORBIDDEN'];else this['isInactive'](_0x42fab7)&&(_0x51c106=collator_1['CollationFaultType']['INACTIVE']);}}}if(_0x51c106)throw new errors_1['CollationError'](_0x42fab7,_0x39c6d5,_0x3a4ea7,_0x51c106);}static['getDimensionsById'](_0x570b3a,_0x21cf39){const _0x443ea0={'$ADJACENT':_0x21cf39+',0'};let _0x4d4129=_0x21cf39;return _0x570b3a['reverse']()['forEach'](_0x40b24f=>{_0x443ea0[_0x40b24f]=_0x4d4129,_0x4d4129=_0x4d4129['substring'](0x0,_0x4d4129['lastIndexOf'](','));}),_0x443ea0;}static['getSeed'](){return'999000000000000';}static['getTriggerSeed'](){return'888000001000001';}static['compile'](_0x3c995b){CollatorService['bindAncestorArray'](_0x3c995b);}static['bindAncestorArray'](_0x36924e){_0x36924e['forEach'](_0x5b0cd8=>{const _0x252593={},_0x5273b7=Object['keys'](_0x5b0cd8['activities'])['find'](_0x16f375=>_0x5b0cd8['activities'][_0x16f375]['type']==='trigger');if(!_0x5273b7)throw new Error('collator-trigger-activity-not-found');const _0x318de5=(_0x258183,_0x2a8ac3)=>{_0x252593[_0x258183]=_0x2a8ac3,_0x5b0cd8['activities'][_0x258183]['ancestors']=_0x2a8ac3;const _0x3acfab=_0x5b0cd8['transitions']?.[_0x258183]||[];_0x3acfab['forEach'](_0x2e773b=>{_0x318de5(_0x2e773b['to'],[..._0x2a8ac3,_0x258183]);});};_0x318de5(_0x5273b7,[]);});}static['getDimensionalSeed'](_0x37cde3=0x0){return','+_0x37cde3;}}function _0x2d0e(){const _0x311cf3=['11223zGnBiq','13eyKYNv','988158dfMKYI','69707fXJqyp','5kMwHBx','77562NzUfPC','2138689qdeiob','171Ylwpzy','2670hSHcwa','2388168zzvcsg','12NOzLwU','16352IYrZLb'];_0x2d0e=function(){return _0x311cf3;};return _0x2d0e();}exports['CollatorService']=CollatorService,CollatorService['targetLength']=0xf;
1
+ 'use strict';(function(_0x4954a3,_0x2b6920){const _0x2c3dc8=_0x59cd,_0x4afdea=_0x4954a3();while(!![]){try{const _0x28b6b7=-parseInt(_0x2c3dc8(0xe0))/0x1*(parseInt(_0x2c3dc8(0xe9))/0x2)+-parseInt(_0x2c3dc8(0xde))/0x3*(-parseInt(_0x2c3dc8(0xe8))/0x4)+parseInt(_0x2c3dc8(0xe3))/0x5*(parseInt(_0x2c3dc8(0xe6))/0x6)+parseInt(_0x2c3dc8(0xdf))/0x7*(parseInt(_0x2c3dc8(0xe7))/0x8)+parseInt(_0x2c3dc8(0xe4))/0x9*(parseInt(_0x2c3dc8(0xe1))/0xa)+parseInt(_0x2c3dc8(0xe2))/0xb+parseInt(_0x2c3dc8(0xea))/0xc*(-parseInt(_0x2c3dc8(0xe5))/0xd);if(_0x28b6b7===_0x2b6920)break;else _0x4afdea['push'](_0x4afdea['shift']());}catch(_0x4ca71a){_0x4afdea['push'](_0x4afdea['shift']());}}}(_0x2daa,0x73234));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['CollatorService']=void 0x0;function _0x59cd(_0x1d0bda,_0xf182c9){const _0x2daa73=_0x2daa();return _0x59cd=function(_0x59cd4f,_0x58ad19){_0x59cd4f=_0x59cd4f-0xde;let _0x33977e=_0x2daa73[_0x59cd4f];return _0x33977e;},_0x59cd(_0x1d0bda,_0xf182c9);}const errors_1=require('../../modules/errors'),collator_1=require('../../types/collator');class CollatorService{static['assertJobActive'](_0x4d7fb3,_0x24beac,_0x3ec26e,_0x5c1632=0x0){if(_0x4d7fb3<=_0x5c1632)throw new errors_1['InactiveJobError'](_0x24beac,_0x4d7fb3,_0x3ec26e);}static['getDimensionalAddress'](_0x5bba4a,_0x46c9df=![]){let _0x5345bd=_0x5bba4a['context']['metadata']['dad']||_0x5bba4a['metadata']['dad'];return _0x46c9df&&_0x5345bd&&_0x5bba4a['leg']===0x2&&(_0x5345bd=_0x5345bd['substring'](0x0,_0x5345bd['lastIndexOf'](','))+',0'),CollatorService['getDimensionsById']([..._0x5bba4a['config']['ancestors'],_0x5bba4a['metadata']['aid']],_0x5345bd);}static['resolveReentryDimension'](_0x5a73f5){const _0x1d73d2=_0x5a73f5['config']['ancestor'],_0x488ccc=_0x5a73f5['config']['ancestors'],_0x203374=_0x488ccc['indexOf'](_0x1d73d2),_0x831e79=_0x5a73f5['metadata']['dad']['split'](',');return _0x831e79['length']=_0x203374+0x1,_0x831e79['push']('0'),_0x831e79['join'](',');}static async['notarizeEntry'](_0x29fd77,_0x578104){const _0x216dc8=await _0x29fd77['store']['collate'](_0x29fd77['context']['metadata']['jid'],_0x29fd77['metadata']['aid'],-0x5af3107a4000,this['getDimensionalAddress'](_0x29fd77),_0x578104);return this['verifyInteger'](_0x216dc8,0x1,'enter'),_0x216dc8;}static async['authorizeReentry'](_0x2e69b1,_0x20a2b7){const _0x7f3cb=await _0x2e69b1['store']['collate'](_0x2e69b1['context']['metadata']['jid'],_0x2e69b1['metadata']['aid'],-0x9184e72a000,this['getDimensionalAddress'](_0x2e69b1),_0x20a2b7);return _0x7f3cb;}static async['notarizeEarlyExit'](_0x51f7cc,_0xe9194e){return await _0x51f7cc['store']['collate'](_0x51f7cc['context']['metadata']['jid'],_0x51f7cc['metadata']['aid'],-0xa012317b000,this['getDimensionalAddress'](_0x51f7cc),_0xe9194e);}static async['notarizeEarlyCompletion'](_0x2d7812,_0x4caf52){const _0x2142eb=_0x2d7812['config']['cycle']?0x9184e72a000:0xa012317b000;return await _0x2d7812['store']['collate'](_0x2d7812['context']['metadata']['jid'],_0x2d7812['metadata']['aid'],0xf4241-_0x2142eb,this['getDimensionalAddress'](_0x2d7812),_0x4caf52);}static async['notarizeInception'](_0x3c5801,_0x507ca9,_0x200614){_0x507ca9&&await _0x3c5801['store']['collateSynthetic'](_0x3c5801['context']['metadata']['jid'],_0x507ca9,0xf4240,_0x200614);}static async['isInceptionOverage'](_0x3db2be,_0x4d5152){if(_0x4d5152){const _0x2eceed=await _0x3db2be['store']['collateSynthetic'](_0x3db2be['context']['metadata']['jid'],_0x4d5152,0xf4240);return _0x2eceed>0xf4240;}return![];}static async['notarizeReentry'](_0x27e0c3,_0x1c4909,_0x38255d){const _0x4bcab8=_0x27e0c3['context']['metadata']['jid'],_0x19ce10=_0x38255d||_0x27e0c3['store']['transact']();await _0x27e0c3['store']['collate'](_0x4bcab8,_0x27e0c3['metadata']['aid'],0xf4240,this['getDimensionalAddress'](_0x27e0c3,!![]),_0x19ce10),await _0x27e0c3['store']['collateSynthetic'](_0x4bcab8,_0x1c4909,0xf4240,_0x19ce10);const [_0x5e6d08,_0x3a06a3]=await _0x19ce10['exec'](),_0x50afd0=Array['isArray'](_0x5e6d08)?_0x5e6d08[0x1]:_0x5e6d08,_0x4bd2ce=Array['isArray'](_0x3a06a3)?_0x3a06a3[0x1]:_0x3a06a3;return this['verifyInteger'](_0x50afd0,0x2,'enter'),this['verifySyntheticInteger'](_0x4bd2ce),_0x50afd0;}static async['notarizeContinuation'](_0x34f8bd,_0x36598a){return await _0x34f8bd['store']['collate'](_0x34f8bd['context']['metadata']['jid'],_0x34f8bd['metadata']['aid'],0x1,this['getDimensionalAddress'](_0x34f8bd),_0x36598a);}static async['notarizeCompletion'](_0x1252f8,_0x36470e){const _0x1105b7=_0x1252f8['config']['cycle']?0x0:0xe8d4a51000;return await _0x1252f8['store']['collate'](_0x1252f8['context']['metadata']['jid'],_0x1252f8['metadata']['aid'],0x1-_0x1105b7,this['getDimensionalAddress'](_0x1252f8),_0x36470e);}static['getDigitAtIndex'](_0x11199b,_0x3bd273){const _0x3eb6f7=_0x11199b['toString']();if(_0x3bd273<0x0||_0x3bd273>=_0x3eb6f7['length'])return null;const _0x44da46=parseInt(_0x3eb6f7[_0x3bd273],0xa);return _0x44da46;}static['getDimensionalIndex'](_0x29de59){const _0x1edf8f=_0x29de59['toString']();if(_0x1edf8f['length']<0x9)return null;const _0x4cfab2=_0x1edf8f['substring'](0x3,0x9),_0x139f76=parseInt(_0x4cfab2,0xa);return _0x139f76-0x1;}static['isDuplicate'](_0x456a50,_0x9e10f0){return this['getDigitAtIndex'](_0x456a50,_0x9e10f0)<0x8;}static['isInactive'](_0xe96029){return this['getDigitAtIndex'](_0xe96029,0x2)<0x9;}static['isPrimed'](_0xc7c4a,_0x34731f){return _0x34731f==0x1?_0xc7c4a!=-0x5af3107a4000:this['getDigitAtIndex'](_0xc7c4a,0x0)<0x9&&this['getDigitAtIndex'](_0xc7c4a,0x1)<0x9;}static['verifySyntheticInteger'](_0x41f363){const _0x52d427=_0x41f363['toString'](),_0x4389e4=parseInt(_0x52d427[_0x52d427['length']-0x1],0xa);if(_0x4389e4>0x0)throw new errors_1['CollationError'](_0x41f363,0x2,'enter',collator_1['CollationFaultType']['INACTIVE']);else{if(_0x41f363>=0x1e8480)throw new errors_1['CollationError'](_0x41f363,0x2,'enter',collator_1['CollationFaultType']['DUPLICATE']);}}static['verifyInteger'](_0x41a5e5,_0x442eda,_0x34781a){let _0x35da99;if(_0x442eda===0x1&&_0x34781a==='enter'){if(!this['isPrimed'](_0x41a5e5,0x1))_0x35da99=collator_1['CollationFaultType']['MISSING'];else{if(this['isDuplicate'](_0x41a5e5,0x0))_0x35da99=collator_1['CollationFaultType']['DUPLICATE'];else _0x41a5e5!=0x331a2bfa73000&&(_0x35da99=collator_1['CollationFaultType']['INVALID']);}}else{if(_0x442eda===0x1&&_0x34781a==='exit'){if(_0x41a5e5===-0x9184e72a000)_0x35da99=collator_1['CollationFaultType']['MISSING'];else this['isDuplicate'](_0x41a5e5,0x1)&&(_0x35da99=collator_1['CollationFaultType']['DUPLICATE']);}else{if(_0x442eda===0x2&&_0x34781a==='enter'){if(!this['isPrimed'](_0x41a5e5,0x2))_0x35da99=collator_1['CollationFaultType']['FORBIDDEN'];else this['isInactive'](_0x41a5e5)&&(_0x35da99=collator_1['CollationFaultType']['INACTIVE']);}}}if(_0x35da99)throw new errors_1['CollationError'](_0x41a5e5,_0x442eda,_0x34781a,_0x35da99);}static['getDimensionsById'](_0x179252,_0x1e8fe7){const _0x3edd66={'$ADJACENT':_0x1e8fe7+',0'};let _0x464851=_0x1e8fe7;return _0x179252['reverse']()['forEach'](_0x3b2079=>{_0x3edd66[_0x3b2079]=_0x464851,_0x464851=_0x464851['substring'](0x0,_0x464851['lastIndexOf'](','));}),_0x3edd66;}static['getSeed'](){return'999000000000000';}static['getTriggerSeed'](){return'888000001000001';}static['compile'](_0x380b82){CollatorService['bindAncestorArray'](_0x380b82);}static['bindAncestorArray'](_0x2ac5eb){_0x2ac5eb['forEach'](_0x3a062f=>{const _0x16edca={},_0x2661aa=Object['keys'](_0x3a062f['activities'])['find'](_0x395999=>_0x3a062f['activities'][_0x395999]['type']==='trigger');if(!_0x2661aa)throw new Error('collator-trigger-activity-not-found');const _0x301d9d=(_0x4a6768,_0x55f7ed)=>{_0x16edca[_0x4a6768]=_0x55f7ed,_0x3a062f['activities'][_0x4a6768]['ancestors']=_0x55f7ed;const _0xa30725=_0x3a062f['transitions']?.[_0x4a6768]||[];_0xa30725['forEach'](_0x4d4316=>{_0x301d9d(_0x4d4316['to'],[..._0x55f7ed,_0x4a6768]);});};_0x301d9d(_0x2661aa,[]);});}static['getDimensionalSeed'](_0x42d694=0x0){return','+_0x42d694;}}exports['CollatorService']=CollatorService,CollatorService['targetLength']=0xf;function _0x2daa(){const _0x1d3cf5=['3975862fFDzps','2176935vrXMET','41841pJteYX','23110802vHgYQP','6soiZFB','73952QEXwQo','4JPmYWy','59108bsEtfx','12RkCFgy','1834320jitdNd','308ocOTUA','10odJuTl','1570qnSoGs'];_0x2daa=function(){return _0x1d3cf5;};return _0x2daa();}
@@ -1 +1 @@
1
- 'use strict';function _0x3b0c(_0x1f6194,_0xdb440b){const _0x4eb82d=_0x4eb8();return _0x3b0c=function(_0x3b0c66,_0xd2a7ce){_0x3b0c66=_0x3b0c66-0x87;let _0x2b7802=_0x4eb82d[_0x3b0c66];return _0x2b7802;},_0x3b0c(_0x1f6194,_0xdb440b);}(function(_0x2a349e,_0x2e7399){const _0x59b9e5=_0x3b0c,_0x5d3931=_0x2a349e();while(!![]){try{const _0x48246a=parseInt(_0x59b9e5(0x87))/0x1+parseInt(_0x59b9e5(0x8f))/0x2+-parseInt(_0x59b9e5(0x8d))/0x3*(-parseInt(_0x59b9e5(0x8a))/0x4)+-parseInt(_0x59b9e5(0x89))/0x5+-parseInt(_0x59b9e5(0x8e))/0x6+parseInt(_0x59b9e5(0x8c))/0x7+-parseInt(_0x59b9e5(0x8b))/0x8*(parseInt(_0x59b9e5(0x88))/0x9);if(_0x48246a===_0x2e7399)break;else _0x5d3931['push'](_0x5d3931['shift']());}catch(_0x254869){_0x5d3931['push'](_0x5d3931['shift']());}}}(_0x4eb8,0xcf6db));function _0x4eb8(){const _0x43e857=['2711682rZpudR','1861708PlERWT','205690ZeuGFP','243DBWIjs','3646010KzMRyk','948oKYXNP','117296vDlmti','7877737lrNEwa','2085ixKAVU'];_0x4eb8=function(){return _0x43e857;};return _0x4eb8();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['Deployer']=void 0x0;const key_1=require('../../modules/key'),utils_1=require('../../modules/utils'),collator_1=require('../collator'),serializer_1=require('../serializer'),pipe_1=require('../pipe'),validator_1=require('./validator'),DEFAULT_METADATA_RANGE_SIZE=0x1a,DEFAULT_DATA_RANGE_SIZE=0x104,DEFAULT_RANGE_SIZE=DEFAULT_METADATA_RANGE_SIZE+DEFAULT_DATA_RANGE_SIZE;class Deployer{constructor(_0x4a30bd){this['manifest']=null,this['manifest']=_0x4a30bd;}async['deploy'](_0x3db499,_0x200dce){this['store']=_0x3db499,this['stream']=_0x200dce,collator_1['CollatorService']['compile'](this['manifest']['app']['graphs']),this['convertActivitiesToHooks'](),this['convertTopicsToTypes'](),this['copyJobSchemas'](),this['bindBackRefs'](),this['bindParents'](),this['bindCycleTarget'](),this['resolveMappingDependencies'](),this['resolveJobMapsPaths'](),await this['generateSymKeys'](),await this['generateSymVals'](),await this['deployHookPatterns'](),await this['deployActivitySchemas'](),await this['deploySubscriptions'](),await this['deployTransitions'](),await this['deployConsumerGroups']();}['getVID'](){return{'id':this['manifest']['app']['id'],'version':this['manifest']['app']['version']};}async['generateSymKeys'](){for(const _0x4b2911 of this['manifest']['app']['graphs']){const [,_0x402409]=this['findTrigger'](_0x4b2911),_0x350edd=_0x402409['subscribes'],[_0x4a9c61,_0x3d962e,_0x3e5504]=await this['store']['reserveSymbolRange']('$'+_0x350edd,DEFAULT_RANGE_SIZE,'JOB'),_0x3e201e='',_0x17426d=this['bindSymbols'](_0x4a9c61,_0x3d962e,_0x3e5504,_0x3e201e,_0x402409['PRODUCES']);Object['keys'](_0x17426d)['length']&&await this['store']['addSymbols']('$'+_0x350edd,_0x17426d);for(const [_0x461ba4,_0x532745]of Object['entries'](_0x4b2911['activities'])){const [_0x196035,_0x1d0bb5,_0x6da7c2]=await this['store']['reserveSymbolRange'](_0x461ba4,DEFAULT_RANGE_SIZE,'ACTIVITY'),_0x5233d3=_0x461ba4+'/';this['bindSelf'](_0x532745['consumes'],_0x532745['produces'],_0x461ba4);const _0x2aae19=this['bindSymbols'](_0x196035,_0x1d0bb5,_0x6da7c2,_0x5233d3,_0x532745['produces']);Object['keys'](_0x2aae19)['length']&&await this['store']['addSymbols'](_0x461ba4,_0x2aae19);}}}['bindSelf'](_0x1ac2d6,_0xc8e098,_0x19d332){for(const _0x298971 of[_0x19d332,'$self']){const _0x513d6c=_0x1ac2d6[_0x298971];if(_0x513d6c)for(const _0x6f46fa of _0x513d6c){!_0xc8e098['includes'](_0x6f46fa)&&_0xc8e098['push'](_0x6f46fa);}}}['bindSymbols'](_0x84ab1b,_0x3954c7,_0x4f0c50,_0x4496a6,_0x2c7bb4){const _0x1afbb4={},_0x54aea9={..._0x4f0c50};for(const _0x28dd43 of _0x2c7bb4){const _0xcb61cc=''+_0x4496a6+_0x28dd43;if(!_0x54aea9[_0xcb61cc]){if(_0x84ab1b>_0x3954c7)throw new Error('Symbol\x20index\x20out\x20of\x20bounds');const _0x49d279=(0x0,utils_1['getSymKey'])(_0x84ab1b);_0x84ab1b++,_0x1afbb4[_0xcb61cc]=_0x49d279,_0x54aea9[_0xcb61cc]=_0x49d279;}}return _0x1afbb4;}['copyJobSchemas'](){const _0x48a0de=this['manifest']['app']['graphs'];for(const _0x1f448b of _0x48a0de){const _0x3e96d8=_0x1f448b['output']?.['schema'],_0x498f11=_0x1f448b['input']?.['schema'];if(!_0x3e96d8&&!_0x498f11)continue;const _0x5b897a=_0x1f448b['activities'];for(const _0x15f938 in _0x5b897a){if(_0x5b897a[_0x15f938]['type']==='trigger'){const _0xdf604c=_0x5b897a[_0x15f938];_0x3e96d8&&(!_0xdf604c['job']&&(_0xdf604c['job']={}),_0xdf604c['job']['schema']=_0x3e96d8),_0x498f11&&(_0xdf604c['output']={'schema':_0x498f11});}}}}['bindBackRefs'](){for(const _0x21961b of this['manifest']['app']['graphs']){const _0x49045a=_0x21961b['activities'],_0x7b834f=this['findTrigger'](_0x21961b)[0x0];for(const _0x51e6d6 in _0x49045a){_0x49045a[_0x51e6d6]['trigger']=_0x7b834f,_0x49045a[_0x51e6d6]['subscribes']=_0x21961b['subscribes'],_0x21961b['publishes']&&(_0x49045a[_0x51e6d6]['publishes']=_0x21961b['publishes']),_0x49045a[_0x51e6d6]['expire']=_0x21961b['expire']??undefined,_0x49045a[_0x51e6d6]['persistent']=_0x21961b['persistent']??undefined;}}}['bindCycleTarget'](){for(const _0x44dc2e of this['manifest']['app']['graphs']){const _0x2fe7d0=_0x44dc2e['activities'];for(const _0x21b9cf in _0x2fe7d0){const _0x10abd3=_0x2fe7d0[_0x21b9cf];_0x10abd3['type']==='cycle'&&(_0x2fe7d0[_0x10abd3['ancestor']]['cycle']=!![]);}}}['convertTopicsToTypes'](){for(const _0x1d32b7 of this['manifest']['app']['graphs']){const _0x4ff02e=_0x1d32b7['activities'];for(const _0x42a6e5 in _0x4ff02e){const _0x1144e8=_0x4ff02e[_0x42a6e5];['worker','await']['includes'](_0x1144e8['type'])&&_0x1144e8['topic']&&!_0x1144e8['subtype']&&(_0x1144e8['subtype']=_0x1144e8['topic']);}}}['convertActivitiesToHooks'](){for(const _0x3f2294 of this['manifest']['app']['graphs']){const _0x15323c=_0x3f2294['activities'];for(const _0x3dc446 in _0x15323c){const _0x3329be=_0x15323c[_0x3dc446];['activity']['includes'](_0x3329be['type'])&&(_0x3329be['type']='hook');}}}async['bindParents'](){const _0x461ed2=this['manifest']['app']['graphs'];for(const _0x2ccc5c of _0x461ed2){if(_0x2ccc5c['transitions'])for(const _0x4cdda6 in _0x2ccc5c['transitions']){const _0x58a3d9=_0x2ccc5c['transitions'][_0x4cdda6];for(const _0x46d0c9 of _0x58a3d9){const _0x2bbaee=_0x46d0c9['to'];_0x2ccc5c['activities'][_0x2bbaee]['parent']=_0x4cdda6;}_0x2ccc5c['activities'][_0x4cdda6]['transitions']=_0x58a3d9;}}}['collectValues'](_0x4f3a05,_0x5161b4){for(const [_0x2ff16b,_0x270c4b]of Object['entries'](_0x4f3a05)){if(_0x2ff16b==='enum'||_0x2ff16b==='examples'||_0x2ff16b==='default'){if(Array['isArray'](_0x270c4b))for(const _0x3af961 of _0x270c4b){typeof _0x3af961==='string'&&_0x3af961['length']>0x5&&_0x5161b4['add'](_0x3af961);}else typeof _0x270c4b==='string'&&_0x270c4b['length']>0x5&&_0x5161b4['add'](_0x270c4b);}else typeof _0x270c4b==='object'&&this['collectValues'](_0x270c4b,_0x5161b4);}}['traverse'](_0x550c9b,_0x982358){for(const _0x8ad638 of Object['values'](_0x550c9b)){typeof _0x8ad638==='object'&&('schema'in _0x8ad638?this['collectValues'](_0x8ad638['schema'],_0x982358):this['traverse'](_0x8ad638,_0x982358));}}async['generateSymVals'](){const _0x136df3=new Set();for(const _0x506a78 of this['manifest']['app']['graphs']){this['traverse'](_0x506a78,_0x136df3);}const _0x1a776d=await this['store']['getSymbolValues'](),_0x21c850=Object['keys'](_0x1a776d)['length'],_0x3364d8=Math['pow'](0x34,0x2)-0x1,_0x3ebb25=serializer_1['SerializerService']['filterSymVals'](_0x21c850,_0x3364d8,_0x1a776d,_0x136df3);await this['store']['addSymbolValues'](_0x3ebb25);}['resolveJobMapsPaths'](){function _0x3345ed(_0x33b1d2){const _0x22a211=[];function _0x138d1b(_0x2175a1,_0x2b482d=[]){for(const _0x3225b2 in _0x2175a1){if(typeof _0x2175a1[_0x3225b2]==='object'&&_0x2175a1[_0x3225b2]!==null&&!('@pipe'in _0x2175a1[_0x3225b2])){const _0x327707=[..._0x2b482d,_0x3225b2];_0x138d1b(_0x2175a1[_0x3225b2],_0x327707);}else{const _0x103508=[..._0x2b482d,_0x3225b2]['join']('/');if(!_0x103508['includes']('[')){const _0xbf475b='data/'+_0x103508;!_0x22a211['includes'](_0xbf475b)&&_0x22a211['push'](_0xbf475b);}else{const [_0x35fd2e,_0x245bdc]=_0x103508['split']('['),[_0x44afd9,_0x595387]=_0x245bdc['split'](']');if(!isNaN(parseInt(_0x44afd9)))for(let _0x5dd4a0=0x0;_0x5dd4a0<parseInt(_0x44afd9);_0x5dd4a0++){const _0x34efe8='data/'+_0x35fd2e+'/'+_0x5dd4a0;!_0x22a211['includes'](_0x34efe8)&&_0x22a211['push'](_0x34efe8);}}}}}return _0x33b1d2&&_0x138d1b(_0x33b1d2),_0x22a211;}for(const _0x48c3fe of this['manifest']['app']['graphs']){let _0x19ca85=[];const [,_0x50c8ba]=this['findTrigger'](_0x48c3fe);for(const _0x3688f3 in _0x48c3fe['activities']){const _0x19a3d2=_0x48c3fe['activities'][_0x3688f3];_0x19ca85=_0x19ca85['concat'](_0x3345ed(_0x19a3d2['job']?.['maps']));}_0x50c8ba['PRODUCES']=_0x19ca85;}}['resolveMappingDependencies'](){const _0x482efd=[];function _0x49b944(_0x65ca33,_0xf8385d){for(const _0x24712f in _0x65ca33){if(typeof _0x65ca33[_0x24712f]==='string'){const _0x26979e=_0x65ca33[_0x24712f],_0x2e67c0=_0x26979e['match'](/^\{[^@].*}$/);_0x2e67c0&&!validator_1['Validator']['CONTEXT_VARS']['includes'](_0x26979e)&&(_0x26979e['split']('.')[0x1]!=='input'&&(_0x482efd['push'](_0x26979e),_0xf8385d['push'](_0x26979e)));}else typeof _0x65ca33[_0x24712f]==='object'&&_0x65ca33[_0x24712f]!==null&&_0x49b944(_0x65ca33[_0x24712f],_0xf8385d);}}const _0x112565=this['manifest']['app']['graphs'];for(const _0x180528 of _0x112565){const _0x26bf08=_0x180528['activities'];for(const _0x2a7ce6 in _0x26bf08){const _0x329f7b=_0x26bf08[_0x2a7ce6];_0x329f7b['consumes']=[],_0x49b944(_0x329f7b,_0x329f7b['consumes']),_0x329f7b['consumes']=this['groupMappingRules'](_0x329f7b['consumes']);}}const _0x4b3d98=this['groupMappingRules'](_0x482efd);for(const _0x55b4fc of _0x112565){const _0x5879af=_0x55b4fc['activities'];for(const _0x4fbe10 in _0x5879af){const _0x2950a0=_0x5879af[_0x4fbe10];_0x2950a0['produces']=_0x4b3d98[''+_0x4fbe10]||[];}}}['groupMappingRules'](_0x5bce71){_0x5bce71=Array['from'](new Set(_0x5bce71))['sort']();const _0x4ac5db={};for(const _0x106a73 of _0x5bce71){const [_0x3f71a9,_0x1e8e8a]=this['resolveMappableValue'](_0x106a73);!_0x4ac5db[_0x3f71a9]&&(_0x4ac5db[_0x3f71a9]=[]),_0x4ac5db[_0x3f71a9]['push'](_0x1e8e8a);}return _0x4ac5db;}['resolveMappableValue'](_0x229622){_0x229622=_0x229622['substring'](0x1,_0x229622['length']-0x1);const _0x22f745=_0x229622['split']('.');if(_0x22f745[0x0]==='$job'){const [_0x1f28dd,..._0x3c1dca]=_0x22f745;return[_0x1f28dd,_0x3c1dca['join']('/')];}else{const [_0x3a3c2f,_0x43d2b3,_0x4c1601,..._0x1f0760]=_0x22f745,_0x562f49={'hook':'hook/data','input':'input/data','output':_0x4c1601==='data'?'output/data':'output/metadata'}[_0x43d2b3];return[_0x3a3c2f,_0x562f49+'/'+_0x1f0760['join']('/')];}}async['deployActivitySchemas'](){const _0x4e334d=this['manifest']['app']['graphs'],_0x30291c={};for(const _0x127fdb of _0x4e334d){const _0x3fec48=_0x127fdb['activities'];for(const _0x5c9e0f in _0x3fec48){const _0x49fe4e=_0x3fec48[_0x5c9e0f];delete _0x49fe4e['transitions'],_0x30291c[_0x5c9e0f]=_0x49fe4e;}}await this['store']['setSchemas'](_0x30291c,this['getVID']());}async['deploySubscriptions'](){const _0xfe703=this['manifest']['app']['graphs'],_0x5eeea7={};for(const _0x3813aa of _0xfe703){const _0x447cea=_0x3813aa['activities'],_0x362558=_0x3813aa['subscribes'];for(const _0x1459db in _0x447cea){if(_0x447cea[_0x1459db]['type']==='trigger'){_0x5eeea7[_0x362558]=_0x1459db;break;}}}await this['store']['setSubscriptions'](_0x5eeea7,this['getVID']());}['findTrigger'](_0x493ec3){for(const _0x5f200d in _0x493ec3['activities']){const _0x427568=_0x493ec3['activities'][_0x5f200d];if(_0x427568['type']==='trigger')return[_0x5f200d,_0x427568];}return null;}async['deployTransitions'](){const _0x548a4a=this['manifest']['app']['graphs'],_0x2e7d34={};for(const _0x4ac719 of _0x548a4a){if(_0x4ac719['subscribes']&&_0x4ac719['subscribes']['startsWith']('.')){const [_0x4b6e7a]=this['findTrigger'](_0x4ac719);_0x4b6e7a&&(_0x2e7d34[_0x4ac719['subscribes']]={[_0x4b6e7a]:!![]});}if(_0x4ac719['transitions'])for(const _0x4b037b in _0x4ac719['transitions']){const _0x24e17b=_0x4ac719['transitions'][_0x4b037b],_0x524197={};for(const _0x209ca0 of _0x24e17b){const _0xfe1907=_0x209ca0['to'];_0x209ca0['conditions']?_0x524197[_0xfe1907]=_0x209ca0['conditions']:_0x524197[_0xfe1907]=!![];}Object['keys'](_0x524197)['length']>0x0&&(_0x2e7d34['.'+_0x4b037b]=_0x524197);}}await this['store']['setTransitions'](_0x2e7d34,this['getVID']());}async['deployHookPatterns'](){const _0x1fcd00=this['manifest']['app']['graphs'],_0x3b3566={};for(const _0x50d3ce of _0x1fcd00){if(_0x50d3ce['hooks'])for(const _0x27a2b4 in _0x50d3ce['hooks']){_0x3b3566[_0x27a2b4]=_0x50d3ce['hooks'][_0x27a2b4];const _0x2b3aca=_0x50d3ce['hooks'][_0x27a2b4][0x0]['to'],_0x28fbcb=_0x50d3ce['activities'][_0x2b3aca];_0x28fbcb&&(!_0x28fbcb['hook']&&(_0x28fbcb['hook']={}),_0x28fbcb['hook']['topic']=_0x27a2b4);}}await this['store']['setHookRules'](_0x3b3566);}async['deployConsumerGroups'](){const _0x2454f3={'appId':this['manifest']['app']['id']},_0x2966b0=this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0x2454f3);await this['deployConsumerGroup'](_0x2966b0,'ENGINE');for(const _0x2ec3fc of this['manifest']['app']['graphs']){const _0x1022aa=_0x2ec3fc['activities'];for(const _0x3cf26e in _0x1022aa){const _0x369a90=_0x1022aa[_0x3cf26e];if(_0x369a90['type']==='worker'&&pipe_1['Pipe']['resolve'](_0x369a90['subtype'],{})===_0x369a90['subtype']){_0x2454f3['topic']=_0x369a90['subtype'];const _0x41bc6a=this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0x2454f3);await this['deployConsumerGroup'](_0x41bc6a,'WORKER');}}}}async['deployConsumerGroup'](_0xc6db2,_0x3fef9f){try{await this['stream']['createConsumerGroup'](_0xc6db2,_0x3fef9f);}catch(_0x1ade79){this['store']['logger']['info']('router-stream-group-exists',{'stream':_0xc6db2,'group':_0x3fef9f});}}}exports['Deployer']=Deployer;
1
+ 'use strict';(function(_0x5ecb5c,_0x2bdd7c){const _0x34b0cf=_0x5b5b,_0x124fe1=_0x5ecb5c();while(!![]){try{const _0x43eda6=-parseInt(_0x34b0cf(0x1b6))/0x1+parseInt(_0x34b0cf(0x1bc))/0x2+-parseInt(_0x34b0cf(0x1bd))/0x3+-parseInt(_0x34b0cf(0x1b8))/0x4+parseInt(_0x34b0cf(0x1bb))/0x5*(parseInt(_0x34b0cf(0x1b7))/0x6)+-parseInt(_0x34b0cf(0x1ba))/0x7+parseInt(_0x34b0cf(0x1b9))/0x8;if(_0x43eda6===_0x2bdd7c)break;else _0x124fe1['push'](_0x124fe1['shift']());}catch(_0x4f57a7){_0x124fe1['push'](_0x124fe1['shift']());}}}(_0x445b,0xed9bc));function _0x445b(){const _0x50a13a=['5YfIBaK','222606AsIXxV','3755517ZQrZWo','1587412QhYMhw','11627718TgVVxE','2399884hIuOvA','22252880ALwCiz','2928800dwcpLZ'];_0x445b=function(){return _0x50a13a;};return _0x445b();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['Deployer']=void 0x0;const key_1=require('../../modules/key'),utils_1=require('../../modules/utils'),collator_1=require('../collator'),serializer_1=require('../serializer'),pipe_1=require('../pipe'),validator_1=require('./validator'),DEFAULT_METADATA_RANGE_SIZE=0x1a,DEFAULT_DATA_RANGE_SIZE=0x104,DEFAULT_RANGE_SIZE=DEFAULT_METADATA_RANGE_SIZE+DEFAULT_DATA_RANGE_SIZE;class Deployer{constructor(_0x415613){this['manifest']=null,this['manifest']=_0x415613;}async['deploy'](_0x39e7aa,_0x140594){this['store']=_0x39e7aa,this['stream']=_0x140594,collator_1['CollatorService']['compile'](this['manifest']['app']['graphs']),this['convertActivitiesToHooks'](),this['convertTopicsToTypes'](),this['copyJobSchemas'](),this['bindBackRefs'](),this['bindParents'](),this['bindCycleTarget'](),this['resolveMappingDependencies'](),this['resolveJobMapsPaths'](),await this['generateSymKeys'](),await this['generateSymVals'](),await this['deployHookPatterns'](),await this['deployActivitySchemas'](),await this['deploySubscriptions'](),await this['deployTransitions'](),await this['deployConsumerGroups']();}['getVID'](){return{'id':this['manifest']['app']['id'],'version':this['manifest']['app']['version']};}async['generateSymKeys'](){for(const _0x50f3b7 of this['manifest']['app']['graphs']){const [,_0x1458e3]=this['findTrigger'](_0x50f3b7),_0x3d465d=_0x1458e3['subscribes'],[_0x4dbae4,_0x171937,_0x1c0030]=await this['store']['reserveSymbolRange']('$'+_0x3d465d,DEFAULT_RANGE_SIZE,'JOB'),_0x289786='',_0x891080=this['bindSymbols'](_0x4dbae4,_0x171937,_0x1c0030,_0x289786,_0x1458e3['PRODUCES']);Object['keys'](_0x891080)['length']&&await this['store']['addSymbols']('$'+_0x3d465d,_0x891080);for(const [_0x4f41de,_0x10a2f3]of Object['entries'](_0x50f3b7['activities'])){const [_0x14fbe0,_0x52aa90,_0x627e9a]=await this['store']['reserveSymbolRange'](_0x4f41de,DEFAULT_RANGE_SIZE,'ACTIVITY'),_0x5ac360=_0x4f41de+'/';this['bindSelf'](_0x10a2f3['consumes'],_0x10a2f3['produces'],_0x4f41de);const _0x4f212a=this['bindSymbols'](_0x14fbe0,_0x52aa90,_0x627e9a,_0x5ac360,_0x10a2f3['produces']);Object['keys'](_0x4f212a)['length']&&await this['store']['addSymbols'](_0x4f41de,_0x4f212a);}}}['bindSelf'](_0xee7469,_0x27f0d0,_0x1c52c0){for(const _0x1f9033 of[_0x1c52c0,'$self']){const _0x229d5a=_0xee7469[_0x1f9033];if(_0x229d5a)for(const _0x2f3a83 of _0x229d5a){!_0x27f0d0['includes'](_0x2f3a83)&&_0x27f0d0['push'](_0x2f3a83);}}}['bindSymbols'](_0x521674,_0x3bb6dd,_0x517b17,_0x20c63e,_0x851138){const _0x45d648={},_0x301b16={..._0x517b17};for(const _0x1cfa8f of _0x851138){const _0x483d98=''+_0x20c63e+_0x1cfa8f;if(!_0x301b16[_0x483d98]){if(_0x521674>_0x3bb6dd)throw new Error('Symbol\x20index\x20out\x20of\x20bounds');const _0x166568=(0x0,utils_1['getSymKey'])(_0x521674);_0x521674++,_0x45d648[_0x483d98]=_0x166568,_0x301b16[_0x483d98]=_0x166568;}}return _0x45d648;}['copyJobSchemas'](){const _0x9cc71a=this['manifest']['app']['graphs'];for(const _0x53f45e of _0x9cc71a){const _0x440252=_0x53f45e['output']?.['schema'],_0xfaca63=_0x53f45e['input']?.['schema'];if(!_0x440252&&!_0xfaca63)continue;const _0x14dc1b=_0x53f45e['activities'];for(const _0x229fb3 in _0x14dc1b){if(_0x14dc1b[_0x229fb3]['type']==='trigger'){const _0x479413=_0x14dc1b[_0x229fb3];_0x440252&&(!_0x479413['job']&&(_0x479413['job']={}),_0x479413['job']['schema']=_0x440252),_0xfaca63&&(_0x479413['output']={'schema':_0xfaca63});}}}}['bindBackRefs'](){for(const _0x2d0a73 of this['manifest']['app']['graphs']){const _0x4bde1f=_0x2d0a73['activities'],_0x564a76=this['findTrigger'](_0x2d0a73)[0x0];for(const _0x373173 in _0x4bde1f){_0x4bde1f[_0x373173]['trigger']=_0x564a76,_0x4bde1f[_0x373173]['subscribes']=_0x2d0a73['subscribes'],_0x2d0a73['publishes']&&(_0x4bde1f[_0x373173]['publishes']=_0x2d0a73['publishes']),_0x4bde1f[_0x373173]['expire']=_0x2d0a73['expire']??undefined,_0x4bde1f[_0x373173]['persistent']=_0x2d0a73['persistent']??undefined;}}}['bindCycleTarget'](){for(const _0x43dbc1 of this['manifest']['app']['graphs']){const _0x18245e=_0x43dbc1['activities'];for(const _0x44a80c in _0x18245e){const _0x348765=_0x18245e[_0x44a80c];_0x348765['type']==='cycle'&&(_0x18245e[_0x348765['ancestor']]['cycle']=!![]);}}}['convertTopicsToTypes'](){for(const _0xc71e8 of this['manifest']['app']['graphs']){const _0x49a774=_0xc71e8['activities'];for(const _0x1ce498 in _0x49a774){const _0x48a6b0=_0x49a774[_0x1ce498];['worker','await']['includes'](_0x48a6b0['type'])&&_0x48a6b0['topic']&&!_0x48a6b0['subtype']&&(_0x48a6b0['subtype']=_0x48a6b0['topic']);}}}['convertActivitiesToHooks'](){for(const _0x4c2587 of this['manifest']['app']['graphs']){const _0x503dbe=_0x4c2587['activities'];for(const _0x553284 in _0x503dbe){const _0xe0f248=_0x503dbe[_0x553284];['activity']['includes'](_0xe0f248['type'])&&(_0xe0f248['type']='hook');}}}async['bindParents'](){const _0x4b1599=this['manifest']['app']['graphs'];for(const _0x5b1a70 of _0x4b1599){if(_0x5b1a70['transitions'])for(const _0x3d083f in _0x5b1a70['transitions']){const _0x1ae1f1=_0x5b1a70['transitions'][_0x3d083f];for(const _0x34e40f of _0x1ae1f1){const _0x3d1f51=_0x34e40f['to'];_0x5b1a70['activities'][_0x3d1f51]['parent']=_0x3d083f;}_0x5b1a70['activities'][_0x3d083f]['transitions']=_0x1ae1f1;}}}['collectValues'](_0x4c9a4b,_0x411f6d){for(const [_0x1914c7,_0x145517]of Object['entries'](_0x4c9a4b)){if(_0x1914c7==='enum'||_0x1914c7==='examples'||_0x1914c7==='default'){if(Array['isArray'](_0x145517))for(const _0x37778a of _0x145517){typeof _0x37778a==='string'&&_0x37778a['length']>0x5&&_0x411f6d['add'](_0x37778a);}else typeof _0x145517==='string'&&_0x145517['length']>0x5&&_0x411f6d['add'](_0x145517);}else typeof _0x145517==='object'&&this['collectValues'](_0x145517,_0x411f6d);}}['traverse'](_0x552855,_0x35e3a5){for(const _0x47fbe9 of Object['values'](_0x552855)){typeof _0x47fbe9==='object'&&('schema'in _0x47fbe9?this['collectValues'](_0x47fbe9['schema'],_0x35e3a5):this['traverse'](_0x47fbe9,_0x35e3a5));}}async['generateSymVals'](){const _0x5439eb=new Set();for(const _0x3ff91c of this['manifest']['app']['graphs']){this['traverse'](_0x3ff91c,_0x5439eb);}const _0xf948cf=await this['store']['getSymbolValues'](),_0x2cc417=Object['keys'](_0xf948cf)['length'],_0x23fa14=Math['pow'](0x34,0x2)-0x1,_0x3e32db=serializer_1['SerializerService']['filterSymVals'](_0x2cc417,_0x23fa14,_0xf948cf,_0x5439eb);await this['store']['addSymbolValues'](_0x3e32db);}['resolveJobMapsPaths'](){function _0x53cf3d(_0x490d40){const _0x252eae=[];function _0x4cd3a4(_0x5ddbaa,_0x3daa53=[]){for(const _0x17a6fd in _0x5ddbaa){if(typeof _0x5ddbaa[_0x17a6fd]==='object'&&_0x5ddbaa[_0x17a6fd]!==null&&!('@pipe'in _0x5ddbaa[_0x17a6fd])){const _0xde2eec=[..._0x3daa53,_0x17a6fd];_0x4cd3a4(_0x5ddbaa[_0x17a6fd],_0xde2eec);}else{const _0x38c39e=[..._0x3daa53,_0x17a6fd]['join']('/');if(!_0x38c39e['includes']('[')){const _0x17cd5d='data/'+_0x38c39e;!_0x252eae['includes'](_0x17cd5d)&&_0x252eae['push'](_0x17cd5d);}else{const [_0x2d63b2,_0xdc9a3b]=_0x38c39e['split']('['),[_0x156441,_0x403fe4]=_0xdc9a3b['split'](']');if(!isNaN(parseInt(_0x156441)))for(let _0x34de51=0x0;_0x34de51<parseInt(_0x156441);_0x34de51++){const _0x26c4d5='data/'+_0x2d63b2+'/'+_0x34de51;!_0x252eae['includes'](_0x26c4d5)&&_0x252eae['push'](_0x26c4d5);}}}}}return _0x490d40&&_0x4cd3a4(_0x490d40),_0x252eae;}for(const _0x22d723 of this['manifest']['app']['graphs']){let _0x1d3d47=[];const [,_0x1b4b19]=this['findTrigger'](_0x22d723);for(const _0x458c7c in _0x22d723['activities']){const _0xdcd0aa=_0x22d723['activities'][_0x458c7c];_0x1d3d47=_0x1d3d47['concat'](_0x53cf3d(_0xdcd0aa['job']?.['maps']));}_0x1b4b19['PRODUCES']=_0x1d3d47;}}['resolveMappingDependencies'](){const _0x1ee3db=[];function _0x30be9d(_0x1b0d5c,_0x1e9b77){for(const _0x560590 in _0x1b0d5c){if(typeof _0x1b0d5c[_0x560590]==='string'){const _0x125447=_0x1b0d5c[_0x560590],_0x6520b0=_0x125447['match'](/^\{[^@].*}$/);_0x6520b0&&!validator_1['Validator']['CONTEXT_VARS']['includes'](_0x125447)&&(_0x125447['split']('.')[0x1]!=='input'&&(_0x1ee3db['push'](_0x125447),_0x1e9b77['push'](_0x125447)));}else typeof _0x1b0d5c[_0x560590]==='object'&&_0x1b0d5c[_0x560590]!==null&&_0x30be9d(_0x1b0d5c[_0x560590],_0x1e9b77);}}const _0xe52bbb=this['manifest']['app']['graphs'];for(const _0xf2933f of _0xe52bbb){const _0x22829b=_0xf2933f['activities'];for(const _0xdc40fe in _0x22829b){const _0x21c234=_0x22829b[_0xdc40fe];_0x21c234['consumes']=[],_0x30be9d(_0x21c234,_0x21c234['consumes']),_0x21c234['consumes']=this['groupMappingRules'](_0x21c234['consumes']);}}const _0x16a6af=this['groupMappingRules'](_0x1ee3db);for(const _0x702ae2 of _0xe52bbb){const _0x1eaee8=_0x702ae2['activities'];for(const _0x3f3ff4 in _0x1eaee8){const _0x26b3de=_0x1eaee8[_0x3f3ff4];_0x26b3de['produces']=_0x16a6af[''+_0x3f3ff4]||[];}}}['groupMappingRules'](_0x104cb4){_0x104cb4=Array['from'](new Set(_0x104cb4))['sort']();const _0xe2494f={};for(const _0x104637 of _0x104cb4){const [_0x36ac31,_0x2a15e5]=this['resolveMappableValue'](_0x104637);!_0xe2494f[_0x36ac31]&&(_0xe2494f[_0x36ac31]=[]),_0xe2494f[_0x36ac31]['push'](_0x2a15e5);}return _0xe2494f;}['resolveMappableValue'](_0x56ab22){_0x56ab22=_0x56ab22['substring'](0x1,_0x56ab22['length']-0x1);const _0x335707=_0x56ab22['split']('.');if(_0x335707[0x0]==='$job'){const [_0x4dc206,..._0x9d6234]=_0x335707;return[_0x4dc206,_0x9d6234['join']('/')];}else{const [_0x40c585,_0x20047c,_0x2260c6,..._0x145ea3]=_0x335707,_0x2f2a25={'hook':'hook/data','input':'input/data','output':_0x2260c6==='data'?'output/data':'output/metadata'}[_0x20047c];return[_0x40c585,_0x2f2a25+'/'+_0x145ea3['join']('/')];}}async['deployActivitySchemas'](){const _0x3936f9=this['manifest']['app']['graphs'],_0x4ecfef={};for(const _0x2acde7 of _0x3936f9){const _0xea8f63=_0x2acde7['activities'];for(const _0x2048ff in _0xea8f63){const _0x29c346=_0xea8f63[_0x2048ff];delete _0x29c346['transitions'],_0x4ecfef[_0x2048ff]=_0x29c346;}}await this['store']['setSchemas'](_0x4ecfef,this['getVID']());}async['deploySubscriptions'](){const _0x4a9b9c=this['manifest']['app']['graphs'],_0x4e6b97={};for(const _0x275e4e of _0x4a9b9c){const _0xc36a61=_0x275e4e['activities'],_0x40b306=_0x275e4e['subscribes'];for(const _0x55f66a in _0xc36a61){if(_0xc36a61[_0x55f66a]['type']==='trigger'){_0x4e6b97[_0x40b306]=_0x55f66a;break;}}}await this['store']['setSubscriptions'](_0x4e6b97,this['getVID']());}['findTrigger'](_0x15a832){for(const _0x57d292 in _0x15a832['activities']){const _0x269d99=_0x15a832['activities'][_0x57d292];if(_0x269d99['type']==='trigger')return[_0x57d292,_0x269d99];}return null;}async['deployTransitions'](){const _0x2fe11b=this['manifest']['app']['graphs'],_0x34518a={};for(const _0x5aacf6 of _0x2fe11b){if(_0x5aacf6['subscribes']&&_0x5aacf6['subscribes']['startsWith']('.')){const [_0x49dd50]=this['findTrigger'](_0x5aacf6);_0x49dd50&&(_0x34518a[_0x5aacf6['subscribes']]={[_0x49dd50]:!![]});}if(_0x5aacf6['transitions'])for(const _0x89b9c5 in _0x5aacf6['transitions']){const _0x543a67=_0x5aacf6['transitions'][_0x89b9c5],_0x2bb293={};for(const _0x42402c of _0x543a67){const _0x51cd96=_0x42402c['to'];_0x42402c['conditions']?_0x2bb293[_0x51cd96]=_0x42402c['conditions']:_0x2bb293[_0x51cd96]=!![];}Object['keys'](_0x2bb293)['length']>0x0&&(_0x34518a['.'+_0x89b9c5]=_0x2bb293);}}await this['store']['setTransitions'](_0x34518a,this['getVID']());}async['deployHookPatterns'](){const _0x11ca6d=this['manifest']['app']['graphs'],_0x1ac376={};for(const _0x451e61 of _0x11ca6d){if(_0x451e61['hooks'])for(const _0x899861 in _0x451e61['hooks']){_0x1ac376[_0x899861]=_0x451e61['hooks'][_0x899861];const _0x2edf9d=_0x451e61['hooks'][_0x899861][0x0]['to'],_0x5152f6=_0x451e61['activities'][_0x2edf9d];_0x5152f6&&(!_0x5152f6['hook']&&(_0x5152f6['hook']={}),_0x5152f6['hook']['topic']=_0x899861);}}await this['store']['setHookRules'](_0x1ac376);}async['deployConsumerGroups'](){const _0x10550d={'appId':this['manifest']['app']['id']},_0x11ee4d=this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0x10550d);await this['deployConsumerGroup'](_0x11ee4d,'ENGINE');for(const _0x23b773 of this['manifest']['app']['graphs']){const _0x32710c=_0x23b773['activities'];for(const _0x28954d in _0x32710c){const _0x2b22f3=_0x32710c[_0x28954d];if(_0x2b22f3['type']==='worker'&&pipe_1['Pipe']['resolve'](_0x2b22f3['subtype'],{})===_0x2b22f3['subtype']){_0x10550d['topic']=_0x2b22f3['subtype'];const _0x4f44c6=this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0x10550d);await this['deployConsumerGroup'](_0x4f44c6,'WORKER');}}}}async['deployConsumerGroup'](_0x24a074,_0x213a32){try{await this['stream']['createConsumerGroup'](_0x24a074,_0x213a32);}catch(_0x3681f1){this['store']['logger']['info']('router-stream-group-exists',{'stream':_0x24a074,'group':_0x213a32});}}}function _0x5b5b(_0xb600f6,_0x21ce69){const _0x445bbd=_0x445b();return _0x5b5b=function(_0x5b5bd1,_0x45d748){_0x5b5bd1=_0x5b5bd1-0x1b6;let _0x10ea24=_0x445bbd[_0x5b5bd1];return _0x10ea24;},_0x5b5b(_0xb600f6,_0x21ce69);}exports['Deployer']=Deployer;
@@ -1 +1 @@
1
- 'use strict';(function(_0x4c475c,_0x3ee2b0){const _0x1ac86f=_0x2d56,_0xfea318=_0x4c475c();while(!![]){try{const _0x4a222e=parseInt(_0x1ac86f(0x109))/0x1*(-parseInt(_0x1ac86f(0x101))/0x2)+parseInt(_0x1ac86f(0x103))/0x3*(parseInt(_0x1ac86f(0x104))/0x4)+-parseInt(_0x1ac86f(0x108))/0x5*(parseInt(_0x1ac86f(0x100))/0x6)+parseInt(_0x1ac86f(0xff))/0x7+-parseInt(_0x1ac86f(0x105))/0x8+-parseInt(_0x1ac86f(0x102))/0x9+-parseInt(_0x1ac86f(0x106))/0xa*(-parseInt(_0x1ac86f(0x107))/0xb);if(_0x4a222e===_0x3ee2b0)break;else _0xfea318['push'](_0xfea318['shift']());}catch(_0x5b5951){_0xfea318['push'](_0xfea318['shift']());}}}(_0x198a,0x8dd28));var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0x46d1bb,_0xda5c60,_0x52859d,_0x35dbb4){if(_0x35dbb4===undefined)_0x35dbb4=_0x52859d;var _0x5566e5=Object['getOwnPropertyDescriptor'](_0xda5c60,_0x52859d);(!_0x5566e5||('get'in _0x5566e5?!_0xda5c60['__esModule']:_0x5566e5['writable']||_0x5566e5['configurable']))&&(_0x5566e5={'enumerable':!![],'get':function(){return _0xda5c60[_0x52859d];}}),Object['defineProperty'](_0x46d1bb,_0x35dbb4,_0x5566e5);}:function(_0xfb49e0,_0x48831d,_0x56dc47,_0x2d5654){if(_0x2d5654===undefined)_0x2d5654=_0x56dc47;_0xfb49e0[_0x2d5654]=_0x48831d[_0x56dc47];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object['create']?function(_0x454ff4,_0x56a4ad){Object['defineProperty'](_0x454ff4,'default',{'enumerable':!![],'value':_0x56a4ad});}:function(_0x4c63f0,_0x2b9893){_0x4c63f0['default']=_0x2b9893;}),__importStar=this&&this['__importStar']||function(_0x46d158){if(_0x46d158&&_0x46d158['__esModule'])return _0x46d158;var _0x200332={};if(_0x46d158!=null){for(var _0x59a08a in _0x46d158)if(_0x59a08a!=='default'&&Object['prototype']['hasOwnProperty']['call'](_0x46d158,_0x59a08a))__createBinding(_0x200332,_0x46d158,_0x59a08a);}return __setModuleDefault(_0x200332,_0x46d158),_0x200332;},__importDefault=this&&this['__importDefault']||function(_0x5e247c){return _0x5e247c&&_0x5e247c['__esModule']?_0x5e247c:{'default':_0x5e247c};};Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['CompilerService']=void 0x0;const fs=__importStar(require('fs/promises')),path=__importStar(require('path')),json_schema_ref_parser_1=__importDefault(require('@apidevtools/json-schema-ref-parser')),js_yaml_1=__importDefault(require('js-yaml')),deployer_1=require('./deployer'),validator_1=require('./validator');function _0x2d56(_0x3fc864,_0x747f55){const _0x198ae5=_0x198a();return _0x2d56=function(_0x2d56f9,_0x48ec95){_0x2d56f9=_0x2d56f9-0xff;let _0x2de5ef=_0x198ae5[_0x2d56f9];return _0x2de5ef;},_0x2d56(_0x3fc864,_0x747f55);}class CompilerService{constructor(_0x4bb220,_0x171019,_0xe6fe4c){this['store']=_0x4bb220,this['stream']=_0x171019,this['logger']=_0xe6fe4c;}async['plan'](_0x34b588){try{let _0x2230c9;this['isPath'](_0x34b588)?_0x2230c9=await json_schema_ref_parser_1['default']['dereference'](_0x34b588):_0x2230c9=js_yaml_1['default']['load'](_0x34b588);const _0x50dfc8=new validator_1['Validator'](_0x2230c9);return _0x50dfc8['validate'](this['store']),_0x2230c9;}catch(_0xeeae7d){this['logger']['error']('compiler-plan-error',_0xeeae7d);}}['isPath'](_0x54f6f0){return!_0x54f6f0['trim']()['startsWith']('app:');}async['deploy'](_0x3c8866){try{let _0x435bed;this['isPath'](_0x3c8866)?(_0x435bed=await json_schema_ref_parser_1['default']['dereference'](_0x3c8866),await this['saveAsJSON'](_0x3c8866,_0x435bed)):_0x435bed=js_yaml_1['default']['load'](_0x3c8866);const _0x42eb53=new validator_1['Validator'](_0x435bed);_0x42eb53['validate'](this['store']);const _0x145b41=new deployer_1['Deployer'](_0x435bed);return await _0x145b41['deploy'](this['store'],this['stream']),await this['store']['setApp'](_0x435bed['app']['id'],_0x435bed['app']['version']),_0x435bed;}catch(_0x156b73){this['logger']['error']('compiler-deploy-error',_0x156b73);}}async['activate'](_0x2c382e,_0x4fb0ac){return await this['store']['activateAppVersion'](_0x2c382e,_0x4fb0ac);}async['saveAsJSON'](_0x49a8ae,_0x3914ed){const _0x584da4=JSON['stringify'](_0x3914ed,null,0x2),_0x13f63a=path['join'](path['dirname'](_0x49a8ae),'.hotmesh.'+_0x3914ed['app']['id']+'.'+_0x3914ed['app']['version']+'.json');await fs['writeFile'](_0x13f63a,_0x584da4,'utf8');}}exports['CompilerService']=CompilerService;function _0x198a(){const _0x8ea37f=['9btctXy','692152QwmmoE','7100768gkIznY','4281470yUatnq','66iJTylw','113480QLbvMn','379UpsEOl','6547093MTuJro','132QgZCpn','5340aWAwMD','9391977ENaShq'];_0x198a=function(){return _0x8ea37f;};return _0x198a();}
1
+ 'use strict';(function(_0x1952fe,_0x369d02){const _0x131048=_0x3d65,_0x1a3d84=_0x1952fe();while(!![]){try{const _0x11fc66=parseInt(_0x131048(0xa8))/0x1*(-parseInt(_0x131048(0xaa))/0x2)+-parseInt(_0x131048(0xa3))/0x3*(parseInt(_0x131048(0xa5))/0x4)+-parseInt(_0x131048(0xa2))/0x5*(-parseInt(_0x131048(0xac))/0x6)+parseInt(_0x131048(0xa4))/0x7*(-parseInt(_0x131048(0xa6))/0x8)+parseInt(_0x131048(0xa7))/0x9+parseInt(_0x131048(0xab))/0xa+-parseInt(_0x131048(0xa9))/0xb;if(_0x11fc66===_0x369d02)break;else _0x1a3d84['push'](_0x1a3d84['shift']());}catch(_0x353d11){_0x1a3d84['push'](_0x1a3d84['shift']());}}}(_0x555e,0xa3973));function _0x3d65(_0x5c7b67,_0x1fa3c5){const _0x555e84=_0x555e();return _0x3d65=function(_0x3d6517,_0x2fd6a2){_0x3d6517=_0x3d6517-0xa2;let _0xa2535f=_0x555e84[_0x3d6517];return _0xa2535f;},_0x3d65(_0x5c7b67,_0x1fa3c5);}var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0x361e29,_0x1d5b08,_0x40f37f,_0x5aef31){if(_0x5aef31===undefined)_0x5aef31=_0x40f37f;var _0x1fe717=Object['getOwnPropertyDescriptor'](_0x1d5b08,_0x40f37f);(!_0x1fe717||('get'in _0x1fe717?!_0x1d5b08['__esModule']:_0x1fe717['writable']||_0x1fe717['configurable']))&&(_0x1fe717={'enumerable':!![],'get':function(){return _0x1d5b08[_0x40f37f];}}),Object['defineProperty'](_0x361e29,_0x5aef31,_0x1fe717);}:function(_0x2f664c,_0x33ea38,_0x2ac054,_0x107a6a){if(_0x107a6a===undefined)_0x107a6a=_0x2ac054;_0x2f664c[_0x107a6a]=_0x33ea38[_0x2ac054];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object['create']?function(_0x3f8008,_0x4bccb3){Object['defineProperty'](_0x3f8008,'default',{'enumerable':!![],'value':_0x4bccb3});}:function(_0x4cf934,_0x742770){_0x4cf934['default']=_0x742770;}),__importStar=this&&this['__importStar']||function(_0x27461b){if(_0x27461b&&_0x27461b['__esModule'])return _0x27461b;var _0x1f39d6={};if(_0x27461b!=null){for(var _0x5e66a6 in _0x27461b)if(_0x5e66a6!=='default'&&Object['prototype']['hasOwnProperty']['call'](_0x27461b,_0x5e66a6))__createBinding(_0x1f39d6,_0x27461b,_0x5e66a6);}return __setModuleDefault(_0x1f39d6,_0x27461b),_0x1f39d6;},__importDefault=this&&this['__importDefault']||function(_0x278f57){return _0x278f57&&_0x278f57['__esModule']?_0x278f57:{'default':_0x278f57};};function _0x555e(){const _0x625948=['18857476OeJKyD','15102iEOBbZ','12442800YOSvcc','3516RHGaLo','9710lvcpZG','13128FQLCEv','50218pyVXLY','680mhewOY','376QVexzW','11787471Taneop','30VtIDqG'];_0x555e=function(){return _0x625948;};return _0x555e();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['CompilerService']=void 0x0;const fs=__importStar(require('fs/promises')),path=__importStar(require('path')),json_schema_ref_parser_1=__importDefault(require('@apidevtools/json-schema-ref-parser')),js_yaml_1=__importDefault(require('js-yaml')),deployer_1=require('./deployer'),validator_1=require('./validator');class CompilerService{constructor(_0x495f79,_0x4e9fdb,_0x3a111f){this['store']=_0x495f79,this['stream']=_0x4e9fdb,this['logger']=_0x3a111f;}async['plan'](_0x463114){try{let _0x59318c;this['isPath'](_0x463114)?_0x59318c=await json_schema_ref_parser_1['default']['dereference'](_0x463114):_0x59318c=js_yaml_1['default']['load'](_0x463114);const _0x245ef3=new validator_1['Validator'](_0x59318c);return _0x245ef3['validate'](this['store']),_0x59318c;}catch(_0x24d11c){this['logger']['error']('compiler-plan-error',_0x24d11c);}}['isPath'](_0x2ddf92){return!_0x2ddf92['trim']()['startsWith']('app:');}async['deploy'](_0x1b7f66){try{let _0x54ed68;this['isPath'](_0x1b7f66)?(_0x54ed68=await json_schema_ref_parser_1['default']['dereference'](_0x1b7f66),await this['saveAsJSON'](_0x1b7f66,_0x54ed68)):_0x54ed68=js_yaml_1['default']['load'](_0x1b7f66);const _0x5cf06b=new validator_1['Validator'](_0x54ed68);_0x5cf06b['validate'](this['store']);const _0x1bf334=new deployer_1['Deployer'](_0x54ed68);return await _0x1bf334['deploy'](this['store'],this['stream']),await this['store']['setApp'](_0x54ed68['app']['id'],_0x54ed68['app']['version']),_0x54ed68;}catch(_0x30c8f3){this['logger']['error']('compiler-deploy-error',_0x30c8f3);}}async['activate'](_0x508fe2,_0x206661){return await this['store']['activateAppVersion'](_0x508fe2,_0x206661);}async['saveAsJSON'](_0x5ed9bf,_0x27192d){const _0x4d4241=JSON['stringify'](_0x27192d,null,0x2),_0x2852cf=path['join'](path['dirname'](_0x5ed9bf),'.hotmesh.'+_0x27192d['app']['id']+'.'+_0x27192d['app']['version']+'.json');await fs['writeFile'](_0x2852cf,_0x4d4241,'utf8');}}exports['CompilerService']=CompilerService;
@@ -1 +1 @@
1
- 'use strict';(function(_0x4cf40f,_0xf828db){const _0x2220bf=_0x58d3,_0x4be5d3=_0x4cf40f();while(!![]){try{const _0x3dbff8=-parseInt(_0x2220bf(0x190))/0x1+-parseInt(_0x2220bf(0x186))/0x2*(parseInt(_0x2220bf(0x185))/0x3)+parseInt(_0x2220bf(0x187))/0x4*(-parseInt(_0x2220bf(0x18f))/0x5)+parseInt(_0x2220bf(0x188))/0x6*(parseInt(_0x2220bf(0x18b))/0x7)+-parseInt(_0x2220bf(0x18a))/0x8*(-parseInt(_0x2220bf(0x18c))/0x9)+-parseInt(_0x2220bf(0x189))/0xa*(parseInt(_0x2220bf(0x18d))/0xb)+parseInt(_0x2220bf(0x18e))/0xc;if(_0x3dbff8===_0xf828db)break;else _0x4be5d3['push'](_0x4be5d3['shift']());}catch(_0x14708e){_0x4be5d3['push'](_0x4be5d3['shift']());}}}(_0x2e01,0xcaddc));function _0x58d3(_0x1903bf,_0x11390d){const _0x2e0137=_0x2e01();return _0x58d3=function(_0x58d3e5,_0x328342){_0x58d3e5=_0x58d3e5-0x185;let _0xa550b9=_0x2e0137[_0x58d3e5];return _0xa550b9;},_0x58d3(_0x1903bf,_0x11390d);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['Validator']=void 0x0;const pipe_1=require('../pipe');class Validator{constructor(_0xa6f431){this['manifest']=null,this['activityIds']=[],this['mappingStatements']={},this['store']=null,this['manifest']=_0xa6f431;}async['validate'](_0x510a27){this['store']=_0x510a27,this['getMappingStatements'](),this['validateActivityIds'](),this['validateReferencedActivityIds'](),this['validateMappingStatements'](),this['validateTransitions'](),this['validateTransitionConditions'](),this['validateStats'](),this['validateSchemas'](),this['validateUniqueHandledTopics'](),this['validateGraphPublishSubscribe'](),this['validateHooks'](),this['validateConditionalStatements']();}['validateActivityIds'](){const _0x29cf9a=new Set();this['manifest']['app']['graphs']['forEach'](_0x1a40c0=>{const _0x41e125=Object['keys'](_0x1a40c0['activities']);_0x41e125['forEach'](_0x56f64f=>{if(_0x29cf9a['has'](_0x56f64f))throw new Error('Duplicate\x20activity\x20id\x20found:\x20'+_0x56f64f);else _0x29cf9a['add'](_0x56f64f);});}),this['activityIds']=Array['from'](_0x29cf9a);}['isMappingStatement'](_0x24fd86){return typeof _0x24fd86==='string'&&_0x24fd86['startsWith']('{')&&_0x24fd86['endsWith']('}');}['extractMappingStatements'](_0x54bb2c,_0x21c266,_0x191c51){for(const _0x30a465 in _0x54bb2c){if(typeof _0x54bb2c[_0x30a465]==='object'&&_0x54bb2c[_0x30a465]!==null)this['extractMappingStatements'](_0x54bb2c[_0x30a465],_0x21c266,_0x191c51);else this['isMappingStatement'](_0x54bb2c[_0x30a465])&&(!_0x21c266[_0x191c51]&&(_0x21c266[_0x191c51]=[]),_0x21c266[_0x191c51]['push'](_0x54bb2c[_0x30a465]));}}['getMappingStatements'](){const _0x484ce1={};this['manifest']['app']['graphs']['forEach'](_0x4764a9=>{const _0x18616a=_0x4764a9['activities'];for(const _0x59a2b3 in _0x18616a){const _0xcf3000=_0x18616a[_0x59a2b3];this['extractMappingStatements'](_0xcf3000,_0x484ce1,_0x59a2b3);}}),this['mappingStatements']=_0x484ce1;}['validateReferencedActivityIds'](){const _0x441a7f=this['mappingStatements'],_0x1aebe4=this['activityIds'];for(const _0x41f91d in _0x441a7f){const _0x14a806=_0x441a7f[_0x41f91d];_0x14a806['forEach'](_0x3a4536=>{if(_0x3a4536['startsWith']('{')&&_0x3a4536['endsWith']('}')){const _0x10d5ff=_0x3a4536['slice'](0x1,-0x1)['split']('.'),_0x6685d9=_0x10d5ff[0x0];if(!(Validator['SYS_VARS']['includes'](_0x6685d9)||_0x1aebe4['includes'](_0x6685d9)||this['isFunction'](_0x3a4536)||this['isContextVariable'](_0x3a4536)))throw new Error('Mapping\x20statement\x20references\x20non-existent\x20activity:\x20'+_0x3a4536);}});}}['isFunction'](_0x20b07b){return _0x20b07b['startsWith']('{@')&&pipe_1['Pipe']['resolveFunction'](_0x20b07b);}['isContextVariable'](_0x3a00c4){return['{$input}','{$output}','{$item}','{$key}','{$index}']['includes'](_0x3a00c4);}['validateMappingStatements'](){}['validateTransitions'](){}['validateTransitionConditions'](){}['validateStats'](){}['validateSchemas'](){}['validateUniqueHandledTopics'](){}['validateGraphPublishSubscribe'](){}['validateHooks'](){}['validateConditionalStatements'](){}}exports['Validator']=Validator,Validator['SYS_VARS']=['$app','$self','$graph','$job'],Validator['CONTEXT_VARS']=['{$input}','{$output}','{$item}','{$key}','{$index}'];function _0x2e01(){const _0x34570a=['2663234qGmQNR','17973jGVxmZ','267839xUBigP','16281888VYnghN','90ZmRmSN','872274pOiRWY','3oWtwTe','6126VoNatE','187544OdIiuw','24yMPJqx','180uoxLwq','440bLDyxh'];_0x2e01=function(){return _0x34570a;};return _0x2e01();}
1
+ 'use strict';(function(_0x5e236a,_0x1185f3){const _0x51374d=_0x3ff5,_0xcb520f=_0x5e236a();while(!![]){try{const _0x1009bf=-parseInt(_0x51374d(0x9a))/0x1*(parseInt(_0x51374d(0x92))/0x2)+-parseInt(_0x51374d(0x96))/0x3*(-parseInt(_0x51374d(0x97))/0x4)+-parseInt(_0x51374d(0x98))/0x5+parseInt(_0x51374d(0x93))/0x6+parseInt(_0x51374d(0x99))/0x7+parseInt(_0x51374d(0x95))/0x8*(-parseInt(_0x51374d(0x94))/0x9)+-parseInt(_0x51374d(0x91))/0xa;if(_0x1009bf===_0x1185f3)break;else _0xcb520f['push'](_0xcb520f['shift']());}catch(_0x5b5f39){_0xcb520f['push'](_0xcb520f['shift']());}}}(_0x1315,0xe5f50));function _0x3ff5(_0x97cbdf,_0x59969f){const _0x13152d=_0x1315();return _0x3ff5=function(_0x3ff5d8,_0x380e19){_0x3ff5d8=_0x3ff5d8-0x91;let _0x3b38aa=_0x13152d[_0x3ff5d8];return _0x3b38aa;},_0x3ff5(_0x97cbdf,_0x59969f);}function _0x1315(){const _0x808293=['573623pYRqeN','1558260MzuFmw','6sthnun','5261268GvBAAV','7524513FIDQwX','8lzzmSR','320442xlSfHf','56BKYMfu','1275830ZtCraM','10762836tCsHZJ'];_0x1315=function(){return _0x808293;};return _0x1315();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['Validator']=void 0x0;const pipe_1=require('../pipe');class Validator{constructor(_0x4ad6d3){this['manifest']=null,this['activityIds']=[],this['mappingStatements']={},this['store']=null,this['manifest']=_0x4ad6d3;}async['validate'](_0x34339a){this['store']=_0x34339a,this['getMappingStatements'](),this['validateActivityIds'](),this['validateReferencedActivityIds'](),this['validateMappingStatements'](),this['validateTransitions'](),this['validateTransitionConditions'](),this['validateStats'](),this['validateSchemas'](),this['validateUniqueHandledTopics'](),this['validateGraphPublishSubscribe'](),this['validateHooks'](),this['validateConditionalStatements']();}['validateActivityIds'](){const _0x49615f=new Set();this['manifest']['app']['graphs']['forEach'](_0x53f9d9=>{const _0x5d1559=Object['keys'](_0x53f9d9['activities']);_0x5d1559['forEach'](_0x1b08e6=>{if(_0x49615f['has'](_0x1b08e6))throw new Error('Duplicate\x20activity\x20id\x20found:\x20'+_0x1b08e6);else _0x49615f['add'](_0x1b08e6);});}),this['activityIds']=Array['from'](_0x49615f);}['isMappingStatement'](_0x409abd){return typeof _0x409abd==='string'&&_0x409abd['startsWith']('{')&&_0x409abd['endsWith']('}');}['extractMappingStatements'](_0x5dd0c9,_0x4cfad5,_0x2a1de8){for(const _0x1fb87c in _0x5dd0c9){if(typeof _0x5dd0c9[_0x1fb87c]==='object'&&_0x5dd0c9[_0x1fb87c]!==null)this['extractMappingStatements'](_0x5dd0c9[_0x1fb87c],_0x4cfad5,_0x2a1de8);else this['isMappingStatement'](_0x5dd0c9[_0x1fb87c])&&(!_0x4cfad5[_0x2a1de8]&&(_0x4cfad5[_0x2a1de8]=[]),_0x4cfad5[_0x2a1de8]['push'](_0x5dd0c9[_0x1fb87c]));}}['getMappingStatements'](){const _0x3f2ef8={};this['manifest']['app']['graphs']['forEach'](_0x4c0291=>{const _0x13bb71=_0x4c0291['activities'];for(const _0xa58f39 in _0x13bb71){const _0x365190=_0x13bb71[_0xa58f39];this['extractMappingStatements'](_0x365190,_0x3f2ef8,_0xa58f39);}}),this['mappingStatements']=_0x3f2ef8;}['validateReferencedActivityIds'](){const _0x34bff7=this['mappingStatements'],_0x21d24e=this['activityIds'];for(const _0x4fd030 in _0x34bff7){const _0x3d815f=_0x34bff7[_0x4fd030];_0x3d815f['forEach'](_0x350fd9=>{if(_0x350fd9['startsWith']('{')&&_0x350fd9['endsWith']('}')){const _0x4fc1e1=_0x350fd9['slice'](0x1,-0x1)['split']('.'),_0xc59c1e=_0x4fc1e1[0x0];if(!(Validator['SYS_VARS']['includes'](_0xc59c1e)||_0x21d24e['includes'](_0xc59c1e)||this['isFunction'](_0x350fd9)||this['isContextVariable'](_0x350fd9)))throw new Error('Mapping\x20statement\x20references\x20non-existent\x20activity:\x20'+_0x350fd9);}});}}['isFunction'](_0x12a810){return _0x12a810['startsWith']('{@')&&pipe_1['Pipe']['resolveFunction'](_0x12a810);}['isContextVariable'](_0x413410){return['{$input}','{$output}','{$item}','{$key}','{$index}']['includes'](_0x413410);}['validateMappingStatements'](){}['validateTransitions'](){}['validateTransitionConditions'](){}['validateStats'](){}['validateSchemas'](){}['validateUniqueHandledTopics'](){}['validateGraphPublishSubscribe'](){}['validateHooks'](){}['validateConditionalStatements'](){}}exports['Validator']=Validator,Validator['SYS_VARS']=['$app','$self','$graph','$job'],Validator['CONTEXT_VARS']=['{$input}','{$output}','{$item}','{$key}','{$index}'];
@@ -1,6 +1,7 @@
1
1
  import { HotMeshEngine, HotMeshWorker } from '../../types/hotmesh';
2
2
  import { ProviderConfig, ProviderNativeClient } from '../../types/provider';
3
3
  export declare class ConnectorService {
4
+ static disconnectAll(): Promise<void>;
4
5
  static connectClient(ProviderConfig: ProviderConfig): Promise<ProviderNativeClient>;
5
6
  static initClients(target: HotMeshEngine | HotMeshWorker): Promise<void>;
6
7
  static initClient(ProviderConfig: ProviderConfig, target: HotMeshEngine | HotMeshWorker, field: string): Promise<void>;
@@ -7,6 +7,13 @@ const nats_1 = require("./providers/nats");
7
7
  const postgres_1 = require("./providers/postgres");
8
8
  const redis_1 = require("./providers/redis");
9
9
  class ConnectorService {
10
+ static async disconnectAll() {
11
+ await redis_1.RedisConnection.disconnectAll();
12
+ await ioredis_1.RedisConnection.disconnectAll();
13
+ await postgres_1.PostgresConnection.disconnectAll();
14
+ await nats_1.NatsConnection.disconnectAll();
15
+ }
16
+ ;
10
17
  static async connectClient(ProviderConfig) {
11
18
  const target = {};
12
19
  await ConnectorService.initClient(ProviderConfig, target, 'client');
@@ -30,20 +37,12 @@ class ConnectorService {
30
37
  }
31
38
  if (connections.sub) {
32
39
  await ConnectorService.initClient(connections.sub, target, 'sub');
33
- if (connections.sub.class === connections.store.class) {
34
- connections.pub = {
35
- class: connections.store.class,
36
- options: { ...connections.store.options },
37
- };
38
- target.pub = target.store;
39
- }
40
- else {
41
- connections.pub = {
42
- class: connections.sub.class,
43
- options: { ...connections.sub.options },
44
- };
45
- await ConnectorService.initClient(connections.pub, target, 'pub');
46
- }
40
+ connections.pub = {
41
+ class: connections.sub.class,
42
+ options: { ...connections.sub.options },
43
+ provider: connections.sub.provider,
44
+ };
45
+ await ConnectorService.initClient(connections.pub, target, 'pub');
47
46
  }
48
47
  }
49
48
  static async initClient(ProviderConfig, target, field) {
@@ -52,24 +51,26 @@ class ConnectorService {
52
51
  }
53
52
  const providerClass = ProviderConfig.class;
54
53
  const options = ProviderConfig.options;
55
- const providerName = (0, utils_1.identifyProvider)(providerClass);
54
+ const providerName = ProviderConfig.provider || (0, utils_1.identifyProvider)(providerClass);
55
+ const providerType = providerName.split('.')[0];
56
56
  let clientInstance;
57
57
  const id = (0, utils_1.guid)();
58
- switch (providerName) {
58
+ switch (providerType) {
59
59
  case 'redis':
60
- clientInstance = await redis_1.RedisConnection.connect(id, providerClass, options);
60
+ clientInstance = await redis_1.RedisConnection.connect(id, providerClass, options, { provider: providerName });
61
61
  break;
62
62
  case 'ioredis':
63
- clientInstance = await ioredis_1.RedisConnection.connect(id, providerClass, options);
63
+ clientInstance = await ioredis_1.RedisConnection.connect(id, providerClass, options, { provider: providerName });
64
64
  break;
65
65
  case 'nats':
66
- clientInstance = await nats_1.NatsConnection.connect(id, providerClass, options);
66
+ clientInstance = await nats_1.NatsConnection.connect(id, providerClass, options, { provider: providerName });
67
67
  break;
68
68
  case 'postgres':
69
- clientInstance = await postgres_1.PostgresConnection.connect(id, providerClass, options);
69
+ const bAutoConnect = field === 'sub';
70
+ clientInstance = await postgres_1.PostgresConnection.connect(id, providerClass, options, { connect: bAutoConnect, provider: providerName });
70
71
  break;
71
72
  default:
72
- throw new Error(`Unknown provider class: ${providerName}`);
73
+ throw new Error(`Unknown provider type: ${providerType}`);
73
74
  }
74
75
  target[field] = clientInstance.getClient();
75
76
  }
@@ -1,16 +1,18 @@
1
+ import { StringAnyType } from '../../types';
1
2
  import { ProviderClass, ProviderNativeClient, ProviderOptions } from '../../types/provider';
2
3
  import { ILogger } from '../logger';
3
4
  declare abstract class AbstractConnection<PClass, POptions> {
4
5
  static logger: ILogger;
6
+ static disconnecting: boolean;
5
7
  protected connection: any | null;
6
8
  protected static instances: Map<string, AbstractConnection<ProviderClass, ProviderOptions>>;
7
9
  protected id: string | null;
8
10
  protected abstract defaultOptions: any;
9
- protected abstract createConnection(client: PClass, options: POptions): Promise<any>;
11
+ protected abstract createConnection(client: PClass, options: POptions, config?: StringAnyType): Promise<any>;
10
12
  abstract getClient(): ProviderNativeClient;
11
13
  disconnect(): Promise<void>;
12
14
  protected abstract closeConnection(connection: any): Promise<void>;
13
- static connect<T extends AbstractConnection<ProviderClass, ProviderOptions>>(this: new () => T, id: string, client: ProviderClass, options?: ProviderOptions): Promise<T>;
15
+ static connect<T extends AbstractConnection<ProviderClass, ProviderOptions>>(this: new () => T, id: string, client: ProviderClass, options?: ProviderOptions, config?: StringAnyType): Promise<T>;
14
16
  static disconnectAll(): Promise<void>;
15
17
  }
16
18
  export { AbstractConnection };
@@ -16,22 +16,27 @@ class AbstractConnection {
16
16
  AbstractConnection.instances.delete(this.id);
17
17
  }
18
18
  }
19
- static async connect(id, client, options) {
19
+ static async connect(id, client, options, config) {
20
20
  if (AbstractConnection.instances.has(id)) {
21
21
  return AbstractConnection.instances.get(id);
22
22
  }
23
23
  const instance = new this();
24
24
  const opts = options ? { ...options } : { ...instance.defaultOptions };
25
- instance.connection = await instance.createConnection(client, opts);
25
+ instance.connection = await instance.createConnection(client, opts, config);
26
26
  instance.id = id;
27
27
  AbstractConnection.instances.set(id, instance);
28
28
  return instance;
29
29
  }
30
30
  static async disconnectAll() {
31
- await Promise.all(Array.from(this.instances.values()).map((instance) => instance.disconnect()));
32
- this.instances.clear();
31
+ if (!this.disconnecting) {
32
+ this.disconnecting = true;
33
+ await Promise.all(Array.from(this.instances.values()).map((instance) => instance.disconnect()));
34
+ this.instances.clear();
35
+ this.disconnecting = false;
36
+ }
33
37
  }
34
38
  }
35
39
  exports.AbstractConnection = AbstractConnection;
36
- AbstractConnection.logger = new logger_1.LoggerService('hotmesh', 'meshos');
40
+ AbstractConnection.logger = new logger_1.LoggerService('hotmesh', 'system');
41
+ AbstractConnection.disconnecting = false;
37
42
  AbstractConnection.instances = new Map();
@@ -1,9 +1,20 @@
1
1
  import { AbstractConnection } from '..';
2
- import { PostgresClientOptions, PostgresClientType, PostgresClassType } from '../../../types/postgres';
2
+ import { PostgresClientOptions, PostgresClientType, PostgresClassType, PostgresPoolClientType } from '../../../types/postgres';
3
3
  declare class PostgresConnection extends AbstractConnection<PostgresClassType, PostgresClientOptions> {
4
4
  defaultOptions: PostgresClientOptions;
5
- createConnection(clientConstructor: any, options: PostgresClientOptions): Promise<PostgresClientType>;
5
+ protected static poolClientInstances: Set<PostgresPoolClientType>;
6
+ protected static connectionInstances: Set<PostgresClientType>;
7
+ poolClientInstance: PostgresPoolClientType;
8
+ createConnection(clientConstructor: any, options: PostgresClientOptions, config?: {
9
+ connect?: boolean;
10
+ provider?: string;
11
+ }): Promise<PostgresClientType>;
6
12
  getClient(): PostgresClientType;
13
+ static disconnectAll(): Promise<void>;
14
+ static disconnectPoolClients(): Promise<void>;
15
+ static disconnectConnections(): Promise<void>;
7
16
  closeConnection(connection: PostgresClientType): Promise<void>;
17
+ static isPoolClient(client: any): client is PostgresPoolClientType;
18
+ static getTransactionClient(transactionClient: any): Promise<[('client' | 'poolclient'), PostgresClientType]>;
8
19
  }
9
20
  export { PostgresConnection };
@@ -15,11 +15,23 @@ class PostgresConnection extends __1.AbstractConnection {
15
15
  idleTimeoutMillis: 30000,
16
16
  };
17
17
  }
18
- async createConnection(clientConstructor, options) {
19
- const connection = new clientConstructor(options);
18
+ async createConnection(clientConstructor, options, config = {}) {
20
19
  try {
21
- await connection.connect();
22
- await connection.query('SELECT 1');
20
+ let connection;
21
+ if (config.provider === 'postgres.poolclient' || PostgresConnection.isPoolClient(clientConstructor)) {
22
+ connection = clientConstructor;
23
+ if (config.connect) {
24
+ const client = await clientConstructor.connect();
25
+ PostgresConnection.poolClientInstances.add(client);
26
+ this.poolClientInstance = client;
27
+ }
28
+ }
29
+ else {
30
+ connection = new clientConstructor(options);
31
+ await connection.connect();
32
+ await connection.query('SELECT 1');
33
+ }
34
+ PostgresConnection.connectionInstances.add(connection);
23
35
  return connection;
24
36
  }
25
37
  catch (error) {
@@ -35,14 +47,47 @@ class PostgresConnection extends __1.AbstractConnection {
35
47
  if (!this.connection) {
36
48
  throw new Error('Postgres client is not connected');
37
49
  }
38
- return this.connection;
50
+ return this.poolClientInstance || this.connection;
51
+ }
52
+ static async disconnectAll() {
53
+ if (!this.disconnecting) {
54
+ this.disconnecting = true;
55
+ await this.disconnectPoolClients();
56
+ await this.disconnectConnections();
57
+ this.disconnecting = false;
58
+ }
59
+ }
60
+ static async disconnectPoolClients() {
61
+ Array.from(this.poolClientInstances.values()).map((instance) => {
62
+ instance.release();
63
+ });
64
+ this.poolClientInstances.clear();
65
+ }
66
+ static async disconnectConnections() {
67
+ Array.from(this.connectionInstances.values()).map((instance) => {
68
+ instance.end();
69
+ });
70
+ this.connectionInstances.clear();
39
71
  }
40
72
  async closeConnection(connection) {
41
- if (!connection) {
42
- PostgresConnection.logger.warn(`postgres-not-connected-cannot-close`);
43
- return;
73
+ }
74
+ static isPoolClient(client) {
75
+ return !(isNaN(client?.totalCount) && isNaN(client?.idleCount));
76
+ }
77
+ static async getTransactionClient(transactionClient) {
78
+ let client;
79
+ let type;
80
+ if (PostgresConnection.isPoolClient(transactionClient)) {
81
+ type = 'poolclient';
82
+ client = await transactionClient.connect();
83
+ }
84
+ else {
85
+ type = 'client';
86
+ client = transactionClient;
44
87
  }
45
- await connection.end();
88
+ return [type, client];
46
89
  }
47
90
  }
48
91
  exports.PostgresConnection = PostgresConnection;
92
+ PostgresConnection.poolClientInstances = new Set();
93
+ PostgresConnection.connectionInstances = new Set();
@@ -34,7 +34,7 @@ declare class EngineService {
34
34
  search: SearchService<ProviderClient> | null;
35
35
  store: StoreService<ProviderClient, ProviderTransaction> | null;
36
36
  stream: StreamService<ProviderClient, ProviderTransaction> | null;
37
- subscribe: SubService<ProviderClient, ProviderTransaction> | null;
37
+ subscribe: SubService<ProviderClient> | null;
38
38
  router: Router<typeof this.stream> | null;
39
39
  taskService: TaskService | null;
40
40
  logger: ILogger;