@izara_project/izara-core-generate-service-code 1.0.74 → 1.0.76
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/compile/loadSchemas.js +36 -30
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +2 -4
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +12 -2
- package/src/emit/coreFunction/templates/InitialSetupRunner.ejs +5 -3
- package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +13 -6
- package/src/emit/coreFunction/templates/InitialSetup_HdrInv.ejs +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/rbac/emitDynamicRbacFlowSchemas.js +20 -5
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +58 -43
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +68 -20
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +69 -20
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +69 -20
- 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 +36 -2
- 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/src/output/mergeHooks.js +4 -3
- 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 changeRelationshipComplete(
|
|
|
42
42
|
try {
|
|
43
43
|
const {
|
|
44
44
|
returnValue,
|
|
45
|
+
parentFlowId,
|
|
45
46
|
status,
|
|
46
47
|
errorsFound,
|
|
47
48
|
graphServiceTag
|
|
@@ -49,106 +50,109 @@ export default async function changeRelationshipComplete(
|
|
|
49
50
|
|
|
50
51
|
_izContext.logger.debug('Function:ChangeRelationshipComplete', {
|
|
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('[ChangeRelationshipComplete] 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
|
+
'[ChangeRelationshipComplete] 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 createRelPendingObjects ::',
|
|
72
|
-
createRelPendingObjects
|
|
73
|
-
);
|
|
74
97
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
parentFlowId: returnValue.parentFlowId,
|
|
95
|
-
status: status,
|
|
96
|
-
errorsFound: errorsFound
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
changeRelCompleteMsg =
|
|
100
|
-
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
101
|
-
passBackProperties,
|
|
102
|
-
changeRelCompleteMsg
|
|
103
|
-
);
|
|
104
|
-
_izContext.logger.debug(
|
|
105
|
-
'After addCallingFlowToSnsResponseMessageObject',
|
|
106
|
-
changeRelCompleteMsg
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
let messageAttributes =
|
|
110
|
-
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
111
|
-
passBackProperties,
|
|
112
|
-
{}
|
|
113
|
-
);
|
|
114
|
-
_izContext.logger.debug(
|
|
115
|
-
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
116
|
-
changeRelCompleteMsg
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
let sendMessageToOutChangeRelationshipComplete = {
|
|
120
|
-
Message: JSON.stringify(changeRelCompleteMsg),
|
|
121
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
122
|
-
_izContext,
|
|
123
|
-
messageAttributes
|
|
124
|
-
),
|
|
125
|
-
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
126
|
-
_izContext,
|
|
127
|
-
TOPIC_NAME_GENERATE_CODE.outChangeRelationshipComplete
|
|
128
|
-
)
|
|
129
|
-
};
|
|
130
|
-
_izContext.logger.debug(
|
|
131
|
-
'Send message to OutChangeRelationshipComplete :::>',
|
|
132
|
-
sendMessageToOutChangeRelationshipComplete
|
|
133
|
-
);
|
|
134
|
-
await sns.publishAsync(
|
|
135
|
-
_izContext,
|
|
136
|
-
sendMessageToOutChangeRelationshipComplete
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
//(<afterCheckAwaitingStep>)
|
|
140
|
-
//(</afterCheckAwaitingStep>)
|
|
141
|
-
} // check pendingStepId finished
|
|
142
|
-
|
|
143
|
-
// remove awaitingMultipleStep after finished
|
|
144
|
-
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
145
|
-
_izContext,
|
|
146
|
-
awaitingStepId,
|
|
147
|
-
pendingStepId,
|
|
148
|
-
errorsFound
|
|
98
|
+
if (result.isComplete) {
|
|
99
|
+
_izContext.logger.debug('finished all awaitingStep');
|
|
100
|
+
|
|
101
|
+
let changeRelCompleteMsg = {
|
|
102
|
+
firstObject: returnValue.requestParams.firstObject,
|
|
103
|
+
secondObject: returnValue.requestParams.secondObject,
|
|
104
|
+
relType: returnValue.requestParams.relType,
|
|
105
|
+
oldRelTypeAndDirection:
|
|
106
|
+
returnValue.requestParams.oldRelTypeAndDirection,
|
|
107
|
+
newRelType: returnValue.requestParams.newRelType,
|
|
108
|
+
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
109
|
+
status: status,
|
|
110
|
+
errorsFound: errorsFound
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
changeRelCompleteMsg =
|
|
114
|
+
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
115
|
+
passBackProperties,
|
|
116
|
+
changeRelCompleteMsg
|
|
149
117
|
);
|
|
150
|
-
|
|
151
|
-
|
|
118
|
+
_izContext.logger.debug(
|
|
119
|
+
'After addCallingFlowToSnsResponseMessageObject',
|
|
120
|
+
changeRelCompleteMsg
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
let messageAttributes =
|
|
124
|
+
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
125
|
+
passBackProperties,
|
|
126
|
+
{}
|
|
127
|
+
);
|
|
128
|
+
_izContext.logger.debug(
|
|
129
|
+
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
130
|
+
changeRelCompleteMsg
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
let sendMessageToOutChangeRelationshipComplete = {
|
|
134
|
+
Message: JSON.stringify(changeRelCompleteMsg),
|
|
135
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
136
|
+
_izContext,
|
|
137
|
+
messageAttributes
|
|
138
|
+
),
|
|
139
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
140
|
+
_izContext,
|
|
141
|
+
TOPIC_NAME_GENERATE_CODE.outChangeRelationshipComplete
|
|
142
|
+
)
|
|
143
|
+
};
|
|
144
|
+
_izContext.logger.debug(
|
|
145
|
+
'Send message to OutChangeRelationshipComplete :::>',
|
|
146
|
+
sendMessageToOutChangeRelationshipComplete
|
|
147
|
+
);
|
|
148
|
+
await sns.publishAsync(
|
|
149
|
+
_izContext,
|
|
150
|
+
sendMessageToOutChangeRelationshipComplete
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
//(<afterCheckAwaitingStep>)
|
|
154
|
+
//(</afterCheckAwaitingStep>)
|
|
155
|
+
} // check isComplete finished
|
|
152
156
|
|
|
153
157
|
//(<afterCheckAllAwaitingStep>)
|
|
154
158
|
//(</afterCheckAllAwaitingStep>)
|
|
@@ -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 CreateRelationshipComplete from './CreateRelationshipComplete_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
|
+
'CreateRelationshipCompleteHdrSqs', // 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
|
+
CreateRelationshipComplete, // mainFunction that need to invoke.
|
|
80
|
+
'CreateRelationshipCompleteHdrSqs', // 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, CreateRelationshipComplete_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 createRelationshipComplete(
|
|
|
42
42
|
try {
|
|
43
43
|
const {
|
|
44
44
|
returnValue,
|
|
45
|
+
parentFlowId,
|
|
45
46
|
status,
|
|
46
47
|
errorsFound,
|
|
47
48
|
graphServiceTag
|
|
@@ -49,105 +50,108 @@ export default async function createRelationshipComplete(
|
|
|
49
50
|
|
|
50
51
|
_izContext.logger.debug('Function:createRelationshipComplete', {
|
|
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.createRel // 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('[CreateRelationshipComplete] 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
|
+
'[CreateRelationshipComplete] 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 createRelPendingObjects ::',
|
|
72
|
-
createRelPendingObjects
|
|
73
|
-
);
|
|
74
97
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
parentFlowId: returnValue.parentFlowId,
|
|
94
|
-
status: status,
|
|
95
|
-
errorsFound: errorsFound
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
createCompleteMsg =
|
|
99
|
-
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
100
|
-
passBackProperties,
|
|
101
|
-
createCompleteMsg
|
|
102
|
-
);
|
|
103
|
-
_izContext.logger.debug(
|
|
104
|
-
'After addCallingFlowToSnsResponseMessageObject',
|
|
105
|
-
createCompleteMsg
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
let messageAttributes =
|
|
109
|
-
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
110
|
-
passBackProperties,
|
|
111
|
-
{}
|
|
112
|
-
);
|
|
113
|
-
_izContext.logger.debug(
|
|
114
|
-
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
115
|
-
createCompleteMsg
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
let sendMessageToOutCreateRelationshipComplete = {
|
|
119
|
-
Message: JSON.stringify(createCompleteMsg),
|
|
120
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
121
|
-
_izContext,
|
|
122
|
-
messageAttributes
|
|
123
|
-
),
|
|
124
|
-
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
125
|
-
_izContext,
|
|
126
|
-
TOPIC_NAME_GENERATE_CODE.outCreateRelComplete
|
|
127
|
-
)
|
|
128
|
-
};
|
|
129
|
-
_izContext.logger.debug(
|
|
130
|
-
'Send message to OutCreateRelationshipComplete :::>',
|
|
131
|
-
sendMessageToOutCreateRelationshipComplete
|
|
132
|
-
);
|
|
133
|
-
await sns.publishAsync(
|
|
134
|
-
_izContext,
|
|
135
|
-
sendMessageToOutCreateRelationshipComplete
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
//(<afterCheckAwaitingStep>)
|
|
139
|
-
//(</afterCheckAwaitingStep>)
|
|
140
|
-
} // check pendingStepId finished
|
|
141
|
-
|
|
142
|
-
// remove awaitingMultipleStep after finished
|
|
143
|
-
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
144
|
-
_izContext,
|
|
145
|
-
awaitingStepId,
|
|
146
|
-
pendingStepId,
|
|
147
|
-
errorsFound
|
|
98
|
+
if (result.isComplete) {
|
|
99
|
+
_izContext.logger.debug('finished all awaitingStep');
|
|
100
|
+
|
|
101
|
+
let createCompleteMsg = {
|
|
102
|
+
firstObject: returnValue.requestParams.firstObject,
|
|
103
|
+
secondObject: returnValue.requestParams.secondObject,
|
|
104
|
+
relType: returnValue.requestParams.relType,
|
|
105
|
+
relationshipProperties:
|
|
106
|
+
returnValue.requestParams.relationshipProperties,
|
|
107
|
+
parentFlowId: parentFlowId || returnValue?.parentFlowId,
|
|
108
|
+
status: status,
|
|
109
|
+
errorsFound: errorsFound
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
createCompleteMsg =
|
|
113
|
+
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
114
|
+
passBackProperties,
|
|
115
|
+
createCompleteMsg
|
|
148
116
|
);
|
|
149
|
-
|
|
150
|
-
|
|
117
|
+
_izContext.logger.debug(
|
|
118
|
+
'After addCallingFlowToSnsResponseMessageObject',
|
|
119
|
+
createCompleteMsg
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
let messageAttributes =
|
|
123
|
+
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
124
|
+
passBackProperties,
|
|
125
|
+
{}
|
|
126
|
+
);
|
|
127
|
+
_izContext.logger.debug(
|
|
128
|
+
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
129
|
+
createCompleteMsg
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
let sendMessageToOutCreateRelationshipComplete = {
|
|
133
|
+
Message: JSON.stringify(createCompleteMsg),
|
|
134
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
135
|
+
_izContext,
|
|
136
|
+
messageAttributes
|
|
137
|
+
),
|
|
138
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
139
|
+
_izContext,
|
|
140
|
+
TOPIC_NAME_GENERATE_CODE.outCreateRelComplete
|
|
141
|
+
)
|
|
142
|
+
};
|
|
143
|
+
_izContext.logger.debug(
|
|
144
|
+
'Send message to OutCreateRelationshipComplete :::>',
|
|
145
|
+
sendMessageToOutCreateRelationshipComplete
|
|
146
|
+
);
|
|
147
|
+
await sns.publishAsync(
|
|
148
|
+
_izContext,
|
|
149
|
+
sendMessageToOutCreateRelationshipComplete
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
//(<afterCheckAwaitingStep>)
|
|
153
|
+
//(</afterCheckAwaitingStep>)
|
|
154
|
+
} // check isComplete finished
|
|
151
155
|
|
|
152
156
|
//(<afterCheckAllAwaitingStep>)
|
|
153
157
|
//(</afterCheckAllAwaitingStep>)
|
|
@@ -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 DeleteRelationshipComplete from './DeleteRelationshipComplete_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
|
+
'DeleteRelationshipCompleteHdrSqs', // 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
|
+
DeleteRelationshipComplete, // mainFunction that need to invoke.
|
|
80
|
+
'DeleteRelationshipCompleteHdrSqs', // 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, DeleteRelationshipComplete_HdrSqs: ', error);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
});
|