@izara_project/izara-market-library-service-schemas 1.0.27 → 1.0.28

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 (127) hide show
  1. package/package.json +9 -5
  2. package/src/GenerateCodeLibs/src/Consts.js +5 -2
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +5 -5
  4. package/src/MainLibs/src/Consts.js +44 -2
  5. package/src/reStructure/GenerateCode.js +0 -4
  6. package/src/reStructure/GenerateSchema.js +17 -5
  7. package/src/reStructure/SchemaConfig.js +3 -2
  8. package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +58 -6
  9. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +161 -101
  10. package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +3 -4
  11. package/src/reStructure/TemplateData/findData/handler/template.ejs +1 -1
  12. package/src/reStructure/TemplateData/findData/mainFunction/template.ejs +3 -3
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/template.ejs +2 -3
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -3
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +2 -3
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +5 -6
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/handler/template.ejs +1 -2
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +3 -4
  19. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/handler/template.ejs +2 -2
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/mainFunction/template.ejs +3 -4
  21. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +2 -3
  22. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +5 -6
  23. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/template.ejs +1 -1
  24. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +4 -5
  25. package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ReservedTableData.js +1 -0
  26. package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/WebSocketTaskData.js +1 -0
  27. package/src/reStructure/TemplateData/perActionComplete/create/handler/template.ejs +2 -3
  28. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +4 -5
  29. package/src/reStructure/TemplateData/perActionComplete/delete/handler/template.ejs +2 -2
  30. package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +4 -6
  31. package/src/reStructure/TemplateData/perActionComplete/generateTemplateData.js +1 -1
  32. package/src/reStructure/TemplateData/perActionComplete/get/handler/template.ejs +2 -3
  33. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +4 -6
  34. package/src/reStructure/TemplateData/perActionComplete/update/handler/template.ejs +2 -3
  35. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -6
  36. package/src/reStructure/TemplateData/perActionEndpoint/handler/api/template.ejs +1 -1
  37. package/src/reStructure/TemplateData/perActionEndpoint/handler/dsq/template.ejs +2 -2
  38. package/src/reStructure/TemplateData/perActionEndpoint/handler/inv/template.ejs +1 -3
  39. package/src/reStructure/TemplateData/perActionEndpoint/handler/sqs/template.ejs +2 -2
  40. package/src/reStructure/TemplateData/perActionEndpoint/handler/webSocket/template.ejs +3 -3
  41. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/create/template.ejs +6 -7
  42. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/delete/template.ejs +5 -4
  43. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/get/template.ejs +5 -6
  44. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/update/template.ejs +5 -6
  45. package/src/reStructure/TemplateData/processLogical/handler/template.ejs +1 -1
  46. package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +5 -6
  47. package/src/reStructure/TemplateData/processLogicalPagination/handler/dsq/template.ejs +1 -1
  48. package/src/reStructure/TemplateData/processLogicalPagination/handler/sqs/template.ejs +1 -1
  49. package/src/reStructure/TemplateData/processLogicalPagination/mainFunction/template.ejs +6 -5
  50. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +27 -6
  51. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +25 -4
  52. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +26 -4
  53. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +26 -4
  54. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/api/template.ejs +1 -1
  55. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/dsq/template.ejs +2 -2
  56. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/inv/template.ejs +1 -1
  57. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/sqs/template.ejs +2 -2
  58. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +66 -18
  59. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -3
  60. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +5 -6
  61. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +25 -4
  62. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +25 -4
  63. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +25 -4
  64. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +26 -4
  65. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/api/template.ejs +1 -1
  66. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs +2 -2
  67. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/inv/template.ejs +1 -1
  68. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs +2 -2
  69. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +55 -5
  70. package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +62 -6
  71. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +119 -0
  72. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/template.ejs +20 -0
  73. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +131 -0
  74. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/template.ejs +17 -0
  75. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +119 -0
  76. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/template.ejs +13 -0
  77. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +131 -0
  78. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/template.ejs +17 -0
  79. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/data.js +57 -0
  80. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/request.json +0 -0
  81. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/template.ejs +138 -0
  82. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/data.js +58 -0
  83. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/request.json +0 -0
  84. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/template.ejs +183 -0
  85. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/data.js +59 -0
  86. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/request.json +0 -0
  87. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/template.ejs +125 -0
  88. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/data.js +59 -0
  89. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/request.json +0 -0
  90. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/template.ejs +163 -0
  91. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/data.js +59 -0
  92. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +322 -0
  93. package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/data.js +77 -0
  94. package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/snsTemplate.ejs +59 -0
  95. package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/sqsTemplate.ejs +43 -0
  96. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +110 -0
  97. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/request.json +0 -0
  98. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/template.ejs +20 -0
  99. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/data.js +60 -0
  100. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/request.json +0 -0
  101. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +125 -0
  102. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/data.js +55 -0
  103. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/request.json +0 -0
  104. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +141 -0
  105. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/data.js +71 -0
  106. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/request.json +0 -0
  107. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/template.ejs +47 -0
  108. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/data.js +71 -0
  109. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/request.json +0 -0
  110. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/template.ejs +10 -0
  111. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +25 -22
  112. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +25 -5
  113. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +26 -5
  114. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +25 -4
  115. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/api/template.ejs +1 -1
  116. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/dsq/template.ejs +2 -2
  117. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/inv/template.ejs +1 -1
  118. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/sqs/template.ejs +2 -2
  119. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +55 -7
  120. package/src/reStructure/TemplateData/resourceYaml/dynamodb/defaultDynamoDbTable.js +50 -42
  121. package/src/reStructure/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +98 -0
  122. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +4 -5
  123. package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -1
  124. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +11 -2
  125. package/src/reStructure/TemplateData/testTemplate/data.js +27 -0
  126. package/src/reStructure/TemplateData/testTemplate/template.ejs +5 -0
  127. /package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/{attributeLink.ejs → attributeLinkTemplate.ejs} +0 -0
@@ -0,0 +1,119 @@
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
+ } = require("../../../../../../../MainLibs/index.js").consts;
41
+
42
+ const templatePath = path.join(__dirname, './template.ejs')
43
+
44
+ /**
45
+ * receive objectSchema
46
+ * create data for updateRelationshipSchema
47
+ *
48
+ * @param {Object} objectSchema
49
+ * @return {{ templatePath, templateData, setting } }
50
+ */
51
+
52
+ function data(_izContext, allObjectRelationships, srcPath) {
53
+ let createSourceArray = [];
54
+
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.hdrInv
65
+ let functionName = FUNCTION_NAME.getRel
66
+ let additionalResourcePermission = defaultIamRolePerAction();
67
+
68
+ additionalResourcePermission.push(awaitingMultipleStepsRole())
69
+
70
+ additionalResourcePermission.push(
71
+ createIamRole({
72
+ [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
73
+ },
74
+ [
75
+ resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.getRelComplete)),
76
+ ]
77
+ )
78
+ )
79
+
80
+ for (const relationship of allObjectRelationships) {
81
+ let [relationshipTag, links] = checkDynamoTypeRelationship(relationship)
82
+ for (const link of links) {
83
+ let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
84
+ additionalResourcePermission.push(
85
+ createIamRole(
86
+ {
87
+ [RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.updateItem]
88
+ },
89
+ [
90
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameFrom)),
91
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameTo))
92
+ ]
93
+ )
94
+ )
95
+ }
96
+ }
97
+
98
+ return {
99
+ templatePath: templatePath,
100
+ templateData: {
101
+ functionName,
102
+ handlerType,
103
+ additionalResourcePermission,
104
+ resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
105
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME.getRel) + upperCase(shortNameHandler(handlerType)),
106
+ roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
107
+ },
108
+ setting: {
109
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
110
+ saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
111
+ fileExtension: '.yml',
112
+ isAppend: true
113
+ }
114
+
115
+ }
116
+ }
117
+
118
+
119
+ 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 %><%- handlerType %>IamRole#>
7
+ #<#/<%- functionName %><%- 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,131 @@
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.getRel
66
+ let additionalResourcePermission = defaultIamRolePerAction();
67
+
68
+ additionalResourcePermission.push(
69
+ // createIamRole(
70
+ // { [RESOURCE_CLASSES.lambda]: ["InvokeFunction"] },
71
+ // [resourceNames(RESOURCE_CLASSES.lambda, "*GetNodeHdrInv")]),
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
+ ], [RESOURCE_CLASSES.sns]:
82
+ [SNS_RESOURCE.publish, SNS_RESOURCE.subscribe]
83
+ },
84
+ [
85
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs)),
86
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs) + "DLQ"),
87
+ resourceNames(RESOURCE_CLASSES.sns, "In" + upperCase(functionName) + upperCase(HANDLER.hdrSqs)),
88
+ resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(functionName) + upperCase(HANDLER.hdrSqs)),
89
+ resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.getRelComplete))
90
+ ]
91
+ ),
92
+ )
93
+ additionalResourcePermission.push(awaitingMultipleStepsRole())
94
+
95
+ for (const relationship of allObjectRelationships) {
96
+ let [relationshipTag, links] = checkDynamoTypeRelationship(relationship)
97
+ for (const link of links) {
98
+ let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
99
+ additionalResourcePermission.push(
100
+ createIamRole(
101
+ {
102
+ [RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.updateItem]
103
+ },
104
+ [
105
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameFrom)),
106
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameTo))
107
+ ]
108
+ )
109
+ )
110
+ }
111
+ }
112
+ return {
113
+ templatePath: templatePath,
114
+ templateData: {
115
+ functionName,
116
+ handlerType,
117
+ additionalResourcePermission,
118
+ resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
119
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME.getRel) + upperCase(shortNameHandler(handlerType)),
120
+ roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
121
+ },
122
+ setting: {
123
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
124
+ saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
125
+ fileExtension: '.yml',
126
+ isAppend: true
127
+ }
128
+ }
129
+ }
130
+
131
+ 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 %><%- handlerType %>IamRole#>
11
+ #<#/<%- functionName %><%- 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.getRel;
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,138 @@
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: ["firstObject", "secondObject", "relType", 'relId'],
31
+ properties: {
32
+ firstObject: {
33
+ type: "object",
34
+ required: ["objType", "identifiers"],
35
+ properties: {
36
+ objType: {
37
+ type: "object",
38
+ required: ["serviceTag", "objectType"],
39
+ properties: {
40
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
41
+ objectType: izara.validatorSchema.stringNotEmpty()
42
+ }
43
+ },
44
+ identifiers: {
45
+ type: "object",
46
+ minProperties: 1
47
+ }
48
+ }
49
+ },
50
+ secondObject: {
51
+ type: "object",
52
+ required: ["objType", "identifiers"],
53
+ properties: {
54
+ objType: {
55
+ type: "object",
56
+ required: ["serviceTag", "objectType"],
57
+ properties: {
58
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
59
+ objectType: izara.validatorSchema.stringNotEmpty()
60
+ }
61
+ },
62
+ identifiers: {
63
+ type: "object",
64
+ minProperties: 1
65
+ }
66
+ }
67
+ },
68
+ relType: {
69
+ type: "object",
70
+ required: ["relationshipTag", "serviceTag"],
71
+ properties: {
72
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
73
+ serviceTag: {
74
+ type: 'string',
75
+ pattern: "^[a-zA-Z0-9_-]+$",
76
+ enum: [process.env.iz_serviceTag]
77
+ },
78
+ }
79
+ },
80
+ relationshipDirection: {
81
+ type: "string",
82
+ default: ""
83
+ },
84
+ relId: {
85
+ type: 'string',
86
+ },
87
+ }
88
+ };
89
+
90
+
91
+
92
+ //(<globalVarible>
93
+ //</globalVarible>)
94
+
95
+ // validate event params in middleware before into main function
96
+ validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
97
+ middleware.setValidatorSchema(validatorSchema)
98
+ // if need to validate authorizer or additional params , add code to hook tag below
99
+
100
+ //(<afterValidateWith>)
101
+ //(</afterValidateWith>)
102
+
103
+
104
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
105
+ event._izContext.logger.debug('Event:', event);
106
+ try {
107
+ // invoke LambdaFunction
108
+ let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
109
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
110
+ {
111
+ firstObject: event.firstObject,
112
+ secondObject: event.secondObject,
113
+ relType: event.relType,
114
+ relId: event.relId,
115
+ relationshipDirection: event.relationshipDirection,
116
+ },
117
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
118
+ );
119
+
120
+ // return error to client
121
+ if (lambdaFunctionResponse instanceof Error) {
122
+ return (izara.response.failure(lambdaFunctionResponse));
123
+ }
124
+
125
+ // return success to client
126
+ return (izara.response.success(lambdaFunctionResponse));
127
+
128
+ } catch (err) {
129
+ event._izContext.logger.error('Error, <%- functionName %>HdrApi: ', err);
130
+ return (izara.response.failure(err));
131
+ }
132
+ });
133
+ <%_ function firstLetterUpperCase(text) {
134
+ return text.charAt(0).toUpperCase() + text.slice(1)
135
+ } _%>
136
+ <%_ function firstLetterLowerCase(str) {
137
+ return str.charAt(0).toLowerCase() + str.slice(1)
138
+ } _%>
@@ -0,0 +1,58 @@
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
+ * create data for hdrInv template
30
+ *
31
+ * @return {{ templatePath, templateData, setting } }
32
+ */
33
+ function data(_izContext, srcPath) {
34
+ const createSourceParams = createParamForCreateSource(srcPath)
35
+ return [createSourceParams];
36
+ }
37
+
38
+
39
+ function createParamForCreateSource(srcPath) {
40
+ let functionName = FUNCTION_NAME.getRel
41
+ let queueName = functionName + upperCase(HANDLER.hdrDsq)
42
+ return {
43
+ templatePath: templatePath,
44
+ templateData: {
45
+ functionName,
46
+ queueName,
47
+ },
48
+ setting: {
49
+ savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
50
+ saveFileName: upperCase(functionName) + "_" + upperCase(HANDLER.hdrDsq),
51
+ fileExtension: '.js',
52
+ isAppend: false
53
+ }
54
+ }
55
+ }
56
+
57
+
58
+ module.exports = data;