@izara_project/izara-core-generate-service-code 1.0.22 → 1.0.24
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/generateCode/generateFlowSchema/GenerateCodeFlowSchema.js +11 -8
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/functionYaml/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/functionYaml/template.ejs +3 -10
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/data.js +5 -4
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/template.ejs +5 -14
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/index.js +4 -13
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/mainFunction/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/index.js +5 -9
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/functionYaml/data.js +6 -10
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/functionYaml/template.ejs +4 -11
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/handler/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/sns-in-sqs/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/sns-out/data.js +4 -3
- package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/data.js +4 -8
- package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/template.ejs +12 -21
- package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/handler/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/index.js +3 -7
- package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/functionYaml/data.js +11 -9
- package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/functionYaml/template.ejs +3 -10
- package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/handler/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/index.js +3 -7
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/functionYaml/data.js +4 -3
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/handler/data.js +3 -3
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/functionYaml/data.js +8 -11
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/handler/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/mainFunction/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/index.js +8 -24
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/sns-in/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/sns-out/data.js +4 -3
- package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/data.js +14 -12
- package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/template.ejs +5 -8
- package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/templateByStatusType/statusFieldTemplate.ejs +30 -0
- package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/templateByStatusType/storedCacheTemplate.ejs +26 -0
- package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/templateByStatusType/triggerCacheTemplate.ejs +44 -0
- package/src/generateCode/generateFlowSchema/event/s3Component/index.js +23 -55
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/functionYaml/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/handler/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/mainFunction/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/queue/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/createObject/functionYaml/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/createObject/handler/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/createObject/mainFunction/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/functionYaml/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/handler/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/mainFunction/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/queue/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/functionYaml/data.js +6 -10
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/handler/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/mainFunction/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/sqs/data.js +2 -2
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/functionYml/HdrS3/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/handler/handlerS3/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/mainFunction/data.js +3 -7
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/relate/S3/data.js +4 -4
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/relate/sns-out/data.js +5 -3
- package/src/generateCode/generateFlowSchema/event/s3Component/websocket/dynamoDb/ReservedTableData.js +3 -3
- package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/data.js +4 -8
- package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/template.ejs +3 -5
- package/src/generateCode/generateFlowSchema/flowStep/flowStep.js +7 -2
- package/src/generateCode/generateFlowSchema/libs/data.js +3 -7
- package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/functionYaml/data.js +9 -9
- package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/handler/data.js +1 -5
- package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/index.js +6 -18
- package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/mainFunction/data.js +15 -14
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/checkTriggerCacheComplete/functionYaml/data.js +4 -8
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/checkTriggerCacheComplete/handler/data.js +15 -15
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/checkTriggerCacheComplete/mainFunction/data.js +15 -15
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/index.js +13 -33
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/processTriggerCache/functionYaml/data.js +4 -8
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/processTriggerCache/handler/data.js +12 -14
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/processTriggerCache/mainFunction/data.js +11 -14
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/functionYaml/dsq/data.js +4 -9
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/functionYaml/sqs/data.js +4 -9
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/handler/dsq/data.js +11 -14
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/handler/sqs/data.js +11 -14
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/mainFunction/data.js +15 -15
- package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheQueue/data.js +2 -3
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/template.ejs +185 -103
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/delete/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/get/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/mainFunction/template.ejs +137 -71
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/create/main/template.ejs +1 -1
- package/src/generateCode/generateSchema/actionEndpointComponent/yaml/data.js +6 -4
- package/src/generateCode/generateSchema/findDataComponent/mainFunction/data.js +1 -1
- package/src/generateCode/generateSchema/relationshipPerActionComponent/changeRelationship/complete/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/relationshipPerActionComponent/create/action/functionYaml/data.js +1 -0
- package/src/generateCode/generateSchema/relationshipPerActionComponent/create/complete/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/action/functionYaml/data.js +1 -0
- package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/complete/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/relationshipPerActionComponent/get/action/functionYaml/data.js +1 -0
- package/src/generateCode/generateSchema/relationshipPerActionComponent/get/complete/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/complete/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/functionYaml/data.js +1 -0
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/sns-out/data.js +2 -1
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/complete/sns-out/data.js +2 -1
- package/src/generateCode/resourceYamlComponent/sns-out/data.js +2 -1
- package/src/generateCode/resourceYamlComponent/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +2 -1
- package/src/generateCode/resourceYamlComponent/sns-out/template.ejs +2 -6
- package/src/generateCode.js +9 -7
- package/src/libs/Consts.js +9 -12
- package/src/libs/Utils.js +26 -1
- package/src/__TemplateData/flowSchema/event/externalTopic/Process/handler/data.js +0 -64
- package/src/__TemplateData/flowSchema/event/externalTopic/sns-out/data.js +0 -75
|
@@ -22,25 +22,154 @@ import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
|
22
22
|
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
23
23
|
import _ from 'lodash';
|
|
24
24
|
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
consts,
|
|
27
|
+
errors,
|
|
28
|
+
} from '@izara_project/izara-core-library-service-schemas';
|
|
29
|
+
|
|
26
30
|
const { TOPIC_NAME_GENERATE_CODE } = consts;
|
|
31
|
+
const { NoRetryError } = errors;
|
|
27
32
|
const PREFIX = {
|
|
28
|
-
CREATE_OBJECT_ASYNC:
|
|
29
|
-
CREATE_OBJECT_ASYNC_COMPLETE:
|
|
30
|
-
}
|
|
33
|
+
CREATE_OBJECT_ASYNC: 'createObjectAsync',
|
|
34
|
+
CREATE_OBJECT_ASYNC_COMPLETE: 'createObjectAsyncComplete',
|
|
35
|
+
};
|
|
36
|
+
|
|
31
37
|
//(<optionalRequire>)
|
|
32
38
|
//(</optionalRequire>)
|
|
33
39
|
|
|
34
40
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @param {*} _izContext
|
|
37
41
|
* @param {*} returnValue
|
|
38
42
|
* @param {*} status
|
|
39
|
-
* @param {*} errorsFounds
|
|
40
43
|
* @param {*} graphServiceTag
|
|
44
|
+
* @param {*} errorsFound
|
|
45
|
+
*/
|
|
46
|
+
function validateInput(returnValue, status, graphServiceTag, errorsFound) {
|
|
47
|
+
if (!Object.prototype.hasOwnProperty.call(returnValue, 'queryResult')) {
|
|
48
|
+
errorsFound.push(
|
|
49
|
+
'message is not have property queryResult, should be not happen',
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if (
|
|
53
|
+
!Object.prototype.hasOwnProperty.call(returnValue.requestParams, 'objType')
|
|
54
|
+
) {
|
|
55
|
+
errorsFound.push(
|
|
56
|
+
'message is not have property objType, should be not happen',
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
60
|
+
!Object.prototype.hasOwnProperty.call(
|
|
61
|
+
returnValue.requestParams,
|
|
62
|
+
'objInstanceFull',
|
|
63
|
+
)
|
|
64
|
+
) {
|
|
65
|
+
errorsFound.push(
|
|
66
|
+
'message is not have property objInstance, should be not objInstance',
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (status == 'error' && errorsFound.length > 0) {
|
|
71
|
+
errorsFound.push('error before validate');
|
|
72
|
+
} else if (status == 'error' && errorsFound.length == 0) {
|
|
73
|
+
errorsFound.push(
|
|
74
|
+
'[invalid]status is error not have errorsFound form graphService',
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (status === 'complete' && errorsFound.length > 0) {
|
|
78
|
+
errorsFound.push(
|
|
79
|
+
'[Invalid] status is complete should be not have errorsFound',
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (graphServiceTag == null) {
|
|
83
|
+
errorsFound.push('[Invalid] graphServerTag is not empty string');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {*} returnValue
|
|
89
|
+
* @returns {object|null}
|
|
90
|
+
*/
|
|
91
|
+
function buildExistsNode(returnValue) {
|
|
92
|
+
const { existsNode } = returnValue.queryResult.returnCreateNode;
|
|
93
|
+
if (!Object.keys(existsNode).length) return null;
|
|
94
|
+
|
|
95
|
+
const { objType } = returnValue.requestParams;
|
|
96
|
+
return {
|
|
97
|
+
objType: {
|
|
98
|
+
objectType: objType.objectType,
|
|
99
|
+
serviceTag: objType.serviceTag,
|
|
100
|
+
},
|
|
101
|
+
objInstanceFull: existsNode.objInstanceFull,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {*} returnValue
|
|
107
|
+
* @param {*} existsNode
|
|
108
|
+
* @param {*} status
|
|
109
|
+
* @param {*} errorsFound
|
|
110
|
+
* @returns {object}
|
|
111
|
+
*/
|
|
112
|
+
function buildMessageObject(returnValue, existsNode, status, errorsFound) {
|
|
113
|
+
const { objType } = returnValue.requestParams;
|
|
114
|
+
const { returnCreateNode } = returnValue.queryResult;
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
objType: {
|
|
118
|
+
objectType: objType.objectType,
|
|
119
|
+
serviceTag: objType.serviceTag,
|
|
120
|
+
},
|
|
121
|
+
objInstanceFull: returnCreateNode.objInstanceFull,
|
|
122
|
+
relationships: returnCreateNode.relationships,
|
|
123
|
+
existsNode,
|
|
124
|
+
status,
|
|
125
|
+
errorsFound,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @param {*} _izContext
|
|
41
131
|
* @param {*} passBackProperties
|
|
132
|
+
* @param {*} messageObject
|
|
42
133
|
*/
|
|
134
|
+
async function sendSnsMessage(_izContext, passBackProperties, messageObject) {
|
|
135
|
+
const enrichedMessage =
|
|
136
|
+
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
137
|
+
passBackProperties,
|
|
138
|
+
messageObject,
|
|
139
|
+
);
|
|
140
|
+
const messageAttributes =
|
|
141
|
+
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
142
|
+
passBackProperties,
|
|
143
|
+
{},
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const snsPayload = {
|
|
147
|
+
Message: JSON.stringify(enrichedMessage),
|
|
148
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
149
|
+
_izContext,
|
|
150
|
+
messageAttributes,
|
|
151
|
+
),
|
|
152
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(
|
|
153
|
+
_izContext,
|
|
154
|
+
TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete,
|
|
155
|
+
),
|
|
156
|
+
};
|
|
43
157
|
|
|
158
|
+
_izContext.logger.debug(
|
|
159
|
+
'Send message to OutCreateObjectComplete :::>',
|
|
160
|
+
snsPayload,
|
|
161
|
+
);
|
|
162
|
+
await sns.publishAsync(_izContext, snsPayload);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @param {*} _izContext
|
|
167
|
+
* @param {*} returnValue
|
|
168
|
+
* @param {*} status
|
|
169
|
+
* @param {*} errorsFound
|
|
170
|
+
* @param {*} graphServiceTag
|
|
171
|
+
* @param {*} passBackProperties
|
|
172
|
+
*/
|
|
44
173
|
export default async function createObjectComplete(
|
|
45
174
|
_izContext,
|
|
46
175
|
returnValue,
|
|
@@ -50,7 +179,7 @@ export default async function createObjectComplete(
|
|
|
50
179
|
passBackProperties,
|
|
51
180
|
) {
|
|
52
181
|
try {
|
|
53
|
-
_izContext.logger.debug(
|
|
182
|
+
_izContext.logger.debug('function createObjectComplete:', {
|
|
54
183
|
returnValue,
|
|
55
184
|
status,
|
|
56
185
|
errorsFound,
|
|
@@ -59,106 +188,63 @@ export default async function createObjectComplete(
|
|
|
59
188
|
});
|
|
60
189
|
|
|
61
190
|
if (_.isEmpty(returnValue.requestParams)) {
|
|
62
|
-
_izContext.logger.debug(
|
|
63
|
-
throw new NoRetryError(
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
errorsFound.push("message is not have property queryResult, should be not happen");
|
|
68
|
-
};
|
|
69
|
-
if (!returnValue.requestParams.hasOwnProperty("objType")) {
|
|
70
|
-
errorsFound.push("message is not have property objType, should be not happen");
|
|
71
|
-
};
|
|
72
|
-
if (!returnValue.requestParams.hasOwnProperty("objInstanceFull")) {
|
|
73
|
-
errorsFound.push("message is not have property objInstance, should be not objInstance");
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
if (status == "error" && errorsFound.length > 0) {
|
|
77
|
-
errorsFound.push("error before validate");
|
|
78
|
-
} else if (status == "error" && errorsFound.length == 0) {
|
|
79
|
-
errorsFound.push("[invalid]status is error not have errorsFound form graphService");
|
|
80
|
-
|
|
81
|
-
};
|
|
82
|
-
if (status === "complete" && errorsFound.length > 0) {
|
|
83
|
-
errorsFound.push("[Invalid] status is complete should be not have errorsFound");
|
|
84
|
-
};
|
|
85
|
-
if (graphServiceTag == null) {
|
|
86
|
-
errorsFound.push("[Invalid] graphServerTag is not empty string");
|
|
87
|
-
};
|
|
191
|
+
_izContext.logger.debug('message callingFlowProperties is empty');
|
|
192
|
+
throw new NoRetryError('message not an object');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
validateInput(returnValue, status, graphServiceTag, errorsFound);
|
|
88
196
|
|
|
89
197
|
if (errorsFound.length > 0) {
|
|
90
|
-
_izContext.logger.debug(
|
|
91
|
-
errorsFound
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
let existsNode = null;
|
|
95
|
-
|
|
96
|
-
if (Object.keys(returnValue.queryResult.returnCreateNode.existsNode).length) {
|
|
97
|
-
existsNode = {
|
|
98
|
-
objType: {
|
|
99
|
-
objectType: returnValue.requestParams.objType.objectType,
|
|
100
|
-
serviceTag: returnValue.requestParams.objType.serviceTag
|
|
101
|
-
},
|
|
102
|
-
objInstanceFull: returnValue.queryResult.returnCreateNode.existsNode.objInstanceFull
|
|
103
|
-
}
|
|
198
|
+
_izContext.logger.debug('Have error form graphServerTag:', errorsFound);
|
|
199
|
+
errorsFound.push(errorsFound.join(','));
|
|
104
200
|
}
|
|
105
201
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
202
|
+
const existsNode = buildExistsNode(returnValue);
|
|
203
|
+
|
|
204
|
+
const { requestParams } = returnValue;
|
|
205
|
+
const awaitingStepId = await asyncFlowSharedLib.createAwaitingStepId(
|
|
206
|
+
hash({
|
|
207
|
+
objType: requestParams.objType,
|
|
109
208
|
graphServerTag: graphServiceTag,
|
|
110
|
-
identifiers:
|
|
111
|
-
callingFlowProperties:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
209
|
+
identifiers: requestParams.objInstanceFull.identifiers,
|
|
210
|
+
callingFlowProperties:
|
|
211
|
+
passBackProperties.passBackProperties.parentPassBackProperties
|
|
212
|
+
.callingFlowProperties || {},
|
|
213
|
+
}),
|
|
214
|
+
PREFIX.CREATE_OBJECT_ASYNC,
|
|
215
|
+
);
|
|
216
|
+
_izContext.logger.debug('awaitingStepId:', awaitingStepId);
|
|
116
217
|
|
|
117
|
-
|
|
218
|
+
const recordAwaitingSteps = await dynamodbSharedLib.query(
|
|
118
219
|
_izContext,
|
|
119
|
-
await dynamodbSharedLib.tableName(_izContext,
|
|
120
|
-
{
|
|
121
|
-
awaitingStepId: awaitingStepId
|
|
122
|
-
}
|
|
220
|
+
await dynamodbSharedLib.tableName(_izContext, 'AwaitingMultipleSteps'),
|
|
221
|
+
{ awaitingStepId },
|
|
123
222
|
);
|
|
124
|
-
_izContext.logger.debug(
|
|
223
|
+
_izContext.logger.debug('record awaitingSteps::', recordAwaitingSteps);
|
|
125
224
|
|
|
126
225
|
await Promise.all(
|
|
127
226
|
recordAwaitingSteps.Items.map(async ({ pendingStepId }) => {
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
status: status,
|
|
145
|
-
errorsFound: errorsFound
|
|
146
|
-
}
|
|
227
|
+
if (
|
|
228
|
+
await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithError(
|
|
229
|
+
_izContext,
|
|
230
|
+
pendingStepId,
|
|
231
|
+
awaitingStepId,
|
|
232
|
+
errorsFound,
|
|
233
|
+
)
|
|
234
|
+
) {
|
|
235
|
+
_izContext.logger.debug('finish all awaitingStep');
|
|
236
|
+
|
|
237
|
+
const messageObject = buildMessageObject(
|
|
238
|
+
returnValue,
|
|
239
|
+
existsNode,
|
|
240
|
+
status,
|
|
241
|
+
errorsFound,
|
|
242
|
+
);
|
|
147
243
|
|
|
148
244
|
//(<beforeSendMessage>)
|
|
149
245
|
//(</beforeSendMessage>)
|
|
150
246
|
|
|
151
|
-
|
|
152
|
-
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {})
|
|
153
|
-
|
|
154
|
-
let sendMessageOutCreateObjectComplete = {
|
|
155
|
-
Message: JSON.stringify(messageObject),
|
|
156
|
-
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
157
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete)
|
|
158
|
-
};
|
|
159
|
-
_izContext.logger.debug("Send message to OutCreateObjectComplete :::>", sendMessageOutCreateObjectComplete)
|
|
160
|
-
await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete);
|
|
161
|
-
|
|
247
|
+
await sendSnsMessage(_izContext, passBackProperties, messageObject);
|
|
162
248
|
|
|
163
249
|
//(<afterSendMessage>)
|
|
164
250
|
//(</afterSendMessage>)
|
|
@@ -168,20 +254,16 @@ export default async function createObjectComplete(
|
|
|
168
254
|
_izContext,
|
|
169
255
|
awaitingStepId,
|
|
170
256
|
pendingStepId,
|
|
171
|
-
errorsFound
|
|
257
|
+
errorsFound,
|
|
172
258
|
);
|
|
259
|
+
}),
|
|
260
|
+
);
|
|
173
261
|
|
|
174
|
-
})
|
|
175
|
-
)
|
|
176
262
|
//(<beforeReturn>)
|
|
177
263
|
//(</beforeReturn>)
|
|
178
|
-
return {
|
|
179
|
-
returnValue: returnValue,
|
|
180
|
-
status: status,
|
|
181
|
-
errorsFound: errorsFound
|
|
182
|
-
}
|
|
183
|
-
|
|
264
|
+
return { returnValue, status, errorsFound };
|
|
184
265
|
} catch (err) {
|
|
185
|
-
|
|
266
|
+
_izContext.logger.error('createObjectComplete error:', err);
|
|
267
|
+
throw err;
|
|
186
268
|
}
|
|
187
269
|
}
|
package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/sns-out/data.js
CHANGED
|
@@ -60,7 +60,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
|
|
|
60
60
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
61
61
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
62
62
|
fileExtension: '.yml',
|
|
63
|
-
isAppend: true
|
|
63
|
+
isAppend: true,
|
|
64
|
+
fromFile: 'actionEndpointCom/create/sns-out/data.js'
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
67
|
}
|
package/src/generateCode/generateSchema/actionEndpointCompleteComponent/delete/sns-out/data.js
CHANGED
|
@@ -60,7 +60,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
|
|
|
60
60
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
61
61
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
62
62
|
fileExtension: '.yml',
|
|
63
|
-
isAppend: true
|
|
63
|
+
isAppend: true,
|
|
64
|
+
fromFile: 'actionEndpointCom/delete/sns-out/data.js'
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
67
|
}
|
|
@@ -60,7 +60,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
|
|
|
60
60
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
61
61
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
62
62
|
fileExtension: '.yml',
|
|
63
|
-
isAppend: true
|
|
63
|
+
isAppend: true,
|
|
64
|
+
fromFile: 'actionEndpointCom/get/sns-out/data.js'
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
67
|
}
|
|
@@ -15,119 +15,185 @@ 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 { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
21
19
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
22
20
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
23
21
|
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
24
22
|
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
25
|
-
import { sns } from
|
|
23
|
+
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
24
|
+
import {
|
|
25
|
+
consts,
|
|
26
|
+
} from '@izara_project/izara-core-library-service-schemas';
|
|
26
27
|
|
|
27
|
-
import { consts } from '@izara_project/izara-core-library-service-schemas';
|
|
28
28
|
const { TOPIC_NAME_GENERATE_CODE } = consts;
|
|
29
|
+
const PREFIX = {
|
|
30
|
+
updateNode: 'updateNode',
|
|
31
|
+
};
|
|
29
32
|
|
|
30
33
|
//(<optionalRequire>)
|
|
31
34
|
//(</optionalRequire>)
|
|
32
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @param {*} returnValue
|
|
38
|
+
* @returns {string}
|
|
39
|
+
*/
|
|
40
|
+
function buildAwaitingStepId(returnValue) {
|
|
41
|
+
const { objType, objInstanceFull } = returnValue.requestParams;
|
|
42
|
+
return asyncFlowSharedLib.createAwaitingStepId(
|
|
43
|
+
hash({
|
|
44
|
+
objectType: objType.objectType,
|
|
45
|
+
serviceTag: objType.serviceTag,
|
|
46
|
+
identifiers: objInstanceFull.identifiers,
|
|
47
|
+
fields: objInstanceFull.fields,
|
|
48
|
+
}),
|
|
49
|
+
PREFIX.updateNode,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {*} returnValue
|
|
55
|
+
* @param {*} status
|
|
56
|
+
* @param {*} errorsFound
|
|
57
|
+
* @returns {object}
|
|
58
|
+
*/
|
|
59
|
+
function buildUpdateCompleteMsg(returnValue, status, errorsFound) {
|
|
60
|
+
const { objType, objInstanceFull } = returnValue.requestParams;
|
|
61
|
+
return {
|
|
62
|
+
objType: {
|
|
63
|
+
objectType: objType.objectType,
|
|
64
|
+
serviceTag: objType.serviceTag,
|
|
65
|
+
},
|
|
66
|
+
objInstanceFull: {
|
|
67
|
+
identifiers: objInstanceFull.identifiers,
|
|
68
|
+
fields: objInstanceFull.fields,
|
|
69
|
+
},
|
|
70
|
+
status,
|
|
71
|
+
errorsFound,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param {*} _izContext
|
|
77
|
+
* @param {*} passBackProperties
|
|
78
|
+
* @param {*} message
|
|
79
|
+
*/
|
|
80
|
+
async function sendSnsMessage(_izContext, passBackProperties, message) {
|
|
81
|
+
const enrichedMessage =
|
|
82
|
+
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
83
|
+
passBackProperties,
|
|
84
|
+
message,
|
|
85
|
+
);
|
|
86
|
+
_izContext.logger.debug(
|
|
87
|
+
'after addCallingFlow to SnsResponseMessageObject',
|
|
88
|
+
enrichedMessage,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const messageAttributes =
|
|
92
|
+
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
93
|
+
passBackProperties,
|
|
94
|
+
{},
|
|
95
|
+
);
|
|
96
|
+
_izContext.logger.debug(
|
|
97
|
+
'after addCallingFlow to SnsResponseMessageAttributes',
|
|
98
|
+
enrichedMessage,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const snsPayload = {
|
|
102
|
+
Message: JSON.stringify(enrichedMessage),
|
|
103
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
104
|
+
_izContext,
|
|
105
|
+
messageAttributes,
|
|
106
|
+
),
|
|
107
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(
|
|
108
|
+
_izContext,
|
|
109
|
+
TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete,
|
|
110
|
+
),
|
|
111
|
+
};
|
|
112
|
+
_izContext.logger.debug(
|
|
113
|
+
'Send Message to OutUpdateNodeComplete::',
|
|
114
|
+
snsPayload,
|
|
115
|
+
);
|
|
116
|
+
await sns.publishAsync(_izContext, snsPayload);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @param {*} _izContext
|
|
121
|
+
* @param {*} returnValue
|
|
122
|
+
* @param {*} status
|
|
123
|
+
* @param {*} errorsFound
|
|
124
|
+
* @param {*} passBackProperties
|
|
125
|
+
*/
|
|
33
126
|
export default async function updateNodeComplete(
|
|
34
127
|
_izContext,
|
|
35
128
|
returnValue,
|
|
36
129
|
status,
|
|
37
130
|
errorsFound,
|
|
38
|
-
passBackProperties = {}
|
|
131
|
+
passBackProperties = {},
|
|
39
132
|
) {
|
|
40
133
|
try {
|
|
41
|
-
_izContext.logger.debug(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
passBackProperties: passBackProperties
|
|
134
|
+
_izContext.logger.debug('Function:updateNodeComplete', {
|
|
135
|
+
returnValue,
|
|
136
|
+
status,
|
|
137
|
+
errorsFound,
|
|
138
|
+
passBackProperties,
|
|
47
139
|
});
|
|
48
140
|
|
|
49
|
-
|
|
50
|
-
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
51
|
-
hash({
|
|
52
|
-
objectType: returnValue.requestParams.objType.objectType,
|
|
53
|
-
serviceTag: returnValue.requestParams.objType.serviceTag,
|
|
54
|
-
identifiers: returnValue.requestParams.objInstanceFull.identifiers,
|
|
55
|
-
fields: returnValue.requestParams.objInstanceFull.fields
|
|
56
|
-
}),
|
|
57
|
-
PREFIX.updateNode
|
|
58
|
-
)
|
|
141
|
+
const awaitingStepId = buildAwaitingStepId(returnValue);
|
|
59
142
|
|
|
60
|
-
|
|
143
|
+
const updateNodePendingObjects = await dynamodbSharedLib.query(
|
|
61
144
|
_izContext,
|
|
62
|
-
await dynamodbSharedLib.tableName(_izContext,
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
145
|
+
await dynamodbSharedLib.tableName(_izContext, 'AwaitingMultipleSteps'),
|
|
146
|
+
{ awaitingStepId },
|
|
147
|
+
);
|
|
148
|
+
_izContext.logger.debug(
|
|
149
|
+
'updateNodePendingObjects',
|
|
150
|
+
updateNodePendingObjects,
|
|
66
151
|
);
|
|
67
|
-
_izContext.logger.debug("updateNodePendingObjects", updateNodePendingObjects);
|
|
68
152
|
|
|
69
153
|
await Promise.all(
|
|
70
154
|
updateNodePendingObjects.Items.map(async ({ pendingStepId }) => {
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
fields: returnValue.requestParams.objInstanceFull.fields
|
|
87
|
-
},
|
|
88
|
-
status: status,
|
|
89
|
-
errorsFound: errorsFound,
|
|
90
|
-
};
|
|
155
|
+
if (
|
|
156
|
+
await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithError(
|
|
157
|
+
_izContext,
|
|
158
|
+
pendingStepId,
|
|
159
|
+
awaitingStepId,
|
|
160
|
+
errorsFound,
|
|
161
|
+
)
|
|
162
|
+
) {
|
|
163
|
+
_izContext.logger.debug('finished all awaitingStep');
|
|
164
|
+
|
|
165
|
+
const updateCompleteMsg = buildUpdateCompleteMsg(
|
|
166
|
+
returnValue,
|
|
167
|
+
status,
|
|
168
|
+
errorsFound,
|
|
169
|
+
);
|
|
91
170
|
|
|
92
171
|
//(<additionalProperties>)
|
|
93
172
|
//(</additionalProperties>)
|
|
94
173
|
|
|
95
|
-
|
|
96
|
-
_izContext.logger.debug("after addCallingFlow to SnsResponseMessageObject", updateCompleteMsg);
|
|
97
|
-
|
|
98
|
-
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
|
|
99
|
-
_izContext.logger.debug("after addCallingFlow to SnsResponseMessageAttributes", updateCompleteMsg);
|
|
100
|
-
|
|
101
|
-
let sendMessageToOutUpdateNodeComplete = {
|
|
102
|
-
Message: JSON.stringify(updateCompleteMsg),
|
|
103
|
-
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
104
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete)
|
|
105
|
-
};
|
|
106
|
-
_izContext.logger.debug("Send Message to OutUpdateNodeComplete::", sendMessageToOutUpdateNodeComplete);
|
|
107
|
-
await sns.publishAsync(_izContext, sendMessageToOutUpdateNodeComplete)
|
|
108
|
-
|
|
174
|
+
await sendSnsMessage(_izContext, passBackProperties, updateCompleteMsg);
|
|
109
175
|
}
|
|
110
176
|
|
|
111
177
|
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
112
178
|
_izContext,
|
|
113
179
|
awaitingStepId,
|
|
114
180
|
pendingStepId,
|
|
115
|
-
errorsFound
|
|
181
|
+
errorsFound,
|
|
116
182
|
);
|
|
117
|
-
})
|
|
118
|
-
)
|
|
183
|
+
}),
|
|
184
|
+
);
|
|
119
185
|
|
|
120
186
|
//(<beforeReturn>)
|
|
121
187
|
//(</beforeReturn>)
|
|
122
188
|
|
|
189
|
+
const { queryResult } = returnValue;
|
|
123
190
|
return {
|
|
124
|
-
objType:
|
|
125
|
-
objInstanceFull:
|
|
126
|
-
errorsFound
|
|
127
|
-
}
|
|
128
|
-
|
|
191
|
+
objType: queryResult.objType,
|
|
192
|
+
objInstanceFull: queryResult.objInstanceFull,
|
|
193
|
+
errorsFound,
|
|
194
|
+
};
|
|
129
195
|
} catch (err) {
|
|
130
|
-
_izContext.logger.error(
|
|
131
|
-
throw
|
|
196
|
+
_izContext.logger.error('error UpdateNodeComplete:', err);
|
|
197
|
+
throw err;
|
|
132
198
|
}
|
|
133
199
|
}
|
package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/sns-out/data.js
CHANGED
|
@@ -57,7 +57,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
|
|
|
57
57
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
58
58
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
59
59
|
fileExtension: '.yml',
|
|
60
|
-
isAppend: true
|
|
60
|
+
isAppend: true,
|
|
61
|
+
fromFile: 'actionEndpointCom/update/sns-out/data.js'
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
}
|