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

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 (65) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +2 -1
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +15 -1
  4. package/src/MainLibs/src/Consts.js +7 -2
  5. package/src/reStructure/GenerateCode.js +16 -18
  6. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +1 -1
  7. package/src/reStructure/TemplateData/externalService/functionNameConfig/data.js +18 -8
  8. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +1 -1
  9. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +15 -15
  10. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +2 -2
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/template.ejs +0 -4
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
  13. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +11 -1
  14. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +1 -14
  15. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +14 -0
  16. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +17 -0
  17. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +81 -0
  18. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +202 -0
  19. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +21 -0
  20. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +77 -0
  21. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/request.json +7 -0
  22. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/template.ejs +64 -0
  23. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +73 -0
  24. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/request.json +5 -0
  25. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +88 -0
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +1 -1
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +1 -1
  29. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +1 -1
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +89 -0
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +20 -0
  32. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +57 -0
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/template.ejs +85 -0
  34. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +55 -0
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +85 -0
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +3 -28
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +6 -10
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +4 -2
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +4 -3
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +26 -0
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +2 -2
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +6 -10
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +4 -4
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -4
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +8 -1
  46. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +32 -5
  47. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +18 -18
  48. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/sqsTemplate.ejs +53 -0
  49. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +77 -0
  50. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +55 -10
  51. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +27 -7
  52. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +3 -3
  53. package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +9 -3
  54. package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +1 -1
  55. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +9 -3
  56. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +1 -1
  57. package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +10 -4
  58. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +1 -1
  59. package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +9 -3
  60. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +1 -1
  61. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +5 -5
  62. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +5 -5
  63. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +1 -1
  64. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template copy.ejs +0 -125
  65. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/template.ejs +0 -0
@@ -25,16 +25,15 @@ const path = require("path")
25
25
  // STORAGE_TYPES
26
26
  // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
27
27
 
28
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/utils.js");
28
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils.js");
29
29
  const STORAGE_TYPES = {
30
30
  dynamoDB: "dynamoDB",
31
31
  graph: "graph"
32
32
  }
33
33
 
34
- const snsTemplatePath = path.join(__dirname, './snsTemplate.ejs');
34
+ const snsTemplatePath = path.join(__dirname, '../../../resourceYaml/sns-in-sqs/snsTemplate.ejs');
35
35
  const sqsTemplatePath = path.join(__dirname, './sqsTemplate.ejs');
36
- const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../MainLibs/src/Consts.js')
37
-
36
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js');
38
37
 
39
38
  /**
40
39
  * create data for dynamoDbYaml tempalte from objectSchema
@@ -46,9 +45,9 @@ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../.
46
45
  * @returns {Object[]} - data of multiple dynamoDb template
47
46
  */
48
47
 
49
- function createDataForDefaultSnsInSqs(_izContext, srcPath) {
48
+ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
50
49
  let resultsForCreateDefaultSnsInSqs = [];
51
- const defaultSnsInSqsDataList = [];
50
+
52
51
  const setting = {
53
52
  initialData: "Resources:\n",
54
53
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
@@ -58,19 +57,15 @@ function createDataForDefaultSnsInSqs(_izContext, srcPath) {
58
57
  }
59
58
 
60
59
  // GCTpBasTestInPersonCreate => GCTpBas_Test_PersonCreate_In
61
- defaultSnsInSqsDataList.push(
62
- {
63
- queueName: upperCase(FUNCTION_NAME.findData)
64
- },
60
+ let flowSteps = Object.keys(flowSchema.flowSteps)
61
+ const generatedSnsTopicInForFlowSchema = [
65
62
  {
66
- queueName: upperCase(FUNCTION_NAME.processLogical)
63
+ queueName: upperCase(flowSteps[0].split("_")[0]),
67
64
  },
68
- {
69
- queueName: upperCase(FUNCTION_NAME.paginateProcessLogical)
70
- }
71
- )
65
+ ];
66
+
72
67
 
73
- for (let defaultSnsInSqsData of defaultSnsInSqsDataList) {
68
+ for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
74
69
  resultsForCreateDefaultSnsInSqs.push({
75
70
  templatePath: snsTemplatePath,
76
71
  templateData: defaultSnsInSqsData,
@@ -80,8 +75,12 @@ function createDataForDefaultSnsInSqs(_izContext, srcPath) {
80
75
 
81
76
  let defaultDsqQueueDataList = [
82
77
  {
83
- queueName: upperCase(FUNCTION_NAME.paginateProcessLogical) + upperCase(HANDLER.hdrDsq)
84
- }
78
+ queueName: upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpointComplete) + upperCase(HANDLER.hdrSqs),
79
+ subscribeTo: upperCase(flowSteps[1].split("_")[0])
80
+ },
81
+ // {
82
+ // queueName: upperCase(FUNCTION_NAME.flowSchemaOwnTopicComplete) + upperCase(HANDLER.hdrSqs)
83
+ // }
85
84
  ]
86
85
  for (let defaultDsqQueueData of defaultDsqQueueDataList) {
87
86
  resultsForCreateDefaultSnsInSqs.push({
@@ -90,6 +89,7 @@ function createDataForDefaultSnsInSqs(_izContext, srcPath) {
90
89
  setting: setting
91
90
  })
92
91
  }
92
+ console.log()
93
93
  return resultsForCreateDefaultSnsInSqs;
94
94
  }
95
95
 
@@ -0,0 +1,53 @@
1
+ <% if (subscribeTo) { %>
2
+ ##===== SNS Subscription
3
+ ##===== [Topic In]
4
+ SubscriptionToOut<%- subscribeTo %>:
5
+ Type: AWS::SNS::Subscription
6
+ Properties:
7
+ TopicArn: !Ref Out<%- subscribeTo %>
8
+ Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>"
9
+ Protocol: "sqs"
10
+ <% } %>
11
+ #------- queue ---------
12
+ <%- queueName %>:
13
+ Type: "AWS::SQS::Queue"
14
+ Properties:
15
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
16
+ RedrivePolicy:
17
+ deadLetterTargetArn: #!GetAtt
18
+ Fn::GetAtt:
19
+ - <%- queueName %>DLQ
20
+ - Arn
21
+ maxReceiveCount: 3
22
+ VisibilityTimeout: 120
23
+
24
+ <%- queueName %>DLQ:
25
+ Type: AWS::SQS::Queue
26
+ Properties:
27
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
28
+
29
+ <%- queueName %>Policy:
30
+ Type: AWS::SQS::QueuePolicy
31
+ Properties:
32
+ PolicyDocument:
33
+ Version: "2012-10-17"
34
+ Statement:
35
+ - Sid: "allow-sns-messages"
36
+ Effect: Allow
37
+ Principal: "*"
38
+ Resource: #!GetAtt
39
+ Fn::GetAtt:
40
+ - <%- queueName %>
41
+ - Arn
42
+ Action: "SQS:SendMessage"
43
+ Queues:
44
+ - Ref: <%- queueName %>
45
+ #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
46
+ #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
47
+
48
+ <%_ function firstLetterUpperCase(text){
49
+ return text.charAt(0).toUpperCase() + text.slice(1)
50
+ } _%>
51
+ <%_ function firstLetterLowerCase(str) {
52
+ return str.charAt(0).toLowerCase() + str.slice(1)
53
+ } _%>
@@ -0,0 +1,77 @@
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
+
23
+ // const {
24
+ // HANDLER,
25
+ // STORAGE_TYPES
26
+ // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
27
+
28
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils.js");
29
+ const STORAGE_TYPES = {
30
+ dynamoDB: "dynamoDB",
31
+ graph: "graph"
32
+ }
33
+
34
+ const templatePath = path.join(__dirname, '../../../resourceYaml/sns-out/template.ejs');
35
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js')
36
+
37
+ /**
38
+ * create data for dynamoDbYaml template 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 createDataForSnsOut(_izContext, flowSchema, srcPath) {
48
+ let resultsForCreateDefaultSnsInSqs = [];
49
+
50
+ // GCTpBasTestInPersonCreate => GCTpBas_Test_PersonCreate_In
51
+ let flowSteps = Object.keys(flowSchema.flowSteps)
52
+ const generatedSnsTopicOutForFlowSchema = [
53
+ {
54
+ queueName: upperCase(flowSteps[1].split("_")[0])
55
+ }
56
+ ];
57
+
58
+
59
+ for (let defaultSnsOutData of generatedSnsTopicOutForFlowSchema) {
60
+ resultsForCreateDefaultSnsInSqs.push({
61
+ templatePath: templatePath,
62
+ templateData: defaultSnsOutData,
63
+ setting: {
64
+ initialData: "Resources:\n",
65
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
66
+ saveFileName: SAVE_FILE_NAME.snsOutYaml,
67
+ fileExtension: ".yml",
68
+ isAppend: true
69
+ }
70
+
71
+ })
72
+ }
73
+
74
+ return resultsForCreateDefaultSnsInSqs;
75
+ }
76
+
77
+ module.exports = createDataForSnsOut;
@@ -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
@@ -22,7 +22,7 @@ const snsSharedLib = require('@izara_project/izara-core-library-sns');
22
22
  const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
23
23
  const _ = require('lodash');
24
24
  const hash = require("object-hash")
25
-
25
+ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
26
26
  const PREFIX = {
27
27
  CREATE_OBJECT_ASYNC: "createObjectAsync",
28
28
  CREATE_OBJECT_ASYNC_COMPLETE: "createObjectAsyncComplete"
@@ -77,7 +77,7 @@ module.exports.createObjectComplete = async (
77
77
  };
78
78
 
79
79
  if (status == "error" && errorsFound.length > 0) {
80
- errorsFound.push(errorsFound);
80
+ errorsFound.push("error before validate");
81
81
  } else if (status == "error" && errorsFound.length == 0) {
82
82
  errorsFound.push("[invalid]statur is error not have errorfound form graphService");
83
83
 
@@ -141,7 +141,7 @@ module.exports.createObjectComplete = async (
141
141
  let sendMessageOutCreateObjectComplete = {
142
142
  Message: JSON.stringify(messageObject),
143
143
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
144
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, "OutCreateObjectComplete")
144
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete)
145
145
  };
146
146
  _izContext.logger.debug("Send message to OutCreateObjectComplete :::>", sendMessageOutCreateObjectComplete)
147
147
  await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete);
@@ -89,15 +89,21 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
89
89
  SQS_RESOURCE.getQueueUrl,
90
90
  SQS_RESOURCE.receiveMessage,
91
91
  SQS_RESOURCE.sendMessage
92
- ],
92
+ ]
93
+ },
94
+ [
95
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
96
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ")
97
+ ]
98
+ ),
99
+ createIamRole(
100
+ {
93
101
  [RESOURCE_CLASSES.sns]: [
94
102
  SNS_RESOURCE.publish,
95
103
  SNS_RESOURCE.subscribe
96
104
  ]
97
105
  },
98
106
  [
99
- resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
100
- resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ"),
101
107
  resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
102
108
  resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out")
103
109
  ]
@@ -72,7 +72,7 @@ module.exports.deleteNodeComplete = async (
72
72
  let sendMessageToOutUpdateNodeComplete = {
73
73
  Message: JSON.stringify(deleteNodeComplete),
74
74
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
75
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete)
75
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete)
76
76
  };
77
77
  _izContext.logger.debug("Send Message to DeleteNodeComplete::", sendMessageToOutUpdateNodeComplete);
78
78
  await sns.publishAsync(_izContext, sendMessageToOutUpdateNodeComplete)
@@ -87,15 +87,21 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
87
87
  SQS_RESOURCE.getQueueUrl,
88
88
  SQS_RESOURCE.receiveMessage,
89
89
  SQS_RESOURCE.sendMessage
90
- ],
90
+ ]
91
+ },
92
+ [
93
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
94
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ")
95
+ ]
96
+ ),
97
+ createIamRole(
98
+ {
91
99
  [RESOURCE_CLASSES.sns]: [
92
100
  SNS_RESOURCE.publish,
93
101
  SNS_RESOURCE.subscribe
94
102
  ]
95
103
  },
96
104
  [
97
- resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
98
- resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ"),
99
105
  resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
100
106
  resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out")
101
107
  ]
@@ -101,7 +101,7 @@ module.exports.updateNodeComplete = async (
101
101
  let sendMessageToOutUpdateNodeComplete = {
102
102
  Message: JSON.stringify(updateCompleteMsg),
103
103
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
104
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete)
104
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete)
105
105
  };
106
106
  _izContext.logger.debug("Send Message to OutUpdateNodeComplete::", sendMessageToOutUpdateNodeComplete);
107
107
  await sns.publishAsync(_izContext, sendMessageToOutUpdateNodeComplete)
@@ -67,15 +67,21 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
67
67
  SQS_RESOURCE.getQueueUrl,
68
68
  SQS_RESOURCE.receiveMessage,
69
69
  SQS_RESOURCE.sendMessage
70
- ],
70
+ ]
71
+ },
72
+ [
73
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
74
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ")
75
+ ]
76
+ ),
77
+ createIamRole(
78
+ {
71
79
  [RESOURCE_CLASSES.sns]: [
72
80
  SNS_RESOURCE.publish,
73
81
  SNS_RESOURCE.subscribe
74
82
  ]
75
83
  },
76
84
  [
77
- resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
78
- resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ"),
79
85
  resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
80
86
  resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out")
81
87
  ]
@@ -93,7 +99,7 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
93
99
  additionalResourcePermission,
94
100
  resourceLocation: SOURCE_PATH.resourceLocationOutPerActionComplete,
95
101
  functionNameConfig,
96
- roleName: SOURCE_GENERATE_IAM_ROLE.roleName,
102
+ roleName: SOURCE_GENERATE_IAM_ROLE.ObjectCompleteRole,
97
103
  },
98
104
  setting: {
99
105
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -101,7 +101,7 @@ module.exports.updateNodeComplete = async (
101
101
  let sendMessageToOutUpdateNodeComplete = {
102
102
  Message: JSON.stringify(updateCompleteMsg),
103
103
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
104
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete)
104
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete)
105
105
  };
106
106
  _izContext.logger.debug("Send Message to OutUpdateNodeComplete::", sendMessageToOutUpdateNodeComplete);
107
107
  await sns.publishAsync(_izContext, sendMessageToOutUpdateNodeComplete)
@@ -91,15 +91,21 @@ function createFunctionYamlOutUpdateComplete(_izContext, srcPath) {
91
91
  SQS_RESOURCE.getQueueUrl,
92
92
  SQS_RESOURCE.receiveMessage,
93
93
  SQS_RESOURCE.sendMessage
94
- ],
94
+ ]
95
+ },
96
+ [
97
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
98
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ")
99
+ ]
100
+ ),
101
+ createIamRole(
102
+ {
95
103
  [RESOURCE_CLASSES.sns]: [
96
104
  SNS_RESOURCE.publish,
97
105
  SNS_RESOURCE.subscribe
98
106
  ]
99
107
  },
100
108
  [
101
- resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName)),
102
- resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + "DLQ"),
103
109
  resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
104
110
  resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out")
105
111
  ]
@@ -109,7 +109,7 @@ module.exports.createRelationshipComplete = async (
109
109
  let sendMessageToOutCreateRelatonshipComplete = {
110
110
  Message: JSON.stringify(createCompleteMsg),
111
111
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
112
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
112
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
113
113
  };
114
114
  _izContext.logger.debug("Send message to OutCreateRelationshipComplete :::>", sendMessageToOutCreateRelatonshipComplete);
115
115
  await sns.publishAsync(_izContext, sendMessageToOutCreateRelatonshipComplete);
@@ -107,13 +107,13 @@ module.exports.createRelationshipComplete = async (
107
107
  let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
108
108
  _izContext.logger.debug("After addCallingFlowToSnsResponseMessageAttributes", deleteRelComp);
109
109
 
110
- let sendMessageToOutCreateRelatonshipComplete = {
110
+ let sendMessageToOutDeleteRelatonshipComplete = {
111
111
  Message: JSON.stringify(deleteRelComp),
112
112
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
113
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
113
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete)
114
114
  };
115
- _izContext.logger.debug("Send message to OutCreateRelationshipComplete :::>", sendMessageToOutCreateRelatonshipComplete);
116
- await sns.publishAsync(_izContext, sendMessageToOutCreateRelatonshipComplete);
115
+ _izContext.logger.debug("Send message to OutCreateRelationshipComplete :::>", sendMessageToOutDeleteRelatonshipComplete);
116
+ await sns.publishAsync(_izContext, sendMessageToOutDeleteRelatonshipComplete);
117
117
 
118
118
 
119
119
  // remove awaitingMultipleStep after finished
@@ -134,7 +134,7 @@ module.exports.createRelationshipComplete = async (
134
134
  errorsFound
135
135
  }
136
136
  } catch (err) {
137
- _izContext.logger.error('error createRelationshipComplete:', err)
137
+ _izContext.logger.error('error deleteRelationshipComplete:', err)
138
138
  throw (err)
139
139
  }
140
140
  }
@@ -107,13 +107,13 @@ module.exports.createRelationshipComplete = async (
107
107
  let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
108
108
  _izContext.logger.debug("After addCallingFlowToSnsResponseMessageAttributes", createCompleteMsg);
109
109
 
110
- let sendMessageToOutCreateRelatonshipComplete = {
110
+ let sendMessageToOutGetRelComplete = {
111
111
  Message: JSON.stringify(createCompleteMsg),
112
112
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
113
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
113
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outGetRelComplete)
114
114
  };
115
- _izContext.logger.debug("Send message to OutCreateRelationshipComplete :::>", sendMessageToOutCreateRelatonshipComplete);
116
- await sns.publishAsync(_izContext, sendMessageToOutCreateRelatonshipComplete);
115
+ _izContext.logger.debug("Send message to outGetRelComplete :::>", sendMessageToOutGetRelComplete);
116
+ await sns.publishAsync(_izContext, sendMessageToOutGetRelComplete);
117
117
 
118
118
 
119
119
  // remove awaitingMultipleStep after finished
@@ -135,7 +135,7 @@ module.exports.createRelationshipComplete = async (
135
135
  }
136
136
 
137
137
  } catch (err) {
138
- _izContext.logger.error('error createRelationshipComplete:', err)
138
+ _izContext.logger.error('error GetRelationshipComplete:', err)
139
139
  throw (err)
140
140
  }
141
141
  }
@@ -112,7 +112,7 @@ module.exports.updateRelationshipComplete = async (
112
112
  let sendMessageToOutUpdateRelatonshipComplete = {
113
113
  Message: JSON.stringify(updateCompleteMsg),
114
114
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
115
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete)
115
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete)
116
116
  };
117
117
  _izContext.logger.debug("Send message to OutUpdateRelationshipComplete :::>", sendMessageToOutUpdateRelatonshipComplete);
118
118
  await sns.publishAsync(_izContext, sendMessageToOutUpdateRelatonshipComplete);