@izara_project/izara-core-generate-service-code 1.0.74 → 1.0.75
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/package.json +1 -1
- package/src/emit/crud/emitCrudApplicationArtifacts.js +2 -2
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +43 -2
- package/src/emit/crud/templates/CreateComplete_HdrSqs.ejs +99 -0
- package/src/emit/crud/templates/CreateComplete_Main.ejs +188 -0
- package/src/emit/crud/templates/DeleteComplete_HdrSqs.ejs +99 -0
- package/src/emit/crud/templates/DeleteComplete_Main.ejs +188 -0
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateComplete_HdrSqs.ejs +99 -0
- package/src/emit/crud/templates/UpdateComplete_Main.ejs +188 -0
- package/src/emit/custom/customFlows.js +15 -1
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +2 -0
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +1 -1
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +21 -1
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +1 -1
- package/src/emit/relationship/templates/ChangeRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +91 -87
- package/src/emit/relationship/templates/CreateRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +90 -86
- package/src/emit/relationship/templates/DeleteRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +85 -81
- package/src/emit/relationship/templates/GetRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +2 -0
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +2 -20
- package/src/emit/relationship/templates/MoveRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +93 -89
- package/src/emit/relationship/templates/UpdateRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +85 -81
- package/src/emit/resource/emitResourceArtifacts.js +23 -0
- package/src/emit/shared/templates/FindData_Main.ejs +1 -1
- package/src/emit/system/emitSystemWebSocketArtifacts.js +54 -2
- package/src/emit/system/templates/RegisterComplete_HdrSqs.ejs +64 -0
- package/src/emit/system/templates/RegisterComplete_Main.ejs +154 -0
- package/src/emit/system/templates/RegisterComplete_Yaml.ejs +17 -0
- package/src/emit/system/templates/RegisterWbs_Yaml.ejs +7 -0
- package/src/emit/system/templates/Register_HdrWbs.ejs +56 -0
- package/src/emit/system/templates/Register_Main.ejs +148 -0
- package/test/customFlowApplicationArtifacts.test.js +16 -5
- package/test/publicApi.test.js +21 -0
- package/test/relationshipApplicationArtifacts.test.js +1 -1
- package/test/resourceArtifacts.test.js +20 -0
|
@@ -19,7 +19,7 @@ import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
|
19
19
|
|
|
20
20
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
21
21
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
24
24
|
|
|
25
25
|
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
@@ -42,6 +42,7 @@ export default async function deleteRelationshipComplete(
|
|
|
42
42
|
try {
|
|
43
43
|
const {
|
|
44
44
|
returnValue,
|
|
45
|
+
parentFlowId,
|
|
45
46
|
status,
|
|
46
47
|
errorsFound,
|
|
47
48
|
graphServiceTag
|
|
@@ -49,100 +50,103 @@ export default async function deleteRelationshipComplete(
|
|
|
49
50
|
|
|
50
51
|
_izContext.logger.debug('Function:deleteRelationshipComplete', {
|
|
51
52
|
returnValue: returnValue,
|
|
53
|
+
parentFlowId: parentFlowId,
|
|
52
54
|
status: status,
|
|
53
55
|
errorsFound: errorsFound,
|
|
54
56
|
graphServiceTag: graphServiceTag,
|
|
55
57
|
passBackProperties: passBackProperties
|
|
56
58
|
});
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
returnValue
|
|
60
|
+
const awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
61
|
+
parentFlowId || returnValue?.parentFlowId, // hash id
|
|
60
62
|
PREFIX.deleteRel // prefix, use constant further
|
|
61
63
|
);
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const pending =
|
|
66
|
+
await asyncFlowSharedLib.findPendingStepAwaitingMultipleSteps(
|
|
67
|
+
_izContext,
|
|
68
|
+
awaitingStepId
|
|
69
|
+
);
|
|
70
|
+
_izContext.logger.debug('[DeleteRelationshipComplete] awaiting step', {
|
|
71
|
+
awaitingStepId,
|
|
72
|
+
pending
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (!pending) {
|
|
76
|
+
_izContext.logger.warn(
|
|
77
|
+
`No pending step found for awaitingStepId: ${awaitingStepId}`
|
|
78
|
+
);
|
|
79
|
+
return { returnValue, status, errorsFound };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const result =
|
|
83
|
+
await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
|
|
84
|
+
_izContext,
|
|
85
|
+
pending.pendingStepId,
|
|
86
|
+
awaitingStepId,
|
|
87
|
+
errorsFound
|
|
88
|
+
);
|
|
89
|
+
_izContext.logger.debug(
|
|
90
|
+
'[DeleteRelationshipComplete] all awaiting steps result',
|
|
66
91
|
{
|
|
67
|
-
|
|
92
|
+
isComplete: result.isComplete,
|
|
93
|
+
awaitingStepId,
|
|
94
|
+
pendingStepId: pending.pendingStepId
|
|
68
95
|
}
|
|
69
96
|
);
|
|
70
|
-
_izContext.logger.debug(
|
|
71
|
-
'record of deleteRelPendingObjects ::',
|
|
72
|
-
deleteRelPendingObjects
|
|
73
|
-
);
|
|
74
97
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
parentFlowId: returnValue.parentFlowId,
|
|
92
|
-
status: status,
|
|
93
|
-
errorsFound: errorsFound
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
deleteRelComp =
|
|
97
|
-
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
98
|
-
passBackProperties,
|
|
99
|
-
deleteRelComp
|
|
100
|
-
);
|
|
101
|
-
_izContext.logger.debug(
|
|
102
|
-
'After addCallingFlowToSnsResponseMessageObject',
|
|
103
|
-
deleteRelComp
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
let messageAttributes =
|
|
107
|
-
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
108
|
-
passBackProperties,
|
|
109
|
-
{}
|
|
110
|
-
);
|
|
111
|
-
_izContext.logger.debug(
|
|
112
|
-
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
113
|
-
deleteRelComp
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
let sendMessageToOutDeleteRelationshipComplete = {
|
|
117
|
-
Message: JSON.stringify(deleteRelComp),
|
|
118
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
119
|
-
_izContext,
|
|
120
|
-
messageAttributes
|
|
121
|
-
),
|
|
122
|
-
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
123
|
-
_izContext,
|
|
124
|
-
TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete
|
|
125
|
-
)
|
|
126
|
-
};
|
|
127
|
-
_izContext.logger.debug(
|
|
128
|
-
'Send message to OutDeleteRelationshipComplete :::>',
|
|
129
|
-
sendMessageToOutDeleteRelationshipComplete
|
|
130
|
-
);
|
|
131
|
-
await sns.publishAsync(
|
|
132
|
-
_izContext,
|
|
133
|
-
sendMessageToOutDeleteRelationshipComplete
|
|
134
|
-
);
|
|
135
|
-
} // check pendingStepId finished
|
|
136
|
-
|
|
137
|
-
// remove awaitingMultipleStep after finished
|
|
138
|
-
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
139
|
-
_izContext,
|
|
140
|
-
awaitingStepId,
|
|
141
|
-
pendingStepId,
|
|
142
|
-
errorsFound
|
|
98
|
+
if (result.isComplete) {
|
|
99
|
+
_izContext.logger.debug('finished all awaitingStep');
|
|
100
|
+
|
|
101
|
+
let deleteRelComp = {
|
|
102
|
+
firstObject: returnValue.requestParams.firstObject,
|
|
103
|
+
secondObject: returnValue.requestParams.secondObject,
|
|
104
|
+
relType: returnValue.requestParams.relType,
|
|
105
|
+
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
106
|
+
status: status,
|
|
107
|
+
errorsFound: errorsFound
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
deleteRelComp =
|
|
111
|
+
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
112
|
+
passBackProperties,
|
|
113
|
+
deleteRelComp
|
|
143
114
|
);
|
|
144
|
-
|
|
145
|
-
|
|
115
|
+
_izContext.logger.debug(
|
|
116
|
+
'After addCallingFlowToSnsResponseMessageObject',
|
|
117
|
+
deleteRelComp
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
let messageAttributes =
|
|
121
|
+
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
122
|
+
passBackProperties,
|
|
123
|
+
{}
|
|
124
|
+
);
|
|
125
|
+
_izContext.logger.debug(
|
|
126
|
+
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
127
|
+
deleteRelComp
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
let sendMessageToOutDeleteRelationshipComplete = {
|
|
131
|
+
Message: JSON.stringify(deleteRelComp),
|
|
132
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
133
|
+
_izContext,
|
|
134
|
+
messageAttributes
|
|
135
|
+
),
|
|
136
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
137
|
+
_izContext,
|
|
138
|
+
TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete
|
|
139
|
+
)
|
|
140
|
+
};
|
|
141
|
+
_izContext.logger.debug(
|
|
142
|
+
'Send message to OutDeleteRelationshipComplete :::>',
|
|
143
|
+
sendMessageToOutDeleteRelationshipComplete
|
|
144
|
+
);
|
|
145
|
+
await sns.publishAsync(
|
|
146
|
+
_izContext,
|
|
147
|
+
sendMessageToOutDeleteRelationshipComplete
|
|
148
|
+
);
|
|
149
|
+
} // check isComplete finished
|
|
146
150
|
|
|
147
151
|
return {
|
|
148
152
|
returnValue,
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
|
+
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
3
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
4
|
+
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
5
|
+
import GetRelationshipComplete from './GetRelationshipComplete_Main.js';
|
|
6
|
+
|
|
7
|
+
//(<optionalRequire>)
|
|
8
|
+
//(</optionalRequire>)
|
|
9
|
+
|
|
10
|
+
// validate event properties in body.Message of sqs event
|
|
11
|
+
let perRecordsValidatorSchema = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
returnValue: {
|
|
15
|
+
type: 'object'
|
|
16
|
+
},
|
|
17
|
+
parentFlowId: {
|
|
18
|
+
type: 'string'
|
|
19
|
+
},
|
|
20
|
+
status: {
|
|
21
|
+
type: 'string'
|
|
22
|
+
},
|
|
23
|
+
errorsFound: {
|
|
24
|
+
type: 'array'
|
|
25
|
+
},
|
|
26
|
+
graphServiceTag: {
|
|
27
|
+
type: 'string'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
required: [
|
|
31
|
+
'returnValue',
|
|
32
|
+
'parentFlowId',
|
|
33
|
+
'status',
|
|
34
|
+
'errorsFound',
|
|
35
|
+
'graphServiceTag'
|
|
36
|
+
]
|
|
37
|
+
//(<validatorSchema>)
|
|
38
|
+
//(</validatorSchema>)
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let messageAttributeValidatorSchema = null;
|
|
42
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
43
|
+
|
|
44
|
+
export const main = middleware.wrap(async (event, context) => {
|
|
45
|
+
try {
|
|
46
|
+
let recordPromises = [];
|
|
47
|
+
|
|
48
|
+
// loop each record and send to mainFunction
|
|
49
|
+
await Promise.all(
|
|
50
|
+
event.Records.map(async (record) => {
|
|
51
|
+
let passOnProperties = [];
|
|
52
|
+
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
53
|
+
|
|
54
|
+
//validate message (and MessageAttributes)
|
|
55
|
+
await recordHandlerSharedLib.validateRecord(
|
|
56
|
+
record, // one record will send to mainFunction
|
|
57
|
+
'GetRelationshipCompleteHdrSqs', // queue name that need to retry or send to dlq
|
|
58
|
+
perRecordsValidatorSchema, // schema for record.Message
|
|
59
|
+
messageAttributeValidatorSchema
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
63
|
+
passOnProperties.push(record.body.Message);
|
|
64
|
+
passOnProperties.push(
|
|
65
|
+
callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(
|
|
66
|
+
record.body.Message
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
//(<additionalParams>)
|
|
70
|
+
//(</additionalParams>)
|
|
71
|
+
record._izContext.logger.debug(
|
|
72
|
+
'passOnProperties in handler',
|
|
73
|
+
passOnProperties
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
77
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
78
|
+
record, // one record will send to mainFunction
|
|
79
|
+
GetRelationshipComplete, // mainFunction that need to invoke.
|
|
80
|
+
'GetRelationshipCompleteHdrSqs', // queue name that need to retry or send to dlq
|
|
81
|
+
passOnProperties // all parameters that mainFunction needed.
|
|
82
|
+
);
|
|
83
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
84
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
try {
|
|
88
|
+
await Promise.all(recordPromises);
|
|
89
|
+
return event.Records;
|
|
90
|
+
} catch {
|
|
91
|
+
Logger.debug(
|
|
92
|
+
'Promise.all(recordPromises) in handler threw error (at least one record did no resolve)'
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
Logger.error('Unhandled Error, GetRelationshipComplete_HdrSqs: ', error);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
@@ -42,6 +42,7 @@ export default async function getRelationshipComplete(
|
|
|
42
42
|
try {
|
|
43
43
|
const {
|
|
44
44
|
returnValue,
|
|
45
|
+
parentFlowId,
|
|
45
46
|
status,
|
|
46
47
|
errorsFound,
|
|
47
48
|
graphServiceTag
|
|
@@ -49,6 +50,7 @@ export default async function getRelationshipComplete(
|
|
|
49
50
|
|
|
50
51
|
_izContext.logger.debug('Function:getRelationshipComplete', {
|
|
51
52
|
returnValue: returnValue,
|
|
53
|
+
parentFlowId: parentFlowId,
|
|
52
54
|
status: status,
|
|
53
55
|
errorsFound: errorsFound,
|
|
54
56
|
graphServiceTag: graphServiceTag,
|
|
@@ -162,24 +162,6 @@ export default async function getRelationship(
|
|
|
162
162
|
);
|
|
163
163
|
_izContext.logger.debug('relationshipSchema: ', relationshipSchema);
|
|
164
164
|
|
|
165
|
-
const links = await findLinksByObjTypes(
|
|
166
|
-
_izContext,
|
|
167
|
-
[firstObject.objType, secondObject.objType],
|
|
168
|
-
relationshipSchema.links
|
|
169
|
-
);
|
|
170
|
-
_izContext.logger.debug('links', links);
|
|
171
|
-
if (!links.length) {
|
|
172
|
-
const firstTypeStr = JSON.stringify({
|
|
173
|
-
firstObject: firstObject.objType
|
|
174
|
-
});
|
|
175
|
-
const secondTypeStr = JSON.stringify({
|
|
176
|
-
secondObject: secondObject.objType
|
|
177
|
-
});
|
|
178
|
-
errorsFound.push(
|
|
179
|
-
`not found link between ${firstTypeStr} ${secondTypeStr}`
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
165
|
let targetStorageResources = [];
|
|
184
166
|
|
|
185
167
|
if (relationshipSchema) {
|
|
@@ -213,11 +195,11 @@ export default async function getRelationship(
|
|
|
213
195
|
const {
|
|
214
196
|
serviceTag: firstServiceTag,
|
|
215
197
|
objectType: firstObjectType
|
|
216
|
-
} = firstObjectHie
|
|
198
|
+
} = firstObjectHie?.extendObjType || firstObject?.objType || {};
|
|
217
199
|
const {
|
|
218
200
|
serviceTag: secondServiceTag,
|
|
219
201
|
objectType: secondObjectType
|
|
220
|
-
} = secondObjectHie
|
|
202
|
+
} = secondObjectHie?.extendObjType || secondObject?.objType || {};
|
|
221
203
|
|
|
222
204
|
// find exists link
|
|
223
205
|
if (
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
|
+
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
3
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
4
|
+
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
5
|
+
import MoveRelationshipComplete from './MoveRelationshipComplete_Main.js';
|
|
6
|
+
|
|
7
|
+
//(<optionalRequire>)
|
|
8
|
+
//(</optionalRequire>)
|
|
9
|
+
|
|
10
|
+
// validate event properties in body.Message of sqs event
|
|
11
|
+
let perRecordsValidatorSchema = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
returnValue: {
|
|
15
|
+
type: 'object'
|
|
16
|
+
},
|
|
17
|
+
parentFlowId: {
|
|
18
|
+
type: 'string'
|
|
19
|
+
},
|
|
20
|
+
status: {
|
|
21
|
+
type: 'string'
|
|
22
|
+
},
|
|
23
|
+
errorsFound: {
|
|
24
|
+
type: 'array'
|
|
25
|
+
},
|
|
26
|
+
graphServiceTag: {
|
|
27
|
+
type: 'string'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
required: [
|
|
31
|
+
'returnValue',
|
|
32
|
+
'parentFlowId',
|
|
33
|
+
'status',
|
|
34
|
+
'errorsFound',
|
|
35
|
+
'graphServiceTag'
|
|
36
|
+
]
|
|
37
|
+
//(<validatorSchema>)
|
|
38
|
+
//(</validatorSchema>)
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let messageAttributeValidatorSchema = null;
|
|
42
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
43
|
+
|
|
44
|
+
export const main = middleware.wrap(async (event, context) => {
|
|
45
|
+
try {
|
|
46
|
+
let recordPromises = [];
|
|
47
|
+
|
|
48
|
+
// loop each record and send to mainFunction
|
|
49
|
+
await Promise.all(
|
|
50
|
+
event.Records.map(async (record) => {
|
|
51
|
+
let passOnProperties = [];
|
|
52
|
+
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
53
|
+
|
|
54
|
+
//validate message (and MessageAttributes)
|
|
55
|
+
await recordHandlerSharedLib.validateRecord(
|
|
56
|
+
record, // one record will send to mainFunction
|
|
57
|
+
'MoveRelationshipCompleteHdrSqs', // queue name that need to retry or send to dlq
|
|
58
|
+
perRecordsValidatorSchema, // schema for record.Message
|
|
59
|
+
messageAttributeValidatorSchema
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
63
|
+
passOnProperties.push(record.body.Message);
|
|
64
|
+
passOnProperties.push(
|
|
65
|
+
callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(
|
|
66
|
+
record.body.Message
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
//(<additionalParams>)
|
|
70
|
+
//(</additionalParams>)
|
|
71
|
+
record._izContext.logger.debug(
|
|
72
|
+
'passOnProperties in handler',
|
|
73
|
+
passOnProperties
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
77
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
78
|
+
record, // one record will send to mainFunction
|
|
79
|
+
MoveRelationshipComplete, // mainFunction that need to invoke.
|
|
80
|
+
'MoveRelationshipCompleteHdrSqs', // queue name that need to retry or send to dlq
|
|
81
|
+
passOnProperties // all parameters that mainFunction needed.
|
|
82
|
+
);
|
|
83
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
84
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
try {
|
|
88
|
+
await Promise.all(recordPromises);
|
|
89
|
+
return event.Records;
|
|
90
|
+
} catch {
|
|
91
|
+
Logger.debug(
|
|
92
|
+
'Promise.all(recordPromises) in handler threw error (at least one record did no resolve)'
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
Logger.error('Unhandled Error, MoveRelationshipComplete_HdrSqs: ', error);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
@@ -19,7 +19,7 @@ import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
|
19
19
|
|
|
20
20
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
21
21
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
24
24
|
|
|
25
25
|
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
@@ -42,6 +42,7 @@ export default async function <%- functionName %>(
|
|
|
42
42
|
try {
|
|
43
43
|
const {
|
|
44
44
|
returnValue,
|
|
45
|
+
parentFlowId,
|
|
45
46
|
status,
|
|
46
47
|
errorsFound,
|
|
47
48
|
graphServiceTag
|
|
@@ -49,108 +50,111 @@ export default async function <%- functionName %>(
|
|
|
49
50
|
|
|
50
51
|
_izContext.logger.debug('Function:<%- functionName %>', {
|
|
51
52
|
returnValue: returnValue,
|
|
53
|
+
parentFlowId: parentFlowId,
|
|
52
54
|
status: status,
|
|
53
55
|
errorsFound: errorsFound,
|
|
54
56
|
graphServiceTag: graphServiceTag,
|
|
55
57
|
passBackProperties: passBackProperties
|
|
56
58
|
});
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
returnValue
|
|
60
|
+
const awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
61
|
+
parentFlowId || returnValue?.parentFlowId, // hash id
|
|
60
62
|
PREFIX.changeRel // prefix, use constant further
|
|
61
63
|
);
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const pending =
|
|
66
|
+
await asyncFlowSharedLib.findPendingStepAwaitingMultipleSteps(
|
|
67
|
+
_izContext,
|
|
68
|
+
awaitingStepId
|
|
69
|
+
);
|
|
70
|
+
_izContext.logger.debug('[<%- functionName %>] awaiting step', {
|
|
71
|
+
awaitingStepId,
|
|
72
|
+
pending
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (!pending) {
|
|
76
|
+
_izContext.logger.warn(
|
|
77
|
+
`No pending step found for awaitingStepId: ${awaitingStepId}`
|
|
78
|
+
);
|
|
79
|
+
return { returnValue, status, errorsFound };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const result =
|
|
83
|
+
await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
|
|
84
|
+
_izContext,
|
|
85
|
+
pending.pendingStepId,
|
|
86
|
+
awaitingStepId,
|
|
87
|
+
errorsFound
|
|
88
|
+
);
|
|
89
|
+
_izContext.logger.debug(
|
|
90
|
+
'[<%- functionName %>] all awaiting steps result',
|
|
66
91
|
{
|
|
67
|
-
|
|
92
|
+
isComplete: result.isComplete,
|
|
93
|
+
awaitingStepId,
|
|
94
|
+
pendingStepId: pending.pendingStepId
|
|
68
95
|
}
|
|
69
96
|
);
|
|
70
|
-
_izContext.logger.debug(
|
|
71
|
-
'record of moveRelPendingObjects ::',
|
|
72
|
-
moveRelPendingObjects
|
|
73
|
-
);
|
|
74
97
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
status: status,
|
|
97
|
-
parentFlowId: returnValue.parentFlowId,
|
|
98
|
-
errorsFound: errorsFound
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
moveRelCompleteMsg =
|
|
102
|
-
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
103
|
-
passBackProperties,
|
|
104
|
-
moveRelCompleteMsg
|
|
105
|
-
);
|
|
106
|
-
_izContext.logger.debug(
|
|
107
|
-
'After addCallingFlowToSnsResponseMessageObject',
|
|
108
|
-
moveRelCompleteMsg
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
let messageAttributes =
|
|
112
|
-
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
113
|
-
passBackProperties,
|
|
114
|
-
{}
|
|
115
|
-
);
|
|
116
|
-
_izContext.logger.debug(
|
|
117
|
-
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
118
|
-
moveRelCompleteMsg
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
let sendMessageToOutMoveRelationshipComplete = {
|
|
122
|
-
Message: JSON.stringify(moveRelCompleteMsg),
|
|
123
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
124
|
-
_izContext,
|
|
125
|
-
messageAttributes
|
|
126
|
-
),
|
|
127
|
-
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
128
|
-
_izContext,
|
|
129
|
-
TOPIC_NAME_GENERATE_CODE.outMoveRelComplete
|
|
130
|
-
)
|
|
131
|
-
};
|
|
132
|
-
_izContext.logger.debug(
|
|
133
|
-
'Send message to OutCreateRelationshipComplete :::>',
|
|
134
|
-
sendMessageToOutMoveRelationshipComplete
|
|
135
|
-
);
|
|
136
|
-
await sns.publishAsync(
|
|
137
|
-
_izContext,
|
|
138
|
-
sendMessageToOutMoveRelationshipComplete
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
//(<afterCheckAwaitingStep>)
|
|
142
|
-
//(</afterCheckAwaitingStep>)
|
|
143
|
-
} // check pendingStepId finished
|
|
144
|
-
|
|
145
|
-
// remove awaitingMultipleStep after finished
|
|
146
|
-
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
147
|
-
_izContext,
|
|
148
|
-
awaitingStepId,
|
|
149
|
-
pendingStepId,
|
|
150
|
-
errorsFound
|
|
98
|
+
if (result.isComplete) {
|
|
99
|
+
_izContext.logger.debug('finished all awaitingStep');
|
|
100
|
+
|
|
101
|
+
let moveRelCompleteMsg = {
|
|
102
|
+
firstObject: returnValue.requestParams.firstObject,
|
|
103
|
+
secondObject: returnValue.requestParams.secondObject,
|
|
104
|
+
relType: returnValue.requestParams.relType,
|
|
105
|
+
relationshipProperties:
|
|
106
|
+
returnValue.requestParams.relationshipProperties,
|
|
107
|
+
relationshipDirection:
|
|
108
|
+
returnValue.requestParams.relationshipDirection,
|
|
109
|
+
moveObject: returnValue.requestParams.moveObject,
|
|
110
|
+
status: status,
|
|
111
|
+
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
112
|
+
errorsFound: errorsFound
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
moveRelCompleteMsg =
|
|
116
|
+
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
117
|
+
passBackProperties,
|
|
118
|
+
moveRelCompleteMsg
|
|
151
119
|
);
|
|
152
|
-
|
|
153
|
-
|
|
120
|
+
_izContext.logger.debug(
|
|
121
|
+
'After addCallingFlowToSnsResponseMessageObject',
|
|
122
|
+
moveRelCompleteMsg
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
let messageAttributes =
|
|
126
|
+
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
127
|
+
passBackProperties,
|
|
128
|
+
{}
|
|
129
|
+
);
|
|
130
|
+
_izContext.logger.debug(
|
|
131
|
+
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
132
|
+
moveRelCompleteMsg
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
let sendMessageToOutMoveRelationshipComplete = {
|
|
136
|
+
Message: JSON.stringify(moveRelCompleteMsg),
|
|
137
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
138
|
+
_izContext,
|
|
139
|
+
messageAttributes
|
|
140
|
+
),
|
|
141
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
142
|
+
_izContext,
|
|
143
|
+
TOPIC_NAME_GENERATE_CODE.outMoveRelComplete
|
|
144
|
+
)
|
|
145
|
+
};
|
|
146
|
+
_izContext.logger.debug(
|
|
147
|
+
'Send message to OutCreateRelationshipComplete :::>',
|
|
148
|
+
sendMessageToOutMoveRelationshipComplete
|
|
149
|
+
);
|
|
150
|
+
await sns.publishAsync(
|
|
151
|
+
_izContext,
|
|
152
|
+
sendMessageToOutMoveRelationshipComplete
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
//(<afterCheckAwaitingStep>)
|
|
156
|
+
//(</afterCheckAwaitingStep>)
|
|
157
|
+
} // check isComplete finished
|
|
154
158
|
|
|
155
159
|
//(<afterCheckAllAwaitingStep>)
|
|
156
160
|
//(</afterCheckAllAwaitingStep>)
|