@izara_project/izara-market-library-service-schemas 1.0.54 → 1.0.56
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/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -0
- package/src/reStructure/TemplateData/Auth/generateAuthYml/template.ejs +15 -16
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +13 -14
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +14 -11
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +9 -11
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +16 -13
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +41 -17
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +39 -21
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +43 -8
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +29 -9
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +21 -15
- package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +14 -10
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +21 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +8 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +45 -55
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +5 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +4 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +35 -40
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/template.ejs +3 -17
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +391 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +9 -317
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +5 -5
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +8 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaMainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaMainFunction/template.ejs +5 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +28 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +11 -11
- package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +1 -0
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +28 -26
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +10 -1
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +3 -0
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/templateByStatusType/storedCacheTemplate.ejs +3 -0
- package/src/reStructure/TemplateData/flowSchema/templateByStatusType/triggerCacheTemplate.ejs +3 -0
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/handler/template.ejs +4 -0
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +36 -7
- package/src/reStructure/TemplateData/perActionEndpoint/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/perActionEndpoint/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/perActionEndpoint/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/data.js +10 -2
- package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/template.ejs +1 -1
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +1 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +9 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +6 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/template.ejs +23 -23
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/template.ejs +18 -16
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/template.ejs +14 -12
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/template.ejs +21 -19
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +3 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/api/template.ejs +24 -22
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/dsq/template.ejs +21 -17
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/inv/template.ejs +21 -19
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/sqs/template.ejs +20 -20
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/handler/sqs/template.ejs +1 -1
|
@@ -16,7 +16,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
|
+
|
|
19
20
|
const path = require('path');
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const yaml = require('yaml');
|
|
20
23
|
|
|
21
24
|
const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
25
|
const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
|
|
@@ -56,6 +59,11 @@ function createSourceParamsApi(_izContext, flowSchema, srcPath) {
|
|
|
56
59
|
let handlerType = upperCase(HANDLER.hdrApi)
|
|
57
60
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
58
61
|
|
|
62
|
+
const configPath = path.join(srcPath, '../../config/serverless.config.yml');
|
|
63
|
+
const serverlessConfig = fs.readFileSync(configPath, 'utf8');
|
|
64
|
+
const config = yaml.parse(serverlessConfig);
|
|
65
|
+
const serviceTag = config.main_config.iz_serviceTag;
|
|
66
|
+
|
|
59
67
|
return {
|
|
60
68
|
templatePath: templatePath,
|
|
61
69
|
templateData: {
|
|
@@ -65,7 +73,8 @@ function createSourceParamsApi(_izContext, flowSchema, srcPath) {
|
|
|
65
73
|
additionalResourcePermission,
|
|
66
74
|
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
67
75
|
roleName: upperCase(flowSchema.flowTag),
|
|
68
|
-
event: "post"
|
|
76
|
+
event: "post",
|
|
77
|
+
serviceTag: serviceTag
|
|
69
78
|
},
|
|
70
79
|
setting: {
|
|
71
80
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
6
6
|
- httpApi:
|
|
7
|
-
path: /<%- firstLetterLowerCase(functionName)
|
|
7
|
+
path: /<%- serviceTag %>/<%- firstLetterLowerCase(functionName) %>/<%- functionName %>
|
|
8
8
|
method: <%- event %>
|
|
9
9
|
authorizer: authorizerServiceSchema
|
|
10
10
|
#<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
|
|
11
11
|
#<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
|
|
12
12
|
- httpApi:
|
|
13
|
-
path: /<%- firstLetterLowerCase(functionName) %>/{targetUserId}
|
|
13
|
+
path: /<%- serviceTag %>/<%- firstLetterLowerCase(functionName) %>/<%- functionName %>/{targetUserId}
|
|
14
14
|
method: <%- event %>
|
|
15
15
|
authorizer: authorizerServiceSchema
|
|
16
16
|
#<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
|
|
@@ -52,6 +52,9 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
|
|
|
52
52
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
53
53
|
passOnProperties.push(record.body.TopicArn)
|
|
54
54
|
passOnProperties.push(record.body.Message)
|
|
55
|
+
//(<additionalParams>)
|
|
56
|
+
//(</additionalParams>)
|
|
57
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
55
58
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
56
59
|
|
|
57
60
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
@@ -53,9 +53,9 @@ module.exports.registerCompleteMain = async (
|
|
|
53
53
|
_izContext,
|
|
54
54
|
topicArn,
|
|
55
55
|
requestParams,
|
|
56
|
-
callingFlowConfig = {},
|
|
57
56
|
//(<additionalParams>)
|
|
58
57
|
//(</additionalParams>)
|
|
58
|
+
callingFlowConfig = {},
|
|
59
59
|
) => {
|
|
60
60
|
try {
|
|
61
61
|
_izContext.logger.debug("WebSocketInvoke _izContext", _izContext)
|
package/src/reStructure/TemplateData/flowSchema/templateByStatusType/storedCacheTemplate.ejs
CHANGED
|
@@ -5,6 +5,9 @@ let [ cacheMainStatus, cacheMain, cacheExist ] = await storedCacheSharedLib.chec
|
|
|
5
5
|
//(<keyValueStoredCacheTable>)
|
|
6
6
|
//(</keyValueStoredCacheTable>)
|
|
7
7
|
},
|
|
8
|
+
//(<additionalAttributesWhenCreateStoredCache>)
|
|
9
|
+
//(</additionalAttributesWhenCreateStoredCache>),
|
|
10
|
+
createFlowTypeConcat(_izContext,{flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag}),
|
|
8
11
|
//(<storedCacheConfig>)
|
|
9
12
|
//(</storedCacheConfig>)
|
|
10
13
|
)
|
package/src/reStructure/TemplateData/flowSchema/templateByStatusType/triggerCacheTemplate.ejs
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
//(<keyValueTriggerCacheTable>)
|
|
6
6
|
//(</keyValueTriggerCacheTable>)
|
|
7
7
|
},
|
|
8
|
+
//(<additionalAttributesWhenCreateTriggerCache>)
|
|
9
|
+
//(</additionalAttributesWhenCreateTriggerCache>)
|
|
10
|
+
createFlowTypeConcat(_izContext,{flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag}),
|
|
8
11
|
//(<triggerCacheConfig>)
|
|
9
12
|
//(</triggerCacheConfig>)
|
|
10
13
|
)
|
|
@@ -51,7 +51,11 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
54
|
+
passOnProperties.push(record.body.TopicArn)
|
|
54
55
|
passOnProperties.push(record.body.Message)
|
|
56
|
+
//(<additionalParams>)
|
|
57
|
+
//(</additionalParams>)
|
|
58
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
55
59
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
56
60
|
|
|
57
61
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
@@ -56,10 +56,11 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
|
|
|
56
56
|
|
|
57
57
|
module.exports.<%- functionName %> = async (
|
|
58
58
|
_izContext,
|
|
59
|
+
topicArn,
|
|
59
60
|
requestParams,
|
|
60
|
-
callingFlowConfig = {},
|
|
61
61
|
//(<additionalParams>)
|
|
62
62
|
//(</additionalParams>)
|
|
63
|
+
callingFlowConfig = {},
|
|
63
64
|
) => {
|
|
64
65
|
|
|
65
66
|
try {
|
|
@@ -68,15 +69,43 @@ module.exports.<%- functionName %> = async (
|
|
|
68
69
|
_izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
|
|
69
70
|
|
|
70
71
|
let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID);
|
|
72
|
+
if (!topicArn) {
|
|
73
|
+
throw new NoRetryError('not have TopicArn for get FlowSchemas')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let topicName = topicArn.spilt(":")[5].split("_")
|
|
71
77
|
|
|
78
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
79
|
+
flowTag: topicName[2],
|
|
80
|
+
serviceTag: topicName[0]
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
//(<createIdentifiersFlow>)
|
|
84
|
+
let identifiers
|
|
85
|
+
//(</createIdentifiersFlow>)
|
|
86
|
+
|
|
87
|
+
if (!flowSchema) {
|
|
88
|
+
throw new NoRetryError("not have flowSchema in S3")
|
|
89
|
+
}
|
|
72
90
|
|
|
73
|
-
let wbsTasks
|
|
74
|
-
|
|
75
|
-
await dynamodbSharedLib.
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
let wbsTasks;
|
|
92
|
+
if (flowSchema.statusType === "statusField" || flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
|
|
93
|
+
wbsTasks = await dynamodbSharedLib.query(
|
|
94
|
+
_izContext,
|
|
95
|
+
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
96
|
+
{
|
|
97
|
+
taskKey: `${createFlowTypeConcat(_izContext,{flowTag: topicName[2],serviceTag: topicName[0]})}${identifiers}`
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
} else if (flowSchema.statusType === "none") {
|
|
101
|
+
wbsTasks = await dynamodbSharedLib.query(
|
|
102
|
+
_izContext,
|
|
103
|
+
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
104
|
+
{
|
|
105
|
+
taskKey: correlationId,
|
|
106
|
+
}
|
|
107
|
+
)
|
|
78
108
|
}
|
|
79
|
-
)
|
|
80
109
|
|
|
81
110
|
if (wbsTasks.Items.length) {
|
|
82
111
|
await Promise.all(wbsTasks.Items.map(async ({ connectionId }) => {
|
|
@@ -29,8 +29,8 @@ const {
|
|
|
29
29
|
const <%- functionName %> =require('./<%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(action) %>_Main')
|
|
30
30
|
<%_ } _%>
|
|
31
31
|
|
|
32
|
-
//(<
|
|
33
|
-
//</
|
|
32
|
+
//(<globalVariable>
|
|
33
|
+
//</globalVariable>)
|
|
34
34
|
|
|
35
35
|
//validate event params in middleware before into main function
|
|
36
36
|
validateSchemaMiddleware(
|
|
@@ -29,8 +29,8 @@ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record
|
|
|
29
29
|
const <%- functionName %> =require('./<%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(action) %>_Main')
|
|
30
30
|
<%_ } _%>
|
|
31
31
|
|
|
32
|
-
//(<
|
|
33
|
-
//</
|
|
32
|
+
//(<globalVariable>
|
|
33
|
+
//</globalVariable>)
|
|
34
34
|
|
|
35
35
|
//validate event params in middleware before into main function
|
|
36
36
|
middleware.setValidatorSchema(
|
|
@@ -29,8 +29,8 @@ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record
|
|
|
29
29
|
const <%- functionName %> =require('./<%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(action) %>_Main')
|
|
30
30
|
<%_ } _%>
|
|
31
31
|
|
|
32
|
-
//(<
|
|
33
|
-
//</
|
|
32
|
+
//(<globalVariable>
|
|
33
|
+
//</globalVariable>)
|
|
34
34
|
|
|
35
35
|
//validate event params in middleware before into main function
|
|
36
36
|
middleware.setValidatorSchema(
|
|
@@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
20
|
const path = require('path');
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const yaml = require('yaml');
|
|
21
23
|
|
|
22
24
|
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
25
|
|
|
@@ -56,14 +58,14 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
56
58
|
let createSourceArray = [];
|
|
57
59
|
for (const action of Object.values(ACTIONS)) {
|
|
58
60
|
if (objectSchema.overWriteHandlers?.[action]) {
|
|
59
|
-
// if have
|
|
61
|
+
// if have overWriteHandler of action check hdrApi inside
|
|
60
62
|
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrApi)) {
|
|
61
63
|
// create template data
|
|
62
64
|
const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
|
|
63
65
|
createSourceArray.push(createSourceParam)
|
|
64
66
|
}
|
|
65
67
|
} else {
|
|
66
|
-
// if not have
|
|
68
|
+
// if not have overWriteHandler of action will use default handler
|
|
67
69
|
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
68
70
|
if (defaultHandler.includes(HANDLER.hdrApi)) {
|
|
69
71
|
// create template data and object for create source
|
|
@@ -86,6 +88,11 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
86
88
|
let functionNameObjectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType
|
|
87
89
|
let functionNameConfig = upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrApi))
|
|
88
90
|
|
|
91
|
+
const configPath = path.join(srcPath, '../../config/serverless.config.yml');
|
|
92
|
+
const serverlessConfig = fs.readFileSync(configPath, 'utf8');
|
|
93
|
+
const config = yaml.parse(serverlessConfig);
|
|
94
|
+
const serviceTag = config.main_config.iz_serviceTag;
|
|
95
|
+
|
|
89
96
|
for (let storageResource of Object.values(objectSchema.storageResources)) {
|
|
90
97
|
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
91
98
|
// add IamRole for dynamodb depend on tableName in storageResources of objectSchema
|
|
@@ -184,6 +191,7 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
|
|
|
184
191
|
roleName: groupBy,
|
|
185
192
|
action: action,
|
|
186
193
|
functionNameConfig,
|
|
194
|
+
serviceTag: serviceTag
|
|
187
195
|
},
|
|
188
196
|
setting: {
|
|
189
197
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
6
6
|
- http:
|
|
7
|
-
path:
|
|
7
|
+
path: /<%- serviceTag%>/<%- firstLetterUpperCase(objectType) %>/<%- firstLetterUpperCase(action) %>
|
|
8
8
|
method: <%- event %>
|
|
9
9
|
cors: true
|
|
10
10
|
#<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
|
package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js
CHANGED
|
@@ -88,8 +88,7 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
88
88
|
// const objectType = objectSchema.objectType; // main objectType
|
|
89
89
|
let propertyValue = settings.propertyValueTag
|
|
90
90
|
const storageResources = objectSchema.storageResources // storageResource from main objectType
|
|
91
|
-
const serviceTag = getLocalConfig(srcPath, "iz_serviceTag")
|
|
92
|
-
|
|
91
|
+
const serviceTag = getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag")
|
|
93
92
|
attributeRelationships.push(
|
|
94
93
|
{ // has{objectType}propertyValue
|
|
95
94
|
relationshipTag: PREFIX_RELATIONSHIP.has + upperCase(propertyValue) + PROPERTY_VALUE_TAG.property,
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/api/template.ejs
CHANGED
|
@@ -89,8 +89,8 @@ let validatorSchema = {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
//(<
|
|
93
|
-
//</
|
|
92
|
+
//(<globalVariable>
|
|
93
|
+
//</globalVariable>)
|
|
94
94
|
|
|
95
95
|
// validate event params in middleware before into main function
|
|
96
96
|
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/dsq/template.ejs
CHANGED
|
@@ -110,8 +110,8 @@ let validatorSchema = {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
//(<
|
|
114
|
-
//</
|
|
113
|
+
//(<globalVariable>
|
|
114
|
+
//</globalVariable>)
|
|
115
115
|
|
|
116
116
|
// validate event params in middleware before into main function
|
|
117
117
|
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/sqs/template.ejs
CHANGED
|
@@ -94,8 +94,8 @@ let validatorSchema = {
|
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
|
|
97
|
-
//(<
|
|
98
|
-
//</
|
|
97
|
+
//(<globalVariable>
|
|
98
|
+
//</globalVariable>)
|
|
99
99
|
|
|
100
100
|
// validate event params in middleware before into main function
|
|
101
101
|
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs
CHANGED
|
@@ -348,7 +348,15 @@ module.exports.createRelationship = async (
|
|
|
348
348
|
_izContext,
|
|
349
349
|
awaitingStepIds, // awaitingStepIds
|
|
350
350
|
asyncFlowSharedLib.createPendingStepId( // pendingStepId
|
|
351
|
-
hash({
|
|
351
|
+
hash({
|
|
352
|
+
linkTypeId,
|
|
353
|
+
relationshipProperties,
|
|
354
|
+
correlationId: _izContext.correlationIds.get("id"),
|
|
355
|
+
callingFlowProperties: callingFlowConfig.callingFlowProperties || {},
|
|
356
|
+
firstObject: firstObject,
|
|
357
|
+
secondObject: secondObject,
|
|
358
|
+
relType: relType
|
|
359
|
+
}), // hash id
|
|
352
360
|
PREFIX.createRel // prefix, use constant further
|
|
353
361
|
)
|
|
354
362
|
);
|
package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs
CHANGED
|
@@ -93,7 +93,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
93
93
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
94
94
|
passOnProperties.push(record.body.Message.returnValue)
|
|
95
95
|
passOnProperties.push(record.body.Message.status)
|
|
96
|
-
passOnProperties.push(record.body.Message.errorsFound)
|
|
96
|
+
passOnProperties.push(record.body.Message.errorsFound),
|
|
97
|
+
passOnProperties.push(record.body.Message.graphServiceTag),
|
|
97
98
|
passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message)) // is Ok PassBackProperties
|
|
98
99
|
// passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)) // is Ok callinfFlow
|
|
99
100
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs
CHANGED
|
@@ -34,8 +34,10 @@ const {
|
|
|
34
34
|
TOPIC_NAME_GRAPH_HANDLER,
|
|
35
35
|
PREFIX
|
|
36
36
|
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
37
|
+
|
|
37
38
|
//(<optionalRequire>)
|
|
38
39
|
//(</optionalRequire>)
|
|
40
|
+
|
|
39
41
|
module.exports.createRelationshipComplete = async (
|
|
40
42
|
_izContext,
|
|
41
43
|
returnValue,
|
|
@@ -122,6 +124,8 @@ module.exports.createRelationshipComplete = async (
|
|
|
122
124
|
_izContext.logger.debug("Send message to OutCreateRelationshipComplete :::>", sendMessageToOutCreateRelationshipComplete);
|
|
123
125
|
await sns.publishAsync(_izContext, sendMessageToOutCreateRelationshipComplete);
|
|
124
126
|
|
|
127
|
+
//(<afterCheckAwaitingStep>)
|
|
128
|
+
//(</afterCheckAwaitingStep>)
|
|
125
129
|
} // check pendingStepId finished
|
|
126
130
|
|
|
127
131
|
// remove awaitingMultipleStep after finished
|
|
@@ -134,6 +138,8 @@ module.exports.createRelationshipComplete = async (
|
|
|
134
138
|
}) // end per pendingStep
|
|
135
139
|
);
|
|
136
140
|
|
|
141
|
+
//(<afterCheckAllAwaitingStep>)
|
|
142
|
+
//(</afterCheckAllAwaitingStep>)
|
|
137
143
|
|
|
138
144
|
return {
|
|
139
145
|
returnValue,
|
package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/api/template.ejs
CHANGED
|
@@ -89,8 +89,8 @@ let validatorSchema = {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
//(<
|
|
93
|
-
//</
|
|
92
|
+
//(<globalVariable>
|
|
93
|
+
//</globalVariable>)
|
|
94
94
|
|
|
95
95
|
// validate event params in middleware before into main function
|
|
96
96
|
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs
CHANGED
|
@@ -110,8 +110,8 @@ let validatorSchema = {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
//(<
|
|
114
|
-
//</
|
|
113
|
+
//(<globalVariable>
|
|
114
|
+
//</globalVariable>)
|
|
115
115
|
|
|
116
116
|
// validate event params in middleware before into main function
|
|
117
117
|
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs
CHANGED
|
@@ -90,8 +90,8 @@ let validatorSchema = {
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
//(<
|
|
94
|
-
//</
|
|
93
|
+
//(<globalVariable>
|
|
94
|
+
//</globalVariable>)
|
|
95
95
|
|
|
96
96
|
// validate event params in middleware before into main function
|
|
97
97
|
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/template.ejs
CHANGED
|
@@ -16,16 +16,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
|
-
|
|
20
|
-
const
|
|
19
|
+
|
|
20
|
+
const { middlewareHandler, validatorSchema, response } = require("@izara_project/izara-middleware");
|
|
21
21
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
|
|
23
|
+
//(<optionalRequire>)
|
|
24
|
+
//(</optionalRequire>)
|
|
25
25
|
|
|
26
26
|
const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// validate event params in middlewareHandler before into function
|
|
30
|
+
let basicValidatorSchema = {
|
|
29
31
|
type: "object",
|
|
30
32
|
required: ["firstObject", "secondObject", "relType", 'relId'],
|
|
31
33
|
properties: {
|
|
@@ -37,8 +39,8 @@ let validatorSchema = {
|
|
|
37
39
|
type: "object",
|
|
38
40
|
required: ["serviceTag", "objectType"],
|
|
39
41
|
properties: {
|
|
40
|
-
serviceTag:
|
|
41
|
-
objectType:
|
|
42
|
+
serviceTag: validatorSchema.stringNotEmpty(),
|
|
43
|
+
objectType: validatorSchema.stringNotEmpty()
|
|
42
44
|
}
|
|
43
45
|
},
|
|
44
46
|
identifiers: {
|
|
@@ -55,8 +57,8 @@ let validatorSchema = {
|
|
|
55
57
|
type: "object",
|
|
56
58
|
required: ["serviceTag", "objectType"],
|
|
57
59
|
properties: {
|
|
58
|
-
serviceTag:
|
|
59
|
-
objectType:
|
|
60
|
+
serviceTag: validatorSchema.stringNotEmpty(),
|
|
61
|
+
objectType: validatorSchema.stringNotEmpty()
|
|
60
62
|
}
|
|
61
63
|
},
|
|
62
64
|
identifiers: {
|
|
@@ -69,7 +71,7 @@ let validatorSchema = {
|
|
|
69
71
|
type: "object",
|
|
70
72
|
required: ["relationshipTag", "serviceTag"],
|
|
71
73
|
properties: {
|
|
72
|
-
relationshipTag:
|
|
74
|
+
relationshipTag: validatorSchema.stringNotEmpty(),
|
|
73
75
|
serviceTag: {
|
|
74
76
|
type: 'string',
|
|
75
77
|
pattern: "^[a-zA-Z0-9_-]+$",
|
|
@@ -87,21 +89,19 @@ let validatorSchema = {
|
|
|
87
89
|
}
|
|
88
90
|
};
|
|
89
91
|
|
|
92
|
+
//(<globalVariable>
|
|
93
|
+
//</globalVariable>)
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// validate event params in middleware before into main function
|
|
96
|
-
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
|
97
|
-
middleware.setValidatorSchema(validatorSchema)
|
|
95
|
+
// validate event params in middlewareHandler before into main function
|
|
96
|
+
basicValidatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(basicValidatorSchema);
|
|
97
|
+
middlewareHandler.setValidatorSchema(basicValidatorSchema)
|
|
98
98
|
// if need to validate authorizer or additional params , add code to hook tag below
|
|
99
99
|
|
|
100
100
|
//(<afterValidateWith>)
|
|
101
101
|
//(</afterValidateWith>)
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
module.exports.main =
|
|
104
|
+
module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
|
|
105
105
|
event._izContext.logger.debug('Event:', event);
|
|
106
106
|
try {
|
|
107
107
|
// invoke LambdaFunction
|
|
@@ -119,15 +119,15 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
119
119
|
|
|
120
120
|
// return error to client
|
|
121
121
|
if (lambdaFunctionResponse instanceof Error) {
|
|
122
|
-
return (
|
|
122
|
+
return (response.failure(lambdaFunctionResponse));
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// return success to client
|
|
126
|
-
return (
|
|
126
|
+
return (response.success(lambdaFunctionResponse));
|
|
127
127
|
|
|
128
128
|
} catch (err) {
|
|
129
129
|
event._izContext.logger.error('Error, <%- functionName %>HdrApi: ', err);
|
|
130
|
-
return (
|
|
130
|
+
return (response.failure(err));
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
133
|
<%_ function firstLetterUpperCase(text) {
|
package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/template.ejs
CHANGED
|
@@ -17,8 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
const middleware = izara.middlewareHandler;
|
|
20
|
+
const { middlewareHandler, validatorSchema, response } = require("@izara_project/izara-middleware");
|
|
22
21
|
|
|
23
22
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
24
23
|
|
|
@@ -27,10 +26,13 @@ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-
|
|
|
27
26
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
28
27
|
const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
|
|
29
28
|
|
|
29
|
+
//(<optionalRequire>)
|
|
30
|
+
//(</optionalRequire>)
|
|
30
31
|
|
|
31
32
|
const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
|
|
33
|
+
|
|
32
34
|
// validate event properties in body.Message of sqs event
|
|
33
|
-
|
|
35
|
+
middlewareHandler.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
|
|
34
36
|
{
|
|
35
37
|
type: "object",
|
|
36
38
|
required: ['body', 'messageAttributes'],
|
|
@@ -45,8 +47,8 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
|
|
|
45
47
|
}
|
|
46
48
|
));
|
|
47
49
|
|
|
48
|
-
// validate event params in
|
|
49
|
-
let
|
|
50
|
+
// validate event params in middleware before into function.
|
|
51
|
+
let basicValidatorSchema = {
|
|
50
52
|
type: "object",
|
|
51
53
|
required: ["firstObject", "secondObject", "relType", 'relId'],
|
|
52
54
|
properties: {
|
|
@@ -58,8 +60,8 @@ let validatorSchema = {
|
|
|
58
60
|
type: "object",
|
|
59
61
|
required: ["serviceTag", "objectType"],
|
|
60
62
|
properties: {
|
|
61
|
-
serviceTag:
|
|
62
|
-
objectType:
|
|
63
|
+
serviceTag: validatorSchema.stringNotEmpty(),
|
|
64
|
+
objectType: validatorSchema.stringNotEmpty()
|
|
63
65
|
}
|
|
64
66
|
},
|
|
65
67
|
identifiers: {
|
|
@@ -76,8 +78,8 @@ let validatorSchema = {
|
|
|
76
78
|
type: "object",
|
|
77
79
|
required: ["serviceTag", "objectType"],
|
|
78
80
|
properties: {
|
|
79
|
-
serviceTag:
|
|
80
|
-
objectType:
|
|
81
|
+
serviceTag: validatorSchema.stringNotEmpty(),
|
|
82
|
+
objectType: validatorSchema.stringNotEmpty()
|
|
81
83
|
}
|
|
82
84
|
},
|
|
83
85
|
identifiers: {
|
|
@@ -90,7 +92,7 @@ let validatorSchema = {
|
|
|
90
92
|
type: "object",
|
|
91
93
|
required: ["relationshipTag", "serviceTag"],
|
|
92
94
|
properties: {
|
|
93
|
-
relationshipTag:
|
|
95
|
+
relationshipTag: validatorSchema.stringNotEmpty(),
|
|
94
96
|
serviceTag: {
|
|
95
97
|
type: 'string',
|
|
96
98
|
pattern: "^[a-zA-Z0-9_-]+$",
|
|
@@ -109,18 +111,18 @@ let validatorSchema = {
|
|
|
109
111
|
};
|
|
110
112
|
|
|
111
113
|
|
|
112
|
-
//(<
|
|
113
|
-
|
|
114
|
+
//(<globalVariable>
|
|
115
|
+
//</globalVariable>)
|
|
114
116
|
|
|
115
|
-
// validate event params in
|
|
116
|
-
|
|
117
|
+
// validate event params in middlewareHandler before into main function
|
|
118
|
+
basicValidatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(basicValidatorSchema);
|
|
117
119
|
// if need to validate authorizer or additional params , add code to hook tag below
|
|
118
120
|
|
|
119
121
|
//(<afterValidateWith>)
|
|
120
122
|
//(</afterValidateWith>)
|
|
121
123
|
|
|
122
124
|
|
|
123
|
-
module.exports.main =
|
|
125
|
+
module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
|
|
124
126
|
Logger.debug('event:', event);
|
|
125
127
|
Logger.debug('context:', context);
|
|
126
128
|
try {
|
|
@@ -140,7 +142,7 @@ let validatorSchema = {
|
|
|
140
142
|
await recordHandlerSharedLib.validateRecord(
|
|
141
143
|
record, // one record will send to mainFunction
|
|
142
144
|
"<%- queueName %>", // queue name that need to retry or send to dlq
|
|
143
|
-
|
|
145
|
+
basicValidatorSchema, // schema for record.Message
|
|
144
146
|
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
145
147
|
);
|
|
146
148
|
|