@hotmeshio/hotmesh 0.3.6 → 0.3.8

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 (124) hide show
  1. package/README.md +13 -1
  2. package/build/index.d.ts +3 -1
  3. package/build/index.js +10 -1
  4. package/build/modules/key.js +1 -62
  5. package/build/modules/utils.js +1 -267
  6. package/build/package.json +12 -8
  7. package/build/services/activities/activity.js +1 -495
  8. package/build/services/activities/await.js +1 -109
  9. package/build/services/activities/cycle.js +1 -96
  10. package/build/services/activities/hook.js +1 -154
  11. package/build/services/activities/index.js +1 -20
  12. package/build/services/activities/interrupt.js +1 -149
  13. package/build/services/activities/signal.js +1 -118
  14. package/build/services/activities/trigger.js +1 -237
  15. package/build/services/activities/worker.js +1 -101
  16. package/build/services/collator/index.js +1 -197
  17. package/build/services/compiler/deployer.d.ts +3 -1
  18. package/build/services/compiler/deployer.js +1 -455
  19. package/build/services/compiler/index.d.ts +3 -1
  20. package/build/services/compiler/index.js +1 -91
  21. package/build/services/compiler/validator.js +1 -122
  22. package/build/services/engine/index.d.ts +5 -2
  23. package/build/services/engine/index.js +1 -562
  24. package/build/services/exporter/index.js +1 -93
  25. package/build/services/mapper/index.js +1 -67
  26. package/build/services/meshdata/index.d.ts +0 -1
  27. package/build/services/meshdata/index.js +16 -24
  28. package/build/services/meshflow/client.js +4 -8
  29. package/build/services/meshflow/exporter.js +1 -186
  30. package/build/services/meshflow/index.d.ts +2 -0
  31. package/build/services/meshflow/index.js +2 -0
  32. package/build/services/meshflow/search.d.ts +4 -5
  33. package/build/services/meshflow/search.js +45 -35
  34. package/build/services/meshflow/workflow.d.ts +1 -1
  35. package/build/services/meshflow/workflow.js +3 -28
  36. package/build/services/pipe/functions/array.js +1 -74
  37. package/build/services/pipe/functions/bitwise.js +1 -24
  38. package/build/services/pipe/functions/conditional.js +1 -36
  39. package/build/services/pipe/functions/cron.js +1 -32
  40. package/build/services/pipe/functions/date.js +1 -164
  41. package/build/services/pipe/functions/index.js +1 -30
  42. package/build/services/pipe/functions/json.js +1 -12
  43. package/build/services/pipe/functions/logical.js +1 -12
  44. package/build/services/pipe/functions/math.js +1 -182
  45. package/build/services/pipe/functions/number.js +1 -60
  46. package/build/services/pipe/functions/object.js +1 -81
  47. package/build/services/pipe/functions/string.js +1 -69
  48. package/build/services/pipe/functions/symbol.js +1 -33
  49. package/build/services/pipe/functions/unary.js +1 -18
  50. package/build/services/pipe/index.js +1 -221
  51. package/build/services/quorum/index.d.ts +1 -1
  52. package/build/services/quorum/index.js +1 -219
  53. package/build/services/reporter/index.js +1 -331
  54. package/build/services/router/index.js +1 -420
  55. package/build/services/search/factory.d.ts +7 -0
  56. package/build/services/search/factory.js +20 -0
  57. package/build/services/search/index.d.ts +21 -0
  58. package/build/services/search/index.js +10 -0
  59. package/build/services/search/providers/redis/ioredis.d.ts +18 -0
  60. package/build/services/search/providers/redis/ioredis.js +1 -0
  61. package/build/services/search/providers/redis/redis.d.ts +18 -0
  62. package/build/services/search/providers/redis/redis.js +1 -0
  63. package/build/services/serializer/index.js +1 -265
  64. package/build/services/store/factory.d.ts +2 -1
  65. package/build/services/store/factory.js +2 -2
  66. package/build/services/store/index.d.ts +71 -97
  67. package/build/services/store/index.js +2 -939
  68. package/build/services/store/providers/postgres/postgres.d.ts +0 -0
  69. package/build/services/store/providers/postgres/postgres.js +0 -0
  70. package/build/services/store/providers/postgres/types/hash.d.ts +0 -0
  71. package/build/services/store/providers/postgres/types/hash.js +0 -0
  72. package/build/services/store/providers/postgres/types/list.d.ts +0 -0
  73. package/build/services/store/providers/postgres/types/list.js +0 -0
  74. package/build/services/store/providers/postgres/types/string.d.ts +0 -0
  75. package/build/services/store/providers/postgres/types/string.js +0 -0
  76. package/build/services/store/providers/postgres/types/zset.d.ts +0 -0
  77. package/build/services/store/providers/postgres/types/zset.js +0 -0
  78. package/build/services/store/providers/redis/_base.d.ts +98 -0
  79. package/build/services/store/providers/redis/_base.js +1 -0
  80. package/build/services/store/providers/redis/ioredis.d.ts +12 -0
  81. package/build/services/store/providers/redis/ioredis.js +1 -0
  82. package/build/services/store/providers/redis/redis.d.ts +13 -0
  83. package/build/services/store/providers/redis/redis.js +1 -0
  84. package/build/services/store/providers/store-initializable.d.ts +5 -0
  85. package/build/services/store/providers/store-initializable.js +1 -0
  86. package/build/services/stream/factory.d.ts +2 -1
  87. package/build/services/stream/factory.js +5 -5
  88. package/build/services/stream/index.d.ts +13 -14
  89. package/build/services/stream/index.js +3 -2
  90. package/build/services/stream/providers/postgres/_deploy.d.ts +4 -0
  91. package/build/services/stream/providers/postgres/_deploy.js +1 -0
  92. package/build/services/stream/providers/redis/ioredis.d.ts +21 -0
  93. package/build/services/stream/providers/redis/ioredis.js +1 -0
  94. package/build/services/stream/providers/redis/redis.d.ts +21 -0
  95. package/build/services/stream/providers/redis/redis.js +1 -0
  96. package/build/services/stream/providers/stream-initializable.d.ts +5 -0
  97. package/build/services/stream/providers/stream-initializable.js +1 -0
  98. package/build/services/sub/factory.d.ts +1 -1
  99. package/build/services/sub/factory.js +5 -5
  100. package/build/services/sub/index.d.ts +9 -7
  101. package/build/services/sub/index.js +3 -2
  102. package/build/services/sub/{clients → providers/redis}/ioredis.d.ts +7 -10
  103. package/build/services/sub/providers/redis/ioredis.js +1 -0
  104. package/build/services/sub/{clients → providers/redis}/redis.d.ts +7 -10
  105. package/build/services/sub/providers/redis/redis.js +1 -0
  106. package/build/services/task/index.js +1 -171
  107. package/build/services/telemetry/index.js +1 -225
  108. package/build/services/worker/index.d.ts +2 -2
  109. package/build/services/worker/index.js +1 -158
  110. package/build/types/redis.d.ts +5 -5
  111. package/index.ts +18 -1
  112. package/package.json +12 -8
  113. package/typedoc.json +2 -1
  114. package/types/redis.ts +5 -5
  115. package/build/services/store/clients/ioredis.d.ts +0 -30
  116. package/build/services/store/clients/ioredis.js +0 -220
  117. package/build/services/store/clients/redis.d.ts +0 -32
  118. package/build/services/store/clients/redis.js +0 -319
  119. package/build/services/stream/clients/ioredis.d.ts +0 -24
  120. package/build/services/stream/clients/ioredis.js +0 -121
  121. package/build/services/stream/clients/redis.d.ts +0 -24
  122. package/build/services/stream/clients/redis.js +0 -161
  123. package/build/services/sub/clients/ioredis.js +0 -72
  124. package/build/services/sub/clients/redis.js +0 -63
@@ -1,93 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExporterService = void 0;
4
- const key_1 = require("../../modules/key");
5
- const utils_1 = require("../../modules/utils");
6
- const serializer_1 = require("../serializer");
7
- class ExporterService {
8
- constructor(appId, store, logger) {
9
- this.appId = appId;
10
- this.logger = logger;
11
- this.store = store;
12
- }
13
- async export(jobId, options = {}) {
14
- if (!this.symbols) {
15
- this.symbols = this.store.getAllSymbols();
16
- this.symbols = await this.symbols;
17
- }
18
- const depData = [];
19
- const jobData = await this.store.getRaw(jobId);
20
- const jobExport = this.inflate(jobData, depData);
21
- return jobExport;
22
- }
23
- inflateKey(key) {
24
- return key in this.symbols ? this.symbols[key] : key;
25
- }
26
- inflate(jobHash, dependencyList) {
27
- const actions = {
28
- hooks: {},
29
- main: {
30
- cursor: -1,
31
- items: [],
32
- },
33
- };
34
- const process = {};
35
- const dependencies = this.inflateDependencyData(dependencyList, actions);
36
- const regex = /^([a-zA-Z]{3}),(\d+(?:,\d+)*)/;
37
- Object.entries(jobHash).forEach(([key, value]) => {
38
- const match = key.match(regex);
39
- if (match) {
40
- const [_, letters, numbers] = match;
41
- const path = this.inflateKey(letters);
42
- const dimensions = `${numbers.replace(/,/g, '/')}`;
43
- const resolved = serializer_1.SerializerService.fromString(value);
44
- process[`${dimensions}/${path}`] = resolved;
45
- }
46
- else if (key.length === 3) {
47
- process[this.inflateKey(key)] = serializer_1.SerializerService.fromString(value);
48
- }
49
- });
50
- return {
51
- dependencies,
52
- process: (0, utils_1.restoreHierarchy)(process),
53
- status: jobHash[':'],
54
- };
55
- }
56
- inflateDependencyData(data, actions) {
57
- const hookReg = /([0-9,]+)-(\d+)$/;
58
- const flowReg = /-(\d+)$/;
59
- return data.map((dependency, index) => {
60
- const [action, topic, gid, _pd, ...jid] = dependency.split(key_1.VALSEP);
61
- const jobId = jid.join(key_1.VALSEP);
62
- const match = jobId.match(hookReg);
63
- let prefix;
64
- let type;
65
- let dimensionKey = '';
66
- if (match) {
67
- const [_, dimension, counter] = match;
68
- dimensionKey = dimension.split(',').join('/');
69
- prefix = `${dimensionKey}[${counter}]`;
70
- type = 'hook';
71
- }
72
- else {
73
- const match = jobId.match(flowReg);
74
- if (match) {
75
- const [_, counter] = match;
76
- prefix = `[${counter}]`;
77
- type = 'flow';
78
- }
79
- else {
80
- prefix = '/';
81
- type = 'other';
82
- }
83
- }
84
- return {
85
- type: action,
86
- topic,
87
- gid,
88
- jid: jobId,
89
- };
90
- });
91
- }
92
- }
93
- exports.ExporterService = ExporterService;
1
+ 'use strict';(function(_0x218e0d,_0x1c5099){const _0x18843d=_0x20d5,_0x4c3f9c=_0x218e0d();while(!![]){try{const _0x171017=-parseInt(_0x18843d(0x18e))/0x1*(-parseInt(_0x18843d(0x18f))/0x2)+-parseInt(_0x18843d(0x187))/0x3*(-parseInt(_0x18843d(0x188))/0x4)+-parseInt(_0x18843d(0x189))/0x5+parseInt(_0x18843d(0x18a))/0x6+parseInt(_0x18843d(0x18c))/0x7+-parseInt(_0x18843d(0x18d))/0x8+-parseInt(_0x18843d(0x18b))/0x9;if(_0x171017===_0x1c5099)break;else _0x4c3f9c['push'](_0x4c3f9c['shift']());}catch(_0x5d2264){_0x4c3f9c['push'](_0x4c3f9c['shift']());}}}(_0x4ff3,0x3df75));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['ExporterService']=void 0x0;function _0x20d5(_0x3500e6,_0x19854e){const _0x4ff38a=_0x4ff3();return _0x20d5=function(_0x20d5fa,_0x7cff86){_0x20d5fa=_0x20d5fa-0x187;let _0x2d21e3=_0x4ff38a[_0x20d5fa];return _0x2d21e3;},_0x20d5(_0x3500e6,_0x19854e);}const key_1=require('../../modules/key'),utils_1=require('../../modules/utils'),serializer_1=require('../serializer');class ExporterService{constructor(_0x2fdbb9,_0x234abc,_0x1b3c21){this['appId']=_0x2fdbb9,this['logger']=_0x1b3c21,this['store']=_0x234abc;}async['export'](_0x1b421d,_0x5e47d5={}){!this['symbols']&&(this['symbols']=this['store']['getAllSymbols'](),this['symbols']=await this['symbols']);const _0x3809df=[],_0x44bee9=await this['store']['getRaw'](_0x1b421d),_0x555a49=this['inflate'](_0x44bee9,_0x3809df);return _0x555a49;}['inflateKey'](_0x402d7d){return _0x402d7d in this['symbols']?this['symbols'][_0x402d7d]:_0x402d7d;}['inflate'](_0x1fb047,_0x4514da){const _0x68e4b5={'hooks':{},'main':{'cursor':-0x1,'items':[]}},_0x50d198={},_0x2e159d=this['inflateDependencyData'](_0x4514da,_0x68e4b5),_0x247d70=/^([a-zA-Z]{3}),(\d+(?:,\d+)*)/;return Object['entries'](_0x1fb047)['forEach'](([_0xd312f4,_0x3a39a1])=>{const _0x5c3ae9=_0xd312f4['match'](_0x247d70);if(_0x5c3ae9){const [_0x148b9f,_0x2b67f5,_0x3f0132]=_0x5c3ae9,_0x29a9b9=this['inflateKey'](_0x2b67f5),_0x36cb76=''+_0x3f0132['replace'](/,/g,'/'),_0x2babea=serializer_1['SerializerService']['fromString'](_0x3a39a1);_0x50d198[_0x36cb76+'/'+_0x29a9b9]=_0x2babea;}else _0xd312f4['length']===0x3&&(_0x50d198[this['inflateKey'](_0xd312f4)]=serializer_1['SerializerService']['fromString'](_0x3a39a1));}),{'dependencies':_0x2e159d,'process':(0x0,utils_1['restoreHierarchy'])(_0x50d198),'status':_0x1fb047[':']};}['inflateDependencyData'](_0x52afef,_0x451a37){const _0x1dc374=/([0-9,]+)-(\d+)$/,_0x1c2508=/-(\d+)$/;return _0x52afef['map']((_0x9a515b,_0x5ed950)=>{const [_0x1da7e3,_0x5ca88d,_0x56d2a6,_0x1a6df8,..._0x1e653a]=_0x9a515b['split'](key_1['VALSEP']),_0x1af393=_0x1e653a['join'](key_1['VALSEP']),_0x58cca5=_0x1af393['match'](_0x1dc374);let _0x34fc7b,_0x28cb24,_0x5e3e94='';if(_0x58cca5){const [_0x57f648,_0x28cbe6,_0x3fddc0]=_0x58cca5;_0x5e3e94=_0x28cbe6['split'](',')['join']('/'),_0x34fc7b=_0x5e3e94+'['+_0x3fddc0+']',_0x28cb24='hook';}else{const _0x336e0b=_0x1af393['match'](_0x1c2508);if(_0x336e0b){const [_0x4d42a1,_0x1b4f75]=_0x336e0b;_0x34fc7b='['+_0x1b4f75+']',_0x28cb24='flow';}else _0x34fc7b='/',_0x28cb24='other';}return{'type':_0x1da7e3,'topic':_0x5ca88d,'gid':_0x56d2a6,'jid':_0x1af393};});}}function _0x4ff3(){const _0x2910ac=['1637613DEGtbq','1502914PFMzfy','819632axFKXR','415975uFJotl','2IZlWWm','6PRaNqA','64gsTOSS','1412060dpgyVh','1139562VMARqW'];_0x4ff3=function(){return _0x2910ac;};return _0x4ff3();}exports['ExporterService']=ExporterService;
@@ -1,67 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MapperService = void 0;
4
- const pipe_1 = require("../pipe");
5
- class MapperService {
6
- constructor(rules, data) {
7
- this.rules = rules;
8
- this.data = data;
9
- }
10
- mapRules() {
11
- return this.traverseRules(this.rules);
12
- }
13
- traverseRules(rules) {
14
- if (typeof rules === 'object' && '@pipe' in rules) {
15
- return this.pipe(rules['@pipe']);
16
- }
17
- if (typeof rules === 'object' && rules !== null) {
18
- const mappedRules = {};
19
- for (const key in rules) {
20
- if (Object.prototype.hasOwnProperty.call(rules, key)) {
21
- mappedRules[key] = this.traverseRules(rules[key]);
22
- }
23
- }
24
- return mappedRules;
25
- }
26
- else {
27
- return this.resolve(rules);
28
- }
29
- }
30
- pipe(value) {
31
- const pipe = new pipe_1.Pipe(value, this.data);
32
- return pipe.process();
33
- }
34
- resolve(value) {
35
- const pipe = new pipe_1.Pipe([[value]], this.data);
36
- return pipe.process();
37
- }
38
- static evaluate(transitionRule, context, code) {
39
- if (typeof transitionRule === 'boolean') {
40
- return transitionRule;
41
- }
42
- if ((Array.isArray(transitionRule.code) &&
43
- transitionRule.code.includes(code || 200)) ||
44
- code.toString() === (transitionRule.code || 200).toString()) {
45
- if (!transitionRule.match) {
46
- return true;
47
- }
48
- const orGate = transitionRule.gate === 'or';
49
- let allAreTrue = true;
50
- let someAreTrue = false;
51
- transitionRule.match.forEach(({ expected, actual }) => {
52
- if ((orGate && !someAreTrue) || (!orGate && allAreTrue)) {
53
- const result = pipe_1.Pipe.resolve(actual, context) === expected;
54
- if (orGate && result) {
55
- someAreTrue = true;
56
- }
57
- else if (!orGate && !result) {
58
- allAreTrue = false;
59
- }
60
- }
61
- });
62
- return orGate ? someAreTrue : allAreTrue;
63
- }
64
- return false;
65
- }
66
- }
67
- exports.MapperService = MapperService;
1
+ 'use strict';(function(_0x22bdbc,_0x3b2f01){const _0x2366ee=_0x5cd1,_0x551bc3=_0x22bdbc();while(!![]){try{const _0x420112=parseInt(_0x2366ee(0x105))/0x1*(parseInt(_0x2366ee(0x107))/0x2)+parseInt(_0x2366ee(0x106))/0x3+-parseInt(_0x2366ee(0x102))/0x4+parseInt(_0x2366ee(0x101))/0x5+parseInt(_0x2366ee(0x108))/0x6+parseInt(_0x2366ee(0x104))/0x7+-parseInt(_0x2366ee(0x100))/0x8*(parseInt(_0x2366ee(0x103))/0x9);if(_0x420112===_0x3b2f01)break;else _0x551bc3['push'](_0x551bc3['shift']());}catch(_0x4c474d){_0x551bc3['push'](_0x551bc3['shift']());}}}(_0x366f,0x9844f));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['MapperService']=void 0x0;function _0x366f(){const _0x2eaa81=['5821530zoOLJQ','24FlZpiD','5838615sUfARP','1797980kCuyAG','10340622PIMAKy','6558804gegSLc','6063DeRcrR','2789277qItYsh','170PkMiIl'];_0x366f=function(){return _0x2eaa81;};return _0x366f();}function _0x5cd1(_0x1cb20b,_0x2a16ca){const _0x366f3c=_0x366f();return _0x5cd1=function(_0x5cd1d3,_0x143e8f){_0x5cd1d3=_0x5cd1d3-0x100;let _0x35d309=_0x366f3c[_0x5cd1d3];return _0x35d309;},_0x5cd1(_0x1cb20b,_0x2a16ca);}const pipe_1=require('../pipe');class MapperService{constructor(_0x4a95a0,_0x4e1483){this['rules']=_0x4a95a0,this['data']=_0x4e1483;}['mapRules'](){return this['traverseRules'](this['rules']);}['traverseRules'](_0xc1ebf8){if(typeof _0xc1ebf8==='object'&&'@pipe'in _0xc1ebf8)return this['pipe'](_0xc1ebf8['@pipe']);if(typeof _0xc1ebf8==='object'&&_0xc1ebf8!==null){const _0x5d4086={};for(const _0x3809fe in _0xc1ebf8){Object['prototype']['hasOwnProperty']['call'](_0xc1ebf8,_0x3809fe)&&(_0x5d4086[_0x3809fe]=this['traverseRules'](_0xc1ebf8[_0x3809fe]));}return _0x5d4086;}else return this['resolve'](_0xc1ebf8);}['pipe'](_0x5152da){const _0x3ab0ec=new pipe_1['Pipe'](_0x5152da,this['data']);return _0x3ab0ec['process']();}['resolve'](_0x341e17){const _0x480d3f=new pipe_1['Pipe']([[_0x341e17]],this['data']);return _0x480d3f['process']();}static['evaluate'](_0x132d3c,_0x1e5ea1,_0x18fcc4){if(typeof _0x132d3c==='boolean')return _0x132d3c;if(Array['isArray'](_0x132d3c['code'])&&_0x132d3c['code']['includes'](_0x18fcc4||0xc8)||_0x18fcc4['toString']()===(_0x132d3c['code']||0xc8)['toString']()){if(!_0x132d3c['match'])return!![];const _0x2825eb=_0x132d3c['gate']==='or';let _0x301f8d=!![],_0xb1c9dd=![];return _0x132d3c['match']['forEach'](({expected:_0x2a1257,actual:_0x2ade00})=>{if(_0x2825eb&&!_0xb1c9dd||!_0x2825eb&&_0x301f8d){const _0x81179a=pipe_1['Pipe']['resolve'](_0x2ade00,_0x1e5ea1)===_0x2a1257;if(_0x2825eb&&_0x81179a)_0xb1c9dd=!![];else!_0x2825eb&&!_0x81179a&&(_0x301f8d=![]);}}),_0x2825eb?_0xb1c9dd:_0x301f8d;}return![];}}exports['MapperService']=MapperService;
@@ -23,7 +23,6 @@ declare class MeshData {
23
23
  random: typeof import("../meshflow/workflow").WorkflowService.random;
24
24
  search: typeof import("../meshflow/workflow").WorkflowService.search;
25
25
  getContext: typeof import("../meshflow/workflow").WorkflowService.getContext;
26
- once: typeof import("../meshflow/workflow").WorkflowService.once;
27
26
  interrupt: (entity: string, id: string, options?: JobInterruptOptions) => Promise<void>;
28
27
  execChild: <T>(options?: Partial<WorkflowOptions>) => Promise<T>;
29
28
  executeChild: <T_1>(options?: Partial<WorkflowOptions>) => Promise<T_1>;
@@ -202,17 +202,16 @@ class MeshData {
202
202
  await new Promise((resolve) => setImmediate(resolve));
203
203
  options.$guid = options.$guid ?? workflowId;
204
204
  const hotMesh = await MeshData.workflow.getHotMesh();
205
- const store = hotMesh.engine?.store;
206
- const jobKey = store?.mintKey(hotmesh_2.KeyType.JOB_STATE, {
205
+ const jobKey = hotMesh.engine?.store?.mintKey(hotmesh_2.KeyType.JOB_STATE, {
207
206
  jobId: options.$guid,
208
207
  appId: hotMesh.engine?.appId,
209
208
  });
210
- const jobResponse = ['aAa', '/t', 'aBa', this.toString(result)];
211
- await store?.exec('HSET', jobKey, ...jobResponse);
209
+ const jobResponse = { aAa: '/t', aBa: this.toString(result) };
210
+ await hotMesh.engine?.search.setFields(jobKey, jobResponse);
212
211
  }
213
212
  }
214
213
  async publishDone(result, hotMesh, options) {
215
- await hotMesh.engine?.store?.publish(hotmesh_2.KeyType.QUORUM, {
214
+ await hotMesh.engine?.subscribe?.publish(hotmesh_2.KeyType.QUORUM, {
216
215
  type: 'job',
217
216
  topic: `${hotMesh.engine.appId}.executed`,
218
217
  job: {
@@ -357,9 +356,9 @@ class MeshData {
357
356
  return await this.all(entity, id, options);
358
357
  }
359
358
  const handle = await this.getClient().workflow.getHandle(entity, entity, workflowId, options.namespace);
360
- const store = handle.hotMesh.engine?.store;
359
+ const search = handle.hotMesh.engine?.search;
361
360
  const jobKey = await this.mintKey(entity, workflowId, options.namespace);
362
- const vals = await store?.exec('HMGET', jobKey, ...prefixedFields);
361
+ const vals = await search?.getFields(jobKey, prefixedFields);
363
362
  const result = prefixedFields.reduce((obj, field, index) => {
364
363
  obj[field.substring(1)] = vals?.[index];
365
364
  return obj;
@@ -380,35 +379,29 @@ class MeshData {
380
379
  const workflowId = MeshData.mintGuid(options.prefix ?? entity, id);
381
380
  this.validate(workflowId);
382
381
  const handle = await this.getClient().workflow.getHandle(entity, entity, workflowId, options.namespace);
383
- const store = handle.hotMesh.engine?.store;
382
+ const search = handle.hotMesh.engine?.search;
384
383
  const jobKey = await this.mintKey(entity, workflowId, options.namespace);
385
- const rawResponse = (await store?.exec('HGETALL', jobKey));
386
- const responseObj = {};
387
- for (let i = 0; i < rawResponse.length; i += 2) {
388
- responseObj[rawResponse[i]] = rawResponse[i + 1];
389
- }
390
- return responseObj;
384
+ return await search?.getAllFields(jobKey);
391
385
  }
392
386
  async set(entity, id, options = {}) {
393
387
  const workflowId = MeshData.mintGuid(options.prefix ?? entity, id);
394
388
  this.validate(workflowId);
395
389
  const handle = await this.getClient().workflow.getHandle(entity, entity, workflowId, options.namespace);
396
- const store = handle.hotMesh.engine?.store;
390
+ const search = handle.hotMesh.engine?.search;
397
391
  const jobId = await this.mintKey(entity, workflowId, options.namespace);
398
- const safeArgs = [];
392
+ const safeArgs = {};
399
393
  for (const key in options.search?.data) {
400
- safeArgs.push(this.safeKey(key), options.search?.data[key].toString());
394
+ safeArgs[this.safeKey(key)] = options.search?.data[key].toString();
401
395
  }
402
- return (await store?.exec('HSET', jobId, ...safeArgs));
396
+ return await search?.setFields(jobId, safeArgs);
403
397
  }
404
398
  async incr(entity, id, field, amount, options = {}) {
405
399
  const workflowId = MeshData.mintGuid(options.prefix ?? entity, id);
406
400
  this.validate(workflowId);
407
401
  const handle = await this.getClient().workflow.getHandle(entity, entity, workflowId, options.namespace);
408
- const store = handle.hotMesh.engine?.store;
402
+ const search = handle.hotMesh.engine?.search;
409
403
  const jobId = await this.mintKey(entity, workflowId, options.namespace);
410
- const result = await store?.exec('HINCRBYFLOAT', jobId, this.safeKey(field), amount.toString());
411
- return Number(result);
404
+ return await search?.incrementFieldByFloat(jobId, this.safeKey(field), amount);
412
405
  }
413
406
  async del(entity, id, options) {
414
407
  const workflowId = MeshData.mintGuid(options.prefix ?? entity, id);
@@ -418,9 +411,9 @@ class MeshData {
418
411
  }
419
412
  const prefixedFields = options.fields.map((field) => `_${field}`);
420
413
  const handle = await this.getClient().workflow.getHandle(entity, entity, workflowId, options.namespace);
421
- const store = handle.hotMesh.engine?.store;
414
+ const search = handle.hotMesh.engine?.search;
422
415
  const jobKey = await this.mintKey(entity, workflowId, options.namespace);
423
- const count = await store?.exec('HDEL', jobKey, ...prefixedFields);
416
+ const count = await search?.deleteFields(jobKey, prefixedFields);
424
417
  return Number(count);
425
418
  }
426
419
  async findJobs(options = {}) {
@@ -539,7 +532,6 @@ MeshData.workflow = {
539
532
  random: meshflow_1.MeshFlow.workflow.random,
540
533
  search: meshflow_1.MeshFlow.workflow.search,
541
534
  getContext: meshflow_1.MeshFlow.workflow.getContext,
542
- once: meshflow_1.MeshFlow.workflow.once,
543
535
  interrupt: async (entity, id, options = {}) => {
544
536
  const jobId = MeshData.mintGuid(entity, id);
545
537
  await meshflow_1.MeshFlow.workflow.interrupt(jobId, options);
@@ -45,11 +45,8 @@ class ClientService {
45
45
  }
46
46
  };
47
47
  this.search = async (hotMeshClient, index, query) => {
48
- const store = hotMeshClient.engine.store;
49
- if (query[0]?.startsWith('FT.')) {
50
- return (await store.exec(...query));
51
- }
52
- return (await store.exec('FT.SEARCH', index, ...query));
48
+ const searchClient = hotMeshClient.engine.search;
49
+ return await searchClient.sendIndexedQuery(index, query);
53
50
  };
54
51
  this.workflow = {
55
52
  start: async (options) => {
@@ -180,11 +177,10 @@ _a = ClientService;
180
177
  ClientService.topics = [];
181
178
  ClientService.instances = new Map();
182
179
  ClientService.createStream = async (hotMeshClient, workflowTopic, namespace) => {
183
- const store = hotMeshClient.engine.store;
184
180
  const params = { appId: namespace ?? factory_1.APP_ID, topic: workflowTopic };
185
- const streamKey = store.mintKey(key_1.KeyType.STREAMS, params);
181
+ const streamKey = hotMeshClient.engine.store.mintKey(key_1.KeyType.STREAMS, params);
186
182
  try {
187
- await store.xgroup('CREATE', streamKey, 'WORKER', '$', 'MKSTREAM');
183
+ await hotMeshClient.engine.stream.createConsumerGroup(streamKey, 'WORKER');
188
184
  }
189
185
  catch (err) {
190
186
  }
@@ -1,186 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExporterService = void 0;
4
- const utils_1 = require("../../modules/utils");
5
- const serializer_1 = require("../serializer");
6
- class ExporterService {
7
- constructor(appId, store, logger) {
8
- this.appId = appId;
9
- this.logger = logger;
10
- this.store = store;
11
- }
12
- async export(jobId, options = {}) {
13
- if (!ExporterService.symbols.has(this.appId)) {
14
- const symbols = this.store.getAllSymbols();
15
- ExporterService.symbols.set(this.appId, await symbols);
16
- }
17
- const jobData = await this.store.getRaw(jobId);
18
- const jobExport = this.inflate(jobData, options);
19
- return jobExport;
20
- }
21
- inflate(jobHash, options) {
22
- const timeline = [];
23
- const state = {};
24
- const data = {};
25
- const transitionsObject = {};
26
- const regex = /^([a-zA-Z]{3}),(\d+(?:,\d+)*)/;
27
- Object.entries(jobHash).forEach(([key, value]) => {
28
- const match = key.match(regex);
29
- if (match) {
30
- this.inflateTransition(match, value, transitionsObject);
31
- }
32
- else if (key.startsWith('_')) {
33
- data[key.substring(1)] = value;
34
- }
35
- else if (key.startsWith('-')) {
36
- const keyParts = this.keyToObject(key);
37
- timeline.push({
38
- ...keyParts,
39
- key,
40
- value: this.resolveValue(value, options.values),
41
- });
42
- }
43
- else if (key.length === 3) {
44
- state[this.inflateKey(key)] = serializer_1.SerializerService.fromString(value);
45
- }
46
- });
47
- return this.filterFields({
48
- data: (0, utils_1.restoreHierarchy)(data),
49
- state: Object.entries((0, utils_1.restoreHierarchy)(state))[0][1],
50
- status: parseInt(jobHash[':'], 10),
51
- timeline: this.sortParts(timeline),
52
- transitions: this.sortEntriesByCreated(transitionsObject),
53
- }, options.block, options.allow);
54
- }
55
- resolveValue(raw, withValues) {
56
- const resolved = serializer_1.SerializerService.fromString(raw);
57
- if (withValues !== false) {
58
- return resolved;
59
- }
60
- if (resolved && typeof resolved === 'object') {
61
- if ('data' in resolved) {
62
- resolved.data = {};
63
- }
64
- if ('$error' in resolved) {
65
- resolved.$error = {};
66
- }
67
- }
68
- return resolved;
69
- }
70
- inflateKey(key) {
71
- const symbols = ExporterService.symbols.get(this.appId);
72
- if (key in symbols) {
73
- const path = symbols[key];
74
- const parts = path.split('/');
75
- return parts.join('/');
76
- }
77
- return key;
78
- }
79
- filterFields(fullObject, block = [], allow = []) {
80
- let result = {};
81
- if (allow && allow.length > 0) {
82
- allow.forEach((field) => {
83
- if (field in fullObject) {
84
- result[field] = fullObject[field];
85
- }
86
- });
87
- }
88
- else {
89
- result = { ...fullObject };
90
- }
91
- if (block && block.length > 0) {
92
- block.forEach((field) => {
93
- if (field in result) {
94
- delete result[field];
95
- }
96
- });
97
- }
98
- return result;
99
- }
100
- inflateTransition(match, value, transitionsObject) {
101
- const [_, letters, dimensions] = match;
102
- const path = this.inflateKey(letters);
103
- const parts = path.split('/');
104
- const activity = parts[0];
105
- const isCreate = path.endsWith('/output/metadata/ac');
106
- const isUpdate = path.endsWith('/output/metadata/au');
107
- if (isCreate || isUpdate) {
108
- const targetName = `${activity},${dimensions}`;
109
- const target = transitionsObject[targetName];
110
- if (!target) {
111
- transitionsObject[targetName] = {
112
- activity,
113
- dimensions,
114
- created: isCreate ? value : null,
115
- updated: isUpdate ? value : null,
116
- };
117
- }
118
- else {
119
- target[isCreate ? 'created' : 'updated'] = value;
120
- }
121
- }
122
- }
123
- sortEntriesByCreated(obj) {
124
- const entriesArray = Object.values(obj);
125
- entriesArray.sort((a, b) => {
126
- return (a.created || a.updated).localeCompare(b.created || b.updated);
127
- });
128
- return entriesArray;
129
- }
130
- keyToObject(key) {
131
- function extractDimension(label) {
132
- const parts = label.split(',');
133
- if (parts.length > 1) {
134
- parts.shift();
135
- return parts.join(',');
136
- }
137
- }
138
- const parts = key.split('-');
139
- if (parts.length === 4) {
140
- return {
141
- index: parseInt(parts[2], 10),
142
- dimension: extractDimension(parts[1]),
143
- };
144
- }
145
- else {
146
- return {
147
- index: parseInt(parts[2], 10),
148
- secondary: parseInt(parts[3], 10),
149
- dimension: extractDimension(parts[1]),
150
- };
151
- }
152
- }
153
- sortParts(parts) {
154
- return parts.sort((a, b) => {
155
- const { dimension: aDim, index: aIdx, secondary: aSec } = a;
156
- const { dimension: bDim, index: bIdx, secondary: bSec } = b;
157
- if (aDim === undefined && bDim !== undefined)
158
- return -1;
159
- if (aDim !== undefined && bDim === undefined)
160
- return 1;
161
- if (aDim !== undefined && bDim !== undefined) {
162
- if (aDim < bDim)
163
- return -1;
164
- if (aDim > bDim)
165
- return 1;
166
- }
167
- if (aIdx < bIdx)
168
- return -1;
169
- if (aIdx > bIdx)
170
- return 1;
171
- if (aSec === undefined && bSec !== undefined)
172
- return -1;
173
- if (aSec !== undefined && bSec === undefined)
174
- return 1;
175
- if (aSec !== undefined && bSec !== undefined) {
176
- if (aSec < bSec)
177
- return -1;
178
- if (aSec > bSec)
179
- return 1;
180
- }
181
- return 0;
182
- });
183
- }
184
- }
185
- exports.ExporterService = ExporterService;
186
- ExporterService.symbols = new Map();
1
+ 'use strict';function _0x50fb(_0x35ae8c,_0x3dd2d6){const _0x2caefa=_0x2cae();return _0x50fb=function(_0x50fb10,_0x49e632){_0x50fb10=_0x50fb10-0x8a;let _0x4d0e72=_0x2caefa[_0x50fb10];return _0x4d0e72;},_0x50fb(_0x35ae8c,_0x3dd2d6);}(function(_0x4d6aeb,_0x47382e){const _0x5666d2=_0x50fb,_0x57df4e=_0x4d6aeb();while(!![]){try{const _0x49e336=parseInt(_0x5666d2(0x8c))/0x1*(-parseInt(_0x5666d2(0x8b))/0x2)+parseInt(_0x5666d2(0x90))/0x3*(-parseInt(_0x5666d2(0x8e))/0x4)+-parseInt(_0x5666d2(0x8f))/0x5+parseInt(_0x5666d2(0x91))/0x6+-parseInt(_0x5666d2(0x8a))/0x7+-parseInt(_0x5666d2(0x8d))/0x8+parseInt(_0x5666d2(0x92))/0x9;if(_0x49e336===_0x47382e)break;else _0x57df4e['push'](_0x57df4e['shift']());}catch(_0x537d8d){_0x57df4e['push'](_0x57df4e['shift']());}}}(_0x2cae,0x40318));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['ExporterService']=void 0x0;const utils_1=require('../../modules/utils'),serializer_1=require('../serializer');class ExporterService{constructor(_0x447232,_0x560e22,_0x59fe84){this['appId']=_0x447232,this['logger']=_0x59fe84,this['store']=_0x560e22;}async['export'](_0x2f44a8,_0x5a245d={}){if(!ExporterService['symbols']['has'](this['appId'])){const _0x411ea4=this['store']['getAllSymbols']();ExporterService['symbols']['set'](this['appId'],await _0x411ea4);}const _0x42ea9c=await this['store']['getRaw'](_0x2f44a8),_0xc681cb=this['inflate'](_0x42ea9c,_0x5a245d);return _0xc681cb;}['inflate'](_0x497744,_0x306f5a){const _0xb8c1c6=[],_0x23144f={},_0x4b5e8c={},_0x265c4e={},_0x318f05=/^([a-zA-Z]{3}),(\d+(?:,\d+)*)/;return Object['entries'](_0x497744)['forEach'](([_0x3383ba,_0x52105c])=>{const _0xef78f9=_0x3383ba['match'](_0x318f05);if(_0xef78f9)this['inflateTransition'](_0xef78f9,_0x52105c,_0x265c4e);else{if(_0x3383ba['startsWith']('_'))_0x4b5e8c[_0x3383ba['substring'](0x1)]=_0x52105c;else{if(_0x3383ba['startsWith']('-')){const _0x5ce73a=this['keyToObject'](_0x3383ba);_0xb8c1c6['push']({..._0x5ce73a,'key':_0x3383ba,'value':this['resolveValue'](_0x52105c,_0x306f5a['values'])});}else _0x3383ba['length']===0x3&&(_0x23144f[this['inflateKey'](_0x3383ba)]=serializer_1['SerializerService']['fromString'](_0x52105c));}}}),this['filterFields']({'data':(0x0,utils_1['restoreHierarchy'])(_0x4b5e8c),'state':Object['entries']((0x0,utils_1['restoreHierarchy'])(_0x23144f))[0x0][0x1],'status':parseInt(_0x497744[':'],0xa),'timeline':this['sortParts'](_0xb8c1c6),'transitions':this['sortEntriesByCreated'](_0x265c4e)},_0x306f5a['block'],_0x306f5a['allow']);}['resolveValue'](_0x3f9991,_0x1405e7){const _0x1cca0a=serializer_1['SerializerService']['fromString'](_0x3f9991);if(_0x1405e7!==![])return _0x1cca0a;return _0x1cca0a&&typeof _0x1cca0a==='object'&&('data'in _0x1cca0a&&(_0x1cca0a['data']={}),'$error'in _0x1cca0a&&(_0x1cca0a['$error']={})),_0x1cca0a;}['inflateKey'](_0x44c895){const _0x4edc99=ExporterService['symbols']['get'](this['appId']);if(_0x44c895 in _0x4edc99){const _0xd1d1d5=_0x4edc99[_0x44c895],_0x390d7b=_0xd1d1d5['split']('/');return _0x390d7b['join']('/');}return _0x44c895;}['filterFields'](_0xfc3a3d,_0x4ad895=[],_0x4b5663=[]){let _0x1add43={};return _0x4b5663&&_0x4b5663['length']>0x0?_0x4b5663['forEach'](_0x287f1c=>{_0x287f1c in _0xfc3a3d&&(_0x1add43[_0x287f1c]=_0xfc3a3d[_0x287f1c]);}):_0x1add43={..._0xfc3a3d},_0x4ad895&&_0x4ad895['length']>0x0&&_0x4ad895['forEach'](_0x4f40e9=>{_0x4f40e9 in _0x1add43&&delete _0x1add43[_0x4f40e9];}),_0x1add43;}['inflateTransition'](_0xbeb979,_0x430e9c,_0x59b24d){const [_0x26caca,_0x2b3b90,_0xb9cd21]=_0xbeb979,_0x61546f=this['inflateKey'](_0x2b3b90),_0x514cf9=_0x61546f['split']('/'),_0x4db4b1=_0x514cf9[0x0],_0x2481c8=_0x61546f['endsWith']('/output/metadata/ac'),_0x913886=_0x61546f['endsWith']('/output/metadata/au');if(_0x2481c8||_0x913886){const _0x1c6984=_0x4db4b1+','+_0xb9cd21,_0x2fbacb=_0x59b24d[_0x1c6984];!_0x2fbacb?_0x59b24d[_0x1c6984]={'activity':_0x4db4b1,'dimensions':_0xb9cd21,'created':_0x2481c8?_0x430e9c:null,'updated':_0x913886?_0x430e9c:null}:_0x2fbacb[_0x2481c8?'created':'updated']=_0x430e9c;}}['sortEntriesByCreated'](_0x527ac9){const _0x55e79d=Object['values'](_0x527ac9);return _0x55e79d['sort']((_0x480766,_0x462c97)=>{return(_0x480766['created']||_0x480766['updated'])['localeCompare'](_0x462c97['created']||_0x462c97['updated']);}),_0x55e79d;}['keyToObject'](_0xb37eaf){function _0x42077b(_0x3f1200){const _0x247796=_0x3f1200['split'](',');if(_0x247796['length']>0x1)return _0x247796['shift'](),_0x247796['join'](',');}const _0x80136e=_0xb37eaf['split']('-');return _0x80136e['length']===0x4?{'index':parseInt(_0x80136e[0x2],0xa),'dimension':_0x42077b(_0x80136e[0x1])}:{'index':parseInt(_0x80136e[0x2],0xa),'secondary':parseInt(_0x80136e[0x3],0xa),'dimension':_0x42077b(_0x80136e[0x1])};}['sortParts'](_0xa0b706){return _0xa0b706['sort']((_0x1d3c31,_0x28feeb)=>{const {dimension:_0xa68eb3,index:_0x460d38,secondary:_0x11da3d}=_0x1d3c31,{dimension:_0x3068db,index:_0x89a786,secondary:_0xfe33a1}=_0x28feeb;if(_0xa68eb3===undefined&&_0x3068db!==undefined)return-0x1;if(_0xa68eb3!==undefined&&_0x3068db===undefined)return 0x1;if(_0xa68eb3!==undefined&&_0x3068db!==undefined){if(_0xa68eb3<_0x3068db)return-0x1;if(_0xa68eb3>_0x3068db)return 0x1;}if(_0x460d38<_0x89a786)return-0x1;if(_0x460d38>_0x89a786)return 0x1;if(_0x11da3d===undefined&&_0xfe33a1!==undefined)return-0x1;if(_0x11da3d!==undefined&&_0xfe33a1===undefined)return 0x1;if(_0x11da3d!==undefined&&_0xfe33a1!==undefined){if(_0x11da3d<_0xfe33a1)return-0x1;if(_0x11da3d>_0xfe33a1)return 0x1;}return 0x0;});}}function _0x2cae(){const _0x7242ac=['10090620imfzBI','1845382zpFpip','4652Mztojo','23MrXkVR','3068896izvdLq','8FLjDue','2412655PkMYEi','298275OsgBKq','3143238eSndhk'];_0x2cae=function(){return _0x7242ac;};return _0x2cae();}exports['ExporterService']=ExporterService,ExporterService['symbols']=new Map();
@@ -4,11 +4,13 @@ import { ConnectionService } from './connection';
4
4
  import { Search } from './search';
5
5
  import { WorkerService } from './worker';
6
6
  import { WorkflowService } from './workflow';
7
+ import { WorkflowHandleService } from './handle';
7
8
  declare class MeshFlowClass {
8
9
  constructor();
9
10
  static Client: typeof ClientService;
10
11
  static Connection: typeof ConnectionService;
11
12
  static Search: typeof Search;
13
+ static Handle: typeof WorkflowHandleService;
12
14
  static Worker: typeof WorkerService;
13
15
  static workflow: typeof WorkflowService;
14
16
  static shutdown(): Promise<void>;
@@ -7,6 +7,7 @@ const connection_1 = require("./connection");
7
7
  const search_1 = require("./search");
8
8
  const worker_1 = require("./worker");
9
9
  const workflow_1 = require("./workflow");
10
+ const handle_1 = require("./handle");
10
11
  class MeshFlowClass {
11
12
  constructor() { }
12
13
  static async shutdown() {
@@ -19,5 +20,6 @@ exports.MeshFlow = MeshFlowClass;
19
20
  MeshFlowClass.Client = client_1.ClientService;
20
21
  MeshFlowClass.Connection = connection_1.ConnectionService;
21
22
  MeshFlowClass.Search = search_1.Search;
23
+ MeshFlowClass.Handle = handle_1.WorkflowHandleService;
22
24
  MeshFlowClass.Worker = worker_1.WorkerService;
23
25
  MeshFlowClass.workflow = workflow_1.WorkflowService;
@@ -1,21 +1,20 @@
1
1
  import { HotMesh } from '../hotmesh';
2
- import { RedisClient, RedisMulti } from '../../types/redis';
3
- import { StoreService } from '../store';
2
+ import { SearchService } from '../search';
4
3
  import { WorkflowSearchOptions } from '../../types/meshflow';
5
4
  export declare class Search {
6
5
  jobId: string;
7
6
  searchSessionId: string;
8
7
  searchSessionIndex: number;
9
8
  hotMeshClient: HotMesh;
10
- store: StoreService<RedisClient, RedisMulti> | null;
9
+ search: SearchService<any> | null;
11
10
  cachedFields: Record<string, string>;
12
11
  constructor(workflowId: string, hotMeshClient: HotMesh, searchSessionId: string);
13
12
  safeKey(key: string): string;
14
13
  static configureSearchIndex(hotMeshClient: HotMesh, search?: WorkflowSearchOptions): Promise<void>;
15
14
  static listSearchIndexes(hotMeshClient: HotMesh): Promise<string[]>;
16
15
  getSearchSessionGuid(): string;
17
- set(...args: string[]): Promise<number>;
18
- get(key: string): Promise<string>;
16
+ set(...args: any[]): Promise<number>;
17
+ get(id: string): Promise<string>;
19
18
  mget(...args: string[]): Promise<string[]>;
20
19
  del(...args: string[]): Promise<number | void>;
21
20
  incr(key: string, val: number): Promise<number>;