@izara_project/izara-market-library-service-schemas 1.0.65 → 1.0.67

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 (146) hide show
  1. package/package.json +3 -3
  2. package/src/GenerateCodeLibs/src/Consts.js +7 -2
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +11 -1
  4. package/src/MainLibs/src/Consts.js +64 -25
  5. package/src/MainLibs/src/GenerateCodeUtils.js +6 -6
  6. package/src/reStructure/GenerateCode.js +2 -1
  7. package/src/reStructure/TemplateData/EndpointPerService/generateTemplateData.js +1 -1
  8. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -4
  9. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +49 -5
  10. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +3 -0
  11. package/src/reStructure/TemplateData/findData/findDataYaml/data.js +2 -2
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +1 -1
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +3 -1
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +14 -0
  15. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +2 -2
  16. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +3 -3
  17. package/src/reStructure/TemplateData/flowSchema/flowStep/handler/data.js +1 -1
  18. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +4 -2
  19. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +9 -9
  20. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +24 -24
  21. package/src/reStructure/TemplateData/generateRole/data.js +38 -24
  22. package/src/reStructure/TemplateData/generateRole/template.ejs +5 -7
  23. package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +1 -1
  24. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +1 -1
  25. package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +1 -1
  26. package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +1 -1
  27. package/src/reStructure/TemplateData/processLogical/yaml/data.js +4 -4
  28. package/src/reStructure/TemplateData/processLogicalPagination/yaml/dsq/data.js +2 -2
  29. package/src/reStructure/TemplateData/processLogicalPagination/yaml/sqs/data.js +2 -2
  30. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +1 -1
  31. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/data.js +136 -0
  32. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +1 -1
  33. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +1 -1
  34. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +1 -1
  35. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/template.ejs +9 -0
  36. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  37. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  38. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  39. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  40. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/data.js +73 -0
  41. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/template.ejs +9 -0
  42. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  43. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  44. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/invTemplate.ejs +144 -0
  45. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  46. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +11 -11
  47. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +1 -1
  48. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +1 -1
  49. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/data.js +159 -0
  50. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +2 -2
  51. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +2 -2
  52. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +2 -2
  53. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/template.ejs +9 -0
  54. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  55. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  56. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  57. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  58. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/data.js +73 -0
  59. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/template.ejs +9 -0
  60. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  61. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  62. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/invTemplate.ejs +144 -0
  63. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  64. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +1 -1
  65. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +1 -1
  66. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/data.js +158 -0
  67. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +2 -2
  68. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +2 -2
  69. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +1 -1
  70. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/template.ejs +9 -0
  71. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  72. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  73. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  74. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  75. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/data.js +73 -0
  76. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/template.ejs +9 -0
  77. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  78. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  79. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/invTemplate.ejs +144 -0
  80. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  81. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +1 -1
  82. package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +131 -88
  83. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +2 -2
  84. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/data.js +158 -0
  85. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +2 -2
  86. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +2 -2
  87. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +1 -1
  88. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/template.ejs +9 -0
  89. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  90. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  91. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  92. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  93. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/data.js +73 -0
  94. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/template.ejs +9 -0
  95. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  96. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  97. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/invTemplate.ejs +144 -0
  98. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  99. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +1 -1
  100. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/data.js +160 -0
  101. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/template.ejs +9 -0
  102. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  103. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  104. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  105. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  106. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/data.js +73 -0
  107. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/template.ejs +9 -0
  108. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/apiTemplate.ejs +172 -0
  109. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/dsqTemplate.ejs +218 -0
  110. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/invTemplate.ejs +161 -0
  111. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/sqsTemplate.ejs +197 -0
  112. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/data.js +59 -0
  113. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/template.ejs +386 -0
  114. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/data.js +77 -0
  115. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
  116. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
  117. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/data.js +121 -0
  118. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/template.ejs +20 -0
  119. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/data.js +60 -0
  120. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/template.ejs +129 -0
  121. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/data.js +56 -0
  122. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/template.ejs +159 -0
  123. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/data.js +71 -0
  124. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/template.ejs +46 -0
  125. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/data.js +71 -0
  126. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/template.ejs +10 -0
  127. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +2 -2
  128. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/data.js +164 -0
  129. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +2 -2
  130. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +2 -2
  131. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +1 -1
  132. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/template.ejs +9 -0
  133. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
  134. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
  135. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
  136. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
  137. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/data.js +73 -0
  138. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/template.ejs +9 -0
  139. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/apiTemplate.ejs +155 -0
  140. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
  141. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/invTemplate.ejs +144 -0
  142. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
  143. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +1 -1
  144. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +8 -7
  145. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +36 -30
  146. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +3 -3
@@ -0,0 +1,202 @@
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 izara = require("@izara_project/izara-middleware");
21
+ const middleware = izara.middlewareHandler;
22
+
23
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
24
+
25
+ // const CorrelationIds = require('@izara_project/izara-core-library-correlation-ids')
26
+ // const IntegrationTestDetail = require('@izara_project/izara-core-library-integration-tests')
27
+ const Logger = require('@izara_project/izara-core-library-logger');
28
+ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
29
+
30
+
31
+ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
32
+ // validate event properties in body.Message of sqs event
33
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
34
+ {
35
+ type: "object",
36
+ required: ['body', 'messageAttributes'],
37
+ properties: {
38
+ body: {
39
+ type: 'object',
40
+ },
41
+ messageAttributes: {
42
+ type: 'object'
43
+ }
44
+ }
45
+ }
46
+ ));
47
+
48
+ // validate event params in middlewware before into function.
49
+ let validatorSchema = {
50
+ type: "object",
51
+ required: [
52
+ 'firstObject',
53
+ 'secondObject',
54
+ 'oldReltypeAndDirection',
55
+ 'newRelType',
56
+ ],
57
+ properties: {
58
+ firstObject: {
59
+ type: 'object',
60
+ required: ['objType', 'identifiers'],
61
+ properties: {
62
+ objType: {
63
+ type: 'object',
64
+ required: ['objectType', 'serviceTag'],
65
+ properties: {
66
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
67
+ objectType: izara.validatorSchema.stringNotEmpty(),
68
+ }
69
+ },
70
+ identifiers: {
71
+ type: "object",
72
+ minProperties: 1
73
+ },
74
+ }
75
+ },
76
+ secondObject: {
77
+ type: 'object',
78
+ required: ['objType', 'identifiers'],
79
+ properties: {
80
+ objType: {
81
+ type: 'object',
82
+ required: ['objectType', 'serviceTag'],
83
+ properties: {
84
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
85
+ objectType: izara.validatorSchema.stringNotEmpty(),
86
+ }
87
+ },
88
+ identifiers: {
89
+ type: "object",
90
+ minProperties: 1
91
+ },
92
+ }
93
+ },
94
+ oldReltypeAndDirection: {
95
+ type: 'object',
96
+ required: ['relType', 'relationshipDirection'],
97
+ properties: {
98
+ relType: {
99
+ type: 'object',
100
+ required: ['serviceTag', 'relationshipTag'],
101
+ properties: {
102
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
103
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
104
+ }
105
+ },
106
+ relationshipProperties: {
107
+ type: 'object',
108
+ },
109
+ relationshipDirection: {
110
+ type: 'string',
111
+ enum: ['from', 'to']
112
+
113
+ },
114
+ }
115
+ },
116
+ newRelType: {
117
+ type: 'object',
118
+ required: ['serviceTag', 'relationshipTag'],
119
+ properties: {
120
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
121
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
122
+ }
123
+ },
124
+ settings: {
125
+ type: 'object'
126
+ }
127
+ }
128
+ };
129
+
130
+
131
+ //(<globalVariable>
132
+ //</globalVariable>)
133
+
134
+ // validate event params in middleware before into main function
135
+ validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
136
+ // if need to validate authorizer or additional params , add code to hook tag below
137
+
138
+ //(<afterValidateWith>)
139
+ //(</afterValidateWith>)
140
+
141
+
142
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
143
+ Logger.debug('event:', event);
144
+ Logger.debug('context:', context);
145
+ try {
146
+
147
+ let recordPromises = []; // final return
148
+
149
+ // loop each record and send to mainFunction
150
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
151
+
152
+ // --- reforming record.body for Dsq request
153
+ record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
154
+ record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
155
+
156
+ let passOnProperties = []
157
+
158
+ // --- validate message (and MessageAttributes)
159
+ await recordHandlerSharedLib.validateRecord(
160
+ record, // one record will send to mainFunction
161
+ "<%- queueName %>", // queue name that need to retry or send to dlq
162
+ validatorSchema, // schema for record.Message
163
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
164
+ );
165
+
166
+ // add argument (to invoke lambda) to passOnProperties[]
167
+ passOnProperties.push(record.body.Message)
168
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
169
+ //(<afterPutParamIntoMainFunction>)
170
+ //(</afterPutParamIntoMainFunction>)
171
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
172
+
173
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
174
+ let recordPromise = recordHandlerSharedLib.recordHandler(
175
+ record, // one record will send to mainFunction
176
+ <%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
177
+ "<%- queueName %>", // queue name that need to retry or send to dlq
178
+ passOnProperties, // all parameters that mainFunction needed.
179
+ );
180
+ record._izContext.logger.debug('after recordPromise in handler');
181
+ recordPromises.push(recordPromise); // push promise to recordPromises
182
+ })) //end record
183
+
184
+ Logger.debug('before Promise.all(recordPromises) in handler');
185
+ try {
186
+ await Promise.all(recordPromises); // await all promises
187
+ return event.Records // return all for local test
188
+ } catch {
189
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
190
+ }
191
+ Logger.debug('after Promise.all(recordPromises) in handler');
192
+ } catch (err) {
193
+ Logger.error('Unhandled Error, updateRelationshipHdrDsq:', err);
194
+ throw (err);
195
+ }
196
+ });
197
+ <%_ function firstLetterUpperCase(text) {
198
+ return text.charAt(0).toUpperCase() + text.slice(1)
199
+ } _%>
200
+ <%_ function firstLetterLowerCase(str) {
201
+ return str.charAt(0).toLowerCase() + str.slice(1)
202
+ } _%>
@@ -0,0 +1,144 @@
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 izara = require("@izara_project/izara-middleware");
21
+ const middleware = izara.middlewareHandler;
22
+
23
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
24
+
25
+ // const CorrelationIds = require('@izara_project/izara-core-library-correlation-ids')
26
+ // const Logger = require('@izara_project/izara-core-library-logger');
27
+ // const IntegrationTestDetail = require('@izara_project/izara-core-library-integration-tests')
28
+
29
+ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
30
+
31
+ // validate event params in middlewware before into function.
32
+ let validatorSchema = {
33
+ type: "object",
34
+ required: [
35
+ 'firstObject',
36
+ 'secondObject',
37
+ 'oldReltypeAndDirection',
38
+ 'newRelType',
39
+ ],
40
+ properties: {
41
+ firstObject: {
42
+ type: 'object',
43
+ required: ['objType', 'identifiers'],
44
+ properties: {
45
+ objType: {
46
+ type: 'object',
47
+ required: ['objectType', 'serviceTag'],
48
+ properties: {
49
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
50
+ objectType: izara.validatorSchema.stringNotEmpty(),
51
+ }
52
+ },
53
+ identifiers: {
54
+ type: "object",
55
+ minProperties: 1
56
+ },
57
+ }
58
+ },
59
+ secondObject: {
60
+ type: 'object',
61
+ required: ['objType', 'identifiers'],
62
+ properties: {
63
+ objType: {
64
+ type: 'object',
65
+ required: ['objectType', 'serviceTag'],
66
+ properties: {
67
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
68
+ objectType: izara.validatorSchema.stringNotEmpty(),
69
+ }
70
+ },
71
+ identifiers: {
72
+ type: "object",
73
+ minProperties: 1
74
+ },
75
+ }
76
+ },
77
+ oldReltypeAndDirection: {
78
+ type: 'object',
79
+ required: ['relType', 'relationshipDirection'],
80
+ properties: {
81
+ relType: {
82
+ type: 'object',
83
+ required: ['serviceTag', 'relationshipTag'],
84
+ properties: {
85
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
86
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
87
+ }
88
+ },
89
+ relationshipProperties: {
90
+ type: 'object',
91
+ },
92
+ relationshipDirection: {
93
+ type: 'string',
94
+ enum: ['from', 'to']
95
+
96
+ },
97
+ }
98
+ },
99
+ newRelType: {
100
+ type: 'object',
101
+ required: ['serviceTag', 'relationshipTag'],
102
+ properties: {
103
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
104
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
105
+ }
106
+ },
107
+ settings: {
108
+ type: 'object'
109
+ }
110
+ }
111
+ };
112
+
113
+ validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema); // is Ok callinfFlow
114
+ middleware.setValidatorSchema(validatorSchema)
115
+
116
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
117
+ event._izContext.logger.debug('Event:', event);
118
+ event._izContext.logger.debug('context:', context);
119
+
120
+ try {
121
+ // invoke LambdaFunction
122
+ return await <%- functionName %>.<%- functionName %>(
123
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
124
+ {
125
+ firstObject: event.firstObject,
126
+ secondObject: event.secondObject,
127
+ relType: event.relType,
128
+ relationshipDirection: event.relationshipDirection,
129
+ relationshipProperties: event.relationshipProperties,
130
+ },
131
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
132
+ );
133
+
134
+ } catch (err) {
135
+ event._izContext.logger.error('Error, <%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handler) %> : ', err);
136
+ throw (err);
137
+ }
138
+ });
139
+ <%_ function firstLetterUpperCase(text) {
140
+ return text.charAt(0).toUpperCase() + text.slice(1)
141
+ } _%>
142
+ <%_ function firstLetterLowerCase(str) {
143
+ return str.charAt(0).toLowerCase() + str.slice(1)
144
+ } _%>
@@ -0,0 +1,181 @@
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
+ const Logger = require('@izara_project/izara-core-library-logger');
26
+ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
27
+
28
+ const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
29
+
30
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
31
+
32
+ // validate event params in middleware before into function
33
+ let validatorSchema = {
34
+ type: "object",
35
+ required: [
36
+ 'firstObject',
37
+ 'secondObject',
38
+ 'oldReltypeAndDirection',
39
+ 'newRelType',
40
+ ],
41
+ properties: {
42
+ firstObject: {
43
+ type: 'object',
44
+ required: ['objType', 'identifiers'],
45
+ properties: {
46
+ objType: {
47
+ type: 'object',
48
+ required: ['objectType', 'serviceTag'],
49
+ properties: {
50
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
51
+ objectType: izara.validatorSchema.stringNotEmpty(),
52
+ }
53
+ },
54
+ identifiers: {
55
+ type: "object",
56
+ minProperties: 1
57
+ },
58
+ }
59
+ },
60
+ secondObject: {
61
+ type: 'object',
62
+ required: ['objType', 'identifiers'],
63
+ properties: {
64
+ objType: {
65
+ type: 'object',
66
+ required: ['objectType', 'serviceTag'],
67
+ properties: {
68
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
69
+ objectType: izara.validatorSchema.stringNotEmpty(),
70
+ }
71
+ },
72
+ identifiers: {
73
+ type: "object",
74
+ minProperties: 1
75
+ },
76
+ }
77
+ },
78
+ oldReltypeAndDirection: {
79
+ type: 'object',
80
+ required: ['relType', 'relationshipDirection'],
81
+ properties: {
82
+ relType: {
83
+ type: 'object',
84
+ required: ['serviceTag', 'relationshipTag'],
85
+ properties: {
86
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
87
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
88
+ }
89
+ },
90
+ relationshipProperties: {
91
+ type: 'object',
92
+ },
93
+ relationshipDirection: {
94
+ type: 'string',
95
+ enum: ['from', 'to']
96
+
97
+ },
98
+ }
99
+ },
100
+ newRelType: {
101
+ type: 'object',
102
+ required: ['serviceTag', 'relationshipTag'],
103
+ properties: {
104
+ serviceTag: izara.validatorSchema.stringNotEmpty(),
105
+ relationshipTag: izara.validatorSchema.stringNotEmpty(),
106
+ }
107
+ },
108
+ settings: {
109
+ type: 'object'
110
+ }
111
+ }
112
+ };
113
+
114
+
115
+ //(<globalVariable>
116
+ //</globalVariable>)
117
+
118
+ // validate event params in middleware before into main function
119
+ validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
120
+ // if need to validate authorizer or additional params , add code to hook tag below
121
+
122
+ //(<afterValidateWith>)
123
+ //(</afterValidateWith>)
124
+
125
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
126
+
127
+ try {
128
+
129
+ let recordPromises = []; // final return
130
+
131
+ // loop each record and send to mainFunction
132
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
133
+
134
+ let passOnProperties = []
135
+
136
+ // --- validate message (and MessageAttributes)
137
+ await recordHandlerSharedLib.validateRecord(
138
+ record, // one record will send to mainFunction
139
+ "<%-firstLetterUpperCase(queueName) %>", // queue name that need to retry or send to dlq
140
+ validatorSchema, // schema for record.Message
141
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
142
+ );
143
+
144
+ // add argument (to invoke lambda) to passOnProperties[]
145
+ passOnProperties.push(record.body.Message)
146
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
147
+ //(<afterPutParamIntoMainFunction>)
148
+ //(</afterPutParamIntoMainFunction>)
149
+
150
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
151
+
152
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
153
+ let recordPromise = recordHandlerSharedLib.recordHandler(
154
+ record, // one record will send to mainFunction
155
+ <%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
156
+ "<%-firstLetterUpperCase(queueName) %>", // queue name that need to retry or send to dlq
157
+ passOnProperties, // all parameters that mainFunction needed.
158
+ );
159
+ record._izContext.logger.debug('after recordPromise in handler');
160
+ recordPromises.push(recordPromise); // push promise to recordPromises
161
+ })) //end record
162
+
163
+ Logger.debug('before Promise.all(recordPromises) in handler');
164
+ try {
165
+ await Promise.all(recordPromises); // await all promises
166
+ return event.Records // return all for local test
167
+ } catch {
168
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
169
+ }
170
+ Logger.debug('after Promise.all(recordPromises) in handler');
171
+ } catch (err) {
172
+ Logger.error('Unhandled Error, updateRelationshipHdrDsq:', err);
173
+ throw (err);
174
+ }
175
+ });
176
+ <%_ function firstLetterUpperCase(text) {
177
+ return text.charAt(0).toUpperCase() + text.slice(1)
178
+ } _%>
179
+ <%_ function firstLetterLowerCase(str) {
180
+ return str.charAt(0).toLowerCase() + str.slice(1)
181
+ } _%>
@@ -100,7 +100,7 @@ function createParamForCreateSource(srcPath) {
100
100
  handlerType,
101
101
  additionalResourcePermission,
102
102
  resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
103
- functionNameConfig: upperCase(SHORT_FUNCTION_NAME.deleteRelComplete),
103
+ functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.deleteRelComplete)),
104
104
  roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipCompleteRole
105
105
  },
106
106
  setting: {