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

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 (69) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +2 -1
  3. package/src/MainLibs/src/Consts.js +11 -4
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +3 -3
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +1 -2
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +2 -2
  7. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -2
  8. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +10 -8
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +4 -4
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/data.js +4 -4
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/data.js +2 -2
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +2 -2
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +1 -1
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +1 -1
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +4 -4
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/handler/data.js +4 -4
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/data.js +4 -4
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/data.js +4 -4
  19. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/data.js +4 -4
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/data.js +1 -1
  21. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +4 -4
  22. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/data.js +4 -4
  23. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +4 -4
  24. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +1 -1
  25. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/data.js +4 -4
  26. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/data.js +4 -4
  27. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +3 -3
  28. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +2 -0
  29. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +3 -2
  30. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -16
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/functionYaml/data.js +115 -0
  32. package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess → flowSchemaOwnTopic/flowSchema}/functionYaml/template.ejs +1 -20
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/handler/data.js +70 -0
  34. package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess → flowSchemaOwnTopic/flowSchema}/handler/template.ejs +14 -32
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/mainFunction/data.js +64 -0
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchema/mainFunction/template.ejs +104 -0
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/functionYaml/data.js +115 -0
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/functionYaml/template.ejs +20 -0
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/handler/data.js +71 -0
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/handler/template.ejs +85 -0
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/mainFunction/data.js +63 -0
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowSchemaComplete/mainFunction/template.ejs +105 -0
  43. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +55 -35
  44. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +10 -0
  45. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/functionYaml/data.js +0 -76
  46. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/handler/data.js +0 -46
  47. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/mainFunction/data.js +0 -45
  48. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/sns-sqs/data.js +0 -35
  49. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/functionYaml/data.js +0 -34
  50. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/functionYaml/template.ejs +0 -0
  51. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/handler/data.js +0 -34
  52. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/handler/template.ejs +0 -0
  53. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/mainFunction/data.js +0 -34
  54. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/mainFunction/template.ejs +0 -0
  55. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/sns-sqs/data.js +0 -34
  56. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/sns-sqs/template.ejs +0 -0
  57. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/functionYaml/data.js +0 -101
  58. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/functionYaml/template.ejs +0 -43
  59. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/data.js +0 -93
  60. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/templateAsyncHandler.ejs +0 -110
  61. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/templateSyncHandler.ejs +0 -49
  62. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/hookLogic/data.js +0 -64
  63. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/mainFunction/data.js +0 -66
  64. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/mainFunction/template.ejs +0 -30
  65. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/data.js +0 -124
  66. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/snsTemplate.ejs +0 -59
  67. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/sqsTemplate.ejs +0 -43
  68. /package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess/mainFunction/template.ejs → flowSchemaOwnTopic/sns-in/data.js} +0 -0
  69. /package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess/sns-sqs/template.ejs → flowSchemaOwnTopic/sns-out/data.js} +0 -0
@@ -0,0 +1,85 @@
1
+ /*
2
+ Copyright (C) 2021 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const izara = require("@izara_project/izara-middleware");
21
+ const middleware = izara.middlewareHandler;
22
+ // const AWS = require('aws-sdk');
23
+ // const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
24
+ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb')
25
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow')
26
+ const hash = require('object-hash')
27
+ // const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
28
+ const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
29
+ const { postToConnection } = require("../../libs/source/ImportDataLib");
30
+ const { flowSchemaOwnTopic } = require('./<%- `${functionName}_Main` %>');
31
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
32
+
33
+ event._izContext.logger.debug('Event:', event);
34
+
35
+ try {
36
+
37
+ if (event.requestContext) {
38
+ const route = event.requestContext.routeKey;
39
+ const connectionId = event.requestContext.connectionId;
40
+ let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
41
+
42
+ switch (route) {
43
+ case '$default':
44
+ console.log('Received unknown route:', route);
45
+ break
46
+ case '<%- route %>':
47
+ console.log("event in route webSocket", event);
48
+ let eventParams = JSON.parse(event.body)
49
+
50
+ await dynamodbSharedLib.putItem(
51
+ event._izContext,
52
+ await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
53
+ {
54
+ taskKey: correlationId,
55
+ connectionId: connectionId,
56
+ }
57
+ )
58
+
59
+ let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
60
+ await flowSchemaOwnTopic(
61
+ event._izContext,
62
+ eventParams,
63
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
64
+ //(<additionalParams>)
65
+ //(</additionalParams>)
66
+ )
67
+
68
+ break
69
+ }
70
+ } else {
71
+ const connId = event.connId;
72
+ // await postMessage({ message: event.message }, connId);
73
+ await postToConnection({ message: event.message }, connId);
74
+ }
75
+
76
+ return (izara.response.webSocketSuccess());
77
+
78
+ } catch (err) {
79
+ const connId = event.requestContext.connectionId
80
+ event._izContext.logger.error('Error, WebSocket: ', err);
81
+ // await sendErrorMessage({ message: err.message }, connId);
82
+ await postToConnection({ message: err.message }, connId);
83
+ return (izara.response.failure(err));
84
+ }
85
+ });
@@ -0,0 +1,63 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+ const path = require('path');
20
+ const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
21
+ const {
22
+ SOURCE_PATH,
23
+ defaultIamRolePerAction,
24
+ createIamRole,
25
+ RESOURCE_CLASSES,
26
+ SNS_RESOURCE,
27
+ resourceNames,
28
+ DYNAMO_RESOURCE,
29
+ SAVE_FILE_NAME,
30
+ FUNCTION_NAME,
31
+ shortNameHandler,
32
+ externalResourceYaml,
33
+ SOURCE_GENERATE_IAM_ROLE
34
+ } = require('../../../../../../MainLibs/src/Consts');
35
+ const templatePath = path.join(__dirname, "template.ejs");
36
+
37
+ /**
38
+ * receive objectSchema
39
+ * create data for WebScoket handler template
40
+ *
41
+ * @param {Object} objectSchema
42
+ * @return {{templatePath, templateData,setting}}
43
+ */
44
+
45
+
46
+ function data(_izContext, flowSchema, srcPath) {
47
+ return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
48
+ }
49
+
50
+ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
51
+ let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicComplete)
52
+ return {
53
+ templatePath: templatePath,
54
+ templateData: {},
55
+ setting: {
56
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
57
+ saveFileName: `${functionName}_Main`,
58
+ fileExtension: ".js",
59
+ isAppend: false
60
+ }
61
+ }
62
+ }
63
+ module.exports = data
@@ -0,0 +1,105 @@
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
16
+ <http: //www.gnu.org/licenses />.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ const hash = require("object-hash");
22
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
23
+
24
+ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
+ const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
+ const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
+ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
+
30
+ const externalRequest = require('@izara_project/izara-core-library-external-request');
31
+ const sns = externalRequest.sns
32
+
33
+ const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
+ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
+ const { v4: uuidv4 } = require('uuid')
36
+ const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
+ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
+ /**
39
+ *
40
+ *
41
+ * description of function.
42
+ * @param {Object} _izContext
43
+ * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
44
+ * @param {Logger} _izContext.logger - property of _izContext
45
+ * @param {Object} requestParams - request params
46
+ * @param {Object} requestParams.identifiers - identifiers for get data
47
+ * @param {Object} requestParams.additionalRequest - additionalRequest
48
+ *
49
+ *
50
+ * @returns {object} description of return value
51
+ */
52
+
53
+ module.exports.flowSchemaOwnTopic = async (
54
+ _izContext,
55
+ requestParams,
56
+ callingFlowConfig = {},
57
+ //(<additionalParams>)
58
+ //(</additionalParams>)
59
+ ) => {
60
+
61
+ try {
62
+ _izContext.logger.debug("WebSocketInvoke _izContext", _izContext)
63
+ _izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
64
+ _izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
65
+
66
+ let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
67
+ flowTag: requestParams.flowTag,
68
+ serviceTag: process.env.iz_serviceTag
69
+ // serviceTag: "GenerateCodeTamplateBas002"
70
+ })
71
+
72
+ _izContext.logger.debug("flowSchema", flowSchema)
73
+
74
+
75
+ if (!flowSchema) {
76
+ throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`)
77
+ }
78
+
79
+ let messageObject = {
80
+ requestParams:requestParams
81
+ }
82
+ // create callingFlow
83
+ messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
84
+ messageObject,
85
+ callingFlowSharedLib.addParentCallingFlowConfig(
86
+ callingFlowConfig,
87
+ callingFlowSharedLib.createCallingFlowConfig(
88
+ await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.createNodeComplete), {}
89
+ )
90
+ )
91
+ )
92
+
93
+ // send message to ImportBatchCreateHdrSqs
94
+ let sendMessageToCreateEndpoint = {
95
+ Message: JSON.stringify(messageObject),
96
+ TopicArn: await snsSharedLib.snsTopicArn(_izContext, `flowSchema.flowSteps`)
97
+ }
98
+ _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
99
+ await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
100
+
101
+ } catch (err) {
102
+ _izContext.logger.error('error WebSocketInvoke: ', err)
103
+ throw (err)
104
+ }
105
+ }
@@ -32,7 +32,8 @@ const createWebSocketDynamoDb = require('./components/websocket/dynamoDb/WebSock
32
32
  const createReservedDataMainTable = require('./components/websocket/dynamoDb/ReservedTableData');
33
33
  const createBucketS3 = require('./components/upload/relate/S3/data');
34
34
  const createWebSocketGenerateCodeLibs = require('./components/upload/relate/libs/data');
35
-
35
+ const createWebSocketConnectYaml = require('./components/websocket/connect/functionYaml/data')
36
+ const createWebSocketConnectHandler = require('./components/websocket/connect/handler/data')
36
37
  // CreateObject components
37
38
  const createFunctionYamlCreateObjectWebSocket = require('./components/upload/createObject/functionYaml/data');
38
39
  const createHandlerCreateObjectWebSocket = require('./components/upload/createObject/handler/data');
@@ -68,6 +69,16 @@ const createConfirmAfterUploadS3Handler = require('./components/upload/confirmRe
68
69
  const createConfirmAfterUploadS3MainFunction = require('./components/upload/confirmReserved/mainFunction/data');
69
70
  const createConfirmAfterUploadS3Queue = require('./components/upload/confirmReserved/queue/data');
70
71
 
72
+ // 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');
76
+
77
+ // 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")
81
+
71
82
  /**
72
83
  * Generates code with templates for different actions
73
84
  * @param {Object} _izContext - Context object
@@ -82,12 +93,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
82
93
 
83
94
  // default webSocket setting
84
95
  const webSocketTaskTable = createWebSocketDynamoDb(_izContext, saveFilePath);
85
- // const webSocketConnectYaml = createWebSocketConnectYaml(_izContext, saveFilePath);
86
- // const webSocketConnectHandler = createWebSocketConnectHandler(_izContext, saveFilePath);
96
+ const webSocketConnectYaml = createWebSocketConnectYaml(_izContext, saveFilePath);
97
+ const webSocketConnectHandler = createWebSocketConnectHandler(_izContext, saveFilePath);
87
98
 
88
- const webSocketResource = [...webSocketTaskTable
89
- // ...webSocketConnectYaml, ...webSocketConnectHandler,
90
- ]
99
+ const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler]
91
100
  if (allLocalFlowSchemas.records.length) {
92
101
  createSourceParams.push(
93
102
  ...webSocketResource
@@ -95,42 +104,41 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
95
104
  }
96
105
 
97
106
  for (const flowSchema of allLocalFlowSchemas.records) {
98
- // console.log("flowSchema::", flowSchema)
107
+
99
108
  const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
100
109
  const bucketS3 = createBucketS3(_izContext, flowSchema, saveFilePath)
101
110
 
102
-
103
111
  const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
104
112
  const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
105
113
  const mainFunctionCreateObjectWebSocket = await createMainFunctionCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
106
- const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, saveFilePath);
114
+ const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
107
115
  const webSocketCreateObjectCompleteQueue = createWebSocketCreateObjectCompleteQueue(_izContext, saveFilePath);
108
- const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, saveFilePath)
109
- const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, saveFilePath);
116
+ const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath)
117
+ const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, flowSchema, saveFilePath);
110
118
 
111
119
  // const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
112
120
  const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, saveFilePath)
113
121
 
114
- const getPreSignUrlFunctionYaml = createReservedLimitFunctionYaml(_izContext, saveFilePath);
115
- const getPreSignUrlHandler = createReservedLimitlHandler(_izContext, saveFilePath);
116
- const getPreSignUrlMainFunction = createReservedLimitMainFunction(_izContext, saveFilePath);
122
+ const getPreSignUrlFunctionYaml = createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
123
+ const getPreSignUrlHandler = createReservedLimitlHandler(_izContext, flowSchema, saveFilePath);
124
+ const getPreSignUrlMainFunction = createReservedLimitMainFunction(_izContext, flowSchema, saveFilePath);
117
125
  const getPreSignUrlQueue = createReservedLimitQueueName(_izContext, saveFilePath);
118
126
 
119
- const reservedLimitCompleteFunctionYaml = createPresignUrlFunctionYaml(_izContext, saveFilePath);
127
+ const reservedLimitCompleteFunctionYaml = createPresignUrlFunctionYaml(_izContext, flowSchema, saveFilePath);
120
128
  const reservedLimitCompleteMainFunction = createPresignUrlMainFunction(_izContext, flowSchema, saveFilePath);
121
- const reservedLimitCompleteHandler = createPresignUrlHandler(_izContext, saveFilePath);
129
+ const reservedLimitCompleteHandler = createPresignUrlHandler(_izContext, flowSchema, saveFilePath);
122
130
  const reservedLimitCompleteQueue = createPresignUrlQueueName(_izContext, saveFilePath);
123
131
 
124
132
  const processAfterUploadFunctionYmlS3 = createProcessAfterUploadS3FunctionYmlS3(_izContext, flowSchema, saveFilePath);
125
133
  // const processAfterUploadFunctionYamlHdrDsq = createProcessAfterUploadS3FunctionYmlDsq(_izContext, saveFilePath);
126
134
  const processAfterUploadSqs = createProcessAfterUploadS3Queue(_izContext, saveFilePath);
127
- const processAfterUploadHandlerS3 = createProcessAfterUploadS3HandlerS3(_izContext, saveFilePath);
135
+ const processAfterUploadHandlerS3 = createProcessAfterUploadS3HandlerS3(_izContext, flowSchema, saveFilePath);
128
136
  // const processAfterUploadHandlerDsq = createProcessAfterUploadS3HandlerDsq(_izContext, saveFilePath);
129
- const processAfterUploadMainFunction = createProcessAfterUploadS3MainFunction(_izContext, saveFilePath);
137
+ const processAfterUploadMainFunction = createProcessAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
130
138
 
131
- const confirmReservedAfterUploadFunctionYaml = createConfirmAfterUploadS3FunctionYaml(_izContext, saveFilePath);
132
- const confirmReservedAfterUploadHandler = createConfirmAfterUploadS3Handler(_izContext, saveFilePath);
133
- const confirmReservedAfterUploadMainFunction = createConfirmAfterUploadS3MainFunction(_izContext, saveFilePath);
139
+ const confirmReservedAfterUploadFunctionYaml = createConfirmAfterUploadS3FunctionYaml(_izContext, flowSchema, saveFilePath);
140
+ const confirmReservedAfterUploadHandler = createConfirmAfterUploadS3Handler(_izContext, flowSchema, saveFilePath);
141
+ const confirmReservedAfterUploadMainFunction = createConfirmAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
134
142
  const confirmReservedAfterUploadQueue = createConfirmAfterUploadS3Queue(_izContext, saveFilePath);
135
143
 
136
144
  // Group related resources for better organization
@@ -175,16 +183,26 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
175
183
  ...confirmReservedAfterUploadQueue
176
184
  ];
177
185
 
178
- for (const event of flowSchema.event) {
179
- if (event.includes("s3")) {
180
- // Group all resources related to S3 upload functionality
181
- const webSocketUploadS3Resources = [
182
- ...webSocketFunctions,
183
- ...webSocketGenerateCodeLibs,
184
- ...reservedDataTable
185
- ];
186
+ // Group all resources related to S3 upload functionality
187
+ const webSocketUploadS3Resources = [
188
+ ...webSocketFunctions,
189
+ ...webSocketGenerateCodeLibs,
190
+ ...reservedDataTable
191
+ ];
186
192
 
193
+ const flowSchemaOwnTopicFunctionYaml = createFlowSchemaOwnTopicFunctionYaml(_izContext, flowSchema, saveFilePath);
194
+ const flowSchemaOwnTopicHandler = createFlowSchemaOwnTopicHandler(_izContext, flowSchema, saveFilePath);
195
+ const flowSchemaOwnTopicMainFunction = createFlowSchemaOwnTopicMainFunction(_izContext, flowSchema, saveFilePath);
187
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]
204
+ for (const event of flowSchema.event) {
205
+ if (event.includes("s3")) {
188
206
  // Add all resources to the parameters array
189
207
  createSourceParams.push(
190
208
  ...webSocketUploadS3Resources,
@@ -196,16 +214,18 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
196
214
  );
197
215
  }
198
216
 
199
- // if (flowSchema.hasOwnProperty("initializeRequest") && flowSchema.hasOwnProperty("response")) {
200
- // const webSocketEndpointResource = []
201
- // createSourceParams.push(...webSocketEndpointResource)
202
- // }
217
+ if (event.includes("ownTopic")) {
218
+ createSourceParams.push(
219
+ ...flowSchemaOwnTopicComponent,
220
+ ...flowSchemaOwnTopicCompleteComponent
221
+ )
222
+ }
203
223
  }
204
224
  }
205
-
225
+ console.log("createSourceParams in flowSchemas", createSourceParams)
206
226
  return createSourceParams;
207
227
  } catch (error) {
208
- _izContext.logger.error('Error generating code with template perActionComplete:', error);
228
+ _izContext.logger.error('Error generating code with template flowSchema:', error);
209
229
  return [];
210
230
  }
211
231
  }
@@ -110,6 +110,10 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
110
110
  handlerType: [],
111
111
  resources: {}
112
112
  },
113
+ [SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic]: {
114
+ handlerType: [],
115
+ resources: {}
116
+ },
113
117
  Other: []
114
118
  };
115
119
  const objectTypeList = [];
@@ -197,6 +201,12 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
197
201
  templateData.additionalResourcePermission,
198
202
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.perActionEndpoint].resources
199
203
  )
204
+ } else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic)) {
205
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic].handlerType.push(templateData);
206
+ processResourcePermissions(
207
+ templateData.additionalResourcePermission,
208
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic].resources
209
+ )
200
210
  }
201
211
  else {
202
212
  // Handle other items
@@ -1,76 +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 path = require('path');
20
-
21
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
22
- const { SOURCE_PATH, defaultIamRolePerAction, shortNameHandler, SAVE_FILE_NAME, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames, DYNAMO_RESOURCE } = require('../../../../libs/Consts');
23
- const templatePath = path.join(__dirname, "./template.ejs")
24
-
25
-
26
- function data(_izContext, flowSchema, srcPath) {
27
- return [createSourceParams(_izContext, srcPath)]
28
- }
29
-
30
- function createSourceParams(_izContext, flowSchema, srcPath) {
31
- let functionName = "InProcessWebSocket";
32
- let handlerType = "HdrWbs"
33
- let additionalResourcePermission = defaultIamRolePerAction();
34
- let functionNameConfig = upperCase(functionName) + upperCase(shortNameHandler(handlerType))
35
-
36
- additionalResourcePermission.push(
37
- createIamRole(
38
- {
39
- [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
40
- },
41
- [
42
- resourceNames(RESOURCE_CLASSES.sns, `InProcess${flowSchema.flowTag}`)
43
- ]
44
- ),
45
- createIamRole(
46
- {
47
- [RESOURCE_CLASSES.dynamoDbTable]: [
48
- DYNAMO_RESOURCE.putItem,
49
- DYNAMO_RESOURCE.deleteItem
50
- ]
51
- },
52
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
53
- )
54
- )
55
-
56
- return {
57
- templatePath: templatePath,
58
- templateData: {
59
- functionName,
60
- handlerType,
61
- functionNameConfig,
62
- additionalResourcePermission,
63
- resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
64
- route: flowSchema.flowTag
65
- },
66
- setting: {
67
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
68
- saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
69
- fileExtension: '.yml',
70
- isAppend: true
71
- }
72
- }
73
- }
74
-
75
-
76
- module.exports = data;
@@ -1,46 +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 path = require('path');
20
-
21
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
22
- const { SOURCE_PATH } = require('../../../../libs/Consts');
23
- const templatePath = path.join(__dirname, './template.ejs')
24
-
25
- function data(_izContext, srcPath) {
26
- return [createSourceParams(_izContext, srcPath)]
27
- }
28
-
29
- function createSourceParams(_izContext, srcPath) {
30
- let functionName = "InProcessWebSocket";
31
- let handlerType = "HdrWbs";
32
-
33
- return {
34
- templatePath: templatePath,
35
- templateData: {},
36
- setting: {
37
- savePath: path.join(srcPath, SOURCE_PATH.webSocket),
38
- saveFileName: upperCase(functionName) + upperCase(handlerType),
39
- fileExtension: ".js",
40
- isAppend: true
41
- }
42
- }
43
- }
44
-
45
-
46
- module.exports = data;
@@ -1,45 +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 path = require('path');
20
-
21
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
22
- const { SOURCE_PATH } = require('../../../../libs/Consts');
23
- const templatePath = path.join(__dirname, './template.ejs')
24
-
25
-
26
- function data(_izContext, srcPath) {
27
- return [createSourceParams(_izContext, srcPath)]
28
- }
29
-
30
- function createSourceParams(_izContext, srcPath) {
31
- let functionName = "InProcessWebSocket";
32
- return {
33
- templatePath: templatePath,
34
- templateData: {},
35
- setting: {
36
- savePath: path.join(srcPath, SOURCE_PATH.webSocket),
37
- saveFileName: `${functionName}_Main`,
38
- fileExtension: ".js",
39
- isAppend: false
40
- }
41
- }
42
- }
43
-
44
-
45
- module.exports = data;
@@ -1,35 +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 path = require('path');
20
-
21
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
22
- const { SOURCE_PATH } = require('../../../../libs/Consts');
23
- const templatePath = path.join(__dirname, './template.ejs')
24
-
25
-
26
- function data(_izContext, srcPath) {
27
- return [createSourceParams(_izContext, srcPath)]
28
- }
29
-
30
- function createSourceParams(_izContext, srcPath) {
31
-
32
- }
33
-
34
-
35
- module.exports = data;