@izara_project/izara-core-generate-service-code 1.0.23 → 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 +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 +5 -14
- 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/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/lambdaSyncInvComponent/functionYaml/data.js +9 -7
- package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/functionYaml/template.ejs +3 -10
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/functionYaml/data.js +1 -0
- 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 +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 +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 +3 -5
- 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/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/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
|
@@ -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
|
}
|
|
@@ -68,7 +68,7 @@ const HTTP_METHOD = {
|
|
|
68
68
|
* Generates yaml source params for a given action and handler
|
|
69
69
|
* @param {Object} _izContext - Context object with logger
|
|
70
70
|
* @param {Array} allObjSchemas - All object schemas
|
|
71
|
-
* @param {string}
|
|
71
|
+
* @param {string} appPath - Source path
|
|
72
72
|
* @param {string} action - Action name (create/update/get/delete)
|
|
73
73
|
* @param {string} handler - Handler type (hdrApi/hdrSqs/hdrDsq/hdrInv)
|
|
74
74
|
* @param {string|null} functionNameConfig - Override for yaml key (null = derive from action+handler)
|
|
@@ -78,7 +78,7 @@ const HTTP_METHOD = {
|
|
|
78
78
|
async function data(
|
|
79
79
|
_izContext,
|
|
80
80
|
allObjSchemas,
|
|
81
|
-
|
|
81
|
+
appPath,
|
|
82
82
|
action,
|
|
83
83
|
handler,
|
|
84
84
|
handlerSuffix = '',
|
|
@@ -187,7 +187,9 @@ async function data(
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
// ── Service config ────────────────────────────────────────────────────────
|
|
190
|
-
const configPath = path.join(
|
|
190
|
+
const configPath = path.join(appPath, '../config/serverless.config.yml');
|
|
191
|
+
|
|
192
|
+
// console.debug('###### configPath:', configPath);
|
|
191
193
|
const ownServiceTag = yaml.parse(fs.readFileSync(configPath, 'utf8'))
|
|
192
194
|
.main_config.iz_serviceTag;
|
|
193
195
|
|
|
@@ -294,7 +296,7 @@ async function data(
|
|
|
294
296
|
}))
|
|
295
297
|
},
|
|
296
298
|
setting: {
|
|
297
|
-
savePath: path.join(
|
|
299
|
+
savePath: path.join(appPath, SOURCE_PATH.appYaml),
|
|
298
300
|
saveFileName: SAVE_FILE_NAME.functionPerActionYaml,
|
|
299
301
|
fileExtension: '.yml',
|
|
300
302
|
isAppend: true
|
|
@@ -74,7 +74,7 @@ async function data(_izContext, appPath, getObjectTypes) {
|
|
|
74
74
|
objectType,
|
|
75
75
|
schemaPath
|
|
76
76
|
);
|
|
77
|
-
// console.log('objectSchemaRecord: ', objectSchemaRecord);
|
|
77
|
+
// console.log('#### objectSchemaRecord: ', objectSchemaRecord);
|
|
78
78
|
|
|
79
79
|
let objectSchema = objectSchemaRecord.records[0];
|
|
80
80
|
// console.log(("objectSchema: ", objectSchema)
|
|
@@ -56,7 +56,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
|
|
|
56
56
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
57
57
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
58
58
|
fileExtension: '.yml',
|
|
59
|
-
isAppend: true
|
|
59
|
+
isAppend: true,
|
|
60
|
+
fromFile: 'relationShip/changeComplete/sns-out/data.js'
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
}
|
|
@@ -55,7 +55,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
|
|
|
55
55
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
56
56
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
57
57
|
fileExtension: '.yml',
|
|
58
|
-
isAppend: true
|
|
58
|
+
isAppend: true,
|
|
59
|
+
fromFile: 'relationShip/createComplete/sns-out/data.js'
|
|
59
60
|
}
|
|
60
61
|
};
|
|
61
62
|
}
|
|
@@ -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: 'relationShip/deleteComplete/sns-out/data.js'
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
}
|
package/src/generateCode/generateSchema/relationshipPerActionComponent/get/complete/sns-out/data.js
CHANGED
|
@@ -58,7 +58,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
|
|
|
58
58
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
59
59
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
60
60
|
fileExtension: '.yml',
|
|
61
|
-
isAppend: true
|
|
61
|
+
isAppend: true,
|
|
62
|
+
fromFile: 'relationShip/getComplete/sns-out/data.js'
|
|
62
63
|
}
|
|
63
64
|
};
|
|
64
65
|
}
|
|
@@ -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: 'relationShip/moveComplete/sns-out/data.js'
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
}
|
package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/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: 'relationShip/update/sns-out/data.js'
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
67
|
}
|
|
@@ -49,7 +49,8 @@ function createParamsForCreateSource(_izContext, appPath) {
|
|
|
49
49
|
savePath: path.join(appPath, SOURCE_PATH.resourceYaml),
|
|
50
50
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
51
51
|
fileExtension: '.yml',
|
|
52
|
-
isAppend: true
|
|
52
|
+
isAppend: true,
|
|
53
|
+
fromFile: 'relationShip/updateComplete/sns-out/data.js'
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
];
|
|
@@ -69,7 +69,8 @@ function createSourceSnsOut(_izContext, srcPath) {
|
|
|
69
69
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
70
70
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
71
71
|
fileExtension: '.yml',
|
|
72
|
-
isAppend: true
|
|
72
|
+
isAppend: true,
|
|
73
|
+
fromFile: 'resourceYaml/sns-out/data.js'
|
|
73
74
|
}
|
|
74
75
|
});
|
|
75
76
|
}
|
package/src/generateCode/resourceYamlComponent/sns-out/defaultSnsOutForFindDataAndProcessLogical.js
CHANGED
|
@@ -55,7 +55,8 @@ function createDataForDefaultSnsOut(_izContext, srcPath) {
|
|
|
55
55
|
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
56
56
|
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
57
57
|
fileExtension: '.yml',
|
|
58
|
-
isAppend: true
|
|
58
|
+
isAppend: true,
|
|
59
|
+
fromFile: 'resourceYaml/sns-out/defaultSnsOut.js'
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
##--------- [Create Topic Out]
|
|
2
|
-
Out<%-
|
|
2
|
+
Out<%- queueName %>:
|
|
3
3
|
Type: AWS::SNS::Topic
|
|
4
4
|
Properties:
|
|
5
5
|
DisplayName: "SNS Message out"
|
|
6
|
-
TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%-
|
|
7
|
-
|
|
8
|
-
<%_ function firstLetterUpperCase(text) {
|
|
9
|
-
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
10
|
-
} _%>
|
|
6
|
+
TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- queueName %>_Out
|
package/src/generateCode.js
CHANGED
|
@@ -64,6 +64,7 @@ async function generateCodeWithTemplate(
|
|
|
64
64
|
try {
|
|
65
65
|
const startTime = Date.now();
|
|
66
66
|
const appPath = path.join(rootServicePath, '/app');
|
|
67
|
+
const schemasPath = path.join(appPath, '/src/schemas');
|
|
67
68
|
console.info(
|
|
68
69
|
`[INFO] [generateCode] STATUS=START | path=${rootServicePath}`
|
|
69
70
|
);
|
|
@@ -73,15 +74,12 @@ async function generateCodeWithTemplate(
|
|
|
73
74
|
const fetchStartTime = Date.now();
|
|
74
75
|
const [allLocalFlowSchemas, allObjSchemas, allLocalRelationshipSchemas] =
|
|
75
76
|
await Promise.all([
|
|
76
|
-
getObjectSchema.getAllLocalFlowSchemas(_izContext,
|
|
77
|
+
getObjectSchema.getAllLocalFlowSchemas(_izContext, schemasPath),
|
|
77
78
|
getObjectSchema.getAllLocalObjectSchemasWithHierarchy(
|
|
78
79
|
_izContext,
|
|
79
|
-
|
|
80
|
+
schemasPath
|
|
80
81
|
),
|
|
81
|
-
getObjectSchema.getAllLocalRelationshipSchema(
|
|
82
|
-
_izContext,
|
|
83
|
-
rootServicePath
|
|
84
|
-
)
|
|
82
|
+
getObjectSchema.getAllLocalRelationshipSchema(_izContext, schemasPath)
|
|
85
83
|
]);
|
|
86
84
|
|
|
87
85
|
const fetchDuration = Date.now() - fetchStartTime;
|
|
@@ -145,6 +143,7 @@ async function generateCodeWithTemplate(
|
|
|
145
143
|
appPath,
|
|
146
144
|
allCreateSource
|
|
147
145
|
);
|
|
146
|
+
|
|
148
147
|
allCreateSource.push(...createSourceRole);
|
|
149
148
|
const roleStr = `items=${allCreateSource.length} roles=${createSourceRole.length}`;
|
|
150
149
|
console.info(
|
|
@@ -156,6 +155,7 @@ async function generateCodeWithTemplate(
|
|
|
156
155
|
console.info('[INFO] [generateCode] STATUS=VALIDATING| source items...');
|
|
157
156
|
for (const item of allCreateSource) {
|
|
158
157
|
if (!item?.templatePath || !item?.templateData || !item?.setting) {
|
|
158
|
+
console.debug('###### error item:', item);
|
|
159
159
|
throw new Error(
|
|
160
160
|
`[generateCode] invalid source item: ${JSON.stringify(item)}`
|
|
161
161
|
);
|
|
@@ -163,6 +163,8 @@ async function generateCodeWithTemplate(
|
|
|
163
163
|
const { templatePath, templateData, setting } = item;
|
|
164
164
|
setting.checkCreateSourcePass = true;
|
|
165
165
|
|
|
166
|
+
// console.debug('####### item:', item);
|
|
167
|
+
|
|
166
168
|
const [status, errors] = await createSource(
|
|
167
169
|
readFileSync(templatePath, 'utf8'),
|
|
168
170
|
templateData,
|
|
@@ -170,7 +172,7 @@ async function generateCodeWithTemplate(
|
|
|
170
172
|
);
|
|
171
173
|
if (!status) {
|
|
172
174
|
console.error('[generateCode] validation failed:', errors);
|
|
173
|
-
|
|
175
|
+
console.debug('###### item:', item);
|
|
174
176
|
throw new Error(errors);
|
|
175
177
|
}
|
|
176
178
|
|
package/src/libs/Utils.js
CHANGED
|
@@ -18,8 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
import yaml from 'yaml';
|
|
19
19
|
import fs from 'fs';
|
|
20
20
|
import path from 'path';
|
|
21
|
+
|
|
21
22
|
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
22
23
|
|
|
24
|
+
import consts from '#libs/Consts.js';
|
|
25
|
+
const { SOURCE_PATH } = consts;
|
|
26
|
+
|
|
23
27
|
function firstLetterUpperCase(text) {
|
|
24
28
|
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
25
29
|
}
|
|
@@ -128,6 +132,26 @@ function deleteFile(filePath) {
|
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
const savePath = {
|
|
136
|
+
resourceYamlFlowSchemaFlowTag: function (appPath, flowTag) {
|
|
137
|
+
return path.join(
|
|
138
|
+
appPath,
|
|
139
|
+
SOURCE_PATH.flowSchema,
|
|
140
|
+
firstLetterUpperCase(flowTag),
|
|
141
|
+
'MainHandler/',
|
|
142
|
+
'source/'
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
flowSchemaFlowTag: function (flowTag) {
|
|
146
|
+
return path.join(
|
|
147
|
+
SOURCE_PATH.flowSchema,
|
|
148
|
+
firstLetterUpperCase(flowTag),
|
|
149
|
+
'MainHandler/',
|
|
150
|
+
'source/'
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
131
155
|
export default {
|
|
132
156
|
firstLetterUpperCase,
|
|
133
157
|
firstLetterLowerCase,
|
|
@@ -135,5 +159,6 @@ export default {
|
|
|
135
159
|
getLocalConfig,
|
|
136
160
|
checkValidTableYaml,
|
|
137
161
|
deleteFileInDir,
|
|
138
|
-
deleteFile
|
|
162
|
+
deleteFile,
|
|
163
|
+
savePath
|
|
139
164
|
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
-
|
|
4
|
-
This program is free software: you can redistribute it and/or modify
|
|
5
|
-
it under the terms of the GNU Affero General Public License as
|
|
6
|
-
published by the Free Software Foundation, either version 3 of the
|
|
7
|
-
License, or (at your option) any later version.
|
|
8
|
-
|
|
9
|
-
This program is distributed in the hope that it will be useful,
|
|
10
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
GNU Affero General Public License for more details.
|
|
13
|
-
|
|
14
|
-
You should have received a copy of the GNU Affero General Public License
|
|
15
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import path from 'path';
|
|
19
|
-
import { fileURLToPath } from 'url';
|
|
20
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
-
const __dirname = path.dirname(__filename);
|
|
22
|
-
|
|
23
|
-
import consts from '../../../../../../libs/Consts.js';
|
|
24
|
-
import utils from '../../../../../../libs/Utils.js';
|
|
25
|
-
|
|
26
|
-
const { SOURCE_PATH, HANDLER } = consts;
|
|
27
|
-
const { firstLetterUpperCase: upperCase } = utils;
|
|
28
|
-
|
|
29
|
-
const templatePath = path.join(__dirname, 'template.ejs');
|
|
30
|
-
/**
|
|
31
|
-
* receive objectSchema
|
|
32
|
-
* create data for WebScoket handler template
|
|
33
|
-
*
|
|
34
|
-
* @param {Object} objectSchema
|
|
35
|
-
* @return {{templatePath, templateData,setting}}
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
39
|
-
let functionName = 'Process' + upperCase(flowSchema.flowTag);
|
|
40
|
-
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
41
|
-
let queueName = 'Process' + upperCase(flowSchema.flowTag) + handlerType;
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
templatePath: templatePath,
|
|
45
|
-
templateData: {
|
|
46
|
-
functionName,
|
|
47
|
-
handlerType,
|
|
48
|
-
queueName
|
|
49
|
-
},
|
|
50
|
-
setting: {
|
|
51
|
-
savePath: path.join(
|
|
52
|
-
srcPath,
|
|
53
|
-
SOURCE_PATH.flowSchema,
|
|
54
|
-
upperCase(flowSchema.flowTag),
|
|
55
|
-
'source/'
|
|
56
|
-
),
|
|
57
|
-
saveFileName: `${functionName}_${handlerType}`,
|
|
58
|
-
fileExtension: '.js',
|
|
59
|
-
isAppend: false
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default createSourceParams;
|