@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,495 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Activity = void 0;
4
- const enums_1 = require("../../modules/enums");
5
- const errors_1 = require("../../modules/errors");
6
- const utils_1 = require("../../modules/utils");
7
- const collator_1 = require("../collator");
8
- const mapper_1 = require("../mapper");
9
- const pipe_1 = require("../pipe");
10
- const serializer_1 = require("../serializer");
11
- const telemetry_1 = require("../telemetry");
12
- const stream_1 = require("../../types/stream");
13
- class Activity {
14
- constructor(config, data, metadata, hook, engine, context) {
15
- this.status = stream_1.StreamStatus.SUCCESS;
16
- this.code = 200;
17
- this.adjacentIndex = 0;
18
- this.config = config;
19
- this.data = data;
20
- this.metadata = metadata;
21
- this.hook = hook;
22
- this.engine = engine;
23
- this.context = context || { data: {}, metadata: {} };
24
- this.logger = engine.logger;
25
- this.store = engine.store;
26
- }
27
- setLeg(leg) {
28
- this.leg = leg;
29
- }
30
- mapStatusThreshold() {
31
- if (this.config.statusThreshold !== undefined) {
32
- const threshold = pipe_1.Pipe.resolve(this.config.statusThreshold, this.context);
33
- if (threshold !== undefined && !isNaN(Number(threshold))) {
34
- return threshold;
35
- }
36
- }
37
- return 0;
38
- }
39
- async verifyEntry() {
40
- this.setLeg(1);
41
- await this.getState();
42
- const threshold = this.mapStatusThreshold();
43
- try {
44
- collator_1.CollatorService.assertJobActive(this.context.metadata.js, this.context.metadata.jid, this.metadata.aid, threshold);
45
- }
46
- catch (error) {
47
- await collator_1.CollatorService.notarizeEntry(this);
48
- if (threshold > 0) {
49
- if (this.context.metadata.js === threshold) {
50
- const status = await this.setStatus(-threshold);
51
- if (Number(status) === 0) {
52
- await this.engine.runJobCompletionTasks(this.context);
53
- }
54
- }
55
- }
56
- else {
57
- throw error;
58
- }
59
- return;
60
- }
61
- await collator_1.CollatorService.notarizeEntry(this);
62
- }
63
- async verifyReentry() {
64
- const guid = this.context.metadata.guid;
65
- this.setLeg(2);
66
- await this.getState();
67
- collator_1.CollatorService.assertJobActive(this.context.metadata.js, this.context.metadata.jid, this.metadata.aid);
68
- return await collator_1.CollatorService.notarizeReentry(this, guid);
69
- }
70
- async processEvent(status = stream_1.StreamStatus.SUCCESS, code = 200, type = 'output') {
71
- this.setLeg(2);
72
- const jid = this.context.metadata.jid;
73
- if (!jid) {
74
- this.logger.error('activity-process-event-error', {
75
- message: 'job id is undefined',
76
- });
77
- return;
78
- }
79
- const aid = this.metadata.aid;
80
- this.status = status;
81
- this.code = code;
82
- this.logger.debug('activity-process-event', {
83
- topic: this.config.subtype,
84
- jid,
85
- aid,
86
- status,
87
- code,
88
- });
89
- let telemetry;
90
- try {
91
- const collationKey = await this.verifyReentry();
92
- this.adjacentIndex = collator_1.CollatorService.getDimensionalIndex(collationKey);
93
- telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
94
- telemetry.startActivitySpan(this.leg);
95
- let multiResponse;
96
- if (status === stream_1.StreamStatus.PENDING) {
97
- multiResponse = await this.processPending(type);
98
- }
99
- else if (status === stream_1.StreamStatus.SUCCESS) {
100
- multiResponse = await this.processSuccess(type);
101
- }
102
- else {
103
- multiResponse = await this.processError();
104
- }
105
- this.transitionAdjacent(multiResponse, telemetry);
106
- }
107
- catch (error) {
108
- if (error instanceof errors_1.CollationError) {
109
- this.logger.info(`process-event-${error.fault}-error`, { ...error });
110
- return;
111
- }
112
- else if (error instanceof errors_1.InactiveJobError) {
113
- this.logger.info('process-event-inactive-job-error', { ...error });
114
- return;
115
- }
116
- else if (error instanceof errors_1.GenerationalError) {
117
- this.logger.info('process-event-generational-job-error', { ...error });
118
- return;
119
- }
120
- else if (error instanceof errors_1.GetStateError) {
121
- this.logger.info('process-event-get-job-error', { ...error });
122
- return;
123
- }
124
- this.logger.error('activity-process-event-error', {
125
- ...error,
126
- message: error.message,
127
- stack: error.stack,
128
- name: error.name,
129
- });
130
- telemetry?.setActivityError(error.message);
131
- throw error;
132
- }
133
- finally {
134
- telemetry?.endActivitySpan();
135
- this.logger.debug('activity-process-event-end', { jid, aid });
136
- }
137
- }
138
- async processPending(type) {
139
- this.bindActivityData(type);
140
- this.adjacencyList = await this.filterAdjacent();
141
- this.mapJobData();
142
- const multi = this.store.getMulti();
143
- await this.setState(multi);
144
- await collator_1.CollatorService.notarizeContinuation(this, multi);
145
- await this.setStatus(this.adjacencyList.length, multi);
146
- return (await multi.exec());
147
- }
148
- async processSuccess(type) {
149
- this.bindActivityData(type);
150
- this.adjacencyList = await this.filterAdjacent();
151
- this.mapJobData();
152
- const multi = this.store.getMulti();
153
- await this.setState(multi);
154
- await collator_1.CollatorService.notarizeCompletion(this, multi);
155
- await this.setStatus(this.adjacencyList.length - 1, multi);
156
- return (await multi.exec());
157
- }
158
- async processError() {
159
- this.bindActivityError(this.data);
160
- this.adjacencyList = await this.filterAdjacent();
161
- if (!this.adjacencyList.length) {
162
- this.bindJobError(this.data);
163
- }
164
- this.mapJobData();
165
- const multi = this.store.getMulti();
166
- await this.setState(multi);
167
- await collator_1.CollatorService.notarizeCompletion(this, multi);
168
- await this.setStatus(this.adjacencyList.length - 1, multi);
169
- return (await multi.exec());
170
- }
171
- async transitionAdjacent(multiResponse, telemetry) {
172
- telemetry.mapActivityAttributes();
173
- const jobStatus = this.resolveStatus(multiResponse);
174
- const attrs = { 'app.job.jss': jobStatus };
175
- const messageIds = await this.transition(this.adjacencyList, jobStatus);
176
- if (messageIds?.length) {
177
- attrs['app.activity.mids'] = messageIds.join(',');
178
- }
179
- telemetry.setActivityAttributes(attrs);
180
- }
181
- resolveStatus(multiResponse) {
182
- const activityStatus = multiResponse[multiResponse.length - 1];
183
- if (Array.isArray(activityStatus)) {
184
- return Number(activityStatus[1]);
185
- }
186
- else {
187
- return Number(activityStatus);
188
- }
189
- }
190
- mapJobData() {
191
- if (this.config.job?.maps) {
192
- const mapper = new mapper_1.MapperService((0, utils_1.deepCopy)(this.config.job.maps), this.context);
193
- const output = mapper.mapRules();
194
- if (output) {
195
- for (const key in output) {
196
- const f1 = key.indexOf('[');
197
- if (f1 > -1) {
198
- const amount = key.substring(f1 + 1).split(']')[0];
199
- if (!isNaN(Number(amount))) {
200
- const left = key.substring(0, f1);
201
- output[left] = output[key];
202
- delete output[key];
203
- }
204
- else if (amount === '-' || amount === '_') {
205
- const obj = output[key];
206
- Object.keys(obj).forEach((newKey) => {
207
- output[newKey] = obj[newKey];
208
- });
209
- }
210
- }
211
- }
212
- }
213
- this.context.data = output;
214
- }
215
- }
216
- mapInputData() {
217
- if (this.config.input?.maps) {
218
- const mapper = new mapper_1.MapperService((0, utils_1.deepCopy)(this.config.input.maps), this.context);
219
- this.context.data = mapper.mapRules();
220
- }
221
- }
222
- mapOutputData() {
223
- if (this.config.output?.maps) {
224
- const mapper = new mapper_1.MapperService((0, utils_1.deepCopy)(this.config.output.maps), this.context);
225
- const actOutData = mapper.mapRules();
226
- const activityId = this.metadata.aid;
227
- const data = { ...this.context[activityId].output, ...actOutData };
228
- this.context[activityId].output.data = data;
229
- }
230
- }
231
- async registerTimeout() {
232
- }
233
- bindActivityError(data) {
234
- const md = this.context[this.metadata.aid].output.metadata;
235
- md.err = JSON.stringify(this.data);
236
- md.$error = { ...data, is_stream_error: true };
237
- }
238
- bindJobError(data) {
239
- this.context.metadata.err = JSON.stringify({
240
- ...data,
241
- is_stream_error: true,
242
- });
243
- }
244
- async getTriggerConfig() {
245
- return await this.store.getSchema(this.config.trigger, await this.engine.getVID());
246
- }
247
- getJobStatus() {
248
- return null;
249
- }
250
- async setStatus(amount, multi) {
251
- const { id: appId } = await this.engine.getVID();
252
- return await this.store.setStatus(amount, this.context.metadata.jid, appId, multi);
253
- }
254
- authorizeEntry(state) {
255
- return (this.adjacencyList?.map((streamData) => {
256
- const { metadata: { aid }, } = streamData;
257
- state[`${aid}/output/metadata/as`] = collator_1.CollatorService.getSeed();
258
- return aid;
259
- }) ?? []);
260
- }
261
- bindDimensionalAddress(state) {
262
- const dad = this.resolveDad();
263
- state[`${this.metadata.aid}/output/metadata/dad`] = dad;
264
- }
265
- async setState(multi) {
266
- const jobId = this.context.metadata.jid;
267
- this.bindJobMetadata();
268
- this.bindActivityMetadata();
269
- const state = {};
270
- await this.bindJobState(state);
271
- const presets = this.authorizeEntry(state);
272
- this.bindDimensionalAddress(state);
273
- this.bindActivityState(state);
274
- const symbolNames = [
275
- `$${this.config.subscribes}`,
276
- this.metadata.aid,
277
- ...presets,
278
- ];
279
- const dIds = collator_1.CollatorService.getDimensionsById([...this.config.ancestors, this.metadata.aid], this.resolveDad());
280
- return await this.store.setState(state, this.getJobStatus(), jobId, symbolNames, dIds, multi);
281
- }
282
- bindJobMetadata() {
283
- this.context.metadata.ju = (0, utils_1.formatISODate)(new Date());
284
- }
285
- bindActivityMetadata() {
286
- const self = this.context['$self'];
287
- if (!self.output.metadata) {
288
- self.output.metadata = {};
289
- }
290
- if (this.status === stream_1.StreamStatus.ERROR) {
291
- self.output.metadata.err = JSON.stringify(this.data);
292
- }
293
- const ts = (0, utils_1.formatISODate)(new Date());
294
- self.output.metadata.ac = ts;
295
- self.output.metadata.au = ts;
296
- self.output.metadata.atp = this.config.type;
297
- if (this.config.subtype) {
298
- self.output.metadata.stp = this.config.subtype;
299
- }
300
- self.output.metadata.aid = this.metadata.aid;
301
- }
302
- async bindJobState(state) {
303
- const triggerConfig = await this.getTriggerConfig();
304
- const PRODUCES = [
305
- ...(triggerConfig.PRODUCES || []),
306
- ...this.bindJobMetadataPaths(),
307
- ];
308
- for (const path of PRODUCES) {
309
- const value = (0, utils_1.getValueByPath)(this.context, path);
310
- if (value !== undefined) {
311
- state[path] = value;
312
- }
313
- }
314
- for (const key in this.context?.data ?? {}) {
315
- if (key.startsWith('-') || key.startsWith('_')) {
316
- state[key] = this.context.data[key];
317
- }
318
- }
319
- telemetry_1.TelemetryService.bindJobTelemetryToState(state, this.config, this.context);
320
- }
321
- bindActivityState(state) {
322
- const produces = [
323
- ...this.config.produces,
324
- ...this.bindActivityMetadataPaths(),
325
- ];
326
- for (const path of produces) {
327
- const prefixedPath = `${this.metadata.aid}/${path}`;
328
- const value = (0, utils_1.getValueByPath)(this.context, prefixedPath);
329
- if (value !== undefined) {
330
- state[prefixedPath] = value;
331
- }
332
- }
333
- telemetry_1.TelemetryService.bindActivityTelemetryToState(state, this.config, this.metadata, this.context, this.leg);
334
- }
335
- bindJobMetadataPaths() {
336
- return serializer_1.MDATA_SYMBOLS.JOB_UPDATE.KEYS.map((key) => `metadata/${key}`);
337
- }
338
- bindActivityMetadataPaths() {
339
- const keys_to_save = this.leg === 1 ? 'ACTIVITY' : 'ACTIVITY_UPDATE';
340
- return serializer_1.MDATA_SYMBOLS[keys_to_save].KEYS.map((key) => `output/metadata/${key}`);
341
- }
342
- async getState() {
343
- const gid = this.context.metadata.gid;
344
- const jobSymbolHashName = `$${this.config.subscribes}`;
345
- const consumes = {
346
- [jobSymbolHashName]: serializer_1.MDATA_SYMBOLS.JOB.KEYS.map((key) => `metadata/${key}`),
347
- };
348
- for (let [activityId, paths] of Object.entries(this.config.consumes)) {
349
- if (activityId === '$job') {
350
- for (const path of paths) {
351
- consumes[jobSymbolHashName].push(path);
352
- }
353
- }
354
- else {
355
- if (activityId === '$self') {
356
- activityId = this.metadata.aid;
357
- }
358
- if (!consumes[activityId]) {
359
- consumes[activityId] = [];
360
- }
361
- for (const path of paths) {
362
- consumes[activityId].push(`${activityId}/${path}`);
363
- }
364
- }
365
- }
366
- telemetry_1.TelemetryService.addTargetTelemetryPaths(consumes, this.config, this.metadata, this.leg);
367
- const { dad, jid } = this.context.metadata;
368
- const dIds = collator_1.CollatorService.getDimensionsById([...this.config.ancestors, this.metadata.aid], dad || '');
369
- const [state, _status] = await this.store.getState(jid, consumes, dIds);
370
- this.context = (0, utils_1.restoreHierarchy)(state);
371
- this.assertGenerationalId(this.context?.metadata?.gid, gid);
372
- this.initDimensionalAddress(dad);
373
- this.initSelf(this.context);
374
- this.initPolicies(this.context);
375
- }
376
- assertGenerationalId(jobGID, msgGID) {
377
- if (msgGID !== jobGID) {
378
- throw new errors_1.GenerationalError(jobGID, msgGID, this.context?.metadata?.jid ?? '', this.context?.metadata?.aid ?? '', this.context?.metadata?.dad ?? '');
379
- }
380
- }
381
- initDimensionalAddress(dad) {
382
- this.metadata.dad = dad;
383
- }
384
- initSelf(context) {
385
- const activityId = this.metadata.aid;
386
- if (!context[activityId]) {
387
- context[activityId] = {};
388
- }
389
- const self = context[activityId];
390
- if (!self.output) {
391
- self.output = {};
392
- }
393
- if (!self.input) {
394
- self.input = {};
395
- }
396
- if (!self.hook) {
397
- self.hook = {};
398
- }
399
- if (!self.output.metadata) {
400
- self.output.metadata = {};
401
- }
402
- self.output.metadata.au = (0, utils_1.formatISODate)(new Date());
403
- context['$self'] = self;
404
- context['$job'] = context;
405
- return context;
406
- }
407
- initPolicies(context) {
408
- const expire = pipe_1.Pipe.resolve(this.config.expire ?? enums_1.HMSH_EXPIRE_DURATION, context);
409
- context.metadata.expire = expire;
410
- if (this.config.persistent != undefined) {
411
- const persistent = pipe_1.Pipe.resolve(this.config.persistent ?? false, context);
412
- context.metadata.persistent = persistent;
413
- }
414
- }
415
- bindActivityData(type) {
416
- this.context[this.metadata.aid][type].data = this.data;
417
- }
418
- resolveDad() {
419
- let dad = this.metadata.dad;
420
- if (this.adjacentIndex > 0) {
421
- dad = `${dad.substring(0, dad.lastIndexOf(','))},${this.adjacentIndex}`;
422
- }
423
- return dad;
424
- }
425
- resolveAdjacentDad() {
426
- return `${this.resolveDad()}${collator_1.CollatorService.getDimensionalSeed(0)}`;
427
- }
428
- async filterAdjacent() {
429
- const adjacencyList = [];
430
- const transitions = await this.store.getTransitions(await this.engine.getVID());
431
- const transition = transitions[`.${this.metadata.aid}`];
432
- const adjacentDad = this.resolveAdjacentDad();
433
- if (transition) {
434
- for (const toActivityId in transition) {
435
- const transitionRule = transition[toActivityId];
436
- if (mapper_1.MapperService.evaluate(transitionRule, this.context, this.code)) {
437
- adjacencyList.push({
438
- metadata: {
439
- guid: (0, utils_1.guid)(),
440
- jid: this.context.metadata.jid,
441
- gid: this.context.metadata.gid,
442
- dad: adjacentDad,
443
- aid: toActivityId,
444
- spn: this.context['$self'].output.metadata?.l2s,
445
- trc: this.context.metadata.trc,
446
- },
447
- type: stream_1.StreamDataType.TRANSITION,
448
- data: {},
449
- });
450
- }
451
- }
452
- }
453
- return adjacencyList;
454
- }
455
- isJobComplete(jobStatus) {
456
- return jobStatus <= 0;
457
- }
458
- shouldEmit() {
459
- if (this.config.emit) {
460
- return pipe_1.Pipe.resolve(this.config.emit, this.context) === true;
461
- }
462
- return false;
463
- }
464
- shouldPersistJob() {
465
- if (this.config.persist !== undefined) {
466
- return pipe_1.Pipe.resolve(this.config.persist, this.context) === true;
467
- }
468
- return false;
469
- }
470
- async transition(adjacencyList, jobStatus) {
471
- if (this.jobWasInterrupted(jobStatus)) {
472
- return;
473
- }
474
- let mIds = [];
475
- if (this.shouldEmit() ||
476
- this.isJobComplete(jobStatus) ||
477
- this.shouldPersistJob()) {
478
- await this.engine.runJobCompletionTasks(this.context, {
479
- emit: !this.isJobComplete(jobStatus) && !this.shouldPersistJob(),
480
- });
481
- }
482
- if (adjacencyList.length && !this.isJobComplete(jobStatus)) {
483
- const multi = this.store.getMulti();
484
- for (const execSignal of adjacencyList) {
485
- await this.engine.router?.publishMessage(null, execSignal, multi);
486
- }
487
- mIds = (await multi.exec());
488
- }
489
- return mIds;
490
- }
491
- jobWasInterrupted(jobStatus) {
492
- return jobStatus < -100000000;
493
- }
494
- }
495
- exports.Activity = Activity;
1
+ 'use strict';(function(_0x4b1300,_0x2869d8){const _0x163eac=_0x117f,_0x4209cd=_0x4b1300();while(!![]){try{const _0x3c16c0=-parseInt(_0x163eac(0x1a8))/0x1*(parseInt(_0x163eac(0x1a7))/0x2)+parseInt(_0x163eac(0x1ac))/0x3+-parseInt(_0x163eac(0x1ae))/0x4+parseInt(_0x163eac(0x1a9))/0x5+parseInt(_0x163eac(0x1aa))/0x6+-parseInt(_0x163eac(0x1ad))/0x7*(-parseInt(_0x163eac(0x1ab))/0x8)+-parseInt(_0x163eac(0x1af))/0x9;if(_0x3c16c0===_0x2869d8)break;else _0x4209cd['push'](_0x4209cd['shift']());}catch(_0x460e41){_0x4209cd['push'](_0x4209cd['shift']());}}}(_0x15f3,0x3e356));function _0x117f(_0x135f60,_0x5e33e7){const _0x15f3f3=_0x15f3();return _0x117f=function(_0x117f21,_0x524ec2){_0x117f21=_0x117f21-0x1a7;let _0x57b674=_0x15f3f3[_0x117f21];return _0x57b674;},_0x117f(_0x135f60,_0x5e33e7);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['Activity']=void 0x0;const enums_1=require('../../modules/enums'),errors_1=require('../../modules/errors'),utils_1=require('../../modules/utils'),collator_1=require('../collator'),mapper_1=require('../mapper'),pipe_1=require('../pipe'),serializer_1=require('../serializer'),telemetry_1=require('../telemetry'),stream_1=require('../../types/stream');function _0x15f3(){const _0x3f1e54=['1922205PwpzVf','2618154UvXkkW','8WJRlKO','358041GWrqEN','1889755iBOuhC','292736yqAhNn','4102407PqFeOa','7822cPxlEK','109QbZqTZ'];_0x15f3=function(){return _0x3f1e54;};return _0x15f3();}class Activity{constructor(_0x1e5c0b,_0x112dd3,_0x50dc7c,_0x5ebc84,_0x2fc507,_0x3dc578){this['status']=stream_1['StreamStatus']['SUCCESS'],this['code']=0xc8,this['adjacentIndex']=0x0,this['config']=_0x1e5c0b,this['data']=_0x112dd3,this['metadata']=_0x50dc7c,this['hook']=_0x5ebc84,this['engine']=_0x2fc507,this['context']=_0x3dc578||{'data':{},'metadata':{}},this['logger']=_0x2fc507['logger'],this['store']=_0x2fc507['store'];}['setLeg'](_0x9170b5){this['leg']=_0x9170b5;}['mapStatusThreshold'](){if(this['config']['statusThreshold']!==undefined){const _0x3f8f82=pipe_1['Pipe']['resolve'](this['config']['statusThreshold'],this['context']);if(_0x3f8f82!==undefined&&!isNaN(Number(_0x3f8f82)))return _0x3f8f82;}return 0x0;}async['verifyEntry'](){this['setLeg'](0x1),await this['getState']();const _0x47f5ff=this['mapStatusThreshold']();try{collator_1['CollatorService']['assertJobActive'](this['context']['metadata']['js'],this['context']['metadata']['jid'],this['metadata']['aid'],_0x47f5ff);}catch(_0x4abeda){await collator_1['CollatorService']['notarizeEntry'](this);if(_0x47f5ff>0x0){if(this['context']['metadata']['js']===_0x47f5ff){const _0x6de70d=await this['setStatus'](-_0x47f5ff);Number(_0x6de70d)===0x0&&await this['engine']['runJobCompletionTasks'](this['context']);}}else throw _0x4abeda;return;}await collator_1['CollatorService']['notarizeEntry'](this);}async['verifyReentry'](){const _0xae4d16=this['context']['metadata']['guid'];return this['setLeg'](0x2),await this['getState'](),collator_1['CollatorService']['assertJobActive'](this['context']['metadata']['js'],this['context']['metadata']['jid'],this['metadata']['aid']),await collator_1['CollatorService']['notarizeReentry'](this,_0xae4d16);}async['processEvent'](_0x37ef49=stream_1['StreamStatus']['SUCCESS'],_0x4ae41c=0xc8,_0x3afaf1='output'){this['setLeg'](0x2);const _0x13fc13=this['context']['metadata']['jid'];if(!_0x13fc13){this['logger']['error']('activity-process-event-error',{'message':'job\x20id\x20is\x20undefined'});return;}const _0x5f5eda=this['metadata']['aid'];this['status']=_0x37ef49,this['code']=_0x4ae41c,this['logger']['debug']('activity-process-event',{'topic':this['config']['subtype'],'jid':_0x13fc13,'aid':_0x5f5eda,'status':_0x37ef49,'code':_0x4ae41c});let _0x235c42;try{const _0x4b2b22=await this['verifyReentry']();this['adjacentIndex']=collator_1['CollatorService']['getDimensionalIndex'](_0x4b2b22),_0x235c42=new telemetry_1['TelemetryService'](this['engine']['appId'],this['config'],this['metadata'],this['context']),_0x235c42['startActivitySpan'](this['leg']);let _0x541c4d;if(_0x37ef49===stream_1['StreamStatus']['PENDING'])_0x541c4d=await this['processPending'](_0x3afaf1);else _0x37ef49===stream_1['StreamStatus']['SUCCESS']?_0x541c4d=await this['processSuccess'](_0x3afaf1):_0x541c4d=await this['processError']();this['transitionAdjacent'](_0x541c4d,_0x235c42);}catch(_0xdf4a88){if(_0xdf4a88 instanceof errors_1['CollationError']){this['logger']['info']('process-event-'+_0xdf4a88['fault']+'-error',{..._0xdf4a88});return;}else{if(_0xdf4a88 instanceof errors_1['InactiveJobError']){this['logger']['info']('process-event-inactive-job-error',{..._0xdf4a88});return;}else{if(_0xdf4a88 instanceof errors_1['GenerationalError']){this['logger']['info']('process-event-generational-job-error',{..._0xdf4a88});return;}else{if(_0xdf4a88 instanceof errors_1['GetStateError']){this['logger']['info']('process-event-get-job-error',{..._0xdf4a88});return;}}}}this['logger']['error']('activity-process-event-error',{..._0xdf4a88,'message':_0xdf4a88['message'],'stack':_0xdf4a88['stack'],'name':_0xdf4a88['name']}),_0x235c42?.['setActivityError'](_0xdf4a88['message']);throw _0xdf4a88;}finally{_0x235c42?.['endActivitySpan'](),this['logger']['debug']('activity-process-event-end',{'jid':_0x13fc13,'aid':_0x5f5eda});}}async['processPending'](_0xdca878){this['bindActivityData'](_0xdca878),this['adjacencyList']=await this['filterAdjacent'](),this['mapJobData']();const _0x3000ba=this['store']['getMulti']();return await this['setState'](_0x3000ba),await collator_1['CollatorService']['notarizeContinuation'](this,_0x3000ba),await this['setStatus'](this['adjacencyList']['length'],_0x3000ba),await _0x3000ba['exec']();}async['processSuccess'](_0x5029a5){this['bindActivityData'](_0x5029a5),this['adjacencyList']=await this['filterAdjacent'](),this['mapJobData']();const _0x2c2a1f=this['store']['getMulti']();return await this['setState'](_0x2c2a1f),await collator_1['CollatorService']['notarizeCompletion'](this,_0x2c2a1f),await this['setStatus'](this['adjacencyList']['length']-0x1,_0x2c2a1f),await _0x2c2a1f['exec']();}async['processError'](){this['bindActivityError'](this['data']),this['adjacencyList']=await this['filterAdjacent']();!this['adjacencyList']['length']&&this['bindJobError'](this['data']);this['mapJobData']();const _0x2aa981=this['store']['getMulti']();return await this['setState'](_0x2aa981),await collator_1['CollatorService']['notarizeCompletion'](this,_0x2aa981),await this['setStatus'](this['adjacencyList']['length']-0x1,_0x2aa981),await _0x2aa981['exec']();}async['transitionAdjacent'](_0x3f50b2,_0x4ee5f7){_0x4ee5f7['mapActivityAttributes']();const _0x43e444=this['resolveStatus'](_0x3f50b2),_0x2c1cc8={'app.job.jss':_0x43e444},_0x770918=await this['transition'](this['adjacencyList'],_0x43e444);_0x770918?.['length']&&(_0x2c1cc8['app.activity.mids']=_0x770918['join'](',')),_0x4ee5f7['setActivityAttributes'](_0x2c1cc8);}['resolveStatus'](_0x2f10bf){const _0x3a9c78=_0x2f10bf[_0x2f10bf['length']-0x1];return Array['isArray'](_0x3a9c78)?Number(_0x3a9c78[0x1]):Number(_0x3a9c78);}['mapJobData'](){if(this['config']['job']?.['maps']){const _0x175757=new mapper_1['MapperService']((0x0,utils_1['deepCopy'])(this['config']['job']['maps']),this['context']),_0x5b1f16=_0x175757['mapRules']();if(_0x5b1f16)for(const _0x6ab1bd in _0x5b1f16){const _0x167f2b=_0x6ab1bd['indexOf']('[');if(_0x167f2b>-0x1){const _0x4b93c3=_0x6ab1bd['substring'](_0x167f2b+0x1)['split'](']')[0x0];if(!isNaN(Number(_0x4b93c3))){const _0x2b98f1=_0x6ab1bd['substring'](0x0,_0x167f2b);_0x5b1f16[_0x2b98f1]=_0x5b1f16[_0x6ab1bd],delete _0x5b1f16[_0x6ab1bd];}else{if(_0x4b93c3==='-'||_0x4b93c3==='_'){const _0x311661=_0x5b1f16[_0x6ab1bd];Object['keys'](_0x311661)['forEach'](_0x46433a=>{_0x5b1f16[_0x46433a]=_0x311661[_0x46433a];});}}}}this['context']['data']=_0x5b1f16;}}['mapInputData'](){if(this['config']['input']?.['maps']){const _0x46cd12=new mapper_1['MapperService']((0x0,utils_1['deepCopy'])(this['config']['input']['maps']),this['context']);this['context']['data']=_0x46cd12['mapRules']();}}['mapOutputData'](){if(this['config']['output']?.['maps']){const _0x18ced0=new mapper_1['MapperService']((0x0,utils_1['deepCopy'])(this['config']['output']['maps']),this['context']),_0x5689ce=_0x18ced0['mapRules'](),_0x630ed5=this['metadata']['aid'],_0x1f8b09={...this['context'][_0x630ed5]['output'],..._0x5689ce};this['context'][_0x630ed5]['output']['data']=_0x1f8b09;}}async['registerTimeout'](){}['bindActivityError'](_0x4b2be3){const _0x29bbdc=this['context'][this['metadata']['aid']]['output']['metadata'];_0x29bbdc['err']=JSON['stringify'](this['data']),_0x29bbdc['$error']={..._0x4b2be3,'is_stream_error':!![]};}['bindJobError'](_0x57d614){this['context']['metadata']['err']=JSON['stringify']({..._0x57d614,'is_stream_error':!![]});}async['getTriggerConfig'](){return await this['store']['getSchema'](this['config']['trigger'],await this['engine']['getVID']());}['getJobStatus'](){return null;}async['setStatus'](_0x2fd3db,_0x486a74){const {id:_0x273343}=await this['engine']['getVID']();return await this['store']['setStatus'](_0x2fd3db,this['context']['metadata']['jid'],_0x273343,_0x486a74);}['authorizeEntry'](_0x1fa1e1){return this['adjacencyList']?.['map'](_0x1cd2ca=>{const {metadata:{aid:_0x53da39}}=_0x1cd2ca;return _0x1fa1e1[_0x53da39+'/output/metadata/as']=collator_1['CollatorService']['getSeed'](),_0x53da39;})??[];}['bindDimensionalAddress'](_0x2a1112){const _0x54912c=this['resolveDad']();_0x2a1112[this['metadata']['aid']+'/output/metadata/dad']=_0x54912c;}async['setState'](_0x570c12){const _0xa976ff=this['context']['metadata']['jid'];this['bindJobMetadata'](),this['bindActivityMetadata']();const _0x2335a7={};await this['bindJobState'](_0x2335a7);const _0x327236=this['authorizeEntry'](_0x2335a7);this['bindDimensionalAddress'](_0x2335a7),this['bindActivityState'](_0x2335a7);const _0x22f236=['$'+this['config']['subscribes'],this['metadata']['aid'],..._0x327236],_0x1d3094=collator_1['CollatorService']['getDimensionsById']([...this['config']['ancestors'],this['metadata']['aid']],this['resolveDad']());return await this['store']['setState'](_0x2335a7,this['getJobStatus'](),_0xa976ff,_0x22f236,_0x1d3094,_0x570c12);}['bindJobMetadata'](){this['context']['metadata']['ju']=(0x0,utils_1['formatISODate'])(new Date());}['bindActivityMetadata'](){const _0x131004=this['context']['$self'];!_0x131004['output']['metadata']&&(_0x131004['output']['metadata']={});this['status']===stream_1['StreamStatus']['ERROR']&&(_0x131004['output']['metadata']['err']=JSON['stringify'](this['data']));const _0xddd5da=(0x0,utils_1['formatISODate'])(new Date());_0x131004['output']['metadata']['ac']=_0xddd5da,_0x131004['output']['metadata']['au']=_0xddd5da,_0x131004['output']['metadata']['atp']=this['config']['type'],this['config']['subtype']&&(_0x131004['output']['metadata']['stp']=this['config']['subtype']),_0x131004['output']['metadata']['aid']=this['metadata']['aid'];}async['bindJobState'](_0x1a71b6){const _0x7ba6ee=await this['getTriggerConfig'](),_0x14340a=[..._0x7ba6ee['PRODUCES']||[],...this['bindJobMetadataPaths']()];for(const _0x3bd077 of _0x14340a){const _0x52cc32=(0x0,utils_1['getValueByPath'])(this['context'],_0x3bd077);_0x52cc32!==undefined&&(_0x1a71b6[_0x3bd077]=_0x52cc32);}for(const _0x5209b2 in this['context']?.['data']??{}){(_0x5209b2['startsWith']('-')||_0x5209b2['startsWith']('_'))&&(_0x1a71b6[_0x5209b2]=this['context']['data'][_0x5209b2]);}telemetry_1['TelemetryService']['bindJobTelemetryToState'](_0x1a71b6,this['config'],this['context']);}['bindActivityState'](_0x1d9431){const _0x30e5b9=[...this['config']['produces'],...this['bindActivityMetadataPaths']()];for(const _0x539173 of _0x30e5b9){const _0x4b6e5f=this['metadata']['aid']+'/'+_0x539173,_0x5d3296=(0x0,utils_1['getValueByPath'])(this['context'],_0x4b6e5f);_0x5d3296!==undefined&&(_0x1d9431[_0x4b6e5f]=_0x5d3296);}telemetry_1['TelemetryService']['bindActivityTelemetryToState'](_0x1d9431,this['config'],this['metadata'],this['context'],this['leg']);}['bindJobMetadataPaths'](){return serializer_1['MDATA_SYMBOLS']['JOB_UPDATE']['KEYS']['map'](_0x5a70dc=>'metadata/'+_0x5a70dc);}['bindActivityMetadataPaths'](){const _0x3d4712=this['leg']===0x1?'ACTIVITY':'ACTIVITY_UPDATE';return serializer_1['MDATA_SYMBOLS'][_0x3d4712]['KEYS']['map'](_0x496e1b=>'output/metadata/'+_0x496e1b);}async['getState'](){const _0x46e483=this['context']['metadata']['gid'],_0x108e7c='$'+this['config']['subscribes'],_0x1c734e={[_0x108e7c]:serializer_1['MDATA_SYMBOLS']['JOB']['KEYS']['map'](_0x50ccb8=>'metadata/'+_0x50ccb8)};for(let [_0x2db636,_0x4aa80a]of Object['entries'](this['config']['consumes'])){if(_0x2db636==='$job')for(const _0x1faeef of _0x4aa80a){_0x1c734e[_0x108e7c]['push'](_0x1faeef);}else{_0x2db636==='$self'&&(_0x2db636=this['metadata']['aid']);!_0x1c734e[_0x2db636]&&(_0x1c734e[_0x2db636]=[]);for(const _0x265847 of _0x4aa80a){_0x1c734e[_0x2db636]['push'](_0x2db636+'/'+_0x265847);}}}telemetry_1['TelemetryService']['addTargetTelemetryPaths'](_0x1c734e,this['config'],this['metadata'],this['leg']);const {dad:_0x2c13c8,jid:_0xc65cea}=this['context']['metadata'],_0x484d73=collator_1['CollatorService']['getDimensionsById']([...this['config']['ancestors'],this['metadata']['aid']],_0x2c13c8||''),[_0x2b680b,_0x28f006]=await this['store']['getState'](_0xc65cea,_0x1c734e,_0x484d73);this['context']=(0x0,utils_1['restoreHierarchy'])(_0x2b680b),this['assertGenerationalId'](this['context']?.['metadata']?.['gid'],_0x46e483),this['initDimensionalAddress'](_0x2c13c8),this['initSelf'](this['context']),this['initPolicies'](this['context']);}['assertGenerationalId'](_0xd821ce,_0x400386){if(_0x400386!==_0xd821ce)throw new errors_1['GenerationalError'](_0xd821ce,_0x400386,this['context']?.['metadata']?.['jid']??'',this['context']?.['metadata']?.['aid']??'',this['context']?.['metadata']?.['dad']??'');}['initDimensionalAddress'](_0x331c1e){this['metadata']['dad']=_0x331c1e;}['initSelf'](_0x463f04){const _0x27cb86=this['metadata']['aid'];!_0x463f04[_0x27cb86]&&(_0x463f04[_0x27cb86]={});const _0x466590=_0x463f04[_0x27cb86];return!_0x466590['output']&&(_0x466590['output']={}),!_0x466590['input']&&(_0x466590['input']={}),!_0x466590['hook']&&(_0x466590['hook']={}),!_0x466590['output']['metadata']&&(_0x466590['output']['metadata']={}),_0x466590['output']['metadata']['au']=(0x0,utils_1['formatISODate'])(new Date()),_0x463f04['$self']=_0x466590,_0x463f04['$job']=_0x463f04,_0x463f04;}['initPolicies'](_0xf467ac){const _0x4c47b2=pipe_1['Pipe']['resolve'](this['config']['expire']??enums_1['HMSH_EXPIRE_DURATION'],_0xf467ac);_0xf467ac['metadata']['expire']=_0x4c47b2;if(this['config']['persistent']!=undefined){const _0x32f74e=pipe_1['Pipe']['resolve'](this['config']['persistent']??![],_0xf467ac);_0xf467ac['metadata']['persistent']=_0x32f74e;}}['bindActivityData'](_0x26ff39){this['context'][this['metadata']['aid']][_0x26ff39]['data']=this['data'];}['resolveDad'](){let _0x4670a8=this['metadata']['dad'];return this['adjacentIndex']>0x0&&(_0x4670a8=_0x4670a8['substring'](0x0,_0x4670a8['lastIndexOf'](','))+','+this['adjacentIndex']),_0x4670a8;}['resolveAdjacentDad'](){return''+this['resolveDad']()+collator_1['CollatorService']['getDimensionalSeed'](0x0);}async['filterAdjacent'](){const _0x889a38=[],_0x5f1b9a=await this['store']['getTransitions'](await this['engine']['getVID']()),_0x4590d1=_0x5f1b9a['.'+this['metadata']['aid']],_0x28d2e5=this['resolveAdjacentDad']();if(_0x4590d1)for(const _0x2452b1 in _0x4590d1){const _0x29093f=_0x4590d1[_0x2452b1];mapper_1['MapperService']['evaluate'](_0x29093f,this['context'],this['code'])&&_0x889a38['push']({'metadata':{'guid':(0x0,utils_1['guid'])(),'jid':this['context']['metadata']['jid'],'gid':this['context']['metadata']['gid'],'dad':_0x28d2e5,'aid':_0x2452b1,'spn':this['context']['$self']['output']['metadata']?.['l2s'],'trc':this['context']['metadata']['trc']},'type':stream_1['StreamDataType']['TRANSITION'],'data':{}});}return _0x889a38;}['isJobComplete'](_0x18db98){return _0x18db98<=0x0;}['shouldEmit'](){if(this['config']['emit'])return pipe_1['Pipe']['resolve'](this['config']['emit'],this['context'])===!![];return![];}['shouldPersistJob'](){if(this['config']['persist']!==undefined)return pipe_1['Pipe']['resolve'](this['config']['persist'],this['context'])===!![];return![];}async['transition'](_0x5462cb,_0x4f28c5){if(this['jobWasInterrupted'](_0x4f28c5))return;let _0x2a8437=[];(this['shouldEmit']()||this['isJobComplete'](_0x4f28c5)||this['shouldPersistJob']())&&await this['engine']['runJobCompletionTasks'](this['context'],{'emit':!this['isJobComplete'](_0x4f28c5)&&!this['shouldPersistJob']()});if(_0x5462cb['length']&&!this['isJobComplete'](_0x4f28c5)){const _0x4683a4=this['store']['getMulti']();for(const _0x236827 of _0x5462cb){await this['engine']['router']?.['publishMessage'](null,_0x236827,_0x4683a4);}_0x2a8437=await _0x4683a4['exec']();}return _0x2a8437;}['jobWasInterrupted'](_0x4fd1da){return _0x4fd1da<-0x5f5e100;}}exports['Activity']=Activity;
@@ -1,109 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Await = void 0;
4
- const errors_1 = require("../../modules/errors");
5
- const utils_1 = require("../../modules/utils");
6
- const collator_1 = require("../collator");
7
- const pipe_1 = require("../pipe");
8
- const telemetry_1 = require("../telemetry");
9
- const stream_1 = require("../../types/stream");
10
- const activity_1 = require("./activity");
11
- class Await extends activity_1.Activity {
12
- constructor(config, data, metadata, hook, engine, context) {
13
- super(config, data, metadata, hook, engine, context);
14
- }
15
- async process() {
16
- this.logger.debug('await-process', {
17
- jid: this.context.metadata.jid,
18
- gid: this.context.metadata.gid,
19
- aid: this.metadata.aid,
20
- });
21
- let telemetry;
22
- try {
23
- await this.verifyEntry();
24
- telemetry = new telemetry_1.TelemetryService(this.engine.appId, this.config, this.metadata, this.context);
25
- telemetry.startActivitySpan(this.leg);
26
- this.mapInputData();
27
- const multi = this.store.getMulti();
28
- const messageId = await this.execActivity(multi);
29
- await collator_1.CollatorService.authorizeReentry(this, multi);
30
- await this.setState(multi);
31
- await this.setStatus(0, multi);
32
- const multiResponse = (await multi.exec());
33
- telemetry.mapActivityAttributes();
34
- const jobStatus = this.resolveStatus(multiResponse);
35
- telemetry.setActivityAttributes({
36
- 'app.activity.mid': messageId,
37
- 'app.job.jss': jobStatus,
38
- });
39
- return this.context.metadata.aid;
40
- }
41
- catch (error) {
42
- if (error instanceof errors_1.InactiveJobError) {
43
- this.logger.error('await-inactive-job-error', { ...error });
44
- return;
45
- }
46
- else if (error instanceof errors_1.GenerationalError) {
47
- this.logger.info('process-event-generational-job-error', { ...error });
48
- return;
49
- }
50
- else if (error instanceof errors_1.GetStateError) {
51
- this.logger.error('await-get-state-error', { ...error });
52
- return;
53
- }
54
- else if (error instanceof errors_1.CollationError) {
55
- if (error.fault === 'duplicate') {
56
- this.logger.info('await-collation-overage', {
57
- job_id: this.context.metadata.jid,
58
- guid: this.context.metadata.guid,
59
- });
60
- return;
61
- }
62
- this.logger.error('await-collation-error', { ...error });
63
- }
64
- else {
65
- this.logger.error('await-process-error', { ...error });
66
- }
67
- telemetry?.setActivityError(error.message);
68
- throw error;
69
- }
70
- finally {
71
- telemetry?.endActivitySpan();
72
- this.logger.debug('await-process-end', {
73
- jid: this.context.metadata.jid,
74
- gid: this.context.metadata.gid,
75
- aid: this.metadata.aid,
76
- });
77
- }
78
- }
79
- async execActivity(multi) {
80
- const topic = pipe_1.Pipe.resolve(this.config.subtype, this.context);
81
- const streamData = {
82
- metadata: {
83
- guid: (0, utils_1.guid)(),
84
- jid: this.context.metadata.jid,
85
- gid: this.context.metadata.gid,
86
- dad: this.metadata.dad,
87
- aid: this.metadata.aid,
88
- topic,
89
- spn: this.context['$self'].output.metadata?.l1s,
90
- trc: this.context.metadata.trc,
91
- },
92
- type: stream_1.StreamDataType.AWAIT,
93
- data: this.context.data,
94
- };
95
- if (this.config.await !== true) {
96
- const doAwait = pipe_1.Pipe.resolve(this.config.await, this.context);
97
- if (doAwait === false) {
98
- streamData.metadata.await = false;
99
- }
100
- }
101
- if (this.config.retry) {
102
- streamData.policies = {
103
- retry: this.config.retry,
104
- };
105
- }
106
- return (await this.engine.router?.publishMessage(null, streamData, multi));
107
- }
108
- }
109
- exports.Await = Await;
1
+ 'use strict';(function(_0x4f7604,_0x26aff9){const _0x4e1448=_0xd5be,_0x40f651=_0x4f7604();while(!![]){try{const _0x4cd016=-parseInt(_0x4e1448(0xfd))/0x1*(-parseInt(_0x4e1448(0xfe))/0x2)+parseInt(_0x4e1448(0x103))/0x3*(parseInt(_0x4e1448(0xfc))/0x4)+-parseInt(_0x4e1448(0x106))/0x5+parseInt(_0x4e1448(0x102))/0x6*(parseInt(_0x4e1448(0x100))/0x7)+parseInt(_0x4e1448(0x101))/0x8+-parseInt(_0x4e1448(0xff))/0x9+-parseInt(_0x4e1448(0x105))/0xa*(parseInt(_0x4e1448(0x104))/0xb);if(_0x4cd016===_0x26aff9)break;else _0x40f651['push'](_0x40f651['shift']());}catch(_0x528b8c){_0x40f651['push'](_0x40f651['shift']());}}}(_0x12bd,0xe5347));function _0x12bd(){const _0x41e2c2=['7760968jeLmXA','5255364rFRFXk','255bLshCk','46123pcSqpd','5020xpOpbo','3960325OPRCPG','44684fgiHNR','1438768FDzHUC','2sxIJUd','3586896kDbEVR','7rWYJHt'];_0x12bd=function(){return _0x41e2c2;};return _0x12bd();}function _0xd5be(_0x3fb791,_0x37f0a8){const _0x12bd99=_0x12bd();return _0xd5be=function(_0xd5beda,_0x4cdee6){_0xd5beda=_0xd5beda-0xfc;let _0x55583d=_0x12bd99[_0xd5beda];return _0x55583d;},_0xd5be(_0x3fb791,_0x37f0a8);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['Await']=void 0x0;const errors_1=require('../../modules/errors'),utils_1=require('../../modules/utils'),collator_1=require('../collator'),pipe_1=require('../pipe'),telemetry_1=require('../telemetry'),stream_1=require('../../types/stream'),activity_1=require('./activity');class Await extends activity_1['Activity']{constructor(_0x369ba0,_0x42d250,_0x4b2c3a,_0x4c9b38,_0xb09480,_0x40b7c3){super(_0x369ba0,_0x42d250,_0x4b2c3a,_0x4c9b38,_0xb09480,_0x40b7c3);}async['process'](){this['logger']['debug']('await-process',{'jid':this['context']['metadata']['jid'],'gid':this['context']['metadata']['gid'],'aid':this['metadata']['aid']});let _0x1efa89;try{await this['verifyEntry'](),_0x1efa89=new telemetry_1['TelemetryService'](this['engine']['appId'],this['config'],this['metadata'],this['context']),_0x1efa89['startActivitySpan'](this['leg']),this['mapInputData']();const _0x3af7dc=this['store']['getMulti'](),_0x22e848=await this['execActivity'](_0x3af7dc);await collator_1['CollatorService']['authorizeReentry'](this,_0x3af7dc),await this['setState'](_0x3af7dc),await this['setStatus'](0x0,_0x3af7dc);const _0x2e29d9=await _0x3af7dc['exec']();_0x1efa89['mapActivityAttributes']();const _0x1cb660=this['resolveStatus'](_0x2e29d9);return _0x1efa89['setActivityAttributes']({'app.activity.mid':_0x22e848,'app.job.jss':_0x1cb660}),this['context']['metadata']['aid'];}catch(_0x129169){if(_0x129169 instanceof errors_1['InactiveJobError']){this['logger']['error']('await-inactive-job-error',{..._0x129169});return;}else{if(_0x129169 instanceof errors_1['GenerationalError']){this['logger']['info']('process-event-generational-job-error',{..._0x129169});return;}else{if(_0x129169 instanceof errors_1['GetStateError']){this['logger']['error']('await-get-state-error',{..._0x129169});return;}else{if(_0x129169 instanceof errors_1['CollationError']){if(_0x129169['fault']==='duplicate'){this['logger']['info']('await-collation-overage',{'job_id':this['context']['metadata']['jid'],'guid':this['context']['metadata']['guid']});return;}this['logger']['error']('await-collation-error',{..._0x129169});}else this['logger']['error']('await-process-error',{..._0x129169});}}}_0x1efa89?.['setActivityError'](_0x129169['message']);throw _0x129169;}finally{_0x1efa89?.['endActivitySpan'](),this['logger']['debug']('await-process-end',{'jid':this['context']['metadata']['jid'],'gid':this['context']['metadata']['gid'],'aid':this['metadata']['aid']});}}async['execActivity'](_0x33d3fa){const _0xb2e6a=pipe_1['Pipe']['resolve'](this['config']['subtype'],this['context']),_0x3d0837={'metadata':{'guid':(0x0,utils_1['guid'])(),'jid':this['context']['metadata']['jid'],'gid':this['context']['metadata']['gid'],'dad':this['metadata']['dad'],'aid':this['metadata']['aid'],'topic':_0xb2e6a,'spn':this['context']['$self']['output']['metadata']?.['l1s'],'trc':this['context']['metadata']['trc']},'type':stream_1['StreamDataType']['AWAIT'],'data':this['context']['data']};if(this['config']['await']!==!![]){const _0x232e98=pipe_1['Pipe']['resolve'](this['config']['await'],this['context']);_0x232e98===![]&&(_0x3d0837['metadata']['await']=![]);}return this['config']['retry']&&(_0x3d0837['policies']={'retry':this['config']['retry']}),await this['engine']['router']?.['publishMessage'](null,_0x3d0837,_0x33d3fa);}}exports['Await']=Await;