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

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 (60) hide show
  1. package/package.json +9 -9
  2. package/src/GenerateCodeLibs/src/Consts.js +27 -12
  3. package/src/MainLibs/src/Consts.js +7 -4
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +2 -5
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +1 -1
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +1 -1
  7. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +5 -5
  8. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +22 -0
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +1 -1
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +1 -1
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +1 -1
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +1 -2
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +1 -1
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +1 -1
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/template.ejs +18 -18
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +1 -1
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +1 -1
  18. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +73 -0
  19. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +53 -0
  20. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +75 -0
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +10 -0
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +83 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +17 -0
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +65 -0
  25. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template copy.ejs +125 -0
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +130 -0
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +61 -0
  28. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +70 -0
  29. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +147 -0
  30. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +18 -0
  31. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +64 -0
  32. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowSchema → externalTopic/websocket}/handler/template.ejs +17 -16
  33. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +60 -0
  34. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +74 -0
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → EndpointComponent}/functionYaml/data.js +15 -23
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → EndpointComponent}/functionYaml/template.ejs +6 -0
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +57 -0
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +84 -0
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +52 -0
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +73 -0
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/functionYaml/data.js +25 -23
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/functionYaml/template.ejs +10 -6
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/handler/data.js +6 -20
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +84 -0
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/mainFunction/data.js +4 -15
  46. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/mainFunction/template.ejs +16 -33
  47. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +117 -0
  48. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +24 -0
  49. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → FlowSchemaComponent}/handler/data.js +6 -19
  50. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaComponent}/handler/template.ejs +4 -3
  51. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → FlowSchemaComponent}/mainFunction/data.js +3 -1
  52. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +96 -0
  53. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +163 -115
  54. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +10 -0
  55. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +3 -3
  56. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +3 -3
  57. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +13 -14
  58. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +3 -3
  59. /package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → FlowSchemaComponent}/mainFunction/template.ejs +0 -0
  60. /package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{sns-out/data.js → sns-in/template.ejs} +0 -0
@@ -52,7 +52,9 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
52
52
  let topicArn = Object.keys(flowSchema.flowSteps)[0];
53
53
  return {
54
54
  templatePath: templatePath,
55
- templateData: {},
55
+ templateData: {
56
+ topicArn
57
+ },
56
58
  setting: {
57
59
  savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
58
60
  saveFileName: `${functionName}_Main`,
@@ -0,0 +1,96 @@
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 snsTemplatePath = path.join(__dirname, './snsTemplate.ejs');
35
+ const sqsTemplatePath = path.join(__dirname, './sqsTemplate.ejs');
36
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../MainLibs/src/Consts.js')
37
+
38
+
39
+ /**
40
+ * create data for dynamoDbYaml tempalte from objectSchema
41
+ * return array of dynamoDb data
42
+ * because one objectSchema can create multiple dynamoDb table
43
+ *
44
+ * @param {Object} _izContext
45
+ * @param {String} saveFilePath
46
+ * @returns {Object[]} - data of multiple dynamoDb template
47
+ */
48
+
49
+ function createDataForDefaultSnsInSqs(_izContext, srcPath) {
50
+ let resultsForCreateDefaultSnsInSqs = [];
51
+ const defaultSnsInSqsDataList = [];
52
+ const setting = {
53
+ initialData: "Resources:\n",
54
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
55
+ saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
56
+ fileExtension: ".yml",
57
+ isAppend: true
58
+ }
59
+
60
+ // GCTpBasTestInPersonCreate => GCTpBas_Test_PersonCreate_In
61
+ defaultSnsInSqsDataList.push(
62
+ {
63
+ queueName: upperCase(FUNCTION_NAME.findData)
64
+ },
65
+ {
66
+ queueName: upperCase(FUNCTION_NAME.processLogical)
67
+ },
68
+ {
69
+ queueName: upperCase(FUNCTION_NAME.paginateProcessLogical)
70
+ }
71
+ )
72
+
73
+ for (let defaultSnsInSqsData of defaultSnsInSqsDataList) {
74
+ resultsForCreateDefaultSnsInSqs.push({
75
+ templatePath: snsTemplatePath,
76
+ templateData: defaultSnsInSqsData,
77
+ setting: setting
78
+ })
79
+ }
80
+
81
+ let defaultDsqQueueDataList = [
82
+ {
83
+ queueName: upperCase(FUNCTION_NAME.paginateProcessLogical) + upperCase(HANDLER.hdrDsq)
84
+ }
85
+ ]
86
+ for (let defaultDsqQueueData of defaultDsqQueueDataList) {
87
+ resultsForCreateDefaultSnsInSqs.push({
88
+ templatePath: sqsTemplatePath,
89
+ templateData: defaultDsqQueueData,
90
+ setting: setting
91
+ })
92
+ }
93
+ return resultsForCreateDefaultSnsInSqs;
94
+ }
95
+
96
+ module.exports = createDataForDefaultSnsInSqs;
@@ -47,7 +47,7 @@ const createWebSocketCreateObjectCompleteMainFunction = require('./components/up
47
47
 
48
48
  // PreSign URL components
49
49
  const createReservedLimitFunctionYaml = require('./components/upload/preSignUrl/reservedLimit/functionYaml/data');
50
- const createReservedLimitlHandler = require('./components/upload/preSignUrl/reservedLimit/handler/data');
50
+ const createReservedLimitHandler = require('./components/upload/preSignUrl/reservedLimit/handler/data');
51
51
  const createReservedLimitMainFunction = require('./components/upload/preSignUrl/reservedLimit/mainFunction/data');
52
52
  const createReservedLimitQueueName = require('./components/upload/preSignUrl/reservedLimit/sqs/data');
53
53
 
@@ -56,6 +56,7 @@ const createPresignUrlFunctionYaml = require('./components/upload/preSignUrl/cre
56
56
  const createPresignUrlHandler = require('./components/upload/preSignUrl/createPresignUrl/handler/data');
57
57
  const createPresignUrlMainFunction = require('./components/upload/preSignUrl/createPresignUrl/mainFunction/data');
58
58
  const createPresignUrlQueueName = require('./components/upload/preSignUrl/createPresignUrl/queue/data');
59
+ // const createReservedLimitQueueName = require('./components/upload/preSignUrl/reservedLimit/sqs/data');
59
60
 
60
61
  // Process uploaded file components
61
62
  const createProcessAfterUploadS3FunctionYmlS3 = require('./components/upload/processFile/functionYml/HdrS3/data');
@@ -69,16 +70,29 @@ const createConfirmAfterUploadS3Handler = require('./components/upload/confirmRe
69
70
  const createConfirmAfterUploadS3MainFunction = require('./components/upload/confirmReserved/mainFunction/data');
70
71
  const createConfirmAfterUploadS3Queue = require('./components/upload/confirmReserved/queue/data');
71
72
 
73
+ // ** External Topic ** //
74
+ const createExternalWebsocketFunctionYaml = require('./externalTopic/websocket/functionYaml/data');
75
+ const createExternalWebsocketHandler = require('./externalTopic/websocket/handler/data');
76
+ const createExternalWebsocketMainFunction = require('./externalTopic/websocket/mainFunction/data');
77
+ const createExternalSqsFunctionYaml = require('./externalTopic/sqs/functionYaml/data');
78
+ const createExternalSqsHandler = require('./externalTopic/sqs/handler/data');
79
+ const createExternalSqsMainFunction = require('./externalTopic/sqs/mainFunction/data');
80
+ const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
81
+ const createExternalTopicSnsOut = require('./externalTopic/sns-out/data');
82
+
72
83
  // flowSchema OwnTopic component
73
- const createFlowSchemaOwnTopicFunctionYaml = require('./flowSchemaOwnTopic/flowSchema/functionYaml/data');
74
- const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/flowSchema/handler/data');
75
- const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/flowSchema/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')
76
87
 
77
88
  // flowSchema OwnTopicComplete component
78
- const createFlowSchemaOwnTopicCompleteFunctionYaml = require("./flowSchemaOwnTopic/flowSchemaComplete/functionYaml/data")
79
- const createFlowSchemaOwnTopicCompleteHandler = require("./flowSchemaOwnTopic/flowSchemaComplete/handler/data")
80
- const createFlowSchemaOwnTopicCompleteMainFunction = require("./flowSchemaOwnTopic/flowSchemaComplete/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")
81
92
 
93
+ const createFlowSchemaOwnTopicEndpointFuntionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data')
94
+ const createFlowSchemaOwnTopicEndpointHandler = require('./flowSchemaOwnTopic/EndpointComponent/handler/data')
95
+ const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTopic/EndpointComponent/mainFunction/data')
82
96
  /**
83
97
  * Generates code with templates for different actions
84
98
  * @param {Object} _izContext - Context object
@@ -98,131 +112,165 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
98
112
 
99
113
  const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler]
100
114
  if (allLocalFlowSchemas.records.length) {
115
+ const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, saveFilePath)
101
116
  createSourceParams.push(
102
- ...webSocketResource
117
+ ...webSocketResource,
118
+ ...webSocketGenerateCodeLibs
119
+
103
120
  )
104
121
  }
105
122
 
106
123
  for (const flowSchema of allLocalFlowSchemas.records) {
107
-
108
- const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
109
- const bucketS3 = createBucketS3(_izContext, flowSchema, saveFilePath)
110
-
111
- const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
112
- const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
113
- const mainFunctionCreateObjectWebSocket = await createMainFunctionCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
114
- const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
115
- const webSocketCreateObjectCompleteQueue = createWebSocketCreateObjectCompleteQueue(_izContext, saveFilePath);
116
- const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath)
117
- const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, flowSchema, saveFilePath);
118
-
119
- // const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
120
- const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, saveFilePath)
121
-
122
- const getPreSignUrlFunctionYaml = createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
123
- const getPreSignUrlHandler = createReservedLimitlHandler(_izContext, flowSchema, saveFilePath);
124
- const getPreSignUrlMainFunction = createReservedLimitMainFunction(_izContext, flowSchema, saveFilePath);
125
- const getPreSignUrlQueue = createReservedLimitQueueName(_izContext, saveFilePath);
126
-
127
- const reservedLimitCompleteFunctionYaml = createPresignUrlFunctionYaml(_izContext, flowSchema, saveFilePath);
128
- const reservedLimitCompleteMainFunction = createPresignUrlMainFunction(_izContext, flowSchema, saveFilePath);
129
- const reservedLimitCompleteHandler = createPresignUrlHandler(_izContext, flowSchema, saveFilePath);
130
- const reservedLimitCompleteQueue = createPresignUrlQueueName(_izContext, saveFilePath);
131
-
132
- const processAfterUploadFunctionYmlS3 = createProcessAfterUploadS3FunctionYmlS3(_izContext, flowSchema, saveFilePath);
133
- // const processAfterUploadFunctionYamlHdrDsq = createProcessAfterUploadS3FunctionYmlDsq(_izContext, saveFilePath);
134
- const processAfterUploadSqs = createProcessAfterUploadS3Queue(_izContext, saveFilePath);
135
- const processAfterUploadHandlerS3 = createProcessAfterUploadS3HandlerS3(_izContext, flowSchema, saveFilePath);
136
- // const processAfterUploadHandlerDsq = createProcessAfterUploadS3HandlerDsq(_izContext, saveFilePath);
137
- const processAfterUploadMainFunction = createProcessAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
138
-
139
- const confirmReservedAfterUploadFunctionYaml = createConfirmAfterUploadS3FunctionYaml(_izContext, flowSchema, saveFilePath);
140
- const confirmReservedAfterUploadHandler = createConfirmAfterUploadS3Handler(_izContext, flowSchema, saveFilePath);
141
- const confirmReservedAfterUploadMainFunction = createConfirmAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
142
- const confirmReservedAfterUploadQueue = createConfirmAfterUploadS3Queue(_izContext, saveFilePath);
143
-
144
- // Group related resources for better organization
145
- const webSocketFunctions = [
146
- ...functionYamlCreateObjectWebSocket,
147
- ...handlerCreateObjectWebSocket,
148
- ...mainFunctionCreateObjectWebSocket,
149
- ...webSocketCreateObjectCompleteFunctionYaml,
150
- ...webSocketCreateObjectCompleteQueue,
151
- ...webSocketCreateObjectCompleteMainFunction,
152
- ...webSocketCreateObjectCompleteHandler
153
- ];
154
-
155
- const getPreSignUrlResources = [
156
- ...getPreSignUrlFunctionYaml,
157
- ...getPreSignUrlHandler,
158
- ...getPreSignUrlMainFunction,
159
- ...getPreSignUrlQueue
160
- ];
161
-
162
- const reservedLimitResources = [
163
- ...reservedLimitCompleteFunctionYaml,
164
- ...reservedLimitCompleteHandler,
165
- ...reservedLimitCompleteMainFunction,
166
- ...reservedLimitCompleteQueue
167
- ];
168
-
169
- const processAfterUploadResources = [
170
- ...processAfterUploadFunctionYmlS3,
171
- ...processAfterUploadSqs,
172
- ...processAfterUploadHandlerS3,
173
- ...processAfterUploadMainFunction
174
- // Commented resources kept for reference
175
- // ...processAfterUploadHandlerDsq,
176
- // ...processAfterUploadFunctionYamlHdrDsq
177
- ];
178
-
179
- const confirmAfterUploadResources = [
180
- ...confirmReservedAfterUploadFunctionYaml,
181
- ...confirmReservedAfterUploadHandler,
182
- ...confirmReservedAfterUploadMainFunction,
183
- ...confirmReservedAfterUploadQueue
184
- ];
185
-
186
- // Group all resources related to S3 upload functionality
187
- const webSocketUploadS3Resources = [
188
- ...webSocketFunctions,
189
- ...webSocketGenerateCodeLibs,
190
- ...reservedDataTable
191
- ];
192
-
193
- const flowSchemaOwnTopicFunctionYaml = createFlowSchemaOwnTopicFunctionYaml(_izContext, flowSchema, saveFilePath);
194
- const flowSchemaOwnTopicHandler = createFlowSchemaOwnTopicHandler(_izContext, flowSchema, saveFilePath);
195
- const flowSchemaOwnTopicMainFunction = createFlowSchemaOwnTopicMainFunction(_izContext, flowSchema, saveFilePath);
196
-
197
- const flowSchemaOwnTopicComponent = [...flowSchemaOwnTopicFunctionYaml, ...flowSchemaOwnTopicHandler, ...flowSchemaOwnTopicMainFunction];
198
-
199
- const flowSchemaOwnTopicCompleteFunctionYaml = createFlowSchemaOwnTopicCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
200
- const flowSchemaOwnTopicCompleteHandler = createFlowSchemaOwnTopicCompleteHandler(_izContext, flowSchema, saveFilePath);
201
- const flowSchemaOwnTopicCompleteMainFunction = createFlowSchemaOwnTopicCompleteMainFunction(_izContext, flowSchema, saveFilePath);
202
-
203
- const flowSchemaOwnTopicCompleteComponent = [...flowSchemaOwnTopicCompleteFunctionYaml, ...flowSchemaOwnTopicCompleteHandler, ...flowSchemaOwnTopicCompleteMainFunction]
124
+ console.log("flowSchema in Generate TemplateData", flowSchema);
204
125
  for (const event of flowSchema.event) {
205
126
  if (event.includes("s3")) {
206
- // Add all resources to the parameters array
127
+ const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
128
+ const bucketS3 = createBucketS3(_izContext, flowSchema, saveFilePath)
129
+
130
+ const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
131
+ const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
132
+ const mainFunctionCreateObjectWebSocket = await createMainFunctionCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
133
+ const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
134
+ const webSocketCreateObjectCompleteQueue = createWebSocketCreateObjectCompleteQueue(_izContext, saveFilePath);
135
+ const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath)
136
+ const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, flowSchema, saveFilePath);
137
+
138
+ // const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
139
+
140
+ const getPreSignUrlFunctionYaml = createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
141
+ const getPreSignUrlHandler = createReservedLimitHandler(_izContext, flowSchema, saveFilePath);
142
+ const getPreSignUrlMainFunction = createReservedLimitMainFunction(_izContext, flowSchema, saveFilePath);
143
+ const getPreSignUrlQueue = createReservedLimitQueueName(_izContext, saveFilePath);
144
+
145
+ const reservedLimitCompleteFunctionYaml = createPresignUrlFunctionYaml(_izContext, flowSchema, saveFilePath);
146
+ const reservedLimitCompleteMainFunction = createPresignUrlMainFunction(_izContext, flowSchema, saveFilePath);
147
+ const reservedLimitCompleteHandler = createPresignUrlHandler(_izContext, flowSchema, saveFilePath);
148
+ const reservedLimitCompleteQueue = createPresignUrlQueueName(_izContext, saveFilePath);
149
+
150
+ const processAfterUploadFunctionYmlS3 = createProcessAfterUploadS3FunctionYmlS3(_izContext, flowSchema, saveFilePath);
151
+ // const processAfterUploadFunctionYamlHdrDsq = createProcessAfterUploadS3FunctionYmlDsq(_izContext, saveFilePath);
152
+ const processAfterUploadSqs = createProcessAfterUploadS3Queue(_izContext, saveFilePath);
153
+ const processAfterUploadHandlerS3 = createProcessAfterUploadS3HandlerS3(_izContext, flowSchema, saveFilePath);
154
+ // const processAfterUploadHandlerDsq = createProcessAfterUploadS3HandlerDsq(_izContext, saveFilePath);
155
+ const processAfterUploadMainFunction = createProcessAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
156
+
157
+ const confirmReservedAfterUploadFunctionYaml = createConfirmAfterUploadS3FunctionYaml(_izContext, flowSchema, saveFilePath);
158
+ const confirmReservedAfterUploadHandler = createConfirmAfterUploadS3Handler(_izContext, flowSchema, saveFilePath);
159
+ const confirmReservedAfterUploadMainFunction = createConfirmAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
160
+ const confirmReservedAfterUploadQueue = createConfirmAfterUploadS3Queue(_izContext, saveFilePath);
161
+
162
+ const webSocketFunctions = [
163
+ ...functionYamlCreateObjectWebSocket,
164
+ ...handlerCreateObjectWebSocket,
165
+ ...mainFunctionCreateObjectWebSocket,
166
+ ...webSocketCreateObjectCompleteFunctionYaml,
167
+ ...webSocketCreateObjectCompleteQueue,
168
+ ...webSocketCreateObjectCompleteMainFunction,
169
+ ...webSocketCreateObjectCompleteHandler
170
+ ];
171
+
172
+ const getPreSignUrlResources = [
173
+ ...getPreSignUrlFunctionYaml,
174
+ ...getPreSignUrlHandler,
175
+ ...getPreSignUrlMainFunction,
176
+ ...getPreSignUrlQueue
177
+ ];
178
+
179
+ const reservedLimitResources = [
180
+ ...reservedLimitCompleteFunctionYaml,
181
+ ...reservedLimitCompleteHandler,
182
+ ...reservedLimitCompleteMainFunction,
183
+ ...reservedLimitCompleteQueue
184
+ ];
185
+
186
+ const processAfterUploadResources = [
187
+ ...processAfterUploadFunctionYmlS3,
188
+ ...processAfterUploadSqs,
189
+ ...processAfterUploadHandlerS3,
190
+ ...processAfterUploadMainFunction
191
+ // Commented resources kept for reference
192
+ // ...processAfterUploadHandlerDsq,
193
+ // ...processAfterUploadFunctionYamlHdrDsq
194
+ ];
195
+
196
+ const confirmAfterUploadResources = [
197
+ ...confirmReservedAfterUploadFunctionYaml,
198
+ ...confirmReservedAfterUploadHandler,
199
+ ...confirmReservedAfterUploadMainFunction,
200
+ ...confirmReservedAfterUploadQueue
201
+ ];
202
+
203
+ const webSocketUploadS3Resources = [
204
+ ...webSocketFunctions,
205
+ ...reservedDataTable,
206
+ ...bucketS3,
207
+ ];
208
+ console.log("event s3 generated")
209
+
207
210
  createSourceParams.push(
208
211
  ...webSocketUploadS3Resources,
209
212
  ...getPreSignUrlResources,
210
213
  ...reservedLimitResources,
211
- ...bucketS3,
212
214
  ...processAfterUploadResources,
213
- ...confirmAfterUploadResources
215
+ ...confirmAfterUploadResources,
214
216
  );
215
- }
216
217
 
217
- if (event.includes("ownTopic")) {
218
- createSourceParams.push(
219
- ...flowSchemaOwnTopicComponent,
220
- ...flowSchemaOwnTopicCompleteComponent
221
- )
218
+ } else if (event.includes("extTopic")) {
219
+ // ** External Topic ** //
220
+ const externalTopicSnsInSqs = createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath);
221
+ const externalTopicSnsOut = createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath);
222
+ const externalWebsocketFunctionYaml = createExternalWebsocketFunctionYaml(_izContext, flowSchema, saveFilePath);
223
+ const externalWebsocketHandler = createExternalWebsocketHandler(_izContext, flowSchema, saveFilePath);
224
+ const externalWebsocketMainFunction = createExternalWebsocketMainFunction(_izContext, flowSchema, saveFilePath);
225
+ const externalSqsFunctionYaml = createExternalSqsFunctionYaml(_izContext, flowSchema, saveFilePath);
226
+ const externalSqsHandler = createExternalSqsHandler(_izContext, flowSchema, saveFilePath);
227
+ const externalSqsMainFunction = createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
228
+
229
+ // Group related resources for better organization
230
+ const externalTopic = [
231
+ ...externalWebsocketFunctionYaml,
232
+ ...externalWebsocketHandler,
233
+ ...externalWebsocketMainFunction,
234
+ ...externalSqsFunctionYaml,
235
+ ...externalSqsHandler,
236
+ ...externalSqsMainFunction,
237
+ ...externalTopicSnsInSqs,
238
+ ...externalTopicSnsOut
239
+ ];
240
+
241
+ console.log("event externalTopic generated")
242
+ createSourceParams.push(...externalTopic)
243
+
244
+ } else if (event.includes("ownTopic")) {
245
+
246
+ // flowSchema OwnTopic components
247
+ const flowSchemaOwnTopicFunctionYaml = createFlowSchemaOwnTopicFunctionYaml(_izContext, flowSchema, saveFilePath);
248
+ const flowSchemaOwnTopicHandler = createFlowSchemaOwnTopicHandler(_izContext, flowSchema, saveFilePath);
249
+ const flowSchemaOwnTopicMainFunction = createFlowSchemaOwnTopicMainFunction(_izContext, flowSchema, saveFilePath);
250
+ const flowSchemaOwnTopicComponent = [...flowSchemaOwnTopicFunctionYaml, ...flowSchemaOwnTopicHandler, ...flowSchemaOwnTopicMainFunction]
251
+ // flowSchema OwnTopic Complete component
252
+ const flowSchemaOwnTopicCompleteFunctionYaml = createFlowSchemaOwnTopicCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
253
+ const flowSchemaOwnTopicCompleteHandler = createFlowSchemaOwnTopicCompleteHandler(_izContext, flowSchema, saveFilePath);
254
+ const flowSchemaOwnTopicCompleteMainFunction = createFlowSchemaOwnTopicCompleteMainFunction(_izContext, flowSchema, saveFilePath);
255
+ const flowSchemaOwnTopicCompleteComponent = [...flowSchemaOwnTopicCompleteFunctionYaml, ...flowSchemaOwnTopicCompleteHandler, ...flowSchemaOwnTopicCompleteMainFunction]
256
+ // flowSchemaOwnTopic Endpoint
257
+ const flowSchemaOwnTopicEndpointFuntionYaml = createFlowSchemaOwnTopicEndpointFuntionYaml(_izContext, flowSchema, saveFilePath);
258
+ const flowSchemaOwnTopicEndpointHandler = createFlowSchemaOwnTopicEndpointHandler(_izContext, flowSchema, saveFilePath);
259
+ const flowSchemaOwnTopicEndpointMainFunction = createFlowSchemaOwnTopicEndpointMainFunction(_izContext, flowSchema, saveFilePath);
260
+ const flowSchemaOwnTopicEndpointComponent = [...flowSchemaOwnTopicEndpointFuntionYaml, ...flowSchemaOwnTopicEndpointHandler, ...flowSchemaOwnTopicEndpointMainFunction]
261
+
262
+ // Group the resources
263
+ const ownTopicResources = [
264
+ ...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicCompleteComponent, ...flowSchemaOwnTopicEndpointComponent
265
+ ];
266
+
267
+ console.log("event ownTopic generated")
268
+ createSourceParams.push(...ownTopicResources);
269
+
270
+
222
271
  }
223
272
  }
224
273
  }
225
- console.log("createSourceParams in flowSchemas", createSourceParams)
226
274
  return createSourceParams;
227
275
  } catch (error) {
228
276
  _izContext.logger.error('Error generating code with template flowSchema:', error);
@@ -114,6 +114,10 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
114
114
  handlerType: [],
115
115
  resources: {}
116
116
  },
117
+ [SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole]: {
118
+ handlerType: [],
119
+ resources: {}
120
+ },
117
121
  Other: []
118
122
  };
119
123
  const objectTypeList = [];
@@ -207,6 +211,12 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
207
211
  templateData.additionalResourcePermission,
208
212
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic].resources
209
213
  )
214
+ } else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole)) {
215
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole].handlerType.push(templateData);
216
+ processResourcePermissions(
217
+ templateData.additionalResourcePermission,
218
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole].resources
219
+ )
210
220
  }
211
221
  else {
212
222
  // Handle other items
@@ -270,7 +270,7 @@ module.exports.createRelationship = async (
270
270
  let messageParams = {
271
271
  Message: JSON.stringify(createRelCompleteMsg),
272
272
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
273
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete),
273
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete),
274
274
  };
275
275
 
276
276
  _izContext.logger.debug("messageParams OutCreateRelationshipComplete ::::::: ", messageParams);
@@ -376,7 +376,7 @@ module.exports.createRelationship = async (
376
376
 
377
377
  let messageToInCreateRelationship = {
378
378
  Message: JSON.stringify(createRelMessageBody),
379
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateRel, storageResource.graphServiceTag),
379
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateRel, storageResource.graphServiceTag),
380
380
  };
381
381
  _izContext.logger.debug("RequestParams before send to sqs messageToInUpdateRelationship ::::::: ", messageToInCreateRelationship);
382
382
  await sns.publishAsync(_izContext, messageToInCreateRelationship);
@@ -403,7 +403,7 @@ module.exports.createRelationship = async (
403
403
  let sendMessageToOutCreateRelComplete = {
404
404
  Message: JSON.stringify(messageObject),
405
405
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
406
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
406
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
407
407
  }
408
408
  _izContext.logger.debug("send Message to outCreateRelationshipComplete :::", sendMessageToOutCreateRelComplete);
409
409
  await sns.publishAsync(_izContext, sendMessageToOutCreateRelComplete);
@@ -236,7 +236,7 @@ module.exports.deleteRelationship = async (
236
236
  let messageParams = {
237
237
  Message: JSON.stringify(deleteRelCompleteMsg),
238
238
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
239
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete),
239
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete),
240
240
  };
241
241
 
242
242
  _izContext.logger.debug("messageParams OutCreateRelationshipComplete ::::::: ", messageParams);
@@ -336,7 +336,7 @@ module.exports.deleteRelationship = async (
336
336
 
337
337
  let messageToInUpdateRelationship = {
338
338
  Message: JSON.stringify(deleteRelMessageBody),
339
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inDeleteRel, storageResource.graphServiceTag),
339
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inDeleteRel, storageResource.graphServiceTag),
340
340
  };
341
341
  _izContext.logger.debug("RequestParams before send to sqs messageToInUpdateRelationship ::::::: ", messageToInUpdateRelationship);
342
342
  await sns.publishAsync(_izContext, messageToInUpdateRelationship);
@@ -363,7 +363,7 @@ module.exports.deleteRelationship = async (
363
363
  let sendMessageToOutDeleteRelComplete = {
364
364
  Message: JSON.stringify(messageObject),
365
365
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
366
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete)
366
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete)
367
367
  }
368
368
  _izContext.logger.debug("send Message to outCreateRelationshipComplete :::", sendMessageToOutDeleteRelComplete);
369
369
  await sns.publishAsync(_izContext, sendMessageToOutDeleteRelComplete);
@@ -86,14 +86,14 @@ module.exports.getRelationship = async (
86
86
  relType,
87
87
  relId,
88
88
  relationshipDirection,
89
- //(<requestparamCreateRel>)
90
- //(</requestparamCreateRel>)
89
+ //(<requestparamGetRel>)
90
+ //(</requestparamGetRel>)
91
91
  } = requestParams;
92
92
 
93
93
  let errorsFound = [];
94
94
 
95
- //(<beforeValidateCreateRel>)
96
- //(</beforeValidateCreateRel>).
95
+ //(<beforeValidateGetRel>)
96
+ //(</beforeValidateGetRel>).
97
97
  // validate object and identifiers
98
98
  async function validateIdentifiersExists(_izContext, objType, identifiersObject) {
99
99
 
@@ -125,11 +125,11 @@ module.exports.getRelationship = async (
125
125
  await validateIdentifiersExists(_izContext, secondObject.objType, secondObject.identifiers);
126
126
  // finished validate object and identifiers
127
127
 
128
- //(<afterValidateCreateRel>)
129
- //(</afterValidateCreateRel>)
128
+ //(<afterValidateGetRel>)
129
+ //(</afterValidateGetRel>)
130
130
 
131
- //(<beforeGetRelCreateRel>)
132
- //(</beforeGetRelCreateRel>)
131
+ //(<beforeGetRel>)
132
+ //(</beforeGetRel>)
133
133
 
134
134
  const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType);
135
135
  _izContext.logger.debug("relationshipSchema: ", relationshipSchema);
@@ -205,8 +205,8 @@ module.exports.getRelationship = async (
205
205
  secondObject: secondObject,
206
206
  relType: relType,
207
207
  relationshipDirection,
208
- //(<inCreateRelCompleteMsgCrateRel>)
209
- //(</inCreateRelCompleteMsgCrateRel>)
208
+ //(<inGetRelCompleteMsgCrateRel>)
209
+ //(</inGetRelCompleteMsgCrateRel>)
210
210
  status: 'error',
211
211
  errorFounds: errorsFound
212
212
  };
@@ -221,7 +221,7 @@ module.exports.getRelationship = async (
221
221
  let messageParams = {
222
222
  Message: JSON.stringify(getRelCompleteMsg),
223
223
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
224
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete),
224
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outGetRelComplete),
225
225
  };
226
226
 
227
227
  _izContext.logger.debug("messageParams OutCreateRelationshipComplete ::::::: ", messageParams);
@@ -276,8 +276,7 @@ module.exports.getRelationship = async (
276
276
  )
277
277
  result = getResultFromDynamo;
278
278
  }
279
- }
280
- )
279
+ })
281
280
  )
282
281
 
283
282
  let messageObject = {
@@ -297,7 +296,7 @@ module.exports.getRelationship = async (
297
296
  let sendMessageToOutGetRelComplete = {
298
297
  Message: JSON.stringify(messageObject),
299
298
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
300
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outGetRelComplete)
299
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outGetRelComplete)
301
300
  }
302
301
  _izContext.logger.debug("send Message to outCreateRelationshipComplete :::", sendMessageToOutGetRelComplete);
303
302
  await sns.publishAsync(_izContext, sendMessageToOutGetRelComplete);
@@ -235,7 +235,7 @@ module.exports.updateRelationship = async (
235
235
  let messageParams = {
236
236
  Message: JSON.stringify(updateCompleteMsg),
237
237
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
238
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete),
238
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete),
239
239
  };
240
240
 
241
241
  _izContext.logger.debug("messageParams OutUpdateRelationshipComplete ::::::: ", messageParams);
@@ -338,7 +338,7 @@ module.exports.updateRelationship = async (
338
338
 
339
339
  let messageToInUpdateRelationship = {
340
340
  Message: JSON.stringify(updateRelMessageBody),
341
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateRel, storageResource.graphServiceTag),
341
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateRel, storageResource.graphServiceTag),
342
342
  };
343
343
  _izContext.logger.debug("RequestParams before send to sqs messageToInUpdateRelationship ::::::: ", messageToInUpdateRelationship);
344
344
  await sns.publishAsync(_izContext, messageToInUpdateRelationship);
@@ -364,7 +364,7 @@ module.exports.updateRelationship = async (
364
364
  let sendMessageToOutCreateRelComplete = {
365
365
  Message: JSON.stringify(messageObject),
366
366
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
367
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
367
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
368
368
  }
369
369
  _izContext.logger.debug("send Message to outCreateRelationshipComplete :::", sendMessageToOutCreateRelComplete);
370
370
  await sns.publishAsync(_izContext, sendMessageToOutCreateRelComplete);