@hotmeshio/hotmesh 0.3.5 → 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 (132) hide show
  1. package/build/index.d.ts +6 -4
  2. package/build/index.js +13 -5
  3. package/build/modules/key.js +1 -62
  4. package/build/modules/utils.d.ts +1 -0
  5. package/build/modules/utils.js +1 -242
  6. package/build/package.json +14 -9
  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.d.ts +0 -1
  15. package/build/services/activities/trigger.js +1 -269
  16. package/build/services/activities/worker.js +1 -101
  17. package/build/services/collator/index.js +1 -197
  18. package/build/services/compiler/deployer.d.ts +3 -1
  19. package/build/services/compiler/deployer.js +1 -455
  20. package/build/services/compiler/index.d.ts +3 -1
  21. package/build/services/compiler/index.js +1 -91
  22. package/build/services/compiler/validator.js +1 -122
  23. package/build/services/engine/index.d.ts +5 -2
  24. package/build/services/engine/index.js +1 -583
  25. package/build/services/exporter/index.js +1 -93
  26. package/build/services/mapper/index.js +1 -67
  27. package/build/services/meshdata/index.d.ts +0 -1
  28. package/build/services/meshdata/index.js +16 -24
  29. package/build/services/meshflow/client.js +4 -8
  30. package/build/services/meshflow/exporter.js +1 -186
  31. package/build/services/meshflow/search.d.ts +4 -5
  32. package/build/services/meshflow/search.js +48 -36
  33. package/build/services/meshflow/worker.js +1 -1
  34. package/build/services/meshflow/workflow.d.ts +1 -1
  35. package/build/services/meshflow/workflow.js +5 -30
  36. package/build/services/meshos/index.d.ts +81 -0
  37. package/build/services/meshos/index.js +339 -0
  38. package/build/services/pipe/functions/array.js +1 -74
  39. package/build/services/pipe/functions/bitwise.js +1 -24
  40. package/build/services/pipe/functions/conditional.js +1 -36
  41. package/build/services/pipe/functions/cron.js +1 -32
  42. package/build/services/pipe/functions/date.js +1 -164
  43. package/build/services/pipe/functions/index.js +1 -30
  44. package/build/services/pipe/functions/json.js +1 -12
  45. package/build/services/pipe/functions/logical.js +1 -12
  46. package/build/services/pipe/functions/math.js +1 -182
  47. package/build/services/pipe/functions/number.js +1 -60
  48. package/build/services/pipe/functions/object.js +1 -81
  49. package/build/services/pipe/functions/string.js +1 -69
  50. package/build/services/pipe/functions/symbol.js +1 -33
  51. package/build/services/pipe/functions/unary.js +1 -18
  52. package/build/services/pipe/index.js +1 -221
  53. package/build/services/quorum/index.d.ts +1 -1
  54. package/build/services/quorum/index.js +1 -233
  55. package/build/services/reporter/index.js +1 -331
  56. package/build/services/router/index.js +1 -420
  57. package/build/services/search/factory.d.ts +7 -0
  58. package/build/services/search/factory.js +20 -0
  59. package/build/services/search/index.d.ts +21 -0
  60. package/build/services/search/index.js +10 -0
  61. package/build/services/search/providers/redis/ioredis.d.ts +18 -0
  62. package/build/services/search/providers/redis/ioredis.js +1 -0
  63. package/build/services/search/providers/redis/redis.d.ts +18 -0
  64. package/build/services/search/providers/redis/redis.js +1 -0
  65. package/build/services/serializer/index.js +1 -265
  66. package/build/services/store/factory.d.ts +8 -0
  67. package/build/services/store/factory.js +20 -0
  68. package/build/services/store/index.d.ts +71 -98
  69. package/build/services/store/index.js +2 -941
  70. package/build/services/store/providers/postgres/postgres.d.ts +0 -0
  71. package/build/services/store/providers/postgres/postgres.js +0 -0
  72. package/build/services/store/providers/postgres/types/hash.d.ts +0 -0
  73. package/build/services/store/providers/postgres/types/hash.js +0 -0
  74. package/build/services/store/providers/postgres/types/list.d.ts +0 -0
  75. package/build/services/store/providers/postgres/types/list.js +0 -0
  76. package/build/services/store/providers/postgres/types/string.d.ts +0 -0
  77. package/build/services/store/providers/postgres/types/string.js +0 -0
  78. package/build/services/store/providers/postgres/types/zset.d.ts +0 -0
  79. package/build/services/store/providers/postgres/types/zset.js +0 -0
  80. package/build/services/store/providers/redis/_base.d.ts +98 -0
  81. package/build/services/store/providers/redis/_base.js +1 -0
  82. package/build/services/store/providers/redis/ioredis.d.ts +12 -0
  83. package/build/services/store/providers/redis/ioredis.js +1 -0
  84. package/build/services/store/providers/redis/redis.d.ts +13 -0
  85. package/build/services/store/providers/redis/redis.js +1 -0
  86. package/build/services/store/providers/store-initializable.d.ts +5 -0
  87. package/build/services/store/providers/store-initializable.js +1 -0
  88. package/build/services/stream/factory.d.ts +8 -0
  89. package/build/services/stream/factory.js +20 -0
  90. package/build/services/stream/index.d.ts +13 -14
  91. package/build/services/stream/index.js +3 -2
  92. package/build/services/stream/providers/postgres/_deploy.d.ts +4 -0
  93. package/build/services/stream/providers/postgres/_deploy.js +1 -0
  94. package/build/services/stream/providers/redis/ioredis.d.ts +21 -0
  95. package/build/services/stream/providers/redis/ioredis.js +1 -0
  96. package/build/services/stream/providers/redis/redis.d.ts +21 -0
  97. package/build/services/stream/providers/redis/redis.js +1 -0
  98. package/build/services/stream/providers/stream-initializable.d.ts +5 -0
  99. package/build/services/stream/providers/stream-initializable.js +1 -0
  100. package/build/services/sub/factory.d.ts +7 -0
  101. package/build/services/sub/factory.js +20 -0
  102. package/build/services/sub/index.d.ts +9 -7
  103. package/build/services/sub/index.js +3 -2
  104. package/build/services/sub/{clients → providers/redis}/ioredis.d.ts +7 -10
  105. package/build/services/sub/providers/redis/ioredis.js +1 -0
  106. package/build/services/sub/{clients → providers/redis}/redis.d.ts +7 -10
  107. package/build/services/sub/providers/redis/redis.js +1 -0
  108. package/build/services/task/index.js +1 -171
  109. package/build/services/telemetry/index.js +1 -225
  110. package/build/services/worker/index.d.ts +2 -2
  111. package/build/services/worker/index.js +1 -179
  112. package/build/types/index.d.ts +1 -0
  113. package/build/types/manifest.d.ts +49 -0
  114. package/build/types/manifest.js +2 -0
  115. package/build/types/redis.d.ts +5 -5
  116. package/index.ts +19 -4
  117. package/package.json +14 -9
  118. package/typedoc.json +1 -0
  119. package/types/index.ts +15 -0
  120. package/types/manifest.ts +68 -0
  121. package/types/meshflow.ts +1 -1
  122. package/types/redis.ts +5 -5
  123. package/build/services/store/clients/ioredis.d.ts +0 -30
  124. package/build/services/store/clients/ioredis.js +0 -220
  125. package/build/services/store/clients/redis.d.ts +0 -32
  126. package/build/services/store/clients/redis.js +0 -319
  127. package/build/services/stream/clients/ioredis.d.ts +0 -24
  128. package/build/services/stream/clients/ioredis.js +0 -121
  129. package/build/services/stream/clients/redis.d.ts +0 -24
  130. package/build/services/stream/clients/redis.js +0 -161
  131. package/build/services/sub/clients/ioredis.js +0 -72
  132. package/build/services/sub/clients/redis.js +0 -63
@@ -1,455 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Deployer = void 0;
4
- const key_1 = require("../../modules/key");
5
- const utils_1 = require("../../modules/utils");
6
- const collator_1 = require("../collator");
7
- const serializer_1 = require("../serializer");
8
- const pipe_1 = require("../pipe");
9
- const validator_1 = require("./validator");
10
- const DEFAULT_METADATA_RANGE_SIZE = 26;
11
- const DEFAULT_DATA_RANGE_SIZE = 260;
12
- const DEFAULT_RANGE_SIZE = DEFAULT_METADATA_RANGE_SIZE + DEFAULT_DATA_RANGE_SIZE;
13
- class Deployer {
14
- constructor(manifest) {
15
- this.manifest = null;
16
- this.manifest = manifest;
17
- }
18
- async deploy(store) {
19
- this.store = store;
20
- collator_1.CollatorService.compile(this.manifest.app.graphs);
21
- this.convertActivitiesToHooks();
22
- this.convertTopicsToTypes();
23
- this.copyJobSchemas();
24
- this.bindBackRefs();
25
- this.bindParents();
26
- this.bindCycleTarget();
27
- this.resolveMappingDependencies();
28
- this.resolveJobMapsPaths();
29
- await this.generateSymKeys();
30
- await this.generateSymVals();
31
- await this.deployHookPatterns();
32
- await this.deployActivitySchemas();
33
- await this.deploySubscriptions();
34
- await this.deployTransitions();
35
- await this.deployConsumerGroups();
36
- }
37
- getVID() {
38
- return {
39
- id: this.manifest.app.id,
40
- version: this.manifest.app.version,
41
- };
42
- }
43
- async generateSymKeys() {
44
- for (const graph of this.manifest.app.graphs) {
45
- const [, trigger] = this.findTrigger(graph);
46
- const topic = trigger.subscribes;
47
- const [lower, upper, symbols] = await this.store.reserveSymbolRange(`$${topic}`, DEFAULT_RANGE_SIZE, 'JOB');
48
- const prefix = '';
49
- const newSymbols = this.bindSymbols(lower, upper, symbols, prefix, trigger.PRODUCES);
50
- if (Object.keys(newSymbols).length) {
51
- await this.store.addSymbols(`$${topic}`, newSymbols);
52
- }
53
- for (const [activityId, activity] of Object.entries(graph.activities)) {
54
- const [lower, upper, symbols] = await this.store.reserveSymbolRange(activityId, DEFAULT_RANGE_SIZE, 'ACTIVITY');
55
- const prefix = `${activityId}/`;
56
- this.bindSelf(activity.consumes, activity.produces, activityId);
57
- const newSymbols = this.bindSymbols(lower, upper, symbols, prefix, activity.produces);
58
- if (Object.keys(newSymbols).length) {
59
- await this.store.addSymbols(activityId, newSymbols);
60
- }
61
- }
62
- }
63
- }
64
- bindSelf(consumes, produces, activityId) {
65
- for (const selfId of [activityId, '$self']) {
66
- const selfConsumes = consumes[selfId];
67
- if (selfConsumes) {
68
- for (const path of selfConsumes) {
69
- if (!produces.includes(path)) {
70
- produces.push(path);
71
- }
72
- }
73
- }
74
- }
75
- }
76
- bindSymbols(startIndex, maxIndex, existingSymbols, prefix, produces) {
77
- const newSymbols = {};
78
- const currentSymbols = { ...existingSymbols };
79
- for (const path of produces) {
80
- const fullPath = `${prefix}${path}`;
81
- if (!currentSymbols[fullPath]) {
82
- if (startIndex > maxIndex) {
83
- throw new Error('Symbol index out of bounds');
84
- }
85
- const symbol = (0, utils_1.getSymKey)(startIndex);
86
- startIndex++;
87
- newSymbols[fullPath] = symbol;
88
- currentSymbols[fullPath] = symbol;
89
- }
90
- }
91
- return newSymbols;
92
- }
93
- copyJobSchemas() {
94
- const graphs = this.manifest.app.graphs;
95
- for (const graph of graphs) {
96
- const jobSchema = graph.output?.schema;
97
- const outputSchema = graph.input?.schema;
98
- if (!jobSchema && !outputSchema)
99
- continue;
100
- const activities = graph.activities;
101
- for (const activityKey in activities) {
102
- if (activities[activityKey].type === 'trigger') {
103
- const trigger = activities[activityKey];
104
- if (jobSchema) {
105
- if (!trigger.job) {
106
- trigger.job = {};
107
- }
108
- trigger.job.schema = jobSchema;
109
- }
110
- if (outputSchema) {
111
- trigger.output = { schema: outputSchema };
112
- }
113
- }
114
- }
115
- }
116
- }
117
- bindBackRefs() {
118
- for (const graph of this.manifest.app.graphs) {
119
- const activities = graph.activities;
120
- const triggerId = this.findTrigger(graph)[0];
121
- for (const activityKey in activities) {
122
- activities[activityKey].trigger = triggerId;
123
- activities[activityKey].subscribes = graph.subscribes;
124
- if (graph.publishes) {
125
- activities[activityKey].publishes = graph.publishes;
126
- }
127
- activities[activityKey].expire = graph.expire ?? undefined;
128
- activities[activityKey].persistent = graph.persistent ?? undefined;
129
- }
130
- }
131
- }
132
- bindCycleTarget() {
133
- for (const graph of this.manifest.app.graphs) {
134
- const activities = graph.activities;
135
- for (const activityKey in activities) {
136
- const activity = activities[activityKey];
137
- if (activity.type === 'cycle') {
138
- activities[activity.ancestor].cycle = true;
139
- }
140
- }
141
- }
142
- }
143
- convertTopicsToTypes() {
144
- for (const graph of this.manifest.app.graphs) {
145
- const activities = graph.activities;
146
- for (const activityKey in activities) {
147
- const activity = activities[activityKey];
148
- if (['worker', 'await'].includes(activity.type) &&
149
- activity.topic &&
150
- !activity.subtype) {
151
- activity.subtype = activity.topic;
152
- }
153
- }
154
- }
155
- }
156
- convertActivitiesToHooks() {
157
- for (const graph of this.manifest.app.graphs) {
158
- const activities = graph.activities;
159
- for (const activityKey in activities) {
160
- const activity = activities[activityKey];
161
- if (['activity'].includes(activity.type)) {
162
- activity.type = 'hook';
163
- }
164
- }
165
- }
166
- }
167
- async bindParents() {
168
- const graphs = this.manifest.app.graphs;
169
- for (const graph of graphs) {
170
- if (graph.transitions) {
171
- for (const fromActivity in graph.transitions) {
172
- const toTransitions = graph.transitions[fromActivity];
173
- for (const transition of toTransitions) {
174
- const to = transition.to;
175
- graph.activities[to].parent = fromActivity;
176
- }
177
- graph.activities[fromActivity].transitions = toTransitions;
178
- }
179
- }
180
- }
181
- }
182
- collectValues(schema, values) {
183
- for (const [key, value] of Object.entries(schema)) {
184
- if (key === 'enum' || key === 'examples' || key === 'default') {
185
- if (Array.isArray(value)) {
186
- for (const v of value) {
187
- if (typeof v === 'string' && v.length > 5) {
188
- values.add(v);
189
- }
190
- }
191
- }
192
- else if (typeof value === 'string' && value.length > 5) {
193
- values.add(value);
194
- }
195
- }
196
- else if (typeof value === 'object') {
197
- this.collectValues(value, values);
198
- }
199
- }
200
- }
201
- traverse(obj, values) {
202
- for (const value of Object.values(obj)) {
203
- if (typeof value === 'object') {
204
- if ('schema' in value) {
205
- this.collectValues(value.schema, values);
206
- }
207
- else {
208
- this.traverse(value, values);
209
- }
210
- }
211
- }
212
- }
213
- async generateSymVals() {
214
- const uniqueStrings = new Set();
215
- for (const graph of this.manifest.app.graphs) {
216
- this.traverse(graph, uniqueStrings);
217
- }
218
- const existingSymbols = await this.store.getSymbolValues();
219
- const startIndex = Object.keys(existingSymbols).length;
220
- const maxIndex = Math.pow(52, 2) - 1;
221
- const newSymbols = serializer_1.SerializerService.filterSymVals(startIndex, maxIndex, existingSymbols, uniqueStrings);
222
- await this.store.addSymbolValues(newSymbols);
223
- }
224
- resolveJobMapsPaths() {
225
- function parsePaths(obj) {
226
- const result = [];
227
- function traverse(obj, path = []) {
228
- for (const key in obj) {
229
- if (typeof obj[key] === 'object' &&
230
- obj[key] !== null &&
231
- !('@pipe' in obj[key])) {
232
- const newPath = [...path, key];
233
- traverse(obj[key], newPath);
234
- }
235
- else {
236
- const pathName = [...path, key].join('/');
237
- if (!pathName.includes('[')) {
238
- const finalPath = `data/${pathName}`;
239
- if (!result.includes(finalPath)) {
240
- result.push(finalPath);
241
- }
242
- }
243
- else {
244
- const [left, right] = pathName.split('[');
245
- const [amount, _] = right.split(']');
246
- if (!isNaN(parseInt(amount))) {
247
- for (let i = 0; i < parseInt(amount); i++) {
248
- const finalPath = `data/${left}/${i}`;
249
- if (!result.includes(finalPath)) {
250
- result.push(finalPath);
251
- }
252
- }
253
- }
254
- }
255
- }
256
- }
257
- }
258
- if (obj) {
259
- traverse(obj);
260
- }
261
- return result;
262
- }
263
- for (const graph of this.manifest.app.graphs) {
264
- let results = [];
265
- const [, trigger] = this.findTrigger(graph);
266
- for (const activityKey in graph.activities) {
267
- const activity = graph.activities[activityKey];
268
- results = results.concat(parsePaths(activity.job?.maps));
269
- }
270
- trigger.PRODUCES = results;
271
- }
272
- }
273
- resolveMappingDependencies() {
274
- const dynamicMappingRules = [];
275
- function traverse(obj, consumes) {
276
- for (const key in obj) {
277
- if (typeof obj[key] === 'string') {
278
- const stringValue = obj[key];
279
- const dynamicMappingRuleMatch = stringValue.match(/^\{[^@].*}$/);
280
- if (dynamicMappingRuleMatch &&
281
- !validator_1.Validator.CONTEXT_VARS.includes(stringValue)) {
282
- if (stringValue.split('.')[1] !== 'input') {
283
- dynamicMappingRules.push(stringValue);
284
- consumes.push(stringValue);
285
- }
286
- }
287
- }
288
- else if (typeof obj[key] === 'object' && obj[key] !== null) {
289
- traverse(obj[key], consumes);
290
- }
291
- }
292
- }
293
- const graphs = this.manifest.app.graphs;
294
- for (const graph of graphs) {
295
- const activities = graph.activities;
296
- for (const activityId in activities) {
297
- const activity = activities[activityId];
298
- activity.consumes = [];
299
- traverse(activity, activity.consumes);
300
- activity.consumes = this.groupMappingRules(activity.consumes);
301
- }
302
- }
303
- const groupedRules = this.groupMappingRules(dynamicMappingRules);
304
- for (const graph of graphs) {
305
- const activities = graph.activities;
306
- for (const activityId in activities) {
307
- const activity = activities[activityId];
308
- activity.produces = groupedRules[`${activityId}`] || [];
309
- }
310
- }
311
- }
312
- groupMappingRules(rules) {
313
- rules = Array.from(new Set(rules)).sort();
314
- const groupedRules = {};
315
- for (const rule of rules) {
316
- const [group, resolved] = this.resolveMappableValue(rule);
317
- if (!groupedRules[group]) {
318
- groupedRules[group] = [];
319
- }
320
- groupedRules[group].push(resolved);
321
- }
322
- return groupedRules;
323
- }
324
- resolveMappableValue(mappable) {
325
- mappable = mappable.substring(1, mappable.length - 1);
326
- const parts = mappable.split('.');
327
- if (parts[0] === '$job') {
328
- const [group, ...path] = parts;
329
- return [group, path.join('/')];
330
- }
331
- else {
332
- const [group, type, subtype, ...path] = parts;
333
- const prefix = {
334
- hook: 'hook/data',
335
- input: 'input/data',
336
- output: subtype === 'data' ? 'output/data' : 'output/metadata',
337
- }[type];
338
- return [group, `${prefix}/${path.join('/')}`];
339
- }
340
- }
341
- async deployActivitySchemas() {
342
- const graphs = this.manifest.app.graphs;
343
- const activitySchemas = {};
344
- for (const graph of graphs) {
345
- const activities = graph.activities;
346
- for (const activityKey in activities) {
347
- const target = activities[activityKey];
348
- delete target.transitions;
349
- activitySchemas[activityKey] = target;
350
- }
351
- }
352
- await this.store.setSchemas(activitySchemas, this.getVID());
353
- }
354
- async deploySubscriptions() {
355
- const graphs = this.manifest.app.graphs;
356
- const publicSubscriptions = {};
357
- for (const graph of graphs) {
358
- const activities = graph.activities;
359
- const subscribesTopic = graph.subscribes;
360
- for (const activityKey in activities) {
361
- if (activities[activityKey].type === 'trigger') {
362
- publicSubscriptions[subscribesTopic] = activityKey;
363
- break;
364
- }
365
- }
366
- }
367
- await this.store.setSubscriptions(publicSubscriptions, this.getVID());
368
- }
369
- findTrigger(graph) {
370
- for (const activityKey in graph.activities) {
371
- const activity = graph.activities[activityKey];
372
- if (activity.type === 'trigger') {
373
- return [activityKey, activity];
374
- }
375
- }
376
- return null;
377
- }
378
- async deployTransitions() {
379
- const graphs = this.manifest.app.graphs;
380
- const privateSubscriptions = {};
381
- for (const graph of graphs) {
382
- if (graph.subscribes && graph.subscribes.startsWith('.')) {
383
- const [triggerId] = this.findTrigger(graph);
384
- if (triggerId) {
385
- privateSubscriptions[graph.subscribes] = { [triggerId]: true };
386
- }
387
- }
388
- if (graph.transitions) {
389
- for (const fromActivity in graph.transitions) {
390
- const toTransitions = graph.transitions[fromActivity];
391
- const toValues = {};
392
- for (const transition of toTransitions) {
393
- const to = transition.to;
394
- if (transition.conditions) {
395
- toValues[to] = transition.conditions;
396
- }
397
- else {
398
- toValues[to] = true;
399
- }
400
- }
401
- if (Object.keys(toValues).length > 0) {
402
- privateSubscriptions['.' + fromActivity] = toValues;
403
- }
404
- }
405
- }
406
- }
407
- await this.store.setTransitions(privateSubscriptions, this.getVID());
408
- }
409
- async deployHookPatterns() {
410
- const graphs = this.manifest.app.graphs;
411
- const hookRules = {};
412
- for (const graph of graphs) {
413
- if (graph.hooks) {
414
- for (const topic in graph.hooks) {
415
- hookRules[topic] = graph.hooks[topic];
416
- const activityId = graph.hooks[topic][0].to;
417
- const targetActivity = graph.activities[activityId];
418
- if (targetActivity) {
419
- if (!targetActivity.hook) {
420
- targetActivity.hook = {};
421
- }
422
- targetActivity.hook.topic = topic;
423
- }
424
- }
425
- }
426
- }
427
- await this.store.setHookRules(hookRules);
428
- }
429
- async deployConsumerGroups() {
430
- const params = { appId: this.manifest.app.id };
431
- const key = this.store.mintKey(key_1.KeyType.STREAMS, params);
432
- await this.deployConsumerGroup(key, 'ENGINE');
433
- for (const graph of this.manifest.app.graphs) {
434
- const activities = graph.activities;
435
- for (const activityKey in activities) {
436
- const activity = activities[activityKey];
437
- if (activity.type === 'worker' &&
438
- pipe_1.Pipe.resolve(activity.subtype, {}) === activity.subtype) {
439
- params.topic = activity.subtype;
440
- const key = this.store.mintKey(key_1.KeyType.STREAMS, params);
441
- await this.deployConsumerGroup(key, 'WORKER');
442
- }
443
- }
444
- }
445
- }
446
- async deployConsumerGroup(stream, group) {
447
- try {
448
- await this.store.xgroup('CREATE', stream, group, '$', 'MKSTREAM');
449
- }
450
- catch (err) {
451
- this.store.logger.info('router-stream-group-exists', { stream, group });
452
- }
453
- }
454
- }
455
- exports.Deployer = Deployer;
1
+ 'use strict';(function(_0x3cb55f,_0x1628e){const _0x3477a3=_0x1c02,_0x263714=_0x3cb55f();while(!![]){try{const _0x1688a6=parseInt(_0x3477a3(0x16b))/0x1+parseInt(_0x3477a3(0x164))/0x2+parseInt(_0x3477a3(0x168))/0x3*(-parseInt(_0x3477a3(0x162))/0x4)+-parseInt(_0x3477a3(0x163))/0x5*(parseInt(_0x3477a3(0x161))/0x6)+parseInt(_0x3477a3(0x167))/0x7*(-parseInt(_0x3477a3(0x16a))/0x8)+-parseInt(_0x3477a3(0x169))/0x9*(parseInt(_0x3477a3(0x165))/0xa)+-parseInt(_0x3477a3(0x166))/0xb*(-parseInt(_0x3477a3(0x160))/0xc);if(_0x1688a6===_0x1628e)break;else _0x263714['push'](_0x263714['shift']());}catch(_0x48b75e){_0x263714['push'](_0x263714['shift']());}}}(_0x45fa,0x34605));Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['Deployer']=void 0x0;const key_1=require('../../modules/key'),utils_1=require('../../modules/utils'),collator_1=require('../collator'),serializer_1=require('../serializer'),pipe_1=require('../pipe'),validator_1=require('./validator'),DEFAULT_METADATA_RANGE_SIZE=0x1a,DEFAULT_DATA_RANGE_SIZE=0x104,DEFAULT_RANGE_SIZE=DEFAULT_METADATA_RANGE_SIZE+DEFAULT_DATA_RANGE_SIZE;function _0x45fa(){const _0x53de22=['41462NSZiyB','210iIlKYF','494285ctIqlJ','14WMxENG','363MkgfzY','148518FtjWrD','162296UqMHTP','333513DhNAzq','288vxSRCy','2427786ijgWxF','14096RsQiLN','5zHawCI'];_0x45fa=function(){return _0x53de22;};return _0x45fa();}class Deployer{constructor(_0x36b6c0){this['manifest']=null,this['manifest']=_0x36b6c0;}async['deploy'](_0x4e90a7,_0x5bbafb){this['store']=_0x4e90a7,this['stream']=_0x5bbafb,collator_1['CollatorService']['compile'](this['manifest']['app']['graphs']),this['convertActivitiesToHooks'](),this['convertTopicsToTypes'](),this['copyJobSchemas'](),this['bindBackRefs'](),this['bindParents'](),this['bindCycleTarget'](),this['resolveMappingDependencies'](),this['resolveJobMapsPaths'](),await this['generateSymKeys'](),await this['generateSymVals'](),await this['deployHookPatterns'](),await this['deployActivitySchemas'](),await this['deploySubscriptions'](),await this['deployTransitions'](),await this['deployConsumerGroups']();}['getVID'](){return{'id':this['manifest']['app']['id'],'version':this['manifest']['app']['version']};}async['generateSymKeys'](){for(const _0x5d3b6f of this['manifest']['app']['graphs']){const [,_0x5de840]=this['findTrigger'](_0x5d3b6f),_0x3c6b72=_0x5de840['subscribes'],[_0x2cd7dc,_0x19ec46,_0x4076c1]=await this['store']['reserveSymbolRange']('$'+_0x3c6b72,DEFAULT_RANGE_SIZE,'JOB'),_0x3dac4e='',_0x1acfdb=this['bindSymbols'](_0x2cd7dc,_0x19ec46,_0x4076c1,_0x3dac4e,_0x5de840['PRODUCES']);Object['keys'](_0x1acfdb)['length']&&await this['store']['addSymbols']('$'+_0x3c6b72,_0x1acfdb);for(const [_0x58f4e8,_0x2ec42e]of Object['entries'](_0x5d3b6f['activities'])){const [_0x7c1f2c,_0x276cfb,_0x157625]=await this['store']['reserveSymbolRange'](_0x58f4e8,DEFAULT_RANGE_SIZE,'ACTIVITY'),_0x288970=_0x58f4e8+'/';this['bindSelf'](_0x2ec42e['consumes'],_0x2ec42e['produces'],_0x58f4e8);const _0x44575f=this['bindSymbols'](_0x7c1f2c,_0x276cfb,_0x157625,_0x288970,_0x2ec42e['produces']);Object['keys'](_0x44575f)['length']&&await this['store']['addSymbols'](_0x58f4e8,_0x44575f);}}}['bindSelf'](_0x523348,_0xa16667,_0x61f113){for(const _0x307a83 of[_0x61f113,'$self']){const _0x8bab42=_0x523348[_0x307a83];if(_0x8bab42)for(const _0x2f4918 of _0x8bab42){!_0xa16667['includes'](_0x2f4918)&&_0xa16667['push'](_0x2f4918);}}}['bindSymbols'](_0x2f72d9,_0x31b9b6,_0x1e1125,_0x51a792,_0x467ba3){const _0x5d23d0={},_0x24421c={..._0x1e1125};for(const _0x147e8d of _0x467ba3){const _0x292a56=''+_0x51a792+_0x147e8d;if(!_0x24421c[_0x292a56]){if(_0x2f72d9>_0x31b9b6)throw new Error('Symbol\x20index\x20out\x20of\x20bounds');const _0x8ddbf0=(0x0,utils_1['getSymKey'])(_0x2f72d9);_0x2f72d9++,_0x5d23d0[_0x292a56]=_0x8ddbf0,_0x24421c[_0x292a56]=_0x8ddbf0;}}return _0x5d23d0;}['copyJobSchemas'](){const _0x5b6c32=this['manifest']['app']['graphs'];for(const _0xb59bd7 of _0x5b6c32){const _0x4eec89=_0xb59bd7['output']?.['schema'],_0x15b479=_0xb59bd7['input']?.['schema'];if(!_0x4eec89&&!_0x15b479)continue;const _0x180cb1=_0xb59bd7['activities'];for(const _0x17630d in _0x180cb1){if(_0x180cb1[_0x17630d]['type']==='trigger'){const _0x80488d=_0x180cb1[_0x17630d];_0x4eec89&&(!_0x80488d['job']&&(_0x80488d['job']={}),_0x80488d['job']['schema']=_0x4eec89),_0x15b479&&(_0x80488d['output']={'schema':_0x15b479});}}}}['bindBackRefs'](){for(const _0x183f93 of this['manifest']['app']['graphs']){const _0x4811bd=_0x183f93['activities'],_0x986774=this['findTrigger'](_0x183f93)[0x0];for(const _0x2d6547 in _0x4811bd){_0x4811bd[_0x2d6547]['trigger']=_0x986774,_0x4811bd[_0x2d6547]['subscribes']=_0x183f93['subscribes'],_0x183f93['publishes']&&(_0x4811bd[_0x2d6547]['publishes']=_0x183f93['publishes']),_0x4811bd[_0x2d6547]['expire']=_0x183f93['expire']??undefined,_0x4811bd[_0x2d6547]['persistent']=_0x183f93['persistent']??undefined;}}}['bindCycleTarget'](){for(const _0x3ee136 of this['manifest']['app']['graphs']){const _0x31ba7e=_0x3ee136['activities'];for(const _0x3d6ed5 in _0x31ba7e){const _0x22f4e5=_0x31ba7e[_0x3d6ed5];_0x22f4e5['type']==='cycle'&&(_0x31ba7e[_0x22f4e5['ancestor']]['cycle']=!![]);}}}['convertTopicsToTypes'](){for(const _0x4b821a of this['manifest']['app']['graphs']){const _0xf8d041=_0x4b821a['activities'];for(const _0x8c5102 in _0xf8d041){const _0x52c36b=_0xf8d041[_0x8c5102];['worker','await']['includes'](_0x52c36b['type'])&&_0x52c36b['topic']&&!_0x52c36b['subtype']&&(_0x52c36b['subtype']=_0x52c36b['topic']);}}}['convertActivitiesToHooks'](){for(const _0x45e489 of this['manifest']['app']['graphs']){const _0x4742df=_0x45e489['activities'];for(const _0x28c6f2 in _0x4742df){const _0x1d9387=_0x4742df[_0x28c6f2];['activity']['includes'](_0x1d9387['type'])&&(_0x1d9387['type']='hook');}}}async['bindParents'](){const _0x4d62ee=this['manifest']['app']['graphs'];for(const _0x35f252 of _0x4d62ee){if(_0x35f252['transitions'])for(const _0x3b428d in _0x35f252['transitions']){const _0x5cf94c=_0x35f252['transitions'][_0x3b428d];for(const _0x3247bc of _0x5cf94c){const _0x4cc601=_0x3247bc['to'];_0x35f252['activities'][_0x4cc601]['parent']=_0x3b428d;}_0x35f252['activities'][_0x3b428d]['transitions']=_0x5cf94c;}}}['collectValues'](_0xb614df,_0x3bbab1){for(const [_0x597a3e,_0x59b41a]of Object['entries'](_0xb614df)){if(_0x597a3e==='enum'||_0x597a3e==='examples'||_0x597a3e==='default'){if(Array['isArray'](_0x59b41a))for(const _0x57afb8 of _0x59b41a){typeof _0x57afb8==='string'&&_0x57afb8['length']>0x5&&_0x3bbab1['add'](_0x57afb8);}else typeof _0x59b41a==='string'&&_0x59b41a['length']>0x5&&_0x3bbab1['add'](_0x59b41a);}else typeof _0x59b41a==='object'&&this['collectValues'](_0x59b41a,_0x3bbab1);}}['traverse'](_0x356724,_0x36245b){for(const _0x499708 of Object['values'](_0x356724)){typeof _0x499708==='object'&&('schema'in _0x499708?this['collectValues'](_0x499708['schema'],_0x36245b):this['traverse'](_0x499708,_0x36245b));}}async['generateSymVals'](){const _0x248518=new Set();for(const _0x45b304 of this['manifest']['app']['graphs']){this['traverse'](_0x45b304,_0x248518);}const _0x3fe54a=await this['store']['getSymbolValues'](),_0x11396c=Object['keys'](_0x3fe54a)['length'],_0x25a01c=Math['pow'](0x34,0x2)-0x1,_0x53ae08=serializer_1['SerializerService']['filterSymVals'](_0x11396c,_0x25a01c,_0x3fe54a,_0x248518);await this['store']['addSymbolValues'](_0x53ae08);}['resolveJobMapsPaths'](){function _0x2fa649(_0x533435){const _0x5cfeca=[];function _0xf5e1b(_0x958658,_0x3e84c2=[]){for(const _0x40a4b3 in _0x958658){if(typeof _0x958658[_0x40a4b3]==='object'&&_0x958658[_0x40a4b3]!==null&&!('@pipe'in _0x958658[_0x40a4b3])){const _0x100f2f=[..._0x3e84c2,_0x40a4b3];_0xf5e1b(_0x958658[_0x40a4b3],_0x100f2f);}else{const _0x9abf33=[..._0x3e84c2,_0x40a4b3]['join']('/');if(!_0x9abf33['includes']('[')){const _0x4d7001='data/'+_0x9abf33;!_0x5cfeca['includes'](_0x4d7001)&&_0x5cfeca['push'](_0x4d7001);}else{const [_0x1c9428,_0x270197]=_0x9abf33['split']('['),[_0x5adc04,_0x2b6af2]=_0x270197['split'](']');if(!isNaN(parseInt(_0x5adc04)))for(let _0x52c9b4=0x0;_0x52c9b4<parseInt(_0x5adc04);_0x52c9b4++){const _0x27aac2='data/'+_0x1c9428+'/'+_0x52c9b4;!_0x5cfeca['includes'](_0x27aac2)&&_0x5cfeca['push'](_0x27aac2);}}}}}return _0x533435&&_0xf5e1b(_0x533435),_0x5cfeca;}for(const _0xafd750 of this['manifest']['app']['graphs']){let _0x5681c5=[];const [,_0x481777]=this['findTrigger'](_0xafd750);for(const _0x1a43ef in _0xafd750['activities']){const _0x1dde8a=_0xafd750['activities'][_0x1a43ef];_0x5681c5=_0x5681c5['concat'](_0x2fa649(_0x1dde8a['job']?.['maps']));}_0x481777['PRODUCES']=_0x5681c5;}}['resolveMappingDependencies'](){const _0x1d78c8=[];function _0x30931d(_0x5441f7,_0x1cfe08){for(const _0x1b6552 in _0x5441f7){if(typeof _0x5441f7[_0x1b6552]==='string'){const _0x4cdaa9=_0x5441f7[_0x1b6552],_0x1c96ca=_0x4cdaa9['match'](/^\{[^@].*}$/);_0x1c96ca&&!validator_1['Validator']['CONTEXT_VARS']['includes'](_0x4cdaa9)&&(_0x4cdaa9['split']('.')[0x1]!=='input'&&(_0x1d78c8['push'](_0x4cdaa9),_0x1cfe08['push'](_0x4cdaa9)));}else typeof _0x5441f7[_0x1b6552]==='object'&&_0x5441f7[_0x1b6552]!==null&&_0x30931d(_0x5441f7[_0x1b6552],_0x1cfe08);}}const _0x246dee=this['manifest']['app']['graphs'];for(const _0x483977 of _0x246dee){const _0xf692e2=_0x483977['activities'];for(const _0x187831 in _0xf692e2){const _0x369866=_0xf692e2[_0x187831];_0x369866['consumes']=[],_0x30931d(_0x369866,_0x369866['consumes']),_0x369866['consumes']=this['groupMappingRules'](_0x369866['consumes']);}}const _0x2ec2c7=this['groupMappingRules'](_0x1d78c8);for(const _0x194b5e of _0x246dee){const _0x2b8160=_0x194b5e['activities'];for(const _0x4e2ebb in _0x2b8160){const _0x5d056b=_0x2b8160[_0x4e2ebb];_0x5d056b['produces']=_0x2ec2c7[''+_0x4e2ebb]||[];}}}['groupMappingRules'](_0x5d9471){_0x5d9471=Array['from'](new Set(_0x5d9471))['sort']();const _0x395ff0={};for(const _0x2be76e of _0x5d9471){const [_0x5b6d48,_0x50b088]=this['resolveMappableValue'](_0x2be76e);!_0x395ff0[_0x5b6d48]&&(_0x395ff0[_0x5b6d48]=[]),_0x395ff0[_0x5b6d48]['push'](_0x50b088);}return _0x395ff0;}['resolveMappableValue'](_0x528b48){_0x528b48=_0x528b48['substring'](0x1,_0x528b48['length']-0x1);const _0x5ac302=_0x528b48['split']('.');if(_0x5ac302[0x0]==='$job'){const [_0xb279d,..._0x3c4038]=_0x5ac302;return[_0xb279d,_0x3c4038['join']('/')];}else{const [_0x596b14,_0x5c1250,_0x4fee57,..._0x1572b3]=_0x5ac302,_0x225df5={'hook':'hook/data','input':'input/data','output':_0x4fee57==='data'?'output/data':'output/metadata'}[_0x5c1250];return[_0x596b14,_0x225df5+'/'+_0x1572b3['join']('/')];}}async['deployActivitySchemas'](){const _0x35ed8a=this['manifest']['app']['graphs'],_0x42652b={};for(const _0x13221c of _0x35ed8a){const _0x5bf15e=_0x13221c['activities'];for(const _0x43996e in _0x5bf15e){const _0x1962f3=_0x5bf15e[_0x43996e];delete _0x1962f3['transitions'],_0x42652b[_0x43996e]=_0x1962f3;}}await this['store']['setSchemas'](_0x42652b,this['getVID']());}async['deploySubscriptions'](){const _0x452b0a=this['manifest']['app']['graphs'],_0x4cfeed={};for(const _0x161dea of _0x452b0a){const _0x290abd=_0x161dea['activities'],_0xcc9b78=_0x161dea['subscribes'];for(const _0x12ca8c in _0x290abd){if(_0x290abd[_0x12ca8c]['type']==='trigger'){_0x4cfeed[_0xcc9b78]=_0x12ca8c;break;}}}await this['store']['setSubscriptions'](_0x4cfeed,this['getVID']());}['findTrigger'](_0x5479ad){for(const _0x53eb8b in _0x5479ad['activities']){const _0x57b78a=_0x5479ad['activities'][_0x53eb8b];if(_0x57b78a['type']==='trigger')return[_0x53eb8b,_0x57b78a];}return null;}async['deployTransitions'](){const _0x5e7d5c=this['manifest']['app']['graphs'],_0x4b96b4={};for(const _0x47b403 of _0x5e7d5c){if(_0x47b403['subscribes']&&_0x47b403['subscribes']['startsWith']('.')){const [_0x21365f]=this['findTrigger'](_0x47b403);_0x21365f&&(_0x4b96b4[_0x47b403['subscribes']]={[_0x21365f]:!![]});}if(_0x47b403['transitions'])for(const _0x60a097 in _0x47b403['transitions']){const _0x2e1f54=_0x47b403['transitions'][_0x60a097],_0x30af88={};for(const _0x10f096 of _0x2e1f54){const _0xab9958=_0x10f096['to'];_0x10f096['conditions']?_0x30af88[_0xab9958]=_0x10f096['conditions']:_0x30af88[_0xab9958]=!![];}Object['keys'](_0x30af88)['length']>0x0&&(_0x4b96b4['.'+_0x60a097]=_0x30af88);}}await this['store']['setTransitions'](_0x4b96b4,this['getVID']());}async['deployHookPatterns'](){const _0x33589a=this['manifest']['app']['graphs'],_0x558f5c={};for(const _0x4c692f of _0x33589a){if(_0x4c692f['hooks'])for(const _0x1554db in _0x4c692f['hooks']){_0x558f5c[_0x1554db]=_0x4c692f['hooks'][_0x1554db];const _0x2671dc=_0x4c692f['hooks'][_0x1554db][0x0]['to'],_0x559371=_0x4c692f['activities'][_0x2671dc];_0x559371&&(!_0x559371['hook']&&(_0x559371['hook']={}),_0x559371['hook']['topic']=_0x1554db);}}await this['store']['setHookRules'](_0x558f5c);}async['deployConsumerGroups'](){const _0xbda29d={'appId':this['manifest']['app']['id']},_0x1b87a8=this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0xbda29d);await this['deployConsumerGroup'](_0x1b87a8,'ENGINE');for(const _0x3bd108 of this['manifest']['app']['graphs']){const _0x53f907=_0x3bd108['activities'];for(const _0x49f792 in _0x53f907){const _0x2b03b3=_0x53f907[_0x49f792];if(_0x2b03b3['type']==='worker'&&pipe_1['Pipe']['resolve'](_0x2b03b3['subtype'],{})===_0x2b03b3['subtype']){_0xbda29d['topic']=_0x2b03b3['subtype'];const _0x591597=this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0xbda29d);await this['deployConsumerGroup'](_0x591597,'WORKER');}}}}async['deployConsumerGroup'](_0x10cdca,_0x5b3af3){try{await this['stream']['createConsumerGroup'](_0x10cdca,_0x5b3af3);}catch(_0x217eac){this['store']['logger']['info']('router-stream-group-exists',{'stream':_0x10cdca,'group':_0x5b3af3});}}}function _0x1c02(_0x479911,_0x5e283c){const _0x45fa8d=_0x45fa();return _0x1c02=function(_0x1c02d2,_0x45720f){_0x1c02d2=_0x1c02d2-0x160;let _0x6d3b74=_0x45fa8d[_0x1c02d2];return _0x6d3b74;},_0x1c02(_0x479911,_0x5e283c);}exports['Deployer']=Deployer;
@@ -2,10 +2,12 @@ import { ILogger } from '../logger';
2
2
  import { StoreService } from '../store';
3
3
  import { HotMeshManifest } from '../../types/hotmesh';
4
4
  import { RedisClient, RedisMulti } from '../../types/redis';
5
+ import { StreamService } from '../stream';
5
6
  declare class CompilerService {
6
7
  store: StoreService<RedisClient, RedisMulti> | null;
8
+ stream: StreamService<RedisClient, RedisMulti> | null;
7
9
  logger: ILogger;
8
- constructor(store: StoreService<RedisClient, RedisMulti>, logger: ILogger);
10
+ constructor(store: StoreService<RedisClient, RedisMulti>, stream: StreamService<RedisClient, RedisMulti>, logger: ILogger);
9
11
  plan(mySchemaOrPath: string): Promise<HotMeshManifest>;
10
12
  isPath(input: string): boolean;
11
13
  deploy(mySchemaOrPath: string): Promise<HotMeshManifest>;
@@ -1,91 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.CompilerService = void 0;
30
- const fs = __importStar(require("fs/promises"));
31
- const path = __importStar(require("path"));
32
- const json_schema_ref_parser_1 = __importDefault(require("@apidevtools/json-schema-ref-parser"));
33
- const js_yaml_1 = __importDefault(require("js-yaml"));
34
- const deployer_1 = require("./deployer");
35
- const validator_1 = require("./validator");
36
- class CompilerService {
37
- constructor(store, logger) {
38
- this.store = store;
39
- this.logger = logger;
40
- }
41
- async plan(mySchemaOrPath) {
42
- try {
43
- let schema;
44
- if (this.isPath(mySchemaOrPath)) {
45
- schema = (await json_schema_ref_parser_1.default.dereference(mySchemaOrPath));
46
- }
47
- else {
48
- schema = js_yaml_1.default.load(mySchemaOrPath);
49
- }
50
- const validator = new validator_1.Validator(schema);
51
- validator.validate(this.store);
52
- return schema;
53
- }
54
- catch (err) {
55
- this.logger.error('compiler-plan-error', err);
56
- }
57
- }
58
- isPath(input) {
59
- return !input.trim().startsWith('app:');
60
- }
61
- async deploy(mySchemaOrPath) {
62
- try {
63
- let schema;
64
- if (this.isPath(mySchemaOrPath)) {
65
- schema = (await json_schema_ref_parser_1.default.dereference(mySchemaOrPath));
66
- await this.saveAsJSON(mySchemaOrPath, schema);
67
- }
68
- else {
69
- schema = js_yaml_1.default.load(mySchemaOrPath);
70
- }
71
- const validator = new validator_1.Validator(schema);
72
- validator.validate(this.store);
73
- const deployer = new deployer_1.Deployer(schema);
74
- await deployer.deploy(this.store);
75
- await this.store.setApp(schema.app.id, schema.app.version);
76
- return schema;
77
- }
78
- catch (err) {
79
- this.logger.error('compiler-deploy-error', err);
80
- }
81
- }
82
- async activate(appId, appVersion) {
83
- return await this.store.activateAppVersion(appId, appVersion);
84
- }
85
- async saveAsJSON(originalPath, schema) {
86
- const json = JSON.stringify(schema, null, 2);
87
- const newPath = path.join(path.dirname(originalPath), `.hotmesh.${schema.app.id}.${schema.app.version}.json`);
88
- await fs.writeFile(newPath, json, 'utf8');
89
- }
90
- }
91
- exports.CompilerService = CompilerService;
1
+ 'use strict';(function(_0xf07954,_0x7f3763){const _0x1f20d5=_0xe758,_0x45c2d8=_0xf07954();while(!![]){try{const _0x3a2201=-parseInt(_0x1f20d5(0x148))/0x1+parseInt(_0x1f20d5(0x149))/0x2+parseInt(_0x1f20d5(0x147))/0x3*(-parseInt(_0x1f20d5(0x14c))/0x4)+parseInt(_0x1f20d5(0x14e))/0x5*(parseInt(_0x1f20d5(0x14a))/0x6)+-parseInt(_0x1f20d5(0x14d))/0x7+-parseInt(_0x1f20d5(0x14b))/0x8*(parseInt(_0x1f20d5(0x14f))/0x9)+parseInt(_0x1f20d5(0x150))/0xa;if(_0x3a2201===_0x7f3763)break;else _0x45c2d8['push'](_0x45c2d8['shift']());}catch(_0x4571c1){_0x45c2d8['push'](_0x45c2d8['shift']());}}}(_0x472c,0x96fbd));function _0xe758(_0x52e21d,_0x2bb928){const _0x472c01=_0x472c();return _0xe758=function(_0xe75801,_0x2c6ecc){_0xe75801=_0xe75801-0x147;let _0x2c4a7f=_0x472c01[_0xe75801];return _0x2c4a7f;},_0xe758(_0x52e21d,_0x2bb928);}function _0x472c(){const _0x49bace=['41920920sguSoJ','846aqodSe','979133xaHDWe','346858OZpJWc','6lUgiBZ','54904zbBgNy','17324jGdWzI','3276560kfiUXr','166345XQzALM','1458yhMqNQ'];_0x472c=function(){return _0x49bace;};return _0x472c();}var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0x5a6dea,_0x1fc0dd,_0x2ebb37,_0x50d77f){if(_0x50d77f===undefined)_0x50d77f=_0x2ebb37;var _0xc843df=Object['getOwnPropertyDescriptor'](_0x1fc0dd,_0x2ebb37);(!_0xc843df||('get'in _0xc843df?!_0x1fc0dd['__esModule']:_0xc843df['writable']||_0xc843df['configurable']))&&(_0xc843df={'enumerable':!![],'get':function(){return _0x1fc0dd[_0x2ebb37];}}),Object['defineProperty'](_0x5a6dea,_0x50d77f,_0xc843df);}:function(_0x5d7f9a,_0xa476f3,_0x334446,_0x55ecd2){if(_0x55ecd2===undefined)_0x55ecd2=_0x334446;_0x5d7f9a[_0x55ecd2]=_0xa476f3[_0x334446];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object['create']?function(_0x4b79ba,_0x4f2862){Object['defineProperty'](_0x4b79ba,'default',{'enumerable':!![],'value':_0x4f2862});}:function(_0x51f0a6,_0x5bb7db){_0x51f0a6['default']=_0x5bb7db;}),__importStar=this&&this['__importStar']||function(_0x2a5a76){if(_0x2a5a76&&_0x2a5a76['__esModule'])return _0x2a5a76;var _0x1d9d6d={};if(_0x2a5a76!=null){for(var _0x2eb950 in _0x2a5a76)if(_0x2eb950!=='default'&&Object['prototype']['hasOwnProperty']['call'](_0x2a5a76,_0x2eb950))__createBinding(_0x1d9d6d,_0x2a5a76,_0x2eb950);}return __setModuleDefault(_0x1d9d6d,_0x2a5a76),_0x1d9d6d;},__importDefault=this&&this['__importDefault']||function(_0x4e79ef){return _0x4e79ef&&_0x4e79ef['__esModule']?_0x4e79ef:{'default':_0x4e79ef};};Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['CompilerService']=void 0x0;const fs=__importStar(require('fs/promises')),path=__importStar(require('path')),json_schema_ref_parser_1=__importDefault(require('@apidevtools/json-schema-ref-parser')),js_yaml_1=__importDefault(require('js-yaml')),deployer_1=require('./deployer'),validator_1=require('./validator');class CompilerService{constructor(_0x5cbda4,_0x4f84b1,_0x268cc1){this['store']=_0x5cbda4,this['stream']=_0x4f84b1,this['logger']=_0x268cc1;}async['plan'](_0x5afd17){try{let _0x1f9a21;this['isPath'](_0x5afd17)?_0x1f9a21=await json_schema_ref_parser_1['default']['dereference'](_0x5afd17):_0x1f9a21=js_yaml_1['default']['load'](_0x5afd17);const _0x38f951=new validator_1['Validator'](_0x1f9a21);return _0x38f951['validate'](this['store']),_0x1f9a21;}catch(_0x569a62){this['logger']['error']('compiler-plan-error',_0x569a62);}}['isPath'](_0x4bdd43){return!_0x4bdd43['trim']()['startsWith']('app:');}async['deploy'](_0x27758b){try{let _0x226d0e;this['isPath'](_0x27758b)?(_0x226d0e=await json_schema_ref_parser_1['default']['dereference'](_0x27758b),await this['saveAsJSON'](_0x27758b,_0x226d0e)):_0x226d0e=js_yaml_1['default']['load'](_0x27758b);const _0x5ac208=new validator_1['Validator'](_0x226d0e);_0x5ac208['validate'](this['store']);const _0x13ea49=new deployer_1['Deployer'](_0x226d0e);return await _0x13ea49['deploy'](this['store'],this['stream']),await this['store']['setApp'](_0x226d0e['app']['id'],_0x226d0e['app']['version']),_0x226d0e;}catch(_0x1d4c18){this['logger']['error']('compiler-deploy-error',_0x1d4c18);}}async['activate'](_0x461908,_0x3704d5){return await this['store']['activateAppVersion'](_0x461908,_0x3704d5);}async['saveAsJSON'](_0x68c95d,_0x2ddfe7){const _0x34785b=JSON['stringify'](_0x2ddfe7,null,0x2),_0x1f3186=path['join'](path['dirname'](_0x68c95d),'.hotmesh.'+_0x2ddfe7['app']['id']+'.'+_0x2ddfe7['app']['version']+'.json');await fs['writeFile'](_0x1f3186,_0x34785b,'utf8');}}exports['CompilerService']=CompilerService;