@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,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 _0x3beb(){const _0xfe4acb=['921325VmmRpj','11392209mjcHpo','12DBvenF','947768HIBigc','33104929FBHGmp','394865Jzvbdt','2569406RLEZqq','3JCMHJj','2846514ESIBnU','35EOeKEt','10sGFSjD'];_0x3beb=function(){return _0xfe4acb;};return _0x3beb();}(function(_0x447d61,_0x3dc167){const _0x132e3b=_0x1384,_0x2459d4=_0x447d61();while(!![]){try{const _0x30a04c=-parseInt(_0x132e3b(0x9d))/0x1+parseInt(_0x132e3b(0x98))/0x2*(-parseInt(_0x132e3b(0x99))/0x3)+parseInt(_0x132e3b(0x9f))/0x4*(-parseInt(_0x132e3b(0xa2))/0x5)+-parseInt(_0x132e3b(0x9a))/0x6+parseInt(_0x132e3b(0x9b))/0x7*(-parseInt(_0x132e3b(0xa0))/0x8)+-parseInt(_0x132e3b(0x9e))/0x9*(-parseInt(_0x132e3b(0x9c))/0xa)+parseInt(_0x132e3b(0xa1))/0xb;if(_0x30a04c===_0x3dc167)break;else _0x2459d4['push'](_0x2459d4['shift']());}catch(_0x4212c1){_0x2459d4['push'](_0x2459d4['shift']());}}}(_0x3beb,0xbaeb3));function _0x1384(_0x4a47ec,_0x611cb1){const _0x3beb3d=_0x3beb();return _0x1384=function(_0x138419,_0x21ceae){_0x138419=_0x138419-0x98;let _0x3432ae=_0x3beb3d[_0x138419];return _0x3432ae;},_0x1384(_0x4a47ec,_0x611cb1);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['Deployer']=void 0x0;const key_1=require('../../modules/key'),utils_1=require('../../modules/utils'),collator_1=require('../collator'),serializer_1=require('../serializer'),pipe_1=require('../pipe'),validator_1=require('./validator'),DEFAULT_METADATA_RANGE_SIZE=0x1a,DEFAULT_DATA_RANGE_SIZE=0x104,DEFAULT_RANGE_SIZE=DEFAULT_METADATA_RANGE_SIZE+DEFAULT_DATA_RANGE_SIZE;class Deployer{constructor(_0x4e5c23){this['manifest']=null,this['manifest']=_0x4e5c23;}async['deploy'](_0xc5ee61,_0x5a1ffb){this['store']=_0xc5ee61,this['stream']=_0x5a1ffb,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 _0x323599 of this['manifest']['app']['graphs']){const [,_0x13256b]=this['findTrigger'](_0x323599),_0x3e1449=_0x13256b['subscribes'],[_0x2cf0cb,_0x576073,_0x508b72]=await this['store']['reserveSymbolRange']('$'+_0x3e1449,DEFAULT_RANGE_SIZE,'JOB'),_0x1ab800='',_0x17407a=this['bindSymbols'](_0x2cf0cb,_0x576073,_0x508b72,_0x1ab800,_0x13256b['PRODUCES']);Object['keys'](_0x17407a)['length']&&await this['store']['addSymbols']('$'+_0x3e1449,_0x17407a);for(const [_0x1ffcda,_0x33e3fa]of Object['entries'](_0x323599['activities'])){const [_0x25bcd9,_0x189e83,_0x16a50c]=await this['store']['reserveSymbolRange'](_0x1ffcda,DEFAULT_RANGE_SIZE,'ACTIVITY'),_0x39f9ce=_0x1ffcda+'/';this['bindSelf'](_0x33e3fa['consumes'],_0x33e3fa['produces'],_0x1ffcda);const _0x43dbd5=this['bindSymbols'](_0x25bcd9,_0x189e83,_0x16a50c,_0x39f9ce,_0x33e3fa['produces']);Object['keys'](_0x43dbd5)['length']&&await this['store']['addSymbols'](_0x1ffcda,_0x43dbd5);}}}['bindSelf'](_0x2985e0,_0x278122,_0x4b0eab){for(const _0x68e797 of[_0x4b0eab,'$self']){const _0xad7592=_0x2985e0[_0x68e797];if(_0xad7592)for(const _0x3d9e3f of _0xad7592){!_0x278122['includes'](_0x3d9e3f)&&_0x278122['push'](_0x3d9e3f);}}}['bindSymbols'](_0x51eed4,_0x31d6e7,_0x2deed8,_0x1de279,_0x4d3796){const _0x4743df={},_0x904b98={..._0x2deed8};for(const _0x2bf034 of _0x4d3796){const _0x19d6f3=''+_0x1de279+_0x2bf034;if(!_0x904b98[_0x19d6f3]){if(_0x51eed4>_0x31d6e7)throw new Error('Symbol\x20index\x20out\x20of\x20bounds');const _0x5652d3=(0x0,utils_1['getSymKey'])(_0x51eed4);_0x51eed4++,_0x4743df[_0x19d6f3]=_0x5652d3,_0x904b98[_0x19d6f3]=_0x5652d3;}}return _0x4743df;}['copyJobSchemas'](){const _0x2a5dc5=this['manifest']['app']['graphs'];for(const _0x3e2935 of _0x2a5dc5){const _0x2f9669=_0x3e2935['output']?.['schema'],_0x99877f=_0x3e2935['input']?.['schema'];if(!_0x2f9669&&!_0x99877f)continue;const _0x1be577=_0x3e2935['activities'];for(const _0x428114 in _0x1be577){if(_0x1be577[_0x428114]['type']==='trigger'){const _0x46779d=_0x1be577[_0x428114];_0x2f9669&&(!_0x46779d['job']&&(_0x46779d['job']={}),_0x46779d['job']['schema']=_0x2f9669),_0x99877f&&(_0x46779d['output']={'schema':_0x99877f});}}}}['bindBackRefs'](){for(const _0x31d6e8 of this['manifest']['app']['graphs']){const _0x3344d3=_0x31d6e8['activities'],_0x166ae4=this['findTrigger'](_0x31d6e8)[0x0];for(const _0x14086d in _0x3344d3){_0x3344d3[_0x14086d]['trigger']=_0x166ae4,_0x3344d3[_0x14086d]['subscribes']=_0x31d6e8['subscribes'],_0x31d6e8['publishes']&&(_0x3344d3[_0x14086d]['publishes']=_0x31d6e8['publishes']),_0x3344d3[_0x14086d]['expire']=_0x31d6e8['expire']??undefined,_0x3344d3[_0x14086d]['persistent']=_0x31d6e8['persistent']??undefined;}}}['bindCycleTarget'](){for(const _0x4695f7 of this['manifest']['app']['graphs']){const _0x272c8f=_0x4695f7['activities'];for(const _0x202ec9 in _0x272c8f){const _0x2461be=_0x272c8f[_0x202ec9];_0x2461be['type']==='cycle'&&(_0x272c8f[_0x2461be['ancestor']]['cycle']=!![]);}}}['convertTopicsToTypes'](){for(const _0x58988d of this['manifest']['app']['graphs']){const _0x405d44=_0x58988d['activities'];for(const _0x2c0ed5 in _0x405d44){const _0x33acaa=_0x405d44[_0x2c0ed5];['worker','await']['includes'](_0x33acaa['type'])&&_0x33acaa['topic']&&!_0x33acaa['subtype']&&(_0x33acaa['subtype']=_0x33acaa['topic']);}}}['convertActivitiesToHooks'](){for(const _0xabd160 of this['manifest']['app']['graphs']){const _0x536227=_0xabd160['activities'];for(const _0x35cd88 in _0x536227){const _0x400e84=_0x536227[_0x35cd88];['activity']['includes'](_0x400e84['type'])&&(_0x400e84['type']='hook');}}}async['bindParents'](){const _0x962d48=this['manifest']['app']['graphs'];for(const _0x54d136 of _0x962d48){if(_0x54d136['transitions'])for(const _0x1d0a43 in _0x54d136['transitions']){const _0x5b1cd9=_0x54d136['transitions'][_0x1d0a43];for(const _0x405022 of _0x5b1cd9){const _0x5b1717=_0x405022['to'];_0x54d136['activities'][_0x5b1717]['parent']=_0x1d0a43;}_0x54d136['activities'][_0x1d0a43]['transitions']=_0x5b1cd9;}}}['collectValues'](_0x4fa37c,_0x2166ad){for(const [_0x202f7e,_0x2c72c2]of Object['entries'](_0x4fa37c)){if(_0x202f7e==='enum'||_0x202f7e==='examples'||_0x202f7e==='default'){if(Array['isArray'](_0x2c72c2))for(const _0x12443d of _0x2c72c2){typeof _0x12443d==='string'&&_0x12443d['length']>0x5&&_0x2166ad['add'](_0x12443d);}else typeof _0x2c72c2==='string'&&_0x2c72c2['length']>0x5&&_0x2166ad['add'](_0x2c72c2);}else typeof _0x2c72c2==='object'&&this['collectValues'](_0x2c72c2,_0x2166ad);}}['traverse'](_0x18bee1,_0x496fdf){for(const _0x49ceec of Object['values'](_0x18bee1)){typeof _0x49ceec==='object'&&('schema'in _0x49ceec?this['collectValues'](_0x49ceec['schema'],_0x496fdf):this['traverse'](_0x49ceec,_0x496fdf));}}async['generateSymVals'](){const _0xa5ef56=new Set();for(const _0x7d4cb7 of this['manifest']['app']['graphs']){this['traverse'](_0x7d4cb7,_0xa5ef56);}const _0x49f68a=await this['store']['getSymbolValues'](),_0x9b826e=Object['keys'](_0x49f68a)['length'],_0x3db775=Math['pow'](0x34,0x2)-0x1,_0x6b4834=serializer_1['SerializerService']['filterSymVals'](_0x9b826e,_0x3db775,_0x49f68a,_0xa5ef56);await this['store']['addSymbolValues'](_0x6b4834);}['resolveJobMapsPaths'](){function _0x1ccd0f(_0x55bb32){const _0x5a22bb=[];function _0x55f42c(_0x531f08,_0x4087bf=[]){for(const _0x561d60 in _0x531f08){if(typeof _0x531f08[_0x561d60]==='object'&&_0x531f08[_0x561d60]!==null&&!('@pipe'in _0x531f08[_0x561d60])){const _0x37e082=[..._0x4087bf,_0x561d60];_0x55f42c(_0x531f08[_0x561d60],_0x37e082);}else{const _0x299009=[..._0x4087bf,_0x561d60]['join']('/');if(!_0x299009['includes']('[')){const _0x5a8038='data/'+_0x299009;!_0x5a22bb['includes'](_0x5a8038)&&_0x5a22bb['push'](_0x5a8038);}else{const [_0x575680,_0x2f0ccd]=_0x299009['split']('['),[_0x1fe2f1,_0x166169]=_0x2f0ccd['split'](']');if(!isNaN(parseInt(_0x1fe2f1)))for(let _0x4841a6=0x0;_0x4841a6<parseInt(_0x1fe2f1);_0x4841a6++){const _0x4bec11='data/'+_0x575680+'/'+_0x4841a6;!_0x5a22bb['includes'](_0x4bec11)&&_0x5a22bb['push'](_0x4bec11);}}}}}return _0x55bb32&&_0x55f42c(_0x55bb32),_0x5a22bb;}for(const _0x194ebf of this['manifest']['app']['graphs']){let _0x35b9aa=[];const [,_0x9dccb8]=this['findTrigger'](_0x194ebf);for(const _0x503533 in _0x194ebf['activities']){const _0x22dc08=_0x194ebf['activities'][_0x503533];_0x35b9aa=_0x35b9aa['concat'](_0x1ccd0f(_0x22dc08['job']?.['maps']));}_0x9dccb8['PRODUCES']=_0x35b9aa;}}['resolveMappingDependencies'](){const _0x120e77=[];function _0x29b634(_0x42f8c6,_0x3c4851){for(const _0xda40b2 in _0x42f8c6){if(typeof _0x42f8c6[_0xda40b2]==='string'){const _0x50471e=_0x42f8c6[_0xda40b2],_0x3ba168=_0x50471e['match'](/^\{[^@].*}$/);_0x3ba168&&!validator_1['Validator']['CONTEXT_VARS']['includes'](_0x50471e)&&(_0x50471e['split']('.')[0x1]!=='input'&&(_0x120e77['push'](_0x50471e),_0x3c4851['push'](_0x50471e)));}else typeof _0x42f8c6[_0xda40b2]==='object'&&_0x42f8c6[_0xda40b2]!==null&&_0x29b634(_0x42f8c6[_0xda40b2],_0x3c4851);}}const _0x3fc407=this['manifest']['app']['graphs'];for(const _0x174076 of _0x3fc407){const _0x5aafe0=_0x174076['activities'];for(const _0x4a0c7a in _0x5aafe0){const _0x1f64b2=_0x5aafe0[_0x4a0c7a];_0x1f64b2['consumes']=[],_0x29b634(_0x1f64b2,_0x1f64b2['consumes']),_0x1f64b2['consumes']=this['groupMappingRules'](_0x1f64b2['consumes']);}}const _0xab847=this['groupMappingRules'](_0x120e77);for(const _0x46502c of _0x3fc407){const _0x227433=_0x46502c['activities'];for(const _0x512571 in _0x227433){const _0x400c9b=_0x227433[_0x512571];_0x400c9b['produces']=_0xab847[''+_0x512571]||[];}}}['groupMappingRules'](_0x32d068){_0x32d068=Array['from'](new Set(_0x32d068))['sort']();const _0x389ed8={};for(const _0x273605 of _0x32d068){const [_0x3349f6,_0x5e0488]=this['resolveMappableValue'](_0x273605);!_0x389ed8[_0x3349f6]&&(_0x389ed8[_0x3349f6]=[]),_0x389ed8[_0x3349f6]['push'](_0x5e0488);}return _0x389ed8;}['resolveMappableValue'](_0xbef3b8){_0xbef3b8=_0xbef3b8['substring'](0x1,_0xbef3b8['length']-0x1);const _0x3f77b5=_0xbef3b8['split']('.');if(_0x3f77b5[0x0]==='$job'){const [_0x18af00,..._0x2ab7c4]=_0x3f77b5;return[_0x18af00,_0x2ab7c4['join']('/')];}else{const [_0x1fa3a5,_0x2a43dc,_0x44c45a,..._0x4719a6]=_0x3f77b5,_0x5ec526={'hook':'hook/data','input':'input/data','output':_0x44c45a==='data'?'output/data':'output/metadata'}[_0x2a43dc];return[_0x1fa3a5,_0x5ec526+'/'+_0x4719a6['join']('/')];}}async['deployActivitySchemas'](){const _0x45e75d=this['manifest']['app']['graphs'],_0x3f289f={};for(const _0x4177c1 of _0x45e75d){const _0x56a263=_0x4177c1['activities'];for(const _0x153598 in _0x56a263){const _0x7e79ad=_0x56a263[_0x153598];delete _0x7e79ad['transitions'],_0x3f289f[_0x153598]=_0x7e79ad;}}await this['store']['setSchemas'](_0x3f289f,this['getVID']());}async['deploySubscriptions'](){const _0x9f9428=this['manifest']['app']['graphs'],_0x3b1f1d={};for(const _0x5f38e9 of _0x9f9428){const _0x80c887=_0x5f38e9['activities'],_0x121314=_0x5f38e9['subscribes'];for(const _0x26ecb9 in _0x80c887){if(_0x80c887[_0x26ecb9]['type']==='trigger'){_0x3b1f1d[_0x121314]=_0x26ecb9;break;}}}await this['store']['setSubscriptions'](_0x3b1f1d,this['getVID']());}['findTrigger'](_0x4032a9){for(const _0x366c5f in _0x4032a9['activities']){const _0x45e181=_0x4032a9['activities'][_0x366c5f];if(_0x45e181['type']==='trigger')return[_0x366c5f,_0x45e181];}return null;}async['deployTransitions'](){const _0x46958a=this['manifest']['app']['graphs'],_0x41e462={};for(const _0x4bec24 of _0x46958a){if(_0x4bec24['subscribes']&&_0x4bec24['subscribes']['startsWith']('.')){const [_0xd390e7]=this['findTrigger'](_0x4bec24);_0xd390e7&&(_0x41e462[_0x4bec24['subscribes']]={[_0xd390e7]:!![]});}if(_0x4bec24['transitions'])for(const _0x5aa9d7 in _0x4bec24['transitions']){const _0x26651c=_0x4bec24['transitions'][_0x5aa9d7],_0x22f12d={};for(const _0x541838 of _0x26651c){const _0x4a3796=_0x541838['to'];_0x541838['conditions']?_0x22f12d[_0x4a3796]=_0x541838['conditions']:_0x22f12d[_0x4a3796]=!![];}Object['keys'](_0x22f12d)['length']>0x0&&(_0x41e462['.'+_0x5aa9d7]=_0x22f12d);}}await this['store']['setTransitions'](_0x41e462,this['getVID']());}async['deployHookPatterns'](){const _0x3e910f=this['manifest']['app']['graphs'],_0x28dfd6={};for(const _0x1a3bc2 of _0x3e910f){if(_0x1a3bc2['hooks'])for(const _0x5a57af in _0x1a3bc2['hooks']){_0x28dfd6[_0x5a57af]=_0x1a3bc2['hooks'][_0x5a57af];const _0x52b885=_0x1a3bc2['hooks'][_0x5a57af][0x0]['to'],_0x20af64=_0x1a3bc2['activities'][_0x52b885];_0x20af64&&(!_0x20af64['hook']&&(_0x20af64['hook']={}),_0x20af64['hook']['topic']=_0x5a57af);}}await this['store']['setHookRules'](_0x28dfd6);}async['deployConsumerGroups'](){const _0x2a5ebd={'appId':this['manifest']['app']['id']},_0xc5e84e=this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0x2a5ebd);await this['deployConsumerGroup'](_0xc5e84e,'ENGINE');for(const _0x34a895 of this['manifest']['app']['graphs']){const _0x4883d0=_0x34a895['activities'];for(const _0x48a8cf in _0x4883d0){const _0x128652=_0x4883d0[_0x48a8cf];if(_0x128652['type']==='worker'&&pipe_1['Pipe']['resolve'](_0x128652['subtype'],{})===_0x128652['subtype']){_0x2a5ebd['topic']=_0x128652['subtype'];const _0x4f9f13=this['store']['mintKey'](key_1['KeyType']['STREAMS'],_0x2a5ebd);await this['deployConsumerGroup'](_0x4f9f13,'WORKER');}}}}async['deployConsumerGroup'](_0x20bd7e,_0x5ec12c){try{await this['stream']['createConsumerGroup'](_0x20bd7e,_0x5ec12c);}catch(_0x426c74){this['store']['logger']['info']('router-stream-group-exists',{'stream':_0x20bd7e,'group':_0x5ec12c});}}}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(_0xd4b70a,_0x5a2603){const _0x58409d=_0x28fa,_0x457d91=_0xd4b70a();while(!![]){try{const _0x4f0bfe=parseInt(_0x58409d(0xfd))/0x1*(parseInt(_0x58409d(0xf8))/0x2)+parseInt(_0x58409d(0xfb))/0x3*(parseInt(_0x58409d(0x100))/0x4)+-parseInt(_0x58409d(0xfa))/0x5*(parseInt(_0x58409d(0xf7))/0x6)+parseInt(_0x58409d(0xfe))/0x7+parseInt(_0x58409d(0xf6))/0x8*(-parseInt(_0x58409d(0xf9))/0x9)+-parseInt(_0x58409d(0xff))/0xa+parseInt(_0x58409d(0xfc))/0xb;if(_0x4f0bfe===_0x5a2603)break;else _0x457d91['push'](_0x457d91['shift']());}catch(_0x3a10a1){_0x457d91['push'](_0x457d91['shift']());}}}(_0x36c4,0xe560c));var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0x32da81,_0x1e6e29,_0x273245,_0x35ed6f){if(_0x35ed6f===undefined)_0x35ed6f=_0x273245;var _0x10168e=Object['getOwnPropertyDescriptor'](_0x1e6e29,_0x273245);(!_0x10168e||('get'in _0x10168e?!_0x1e6e29['__esModule']:_0x10168e['writable']||_0x10168e['configurable']))&&(_0x10168e={'enumerable':!![],'get':function(){return _0x1e6e29[_0x273245];}}),Object['defineProperty'](_0x32da81,_0x35ed6f,_0x10168e);}:function(_0x557939,_0xe0051b,_0x55506e,_0x512e1f){if(_0x512e1f===undefined)_0x512e1f=_0x55506e;_0x557939[_0x512e1f]=_0xe0051b[_0x55506e];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object['create']?function(_0x21e9c1,_0x1c673a){Object['defineProperty'](_0x21e9c1,'default',{'enumerable':!![],'value':_0x1c673a});}:function(_0xde5fd5,_0x8e0f5e){_0xde5fd5['default']=_0x8e0f5e;}),__importStar=this&&this['__importStar']||function(_0x1a3296){if(_0x1a3296&&_0x1a3296['__esModule'])return _0x1a3296;var _0x2f8351={};if(_0x1a3296!=null){for(var _0xd46ac in _0x1a3296)if(_0xd46ac!=='default'&&Object['prototype']['hasOwnProperty']['call'](_0x1a3296,_0xd46ac))__createBinding(_0x2f8351,_0x1a3296,_0xd46ac);}return __setModuleDefault(_0x2f8351,_0x1a3296),_0x2f8351;},__importDefault=this&&this['__importDefault']||function(_0x4274a9){return _0x4274a9&&_0x4274a9['__esModule']?_0x4274a9:{'default':_0x4274a9};};function _0x28fa(_0x33f299,_0x328fc8){const _0x36c43e=_0x36c4();return _0x28fa=function(_0x28fac1,_0x3a2ff8){_0x28fac1=_0x28fac1-0xf6;let _0x2bac90=_0x36c43e[_0x28fac1];return _0x2bac90;},_0x28fa(_0x33f299,_0x328fc8);}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(_0x49bbd6,_0x234ff2,_0x38f01d){this['store']=_0x49bbd6,this['stream']=_0x234ff2,this['logger']=_0x38f01d;}async['plan'](_0x509752){try{let _0x57cdbb;this['isPath'](_0x509752)?_0x57cdbb=await json_schema_ref_parser_1['default']['dereference'](_0x509752):_0x57cdbb=js_yaml_1['default']['load'](_0x509752);const _0x1a5886=new validator_1['Validator'](_0x57cdbb);return _0x1a5886['validate'](this['store']),_0x57cdbb;}catch(_0x5538c9){this['logger']['error']('compiler-plan-error',_0x5538c9);}}['isPath'](_0x50a6dd){return!_0x50a6dd['trim']()['startsWith']('app:');}async['deploy'](_0x517e78){try{let _0x179f51;this['isPath'](_0x517e78)?(_0x179f51=await json_schema_ref_parser_1['default']['dereference'](_0x517e78),await this['saveAsJSON'](_0x517e78,_0x179f51)):_0x179f51=js_yaml_1['default']['load'](_0x517e78);const _0x2786b4=new validator_1['Validator'](_0x179f51);_0x2786b4['validate'](this['store']);const _0x598ef0=new deployer_1['Deployer'](_0x179f51);return await _0x598ef0['deploy'](this['store'],this['stream']),await this['store']['setApp'](_0x179f51['app']['id'],_0x179f51['app']['version']),_0x179f51;}catch(_0x57caa6){this['logger']['error']('compiler-deploy-error',_0x57caa6);}}async['activate'](_0x2388aa,_0xfddbe3){return await this['store']['activateAppVersion'](_0x2388aa,_0xfddbe3);}async['saveAsJSON'](_0x52772b,_0x1a5bf6){const _0x1cdbb1=JSON['stringify'](_0x1a5bf6,null,0x2),_0x39efb9=path['join'](path['dirname'](_0x52772b),'.hotmesh.'+_0x1a5bf6['app']['id']+'.'+_0x1a5bf6['app']['version']+'.json');await fs['writeFile'](_0x39efb9,_0x1cdbb1,'utf8');}}function _0x36c4(){const _0x48aeda=['4309684CbYUwX','1437632lcfhGX','8573550ITkYKJ','121078vtPGeB','45fcaXSl','5tqPzes','3TEJmdU','5379242PMMeZz','31iqpnbj','3197299ALkVuB','6329320tFhsHm'];_0x36c4=function(){return _0x48aeda;};return _0x36c4();}exports['CompilerService']=CompilerService;