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

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 (134) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +7 -2
  3. package/src/MainLibs/src/Consts.js +30 -24
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +4 -4
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +1 -1
  6. package/src/reStructure/TemplateData/findData/GetByStorage/getByDynamo.ejs +2 -1
  7. package/src/reStructure/TemplateData/findData/GetByStorage/getByGraph.ejs +2 -1
  8. package/src/reStructure/TemplateData/findData/mainFunction/template.ejs +2 -1
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -0
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +1 -1
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +3 -1
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +14 -0
  13. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +0 -4
  14. package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +1 -1
  15. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +1 -1
  16. package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +1 -1
  17. package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +1 -1
  18. package/src/reStructure/TemplateData/processLogical/yaml/data.js +2 -2
  19. package/src/reStructure/TemplateData/processLogicalPagination/yaml/dsq/data.js +1 -1
  20. package/src/reStructure/TemplateData/processLogicalPagination/yaml/sqs/data.js +1 -1
  21. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +1 -1
  22. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/data.js +132 -0
  23. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +1 -1
  24. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +1 -1
  25. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +1 -1
  26. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/template.ejs +9 -0
  27. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  28. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  29. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  30. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  31. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/data.js +73 -0
  32. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/template.ejs +9 -0
  33. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  34. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  35. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/invTemplate.ejs +144 -0
  36. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  37. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +11 -11
  38. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +1 -1
  39. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +1 -1
  40. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/data.js +151 -0
  41. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +2 -2
  42. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +2 -2
  43. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +2 -2
  44. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/template.ejs +9 -0
  45. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  46. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  47. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  48. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  49. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/data.js +73 -0
  50. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/template.ejs +9 -0
  51. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  52. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  53. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/invTemplate.ejs +144 -0
  54. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  55. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +1 -1
  56. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +1 -1
  57. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/data.js +151 -0
  58. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +2 -2
  59. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +2 -2
  60. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +1 -1
  61. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/template.ejs +9 -0
  62. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  63. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  64. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  65. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  66. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/data.js +73 -0
  67. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/template.ejs +9 -0
  68. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  69. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  70. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/invTemplate.ejs +144 -0
  71. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  72. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +1 -1
  73. package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +131 -88
  74. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +2 -2
  75. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/data.js +151 -0
  76. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +2 -2
  77. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +2 -2
  78. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +1 -1
  79. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/template.ejs +9 -0
  80. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  81. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  82. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  83. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  84. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/data.js +73 -0
  85. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/template.ejs +9 -0
  86. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  87. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  88. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/invTemplate.ejs +144 -0
  89. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  90. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +1 -1
  91. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/data.js +153 -0
  92. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/template.ejs +9 -0
  93. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  94. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  95. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  96. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  97. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/data.js +73 -0
  98. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/template.ejs +9 -0
  99. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/apiTemplate.ejs +172 -0
  100. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/dsqTemplate.ejs +218 -0
  101. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/invTemplate.ejs +161 -0
  102. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/sqsTemplate.ejs +197 -0
  103. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/data.js +59 -0
  104. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/template.ejs +386 -0
  105. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/data.js +77 -0
  106. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
  107. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
  108. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/data.js +121 -0
  109. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/template.ejs +20 -0
  110. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/data.js +60 -0
  111. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/template.ejs +129 -0
  112. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/data.js +56 -0
  113. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/template.ejs +159 -0
  114. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/data.js +71 -0
  115. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/template.ejs +46 -0
  116. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/data.js +71 -0
  117. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/template.ejs +10 -0
  118. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +2 -2
  119. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/data.js +154 -0
  120. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +2 -2
  121. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +2 -2
  122. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +1 -1
  123. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/template.ejs +9 -0
  124. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  125. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  126. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  127. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  128. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/data.js +73 -0
  129. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/template.ejs +9 -0
  130. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  131. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  132. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/invTemplate.ejs +144 -0
  133. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  134. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +1 -1
@@ -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) %>
5
+ events:
6
+ - sqs:
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>
8
+ batchSize: 10
9
+ filterPatterns: #**** need to update serverless framework upper v.2.69.1
10
+ - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
+ role: <%- roleName %>Role
13
+ #<#<%- functionName %><%- handlerType %>IamRole#>
14
+ #<#/<%- functionName %><%- 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,60 @@
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/src/Utils.js");
24
+ const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../../MainLibs/src/Consts.js");
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
+ const functionName = FUNCTION_NAME.moveRelComplete;
42
+ const handler = HANDLER.hdrSqs
43
+
44
+ return {
45
+ templatePath: templatePath,
46
+ templateData: {
47
+ functionName: upperCase(functionName),
48
+ queueName: upperCase(functionName)
49
+ },
50
+ setting: {
51
+ savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
52
+ saveFileName: `${upperCase(functionName)}_${upperCase(handler)}`,
53
+ fileExtension: '.js',
54
+ isAppend: false
55
+ }
56
+ }
57
+ }
58
+
59
+
60
+ module.exports = data;
@@ -0,0 +1,129 @@
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
+
20
+ // const AWS = require('aws-sdk');
21
+ // const sqs = new AWS.SQS({ apiVersion: '2012-11-05' });
22
+
23
+ const izara = require("@izara_project/izara-middleware");
24
+ const middleware = izara.middlewareHandler;
25
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
26
+ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
27
+
28
+ const <%- functionName %> = require('./<%- functionName %>_Main');
29
+ const Logger = require('@izara_project/izara-core-library-logger');
30
+ // validate event properties in body.Message of sqs event
31
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
32
+ // set schema for record.body.Message
33
+ let perRecordsValidatorSchema = {
34
+ type: "object",
35
+ required: [
36
+ 'returnValue',
37
+ 'status',
38
+ 'errorsFound',
39
+ 'graphServiceTag'
40
+ ],
41
+ properties: {
42
+ returnValue: {
43
+ type: 'object',
44
+ },
45
+ status: {
46
+ type: 'string',
47
+ },
48
+ errorsFound: {
49
+ type: 'array',
50
+ default: []
51
+ },
52
+ graphServiceTag: {
53
+ type: 'string'
54
+ }
55
+ }
56
+ };
57
+
58
+ // set schema for record.body.MessageAttributes
59
+ // const messageAttributeValidatorSchema = {
60
+ // type: "object",
61
+ // required: ['msgAtrrParam1', 'msgAtrrParam2'],
62
+ // properties: {
63
+ // msgAtrrParam1: {
64
+ // type: "string"
65
+ // },
66
+ // msgAtrrParam2: {
67
+ // type: "object"
68
+ // }
69
+ // }
70
+ // };
71
+
72
+ perRecordsValidatorSchema = callingFlowSharedLib.addOptionalPassBackPropertiesToValidatorSchema(perRecordsValidatorSchema); // is Ok passBackProperties
73
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
74
+
75
+ try {
76
+
77
+ let recordPromises = [];
78
+
79
+ // loop each record and send to mainFunction
80
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
81
+
82
+ let passOnProperties = []
83
+ record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
84
+
85
+ //validate message (and MessageAttributes)
86
+ await recordHandlerSharedLib.validateRecord(
87
+ record, // one record will send to mainFunction
88
+ "<%- functionName %>", // queue name that need to retry or send to dlq
89
+ perRecordsValidatorSchema, // schema for record.Message
90
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
91
+ );
92
+
93
+ // add argument (to invoke lambda) to passOnProperties[]
94
+ passOnProperties.push(record.body.Message.returnValue)
95
+ passOnProperties.push(record.body.Message.status)
96
+ passOnProperties.push(record.body.Message.errorsFound)
97
+ passOnProperties.push(record.body.Message.graphServiceTag)
98
+ passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message)) // is Ok PassBackProperties
99
+ // passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)) // is Ok callingFlow
100
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
101
+
102
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
103
+ let recordPromise = recordHandlerSharedLib.recordHandler(
104
+ record, // one record will send to mainFunction
105
+ <%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
106
+ "<%- queueName %>", // queue name that need to retry or send to dlq
107
+ passOnProperties, // all parameters that mainFunction needed.
108
+ );
109
+ record._izContext.logger.debug('after recordPromise in handler');
110
+ recordPromises.push(recordPromise); // push promise to recordPromises
111
+ }))
112
+
113
+ Logger.debug('before Promise.all(recordPromises) in handler');
114
+ try {
115
+ // --- main await all promises
116
+ await Promise.all(recordPromises); // await all promises
117
+
118
+ return event.Records // return all for local testing
119
+
120
+ } catch {
121
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
122
+ }
123
+ Logger.debug('after Promise.all(recordPromises) in handler');
124
+
125
+ } catch (err) {
126
+ Logger.error('Unhandled Error, CreateRelationshipCompleteHdrSqs: ', err);
127
+ throw (err);
128
+ }
129
+ });
@@ -0,0 +1,56 @@
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, firstLetterUpperCase } = require("../../../../../../MainLibs/index.js").utils;
24
+ const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts.js");
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
+ const functionName = upperCase(FUNCTION_NAME.moveRelComplete);
42
+ return {
43
+ templatePath: templatePath,
44
+ templateData: {
45
+ functionName
46
+ },
47
+ setting: {
48
+ savePath: path.join(srcPath, SOURCE_PATH.relationshipPerAction),
49
+ saveFileName: `${upperCase(functionName)}_Main`,
50
+ fileExtension: '.js',
51
+ isAppend: false
52
+ }
53
+ }
54
+ }
55
+
56
+ module.exports = data;
@@ -0,0 +1,159 @@
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 hash = require('@izara_project/izara-shared-core').objectHash;
20
+
21
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
22
+ const lambdaSharedLib = require("@izara_project/izara-core-library-lambda");
23
+ const snsSharedLib = require("@izara_project/izara-core-library-sns");
24
+ const dynamodbSharedLib = require("@izara_project/izara-core-library-dynamodb");
25
+ const asyncFlowSharedLib = require("@izara_project/izara-core-library-asynchronous-flow");
26
+
27
+ const sns = require("@izara_project/izara-core-library-external-request").sns;
28
+ const NoRetryError = require("@izara_project/izara-core-library-core/src/NoRetryError");
29
+
30
+ const { explodedObjectTypeId, explodedRelationshipTypeId, createLinkTypeId } = require('@izara_project/izara-core-library-service-schemas/src/Utils')
31
+
32
+ const {
33
+ TOPIC_NAME_GENERATE_CODE,
34
+ TOPIC_NAME_GRAPH_HANDLER,
35
+ PREFIX
36
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
37
+
38
+ //(<optionalRequire>)
39
+ //(</optionalRequire>)
40
+
41
+ module.exports.<%- functionName %> = async (
42
+ _izContext,
43
+ returnValue,
44
+ status,
45
+ errorsFound,
46
+ graphServiceTag,
47
+ passBackProperties = {},
48
+
49
+ ) => {
50
+ try {
51
+ _izContext.logger.debug("Function:<%- functionName %>", {
52
+ returnValue: returnValue,
53
+ status: status,
54
+ errorsFound: errorsFound,
55
+ graphServiceTag: graphServiceTag,
56
+ passBackProperties: passBackProperties,
57
+ });
58
+
59
+ // start create awaitingStepId
60
+ const linkTypeId = createLinkTypeId(
61
+ _izContext,
62
+ returnValue.requestParams.firstObject.objType,
63
+ returnValue.requestParams.secondObject.objType,
64
+ returnValue.requestParams.relType,
65
+ returnValue.requestParams.relationshipProperties,
66
+ returnValue.requestParams.relationshipDirection,
67
+ returnValue.requestParams.moveObject,
68
+ );
69
+
70
+ let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
71
+ hash({
72
+ linkTypeId,
73
+ graphServiceTag: graphServiceTag,
74
+ callingFlowProperties: passBackProperties.passBackProperties.parentPassBackProperties.callingFlowProperties || {},
75
+ firstObject: returnValue.requestParams.firstObject,
76
+ secondObject: returnValue.requestParams.secondObject,
77
+ relType: returnValue.requestParams.relType,
78
+ relationshipProperties: returnValue.requestParams.relationshipProperties,
79
+ relationshipDirection: returnValue.requestParams.relationshipDirection,
80
+ moveObject: returnValue.requestParams.moveObject,
81
+ }), // hash id
82
+ PREFIX.changeRel // prefix, use constant further
83
+ )
84
+
85
+
86
+ let moveRelPendingObjects = await dynamodbSharedLib.query(
87
+ _izContext,
88
+ await dynamodbSharedLib.tableName(_izContext, "AwaitingMultipleSteps"),
89
+ {
90
+ awaitingStepId: awaitingStepId
91
+ }
92
+ );
93
+ _izContext.logger.debug("record of moveRelPendingObjects ::", moveRelPendingObjects);
94
+
95
+
96
+
97
+ await Promise.all(
98
+ moveRelPendingObjects.Items.map(async ({ pendingStepId }) => {
99
+ if (await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
100
+ _izContext,
101
+ pendingStepId, // task waiting
102
+ awaitingStepId,
103
+ errorsFound
104
+ )) {
105
+ _izContext.logger.debug("finished all awaitingStep");
106
+
107
+ let moveRelCompleteMsg = {
108
+ firstObject: returnValue.requestParams.firstObject,
109
+ secondObject: returnValue.requestParams.secondObject,
110
+ relType: returnValue.requestParams.relType,
111
+ relationshipProperties: returnValue.requestParams.relationshipProperties,
112
+ relationshipDirection: returnValue.requestParams.relationshipDirection,
113
+ moveObject: returnValue.requestParams.moveObject,
114
+ status: status,
115
+ errorsFound: errorsFound
116
+ };
117
+
118
+ moveRelCompleteMsg = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, moveRelCompleteMsg);
119
+ _izContext.logger.debug("After addCallingFlowToSnsResponseMessageObject", moveRelCompleteMsg);
120
+
121
+ let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
122
+ _izContext.logger.debug("After addCallingFlowToSnsResponseMessageAttributes", moveRelCompleteMsg);
123
+
124
+ let sendMessageToOutMoveRelationshipComplete = {
125
+ Message: JSON.stringify(moveRelCompleteMsg),
126
+ MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
127
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outMoveRelComplete)
128
+ };
129
+ _izContext.logger.debug("Send message to OutCreateRelationshipComplete :::>", sendMessageToOutMoveRelationshipComplete);
130
+ await sns.publishAsync(_izContext, sendMessageToOutMoveRelationshipComplete);
131
+
132
+ //(<afterCheckAwaitingStep>)
133
+ //(</afterCheckAwaitingStep>)
134
+ } // check pendingStepId finished
135
+
136
+ // remove awaitingMultipleStep after finished
137
+ await asyncFlowSharedLib.removeAwaitingMultipleStep(
138
+ _izContext,
139
+ awaitingStepId,
140
+ pendingStepId,
141
+ errorsFound
142
+ );
143
+ }) // end per pendingStep
144
+ );
145
+
146
+ //(<afterCheckAllAwaitingStep>)
147
+ //(</afterCheckAllAwaitingStep>)
148
+
149
+ return {
150
+ returnValue,
151
+ status,
152
+ errorsFound
153
+ }
154
+
155
+ } catch (err) {
156
+ _izContext.logger.error('error createRelationshipComplete:', err)
157
+ throw (err)
158
+ }
159
+ }
@@ -0,0 +1,71 @@
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
+
20
+ const path = require("path")
21
+
22
+ // const {
23
+ // HANDLER,
24
+ // STORAGE_TYPES
25
+ // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
26
+
27
+
28
+ const STORAGE_TYPES = {
29
+ dynamoDB: "dynamoDB",
30
+ graph: "graph"
31
+ }
32
+
33
+ const templatePath = path.join(__dirname, './template.ejs');
34
+ const { SOURCE_PATH, FUNCTION_NAME, SAVE_FILE_NAME } = require('../../../../../../MainLibs/index.js').consts;
35
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/index.js").utils;
36
+
37
+
38
+ /**
39
+ * create data for dynamoDbYaml tempalte from objectSchema
40
+ * return array of dynamoDb data
41
+ * because one objectSchema can create multiple dynamoDb table
42
+ *
43
+ * @param {Object} _izContext
44
+ * @param {String} saveFilePath
45
+ * @returns {Object[]} - data of multiple dynamoDb template
46
+ */
47
+
48
+ function createDataForDefaultSnsInSqs(_izContext, srcPath) {
49
+ let createCreateRelationCompleteQueue = [];
50
+ const createRelationshipCompleteQueues = [
51
+ {
52
+ queueName: upperCase(FUNCTION_NAME.moveRelComplete)
53
+ }
54
+ ]
55
+ for (let createRelationshipCompleteQueue of createRelationshipCompleteQueues) {
56
+ createCreateRelationCompleteQueue.push({
57
+ templatePath: templatePath,
58
+ templateData: createRelationshipCompleteQueue,
59
+ setting: {
60
+ initialData: "Resources:\n",
61
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
62
+ saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
63
+ fileExtension: ".yml",
64
+ isAppend: true
65
+ }
66
+ })
67
+ }
68
+ return createCreateRelationCompleteQueue
69
+ }
70
+
71
+ module.exports = createDataForDefaultSnsInSqs;
@@ -0,0 +1,46 @@
1
+ ##===== [Queue]
2
+ <%- queueName %>:
3
+ Type: "AWS::SQS::Queue"
4
+ Properties:
5
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
6
+ RedrivePolicy:
7
+ deadLetterTargetArn:
8
+ # !GetAtt
9
+ Fn::GetAtt:
10
+ - <%- queueName %>DLQ
11
+ - Arn
12
+ maxReceiveCount: 3
13
+ VisibilityTimeout: 120
14
+ ##==== [QueueDLQ]
15
+ <%- queueName %>DLQ:
16
+ Type: AWS::SQS::Queue
17
+ Properties:
18
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
19
+ ##==== [QueuePolicy]
20
+ <%- queueName %>Policy:
21
+ Type: AWS::SQS::QueuePolicy
22
+ Properties:
23
+ PolicyDocument:
24
+ Version: "2012-10-17"
25
+ Statement:
26
+ - Sid: "allow-sns-messages"
27
+ Effect: Allow
28
+ Principal: "*"
29
+ Resource:
30
+ # !GetAtt
31
+ Fn::GetAtt:
32
+ - <%- queueName %>
33
+ - Arn
34
+ Action: "SQS:SendMessage"
35
+ Queues:
36
+ - Ref: <%- queueName %>
37
+ #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
38
+ #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
39
+
40
+
41
+ <%_ function firstLetterUpperCase(text){
42
+ return text.charAt(0).toUpperCase() + text.slice(1)
43
+ } _%>
44
+ <%_ function firstLetterLowerCase(str) {
45
+ return str.charAt(0).toLowerCase() + str.slice(1)
46
+ } _%>
@@ -0,0 +1,71 @@
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
+
20
+ const path = require("path")
21
+
22
+ // const {
23
+ // HANDLER,
24
+ // STORAGE_TYPES
25
+ // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
26
+
27
+
28
+ const STORAGE_TYPES = {
29
+ dynamoDB: "dynamoDB",
30
+ graph: "graph"
31
+ }
32
+
33
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/index.js").utils;
34
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../../../../MainLibs/index.js").consts;
35
+ const templatePath = path.join(__dirname, './template.ejs')
36
+
37
+ /**
38
+ * create data for dynamoDbYaml tempalte from objectSchema
39
+ * return array of dynamoDb data
40
+ * because one objectSchema can create multiple dynamoDb table
41
+ *
42
+ * @param {Object} _izContext
43
+ * @param {String} saveFilePath
44
+ * @returns {Object[]} - data of multiple dynamoDb template
45
+ */
46
+
47
+ function createDefaultSnsOut(_izContext, srcPath) {
48
+ const createSourceParams = createParamsForCreateSource(_izContext, srcPath)
49
+ // console.log("createSourceParamsCreateRelationshipComplete", createSourceParams)
50
+
51
+ return [createSourceParams]
52
+ }
53
+
54
+ function createParamsForCreateSource(_izContext, srcPath) {
55
+ let queueName = FUNCTION_NAME.moveRelComplete;
56
+ return {
57
+ templatePath: templatePath,
58
+ templateData: {
59
+ queueName: upperCase(queueName)
60
+ },
61
+ setting: {
62
+ initialData: 'Resources:\n',
63
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
64
+ saveFileName: SAVE_FILE_NAME.snsOutYaml,
65
+ fileExtension: '.yml',
66
+ isAppend: true
67
+ }
68
+ }
69
+ }
70
+
71
+ module.exports = createDefaultSnsOut
@@ -0,0 +1,10 @@
1
+ ##--------- [Create Topic Out]
2
+ Out<%- firstLetterUpperCase(queueName) %>:
3
+ Type: AWS::SNS::Topic
4
+ Properties:
5
+ DisplayName: "SNS Message out"
6
+ TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- firstLetterUpperCase(queueName) %>_Out
7
+
8
+ <%_ function firstLetterUpperCase(text) {
9
+ return text.charAt(0).toUpperCase() + text.slice(1)
10
+ } _%>
@@ -126,8 +126,8 @@ function createParamForCreateSource(allObjectRelationships, srcPath) {
126
126
  handlerType,
127
127
  additionalResourcePermission,
128
128
  resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
129
- functionNameConfig: upperCase(SHORT_FUNCTION_NAME.updateRel) + upperCase(shortNameHandler(handlerType)),
130
- roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
129
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.updateRel)) + upperCase(shortNameHandler(handlerType)),
130
+ roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
131
131
  },
132
132
  setting: {
133
133
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),