@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
@@ -21,15 +21,13 @@ const izara = require("@izara_project/izara-middleware");
21
21
  const middleware = izara.middlewareHandler;
22
22
  // const AWS = require('aws-sdk');
23
23
  // const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
24
- const izaraShared = require('@izara_project/izara-shared')
25
- const dynamodbSharedLib = izaraShared.dynamodbSharedLib
26
- const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
24
+ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb')
25
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow')
27
26
  const hash = require('object-hash')
28
27
  // const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
29
28
  const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
30
- const { postToConnection } = require("../../libs/source/ImportDataLib");
31
- const createObject = require('./CreateObjectS3_Main');
32
-
29
+ const { postToConnection } = require("../../libs/source/GenerateCodeLibs");
30
+ const flowSchemaOwnTopic = require('./FlowSchemaOwnTopic_Main');
33
31
  module.exports.main = middleware.wrap(async (event, context, callback) => {
34
32
 
35
33
  event._izContext.logger.debug('Event:', event);
@@ -39,37 +37,17 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
39
37
  if (event.requestContext) {
40
38
  const route = event.requestContext.routeKey;
41
39
  const connectionId = event.requestContext.connectionId;
40
+ let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
42
41
 
43
42
  switch (route) {
44
- case "$connect":
45
- console.log("webSocket Connect");
46
- break
47
- case "$disconnect":
48
- console.log("webSocket Disconnect");
49
- break
43
+
50
44
  case '$default':
51
45
  console.log('Received unknown route:', route);
52
46
  break
53
- case 'webSocket':
47
+ case '<%- route %>':
54
48
  console.log("event in route webSocket", event);
55
-
56
49
  let eventParams = JSON.parse(event.body)
57
50
 
58
- let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
59
-
60
- await createObject.createObject(
61
- event._izContext,
62
- eventParams,
63
- //(<additionalParams>)
64
- event,
65
- //(</additionalParams>)
66
- callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
67
- )
68
-
69
- let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
70
- event._izContext.logger.debug("correlationId", correlationId)
71
-
72
- // if (returnValueFlowSchema) {
73
51
  await dynamodbSharedLib.putItem(
74
52
  event._izContext,
75
53
  await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
@@ -78,11 +56,16 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
78
56
  connectionId: connectionId,
79
57
  }
80
58
  )
81
- // }
82
59
 
83
- console.log({ message: eventParams })
84
- // await postMessage(returnValueFlowSchema, connectionId)
85
- // await postToConnection({ message: eventParams }, connectionId)
60
+ let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
61
+ await flowSchemaOwnTopic.flowSchemaOwnTopic(
62
+ event._izContext,
63
+ eventParams,
64
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
65
+ //(<additionalParams>)
66
+ //(</additionalParams>)
67
+ )
68
+
86
69
  break
87
70
  }
88
71
  } else {
@@ -0,0 +1,66 @@
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.flowSchemaOwnTopic)
52
+ let topicArn = Object.keys(flowSchema.flowSteps)[0];
53
+ return {
54
+ templatePath: templatePath,
55
+ templateData: {
56
+ topicArn
57
+ },
58
+ setting: {
59
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
60
+ saveFileName: `${functionName}_Main`,
61
+ fileExtension: ".js",
62
+ isAppend: false
63
+ }
64
+ }
65
+ }
66
+ module.exports = data
@@ -0,0 +1,104 @@
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.flowSchemaOwnTopicComplete), {}
89
+ )
90
+ )
91
+ )
92
+
93
+ let sendMessageToCreateEndpoint = {
94
+ Message: JSON.stringify(messageObject),
95
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, )
96
+ }
97
+ _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
98
+ await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
99
+
100
+ } catch (err) {
101
+ _izContext.logger.error('error WebSocketInvoke: ', err)
102
+ throw (err)
103
+ }
104
+ }
@@ -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;