@hotmeshio/hotmesh 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.ts +6 -4
- package/build/index.js +13 -5
- package/build/modules/key.js +1 -62
- package/build/modules/utils.d.ts +1 -0
- package/build/modules/utils.js +1 -242
- package/build/package.json +14 -9
- package/build/services/activities/activity.js +1 -495
- package/build/services/activities/await.js +1 -109
- package/build/services/activities/cycle.js +1 -96
- package/build/services/activities/hook.js +1 -154
- package/build/services/activities/index.js +1 -20
- package/build/services/activities/interrupt.js +1 -149
- package/build/services/activities/signal.js +1 -118
- package/build/services/activities/trigger.d.ts +0 -1
- package/build/services/activities/trigger.js +1 -269
- package/build/services/activities/worker.js +1 -101
- package/build/services/collator/index.js +1 -197
- package/build/services/compiler/deployer.d.ts +3 -1
- package/build/services/compiler/deployer.js +1 -455
- package/build/services/compiler/index.d.ts +3 -1
- package/build/services/compiler/index.js +1 -91
- package/build/services/compiler/validator.js +1 -122
- package/build/services/engine/index.d.ts +5 -2
- package/build/services/engine/index.js +1 -583
- package/build/services/exporter/index.js +1 -93
- package/build/services/mapper/index.js +1 -67
- package/build/services/meshdata/index.d.ts +0 -1
- package/build/services/meshdata/index.js +16 -24
- package/build/services/meshflow/client.js +4 -8
- package/build/services/meshflow/exporter.js +1 -186
- package/build/services/meshflow/search.d.ts +4 -5
- package/build/services/meshflow/search.js +48 -36
- package/build/services/meshflow/worker.js +1 -1
- package/build/services/meshflow/workflow.d.ts +1 -1
- package/build/services/meshflow/workflow.js +5 -30
- package/build/services/meshos/index.d.ts +81 -0
- package/build/services/meshos/index.js +339 -0
- package/build/services/pipe/functions/array.js +1 -74
- package/build/services/pipe/functions/bitwise.js +1 -24
- package/build/services/pipe/functions/conditional.js +1 -36
- package/build/services/pipe/functions/cron.js +1 -32
- package/build/services/pipe/functions/date.js +1 -164
- package/build/services/pipe/functions/index.js +1 -30
- package/build/services/pipe/functions/json.js +1 -12
- package/build/services/pipe/functions/logical.js +1 -12
- package/build/services/pipe/functions/math.js +1 -182
- package/build/services/pipe/functions/number.js +1 -60
- package/build/services/pipe/functions/object.js +1 -81
- package/build/services/pipe/functions/string.js +1 -69
- package/build/services/pipe/functions/symbol.js +1 -33
- package/build/services/pipe/functions/unary.js +1 -18
- package/build/services/pipe/index.js +1 -221
- package/build/services/quorum/index.d.ts +1 -1
- package/build/services/quorum/index.js +1 -233
- package/build/services/reporter/index.js +1 -331
- package/build/services/router/index.js +1 -420
- package/build/services/search/factory.d.ts +7 -0
- package/build/services/search/factory.js +20 -0
- package/build/services/search/index.d.ts +21 -0
- package/build/services/search/index.js +10 -0
- package/build/services/search/providers/redis/ioredis.d.ts +18 -0
- package/build/services/search/providers/redis/ioredis.js +1 -0
- package/build/services/search/providers/redis/redis.d.ts +18 -0
- package/build/services/search/providers/redis/redis.js +1 -0
- package/build/services/serializer/index.js +1 -265
- package/build/services/store/factory.d.ts +8 -0
- package/build/services/store/factory.js +20 -0
- package/build/services/store/index.d.ts +71 -98
- package/build/services/store/index.js +2 -941
- package/build/services/store/providers/postgres/postgres.d.ts +0 -0
- package/build/services/store/providers/postgres/postgres.js +0 -0
- package/build/services/store/providers/postgres/types/hash.d.ts +0 -0
- package/build/services/store/providers/postgres/types/hash.js +0 -0
- package/build/services/store/providers/postgres/types/list.d.ts +0 -0
- package/build/services/store/providers/postgres/types/list.js +0 -0
- package/build/services/store/providers/postgres/types/string.d.ts +0 -0
- package/build/services/store/providers/postgres/types/string.js +0 -0
- package/build/services/store/providers/postgres/types/zset.d.ts +0 -0
- package/build/services/store/providers/postgres/types/zset.js +0 -0
- package/build/services/store/providers/redis/_base.d.ts +98 -0
- package/build/services/store/providers/redis/_base.js +1 -0
- package/build/services/store/providers/redis/ioredis.d.ts +12 -0
- package/build/services/store/providers/redis/ioredis.js +1 -0
- package/build/services/store/providers/redis/redis.d.ts +13 -0
- package/build/services/store/providers/redis/redis.js +1 -0
- package/build/services/store/providers/store-initializable.d.ts +5 -0
- package/build/services/store/providers/store-initializable.js +1 -0
- package/build/services/stream/factory.d.ts +8 -0
- package/build/services/stream/factory.js +20 -0
- package/build/services/stream/index.d.ts +13 -14
- package/build/services/stream/index.js +3 -2
- package/build/services/stream/providers/postgres/_deploy.d.ts +4 -0
- package/build/services/stream/providers/postgres/_deploy.js +1 -0
- package/build/services/stream/providers/redis/ioredis.d.ts +21 -0
- package/build/services/stream/providers/redis/ioredis.js +1 -0
- package/build/services/stream/providers/redis/redis.d.ts +21 -0
- package/build/services/stream/providers/redis/redis.js +1 -0
- package/build/services/stream/providers/stream-initializable.d.ts +5 -0
- package/build/services/stream/providers/stream-initializable.js +1 -0
- package/build/services/sub/factory.d.ts +7 -0
- package/build/services/sub/factory.js +20 -0
- package/build/services/sub/index.d.ts +9 -7
- package/build/services/sub/index.js +3 -2
- package/build/services/sub/{clients → providers/redis}/ioredis.d.ts +7 -10
- package/build/services/sub/providers/redis/ioredis.js +1 -0
- package/build/services/sub/{clients → providers/redis}/redis.d.ts +7 -10
- package/build/services/sub/providers/redis/redis.js +1 -0
- package/build/services/task/index.js +1 -171
- package/build/services/telemetry/index.js +1 -225
- package/build/services/worker/index.d.ts +2 -2
- package/build/services/worker/index.js +1 -179
- package/build/types/index.d.ts +1 -0
- package/build/types/manifest.d.ts +49 -0
- package/build/types/manifest.js +2 -0
- package/build/types/redis.d.ts +5 -5
- package/index.ts +19 -4
- package/package.json +14 -9
- package/typedoc.json +1 -0
- package/types/index.ts +15 -0
- package/types/manifest.ts +68 -0
- package/types/meshflow.ts +1 -1
- package/types/redis.ts +5 -5
- package/build/services/store/clients/ioredis.d.ts +0 -30
- package/build/services/store/clients/ioredis.js +0 -220
- package/build/services/store/clients/redis.d.ts +0 -32
- package/build/services/store/clients/redis.js +0 -319
- package/build/services/stream/clients/ioredis.d.ts +0 -24
- package/build/services/stream/clients/ioredis.js +0 -121
- package/build/services/stream/clients/redis.d.ts +0 -24
- package/build/services/stream/clients/redis.js +0 -161
- package/build/services/sub/clients/ioredis.js +0 -72
- 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(_0x1b9e1b,_0x71cd11){const _0x3f3abe=_0x39eb,_0xa04d1b=_0x1b9e1b();while(!![]){try{const _0xc6d91c=-parseInt(_0x3f3abe(0x158))/0x1+parseInt(_0x3f3abe(0x154))/0x2+parseInt(_0x3f3abe(0x151))/0x3*(-parseInt(_0x3f3abe(0x156))/0x4)+parseInt(_0x3f3abe(0x14f))/0x5*(-parseInt(_0x3f3abe(0x157))/0x6)+parseInt(_0x3f3abe(0x153))/0x7+parseInt(_0x3f3abe(0x150))/0x8*(parseInt(_0x3f3abe(0x155))/0x9)+parseInt(_0x3f3abe(0x152))/0xa;if(_0xc6d91c===_0x71cd11)break;else _0xa04d1b['push'](_0xa04d1b['shift']());}catch(_0x37757f){_0xa04d1b['push'](_0xa04d1b['shift']());}}}(_0xcac2,0x81243));function _0xcac2(){const _0x29a422=['4845282akJmhD','570209pQFXsh','5NHnlIb','521408UxbdYw','193278bbadiz','14604540XxnZos','5030319LZCJzJ','605964CHivrx','54EArHIW','60WnrGtb'];_0xcac2=function(){return _0x29a422;};return _0xcac2();}function _0x39eb(_0x1b2e8c,_0x526ca3){const _0xcac264=_0xcac2();return _0x39eb=function(_0x39ebce,_0x5c1539){_0x39ebce=_0x39ebce-0x14f;let _0x2d206f=_0xcac264[_0x39ebce];return _0x2d206f;},_0x39eb(_0x1b2e8c,_0x526ca3);}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');class Activity{constructor(_0x365dfa,_0x197c95,_0x3c0a67,_0x20ee92,_0x54bf8a,_0x166e10){this['status']=stream_1['StreamStatus']['SUCCESS'],this['code']=0xc8,this['adjacentIndex']=0x0,this['config']=_0x365dfa,this['data']=_0x197c95,this['metadata']=_0x3c0a67,this['hook']=_0x20ee92,this['engine']=_0x54bf8a,this['context']=_0x166e10||{'data':{},'metadata':{}},this['logger']=_0x54bf8a['logger'],this['store']=_0x54bf8a['store'];}['setLeg'](_0x240275){this['leg']=_0x240275;}['mapStatusThreshold'](){if(this['config']['statusThreshold']!==undefined){const _0x218a6b=pipe_1['Pipe']['resolve'](this['config']['statusThreshold'],this['context']);if(_0x218a6b!==undefined&&!isNaN(Number(_0x218a6b)))return _0x218a6b;}return 0x0;}async['verifyEntry'](){this['setLeg'](0x1),await this['getState']();const _0x282a43=this['mapStatusThreshold']();try{collator_1['CollatorService']['assertJobActive'](this['context']['metadata']['js'],this['context']['metadata']['jid'],this['metadata']['aid'],_0x282a43);}catch(_0x53d073){await collator_1['CollatorService']['notarizeEntry'](this);if(_0x282a43>0x0){if(this['context']['metadata']['js']===_0x282a43){const _0x52cf53=await this['setStatus'](-_0x282a43);Number(_0x52cf53)===0x0&&await this['engine']['runJobCompletionTasks'](this['context']);}}else throw _0x53d073;return;}await collator_1['CollatorService']['notarizeEntry'](this);}async['verifyReentry'](){const _0x1d44c4=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,_0x1d44c4);}async['processEvent'](_0x4818a0=stream_1['StreamStatus']['SUCCESS'],_0x459aa2=0xc8,_0x508a0d='output'){this['setLeg'](0x2);const _0x3e8911=this['context']['metadata']['jid'];if(!_0x3e8911){this['logger']['error']('activity-process-event-error',{'message':'job\x20id\x20is\x20undefined'});return;}const _0x1b54dc=this['metadata']['aid'];this['status']=_0x4818a0,this['code']=_0x459aa2,this['logger']['debug']('activity-process-event',{'topic':this['config']['subtype'],'jid':_0x3e8911,'aid':_0x1b54dc,'status':_0x4818a0,'code':_0x459aa2});let _0x1e595f;try{const _0x3b8168=await this['verifyReentry']();this['adjacentIndex']=collator_1['CollatorService']['getDimensionalIndex'](_0x3b8168),_0x1e595f=new telemetry_1['TelemetryService'](this['engine']['appId'],this['config'],this['metadata'],this['context']),_0x1e595f['startActivitySpan'](this['leg']);let _0x4b13e1;if(_0x4818a0===stream_1['StreamStatus']['PENDING'])_0x4b13e1=await this['processPending'](_0x508a0d);else _0x4818a0===stream_1['StreamStatus']['SUCCESS']?_0x4b13e1=await this['processSuccess'](_0x508a0d):_0x4b13e1=await this['processError']();this['transitionAdjacent'](_0x4b13e1,_0x1e595f);}catch(_0x28d7c0){if(_0x28d7c0 instanceof errors_1['CollationError']){this['logger']['info']('process-event-'+_0x28d7c0['fault']+'-error',{..._0x28d7c0});return;}else{if(_0x28d7c0 instanceof errors_1['InactiveJobError']){this['logger']['info']('process-event-inactive-job-error',{..._0x28d7c0});return;}else{if(_0x28d7c0 instanceof errors_1['GenerationalError']){this['logger']['info']('process-event-generational-job-error',{..._0x28d7c0});return;}else{if(_0x28d7c0 instanceof errors_1['GetStateError']){this['logger']['info']('process-event-get-job-error',{..._0x28d7c0});return;}}}}this['logger']['error']('activity-process-event-error',{..._0x28d7c0,'message':_0x28d7c0['message'],'stack':_0x28d7c0['stack'],'name':_0x28d7c0['name']}),_0x1e595f?.['setActivityError'](_0x28d7c0['message']);throw _0x28d7c0;}finally{_0x1e595f?.['endActivitySpan'](),this['logger']['debug']('activity-process-event-end',{'jid':_0x3e8911,'aid':_0x1b54dc});}}async['processPending'](_0x3ac167){this['bindActivityData'](_0x3ac167),this['adjacencyList']=await this['filterAdjacent'](),this['mapJobData']();const _0x2b8800=this['store']['getMulti']();return await this['setState'](_0x2b8800),await collator_1['CollatorService']['notarizeContinuation'](this,_0x2b8800),await this['setStatus'](this['adjacencyList']['length'],_0x2b8800),await _0x2b8800['exec']();}async['processSuccess'](_0x3ee31d){this['bindActivityData'](_0x3ee31d),this['adjacencyList']=await this['filterAdjacent'](),this['mapJobData']();const _0x3860ee=this['store']['getMulti']();return await this['setState'](_0x3860ee),await collator_1['CollatorService']['notarizeCompletion'](this,_0x3860ee),await this['setStatus'](this['adjacencyList']['length']-0x1,_0x3860ee),await _0x3860ee['exec']();}async['processError'](){this['bindActivityError'](this['data']),this['adjacencyList']=await this['filterAdjacent']();!this['adjacencyList']['length']&&this['bindJobError'](this['data']);this['mapJobData']();const _0x370e2b=this['store']['getMulti']();return await this['setState'](_0x370e2b),await collator_1['CollatorService']['notarizeCompletion'](this,_0x370e2b),await this['setStatus'](this['adjacencyList']['length']-0x1,_0x370e2b),await _0x370e2b['exec']();}async['transitionAdjacent'](_0x20f76b,_0x5dc578){_0x5dc578['mapActivityAttributes']();const _0x85563d=this['resolveStatus'](_0x20f76b),_0x58a19a={'app.job.jss':_0x85563d},_0x4edf25=await this['transition'](this['adjacencyList'],_0x85563d);_0x4edf25?.['length']&&(_0x58a19a['app.activity.mids']=_0x4edf25['join'](',')),_0x5dc578['setActivityAttributes'](_0x58a19a);}['resolveStatus'](_0x6f639f){const _0x3b03b4=_0x6f639f[_0x6f639f['length']-0x1];return Array['isArray'](_0x3b03b4)?Number(_0x3b03b4[0x1]):Number(_0x3b03b4);}['mapJobData'](){if(this['config']['job']?.['maps']){const _0xf29065=new mapper_1['MapperService']((0x0,utils_1['deepCopy'])(this['config']['job']['maps']),this['context']),_0x126d0d=_0xf29065['mapRules']();if(_0x126d0d)for(const _0x2a64f4 in _0x126d0d){const _0x4fb722=_0x2a64f4['indexOf']('[');if(_0x4fb722>-0x1){const _0x139b3c=_0x2a64f4['substring'](_0x4fb722+0x1)['split'](']')[0x0];if(!isNaN(Number(_0x139b3c))){const _0x200857=_0x2a64f4['substring'](0x0,_0x4fb722);_0x126d0d[_0x200857]=_0x126d0d[_0x2a64f4],delete _0x126d0d[_0x2a64f4];}else{if(_0x139b3c==='-'||_0x139b3c==='_'){const _0x5b2099=_0x126d0d[_0x2a64f4];Object['keys'](_0x5b2099)['forEach'](_0x1f2ae0=>{_0x126d0d[_0x1f2ae0]=_0x5b2099[_0x1f2ae0];});}}}}this['context']['data']=_0x126d0d;}}['mapInputData'](){if(this['config']['input']?.['maps']){const _0x221d79=new mapper_1['MapperService']((0x0,utils_1['deepCopy'])(this['config']['input']['maps']),this['context']);this['context']['data']=_0x221d79['mapRules']();}}['mapOutputData'](){if(this['config']['output']?.['maps']){const _0x30e8e0=new mapper_1['MapperService']((0x0,utils_1['deepCopy'])(this['config']['output']['maps']),this['context']),_0x728ce3=_0x30e8e0['mapRules'](),_0x547d99=this['metadata']['aid'],_0x1bea8e={...this['context'][_0x547d99]['output'],..._0x728ce3};this['context'][_0x547d99]['output']['data']=_0x1bea8e;}}async['registerTimeout'](){}['bindActivityError'](_0x3460a8){const _0x119186=this['context'][this['metadata']['aid']]['output']['metadata'];_0x119186['err']=JSON['stringify'](this['data']),_0x119186['$error']={..._0x3460a8,'is_stream_error':!![]};}['bindJobError'](_0x37a417){this['context']['metadata']['err']=JSON['stringify']({..._0x37a417,'is_stream_error':!![]});}async['getTriggerConfig'](){return await this['store']['getSchema'](this['config']['trigger'],await this['engine']['getVID']());}['getJobStatus'](){return null;}async['setStatus'](_0x37967e,_0x39908e){const {id:_0x281596}=await this['engine']['getVID']();return await this['store']['setStatus'](_0x37967e,this['context']['metadata']['jid'],_0x281596,_0x39908e);}['authorizeEntry'](_0x481404){return this['adjacencyList']?.['map'](_0x55cde8=>{const {metadata:{aid:_0x5dda7b}}=_0x55cde8;return _0x481404[_0x5dda7b+'/output/metadata/as']=collator_1['CollatorService']['getSeed'](),_0x5dda7b;})??[];}['bindDimensionalAddress'](_0x16d821){const _0xcd1d53=this['resolveDad']();_0x16d821[this['metadata']['aid']+'/output/metadata/dad']=_0xcd1d53;}async['setState'](_0xca9806){const _0x48bbc1=this['context']['metadata']['jid'];this['bindJobMetadata'](),this['bindActivityMetadata']();const _0x71aaff={};await this['bindJobState'](_0x71aaff);const _0xdfae18=this['authorizeEntry'](_0x71aaff);this['bindDimensionalAddress'](_0x71aaff),this['bindActivityState'](_0x71aaff);const _0xa11722=['$'+this['config']['subscribes'],this['metadata']['aid'],..._0xdfae18],_0x58a4e2=collator_1['CollatorService']['getDimensionsById']([...this['config']['ancestors'],this['metadata']['aid']],this['resolveDad']());return await this['store']['setState'](_0x71aaff,this['getJobStatus'](),_0x48bbc1,_0xa11722,_0x58a4e2,_0xca9806);}['bindJobMetadata'](){this['context']['metadata']['ju']=(0x0,utils_1['formatISODate'])(new Date());}['bindActivityMetadata'](){const _0x456e75=this['context']['$self'];!_0x456e75['output']['metadata']&&(_0x456e75['output']['metadata']={});this['status']===stream_1['StreamStatus']['ERROR']&&(_0x456e75['output']['metadata']['err']=JSON['stringify'](this['data']));const _0x338f54=(0x0,utils_1['formatISODate'])(new Date());_0x456e75['output']['metadata']['ac']=_0x338f54,_0x456e75['output']['metadata']['au']=_0x338f54,_0x456e75['output']['metadata']['atp']=this['config']['type'],this['config']['subtype']&&(_0x456e75['output']['metadata']['stp']=this['config']['subtype']),_0x456e75['output']['metadata']['aid']=this['metadata']['aid'];}async['bindJobState'](_0x215d2c){const _0x17e0f5=await this['getTriggerConfig'](),_0x429df7=[..._0x17e0f5['PRODUCES']||[],...this['bindJobMetadataPaths']()];for(const _0x1fcd7a of _0x429df7){const _0x30dbbc=(0x0,utils_1['getValueByPath'])(this['context'],_0x1fcd7a);_0x30dbbc!==undefined&&(_0x215d2c[_0x1fcd7a]=_0x30dbbc);}for(const _0x575daf in this['context']?.['data']??{}){(_0x575daf['startsWith']('-')||_0x575daf['startsWith']('_'))&&(_0x215d2c[_0x575daf]=this['context']['data'][_0x575daf]);}telemetry_1['TelemetryService']['bindJobTelemetryToState'](_0x215d2c,this['config'],this['context']);}['bindActivityState'](_0x1a419f){const _0x11df47=[...this['config']['produces'],...this['bindActivityMetadataPaths']()];for(const _0x5558a1 of _0x11df47){const _0x4edb0d=this['metadata']['aid']+'/'+_0x5558a1,_0x469fbf=(0x0,utils_1['getValueByPath'])(this['context'],_0x4edb0d);_0x469fbf!==undefined&&(_0x1a419f[_0x4edb0d]=_0x469fbf);}telemetry_1['TelemetryService']['bindActivityTelemetryToState'](_0x1a419f,this['config'],this['metadata'],this['context'],this['leg']);}['bindJobMetadataPaths'](){return serializer_1['MDATA_SYMBOLS']['JOB_UPDATE']['KEYS']['map'](_0x3d50dc=>'metadata/'+_0x3d50dc);}['bindActivityMetadataPaths'](){const _0x7c4ab0=this['leg']===0x1?'ACTIVITY':'ACTIVITY_UPDATE';return serializer_1['MDATA_SYMBOLS'][_0x7c4ab0]['KEYS']['map'](_0x318b82=>'output/metadata/'+_0x318b82);}async['getState'](){const _0x6176cc=this['context']['metadata']['gid'],_0x6ee70d='$'+this['config']['subscribes'],_0x27dcdf={[_0x6ee70d]:serializer_1['MDATA_SYMBOLS']['JOB']['KEYS']['map'](_0x29f3f2=>'metadata/'+_0x29f3f2)};for(let [_0x29ce3d,_0x29483b]of Object['entries'](this['config']['consumes'])){if(_0x29ce3d==='$job')for(const _0x53771e of _0x29483b){_0x27dcdf[_0x6ee70d]['push'](_0x53771e);}else{_0x29ce3d==='$self'&&(_0x29ce3d=this['metadata']['aid']);!_0x27dcdf[_0x29ce3d]&&(_0x27dcdf[_0x29ce3d]=[]);for(const _0x3a1452 of _0x29483b){_0x27dcdf[_0x29ce3d]['push'](_0x29ce3d+'/'+_0x3a1452);}}}telemetry_1['TelemetryService']['addTargetTelemetryPaths'](_0x27dcdf,this['config'],this['metadata'],this['leg']);const {dad:_0x8fab60,jid:_0x1bce64}=this['context']['metadata'],_0x5a7e68=collator_1['CollatorService']['getDimensionsById']([...this['config']['ancestors'],this['metadata']['aid']],_0x8fab60||''),[_0x45dee7,_0x52178d]=await this['store']['getState'](_0x1bce64,_0x27dcdf,_0x5a7e68);this['context']=(0x0,utils_1['restoreHierarchy'])(_0x45dee7),this['assertGenerationalId'](this['context']?.['metadata']?.['gid'],_0x6176cc),this['initDimensionalAddress'](_0x8fab60),this['initSelf'](this['context']),this['initPolicies'](this['context']);}['assertGenerationalId'](_0x29c8e1,_0x353e44){if(_0x353e44!==_0x29c8e1)throw new errors_1['GenerationalError'](_0x29c8e1,_0x353e44,this['context']?.['metadata']?.['jid']??'',this['context']?.['metadata']?.['aid']??'',this['context']?.['metadata']?.['dad']??'');}['initDimensionalAddress'](_0x19054c){this['metadata']['dad']=_0x19054c;}['initSelf'](_0x3902e9){const _0xc1aa97=this['metadata']['aid'];!_0x3902e9[_0xc1aa97]&&(_0x3902e9[_0xc1aa97]={});const _0x4cc875=_0x3902e9[_0xc1aa97];return!_0x4cc875['output']&&(_0x4cc875['output']={}),!_0x4cc875['input']&&(_0x4cc875['input']={}),!_0x4cc875['hook']&&(_0x4cc875['hook']={}),!_0x4cc875['output']['metadata']&&(_0x4cc875['output']['metadata']={}),_0x4cc875['output']['metadata']['au']=(0x0,utils_1['formatISODate'])(new Date()),_0x3902e9['$self']=_0x4cc875,_0x3902e9['$job']=_0x3902e9,_0x3902e9;}['initPolicies'](_0x3504c2){const _0x9caf56=pipe_1['Pipe']['resolve'](this['config']['expire']??enums_1['HMSH_EXPIRE_DURATION'],_0x3504c2);_0x3504c2['metadata']['expire']=_0x9caf56;if(this['config']['persistent']!=undefined){const _0x3b831d=pipe_1['Pipe']['resolve'](this['config']['persistent']??![],_0x3504c2);_0x3504c2['metadata']['persistent']=_0x3b831d;}}['bindActivityData'](_0x50e770){this['context'][this['metadata']['aid']][_0x50e770]['data']=this['data'];}['resolveDad'](){let _0xd2c403=this['metadata']['dad'];return this['adjacentIndex']>0x0&&(_0xd2c403=_0xd2c403['substring'](0x0,_0xd2c403['lastIndexOf'](','))+','+this['adjacentIndex']),_0xd2c403;}['resolveAdjacentDad'](){return''+this['resolveDad']()+collator_1['CollatorService']['getDimensionalSeed'](0x0);}async['filterAdjacent'](){const _0x4cdc7c=[],_0x19e15d=await this['store']['getTransitions'](await this['engine']['getVID']()),_0x3fed6f=_0x19e15d['.'+this['metadata']['aid']],_0x1e5bde=this['resolveAdjacentDad']();if(_0x3fed6f)for(const _0x323433 in _0x3fed6f){const _0x433650=_0x3fed6f[_0x323433];mapper_1['MapperService']['evaluate'](_0x433650,this['context'],this['code'])&&_0x4cdc7c['push']({'metadata':{'guid':(0x0,utils_1['guid'])(),'jid':this['context']['metadata']['jid'],'gid':this['context']['metadata']['gid'],'dad':_0x1e5bde,'aid':_0x323433,'spn':this['context']['$self']['output']['metadata']?.['l2s'],'trc':this['context']['metadata']['trc']},'type':stream_1['StreamDataType']['TRANSITION'],'data':{}});}return _0x4cdc7c;}['isJobComplete'](_0x3a46b2){return _0x3a46b2<=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'](_0x247202,_0x1e1261){if(this['jobWasInterrupted'](_0x1e1261))return;let _0x34948e=[];(this['shouldEmit']()||this['isJobComplete'](_0x1e1261)||this['shouldPersistJob']())&&await this['engine']['runJobCompletionTasks'](this['context'],{'emit':!this['isJobComplete'](_0x1e1261)&&!this['shouldPersistJob']()});if(_0x247202['length']&&!this['isJobComplete'](_0x1e1261)){const _0x5533db=this['store']['getMulti']();for(const _0x263d12 of _0x247202){await this['engine']['router']?.['publishMessage'](null,_0x263d12,_0x5533db);}_0x34948e=await _0x5533db['exec']();}return _0x34948e;}['jobWasInterrupted'](_0x474e38){return _0x474e38<-0x5f5e100;}}exports['Activity']=Activity;
|
|
@@ -1,109 +1 @@
|
|
|
1
|
-
|
|
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(_0x2f86e1,_0x3b8ee7){const _0x182a49=_0x3da1,_0x4f1813=_0x2f86e1();while(!![]){try{const _0xfbfdc=-parseInt(_0x182a49(0x100))/0x1*(-parseInt(_0x182a49(0xf9))/0x2)+-parseInt(_0x182a49(0x103))/0x3*(-parseInt(_0x182a49(0xfb))/0x4)+parseInt(_0x182a49(0xfc))/0x5*(parseInt(_0x182a49(0x101))/0x6)+-parseInt(_0x182a49(0xfa))/0x7+parseInt(_0x182a49(0xfd))/0x8*(parseInt(_0x182a49(0xff))/0x9)+-parseInt(_0x182a49(0xfe))/0xa*(-parseInt(_0x182a49(0x102))/0xb)+-parseInt(_0x182a49(0xf8))/0xc;if(_0xfbfdc===_0x3b8ee7)break;else _0x4f1813['push'](_0x4f1813['shift']());}catch(_0x16f372){_0x4f1813['push'](_0x4f1813['shift']());}}}(_0x47c6,0xf0cdb));function _0x3da1(_0x20e79d,_0x370993){const _0x47c6e5=_0x47c6();return _0x3da1=function(_0x3da1a1,_0x1dda57){_0x3da1a1=_0x3da1a1-0xf8;let _0x3800cf=_0x47c6e5[_0x3da1a1];return _0x3800cf;},_0x3da1(_0x20e79d,_0x370993);}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');function _0x47c6(){const _0x5ef32e=['17476452KtjOrK','3338wyChXK','12604410ZtcWLv','2154968UCabdt','50BtPYyA','328AAcTLF','18606030AOxVpA','180909DWsJMZ','226Taqejx','62346yyfRuI','11XvetXY','6LMCFsD'];_0x47c6=function(){return _0x5ef32e;};return _0x47c6();}class Await extends activity_1['Activity']{constructor(_0x13be64,_0x5380f2,_0x32d9b2,_0x9ebe40,_0x4b2d7c,_0x540c62){super(_0x13be64,_0x5380f2,_0x32d9b2,_0x9ebe40,_0x4b2d7c,_0x540c62);}async['process'](){this['logger']['debug']('await-process',{'jid':this['context']['metadata']['jid'],'gid':this['context']['metadata']['gid'],'aid':this['metadata']['aid']});let _0x150d57;try{await this['verifyEntry'](),_0x150d57=new telemetry_1['TelemetryService'](this['engine']['appId'],this['config'],this['metadata'],this['context']),_0x150d57['startActivitySpan'](this['leg']),this['mapInputData']();const _0x4271e3=this['store']['getMulti'](),_0xbd2061=await this['execActivity'](_0x4271e3);await collator_1['CollatorService']['authorizeReentry'](this,_0x4271e3),await this['setState'](_0x4271e3),await this['setStatus'](0x0,_0x4271e3);const _0x47f20e=await _0x4271e3['exec']();_0x150d57['mapActivityAttributes']();const _0x1fde38=this['resolveStatus'](_0x47f20e);return _0x150d57['setActivityAttributes']({'app.activity.mid':_0xbd2061,'app.job.jss':_0x1fde38}),this['context']['metadata']['aid'];}catch(_0x38b8c0){if(_0x38b8c0 instanceof errors_1['InactiveJobError']){this['logger']['error']('await-inactive-job-error',{..._0x38b8c0});return;}else{if(_0x38b8c0 instanceof errors_1['GenerationalError']){this['logger']['info']('process-event-generational-job-error',{..._0x38b8c0});return;}else{if(_0x38b8c0 instanceof errors_1['GetStateError']){this['logger']['error']('await-get-state-error',{..._0x38b8c0});return;}else{if(_0x38b8c0 instanceof errors_1['CollationError']){if(_0x38b8c0['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',{..._0x38b8c0});}else this['logger']['error']('await-process-error',{..._0x38b8c0});}}}_0x150d57?.['setActivityError'](_0x38b8c0['message']);throw _0x38b8c0;}finally{_0x150d57?.['endActivitySpan'](),this['logger']['debug']('await-process-end',{'jid':this['context']['metadata']['jid'],'gid':this['context']['metadata']['gid'],'aid':this['metadata']['aid']});}}async['execActivity'](_0xff2593){const _0x38608e=pipe_1['Pipe']['resolve'](this['config']['subtype'],this['context']),_0x473e22={'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':_0x38608e,'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 _0xa5975f=pipe_1['Pipe']['resolve'](this['config']['await'],this['context']);_0xa5975f===![]&&(_0x473e22['metadata']['await']=![]);}return this['config']['retry']&&(_0x473e22['policies']={'retry':this['config']['retry']}),await this['engine']['router']?.['publishMessage'](null,_0x473e22,_0xff2593);}}exports['Await']=Await;
|