@izara_project/izara-market-library-service-schemas 1.0.32 → 1.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +2 -1
  3. package/src/MainLibs/src/Consts.js +7 -2
  4. package/src/reStructure/GenerateCode.js +16 -18
  5. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +1 -1
  6. package/src/reStructure/TemplateData/externalService/functionNameConfig/data.js +18 -8
  7. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +15 -15
  8. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +2 -2
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/template.ejs +0 -4
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
  11. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +11 -1
  12. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +1 -14
  13. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +0 -0
  14. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +81 -0
  15. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +202 -0
  16. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +21 -0
  17. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +77 -0
  18. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/request.json +7 -0
  19. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/template.ejs +64 -0
  20. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +73 -0
  21. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/request.json +5 -0
  22. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +88 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +1 -1
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +1 -1
  25. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +1 -1
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +1 -1
  27. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +89 -0
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +20 -0
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +57 -0
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/template.ejs +85 -0
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +55 -0
  32. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +85 -0
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +3 -28
  34. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +6 -10
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +4 -2
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +4 -3
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +26 -0
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +2 -2
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +6 -10
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +4 -4
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -4
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +3 -4
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +18 -18
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/sqsTemplate.ejs +53 -0
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +77 -0
  46. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +55 -10
  47. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +27 -7
  48. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template copy.ejs +0 -125
  49. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/sns-in/template.ejs → createRecordByStatusType/statusFieldTemplate.ejs} +0 -0
@@ -81,18 +81,35 @@ const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
81
81
  const createExternalTopicSnsOut = require('./externalTopic/sns-out/data');
82
82
 
83
83
  // flowSchema OwnTopic component
84
- const createFlowSchemaOwnTopicFunctionYaml = require('./flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data')
85
- const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/FlowSchemaComponent/handler/data')
86
- const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data')
84
+ const createFlowSchemaOwnTopicFunctionYaml = require('./flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data');
85
+ const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/FlowSchemaComponent/handler/data');
86
+ const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data');
87
87
 
88
88
  // flowSchema OwnTopicComplete component
89
- const createFlowSchemaOwnTopicCompleteFunctionYaml = require("./flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data")
90
- const createFlowSchemaOwnTopicCompleteHandler = require("./flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data")
91
- const createFlowSchemaOwnTopicCompleteMainFunction = require("./flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data")
89
+ const createFlowSchemaOwnTopicCompleteFunctionYaml = require("./flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data");
90
+ const createFlowSchemaOwnTopicCompleteHandler = require("./flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data");
91
+ const createFlowSchemaOwnTopicCompleteMainFunction = require("./flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data");
92
+
93
+ // flowSchema OwnTopicEndpoint component
94
+ const createFlowSchemaOwnTopicEndpointFuntionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data');
95
+ const createFlowSchemaOwnTopicEndpointHandler = require('./flowSchemaOwnTopic/EndpointComponent/handler/data');
96
+ const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTopic/EndpointComponent/mainFunction/data');
97
+
98
+ // flowSchema OwnTopicEndpointComplete component
99
+ const createFlowSchemaOwnTopicEndpointCompleteFuntionYaml = require('./flowSchemaOwnTopic/EndpointComplete/functionYaml/data');
100
+ const createFlowSchemaOwnTopicEndpointCompleteHandler = require('./flowSchemaOwnTopic/EndpointComplete/handler/data');
101
+ const createFlowSchemaOwnTopicEndpointCompleteMainFunction = require('./flowSchemaOwnTopic/EndpointComplete/mainFunction/data');
102
+
103
+ const createFlowSchemaOwnTopicQueue = require('./flowSchemaOwnTopic/sns-in/data');
104
+ const createFlowSchemaOwnTopicSnsOut = require('./flowSchemaOwnTopic/sns-out/data');
105
+ // ** EventBridge **
106
+ const createFlowSchemaEventBridgeFunctionYaml = require('./eventBridge/functionYaml/data');
107
+ const createFlowSchemaEventBridgeHandler = require('./eventBridge/handler/inv/data');
108
+ const createFlowSchemaEventBridgeMainFunction = require('./eventBridge/mainFunction/data');
109
+
110
+ const createFlowSchemaDynamoDb = require('./dynamoDb/data')
111
+
92
112
 
93
- const createFlowSchemaOwnTopicEndpointFuntionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data')
94
- const createFlowSchemaOwnTopicEndpointHandler = require('./flowSchemaOwnTopic/EndpointComponent/handler/data')
95
- const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTopic/EndpointComponent/mainFunction/data')
96
113
  /**
97
114
  * Generates code with templates for different actions
98
115
  * @param {Object} _izContext - Context object
@@ -100,6 +117,7 @@ const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTop
100
117
  * @returns {Array} Array of generated code parameters
101
118
  */
102
119
  async function generateCodeWithTemplate(_izContext, objSchemaPath) {
120
+ console.log("objSchemaPath", objSchemaPath);
103
121
  try {
104
122
  const saveFilePath = join(objSchemaPath, '../');
105
123
  let createSourceParams = [];
@@ -259,15 +277,42 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
259
277
  const flowSchemaOwnTopicEndpointMainFunction = createFlowSchemaOwnTopicEndpointMainFunction(_izContext, flowSchema, saveFilePath);
260
278
  const flowSchemaOwnTopicEndpointComponent = [...flowSchemaOwnTopicEndpointFuntionYaml, ...flowSchemaOwnTopicEndpointHandler, ...flowSchemaOwnTopicEndpointMainFunction]
261
279
 
280
+ // flowSchemaOwnTopic EndpointComplete
281
+ const flowSchemaOwnTopicEndpointCompleteFuntionYaml = createFlowSchemaOwnTopicEndpointCompleteFuntionYaml(_izContext, flowSchema, saveFilePath);
282
+ const flowSchemaOwnTopicEndpointCompleteHandler = createFlowSchemaOwnTopicEndpointCompleteHandler(_izContext, flowSchema, saveFilePath);
283
+ const flowSchemaOwnTopicEndpointCompleteMainFunction = createFlowSchemaOwnTopicEndpointCompleteMainFunction(_izContext, flowSchema, saveFilePath);
284
+ const flowSchemaOwnTopicEndpointCompleteComponent = [...flowSchemaOwnTopicEndpointCompleteFuntionYaml, ...flowSchemaOwnTopicEndpointCompleteHandler, ...flowSchemaOwnTopicEndpointCompleteMainFunction];
285
+
286
+ const flowSchemaOwnTopicQueue = createFlowSchemaOwnTopicQueue(_izContext, flowSchema, saveFilePath);
287
+ const flowSchemaOwnTopicSnsOut = createFlowSchemaOwnTopicSnsOut(_izContext, flowSchema, saveFilePath);
262
288
  // Group the resources
263
289
  const ownTopicResources = [
264
- ...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicCompleteComponent, ...flowSchemaOwnTopicEndpointComponent
290
+ ...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicCompleteComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut, ...flowSchemaOwnTopicEndpointCompleteComponent
265
291
  ];
266
292
 
267
293
  console.log("event ownTopic generated")
268
294
  createSourceParams.push(...ownTopicResources);
269
295
 
270
296
 
297
+ } else if (event.includes("eventBridge")) {
298
+ const flowSchemaEventBridgeHandler = createFlowSchemaEventBridgeHandler(_izContext, flowSchema, saveFilePath);
299
+ const flowSchemaEventBridgeMainFunction = createFlowSchemaEventBridgeMainFunction(_izContext, flowSchema, saveFilePath);
300
+ const flowSchemaEventBridgeFunctionYaml = createFlowSchemaEventBridgeFunctionYaml(_izContext, flowSchema, saveFilePath);
301
+
302
+ // Group the resources
303
+ const eventBridgeResources = [
304
+ ...flowSchemaEventBridgeHandler,
305
+ ...flowSchemaEventBridgeMainFunction,
306
+ ...flowSchemaEventBridgeFunctionYaml
307
+ ];
308
+
309
+ console.log("event eventBridge generated")
310
+ createSourceParams.push(...eventBridgeResources);
311
+ }
312
+
313
+ if (flowSchema.statusType === "storedCache") {
314
+ const flowSchemaDynamoDb = createFlowSchemaDynamoDb(_izContext, flowSchema, saveFilePath)
315
+ createSourceParams.push(...flowSchemaDynamoDb);
271
316
  }
272
317
  }
273
318
  }
@@ -106,7 +106,7 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
106
106
  handlerType: [],
107
107
  resources: {}
108
108
  },
109
- [SOURCE_GENERATE_IAM_ROLE.perActionEndpoint]: {
109
+ [SOURCE_GENERATE_IAM_ROLE.PerActionEndpoint]: {
110
110
  handlerType: [],
111
111
  resources: {}
112
112
  },
@@ -118,6 +118,14 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
118
118
  handlerType: [],
119
119
  resources: {}
120
120
  },
121
+ "WebsocketConnect": {
122
+ handlerType: [],
123
+ resources: {}
124
+ },
125
+ [SOURCE_GENERATE_IAM_ROLE.EventBridge]: {
126
+ handlerType: [],
127
+ resources: {}
128
+ },
121
129
  Other: []
122
130
  };
123
131
  const objectTypeList = [];
@@ -193,30 +201,42 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
193
201
  templateData.additionalResourcePermission,
194
202
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ProcessFindDataRole].resources
195
203
  );
196
- } else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role)) {
204
+ } else if (templateData?.roleName?.includes(SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role)) {
197
205
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role].handlerType.push(templateData);
198
206
  processResourcePermissions(
199
207
  templateData.additionalResourcePermission,
200
208
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role].resources
201
209
  )
202
- } else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.perActionEndpoint)) {
203
- groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.perActionEndpoint].handlerType.push(templateData);
210
+ } else if (templateData?.roleName?.includes(SOURCE_GENERATE_IAM_ROLE.PerActionEndpoint)) {
211
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.PerActionEndpoint].handlerType.push(templateData);
204
212
  processResourcePermissions(
205
213
  templateData.additionalResourcePermission,
206
- groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.perActionEndpoint].resources
214
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.PerActionEndpoint].resources
207
215
  )
208
- } else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic)) {
216
+ } else if (templateData?.roleName?.includes(SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic)) {
209
217
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic].handlerType.push(templateData);
210
218
  processResourcePermissions(
211
219
  templateData.additionalResourcePermission,
212
220
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic].resources
213
221
  )
214
- } else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole)) {
222
+ } else if (templateData?.roleName?.includes(SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole)) {
215
223
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole].handlerType.push(templateData);
216
224
  processResourcePermissions(
217
225
  templateData.additionalResourcePermission,
218
226
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole].resources
219
227
  )
228
+ } else if (templateData?.roleName?.includes("WebsocketConnect")) {
229
+ groupedByObjectType["WebsocketConnect"].handlerType.push(templateData);
230
+ processResourcePermissions(
231
+ templateData.additionalResourcePermission,
232
+ groupedByObjectType["WebsocketConnect"].resources
233
+ )
234
+ } else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.EventBridge)) {
235
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.EventBridge].handlerType.push(templateData);
236
+ processResourcePermissions(
237
+ templateData.additionalResourcePermission,
238
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.EventBridge].resources
239
+ )
220
240
  }
221
241
  else {
222
242
  // Handle other items
@@ -1,125 +0,0 @@
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 { middlewareHandler, consts } = require("@izara_project/izara-middleware");
20
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
21
- const Logger = require('@izara_project/izara-core-library-logger');
22
- const {validateSchemaPerRecord} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
23
- const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
24
-
25
- const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main.js')
26
-
27
- //(<globalVarible>
28
- //</globalVarible>)
29
-
30
- //validate event params in middleware before into main function
31
- middleware.setValidatorSchema(
32
- recordHandlerSharedLib.baseValidatorSchema(),
33
- //(<middlewareSettings>)
34
- //(</middlewareSettings>)
35
- )
36
- /*
37
- const perRecordsValidatorSchema = {
38
- type: "object",
39
- required: [],
40
- properties: {},
41
- }
42
- */
43
- //(<globalValidatorSchema>)
44
- //(</globalValidatorSchema>)
45
-
46
- // if need to validate authorizer or additional params , add code to hook tag below
47
-
48
- module.exports.main = middlewareHandler.wrap(async (event,context, callback) => {
49
-
50
- try {
51
-
52
- let recordPromises = [];
53
-
54
- await Promise.all(event.Records.map(async record => {
55
- record._izContext.logger.debug('record RecieveMsgOutHdrSqs', record);
56
-
57
- let passOnProperties = [];
58
-
59
- const OBJTYPE = {
60
- objectType: record.body.Message.objectType,
61
- serviceTag: process.env.iz_serviceTag
62
- }
63
-
64
- await validateSchemaPerRecord(
65
- record,
66
- "<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
67
- OBJTYPE,
68
- "<%- action %>"
69
- //(<validateSchemaSetting>)
70
- //(</validateSchemaSetting>)
71
- )
72
-
73
- //for validate additional params
74
- /*
75
- await recordHandlerSharedLib.validateRecord(
76
- record,
77
- "<%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>",
78
- perRecordsValidatorSchema
79
- );
80
- */
81
- //(<afterGenerateValidatorSchema>)
82
- //(</afterGenerateValidatorSchema>)
83
-
84
- //(<additionalParams>)
85
- //(</additionalParams>)
86
-
87
- passOnProperties.push(record.body.Message);
88
- passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
89
- record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
90
-
91
- let recordPromise = recordHandlerSharedLib.recordHandler(
92
- record,
93
- <%- action %>Main, // mainFunction
94
- '<%- firstLetterUpperCase(queueName) %>', // queueName
95
- passOnProperties
96
- );
97
- record._izContext.logger.debug('after record Promise in handler');
98
- recordPromises.push(recordPromise);
99
- }))
100
-
101
- Logger.debug('before Promise.all(recordPromise) in handler');
102
- try {
103
- await Promise.all(recordPromises);
104
-
105
- return event.Records
106
- } catch {
107
- Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
108
- }
109
- Logger.debug('after Promise.all(recordPromises) in handler');
110
-
111
- } catch (err) {
112
- Logger.debug('unhandled error <%- firstLetterUpperCase(action) %><%- firstLetterUpperCase(handler) %>')
113
- throw err
114
- }
115
- }
116
- )
117
-
118
-
119
-
120
- <%_ function firstLetterUpperCase(text){
121
- return text.charAt(0).toUpperCase() + text.slice(1)
122
- } _%>
123
- <%_ function firstLetterLowerCase(str) {
124
- return str.charAt(0).toLowerCase() + str.slice(1)
125
- } _%>