@izara_project/izara-core-generate-service-code 1.0.23 → 1.0.25
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 +10 -7
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/functionYaml/template.ejs +3 -10
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/data.js +2 -1
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/template.ejs +8 -15
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/index.js +1 -1
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/functionYaml/data.js +2 -6
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/functionYaml/template.ejs +4 -11
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/handler/template.ejs +2 -2
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/sns-out/data.js +2 -1
- package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/data.js +1 -5
- package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/template.ejs +12 -21
- package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/handler/template.ejs +1 -3
- package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/functionYaml/data.js +9 -7
- package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/functionYaml/template.ejs +3 -10
- package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/handler/template.ejs +1 -1
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/functionYaml/data.js +1 -0
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/handler/DsqHandlerTemplate.ejs +2 -2
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/handler/SqsHandlerTemplate.ejs +2 -2
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/functionYaml/data.js +5 -8
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/sns-out/data.js +2 -1
- package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/data.js +12 -10
- package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/template.ejs +6 -9
- 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 +17 -17
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/handler/data.js +1 -1
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/relate/sns-out/data.js +3 -1
- package/src/generateCode/generateFlowSchema/event/s3Component/websocket/dynamoDb/ReservedTableData.js +1 -1
- package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/template.ejs +4 -6
- 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/beforeLogical/template.ejs +14 -6
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/create/main/template.ejs +21 -3
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/delete/main/template.ejs +24 -4
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/update/main/template.ejs +25 -4
- 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/mainFunction/template.ejs +1 -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/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
|
@@ -51,12 +51,7 @@ const templatePath = path.join(__dirname, './template.ejs');
|
|
|
51
51
|
* @param {Object} objectSchema
|
|
52
52
|
* @return {{templatePath, templateData,setting}}
|
|
53
53
|
*/
|
|
54
|
-
|
|
55
|
-
async function data(_izContext, flowSchema, srcPath) {
|
|
56
|
-
return [await createSourceParams(_izContext, flowSchema, srcPath)];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
54
|
+
async function createSourceParams(_izContext, flowSchema, appPath) {
|
|
60
55
|
let functionName =
|
|
61
56
|
'TriggerCache' + upperCase(flowSchema.flowTag) + 'Complete';
|
|
62
57
|
let handlerType = upperCase(HANDLER.hdrDsq);
|
|
@@ -81,7 +76,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
81
76
|
.getLocalObjectSchemas(
|
|
82
77
|
_izContext,
|
|
83
78
|
[flowSchema.objType.objectType],
|
|
84
|
-
path.join(
|
|
79
|
+
path.join(appPath, 'src/schemas')
|
|
85
80
|
)
|
|
86
81
|
.then(res => res.records[0]);
|
|
87
82
|
if (!objectSchema) {
|
|
@@ -124,7 +119,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
124
119
|
queueName
|
|
125
120
|
},
|
|
126
121
|
setting: {
|
|
127
|
-
savePath: path.join(
|
|
122
|
+
savePath: path.join(appPath, SOURCE_PATH.appYaml),
|
|
128
123
|
saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
|
|
129
124
|
fileExtension: '.yml',
|
|
130
125
|
isAppend: true
|
|
@@ -132,4 +127,4 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
132
127
|
};
|
|
133
128
|
}
|
|
134
129
|
|
|
135
|
-
export default
|
|
130
|
+
export default createSourceParams;
|
|
@@ -51,12 +51,7 @@ const templatePath = path.join(__dirname, './template.ejs');
|
|
|
51
51
|
* @param {Object} objectSchema
|
|
52
52
|
* @return {{templatePath, templateData,setting}}
|
|
53
53
|
*/
|
|
54
|
-
|
|
55
|
-
async function data(_izContext, flowSchema, srcPath) {
|
|
56
|
-
return [await createSourceParams(_izContext, flowSchema, srcPath)];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
54
|
+
async function createSourceParams(_izContext, flowSchema, appPath) {
|
|
60
55
|
let functionName =
|
|
61
56
|
'TriggerCache' + upperCase(flowSchema.flowTag) + 'Complete';
|
|
62
57
|
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
@@ -81,7 +76,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
81
76
|
.getLocalObjectSchemas(
|
|
82
77
|
_izContext,
|
|
83
78
|
[flowSchema.objType.objectType],
|
|
84
|
-
path.join(
|
|
79
|
+
path.join(appPath, 'src/schemas')
|
|
85
80
|
)
|
|
86
81
|
.then(res => res.records[0]);
|
|
87
82
|
if (!objectSchema) {
|
|
@@ -124,7 +119,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
124
119
|
queueName
|
|
125
120
|
},
|
|
126
121
|
setting: {
|
|
127
|
-
savePath: path.join(
|
|
122
|
+
savePath: path.join(appPath, SOURCE_PATH.appYaml),
|
|
128
123
|
saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
|
|
129
124
|
fileExtension: '.yml',
|
|
130
125
|
isAppend: true
|
|
@@ -132,4 +127,4 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
132
127
|
};
|
|
133
128
|
}
|
|
134
129
|
|
|
135
|
-
export default
|
|
130
|
+
export default createSourceParams;
|
|
@@ -25,7 +25,7 @@ const { SOURCE_PATH, HANDLER } = consts;
|
|
|
25
25
|
const {
|
|
26
26
|
firstLetterLowerCase: lowerCase,
|
|
27
27
|
firstLetterUpperCase: upperCase,
|
|
28
|
-
|
|
28
|
+
savePath
|
|
29
29
|
} = utils;
|
|
30
30
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
31
31
|
|
|
@@ -35,12 +35,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
|
|
|
35
35
|
* @param {Object} objectSchema
|
|
36
36
|
* @return {{templatePath, templateData,setting}}
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
40
|
-
return [createSourceParams(_izContext, flowSchema, srcPath)];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
38
|
+
function createSourceParams(_izContext, flowSchema, appPath) {
|
|
44
39
|
let functionName =
|
|
45
40
|
'TriggerCache' + upperCase(flowSchema.flowTag) + 'Complete';
|
|
46
41
|
let handlerType = upperCase(HANDLER.hdrDsq);
|
|
@@ -54,12 +49,14 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
54
49
|
queueName
|
|
55
50
|
},
|
|
56
51
|
setting: {
|
|
57
|
-
savePath:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
savePath:
|
|
53
|
+
// path.join(
|
|
54
|
+
// appPath,
|
|
55
|
+
// SOURCE_PATH.flowSchema,
|
|
56
|
+
// upperCase(flowSchema.flowTag),
|
|
57
|
+
// 'source/'
|
|
58
|
+
// ),
|
|
59
|
+
savePath.resourceYamlFlowSchemaFlowTag(appPath, flowSchema.flowTag),
|
|
63
60
|
saveFileName: `${upperCase(functionName)}_${upperCase(handlerType)}`,
|
|
64
61
|
fileExtension: '.js',
|
|
65
62
|
isAppend: true
|
|
@@ -67,4 +64,4 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
67
64
|
};
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
export default
|
|
67
|
+
export default createSourceParams;
|
|
@@ -25,7 +25,7 @@ const { SOURCE_PATH, HANDLER } = consts;
|
|
|
25
25
|
const {
|
|
26
26
|
firstLetterLowerCase: lowerCase,
|
|
27
27
|
firstLetterUpperCase: upperCase,
|
|
28
|
-
|
|
28
|
+
savePath
|
|
29
29
|
} = utils;
|
|
30
30
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
31
31
|
|
|
@@ -35,12 +35,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
|
|
|
35
35
|
* @param {Object} objectSchema
|
|
36
36
|
* @return {{templatePath, templateData,setting}}
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
40
|
-
return [createSourceParams(_izContext, flowSchema, srcPath)];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
38
|
+
function createSourceParams(_izContext, flowSchema, appPath) {
|
|
44
39
|
let functionName =
|
|
45
40
|
'TriggerCache' + upperCase(flowSchema.flowTag) + 'Complete';
|
|
46
41
|
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
@@ -54,12 +49,14 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
54
49
|
queueName
|
|
55
50
|
},
|
|
56
51
|
setting: {
|
|
57
|
-
savePath:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
savePath:
|
|
53
|
+
// path.join(
|
|
54
|
+
// appPath,
|
|
55
|
+
// SOURCE_PATH.flowSchema,
|
|
56
|
+
// upperCase(flowSchema.flowTag),
|
|
57
|
+
// 'source/'
|
|
58
|
+
// ),
|
|
59
|
+
savePath.resourceYamlFlowSchemaFlowTag(appPath, flowSchema.flowTag),
|
|
63
60
|
saveFileName: `${upperCase(functionName)}_${upperCase(handlerType)}`,
|
|
64
61
|
fileExtension: '.js',
|
|
65
62
|
isAppend: true
|
|
@@ -67,4 +64,4 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
67
64
|
};
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
export default
|
|
67
|
+
export default createSourceParams;
|
|
@@ -23,8 +23,11 @@ import consts from '#libs/Consts.js';
|
|
|
23
23
|
import utils from '#libs/Utils.js';
|
|
24
24
|
|
|
25
25
|
const { SOURCE_PATH, HANDLER } = consts;
|
|
26
|
-
const {
|
|
27
|
-
|
|
26
|
+
const {
|
|
27
|
+
firstLetterLowerCase: lowerCase,
|
|
28
|
+
firstLetterUpperCase: upperCase,
|
|
29
|
+
savePath
|
|
30
|
+
} = utils;
|
|
28
31
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
29
32
|
|
|
30
33
|
/**
|
|
@@ -34,12 +37,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
|
|
|
34
37
|
* @param {Object} objectSchema
|
|
35
38
|
* @return {{templatePath, templateData,setting}}
|
|
36
39
|
*/
|
|
37
|
-
|
|
38
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
39
|
-
return [createSourceParams(_izContext, flowSchema, srcPath)];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
40
|
+
function createSourceParams(_izContext, flowSchema, appPath) {
|
|
43
41
|
let functionName =
|
|
44
42
|
'TriggerCache' + upperCase(flowSchema.flowTag) + 'Complete';
|
|
45
43
|
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
@@ -54,12 +52,14 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
54
52
|
flowTag: flowSchema.flowTag
|
|
55
53
|
},
|
|
56
54
|
setting: {
|
|
57
|
-
savePath:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
savePath:
|
|
56
|
+
// path.join(
|
|
57
|
+
// appPath,
|
|
58
|
+
// SOURCE_PATH.flowSchema,
|
|
59
|
+
// upperCase(flowSchema.flowTag),
|
|
60
|
+
// 'source/'
|
|
61
|
+
// ),
|
|
62
|
+
savePath.resourceYamlFlowSchemaFlowTag(appPath, flowSchema.flowTag),
|
|
63
63
|
saveFileName: `${upperCase(functionName)}_Main`,
|
|
64
64
|
fileExtension: '.js',
|
|
65
65
|
isAppend: true
|
|
@@ -67,4 +67,4 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export default
|
|
70
|
+
export default createSourceParams;
|
|
@@ -42,15 +42,14 @@ const templatePath = path.join(__dirname, 'template.ejs');
|
|
|
42
42
|
* @param {String} saveFilePath
|
|
43
43
|
* @returns {Object[]} - data of multiple dynamoDb template
|
|
44
44
|
*/
|
|
45
|
-
|
|
46
|
-
function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
|
|
45
|
+
function createDataForDefaultSnsInSqs(_izContext, flowSchema, appPath) {
|
|
47
46
|
let resultsForCreateDefaultSnsInSqs = [];
|
|
48
47
|
let flowTag = upperCase(flowSchema.flowTag);
|
|
49
48
|
let serviceTag = getLocalConfig('iz_serviceTag');
|
|
50
49
|
// console.log("create topic by flowSteps", flowSteps)
|
|
51
50
|
const setting = {
|
|
52
51
|
initialData: 'Resources:\n',
|
|
53
|
-
savePath: path.join(
|
|
52
|
+
savePath: path.join(appPath, SOURCE_PATH.resourceYaml),
|
|
54
53
|
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
55
54
|
fileExtension: '.yml',
|
|
56
55
|
isAppend: true
|
|
@@ -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.checkAllAwaitingStepsFinished(
|
|
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
|
}
|