@izara_project/izara-market-library-service-schemas 1.0.53 → 1.0.55
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 +2 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -1
- package/src/reStructure/TemplateConfig.js +4 -1
- package/src/reStructure/TemplateData/Auth/generateAuthYml/data.js +58 -0
- package/src/reStructure/TemplateData/Auth/generateAuthYml/template.ejs +16 -0
- package/src/reStructure/TemplateData/Auth/generateTemplateData.js +51 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -1
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +2 -1
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +2 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +78 -54
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +42 -22
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +44 -9
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +30 -10
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +6 -3
- package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +12 -16
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +22 -6
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +4 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/functionYaml/data.js +14 -11
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/data.js +2 -47
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +4 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +9 -13
- package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/data.js +6 -6
- package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/template.ejs +11 -14
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +12 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +6 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +8 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/template.ejs +2 -7
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +22 -24
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +11 -2
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/template.ejs +11 -5
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/handler/template.ejs +27 -23
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/template.ejs +10 -4
- package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/storedCacheTemplate.ejs +3 -0
- package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/triggerCacheTemplate.ejs +3 -0
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +0 -1
- 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/relationshipPerAction/create/action/mainFunction/template.ejs +18 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +5 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/data.js +0 -75
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/template.ejs +0 -98
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +0 -52
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/mainFunction/data.js +0 -57
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/mainFunction/template.ejs +0 -81
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/mainFunction/data.js +0 -58
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/mainFunction/template.ejs +0 -81
- /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/statusFieldTemplate.ejs +0 -0
|
@@ -18,28 +18,48 @@ along with this program. If not, see
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
+
// ==================== Shared Core Utilities ====================
|
|
21
22
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
23
|
+
const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// ==================== Core Service Schemas ====================
|
|
22
27
|
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
23
28
|
const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
29
|
+
const { createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// ==================== Market Service Schemas ====================
|
|
24
33
|
const {
|
|
25
34
|
dynamoDbIdentifiersByStorageResource,
|
|
26
|
-
createFieldForUpdateDynamoDb
|
|
35
|
+
createFieldForUpdateDynamoDb,
|
|
36
|
+
createUpdateDataDetail,
|
|
27
37
|
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
PREFIX,
|
|
41
|
+
TOPIC_NAME_GENERATE_CODE,
|
|
42
|
+
TOPIC_NAME_GRAPH_HANDLER,
|
|
43
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// ==================== Shared Libraries ====================
|
|
28
47
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
29
48
|
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
30
49
|
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
31
50
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
32
51
|
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
33
52
|
|
|
53
|
+
|
|
54
|
+
// ==================== External Services ====================
|
|
34
55
|
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
35
|
-
const sns = externalRequest.sns
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//(</optionalRequire>)
|
|
56
|
+
const sns = externalRequest.sns;
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// ==================== Optional Requires ====================
|
|
60
|
+
// (<optionalRequire>)
|
|
61
|
+
// (</optionalRequire>)
|
|
62
|
+
|
|
43
63
|
/**
|
|
44
64
|
*
|
|
45
65
|
*
|
|
@@ -58,9 +78,9 @@ const { createObjType } = require("@izara_project/izara-core-library-service-sch
|
|
|
58
78
|
module.exports.updateMain = async (
|
|
59
79
|
_izContext,
|
|
60
80
|
requestParams,
|
|
61
|
-
callingFlowConfig = {},
|
|
62
81
|
//(<additionalParams>)
|
|
63
82
|
//(</additionalParams>)
|
|
83
|
+
callingFlowConfig = {},
|
|
64
84
|
) => {
|
|
65
85
|
|
|
66
86
|
try {
|
|
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20
20
|
const path = require('path');
|
|
21
21
|
const fs = require('fs');
|
|
22
22
|
const yaml = require('yaml');
|
|
23
|
+
|
|
23
24
|
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
24
25
|
const {
|
|
25
26
|
DEFAULT_HANDLER_PER_ACTION,
|
|
@@ -56,6 +57,7 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
56
57
|
*/
|
|
57
58
|
async function data(_izContext, allObjSchemas, srcPath) {
|
|
58
59
|
let createSourceSet = new Set();
|
|
60
|
+
console.debug('templatePath:::', templatePath)
|
|
59
61
|
for (const action of Object.values(ACTIONS)) {
|
|
60
62
|
const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
|
|
61
63
|
for (const defaultHandler of defaultHandlers) {
|
|
@@ -183,10 +185,10 @@ async function createParamForCreateSource(_izContext, allObjSchemas, action, han
|
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
let resourceApis = [];
|
|
186
|
-
if (
|
|
188
|
+
if (handler === HANDLER.hdrApi) {
|
|
187
189
|
for (const objectSchema of allObjSchemas.records) {
|
|
188
190
|
resourceApis.push({
|
|
189
|
-
event: objectSchema.objectType,
|
|
191
|
+
event: lowerCase(objectSchema.objectType),
|
|
190
192
|
method: httpEvent(action)
|
|
191
193
|
})
|
|
192
194
|
}
|
|
@@ -202,7 +204,8 @@ async function createParamForCreateSource(_izContext, allObjSchemas, action, han
|
|
|
202
204
|
roleName: groupBy,
|
|
203
205
|
action: action,
|
|
204
206
|
functionNameConfig,
|
|
205
|
-
resourceApis
|
|
207
|
+
resourceApis,
|
|
208
|
+
serviceTag: serviceTag
|
|
206
209
|
},
|
|
207
210
|
setting: {
|
|
208
211
|
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
@@ -9,22 +9,18 @@
|
|
|
9
9
|
batchSize: 10
|
|
10
10
|
<%_ } else if (handlerType === "hdrApi") { _%>
|
|
11
11
|
<%_ resourceApis.forEach(resourceApi => { _%>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
arn: arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:UserAccountTestAuthorizerServiceSchema
|
|
25
|
-
resultTtlInSecond: 300
|
|
26
|
-
#<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
|
|
27
|
-
#<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
|
|
12
|
+
- httpApi:
|
|
13
|
+
path: /<%- serviceTag %>/<%- resourceApi.event %>/<%- action %>
|
|
14
|
+
method: <%- resourceApi.method %>
|
|
15
|
+
authorizer: authorizerServiceSchema
|
|
16
|
+
#<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
|
|
17
|
+
#<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
|
|
18
|
+
- httpApi:
|
|
19
|
+
path: /<%- serviceTag %>/<%- resourceApi.event %>/<%- action %>/{targetUserId}
|
|
20
|
+
method: <%- resourceApi.method %>
|
|
21
|
+
authorizer: authorizerIdentifiers
|
|
22
|
+
#<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
|
|
23
|
+
#<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
|
|
28
24
|
<%_ }) _%>
|
|
29
25
|
<%_ } _%>
|
|
30
26
|
role: <%- firstLetterUpperCase(roleName) _%>Role
|
|
@@ -109,24 +109,40 @@ async function externalLambdaIamRoleDataPerAction(_izContext, allObjSchemas) {
|
|
|
109
109
|
additionalResourcePermission.push(
|
|
110
110
|
createIamRole(
|
|
111
111
|
{ [RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction] },
|
|
112
|
-
storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(
|
|
113
|
-
externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv",
|
|
112
|
+
storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
|
|
113
|
+
externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv", graphServerTag),
|
|
114
114
|
)
|
|
115
115
|
),
|
|
116
116
|
createIamRole(
|
|
117
117
|
{
|
|
118
118
|
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
119
119
|
},
|
|
120
|
-
storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(
|
|
121
|
-
externalResourceName(RESOURCE_CLASSES.sns, "UpdateNode_In",
|
|
120
|
+
storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
|
|
121
|
+
externalResourceName(RESOURCE_CLASSES.sns, "UpdateNode_In", graphServerTag)
|
|
122
122
|
)
|
|
123
123
|
),
|
|
124
124
|
createIamRole(
|
|
125
125
|
{
|
|
126
126
|
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
127
127
|
},
|
|
128
|
-
storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(
|
|
129
|
-
externalResourceName(RESOURCE_CLASSES.sns, "CreateNode_In",
|
|
128
|
+
storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
|
|
129
|
+
externalResourceName(RESOURCE_CLASSES.sns, "CreateNode_In", graphServerTag)
|
|
130
|
+
)
|
|
131
|
+
),
|
|
132
|
+
createIamRole(
|
|
133
|
+
{
|
|
134
|
+
[RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction]
|
|
135
|
+
},
|
|
136
|
+
storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
|
|
137
|
+
externalResourceName(RESOURCE_CLASSES.lambda, "CreateNodeHdrInv", graphServerTag)
|
|
138
|
+
)
|
|
139
|
+
),
|
|
140
|
+
createIamRole(
|
|
141
|
+
{
|
|
142
|
+
[RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction]
|
|
143
|
+
},
|
|
144
|
+
storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
|
|
145
|
+
externalResourceName(RESOURCE_CLASSES.lambda, "UpdateNodeHdrInv", graphServerTag)
|
|
130
146
|
)
|
|
131
147
|
)
|
|
132
148
|
)
|
package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js
CHANGED
|
@@ -25,7 +25,7 @@ const getObjectSchema = require('@izara_project/izara-core-library-service-schem
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* receive objectSchema
|
|
28
|
-
* create data for
|
|
28
|
+
* create data for WebSocket handler template
|
|
29
29
|
*
|
|
30
30
|
* @param {Object} objectSchema
|
|
31
31
|
* @return {{templatePath, templateData,setting}}
|
|
@@ -42,7 +42,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
|
42
42
|
// let fieldNames = Object.keys(objectSchema.fieldNames)
|
|
43
43
|
return {
|
|
44
44
|
templatePath: templatePath,
|
|
45
|
-
templateData: {},
|
|
45
|
+
templateData: { flowTag: flowSchema.flowTag },
|
|
46
46
|
setting: {
|
|
47
47
|
savePath: path.join(srcPath, SOURCE_PATH.webSocket, flowSchema.flowTag, "source/"),
|
|
48
48
|
saveFileName: `${functionName}_Main`,
|
|
@@ -130,7 +130,9 @@ module.exports.reservedLimit = async (
|
|
|
130
130
|
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
131
131
|
callingFlowConfig,
|
|
132
132
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
133
|
+
//(<callingFlowProperties>)
|
|
133
134
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
|
|
135
|
+
//(</callingFlowProperties>)
|
|
134
136
|
callingFlowProperties
|
|
135
137
|
)
|
|
136
138
|
)
|
|
@@ -139,7 +141,9 @@ module.exports.reservedLimit = async (
|
|
|
139
141
|
sendMsgReservedDynamic = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
140
142
|
sendMsgReservedDynamic,
|
|
141
143
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
144
|
+
//(<callingFlowProperties>)
|
|
142
145
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
|
|
146
|
+
//(</callingFlowProperties>)
|
|
143
147
|
callingFlowProperties
|
|
144
148
|
)
|
|
145
149
|
);
|
|
@@ -57,7 +57,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
57
57
|
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
58
58
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
59
59
|
let route = upperCase(flowSchema.flowTag);
|
|
60
|
-
let queueName = upperCase(flowSchema.flowTag) + handlerType;
|
|
60
|
+
let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
|
|
61
61
|
let topicIn = route + "_In";
|
|
62
62
|
additionalResourcePermission.push(
|
|
63
63
|
createIamRole(
|
|
@@ -68,15 +68,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
68
68
|
resourceNames(RESOURCE_CLASSES.sqs, queueName),
|
|
69
69
|
resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
|
|
70
70
|
]
|
|
71
|
-
)
|
|
72
|
-
createIamRole(
|
|
73
|
-
{
|
|
74
|
-
[RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
|
|
75
|
-
},
|
|
76
|
-
[
|
|
77
|
-
resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
|
|
78
|
-
]
|
|
79
|
-
),
|
|
71
|
+
)
|
|
80
72
|
)
|
|
81
73
|
|
|
82
74
|
if (Object.keys(flowSchema.flowSteps).includes("In")) {
|
|
@@ -117,12 +109,23 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
117
109
|
tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
|
|
118
110
|
)
|
|
119
111
|
)
|
|
112
|
+
} else if (flowSchema.statusType === "statusField") {
|
|
113
|
+
additionalResourcePermission.push(
|
|
114
|
+
createIamRole(
|
|
115
|
+
{
|
|
116
|
+
[RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
|
|
117
|
+
},
|
|
118
|
+
[
|
|
119
|
+
resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
|
|
120
|
+
]
|
|
121
|
+
)
|
|
122
|
+
)
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
return {
|
|
123
126
|
templatePath: templatePath,
|
|
124
127
|
templateData: {
|
|
125
|
-
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
|
|
128
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowSchema.flowTag), "source/"),
|
|
126
129
|
functionName,
|
|
127
130
|
handlerType,
|
|
128
131
|
additionalResourcePermission,
|
|
@@ -55,52 +55,7 @@ async function data(_izContext, flowSchema, srcPath) {
|
|
|
55
55
|
async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
56
56
|
let functionName = "Process" + upperCase(flowSchema.flowTag)
|
|
57
57
|
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
58
|
-
let
|
|
59
|
-
let queueName = upperCase(flowSchema.flowTag) + handlerType;
|
|
60
|
-
additionalResourcePermission.push(
|
|
61
|
-
createIamRole(
|
|
62
|
-
{
|
|
63
|
-
[RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
|
|
64
|
-
},
|
|
65
|
-
[
|
|
66
|
-
resourceNames(RESOURCE_CLASSES.sqs, queueName),
|
|
67
|
-
resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
|
|
68
|
-
]
|
|
69
|
-
),
|
|
70
|
-
createIamRole(
|
|
71
|
-
{
|
|
72
|
-
[RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
|
|
73
|
-
},
|
|
74
|
-
[
|
|
75
|
-
resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
|
|
76
|
-
]
|
|
77
|
-
),
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
if (flowSchema.statusType === "storedCache") {
|
|
81
|
-
let tableStroedCaches = [];
|
|
82
|
-
let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0])
|
|
83
|
-
if (!objectSchema) {
|
|
84
|
-
throw new NoRetryError('ObjectSchema not found')
|
|
85
|
-
}
|
|
86
|
-
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
87
|
-
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
88
|
-
if (!tableStroedCaches.includes(storageResource.tableName)) {
|
|
89
|
-
tableStroedCaches.push(storageResource.tableName)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
additionalResourcePermission.push(
|
|
95
|
-
createIamRole(
|
|
96
|
-
{
|
|
97
|
-
[RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
|
|
98
|
-
},
|
|
99
|
-
tableStroedCaches.map(
|
|
100
|
-
tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
|
|
101
|
-
)
|
|
102
|
-
)
|
|
103
|
-
}
|
|
58
|
+
let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
|
|
104
59
|
|
|
105
60
|
return {
|
|
106
61
|
templatePath: templatePath,
|
|
@@ -110,7 +65,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
110
65
|
queueName
|
|
111
66
|
},
|
|
112
67
|
setting: {
|
|
113
|
-
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
68
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
|
|
114
69
|
saveFileName: `${functionName}_${handlerType}`,
|
|
115
70
|
fileExtension: ".js",
|
|
116
71
|
isAppend: false
|
|
@@ -28,7 +28,10 @@ const Logger = require('@izara_project/izara-core-library-logger');
|
|
|
28
28
|
const <%- functionName %> = require('./<%- functionName %>_Main')
|
|
29
29
|
|
|
30
30
|
// validate event properties in body.Message of sqs event
|
|
31
|
-
let perRecordsValidatorSchema = {
|
|
31
|
+
let perRecordsValidatorSchema = {
|
|
32
|
+
//(<validatorSchema>)
|
|
33
|
+
//(</validatorSchema>)
|
|
34
|
+
}
|
|
32
35
|
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
33
36
|
|
|
34
37
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
@@ -31,8 +31,6 @@ const STORAGE_TYPES = {
|
|
|
31
31
|
graph: "graph"
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const snsTemplatePath = path.join(__dirname, '../../../resourceYaml/sns-in-sqs/snsTemplate.ejs');
|
|
35
|
-
const subscriptionSqsTemplatePath = path.join(__dirname, './sqsTemplate.ejs');
|
|
36
34
|
const template = path.join(__dirname, "./template.ejs") // !! <----- Add here
|
|
37
35
|
|
|
38
36
|
const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js');
|
|
@@ -64,24 +62,22 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
|
|
|
64
62
|
if (flowSteps.includes("In")) {
|
|
65
63
|
generatedSnsTopicInForFlowSchema.push(
|
|
66
64
|
{
|
|
67
|
-
queueName: upperCase(flowSchema.flowTag)
|
|
65
|
+
queueName: "Process" + upperCase(flowSchema.flowTag) + upperCase(HANDLER.hdrSqs)
|
|
68
66
|
}
|
|
69
67
|
)
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
// if (flowSteps.includes("Out") && flowSchema.outputTopic === true) {
|
|
71
|
+
// generatedSnsTopicInForFlowSchema.push(
|
|
72
|
+
// {
|
|
73
|
+
// queueName: upperCase(flowSchema.flowTag) + "Complete" + upperCase(HANDLER.hdrSqs)
|
|
74
|
+
// }
|
|
75
|
+
// )
|
|
76
|
+
// }
|
|
81
77
|
|
|
82
78
|
for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
|
|
83
79
|
resultsForCreateDefaultSnsInSqs.push({
|
|
84
|
-
templatePath:
|
|
80
|
+
templatePath: template,
|
|
85
81
|
templateData: defaultSnsInSqsData,
|
|
86
82
|
setting: setting
|
|
87
83
|
})
|
|
@@ -18,14 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
'use strict';
|
|
19
19
|
const path = require('path');
|
|
20
20
|
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
21
|
-
const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require('
|
|
22
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("
|
|
21
|
+
const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require('../../../../MainLibs/src/Consts');
|
|
22
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
|
|
23
23
|
const templatePath = path.join(__dirname, "template.ejs");
|
|
24
24
|
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
25
25
|
const { STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
26
|
-
const statusFieldTemplate = path.join(__dirname, "
|
|
27
|
-
const storedCacheTemplate = path.join(__dirname, "
|
|
28
|
-
const triggerCacheTemplate = path.join(__dirname, "
|
|
26
|
+
const statusFieldTemplate = path.join(__dirname, "../templateByStatusType/statusFieldTemplate.ejs")
|
|
27
|
+
const storedCacheTemplate = path.join(__dirname, "../templateByStatusType/storedCacheTemplate.ejs")
|
|
28
|
+
const triggerCacheTemplate = path.join(__dirname, "../templateByStatusType/triggerCacheTemplate.ejs")
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* receive objectSchema
|
|
@@ -70,7 +70,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
|
70
70
|
functionName,
|
|
71
71
|
tableName,
|
|
72
72
|
flowSchemaComplete,
|
|
73
|
-
triggerType
|
|
73
|
+
triggerType,
|
|
74
74
|
},
|
|
75
75
|
setting: {
|
|
76
76
|
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
|
|
@@ -18,29 +18,26 @@ along with this program. If not, see
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
-
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
21
|
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
23
|
-
|
|
24
22
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
23
|
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
24
|
const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
|
|
27
25
|
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
28
26
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
29
27
|
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
30
|
-
const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
|
|
31
|
-
const triggeredCacheSharedLib = require('@izara_project/izara-core-library-trigger-cache')
|
|
32
28
|
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
33
29
|
const sns = externalRequest.sns
|
|
34
30
|
const sqs = externalRequest.sqs
|
|
35
31
|
const lambda = externalRequest.lambda
|
|
36
|
-
const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
|
|
37
|
-
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
38
32
|
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
33
|
+
<% if (statusType === "triggerCache") { -%>
|
|
34
|
+
const triggeredCacheSharedLib = require('@izara_project/izara-core-library-trigger-cache')
|
|
35
|
+
<% } else if (statusType === "statusField") { -%>
|
|
43
36
|
const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs.js')
|
|
37
|
+
<% } else if (statusType === "storedCache") { -%>
|
|
38
|
+
const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
|
|
39
|
+
<% } -%>
|
|
40
|
+
const { createFlowTypeConcat } = require('@izara_project/izara-core-library-service-schemas').utils
|
|
44
41
|
//(<optionalRequire>)
|
|
45
42
|
//(</optionalRequire>)
|
|
46
43
|
/**
|
|
@@ -63,7 +60,7 @@ module.exports.<%- functionName %> = async (
|
|
|
63
60
|
requestParams,
|
|
64
61
|
//(<additionalParams>)
|
|
65
62
|
//(</additionalParams>)
|
|
66
|
-
|
|
63
|
+
callingFlowConfig = {},
|
|
67
64
|
) => {
|
|
68
65
|
|
|
69
66
|
try {
|
|
@@ -77,17 +74,17 @@ module.exports.<%- functionName %> = async (
|
|
|
77
74
|
<% if (statusType === "statusField") { %>
|
|
78
75
|
<%- include(statusFieldTemplate) %>
|
|
79
76
|
<% } else if (statusType === "storedCache") { %>
|
|
80
|
-
<%- include(storedCacheTemplate, {tableName:tableName,flowSchemaComplete:flowSchemaComplete}) %>
|
|
77
|
+
<%- include(storedCacheTemplate, {tableName:tableName, flowSchemaComplete:flowSchemaComplete,flowTag}) %>
|
|
81
78
|
|
|
82
79
|
<% } else if (statusType === "triggerCache") { %>
|
|
83
80
|
<%- include(triggerCacheTemplate, {
|
|
84
81
|
tableName: tableName,
|
|
85
82
|
flowSchemaComplete: flowSchemaComplete,
|
|
86
|
-
triggerType: triggerType
|
|
83
|
+
triggerType: triggerType,
|
|
84
|
+
flowTag
|
|
87
85
|
}) %>
|
|
88
86
|
<% } %>
|
|
89
87
|
|
|
90
|
-
|
|
91
88
|
//(<endpointHook>)
|
|
92
89
|
//(</endpointHook>)
|
|
93
90
|
|
|
@@ -59,6 +59,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
59
59
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
60
60
|
let route = upperCase(flowSchema.flowTag);
|
|
61
61
|
let queueName = upperCase(flowSchema.flowTag) + handlerType;
|
|
62
|
+
|
|
62
63
|
additionalResourcePermission.push(
|
|
63
64
|
createIamRole(
|
|
64
65
|
{
|
|
@@ -69,14 +70,6 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
69
70
|
resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
|
|
70
71
|
]
|
|
71
72
|
),
|
|
72
|
-
createIamRole(
|
|
73
|
-
{
|
|
74
|
-
[RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
|
|
75
|
-
},
|
|
76
|
-
[
|
|
77
|
-
resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
|
|
78
|
-
]
|
|
79
|
-
),
|
|
80
73
|
)
|
|
81
74
|
|
|
82
75
|
if (flowSchema.statusType === "storedCache") {
|
|
@@ -102,6 +95,17 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
102
95
|
tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
|
|
103
96
|
)
|
|
104
97
|
)
|
|
98
|
+
} else if (flowSchema.statusType === "statusField") {
|
|
99
|
+
additionalResourcePermission.push(
|
|
100
|
+
createIamRole(
|
|
101
|
+
{
|
|
102
|
+
[RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
|
|
103
|
+
},
|
|
104
|
+
[
|
|
105
|
+
resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
|
|
106
|
+
]
|
|
107
|
+
)
|
|
108
|
+
)
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
return {
|
|
@@ -24,11 +24,14 @@ const izara = require("@izara_project/izara-middleware");
|
|
|
24
24
|
const middleware = izara.middlewareHandler;
|
|
25
25
|
const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
|
|
26
26
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
27
|
-
|
|
27
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
28
28
|
const <%- functionName %> = require('./<%- functionName %>_Main')
|
|
29
29
|
|
|
30
30
|
// validate event properties in body.Message of sqs event
|
|
31
|
-
let perRecordsValidatorSchema = {
|
|
31
|
+
let perRecordsValidatorSchema = {
|
|
32
|
+
//(<validatorSchema>)
|
|
33
|
+
//(</validatorSchema>)
|
|
34
|
+
}
|
|
32
35
|
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
33
36
|
|
|
34
37
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
@@ -55,6 +58,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
55
58
|
passOnProperties.push(record.body.Message)
|
|
56
59
|
//(<additionalParams>)
|
|
57
60
|
//(</additionalParams>)
|
|
61
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
58
62
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
59
63
|
|
|
60
64
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
@@ -98,7 +98,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
98
98
|
return {
|
|
99
99
|
templatePath: templatePath,
|
|
100
100
|
templateData: {
|
|
101
|
-
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
|
|
101
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowSchema.flowTag), "source/"),
|
|
102
102
|
functionName,
|
|
103
103
|
handlerType,
|
|
104
104
|
additionalResourcePermission,
|
|
@@ -61,9 +61,9 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
61
61
|
await <%- functionName %>.<%- functionName %>(
|
|
62
62
|
event._izContext,
|
|
63
63
|
eventParams,
|
|
64
|
-
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
65
64
|
//(<additionalParams>)
|
|
66
65
|
//(</additionalParams>)
|
|
66
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
67
67
|
)
|
|
68
68
|
|
|
69
69
|
break
|
|
@@ -55,9 +55,9 @@ const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
|
|
|
55
55
|
module.exports.<%- functionName %> = async (
|
|
56
56
|
_izContext,
|
|
57
57
|
requestParams,
|
|
58
|
-
callingFlowConfig = {},
|
|
59
58
|
//(<additionalParams>)
|
|
60
59
|
//(</additionalParams>)
|
|
60
|
+
callingFlowConfig = {},
|
|
61
61
|
) => {
|
|
62
62
|
|
|
63
63
|
try {
|
|
@@ -24,11 +24,15 @@ const izara = require("@izara_project/izara-middleware");
|
|
|
24
24
|
const middleware = izara.middlewareHandler;
|
|
25
25
|
const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
|
|
26
26
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
27
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
27
28
|
|
|
28
29
|
const <%- functionName %> = require('./<%- functionName %>_Main')
|
|
29
30
|
|
|
30
31
|
// validate event properties in body.Message of sqs event
|
|
31
|
-
let perRecordsValidatorSchema = {
|
|
32
|
+
let perRecordsValidatorSchema = {
|
|
33
|
+
//(<validatorSchema>)
|
|
34
|
+
//(</validatorSchema>)
|
|
35
|
+
}
|
|
32
36
|
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
33
37
|
|
|
34
38
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
@@ -53,6 +57,9 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
53
57
|
|
|
54
58
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
55
59
|
passOnProperties.push(record.body.Message)
|
|
60
|
+
//(<additionalParams>)
|
|
61
|
+
//(</additionalParams>)
|
|
62
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
56
63
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
57
64
|
|
|
58
65
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|