@hotmeshio/hotmesh 0.3.19 → 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 (91) hide show
  1. package/README.md +43 -14
  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 +5 -4
  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.js +1 -1
  28. package/build/services/exporter/index.js +1 -1
  29. package/build/services/hotmesh/index.js +1 -6
  30. package/build/services/mapper/index.js +1 -1
  31. package/build/services/meshflow/connection.js +1 -0
  32. package/build/services/meshflow/exporter.js +1 -1
  33. package/build/services/pipe/functions/array.js +1 -1
  34. package/build/services/pipe/functions/bitwise.js +1 -1
  35. package/build/services/pipe/functions/conditional.js +1 -1
  36. package/build/services/pipe/functions/cron.js +1 -1
  37. package/build/services/pipe/functions/date.js +1 -1
  38. package/build/services/pipe/functions/index.js +1 -1
  39. package/build/services/pipe/functions/json.js +1 -1
  40. package/build/services/pipe/functions/logical.js +1 -1
  41. package/build/services/pipe/functions/math.js +1 -1
  42. package/build/services/pipe/functions/number.js +1 -1
  43. package/build/services/pipe/functions/object.js +1 -1
  44. package/build/services/pipe/functions/string.js +1 -1
  45. package/build/services/pipe/functions/symbol.js +1 -1
  46. package/build/services/pipe/functions/unary.js +1 -1
  47. package/build/services/pipe/index.js +1 -1
  48. package/build/services/quorum/index.js +1 -1
  49. package/build/services/reporter/index.js +1 -1
  50. package/build/services/router/index.js +1 -1
  51. package/build/services/search/providers/postgres/postgres.js +1 -1
  52. package/build/services/search/providers/redis/ioredis.js +1 -1
  53. package/build/services/search/providers/redis/redis.js +1 -1
  54. package/build/services/serializer/index.js +1 -1
  55. package/build/services/store/providers/postgres/kvsql.js +1 -1
  56. package/build/services/store/providers/postgres/kvtables.d.ts +2 -2
  57. package/build/services/store/providers/postgres/kvtables.js +1 -1
  58. package/build/services/store/providers/postgres/kvtransaction.js +1 -1
  59. package/build/services/store/providers/postgres/kvtypes/hash.js +1 -1
  60. package/build/services/store/providers/postgres/kvtypes/list.js +1 -1
  61. package/build/services/store/providers/postgres/kvtypes/string.js +1 -1
  62. package/build/services/store/providers/postgres/kvtypes/zset.js +1 -1
  63. package/build/services/store/providers/postgres/postgres.js +1 -1
  64. package/build/services/store/providers/redis/_base.js +1 -1
  65. package/build/services/store/providers/redis/ioredis.js +1 -1
  66. package/build/services/store/providers/redis/redis.js +1 -1
  67. package/build/services/store/providers/store-initializable.js +1 -1
  68. package/build/services/stream/providers/nats/nats.js +1 -1
  69. package/build/services/stream/providers/postgres/postgres.js +1 -1
  70. package/build/services/stream/providers/redis/ioredis.js +1 -1
  71. package/build/services/stream/providers/redis/redis.js +1 -1
  72. package/build/services/stream/providers/stream-initializable.js +1 -1
  73. package/build/services/sub/factory.d.ts +2 -2
  74. package/build/services/sub/factory.js +13 -8
  75. package/build/services/sub/providers/nats/nats.d.ts +19 -0
  76. package/build/services/sub/providers/nats/nats.js +1 -0
  77. package/build/services/sub/providers/postgres/postgres.d.ts +1 -0
  78. package/build/services/sub/providers/postgres/postgres.js +1 -1
  79. package/build/services/sub/providers/redis/ioredis.js +1 -1
  80. package/build/services/sub/providers/redis/redis.js +1 -1
  81. package/build/services/task/index.js +1 -1
  82. package/build/services/telemetry/index.js +1 -1
  83. package/build/services/worker/index.js +1 -1
  84. package/build/types/nats.d.ts +8 -0
  85. package/build/types/postgres.d.ts +10 -1
  86. package/build/types/provider.d.ts +1 -0
  87. package/index.ts +20 -5
  88. package/package.json +5 -4
  89. package/types/nats.ts +34 -0
  90. package/types/postgres.ts +13 -2
  91. package/types/provider.ts +4 -0
@@ -1 +1 @@
1
- 'use strict';(function(_0x3df943,_0x2dd111){const _0x21bcb0=_0x2207,_0x1d5043=_0x3df943();while(!![]){try{const _0x2b4bb7=parseInt(_0x21bcb0(0x186))/0x1*(-parseInt(_0x21bcb0(0x183))/0x2)+parseInt(_0x21bcb0(0x189))/0x3*(parseInt(_0x21bcb0(0x180))/0x4)+parseInt(_0x21bcb0(0x185))/0x5*(parseInt(_0x21bcb0(0x18a))/0x6)+parseInt(_0x21bcb0(0x188))/0x7*(-parseInt(_0x21bcb0(0x18b))/0x8)+parseInt(_0x21bcb0(0x187))/0x9+-parseInt(_0x21bcb0(0x182))/0xa+parseInt(_0x21bcb0(0x184))/0xb*(parseInt(_0x21bcb0(0x181))/0xc);if(_0x2b4bb7===_0x2dd111)break;else _0x1d5043['push'](_0x1d5043['shift']());}catch(_0x35590a){_0x1d5043['push'](_0x1d5043['shift']());}}}(_0x2057,0x4633e));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['WorkerService']=void 0x0;const key_1=require('../../modules/key'),utils_1=require('../../modules/utils'),factory_1=require('../connector/factory'),router_1=require('../router'),stream_1=require('../../types/stream'),enums_1=require('../../modules/enums'),factory_2=require('../stream/factory'),factory_3=require('../sub/factory'),factory_4=require('../store/factory');class WorkerService{constructor(){this['reporting']=![];}static async['init'](_0x345fdf,_0x32bd74,_0x3fe81c,_0x533a53,_0x3ef399){const _0x8f6977=[];if(Array['isArray'](_0x533a53['workers']))for(const _0x54239d of _0x533a53['workers']){await factory_1['ConnectorService']['initClients'](_0x54239d);const _0x259cb6=new WorkerService();_0x259cb6['verifyWorkerFields'](_0x54239d),_0x259cb6['namespace']=_0x345fdf,_0x259cb6['appId']=_0x32bd74,_0x259cb6['guid']=_0x3fe81c,_0x259cb6['callback']=_0x54239d['callback'],_0x259cb6['topic']=_0x54239d['topic'],_0x259cb6['config']=_0x533a53,_0x259cb6['logger']=_0x3ef399,await _0x259cb6['initStoreChannel'](_0x259cb6,_0x54239d['store']),await _0x259cb6['initSubChannel'](_0x259cb6,_0x54239d['sub'],_0x54239d['pub']),await _0x259cb6['subscribe']['subscribe'](key_1['KeyType']['QUORUM'],_0x259cb6['subscriptionHandler'](),_0x32bd74),await _0x259cb6['subscribe']['subscribe'](key_1['KeyType']['QUORUM'],_0x259cb6['subscriptionHandler'](),_0x32bd74,_0x259cb6['topic']),await _0x259cb6['subscribe']['subscribe'](key_1['KeyType']['QUORUM'],_0x259cb6['subscriptionHandler'](),_0x32bd74,_0x259cb6['guid']),await _0x259cb6['initStreamChannel'](_0x259cb6,_0x54239d['stream'],_0x54239d['store']),_0x259cb6['router']=await _0x259cb6['initRouter'](_0x54239d,_0x3ef399);const _0x3501d7=_0x259cb6['store']['mintKey'](key_1['KeyType']['STREAMS'],{'appId':_0x259cb6['appId'],'topic':_0x54239d['topic']});await _0x259cb6['router']['consumeMessages'](_0x3501d7,'WORKER',_0x259cb6['guid'],_0x54239d['callback']),_0x259cb6['inited']=(0x0,utils_1['formatISODate'])(new Date()),_0x8f6977['push'](_0x259cb6);}return _0x8f6977;}['verifyWorkerFields'](_0x4c78b4){if(!(0x0,utils_1['identifyProvider'])(_0x4c78b4['store'])||!(0x0,utils_1['identifyProvider'])(_0x4c78b4['stream'])||!(0x0,utils_1['identifyProvider'])(_0x4c78b4['sub'])||!(_0x4c78b4['topic']&&_0x4c78b4['callback']))throw new Error('worker\x20must\x20include\x20`store`,\x20`stream`,\x20and\x20`sub`\x20fields\x20along\x20with\x20a\x20callback\x20function\x20and\x20topic.');}async['initStoreChannel'](_0x56051f,_0x46b189){_0x56051f['store']=await factory_4['StoreServiceFactory']['init'](_0x46b189,_0x56051f['namespace'],_0x56051f['appId'],_0x56051f['logger']);}async['initSubChannel'](_0x229302,_0x35505e,_0x18f105){_0x229302['subscribe']=await factory_3['SubServiceFactory']['init'](_0x35505e,_0x18f105,_0x229302['namespace'],_0x229302['appId'],_0x229302['guid'],_0x229302['logger']);}async['initStreamChannel'](_0x56b31d,_0x4608fe,_0x13096b){_0x56b31d['stream']=await factory_2['StreamServiceFactory']['init'](_0x4608fe,_0x13096b,_0x56b31d['namespace'],_0x56b31d['appId'],_0x56b31d['logger']);}async['initRouter'](_0x4892f9,_0x55b423){const _0x1d6b9b=await this['store']['getThrottleRate'](_0x4892f9['topic']);return new router_1['Router']({'namespace':this['namespace'],'appId':this['appId'],'guid':this['guid'],'role':stream_1['StreamRole']['WORKER'],'topic':_0x4892f9['topic'],'reclaimDelay':_0x4892f9['reclaimDelay'],'reclaimCount':_0x4892f9['reclaimCount'],'throttle':_0x1d6b9b},this['stream'],_0x55b423);}['subscriptionHandler'](){const _0x3176fb=this;return async(_0x45a6c4,_0x4a02a7)=>{_0x3176fb['logger']['debug']('worker-event-received',{'topic':_0x45a6c4,'type':_0x4a02a7['type']});if(_0x4a02a7['type']==='throttle')_0x4a02a7['topic']!==null&&_0x3176fb['throttle'](_0x4a02a7['throttle']);else{if(_0x4a02a7['type']==='ping')_0x3176fb['sayPong'](_0x3176fb['appId'],_0x3176fb['guid'],_0x4a02a7['originator'],_0x4a02a7['details']);else _0x4a02a7['type']==='rollcall'&&(_0x4a02a7['topic']!==null&&_0x3176fb['doRollCall'](_0x4a02a7));}};}async['doRollCall'](_0x2b331b){let _0x1baf49=0x0;const _0xa69b76=!isNaN(_0x2b331b['max'])?_0x2b331b['max']:enums_1['HMSH_QUORUM_ROLLCALL_CYCLES'];if(this['rollCallInterval'])clearTimeout(this['rollCallInterval']);const _0x541a38=_0x2b331b['interval']/0x2,_0x404f2f=_0x541a38+Math['ceil'](Math['random']()*_0x541a38);do{await(0x0,utils_1['sleepFor'])(Math['ceil'](Math['random']()*0x3e8)),await this['sayPong'](this['appId'],this['guid'],null,!![],_0x2b331b['signature']);if(!_0x2b331b['interval'])return;const {promise:_0x59a546,timerId:_0x2f6241}=(0x0,utils_1['XSleepFor'])(_0x404f2f*0x3e8);this['rollCallInterval']=_0x2f6241,await _0x59a546;}while(this['rollCallInterval']&&_0x1baf49++<_0xa69b76-0x1);}['cancelRollCall'](){this['rollCallInterval']&&(clearTimeout(this['rollCallInterval']),delete this['rollCallInterval']);}['stop'](){this['cancelRollCall']();}async['sayPong'](_0x583c69,_0x3b01d3,_0x5a6433,_0xd4f6a0=![],_0x19e39a=![]){let _0xb2df0;if(_0xd4f6a0){const _0x5b6dd6={'appId':this['appId'],'topic':this['topic']};_0xb2df0={'engine_id':this['guid'],'namespace':this['namespace'],'app_id':this['appId'],'worker_topic':this['topic'],'stream':this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0x5b6dd6),'counts':this['router']?.['counts'],'timestamp':(0x0,utils_1['formatISODate'])(new Date()),'inited':this['inited'],'throttle':this['router']?.['throttle'],'reclaimDelay':this['router']?.['reclaimDelay'],'reclaimCount':this['router']?.['reclaimCount'],'system':await(0x0,utils_1['getSystemHealth'])(),'signature':_0x19e39a?this['callback']['toString']():undefined};}this['subscribe']['publish'](key_1['KeyType']['QUORUM'],{'type':'pong','guid':_0x3b01d3,'originator':_0x5a6433,'profile':_0xb2df0},_0x583c69);}async['throttle'](_0x562e44){this['router']?.['setThrottle'](_0x562e44);}}function _0x2207(_0x4da059,_0x56c7a4){const _0x205753=_0x2057();return _0x2207=function(_0x2207a2,_0x49dd29){_0x2207a2=_0x2207a2-0x180;let _0x485e0b=_0x205753[_0x2207a2];return _0x485e0b;},_0x2207(_0x4da059,_0x56c7a4);}function _0x2057(){const _0x5bacc5=['4638456hEYXgu','120253MpPXII','1187148uhoMKo','2159898DGOOZb','40ojCcRH','4ODlYAu','132CbaRWo','5655480slbqFm','22dQORXO','197263oCtZWH','5nMjtIe','48123xbbBqz'];_0x2057=function(){return _0x5bacc5;};return _0x2057();}exports['WorkerService']=WorkerService;
1
+ 'use strict';(function(_0x45285f,_0x19e90e){const _0x409fea=_0x5984,_0x2c44a0=_0x45285f();while(!![]){try{const _0x30ec35=-parseInt(_0x409fea(0xf4))/0x1+parseInt(_0x409fea(0xf3))/0x2*(parseInt(_0x409fea(0xef))/0x3)+parseInt(_0x409fea(0xf2))/0x4+parseInt(_0x409fea(0xf0))/0x5+-parseInt(_0x409fea(0xee))/0x6*(-parseInt(_0x409fea(0xed))/0x7)+parseInt(_0x409fea(0xf5))/0x8+parseInt(_0x409fea(0xec))/0x9*(-parseInt(_0x409fea(0xf1))/0xa);if(_0x30ec35===_0x19e90e)break;else _0x2c44a0['push'](_0x2c44a0['shift']());}catch(_0x3b2793){_0x2c44a0['push'](_0x2c44a0['shift']());}}}(_0x3d47,0xb399d));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['WorkerService']=void 0x0;function _0x3d47(){const _0x217b24=['2113608UPoMpV','24dJmuNl','1797696aOuFVl','6126475BsEbPL','949570GeCgyw','5320952ItBtOq','2dTVgDH','206590oiYbuO','9101040uVqHXt','432nYNnSd'];_0x3d47=function(){return _0x217b24;};return _0x3d47();}const key_1=require('../../modules/key'),utils_1=require('../../modules/utils'),factory_1=require('../connector/factory'),router_1=require('../router'),stream_1=require('../../types/stream'),enums_1=require('../../modules/enums'),factory_2=require('../stream/factory'),factory_3=require('../sub/factory'),factory_4=require('../store/factory');class WorkerService{constructor(){this['reporting']=![];}static async['init'](_0x35b948,_0x391a9f,_0xf2c847,_0x5a6a93,_0x3da8d7){const _0x5262=[];if(Array['isArray'](_0x5a6a93['workers']))for(const _0x157083 of _0x5a6a93['workers']){await factory_1['ConnectorService']['initClients'](_0x157083);const _0xd91e28=new WorkerService();_0xd91e28['verifyWorkerFields'](_0x157083),_0xd91e28['namespace']=_0x35b948,_0xd91e28['appId']=_0x391a9f,_0xd91e28['guid']=_0xf2c847,_0xd91e28['callback']=_0x157083['callback'],_0xd91e28['topic']=_0x157083['topic'],_0xd91e28['config']=_0x5a6a93,_0xd91e28['logger']=_0x3da8d7,await _0xd91e28['initStoreChannel'](_0xd91e28,_0x157083['store']),await _0xd91e28['initSubChannel'](_0xd91e28,_0x157083['sub'],_0x157083['pub']),await _0xd91e28['subscribe']['subscribe'](key_1['KeyType']['QUORUM'],_0xd91e28['subscriptionHandler'](),_0x391a9f),await _0xd91e28['subscribe']['subscribe'](key_1['KeyType']['QUORUM'],_0xd91e28['subscriptionHandler'](),_0x391a9f,_0xd91e28['topic']),await _0xd91e28['subscribe']['subscribe'](key_1['KeyType']['QUORUM'],_0xd91e28['subscriptionHandler'](),_0x391a9f,_0xd91e28['guid']),await _0xd91e28['initStreamChannel'](_0xd91e28,_0x157083['stream'],_0x157083['store']),_0xd91e28['router']=await _0xd91e28['initRouter'](_0x157083,_0x3da8d7);const _0x500a1f=_0xd91e28['store']['mintKey'](key_1['KeyType']['STREAMS'],{'appId':_0xd91e28['appId'],'topic':_0x157083['topic']});await _0xd91e28['router']['consumeMessages'](_0x500a1f,'WORKER',_0xd91e28['guid'],_0x157083['callback']),_0xd91e28['inited']=(0x0,utils_1['formatISODate'])(new Date()),_0x5262['push'](_0xd91e28);}return _0x5262;}['verifyWorkerFields'](_0x187b03){if(!(0x0,utils_1['identifyProvider'])(_0x187b03['store'])||!(0x0,utils_1['identifyProvider'])(_0x187b03['stream'])||!(0x0,utils_1['identifyProvider'])(_0x187b03['sub'])||!(_0x187b03['topic']&&_0x187b03['callback']))throw new Error('worker\x20must\x20include\x20`store`,\x20`stream`,\x20and\x20`sub`\x20fields\x20along\x20with\x20a\x20callback\x20function\x20and\x20topic.');}async['initStoreChannel'](_0x585f8d,_0x386c4f){_0x585f8d['store']=await factory_4['StoreServiceFactory']['init'](_0x386c4f,_0x585f8d['namespace'],_0x585f8d['appId'],_0x585f8d['logger']);}async['initSubChannel'](_0x39838d,_0x3cc48e,_0x34e127){_0x39838d['subscribe']=await factory_3['SubServiceFactory']['init'](_0x3cc48e,_0x34e127,_0x39838d['namespace'],_0x39838d['appId'],_0x39838d['guid'],_0x39838d['logger']);}async['initStreamChannel'](_0x3c44df,_0x13ecf0,_0x3a8984){_0x3c44df['stream']=await factory_2['StreamServiceFactory']['init'](_0x13ecf0,_0x3a8984,_0x3c44df['namespace'],_0x3c44df['appId'],_0x3c44df['logger']);}async['initRouter'](_0x1817dc,_0x467697){const _0x54617b=await this['store']['getThrottleRate'](_0x1817dc['topic']);return new router_1['Router']({'namespace':this['namespace'],'appId':this['appId'],'guid':this['guid'],'role':stream_1['StreamRole']['WORKER'],'topic':_0x1817dc['topic'],'reclaimDelay':_0x1817dc['reclaimDelay'],'reclaimCount':_0x1817dc['reclaimCount'],'throttle':_0x54617b},this['stream'],_0x467697);}['subscriptionHandler'](){const _0x1efcb8=this;return async(_0xed5e13,_0x56b33c)=>{_0x1efcb8['logger']['debug']('worker-event-received',{'topic':_0xed5e13,'type':_0x56b33c['type']});if(_0x56b33c['type']==='throttle')_0x56b33c['topic']!==null&&_0x1efcb8['throttle'](_0x56b33c['throttle']);else{if(_0x56b33c['type']==='ping')_0x1efcb8['sayPong'](_0x1efcb8['appId'],_0x1efcb8['guid'],_0x56b33c['originator'],_0x56b33c['details']);else _0x56b33c['type']==='rollcall'&&(_0x56b33c['topic']!==null&&_0x1efcb8['doRollCall'](_0x56b33c));}};}async['doRollCall'](_0x30a7f1){let _0xb974f8=0x0;const _0x28ee86=!isNaN(_0x30a7f1['max'])?_0x30a7f1['max']:enums_1['HMSH_QUORUM_ROLLCALL_CYCLES'];if(this['rollCallInterval'])clearTimeout(this['rollCallInterval']);const _0x29abf4=_0x30a7f1['interval']/0x2,_0x1786fb=_0x29abf4+Math['ceil'](Math['random']()*_0x29abf4);do{await(0x0,utils_1['sleepFor'])(Math['ceil'](Math['random']()*0x3e8)),await this['sayPong'](this['appId'],this['guid'],null,!![],_0x30a7f1['signature']);if(!_0x30a7f1['interval'])return;const {promise:_0x1dcea3,timerId:_0x4b927a}=(0x0,utils_1['XSleepFor'])(_0x1786fb*0x3e8);this['rollCallInterval']=_0x4b927a,await _0x1dcea3;}while(this['rollCallInterval']&&_0xb974f8++<_0x28ee86-0x1);}['cancelRollCall'](){this['rollCallInterval']&&(clearTimeout(this['rollCallInterval']),delete this['rollCallInterval']);}['stop'](){this['cancelRollCall']();}async['sayPong'](_0x693b32,_0x290f92,_0x14995e,_0x175b29=![],_0x655336=![]){let _0x47fc1b;if(_0x175b29){const _0x5114db={'appId':this['appId'],'topic':this['topic']};_0x47fc1b={'engine_id':this['guid'],'namespace':this['namespace'],'app_id':this['appId'],'worker_topic':this['topic'],'stream':this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0x5114db),'counts':this['router']?.['counts'],'timestamp':(0x0,utils_1['formatISODate'])(new Date()),'inited':this['inited'],'throttle':this['router']?.['throttle'],'reclaimDelay':this['router']?.['reclaimDelay'],'reclaimCount':this['router']?.['reclaimCount'],'system':await(0x0,utils_1['getSystemHealth'])(),'signature':_0x655336?this['callback']['toString']():undefined};}this['subscribe']['publish'](key_1['KeyType']['QUORUM'],{'type':'pong','guid':_0x290f92,'originator':_0x14995e,'profile':_0x47fc1b},_0x693b32);}async['throttle'](_0x533956){this['router']?.['setThrottle'](_0x533956);}}function _0x5984(_0x22bb97,_0x2e552b){const _0x3d47a9=_0x3d47();return _0x5984=function(_0x59841c,_0x4ec2a7){_0x59841c=_0x59841c-0xec;let _0x7d53ac=_0x3d47a9[_0x59841c];return _0x7d53ac;},_0x5984(_0x22bb97,_0x2e552b);}exports['WorkerService']=WorkerService;
@@ -21,6 +21,14 @@ export interface NatsConnection extends ProviderClient {
21
21
  jetstreamManager(options?: NatsJetStreamOptions): Promise<NatsJetStreamManager>;
22
22
  close(): Promise<void>;
23
23
  }
24
+ export interface NatsSubscriptionType {
25
+ unsubscribe(): void;
26
+ drain(): Promise<void>;
27
+ subject: string;
28
+ queue?: string;
29
+ isClosed: boolean;
30
+ [Symbol.asyncIterator](): AsyncIterableIterator<NatsMessageType>;
31
+ }
24
32
  export type NatsClientType = NatsConnection;
25
33
  export type NatsClassType = (options: NatsClientOptions) => Promise<NatsConnection>;
26
34
  export interface NatsJetStreamClient {
@@ -10,15 +10,24 @@ export interface PostgresClientOptions {
10
10
  export type PostgresJobEnumType = 'status' | 'jdata' | 'adata' | 'udata' | 'jmark' | 'hmark' | 'other';
11
11
  export type PostgresClassType = {
12
12
  new (options: PostgresClientOptions): PostgresClientType;
13
+ };
14
+ export type PostgresPoolType = {
15
+ new (options: PostgresClientOptions): PostgresPoolClientType;
13
16
  connect: (options: PostgresClientOptions) => Promise<PostgresClientType>;
17
+ query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
14
18
  };
15
19
  export interface PostgresClientType {
20
+ connect: () => Promise<PostgresClientType>;
16
21
  query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
17
22
  end: () => Promise<void>;
18
23
  }
19
24
  export interface PostgresPoolClientType {
20
- query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
25
+ connect: () => Promise<PostgresClientType>;
21
26
  release: () => void;
27
+ end: () => Promise<void>;
28
+ query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
29
+ idleCount: number;
30
+ totalCount: number;
22
31
  }
23
32
  export interface PostgresQueryResultType {
24
33
  rows: any[];
@@ -23,6 +23,7 @@ export type TransactionResultList = (string | number)[];
23
23
  export type ProviderConfig = {
24
24
  class: any;
25
25
  options: StringAnyType;
26
+ provider?: string;
26
27
  };
27
28
  export type ProvidersConfig = {
28
29
  sub: ProviderConfig;
package/index.ts CHANGED
@@ -8,25 +8,40 @@ import { MeshOS } from './services/meshos';
8
8
  import * as Errors from './modules/errors';
9
9
  import * as Utils from './modules/utils';
10
10
  import { ConnectorService as Connector } from './services/connector/factory';
11
+ import { PostgresConnection as ConnectorPostgres } from './services/connector/providers/postgres';
12
+ import { RedisConnection as ConnectorIORedis } from './services/connector/providers/ioredis';
13
+ import { RedisConnection as ConnectorRedis } from './services/connector/providers/redis';
14
+ import { NatsConnection as ConnectorNATS } from './services/connector/providers/nats';
11
15
 
12
16
  const { Client, Connection, Search, Worker, workflow } = MeshFlow;
13
17
 
14
18
  export {
15
- Client,
16
- Connection,
17
- Connector,
18
- Errors,
19
+ //Provider Connectors
20
+ Connector, //factory
21
+ ConnectorIORedis,
22
+ ConnectorNATS,
23
+ ConnectorPostgres,
24
+ ConnectorRedis,
25
+
26
+ //Top-level Modules
19
27
  HotMesh,
20
28
  HotMeshConfig,
21
29
  MeshCall,
22
30
  MeshData,
23
31
  MeshFlow,
24
32
  MeshOS,
33
+
34
+ //MeshFlow Submodules
35
+ Client,
36
+ Connection,
25
37
  Search,
26
- Utils,
27
38
  Worker,
28
39
  workflow,
29
40
  WorkflowHandle,
41
+
42
+ //Global Modules
43
+ Errors,
44
+ Utils,
30
45
  };
31
46
 
32
47
  export * as Types from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "description": "Serverless Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -27,14 +27,14 @@
27
27
  "test:connect:nats": "NODE_ENV=test jest ./tests/unit/services/connector/providers/nats.test.ts --detectOpenHandles --forceExit --verbose",
28
28
  "test:cycle": "NODE_ENV=test jest ./tests/functional/cycle/*.test.ts --detectOpenHandles --forceExit --verbose",
29
29
  "test:meshflow": "NODE_ENV=test jest ./tests/meshflow/*/*.test.ts --detectOpenHandles --forceExit --verbose",
30
- "test:meshflow:basic": "NODE_ENV=test jest ./tests/meshflow/basic/*.test.ts --detectOpenHandles --forceExit --verbose",
30
+ "test:meshflow:basic": "HMSH_LOGLEVEL=info NODE_ENV=test jest ./tests/meshflow/basic/*.test.ts --detectOpenHandles --forceExit --verbose",
31
31
  "test:meshflow:collision": "NODE_ENV=test jest ./tests/meshflow/collision/*.test.ts --detectOpenHandles --forceExit --verbose",
32
32
  "test:meshflow:fatal": "NODE_ENV=test jest ./tests/meshflow/fatal/*.test.ts --detectOpenHandles --forceExit --verbose",
33
33
  "test:meshflow:goodbye": "NODE_ENV=test jest ./tests/meshflow/goodbye/*.test.ts --detectOpenHandles --forceExit --verbose",
34
34
  "test:meshflow:hello": "HMSH_LOGLEVEL=debug HMSH_IS_CLUSTER=true NODE_ENV=test jest ./tests/meshflow/helloworld/*.test.ts --detectOpenHandles --forceExit --verbose",
35
35
  "test:meshflow:hook": "NODE_ENV=test jest ./tests/meshflow/hook/*.test.ts --detectOpenHandles --forceExit --verbose",
36
36
  "test:meshflow:interrupt": "NODE_ENV=test jest ./tests/meshflow/interrupt/*.test.ts --detectOpenHandles --forceExit --verbose",
37
- "test:meshflow:loopactivity": "NODE_ENV=test jest ./tests/meshflow/loopactivity/*.test.ts --detectOpenHandles --forceExit --verbose",
37
+ "test:meshflow:loopactivity": "NODE_ENV=test jest ./tests/meshflow/loopactivity/I.test.ts --detectOpenHandles --forceExit --verbose",
38
38
  "test:meshflow:nested": "NODE_ENV=test jest ./tests/meshflow/nested/*.test.ts --detectOpenHandles --forceExit --verbose",
39
39
  "test:meshflow:retry": "NODE_ENV=test jest ./tests/meshflow/retry/*.test.ts --detectOpenHandles --forceExit --verbose",
40
40
  "test:meshflow:sleep": "NODE_ENV=test jest ./tests/meshflow/sleep/*.test.ts --detectOpenHandles --forceExit --verbose",
@@ -68,8 +68,9 @@
68
68
  "test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
69
69
  "test:sub:redis": "NODE_ENV=test jest ./tests/functional/sub/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
70
70
  "test:sub:postgres": "NODE_ENV=test jest ./tests/functional/sub/providers/postgres/postgres.test.ts --detectOpenHandles --forceExit --verbose",
71
+ "test:sub:nats": "NODE_ENV=test jest ./tests/functional/sub/providers/nats/nats.test.ts --detectOpenHandles --forceExit --verbose",
71
72
  "test:trigger": "NODE_ENV=test jest ./tests/unit/services/activities/trigger.test.ts --detectOpenHandles --forceExit --verbose",
72
- "test:meshdata": "NODE_ENV=test jest ./tests/meshdata/postgres.test.ts --forceExit --verbose --detectOpenHandles",
73
+ "test:meshdata": "NODE_ENV=test jest ./tests/meshdata/*.test.ts --forceExit --verbose --detectOpenHandles",
73
74
  "test:meshos": "NODE_ENV=test HMSH_IS_CLUSTER=true jest ./tests/meshos/*.test.ts --forceExit --verbose --detectOpenHandles",
74
75
  "test:meshcall": "NODE_ENV=test jest ./tests/meshcall/*.test.ts --forceExit --verbose --detectOpenHandles",
75
76
  "test:unit": "NODE_ENV=test jest ./tests/unit/*/*/index.test.ts --detectOpenHandles --forceExit --verbose"
package/types/nats.ts CHANGED
@@ -35,6 +35,40 @@ export interface NatsConnection extends ProviderClient {
35
35
  close(): Promise<void>;
36
36
  }
37
37
 
38
+ export interface NatsSubscriptionType {
39
+ /**
40
+ * Unsubscribes from the subject, stopping message delivery.
41
+ */
42
+ unsubscribe(): void;
43
+
44
+ /**
45
+ * Drains the subscription, ensuring all pending messages are delivered
46
+ * before unsubscribing.
47
+ * @returns Promise<void>
48
+ */
49
+ drain(): Promise<void>;
50
+
51
+ /**
52
+ * The subject this subscription is listening to.
53
+ */
54
+ subject: string;
55
+
56
+ /**
57
+ * The queue group this subscription belongs to, if any.
58
+ */
59
+ queue?: string;
60
+
61
+ /**
62
+ * Indicates whether this subscription is currently active.
63
+ */
64
+ isClosed: boolean;
65
+
66
+ /**
67
+ * Async iterator for processing incoming messages.
68
+ */
69
+ [Symbol.asyncIterator](): AsyncIterableIterator<NatsMessageType>;
70
+ }
71
+
38
72
  /** Type representing the NATS Connection */
39
73
  export type NatsClientType = NatsConnection;
40
74
 
package/types/postgres.ts CHANGED
@@ -21,18 +21,29 @@ export type PostgresJobEnumType =
21
21
 
22
22
  export type PostgresClassType = {
23
23
  new (options: PostgresClientOptions): PostgresClientType;
24
- connect: (options: PostgresClientOptions) => Promise<PostgresClientType>;
25
24
  };
26
25
 
26
+ export type PostgresPoolType = {
27
+ new (options: PostgresClientOptions): PostgresPoolClientType;
28
+ connect: (options: PostgresClientOptions) => Promise<PostgresClientType>;
29
+ //NOTE: query is a shorthand and includes implicit `connect/release` handled by pool
30
+ query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
31
+ };
32
+
27
33
  export interface PostgresClientType {
34
+ connect: () => Promise<PostgresClientType>;
28
35
  query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
29
36
  end: () => Promise<void>;
30
37
  // Include other methods if necessary
31
38
  }
32
39
 
33
40
  export interface PostgresPoolClientType {
34
- query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
41
+ connect: () => Promise<PostgresClientType>;
35
42
  release: () => void;
43
+ end: () => Promise<void>;
44
+ query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
45
+ idleCount: number;
46
+ totalCount: number;
36
47
  // Include other methods if necessary
37
48
  }
38
49
 
package/types/provider.ts CHANGED
@@ -67,8 +67,12 @@ export type TransactionResultList = (string | number)[]; // e.g., [3, 2, '0']
67
67
  export type ProviderConfig = {
68
68
  class: any;
69
69
  options: StringAnyType;
70
+ /* 'redis' (Class) | 'ioredis' (Class) | 'postgres' (Client module) | 'postgres.pool' | 'postgres.poolclient', 'nats' */
71
+ provider?: string;
70
72
  };
71
73
 
74
+
75
+
72
76
  export type ProvidersConfig = {
73
77
  sub: ProviderConfig;
74
78
  store: ProviderConfig;