@hotmeshio/hotmesh 0.3.6 → 0.3.7

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 (120) hide show
  1. package/build/index.d.ts +2 -1
  2. package/build/index.js +7 -1
  3. package/build/modules/key.js +1 -62
  4. package/build/modules/utils.js +1 -267
  5. package/build/package.json +12 -8
  6. package/build/services/activities/activity.js +1 -495
  7. package/build/services/activities/await.js +1 -109
  8. package/build/services/activities/cycle.js +1 -96
  9. package/build/services/activities/hook.js +1 -154
  10. package/build/services/activities/index.js +1 -20
  11. package/build/services/activities/interrupt.js +1 -149
  12. package/build/services/activities/signal.js +1 -118
  13. package/build/services/activities/trigger.js +1 -237
  14. package/build/services/activities/worker.js +1 -101
  15. package/build/services/collator/index.js +1 -197
  16. package/build/services/compiler/deployer.d.ts +3 -1
  17. package/build/services/compiler/deployer.js +1 -455
  18. package/build/services/compiler/index.d.ts +3 -1
  19. package/build/services/compiler/index.js +1 -91
  20. package/build/services/compiler/validator.js +1 -122
  21. package/build/services/engine/index.d.ts +5 -2
  22. package/build/services/engine/index.js +1 -562
  23. package/build/services/exporter/index.js +1 -93
  24. package/build/services/mapper/index.js +1 -67
  25. package/build/services/meshdata/index.d.ts +0 -1
  26. package/build/services/meshdata/index.js +16 -24
  27. package/build/services/meshflow/client.js +4 -8
  28. package/build/services/meshflow/exporter.js +1 -186
  29. package/build/services/meshflow/search.d.ts +4 -5
  30. package/build/services/meshflow/search.js +45 -35
  31. package/build/services/meshflow/workflow.d.ts +1 -1
  32. package/build/services/meshflow/workflow.js +3 -28
  33. package/build/services/pipe/functions/array.js +1 -74
  34. package/build/services/pipe/functions/bitwise.js +1 -24
  35. package/build/services/pipe/functions/conditional.js +1 -36
  36. package/build/services/pipe/functions/cron.js +1 -32
  37. package/build/services/pipe/functions/date.js +1 -164
  38. package/build/services/pipe/functions/index.js +1 -30
  39. package/build/services/pipe/functions/json.js +1 -12
  40. package/build/services/pipe/functions/logical.js +1 -12
  41. package/build/services/pipe/functions/math.js +1 -182
  42. package/build/services/pipe/functions/number.js +1 -60
  43. package/build/services/pipe/functions/object.js +1 -81
  44. package/build/services/pipe/functions/string.js +1 -69
  45. package/build/services/pipe/functions/symbol.js +1 -33
  46. package/build/services/pipe/functions/unary.js +1 -18
  47. package/build/services/pipe/index.js +1 -221
  48. package/build/services/quorum/index.d.ts +1 -1
  49. package/build/services/quorum/index.js +1 -219
  50. package/build/services/reporter/index.js +1 -331
  51. package/build/services/router/index.js +1 -420
  52. package/build/services/search/factory.d.ts +7 -0
  53. package/build/services/search/factory.js +20 -0
  54. package/build/services/search/index.d.ts +21 -0
  55. package/build/services/search/index.js +10 -0
  56. package/build/services/search/providers/redis/ioredis.d.ts +18 -0
  57. package/build/services/search/providers/redis/ioredis.js +1 -0
  58. package/build/services/search/providers/redis/redis.d.ts +18 -0
  59. package/build/services/search/providers/redis/redis.js +1 -0
  60. package/build/services/serializer/index.js +1 -265
  61. package/build/services/store/factory.d.ts +2 -1
  62. package/build/services/store/factory.js +2 -2
  63. package/build/services/store/index.d.ts +71 -97
  64. package/build/services/store/index.js +2 -939
  65. package/build/services/store/providers/postgres/postgres.d.ts +0 -0
  66. package/build/services/store/providers/postgres/postgres.js +0 -0
  67. package/build/services/store/providers/postgres/types/hash.d.ts +0 -0
  68. package/build/services/store/providers/postgres/types/hash.js +0 -0
  69. package/build/services/store/providers/postgres/types/list.d.ts +0 -0
  70. package/build/services/store/providers/postgres/types/list.js +0 -0
  71. package/build/services/store/providers/postgres/types/string.d.ts +0 -0
  72. package/build/services/store/providers/postgres/types/string.js +0 -0
  73. package/build/services/store/providers/postgres/types/zset.d.ts +0 -0
  74. package/build/services/store/providers/postgres/types/zset.js +0 -0
  75. package/build/services/store/providers/redis/_base.d.ts +98 -0
  76. package/build/services/store/providers/redis/_base.js +1 -0
  77. package/build/services/store/providers/redis/ioredis.d.ts +12 -0
  78. package/build/services/store/providers/redis/ioredis.js +1 -0
  79. package/build/services/store/providers/redis/redis.d.ts +13 -0
  80. package/build/services/store/providers/redis/redis.js +1 -0
  81. package/build/services/store/providers/store-initializable.d.ts +5 -0
  82. package/build/services/store/providers/store-initializable.js +1 -0
  83. package/build/services/stream/factory.d.ts +2 -1
  84. package/build/services/stream/factory.js +5 -5
  85. package/build/services/stream/index.d.ts +13 -14
  86. package/build/services/stream/index.js +3 -2
  87. package/build/services/stream/providers/postgres/_deploy.d.ts +4 -0
  88. package/build/services/stream/providers/postgres/_deploy.js +1 -0
  89. package/build/services/stream/providers/redis/ioredis.d.ts +21 -0
  90. package/build/services/stream/providers/redis/ioredis.js +1 -0
  91. package/build/services/stream/providers/redis/redis.d.ts +21 -0
  92. package/build/services/stream/providers/redis/redis.js +1 -0
  93. package/build/services/stream/providers/stream-initializable.d.ts +5 -0
  94. package/build/services/stream/providers/stream-initializable.js +1 -0
  95. package/build/services/sub/factory.d.ts +1 -1
  96. package/build/services/sub/factory.js +5 -5
  97. package/build/services/sub/index.d.ts +9 -7
  98. package/build/services/sub/index.js +3 -2
  99. package/build/services/sub/{clients → providers/redis}/ioredis.d.ts +7 -10
  100. package/build/services/sub/providers/redis/ioredis.js +1 -0
  101. package/build/services/sub/{clients → providers/redis}/redis.d.ts +7 -10
  102. package/build/services/sub/providers/redis/redis.js +1 -0
  103. package/build/services/task/index.js +1 -171
  104. package/build/services/telemetry/index.js +1 -225
  105. package/build/services/worker/index.d.ts +2 -2
  106. package/build/services/worker/index.js +1 -158
  107. package/build/types/redis.d.ts +5 -5
  108. package/index.ts +15 -1
  109. package/package.json +12 -8
  110. package/types/redis.ts +5 -5
  111. package/build/services/store/clients/ioredis.d.ts +0 -30
  112. package/build/services/store/clients/ioredis.js +0 -220
  113. package/build/services/store/clients/redis.d.ts +0 -32
  114. package/build/services/store/clients/redis.js +0 -319
  115. package/build/services/stream/clients/ioredis.d.ts +0 -24
  116. package/build/services/stream/clients/ioredis.js +0 -121
  117. package/build/services/stream/clients/redis.d.ts +0 -24
  118. package/build/services/stream/clients/redis.js +0 -161
  119. package/build/services/sub/clients/ioredis.js +0 -72
  120. 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(_0x284374,_0x41ee19){const _0x58c8c1=_0x1cbc,_0x1f2aa4=_0x284374();while(!![]){try{const _0x1b4f64=parseInt(_0x58c8c1(0x1da))/0x1+-parseInt(_0x58c8c1(0x1d9))/0x2*(-parseInt(_0x58c8c1(0x1db))/0x3)+parseInt(_0x58c8c1(0x1d7))/0x4+-parseInt(_0x58c8c1(0x1dc))/0x5+-parseInt(_0x58c8c1(0x1d8))/0x6*(parseInt(_0x58c8c1(0x1de))/0x7)+parseInt(_0x58c8c1(0x1dd))/0x8+-parseInt(_0x58c8c1(0x1d6))/0x9;if(_0x1b4f64===_0x41ee19)break;else _0x1f2aa4['push'](_0x1f2aa4['shift']());}catch(_0x5b0a04){_0x1f2aa4['push'](_0x1f2aa4['shift']());}}}(_0x2727,0x4518b));function _0x1cbc(_0x4fb6bd,_0x22b60a){const _0x2727a0=_0x2727();return _0x1cbc=function(_0x1cbc20,_0x2f0cce){_0x1cbc20=_0x1cbc20-0x1d6;let _0x246b3e=_0x2727a0[_0x1cbc20];return _0x246b3e;},_0x1cbc(_0x4fb6bd,_0x22b60a);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['ExporterService']=void 0x0;const key_1=require('../../modules/key'),utils_1=require('../../modules/utils'),serializer_1=require('../serializer');function _0x2727(){const _0x3716cd=['921945JFSsAD','1145910FIUbBu','4400424nDtfJs','238791euMSVM','3683214OICgfP','428124KpTCsM','60RVZUHl','2FDTSwh','298178NHGHuJ'];_0x2727=function(){return _0x3716cd;};return _0x2727();}class ExporterService{constructor(_0x2c411a,_0x3accb1,_0x5ad595){this['appId']=_0x2c411a,this['logger']=_0x5ad595,this['store']=_0x3accb1;}async['export'](_0x212973,_0x41b896={}){!this['symbols']&&(this['symbols']=this['store']['getAllSymbols'](),this['symbols']=await this['symbols']);const _0x586e38=[],_0x9dc727=await this['store']['getRaw'](_0x212973),_0x8eaeb3=this['inflate'](_0x9dc727,_0x586e38);return _0x8eaeb3;}['inflateKey'](_0x3e22e0){return _0x3e22e0 in this['symbols']?this['symbols'][_0x3e22e0]:_0x3e22e0;}['inflate'](_0x1fef6c,_0x44b6c4){const _0x58a390={'hooks':{},'main':{'cursor':-0x1,'items':[]}},_0x4f6ba9={},_0x1c0ce9=this['inflateDependencyData'](_0x44b6c4,_0x58a390),_0x4c0b4f=/^([a-zA-Z]{3}),(\d+(?:,\d+)*)/;return Object['entries'](_0x1fef6c)['forEach'](([_0x5b31a8,_0x3cd483])=>{const _0x2dec06=_0x5b31a8['match'](_0x4c0b4f);if(_0x2dec06){const [_0x45b358,_0x4df11e,_0x5c05ee]=_0x2dec06,_0x1fcae0=this['inflateKey'](_0x4df11e),_0x27482c=''+_0x5c05ee['replace'](/,/g,'/'),_0x128aa3=serializer_1['SerializerService']['fromString'](_0x3cd483);_0x4f6ba9[_0x27482c+'/'+_0x1fcae0]=_0x128aa3;}else _0x5b31a8['length']===0x3&&(_0x4f6ba9[this['inflateKey'](_0x5b31a8)]=serializer_1['SerializerService']['fromString'](_0x3cd483));}),{'dependencies':_0x1c0ce9,'process':(0x0,utils_1['restoreHierarchy'])(_0x4f6ba9),'status':_0x1fef6c[':']};}['inflateDependencyData'](_0x3e7f2e,_0xed1cf8){const _0x4b96b2=/([0-9,]+)-(\d+)$/,_0x1ea0d5=/-(\d+)$/;return _0x3e7f2e['map']((_0x51c90b,_0x592be5)=>{const [_0xb50cb6,_0x1ebf7f,_0x245513,_0x49faec,..._0xbf1d3b]=_0x51c90b['split'](key_1['VALSEP']),_0x473c8b=_0xbf1d3b['join'](key_1['VALSEP']),_0x5696bf=_0x473c8b['match'](_0x4b96b2);let _0x108ce2,_0x1f5380,_0x35a567='';if(_0x5696bf){const [_0x4a2ad4,_0x1fcebd,_0x527680]=_0x5696bf;_0x35a567=_0x1fcebd['split'](',')['join']('/'),_0x108ce2=_0x35a567+'['+_0x527680+']',_0x1f5380='hook';}else{const _0x512d1a=_0x473c8b['match'](_0x1ea0d5);if(_0x512d1a){const [_0x6edfc6,_0x4c99ef]=_0x512d1a;_0x108ce2='['+_0x4c99ef+']',_0x1f5380='flow';}else _0x108ce2='/',_0x1f5380='other';}return{'type':_0xb50cb6,'topic':_0x1ebf7f,'gid':_0x245513,'jid':_0x473c8b};});}}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 _0xa339(){const _0x3e492c=['9YjVcZL','184554XNZEIK','778492khrNAJ','32NMTwJb','4307280qxwasf','32859cxHdbD','848898WrtqIx','959455RxHEgB','1625064QXkteN'];_0xa339=function(){return _0x3e492c;};return _0xa339();}(function(_0x368632,_0x573daa){const _0x44800c=_0x19e5,_0x225755=_0x368632();while(!![]){try{const _0x3a4fc6=-parseInt(_0x44800c(0x7b))/0x1+-parseInt(_0x44800c(0x77))/0x2*(-parseInt(_0x44800c(0x76))/0x3)+-parseInt(_0x44800c(0x78))/0x4+-parseInt(_0x44800c(0x7d))/0x5+parseInt(_0x44800c(0x7a))/0x6+parseInt(_0x44800c(0x75))/0x7+-parseInt(_0x44800c(0x79))/0x8*(parseInt(_0x44800c(0x7c))/0x9);if(_0x3a4fc6===_0x573daa)break;else _0x225755['push'](_0x225755['shift']());}catch(_0x1c9785){_0x225755['push'](_0x225755['shift']());}}}(_0xa339,0x6907a));function _0x19e5(_0x151b91,_0x85e33f){const _0xa33904=_0xa339();return _0x19e5=function(_0x19e5fd,_0x470794){_0x19e5fd=_0x19e5fd-0x75;let _0x511ec0=_0xa33904[_0x19e5fd];return _0x511ec0;},_0x19e5(_0x151b91,_0x85e33f);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['MapperService']=void 0x0;const pipe_1=require('../pipe');class MapperService{constructor(_0x49de75,_0x7b6e09){this['rules']=_0x49de75,this['data']=_0x7b6e09;}['mapRules'](){return this['traverseRules'](this['rules']);}['traverseRules'](_0xa05658){if(typeof _0xa05658==='object'&&'@pipe'in _0xa05658)return this['pipe'](_0xa05658['@pipe']);if(typeof _0xa05658==='object'&&_0xa05658!==null){const _0x2535e3={};for(const _0x4f79a2 in _0xa05658){Object['prototype']['hasOwnProperty']['call'](_0xa05658,_0x4f79a2)&&(_0x2535e3[_0x4f79a2]=this['traverseRules'](_0xa05658[_0x4f79a2]));}return _0x2535e3;}else return this['resolve'](_0xa05658);}['pipe'](_0x41e02e){const _0x4e7b97=new pipe_1['Pipe'](_0x41e02e,this['data']);return _0x4e7b97['process']();}['resolve'](_0x2bf1c0){const _0x33809f=new pipe_1['Pipe']([[_0x2bf1c0]],this['data']);return _0x33809f['process']();}static['evaluate'](_0x4eabf8,_0x3f352a,_0x11db6a){if(typeof _0x4eabf8==='boolean')return _0x4eabf8;if(Array['isArray'](_0x4eabf8['code'])&&_0x4eabf8['code']['includes'](_0x11db6a||0xc8)||_0x11db6a['toString']()===(_0x4eabf8['code']||0xc8)['toString']()){if(!_0x4eabf8['match'])return!![];const _0x2d393d=_0x4eabf8['gate']==='or';let _0x123614=!![],_0x280235=![];return _0x4eabf8['match']['forEach'](({expected:_0x466d42,actual:_0x59ea92})=>{if(_0x2d393d&&!_0x280235||!_0x2d393d&&_0x123614){const _0x58f5b6=pipe_1['Pipe']['resolve'](_0x59ea92,_0x3f352a)===_0x466d42;if(_0x2d393d&&_0x58f5b6)_0x280235=!![];else!_0x2d393d&&!_0x58f5b6&&(_0x123614=![]);}}),_0x2d393d?_0x280235:_0x123614;}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(_0x354874,_0x4ec742){const _0x369e7d=_0x2f7e,_0x35b1ee=_0x354874();while(!![]){try{const _0x94e592=-parseInt(_0x369e7d(0x1ab))/0x1+parseInt(_0x369e7d(0x1aa))/0x2+parseInt(_0x369e7d(0x1ae))/0x3*(parseInt(_0x369e7d(0x1a9))/0x4)+parseInt(_0x369e7d(0x1b0))/0x5+parseInt(_0x369e7d(0x1ad))/0x6+parseInt(_0x369e7d(0x1ac))/0x7+-parseInt(_0x369e7d(0x1af))/0x8;if(_0x94e592===_0x4ec742)break;else _0x35b1ee['push'](_0x35b1ee['shift']());}catch(_0x5df607){_0x35b1ee['push'](_0x35b1ee['shift']());}}}(_0xeb53,0xf1da5));function _0xeb53(){const _0x579aa8=['4330860kFFhru','6476TrRbQM','794264yoKIwr','1641195phKXod','1361269XxAQwP','9858468wXdSzG','1218WqKmQP','9010712HsiwhO'];_0xeb53=function(){return _0x579aa8;};return _0xeb53();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['ExporterService']=void 0x0;const utils_1=require('../../modules/utils'),serializer_1=require('../serializer');function _0x2f7e(_0x53020d,_0x192d98){const _0xeb535a=_0xeb53();return _0x2f7e=function(_0x2f7eff,_0x4e1180){_0x2f7eff=_0x2f7eff-0x1a9;let _0x5171d1=_0xeb535a[_0x2f7eff];return _0x5171d1;},_0x2f7e(_0x53020d,_0x192d98);}class ExporterService{constructor(_0x29dc91,_0x34614e,_0x138654){this['appId']=_0x29dc91,this['logger']=_0x138654,this['store']=_0x34614e;}async['export'](_0x3ccae0,_0x7349ed={}){if(!ExporterService['symbols']['has'](this['appId'])){const _0x4413d7=this['store']['getAllSymbols']();ExporterService['symbols']['set'](this['appId'],await _0x4413d7);}const _0x48efce=await this['store']['getRaw'](_0x3ccae0),_0x2e0036=this['inflate'](_0x48efce,_0x7349ed);return _0x2e0036;}['inflate'](_0x4339a7,_0x58e51e){const _0x3109be=[],_0x4118b0={},_0x2d74c4={},_0x46f459={},_0x508f41=/^([a-zA-Z]{3}),(\d+(?:,\d+)*)/;return Object['entries'](_0x4339a7)['forEach'](([_0x5355ca,_0x4345f2])=>{const _0x5359c0=_0x5355ca['match'](_0x508f41);if(_0x5359c0)this['inflateTransition'](_0x5359c0,_0x4345f2,_0x46f459);else{if(_0x5355ca['startsWith']('_'))_0x2d74c4[_0x5355ca['substring'](0x1)]=_0x4345f2;else{if(_0x5355ca['startsWith']('-')){const _0x5bd6ff=this['keyToObject'](_0x5355ca);_0x3109be['push']({..._0x5bd6ff,'key':_0x5355ca,'value':this['resolveValue'](_0x4345f2,_0x58e51e['values'])});}else _0x5355ca['length']===0x3&&(_0x4118b0[this['inflateKey'](_0x5355ca)]=serializer_1['SerializerService']['fromString'](_0x4345f2));}}}),this['filterFields']({'data':(0x0,utils_1['restoreHierarchy'])(_0x2d74c4),'state':Object['entries']((0x0,utils_1['restoreHierarchy'])(_0x4118b0))[0x0][0x1],'status':parseInt(_0x4339a7[':'],0xa),'timeline':this['sortParts'](_0x3109be),'transitions':this['sortEntriesByCreated'](_0x46f459)},_0x58e51e['block'],_0x58e51e['allow']);}['resolveValue'](_0x39f4a7,_0x4806af){const _0x2a201c=serializer_1['SerializerService']['fromString'](_0x39f4a7);if(_0x4806af!==![])return _0x2a201c;return _0x2a201c&&typeof _0x2a201c==='object'&&('data'in _0x2a201c&&(_0x2a201c['data']={}),'$error'in _0x2a201c&&(_0x2a201c['$error']={})),_0x2a201c;}['inflateKey'](_0x1391a8){const _0x432734=ExporterService['symbols']['get'](this['appId']);if(_0x1391a8 in _0x432734){const _0x4460b3=_0x432734[_0x1391a8],_0x4b5625=_0x4460b3['split']('/');return _0x4b5625['join']('/');}return _0x1391a8;}['filterFields'](_0x407c28,_0x5c5490=[],_0x2aace2=[]){let _0x57abbf={};return _0x2aace2&&_0x2aace2['length']>0x0?_0x2aace2['forEach'](_0x5e585a=>{_0x5e585a in _0x407c28&&(_0x57abbf[_0x5e585a]=_0x407c28[_0x5e585a]);}):_0x57abbf={..._0x407c28},_0x5c5490&&_0x5c5490['length']>0x0&&_0x5c5490['forEach'](_0x19a31e=>{_0x19a31e in _0x57abbf&&delete _0x57abbf[_0x19a31e];}),_0x57abbf;}['inflateTransition'](_0x237278,_0x11d560,_0xf7aa5d){const [_0x203c86,_0x14668f,_0x2916b9]=_0x237278,_0x2ed7b4=this['inflateKey'](_0x14668f),_0x4c4dee=_0x2ed7b4['split']('/'),_0x3dd3ec=_0x4c4dee[0x0],_0x29a371=_0x2ed7b4['endsWith']('/output/metadata/ac'),_0x1d68e2=_0x2ed7b4['endsWith']('/output/metadata/au');if(_0x29a371||_0x1d68e2){const _0x2b42cd=_0x3dd3ec+','+_0x2916b9,_0x290634=_0xf7aa5d[_0x2b42cd];!_0x290634?_0xf7aa5d[_0x2b42cd]={'activity':_0x3dd3ec,'dimensions':_0x2916b9,'created':_0x29a371?_0x11d560:null,'updated':_0x1d68e2?_0x11d560:null}:_0x290634[_0x29a371?'created':'updated']=_0x11d560;}}['sortEntriesByCreated'](_0x4e6bf6){const _0x39a9e7=Object['values'](_0x4e6bf6);return _0x39a9e7['sort']((_0x4ddad2,_0x3912d0)=>{return(_0x4ddad2['created']||_0x4ddad2['updated'])['localeCompare'](_0x3912d0['created']||_0x3912d0['updated']);}),_0x39a9e7;}['keyToObject'](_0x5dbb85){function _0x5865b2(_0x4d13b8){const _0x2b8546=_0x4d13b8['split'](',');if(_0x2b8546['length']>0x1)return _0x2b8546['shift'](),_0x2b8546['join'](',');}const _0x466260=_0x5dbb85['split']('-');return _0x466260['length']===0x4?{'index':parseInt(_0x466260[0x2],0xa),'dimension':_0x5865b2(_0x466260[0x1])}:{'index':parseInt(_0x466260[0x2],0xa),'secondary':parseInt(_0x466260[0x3],0xa),'dimension':_0x5865b2(_0x466260[0x1])};}['sortParts'](_0x3ff78a){return _0x3ff78a['sort']((_0x5b3c16,_0x2e6798)=>{const {dimension:_0x3f0305,index:_0x4279d5,secondary:_0x408d02}=_0x5b3c16,{dimension:_0x54f467,index:_0x1c5636,secondary:_0x1312fa}=_0x2e6798;if(_0x3f0305===undefined&&_0x54f467!==undefined)return-0x1;if(_0x3f0305!==undefined&&_0x54f467===undefined)return 0x1;if(_0x3f0305!==undefined&&_0x54f467!==undefined){if(_0x3f0305<_0x54f467)return-0x1;if(_0x3f0305>_0x54f467)return 0x1;}if(_0x4279d5<_0x1c5636)return-0x1;if(_0x4279d5>_0x1c5636)return 0x1;if(_0x408d02===undefined&&_0x1312fa!==undefined)return-0x1;if(_0x408d02!==undefined&&_0x1312fa===undefined)return 0x1;if(_0x408d02!==undefined&&_0x1312fa!==undefined){if(_0x408d02<_0x1312fa)return-0x1;if(_0x408d02>_0x1312fa)return 0x1;}return 0x0;});}}exports['ExporterService']=ExporterService,ExporterService['symbols']=new Map();
@@ -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>;