@izara_project/izara-core-generate-service-code 1.0.67 → 1.0.68
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/.prettierrc +11 -0
- package/package.json +16 -12
- package/scripts/format-ejs.js +105 -0
- package/src/compile/compileProject.js +16 -1
- package/src/compile/loadSchemas.js +89 -4
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
- package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +5 -2
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +402 -249
- package/src/emit/custom/customFlows.js +51 -21
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +13 -18
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
- package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
- package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
- package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
- package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
- package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
- package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
- package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
- package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
- package/src/emit/function/functionYamlArtifact.js +20 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +168 -69
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
- package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
- package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
- package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
- package/src/emit/resource/emitResourceArtifacts.js +107 -11
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
- package/src/generate.js +6 -2
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/customFlowApplicationArtifacts.test.js +48 -23
- package/test/dynamicCrudFlowSchemas.test.js +6 -6
- package/test/dynamicRbacFlowSchemas.test.js +8 -12
- package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
- package/test/publicApi.test.js +10 -12
- package/test/resourceArtifacts.test.js +12 -2
- package/docs/test.png +0 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
- /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
|
@@ -15,56 +15,64 @@ You should have received a copy of the GNU Affero General Public License
|
|
|
15
15
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
import {
|
|
19
|
+
middlewareHandler as middleware,
|
|
20
|
+
consts,
|
|
21
|
+
response
|
|
22
|
+
} from '@izara_project/izara-middleware';
|
|
21
23
|
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
22
24
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
23
25
|
import { webSocket } from '@izara_project/izara-core-library-external-request';
|
|
24
26
|
const { postToConnection } = webSocket;
|
|
25
|
-
import { utils } from
|
|
26
|
-
const { createFlowTypeConcat } = utils
|
|
27
|
+
import { utils } from '@izara_project/izara-core-library-service-schemas';
|
|
28
|
+
const { createFlowTypeConcat } = utils;
|
|
27
29
|
|
|
28
30
|
import <%= functionName %> from './<%= functionName %>_Main.js';
|
|
29
31
|
|
|
30
32
|
export const main = middleware.wrap(async (event, context) => {
|
|
31
|
-
|
|
32
33
|
event._izContext.logger.debug('Event:', event);
|
|
33
34
|
|
|
34
35
|
try {
|
|
35
|
-
|
|
36
36
|
if (event.requestContext) {
|
|
37
37
|
const route = event.requestContext.routeKey;
|
|
38
38
|
const connectionId = event.requestContext.connectionId;
|
|
39
|
-
let correlationId = event._izContext.correlationIds.get(
|
|
39
|
+
let correlationId = event._izContext.correlationIds.get(
|
|
40
|
+
consts.X_CORRELATION_ID
|
|
41
|
+
);
|
|
40
42
|
|
|
41
43
|
switch (route) {
|
|
42
44
|
case '<%- route %>':
|
|
43
|
-
console.log(
|
|
44
|
-
let eventParams = JSON.parse(event.body)
|
|
45
|
+
console.log('event in route webSocket', event);
|
|
46
|
+
let eventParams = JSON.parse(event.body);
|
|
45
47
|
|
|
46
48
|
//(<createIdentifiersFlow>)
|
|
47
|
-
let identifiers
|
|
49
|
+
let identifiers;
|
|
48
50
|
//(</createIdentifiersFlow>)
|
|
49
51
|
|
|
50
|
-
await dynamodbSharedLib.putItem(
|
|
51
|
-
|
|
52
|
+
await dynamodbSharedLib.putItem(
|
|
53
|
+
event._izContext,
|
|
54
|
+
await dynamodbSharedLib.tableName(
|
|
55
|
+
event._izContext,
|
|
56
|
+
'WebSocketTask'
|
|
57
|
+
),
|
|
52
58
|
{
|
|
53
|
-
taskKey: `${createFlowTypeConcat(event._izContext, { flowTag:
|
|
54
|
-
connectionId: connectionId
|
|
59
|
+
taskKey: `${createFlowTypeConcat(event._izContext, { flowTag: '<%- route %>', serviceTag: process.env.iz_serviceTag })}${identifiers}`,
|
|
60
|
+
connectionId: connectionId
|
|
55
61
|
}
|
|
56
|
-
)
|
|
62
|
+
);
|
|
57
63
|
|
|
58
|
-
let callingFlow = eventParams?.callingFlow
|
|
64
|
+
let callingFlow = eventParams?.callingFlow
|
|
65
|
+
? eventParams.callingFlow
|
|
66
|
+
: {};
|
|
59
67
|
await <%= functionName %>(
|
|
60
68
|
event._izContext,
|
|
61
69
|
eventParams,
|
|
62
70
|
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
63
71
|
//(<additionalParams>)
|
|
64
72
|
//(</additionalParams>)
|
|
65
|
-
)
|
|
73
|
+
);
|
|
66
74
|
|
|
67
|
-
break
|
|
75
|
+
break;
|
|
68
76
|
}
|
|
69
77
|
} else {
|
|
70
78
|
const connId = event.connId;
|
|
@@ -72,13 +80,12 @@ export const main = middleware.wrap(async (event, context) => {
|
|
|
72
80
|
await postToConnection({ message: event.message }, connId);
|
|
73
81
|
}
|
|
74
82
|
|
|
75
|
-
return
|
|
76
|
-
|
|
83
|
+
return response.webSocketSuccess();
|
|
77
84
|
} catch (err) {
|
|
78
|
-
const connId = event.requestContext.connectionId
|
|
85
|
+
const connId = event.requestContext.connectionId;
|
|
79
86
|
event._izContext.logger.error('Error, WebSocket: ', err);
|
|
80
87
|
// await sendErrorMessage({ message: err.message }, connId);
|
|
81
88
|
await postToConnection({ message: err.message }, connId);
|
|
82
|
-
return
|
|
89
|
+
return response.failure(err);
|
|
83
90
|
}
|
|
84
91
|
});
|
|
@@ -16,8 +16,6 @@ along with this program. If not, see
|
|
|
16
16
|
<http: //www.gnu.org/licenses />.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
19
|
import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
|
|
22
20
|
import { consts } from '@izara_project/izara-middleware';
|
|
23
21
|
|
|
@@ -53,79 +51,98 @@ const { TOPIC_NAME_GENERATE_CODE } = schemaConsts;
|
|
|
53
51
|
export default async function createObject(
|
|
54
52
|
_izContext,
|
|
55
53
|
requestParams,
|
|
56
|
-
callingFlowConfig = {}
|
|
54
|
+
callingFlowConfig = {}
|
|
57
55
|
//(<additionalParams>)
|
|
58
56
|
//(</additionalParams>)
|
|
59
57
|
) {
|
|
60
|
-
|
|
61
58
|
try {
|
|
62
|
-
_izContext.logger.debug(
|
|
63
|
-
_izContext.logger.debug(
|
|
64
|
-
_izContext.logger.debug(
|
|
59
|
+
_izContext.logger.debug('WebSocketInvoke _izContext', _izContext);
|
|
60
|
+
_izContext.logger.debug('WebSocketInvoke requestParams', requestParams);
|
|
61
|
+
_izContext.logger.debug(
|
|
62
|
+
'WebSocketInvoke callingFlowConfig',
|
|
63
|
+
callingFlowConfig
|
|
64
|
+
);
|
|
65
65
|
|
|
66
|
-
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
|
|
66
|
+
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
|
|
67
67
|
|
|
68
|
-
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(
|
|
69
|
+
_izContext,
|
|
70
|
+
{
|
|
71
|
+
flowTag: '<%- flowTag %>',
|
|
72
|
+
serviceTag: process.env.iz_serviceTag
|
|
73
|
+
}
|
|
74
|
+
);
|
|
72
75
|
|
|
73
|
-
_izContext.logger.debug(
|
|
76
|
+
_izContext.logger.debug('getFlowSchema', flowSchema);
|
|
74
77
|
|
|
75
|
-
let getUserFromTableUserUploadRecord = await dynamodbSharedLib.getItem(
|
|
76
|
-
|
|
78
|
+
let getUserFromTableUserUploadRecord = await dynamodbSharedLib.getItem(
|
|
79
|
+
_izContext,
|
|
80
|
+
await dynamodbSharedLib.tableName(_izContext, 'UserUploadRecords'),
|
|
77
81
|
{
|
|
78
82
|
connectionId: connectionId
|
|
79
83
|
}
|
|
80
|
-
)
|
|
84
|
+
);
|
|
81
85
|
|
|
82
|
-
const { userId, submittedByUserId } = getUserFromTableUserUploadRecord
|
|
83
|
-
_izContext.correlationIds.set(consts.BASE_USER_ID, userId)
|
|
84
|
-
_izContext.correlationIds.set(consts.TARGET_ID, submittedByUserId)
|
|
86
|
+
const { userId, submittedByUserId } = getUserFromTableUserUploadRecord;
|
|
87
|
+
_izContext.correlationIds.set(consts.BASE_USER_ID, userId);
|
|
88
|
+
_izContext.correlationIds.set(consts.TARGET_ID, submittedByUserId);
|
|
85
89
|
|
|
86
90
|
if (!flowSchema) {
|
|
87
|
-
throw new NoRetryError(`flowTag not found ${requestParams.action}`)
|
|
91
|
+
throw new NoRetryError(`flowTag not found ${requestParams.action}`);
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
// get objectType
|
|
91
|
-
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
92
|
-
|
|
95
|
+
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
96
|
+
_izContext,
|
|
97
|
+
flowSchema.objType
|
|
98
|
+
);
|
|
99
|
+
_izContext.logger.debug(
|
|
100
|
+
'objectSchema in flowSchema mainFunction',
|
|
101
|
+
objectSchema
|
|
102
|
+
);
|
|
93
103
|
|
|
94
104
|
if (!objectSchema) {
|
|
95
|
-
throw new NoRetryError(`${flowSchema.objType.objectType} not found`)
|
|
105
|
+
throw new NoRetryError(`${flowSchema.objType.objectType} not found`);
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
//(<beforeCreateHook>)
|
|
99
109
|
//(</beforeCreateHook>)
|
|
100
110
|
// create message Object to create Endpoint
|
|
101
111
|
let messageObject = {
|
|
102
|
-
objectType:
|
|
112
|
+
objectType: '<%- objectType %>',
|
|
103
113
|
fieldNames: {
|
|
104
114
|
//(<fieldNamesHook>)
|
|
105
115
|
//(</fieldNamesHook>)
|
|
106
116
|
}
|
|
107
|
-
}
|
|
117
|
+
};
|
|
108
118
|
// create callingFlow
|
|
109
|
-
messageObject =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
messageObject =
|
|
120
|
+
callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
121
|
+
messageObject,
|
|
122
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
123
|
+
callingFlowConfig,
|
|
124
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
125
|
+
await lambdaSharedLib.lambdaFunctionName(
|
|
126
|
+
_izContext,
|
|
127
|
+
TOPIC_NAME_GENERATE_CODE.createNodeComplete
|
|
128
|
+
),
|
|
129
|
+
{}
|
|
130
|
+
)
|
|
115
131
|
)
|
|
116
|
-
)
|
|
117
|
-
)
|
|
132
|
+
);
|
|
118
133
|
|
|
119
134
|
// send message to Create endpoint
|
|
120
135
|
let sendMessageToCreateEndpoint = {
|
|
121
136
|
Message: JSON.stringify(messageObject),
|
|
122
|
-
TopicArn:
|
|
123
|
-
}
|
|
124
|
-
_izContext.logger.debug(
|
|
137
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(_izContext, 'Create_In')
|
|
138
|
+
};
|
|
139
|
+
_izContext.logger.debug(
|
|
140
|
+
'sendMessageToCreateEndpoint',
|
|
141
|
+
sendMessageToCreateEndpoint
|
|
142
|
+
);
|
|
125
143
|
await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
|
|
126
|
-
|
|
127
144
|
} catch (err) {
|
|
128
|
-
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
129
|
-
throw
|
|
145
|
+
_izContext.logger.error('error WebSocketInvoke: ', err);
|
|
146
|
+
throw err;
|
|
130
147
|
}
|
|
131
148
|
}
|
|
@@ -15,9 +15,7 @@ You should have received a copy of the GNU Affero General Public License
|
|
|
15
15
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
|
|
18
|
+
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
21
19
|
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
22
20
|
import Logger from '@izara_project/izara-core-library-logger';
|
|
23
21
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
@@ -29,18 +27,14 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
|
29
27
|
|
|
30
28
|
// set schema for record.body.Message
|
|
31
29
|
let perRecordsValidatorSchema = {
|
|
32
|
-
type:
|
|
33
|
-
required: [
|
|
34
|
-
'returnMessage',
|
|
35
|
-
'errorsFound',
|
|
36
|
-
'passStatus'
|
|
37
|
-
],
|
|
30
|
+
type: 'object',
|
|
31
|
+
required: ['returnMessage', 'errorsFound', 'passStatus'],
|
|
38
32
|
properties: {
|
|
39
33
|
returnMessage: {
|
|
40
|
-
type:
|
|
34
|
+
type: 'object'
|
|
41
35
|
},
|
|
42
36
|
errorsFound: {
|
|
43
|
-
type:
|
|
37
|
+
type: 'array'
|
|
44
38
|
},
|
|
45
39
|
passStatus: {
|
|
46
40
|
type: 'boolean'
|
|
@@ -62,62 +56,73 @@ let perRecordsValidatorSchema = {
|
|
|
62
56
|
// }
|
|
63
57
|
// };
|
|
64
58
|
|
|
65
|
-
perRecordsValidatorSchema =
|
|
59
|
+
perRecordsValidatorSchema =
|
|
60
|
+
callingFlowSharedLib.addOptionalPassBackPropertiesToValidatorSchema(
|
|
61
|
+
perRecordsValidatorSchema
|
|
62
|
+
);
|
|
66
63
|
|
|
67
64
|
export const main = middleware.wrap(async (event, context) => {
|
|
68
|
-
|
|
69
65
|
try {
|
|
70
|
-
|
|
71
66
|
let recordPromises = [];
|
|
72
67
|
|
|
73
68
|
// loop each record and send to mainFunction
|
|
74
|
-
await Promise.all(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
69
|
+
await Promise.all(
|
|
70
|
+
event.Records.map(async (record) => {
|
|
71
|
+
// promise.all for map() function
|
|
72
|
+
|
|
73
|
+
let passOnProperties = [];
|
|
74
|
+
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
75
|
+
|
|
76
|
+
// validate message (and MessageAttributes)
|
|
77
|
+
await recordHandlerSharedLib.validateRecord(
|
|
78
|
+
record, // one record will send to mainFunction
|
|
79
|
+
'<%= functionName %><%= handlerType %>', // queue name that need to retry or send to dlq
|
|
80
|
+
perRecordsValidatorSchema // schema for record.Message
|
|
81
|
+
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
85
|
+
passOnProperties.push(record.body.Message.returnMessage);
|
|
86
|
+
passOnProperties.push(record.body.Message.errorsFound);
|
|
87
|
+
passOnProperties.push(record.body.Message.passStatus);
|
|
88
|
+
//(<additionalProperties>)
|
|
89
|
+
//(</additionalProperties>)
|
|
90
|
+
passOnProperties.push(
|
|
91
|
+
callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(
|
|
92
|
+
record.body.Message
|
|
93
|
+
)
|
|
94
|
+
);
|
|
95
|
+
record._izContext.logger.debug(
|
|
96
|
+
'passOnProperties in handler',
|
|
97
|
+
passOnProperties
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
101
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
102
|
+
record, // one record will send to mainFunction
|
|
103
|
+
<%= functionName %>, // mainFunction that need to invoke.
|
|
104
|
+
'<%= functionName %><%= handlerType %>', // queue name that need to retry or send to dlq
|
|
105
|
+
passOnProperties // all parameters that mainFunction needed.
|
|
106
|
+
);
|
|
107
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
108
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
109
|
+
})
|
|
110
|
+
);
|
|
106
111
|
|
|
107
112
|
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
108
113
|
try {
|
|
109
114
|
// --- main await all promises
|
|
110
115
|
await Promise.all(recordPromises); // await all promises
|
|
111
116
|
|
|
112
|
-
return event.Records // return all for local test
|
|
113
|
-
|
|
117
|
+
return event.Records; // return all for local test
|
|
114
118
|
} catch {
|
|
115
|
-
Logger.debug(
|
|
119
|
+
Logger.debug(
|
|
120
|
+
'Promise.all(recordPromises) in handler threw error (at least one record did no resolve)'
|
|
121
|
+
);
|
|
116
122
|
}
|
|
117
123
|
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
118
|
-
|
|
119
124
|
} catch (err) {
|
|
120
125
|
Logger.error('Unhandled Error, <%= functionName %><%= handlerType %>: ', err);
|
|
121
|
-
throw
|
|
126
|
+
throw err;
|
|
122
127
|
}
|
|
123
128
|
});
|