@izara_project/izara-market-library-service-schemas 1.0.30 → 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 (103) hide show
  1. package/package.json +9 -9
  2. package/src/GenerateCodeLibs/src/Consts.js +29 -13
  3. package/src/MainLibs/src/Consts.js +16 -6
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +3 -6
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +2 -3
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +2 -2
  7. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +3 -3
  8. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +10 -8
  9. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +5 -5
  10. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +22 -0
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +4 -4
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/data.js +4 -4
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/data.js +2 -2
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +1 -1
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +2 -2
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +1 -1
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +1 -1
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +1 -1
  19. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +4 -4
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/handler/data.js +4 -4
  21. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/data.js +4 -4
  22. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +1 -1
  23. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/data.js +4 -4
  24. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/data.js +4 -4
  25. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/data.js +1 -1
  26. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +1 -2
  27. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +4 -4
  28. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/data.js +4 -4
  29. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +4 -4
  30. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +1 -1
  31. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/template.ejs +18 -18
  32. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +1 -1
  33. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/data.js +4 -4
  34. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/data.js +4 -4
  35. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +1 -1
  36. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +1 -1
  37. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +3 -3
  38. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +2 -0
  39. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +3 -2
  40. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -16
  41. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +73 -0
  42. package/src/reStructure/TemplateData/flowSchema/{legacy/hookCode-old/queue/sqsTemplate.ejs → externalTopic/sns-in-sqs/template.ejs} +21 -11
  43. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +75 -0
  44. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +10 -0
  45. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +83 -0
  46. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +17 -0
  47. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +65 -0
  48. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template copy.ejs +125 -0
  49. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +130 -0
  50. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +61 -0
  51. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +70 -0
  52. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +147 -0
  53. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +18 -0
  54. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +64 -0
  55. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +86 -0
  56. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +60 -0
  57. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +74 -0
  58. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +107 -0
  59. package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess → flowSchemaOwnTopic/EndpointComponent}/functionYaml/template.ejs +1 -14
  60. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +57 -0
  61. package/src/reStructure/TemplateData/flowSchema/{legacy/hookCode-old/handler/templateAsyncHandler.ejs → flowSchemaOwnTopic/EndpointComponent/handler/template.ejs} +11 -37
  62. package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess → flowSchemaOwnTopic/EndpointComponent}/mainFunction/data.js +20 -13
  63. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +73 -0
  64. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +117 -0
  65. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +24 -0
  66. package/src/reStructure/TemplateData/flowSchema/{legacy/hookCode-old/mainFunction → flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler}/data.js +15 -24
  67. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +84 -0
  68. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data.js +52 -0
  69. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +88 -0
  70. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +117 -0
  71. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +24 -0
  72. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +57 -0
  73. package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess → flowSchemaOwnTopic/FlowSchemaComponent}/handler/template.ejs +16 -33
  74. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +66 -0
  75. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +104 -0
  76. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +96 -0
  77. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +167 -99
  78. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +20 -0
  79. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +3 -3
  80. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +3 -3
  81. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +13 -14
  82. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +3 -3
  83. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/functionYaml/data.js +0 -76
  84. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/handler/data.js +0 -46
  85. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/sns-sqs/data.js +0 -35
  86. package/src/reStructure/TemplateData/flowSchema/components/schema/inProcess/sns-sqs/template.ejs +0 -0
  87. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/functionYaml/data.js +0 -34
  88. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/functionYaml/template.ejs +0 -0
  89. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/handler/data.js +0 -34
  90. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/handler/template.ejs +0 -0
  91. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/mainFunction/data.js +0 -34
  92. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/mainFunction/template.ejs +0 -0
  93. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/sns-sqs/data.js +0 -34
  94. package/src/reStructure/TemplateData/flowSchema/components/schema/outComplete/sns-sqs/template.ejs +0 -0
  95. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/functionYaml/data.js +0 -101
  96. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/functionYaml/template.ejs +0 -43
  97. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/data.js +0 -93
  98. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/handler/templateSyncHandler.ejs +0 -49
  99. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/hookLogic/data.js +0 -64
  100. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/mainFunction/template.ejs +0 -30
  101. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/data.js +0 -124
  102. package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/snsTemplate.ejs +0 -59
  103. /package/src/reStructure/TemplateData/flowSchema/{components/schema/inProcess/mainFunction → flowSchemaOwnTopic/sns-in}/template.ejs +0 -0
@@ -0,0 +1,86 @@
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 { middlewareHandler, consts } = require("@izara_project/izara-middleware");
21
+ // const AWS = require('aws-sdk');
22
+ // const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
23
+ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
24
+ const callingFlowSharedLib = require('@izara_project/izara-core-calling-flow');
25
+ const hash = require('object-hash');
26
+ // const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
27
+ const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts');
28
+ const { postToConnection } = require("../../libs/source/ImportDataLib");
29
+ const { <%- functionName%>Main } = require("./<%- fileName%>_Main");
30
+
31
+ module.exports.main = middlewareHandler.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 '<%- flowTag%>':
44
+ console.log("event in route <%- flowTag%>", event);
45
+ let eventParams = JSON.parse(event.body)
46
+
47
+ await dynamodbSharedLib.putItem(
48
+ event._izContext,
49
+ await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
50
+ {
51
+ taskKey: correlationId,
52
+ connectionId: connectionId,
53
+ }
54
+ )
55
+
56
+ let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
57
+
58
+ await <%- functionName%>Main(
59
+ event._izContext,
60
+ eventParams,
61
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
62
+ //(<additionalParams>)
63
+ //(</additionalParams>)
64
+ )
65
+ break
66
+ }
67
+ } else {
68
+ const connId = event.connId;
69
+ // await postMessage({ message: event.message }, connId);
70
+ await postToConnection({ message: event.message }, connId);
71
+ }
72
+
73
+ return (izara.response.webSocketSuccess());
74
+
75
+ } catch (err) {
76
+ const connId = event.requestContext.connectionId
77
+ event._izContext.logger.error('Error, WebSocket: ', err);
78
+ // await sendErrorMessage({ message: err.message }, connId);
79
+ await postToConnection({ message: err.message }, connId);
80
+ return (izara.response.failure(err));
81
+ }
82
+ });
83
+ <%_ const join = require('path').join _%>
84
+ <%_ function upperCase (text) {
85
+ return text.charAt(0).toUpperCase() + text.slice(1)
86
+ } _%>
@@ -0,0 +1,60 @@
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
+ const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts");
23
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
24
+ const templatePath = path.join(__dirname, "template.ejs");
25
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
26
+
27
+ /**
28
+ * receive objectSchema
29
+ * create data for WebSocket Main template
30
+ *
31
+ * @param {Object} objectSchema
32
+ * @return {{templatePath, templateData,setting}}
33
+ */
34
+
35
+
36
+ function data(_izContext, flowSchema, srcPath) {
37
+ return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
38
+ }
39
+
40
+ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
41
+ const functionName = upperCase(FUNCTION_NAME.flowSchemaExternalTopic)
42
+ const splitKey = Object.keys(flowSchema.flowSteps)[0].split('_')
43
+ // let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
44
+ // let fieldNames = Object.keys(objectSchema.fieldNames)
45
+ return {
46
+ templatePath: templatePath,
47
+ templateData: {
48
+ serviceTag: splitKey[0],
49
+ topicName: splitKey[3] + '_' + splitKey[4],
50
+ externalTopicMain: FUNCTION_NAME.flowSchemaExternalTopic + 'Main',
51
+ },
52
+ setting: {
53
+ savePath: path.join(srcPath, SOURCE_PATH.webSocket, flowSchema.flowTag + '/'),
54
+ saveFileName: `${functionName}_Main`,
55
+ fileExtension: ".js",
56
+ isAppend: false
57
+ }
58
+ }
59
+ }
60
+ module.exports = data
@@ -0,0 +1,74 @@
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');
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.<%- externalTopicMain%> = async (
54
+ _izContext,
55
+ requestParams,
56
+ callingFlowConfig = {},
57
+ //(<additionalParams>)
58
+ //(</additionalParams>)
59
+ ) => {
60
+
61
+ try {
62
+ // send message to ImportBatchCreateHdrSqs
63
+ let sendMessageToCreateEndpoint = {
64
+ Message: JSON.stringify(requestParams),
65
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, '<%- topicName%>', '<%- serviceTag%>')
66
+ }
67
+ _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
68
+ await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
69
+
70
+ } catch (err) {
71
+ _izContext.logger.error('error WebSocketInvoke: ', err)
72
+ throw (err)
73
+ }
74
+ }
@@ -0,0 +1,107 @@
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 { FLOW_SCHEMA_HOOK_STATE, ACTIONS } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+ const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
23
+ const {
24
+ SOURCE_PATH,
25
+ defaultIamRolePerAction,
26
+ createIamRole,
27
+ RESOURCE_CLASSES,
28
+ SNS_RESOURCE,
29
+ resourceNames,
30
+ DYNAMO_RESOURCE,
31
+ SAVE_FILE_NAME,
32
+ FUNCTION_NAME,
33
+ shortNameHandler,
34
+ externalResourceYaml,
35
+ SOURCE_GENERATE_IAM_ROLE
36
+ } = require('../../../../../../MainLibs/src/Consts');
37
+ const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
38
+
39
+ const templatePath = path.join(__dirname, "template.ejs");
40
+ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
41
+ /**
42
+ * receive objectSchema
43
+ * create data for WebScoket handler template
44
+ *
45
+ * @param {Object} objectSchema
46
+ * @return {{templatePath, templateData,setting}}
47
+ */
48
+
49
+ function data(_izContext, flowSchema, srcPath) {
50
+ return [createSourceParams(_izContext, flowSchema, srcPath)]
51
+ }
52
+
53
+ function createSourceParams(_izContext, flowSchema, srcPath) {
54
+ let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpoint)
55
+ let handlerType = upperCase("hdrSqs")
56
+ let additionalResourcePermission = defaultIamRolePerAction();
57
+ let route = flowSchema.flowTag;
58
+
59
+ additionalResourcePermission.push(
60
+ createIamRole(
61
+ {
62
+ [RESOURCE_CLASSES.dynamoDbTable]: [
63
+ DYNAMO_RESOURCE.putItem,
64
+ DYNAMO_RESOURCE.getItem,
65
+ DYNAMO_RESOURCE.query,
66
+ DYNAMO_RESOURCE.deleteItem,
67
+ DYNAMO_RESOURCE.updateItem
68
+ ]
69
+ },
70
+ [
71
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
72
+ ]
73
+ ),
74
+ createIamRole(
75
+ {
76
+ "execute-api": [
77
+ "ManageConnections"
78
+ ]
79
+ },
80
+ [
81
+ resourceNames(RESOURCE_CLASSES.webSocket)
82
+ ]
83
+ )
84
+ )
85
+
86
+
87
+ return {
88
+ templatePath: templatePath,
89
+ templateData: {
90
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaOwnTopic, flowSchema.flowTag, "source/"),
91
+ functionName,
92
+ handlerType,
93
+ additionalResourcePermission,
94
+ route,
95
+ functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
96
+ roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic
97
+ },
98
+ setting: {
99
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
100
+ saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
101
+ fileExtension: ".yml",
102
+ isAppend: true
103
+ }
104
+ }
105
+ }
106
+
107
+ module.exports = data;
@@ -13,20 +13,7 @@
13
13
  route: <%- route %>
14
14
  # authorizer: ${self:custom.iz_authorizerAppLevel}
15
15
  # identifierResource: 'route.request.header.Auth'
16
- iamRoleStatements:
17
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
18
- - Effect: <%- resourcePermission.effect %>
19
- Action:
20
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
21
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
22
- - <%- resourcePerAction %>:<%- permission %>
23
- <%_}) _%>
24
- <%_ }) _%>
25
- Resource:
26
- <%_ resourcePermission.resource.forEach(resource => { _%>
27
- - <%- resource %>
28
- <%_ }) _%>
29
- <%_}) _%>
16
+ role: <%- roleName %>Role
30
17
  #<#<%- functionName %><%- handlerType %>IamRole#>
31
18
  #<#/<%- functionName %><%- handlerType %>IamRole#>
32
19
  <%_ function firstLetterUpperCase(text){
@@ -0,0 +1,57 @@
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 { FLOW_SCHEMA_HOOK_STATE, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
21
+ const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../MainLibs/src/Consts');
22
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
23
+ const templatePath = path.join(__dirname, "template.ejs")
24
+
25
+ /**
26
+ * receive objectSchema
27
+ * create data for WebScoket handler template
28
+ *
29
+ * @param {Object} objectSchema
30
+ * @return {{templatePath, templateData,setting}}
31
+ */
32
+
33
+
34
+ function data(_izContext, flowSchema, srcPath) {
35
+ return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
36
+ }
37
+
38
+ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
+ let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpoint)
40
+ let handlerType = HANDLER.hdrSqs
41
+ let route = flowSchema.flowTag;
42
+ return {
43
+ templatePath: templatePath,
44
+ templateData: {
45
+ functionName,
46
+ handlerType,
47
+ route
48
+ },
49
+ setting: {
50
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
51
+ saveFileName: `${functionName}_${handlerType}`,
52
+ fileExtension: ".js",
53
+ isAppend: false
54
+ }
55
+ }
56
+ }
57
+ module.exports = data
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2021 Sven Mason <http://izara.io>
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
3
 
4
4
  This program is free software: you can redistribute it and/or modify
5
5
  it under the terms of the GNU Affero General Public License as
@@ -18,43 +18,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
 
20
20
  // const AWS = require('aws-sdk');
21
- // const sqs = new AWS.SQS(firstLetterUpperCase{ apiVersion: '2012-11-05' });
21
+ // const sqs = new AWS.SQS({ apiVersion: '2012-11-05' });
22
22
 
23
23
  const izara = require("@izara_project/izara-middleware");
24
24
  const middleware = izara.middlewareHandler;
25
- const recordHandlerSharedLib = require("@izara_project/izara-shared").recordHandlerSharedLib;
25
+ const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
26
26
  const Logger = require('@izara_project/izara-core-library-logger');
27
- const izaraShared = require('@izara_project/izara-shared');
28
- const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
29
27
 
30
- const <%- hookFunctionName %> = require('./<%- hookFunctionName %>_Main')
28
+ const FlowSchemaOwnTopicEndpoint = require('./FlowSchemaOwnTopicEndpoint_Main')
31
29
 
32
30
  // validate event properties in body.Message of sqs event
33
31
  middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
34
32
 
35
- // set schema for record.body.Message
36
- let perRecordsValidatorSchema = {
37
- type: "object",
38
- required: [
39
- 'returnMessage',
40
- 'errorsFound',
41
- 'passStatus'
42
- ],
43
- properties: {
44
- returnMessage: {
45
- type: "object"
46
- },
47
- errorsFound: {
48
- type: "array"
49
- },
50
- passStatus: {
51
- type: 'boolean'
52
- }
53
- }
54
- };
55
-
56
- perRecordsValidatorSchema = callingFlowSharedLib.addOptionalPassBackPropertiesToValidatorSchema(perRecordsValidatorSchema)
57
-
58
33
  module.exports.main = middleware.wrap(async (event, context, callback) => {
59
34
 
60
35
  try {
@@ -67,24 +42,23 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
67
42
  let passOnProperties = []
68
43
  record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
69
44
 
70
- // validate message (and MessageAttributes)
45
+ //validate message (and MessageAttributes)
71
46
  await recordHandlerSharedLib.validateRecord(
72
47
  record, // one record will send to mainFunction
73
- "<%- queueName %>", // queue name that need to retry or send to dlq
48
+ "FlowSchemaOwnTopicEndpoint", // queue name that need to retry or send to dlq
74
49
  perRecordsValidatorSchema, // schema for record.Message
75
- // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
50
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
76
51
  );
77
52
 
78
53
  // add argument (to invoke lambda) to passOnProperties[]
79
54
  passOnProperties.push(record.body.Message)
80
- passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message))
81
55
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
82
56
 
83
57
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
84
58
  let recordPromise = recordHandlerSharedLib.recordHandler(
85
59
  record, // one record will send to mainFunction
86
- <%- hookFunctionName %>, // mainFunction that need to invoke.
87
- "<%- queueName %>", // queue name that need to retry or send to dlq
60
+ FlowSchemaOwnTopicEndpoint.FlowSchemaOwnTopicEndpoint, // mainFunction that need to invoke.
61
+ "FlowSchemaOwnTopicEndpoint", // queue name that need to retry or send to dlq
88
62
  passOnProperties, // all parameters that mainFunction needed.
89
63
  );
90
64
  record._izContext.logger.debug('after recordPromise in handler');
@@ -96,7 +70,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
96
70
  // --- main await all promises
97
71
  await Promise.all(recordPromises); // await all promises
98
72
 
99
- return event.Records // return all for local test
73
+ return event.Records // return all for local testing
100
74
 
101
75
  } catch {
102
76
  Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
@@ -104,7 +78,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
104
78
  Logger.debug('after Promise.all(recordPromises) in handler');
105
79
 
106
80
  } catch (err) {
107
- Logger.error('Unhandled Error, <%- hookFunctionName %>: ', err);
81
+ Logger.error('Unhandled Error, LambdaFunctionHdrSqs: ', err);
108
82
  throw (err);
109
83
  }
110
84
  });
@@ -18,28 +18,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
  const path = require('path');
20
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)]
21
+ const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../MainLibs/src/Consts');
22
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
23
+ const templatePath = path.join(__dirname, "template.ejs");
24
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
25
+
26
+ /**
27
+ * receive objectSchema
28
+ * create data for WebScoket handler template
29
+ *
30
+ * @param {Object} objectSchema
31
+ * @return {{templatePath, templateData,setting}}
32
+ */
33
+
34
+
35
+ function data(_izContext, flowSchema, srcPath) {
36
+ return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
28
37
  }
29
38
 
30
- function createSourceParams(_izContext, srcPath) {
31
- let functionName = "InProcessWebSocket";
39
+ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
40
+ let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpoint)
32
41
  return {
33
42
  templatePath: templatePath,
34
43
  templateData: {},
35
44
  setting: {
36
- savePath: path.join(srcPath, SOURCE_PATH.webSocket),
45
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
37
46
  saveFileName: `${functionName}_Main`,
38
47
  fileExtension: ".js",
39
48
  isAppend: false
40
49
  }
41
50
  }
42
51
  }
43
-
44
-
45
- module.exports = data;
52
+ module.exports = data
@@ -0,0 +1,73 @@
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
+ const { postToConnection } = require("../../../../libs/source/GenerateCodeLibs");
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.FlowSchemaOwnTopicEndpoint = async (
54
+ _izContext,
55
+ requestParams,
56
+ callingFlowConfig = {},
57
+ //(<additionalParams>)
58
+ //(</additionalParams>)
59
+ ) => {
60
+
61
+ try {
62
+ _izContext.logger.debug("flowSchemaOwnTopicEndpoint _izContext", _izContext)
63
+ _izContext.logger.debug("flowSchemaOwnTopicEndpoint requestParams", requestParams)
64
+ _izContext.logger.debug("flowSchemaOwnTopicEndpoint callingFlowConfig", callingFlowConfig)
65
+
66
+ //(<endpointHookMainFunction>)
67
+ //(</endpointHookMainFunction>)
68
+
69
+ } catch (err) {
70
+ _izContext.logger.error('error WebSocketInvoke: ', err)
71
+ throw (err)
72
+ }
73
+ }