@izara_project/izara-market-library-service-schemas 1.0.62 → 1.0.64

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.
Files changed (49) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +7 -3
  3. package/src/MainLibs/src/Consts.js +6 -2
  4. package/src/reStructure/GenerateCode.js +1 -1
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -8
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +114 -83
  7. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +8 -0
  8. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +11 -1
  9. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +13 -7
  10. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +3 -2
  11. package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +1 -0
  12. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +3 -1
  13. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +123 -0
  14. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/template.ejs +20 -0
  15. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +122 -0
  16. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/template.ejs +17 -0
  17. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +123 -0
  18. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/template.ejs +13 -0
  19. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +123 -0
  20. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/template.ejs +17 -0
  21. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/data.js +57 -0
  22. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/request.json +0 -0
  23. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/template.ejs +155 -0
  24. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/data.js +58 -0
  25. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/request.json +0 -0
  26. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/template.ejs +202 -0
  27. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/data.js +59 -0
  28. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/request.json +0 -0
  29. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/template.ejs +144 -0
  30. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/data.js +59 -0
  31. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/request.json +0 -0
  32. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/template.ejs +181 -0
  33. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/data.js +59 -0
  34. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +382 -0
  35. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/data.js +77 -0
  36. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
  37. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
  38. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +121 -0
  39. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/template.ejs +20 -0
  40. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/data.js +60 -0
  41. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/template.ejs +129 -0
  42. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/data.js +55 -0
  43. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/template.ejs +154 -0
  44. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/data.js +71 -0
  45. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/template.ejs +46 -0
  46. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/data.js +71 -0
  47. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/template.ejs +10 -0
  48. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -2
  49. package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +55 -2
@@ -0,0 +1,20 @@
1
+ <%_ const join = require('path').join; _%>
2
+ <%- firstLetterUpperCase(functionNameConfig) %>:
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
+ name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
+ events:
6
+ - http:
7
+ path: <%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
8
+ method: put
9
+ cors: true
10
+ #<#Authorizer#>
11
+ #<#/Authorizer#>
12
+ role: <%- roleName %>Role
13
+ #<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
14
+ #<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
15
+ <%_ function firstLetterUpperCase(text){
16
+ return text.charAt(0).toUpperCase() + text.slice(1)
17
+ } _%>
18
+ <%_ function firstLetterLowerCase(str) {
19
+ return str.charAt(0).toLowerCase() + str.slice(1)
20
+ } _%>
@@ -0,0 +1,122 @@
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
+ 'use strict';
19
+ const path = require('path');
20
+
21
+ const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+
23
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
24
+ const {
25
+ createIamRole,
26
+ resourceNames,
27
+ RESOURCE_CLASSES,
28
+ SQS_RESOURCE,
29
+ SOURCE_PATH,
30
+ SAVE_FILE_NAME,
31
+ FUNCTION_NAME,
32
+ SNS_RESOURCE,
33
+ defaultIamRolePerAction,
34
+ awaitingMultipleStepsRole,
35
+ shortNameHandler,
36
+ SHORT_FUNCTION_NAME,
37
+ SOURCE_GENERATE_IAM_ROLE,
38
+ checkDynamoTypeRelationship,
39
+ createDynamoDbComponentByLinks,
40
+ DYNAMO_RESOURCE
41
+ } = require("../../../../../../../MainLibs/src/Consts");
42
+
43
+ const templatePath = path.join(__dirname, './template.ejs')
44
+
45
+ /**
46
+ * receive objectSchema
47
+ * create data for updateRelationshipSchema
48
+ *
49
+ * @param {Object} objectSchema
50
+ * @return {{ templatePath, templateData, setting } }
51
+ */
52
+
53
+ function data(_izContext, allObjectRelationships, srcPath) {
54
+ let createSourceArray = [];
55
+
56
+ const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
57
+ createSourceArray.push(createSourceParam);
58
+ // console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
59
+ return createSourceArray
60
+ }
61
+
62
+
63
+ function createParamForCreateSource(allObjectRelationships, srcPath) {
64
+
65
+ let handlerType = HANDLER.hdrDsq
66
+ let functionName = FUNCTION_NAME.changeRel
67
+ let additionalResourcePermission = defaultIamRolePerAction();
68
+
69
+ additionalResourcePermission.push(
70
+ createIamRole(
71
+ {
72
+ [RESOURCE_CLASSES.sqs]: [
73
+ SQS_RESOURCE.deleteMessage,
74
+ SQS_RESOURCE.getQueueAttributes,
75
+ SQS_RESOURCE.receiveMessage,
76
+ SQS_RESOURCE.sendMessage,
77
+ SQS_RESOURCE.getQueueUrl,
78
+ SQS_RESOURCE.deleteMessageBatch
79
+ ],
80
+ },
81
+ [
82
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs)),
83
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs) + "DLQ"),
84
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq)),
85
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq) + "DLQ"),
86
+ ]
87
+ ),
88
+ createIamRole(
89
+ {
90
+ [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish, SNS_RESOURCE.subscribe]
91
+ },
92
+ [
93
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.changeRelComplete) + "_Out"),
94
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
95
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out"),
96
+ ]
97
+ )
98
+ )
99
+
100
+ additionalResourcePermission.push(awaitingMultipleStepsRole())
101
+
102
+
103
+ return {
104
+ templatePath: templatePath,
105
+ templateData: {
106
+ functionName,
107
+ handlerType,
108
+ additionalResourcePermission,
109
+ resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
110
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME.changeRel) + upperCase(shortNameHandler(handlerType)),
111
+ roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
112
+ },
113
+ setting: {
114
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
115
+ saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
116
+ fileExtension: '.yml',
117
+ isAppend: true
118
+ }
119
+ }
120
+ }
121
+
122
+ module.exports = data;
@@ -0,0 +1,17 @@
1
+ <%_ const join = require('path').join; _%>
2
+ <%- firstLetterUpperCase(functionNameConfig) %>:
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
+ name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
+ events:
6
+ - sqs:
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
8
+ batchSize: 10
9
+ role: <%- roleName %>Role
10
+ #<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
11
+ #<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
12
+ <%_ function firstLetterUpperCase(text){
13
+ return text.charAt(0).toUpperCase() + text.slice(1)
14
+ } _%>
15
+ <%_ function firstLetterLowerCase(str) {
16
+ return str.charAt(0).toLowerCase() + str.slice(1)
17
+ } _%>
@@ -0,0 +1,123 @@
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
+ 'use strict';
19
+ const path = require('path');
20
+
21
+ const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
22
+
23
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
24
+ const {
25
+ createIamRole,
26
+ resourceNames,
27
+ RESOURCE_CLASSES,
28
+ SOURCE_PATH,
29
+ SAVE_FILE_NAME,
30
+ FUNCTION_NAME,
31
+ SNS_RESOURCE,
32
+ defaultIamRolePerAction,
33
+ awaitingMultipleStepsRole,
34
+ shortNameHandler,
35
+ SHORT_FUNCTION_NAME,
36
+ SOURCE_GENERATE_IAM_ROLE,
37
+ checkDynamoTypeRelationship,
38
+ createDynamoDbComponentByLinks,
39
+ DYNAMO_RESOURCE,
40
+ SQS_RESOURCE
41
+ } = require("../../../../../../../MainLibs/index.js").consts;
42
+
43
+ const templatePath = path.join(__dirname, './template.ejs')
44
+
45
+ /**
46
+ * receive objectSchema
47
+ * create data for updateRelationshipSchema
48
+ *
49
+ * @param {Object} objectSchema
50
+ * @return {{ templatePath, templateData, setting } }
51
+ */
52
+
53
+ function data(_izContext, allObjectRelationships, srcPath) {
54
+ let createSourceArray = [];
55
+
56
+ const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
57
+ createSourceArray.push(createSourceParam);
58
+ // console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
59
+ return createSourceArray
60
+ }
61
+
62
+
63
+ function createParamForCreateSource(allObjectRelationships, srcPath) {
64
+
65
+ let handlerType = HANDLER.hdrInv
66
+ let functionName = FUNCTION_NAME.changeRel
67
+ let additionalResourcePermission = defaultIamRolePerAction();
68
+
69
+ additionalResourcePermission.push(awaitingMultipleStepsRole())
70
+
71
+ additionalResourcePermission.push(
72
+ createIamRole(
73
+ {
74
+ [RESOURCE_CLASSES.sqs]: [
75
+ SQS_RESOURCE.deleteMessage,
76
+ SQS_RESOURCE.getQueueAttributes,
77
+ SQS_RESOURCE.receiveMessage,
78
+ SQS_RESOURCE.sendMessage,
79
+ SQS_RESOURCE.getQueueUrl,
80
+ SQS_RESOURCE.deleteMessageBatch
81
+ ],
82
+ },
83
+ [
84
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs)),
85
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs) + "DLQ"),
86
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq)),
87
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq) + "DLQ"),
88
+ ]
89
+ ),
90
+ createIamRole(
91
+ {
92
+ [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish, SNS_RESOURCE.subscribe]
93
+ },
94
+ [
95
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.changeRelComplete) + "_Out"),
96
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
97
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out"),
98
+ ]
99
+ )
100
+ )
101
+
102
+ return {
103
+ templatePath: templatePath,
104
+ templateData: {
105
+ functionName,
106
+ handlerType,
107
+ additionalResourcePermission,
108
+ resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
109
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME.changeRel) + upperCase(shortNameHandler(handlerType)),
110
+ roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
111
+ },
112
+ setting: {
113
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
114
+ saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
115
+ fileExtension: '.yml',
116
+ isAppend: true
117
+ }
118
+
119
+ }
120
+ }
121
+
122
+
123
+ module.exports = data;
@@ -0,0 +1,13 @@
1
+ <%_ const join = require('path').join; _%>
2
+ <%- firstLetterUpperCase(functionNameConfig) %>:
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
+ name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
+ role: <%- roleName %>Role
6
+ #<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
7
+ #<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
8
+ <%_ function firstLetterUpperCase(text){
9
+ return text.charAt(0).toUpperCase() + text.slice(1)
10
+ } _%>
11
+ <%_ function firstLetterLowerCase(str) {
12
+ return str.charAt(0).toLowerCase() + str.slice(1)
13
+ } _%>
@@ -0,0 +1,123 @@
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
+ 'use strict';
19
+ const path = require('path');
20
+
21
+ const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+
23
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
24
+ const {
25
+ createIamRole,
26
+ resourceNames,
27
+ RESOURCE_CLASSES,
28
+ SQS_RESOURCE,
29
+ SOURCE_PATH,
30
+ SAVE_FILE_NAME,
31
+ FUNCTION_NAME,
32
+ SNS_RESOURCE,
33
+ defaultIamRolePerAction,
34
+ awaitingMultipleStepsRole,
35
+ shortNameHandler,
36
+ SHORT_FUNCTION_NAME,
37
+ SOURCE_GENERATE_IAM_ROLE,
38
+ checkDynamoTypeRelationship,
39
+ createDynamoDbComponentByLinks,
40
+ DYNAMO_RESOURCE
41
+ } = require("../../../../../../../MainLibs/index.js").consts;
42
+
43
+ const templatePath = path.join(__dirname, './template.ejs')
44
+
45
+ /**
46
+ * receive objectSchema
47
+ * create data for updateRelationshipSchema
48
+ *
49
+ * @param {Object} objectSchema
50
+ * @return {{ templatePath, templateData, setting } }
51
+ */
52
+
53
+ function data(_izContext, allObjectRelationships, srcPath) {
54
+ let createSourceArray = [];
55
+ const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
56
+ createSourceArray.push(createSourceParam);
57
+ // console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
58
+ return createSourceArray
59
+ }
60
+
61
+
62
+ function createParamForCreateSource(allObjectRelationships, srcPath) {
63
+
64
+ let handlerType = HANDLER.hdrSqs
65
+ let functionName = FUNCTION_NAME.changeRel
66
+ let additionalResourcePermission = defaultIamRolePerAction();
67
+
68
+ additionalResourcePermission.push(awaitingMultipleStepsRole())
69
+
70
+ additionalResourcePermission.push(
71
+ createIamRole(
72
+ {
73
+ [RESOURCE_CLASSES.sqs]: [
74
+ SQS_RESOURCE.deleteMessage,
75
+ SQS_RESOURCE.getQueueAttributes,
76
+ SQS_RESOURCE.receiveMessage,
77
+ SQS_RESOURCE.sendMessage,
78
+ SQS_RESOURCE.getQueueUrl,
79
+ SQS_RESOURCE.deleteMessageBatch
80
+ ],
81
+ },
82
+ [
83
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs)),
84
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs) + "DLQ"),
85
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq)),
86
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq) + "DLQ"),
87
+ ]
88
+ ),
89
+ createIamRole(
90
+ {
91
+ [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish, SNS_RESOURCE.subscribe]
92
+ },
93
+ [
94
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.changeRelComplete) + "_Out"),
95
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
96
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out"),
97
+ ]
98
+ )
99
+ )
100
+
101
+ additionalResourcePermission.push(awaitingMultipleStepsRole())
102
+
103
+
104
+ return {
105
+ templatePath: templatePath,
106
+ templateData: {
107
+ functionName,
108
+ handlerType,
109
+ additionalResourcePermission,
110
+ resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
111
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME.changeRel) + upperCase(shortNameHandler(handlerType)),
112
+ roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
113
+ },
114
+ setting: {
115
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
116
+ saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
117
+ fileExtension: '.yml',
118
+ isAppend: true
119
+ }
120
+ }
121
+ }
122
+
123
+ module.exports = data;
@@ -0,0 +1,17 @@
1
+ <%_ const join = require('path').join; _%>
2
+ <%- firstLetterUpperCase(functionNameConfig) %>:
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
+ name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
+ events:
6
+ - sqs:
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
8
+ batchSize: 10
9
+ role: <%- roleName %>Role
10
+ #<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
11
+ #<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
12
+ <%_ function firstLetterUpperCase(text){
13
+ return text.charAt(0).toUpperCase() + text.slice(1)
14
+ } _%>
15
+ <%_ function firstLetterLowerCase(str) {
16
+ return str.charAt(0).toLowerCase() + str.slice(1)
17
+ } _%>
@@ -0,0 +1,57 @@
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
+ 'use strict';
19
+ const path = require('path');
20
+
21
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+
23
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
24
+ const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../../MainLibs/index.js").consts;
25
+
26
+ const templatePath = path.join(__dirname, "./template.ejs")
27
+
28
+ /**
29
+ * receive objectSchema
30
+ * create data for hdrInv template
31
+ *
32
+ * @return {{ templatePath, templateData, setting } }
33
+ */
34
+ function data(_izContext, srcPath) {
35
+ const createSourceParams = createParamForCreateSource(srcPath)
36
+ return [createSourceParams];
37
+ }
38
+
39
+
40
+ function createParamForCreateSource(srcPath) {
41
+ let functionName = FUNCTION_NAME.changeRel;
42
+ return {
43
+ templatePath: templatePath,
44
+ templateData: {
45
+ functionName,
46
+ },
47
+ setting: {
48
+ savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
49
+ saveFileName: upperCase(functionName) + "_" + upperCase(HANDLER.hdrApi),
50
+ fileExtension: '.js',
51
+ isAppend: false
52
+ }
53
+ }
54
+ }
55
+
56
+
57
+ module.exports = data;
@@ -0,0 +1,155 @@
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
+ 'use strict';
19
+ const izara = require("@izara_project/izara-middleware");
20
+ const middleware = izara.middlewareHandler;
21
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
22
+ const {
23
+ validateSchemaMiddleware
24
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
25
+
26
+ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
27
+ // validate event params in middleware before into function
28
+ let validatorSchema = {
29
+ type: "object",
30
+ required: [
31
+ 'firstObject',
32
+ 'secondObject',
33
+ 'oldReltypeAndDirection',
34
+ 'newRelType',
35
+ ],
36
+ properties: {
37
+ firstObject: {
38
+ type: 'object',
39
+ required: ['objType', 'identifiers'],
40
+ properties: {
41
+ objType: {
42
+ type: 'object',
43
+ required: ['objectType', 'serviceTag'],
44
+ properties: {
45
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
46
+ objectType: izara.validatorSchema.stringNotEmpty(),
47
+ }
48
+ },
49
+ identifiers: {
50
+ type: "object",
51
+ minProperties: 1
52
+ },
53
+ }
54
+ },
55
+ secondObject: {
56
+ type: 'object',
57
+ required: ['objType', 'identifiers'],
58
+ properties: {
59
+ objType: {
60
+ type: 'object',
61
+ required: ['objectType', 'serviceTag'],
62
+ properties: {
63
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
64
+ objectType: izara.validatorSchema.stringNotEmpty(),
65
+ }
66
+ },
67
+ identifiers: {
68
+ type: "object",
69
+ minProperties: 1
70
+ },
71
+ }
72
+ },
73
+ oldReltypeAndDirection: {
74
+ type: 'object',
75
+ required: ['relType', 'relationshipDirection'],
76
+ properties: {
77
+ relType: {
78
+ type: 'object',
79
+ required: ['serviceTag', 'relationshipTag'],
80
+ properties: {
81
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
82
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
83
+ }
84
+ },
85
+ relationshipProperties: {
86
+ type: 'object',
87
+ },
88
+ relationshipDirection: {
89
+ type: 'string',
90
+ enum: ['from', 'to']
91
+
92
+ },
93
+ }
94
+ },
95
+ newRelType: {
96
+ type: 'object',
97
+ required: ['serviceTag', 'relationshipTag'],
98
+ properties: {
99
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
100
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
101
+ }
102
+ },
103
+ settings: {
104
+ type: 'object'
105
+ }
106
+ }
107
+ };
108
+
109
+ //(<globalVariable>
110
+ //</globalVariable>)
111
+
112
+ // validate event params in middleware before into main function
113
+ validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
114
+ middleware.setValidatorSchema(validatorSchema)
115
+ // if need to validate authorizer or additional params , add code to hook tag below
116
+
117
+ //(<afterValidateWith>)
118
+ //(</afterValidateWith>)
119
+
120
+
121
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
122
+ event._izContext.logger.debug('Event:', event);
123
+ try {
124
+ // invoke LambdaFunction
125
+ let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
126
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
127
+ {
128
+ firstObject: event.firstObject,
129
+ secondObject: event.secondObject,
130
+ relType: event.relType,
131
+ relationshipDirection: event.relationshipDirection,
132
+ relationshipProperties: event.relationshipProperties,
133
+ },
134
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
135
+ );
136
+
137
+ // return error to client
138
+ if (lambdaFunctionResponse instanceof Error) {
139
+ return (izara.response.failure(lambdaFunctionResponse));
140
+ }
141
+
142
+ // return success to client
143
+ return (izara.response.success(lambdaFunctionResponse));
144
+
145
+ } catch (err) {
146
+ event._izContext.logger.error('Error, <%- functionName %>HdrApi: ', err);
147
+ return (izara.response.failure(err));
148
+ }
149
+ });
150
+ <%_ function firstLetterUpperCase(text) {
151
+ return text.charAt(0).toUpperCase() + text.slice(1)
152
+ } _%>
153
+ <%_ function firstLetterLowerCase(str) {
154
+ return str.charAt(0).toLowerCase() + str.slice(1)
155
+ } _%>