@izara_project/izara-market-library-service-schemas 1.0.40 → 1.0.42

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 (75) hide show
  1. package/package.json +1 -1
  2. package/src/MainLibs/src/Consts.js +1 -1
  3. package/src/reStructure/GenerateSchema.js +6 -6
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -12
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +23 -8
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +28 -21
  7. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +0 -32
  8. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +1 -1
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +1 -1
  10. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +5 -2
  11. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +1 -1
  12. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +0 -20
  13. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +7 -16
  14. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +2 -2
  15. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/template.ejs +0 -1
  16. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/functionYaml/data.js +112 -0
  17. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/handler/data.js +93 -0
  18. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/data.js +61 -0
  19. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/template.ejs +96 -0
  20. package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Process/functionYaml}/data.js +20 -4
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Process/handler}/data.js +3 -3
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +87 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/data.js +2 -2
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/template.ejs +2 -2
  25. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +14 -4
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +52 -0
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +10 -9
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +1 -1
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +8 -4
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/template.ejs +1 -1
  32. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +12 -11
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +93 -49
  34. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +1 -1
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +1 -1
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +2 -0
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +3 -2
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +2 -2
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -1
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +2 -2
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +9 -21
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/sqsTemplate.ejs +0 -10
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +1 -1
  45. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/functionYaml/data.js +37 -24
  46. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/template.ejs +20 -0
  47. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/data.js +24 -20
  48. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/data.js +27 -22
  49. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +90 -0
  50. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +45 -0
  51. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +45 -29
  52. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/data.js +3 -1
  53. package/src/reStructure/TemplateData/flowSchema/register/complete/handler/data.js +0 -1
  54. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +33 -29
  55. package/src/reStructure/TemplateData/flowSchema/register/dynamoDB/register.js +0 -17
  56. package/src/reStructure/TemplateData/flowSchema/register/sns-in/data.js +0 -1
  57. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/data.js +1 -3
  58. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/template.ejs +2 -2
  59. package/src/reStructure/TemplateData/flowSchema/register/wbs/functionYaml/data.js +0 -29
  60. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/data.js +0 -1
  61. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/template.ejs +3 -5
  62. package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +35 -32
  63. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +7 -1
  64. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +1 -1
  65. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/data.js +97 -0
  66. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/template.ejs +52 -0
  67. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +1 -0
  68. package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +18 -18
  69. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +82 -79
  70. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +33 -37
  71. /package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Complete/functionYaml}/template.ejs +0 -0
  72. /package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Complete/handler}/template.ejs +0 -0
  73. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → externalTopic/Process}/functionYaml/template.ejs +0 -0
  74. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/template.ejs +0 -0
  75. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/template.ejs +0 -0
@@ -1,50 +1,94 @@
1
- /* Copyright (C) 2020 Sven Mason <http: //izara.io> This program is free
2
- software: you can redistribute it and/or modify it under the terms of the GNU
3
- Affero General Public License as published by the Free Software Foundation,
4
- either version 3 of the License, or (at your option) any later version. This
5
- program is distributed in the hope that it will be useful, but WITHOUT ANY
6
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
7
- PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
8
- You should have received a copy of the GNU Affero General Public License along
9
- with this program. If not, see <http: //www.gnu.org/licenses />. */ 'use
10
- strict'; const hash = require("object-hash"); const getObjectSchema =
11
- require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
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('@izara_project/izara-shared-core').objectHash;
22
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
23
+
12
24
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
13
- const snsSharedLib = require('@izara_project/izara-core-library-sns'); const
14
- asyncFlowSharedLib =
15
- require('@izara_project/izara-core-library-asynchronous-flow'); const
16
- callingFlowSharedLib =
17
- require('@izara_project/izara-core-library-calling-flow'); const lambdaSharedLib
18
- = require('@izara_project/izara-core-library-lambda'); const externalRequest =
19
- require('@izara_project/izara-core-library-external-request'); const sns =
20
- externalRequest.sns const { postToConnection } =
21
- require("../../../libs/source/GenerateCodeLibs"); const utils =
22
- require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
23
- const NoRetryError =
24
- require('@izara_project/izara-core-library-core').NoRetryError const { v4:
25
- uuidv4 } = require('uuid') const coreConsts =
26
- require("@izara_project/izara-core-library-core/src/Consts"); const {
27
- TOPIC_NAME_GENERATE_CODE } =
28
- require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
29
- /** * * * description of function. * @param {Object} _izContext * @param
30
- {CorrelationIds} _izContext.correlationIds - property of _izContext * @param
31
- {Logger} _izContext.logger - property of _izContext * @param {Object}
32
- requestParams - request params * @param {Object} requestParams.identifiers -
33
- identifiers for get data * @param {Object} requestParams.additionalRequest -
34
- additionalRequest * * * @returns {object} description of return value */
35
- module.exports.FlowSchemaOwnTopicEndpointComplete = async ( _izContext,
36
- requestParams, callingFlowConfig = {}, //(<additionalParams
37
- >) //(</additionalParams
38
- >) ) => { try { _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete
39
- _izContext", _izContext)
40
- _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete requestParams",
41
- requestParams) _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete
42
- callingFlowConfig", callingFlowConfig) //(<endpointCompleteHookMainFunction
43
- >) //(</endpointCompleteHookMainFunction
44
- >) let messageObject = { //(<messageObjectHook>) //(</messageObjectHook>) } let
45
- sendMessageToOutFlowSchema = { Message: JSON.stringify(messageObject), TopicArn:
46
- await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "<%- topicOut %>") };
47
- _izContext.logger.debug("before sendMessageToOutFlowSchema::",
48
- sendMessageToOutFlowSchema); await sns.publishAsync(_izContext,
49
- sendMessageToOutFlowSchema) } catch (err) { _izContext.logger.error('error
50
- FlowSchemaOwnTopicEndpointComplete: ', err) throw (err) } }
25
+ const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
+ const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
27
+ const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
28
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
29
+ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
30
+ const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
31
+ const triggeredCacheSharedLib = require('@izara_project/izara-core-library-trigger-cache')
32
+ const externalRequest = require('@izara_project/izara-core-library-external-request');
33
+ const sns = externalRequest.sns
34
+ const sqs = externalRequest.sqs
35
+ const lambda = externalRequest.lambda
36
+ const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
37
+ const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
38
+ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
39
+ const { v4: uuidv4 } = require('uuid')
40
+ const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
41
+ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
42
+ const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
43
+ const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs.js')
44
+ //(<optionalRequire>)
45
+ //(</optionalRequire>)
46
+ /**
47
+ *
48
+ *
49
+ * description of function.
50
+ * @param {Object} _izContext
51
+ * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
52
+ * @param {Logger} _izContext.logger - property of _izContext
53
+ * @param {Object} requestParams - request params
54
+ * @param {Object} requestParams.identifiers - identifiers for get data
55
+ * @param {Object} requestParams.additionalRequest - additionalRequest
56
+ *
57
+ *
58
+ * @returns {object} description of return value
59
+ */
60
+
61
+ module.exports.<%- functionName %> = async (
62
+ _izContext,
63
+ requestParams,
64
+ callingFlowConfig = {},
65
+ //(<additionalParams>)
66
+ //(</additionalParams>)
67
+ ) => {
68
+
69
+ try {
70
+ _izContext.logger.debug("<%- functionName %> _izContext", _izContext)
71
+ _izContext.logger.debug("<%- functionName %> requestParams", requestParams)
72
+ _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
73
+
74
+ _izContext.correlationIds.get(consts.X_CORRELATION_ID)
75
+ _izContext.correlationIds.get(consts.CONNECTION_ID);
76
+
77
+ //(<endpointHook>)
78
+ //(</endpointHook>)
79
+ const flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
80
+ flowTag: "<%- flowTag %>",
81
+ serviceTag: process.env.iz_serviceTag
82
+ })
83
+ //(<beforeReturn>)
84
+ //(</beforeReturn>)
85
+
86
+ return {
87
+ //(<endpointReturn>)
88
+ //(</endpointReturn>)
89
+ }
90
+ } catch (err) {
91
+ _izContext.logger.error('error WebSocketInvoke: ', err)
92
+ throw (err)
93
+ }
94
+ }
@@ -58,7 +58,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
58
58
  let handlerType = upperCase(HANDLER.hdrSqs)
59
59
  let additionalResourcePermission = defaultIamRolePerAction();
60
60
  let route = upperCase(flowSchema.flowTag);
61
- let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
61
+ let queueName = upperCase(flowSchema.flowTag) + handlerType;
62
62
  additionalResourcePermission.push(
63
63
  createIamRole(
64
64
  {
@@ -39,7 +39,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
39
  let functionName = "Process" + upperCase(flowSchema.flowTag)
40
40
  let handlerType = upperCase(HANDLER.hdrSqs)
41
41
  let route = upperCase(flowSchema.flowTag);
42
- let queueName = `Process${upperCase(flowSchema.flowTag)}${upperCase(handlerType)}`
42
+ let queueName = `${upperCase(flowSchema.flowTag)}${upperCase(handlerType)}`
43
43
 
44
44
  return {
45
45
  templatePath: templatePath,
@@ -53,6 +53,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
53
53
 
54
54
  // add argument (to invoke lambda) to passOnProperties[]
55
55
  passOnProperties.push(record.body.Message)
56
+ //(<additionalParams>)
57
+ //(</additionalParams>)
56
58
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
57
59
 
58
60
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
  const path = require('path');
20
-
20
+ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
21
21
  const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require('../../../../../../MainLibs/src/Consts');
22
22
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
23
23
  const templatePath = path.join(__dirname, "template.ejs");
@@ -45,6 +45,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
45
45
  let tableName = null;
46
46
  if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
47
47
  let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
48
+ if (!objectSchema) throw new NoRetryError('no objectSchema in local service')
48
49
  for (const storageResource of Object.values(objectSchema.storageResources)) {
49
50
  if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
50
51
  tableName = storageResource.tableName
@@ -56,7 +57,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
56
57
  if (flowSchema.statusType === "triggerCache" && flowSchema.hasOwnProperty("triggerType")) {
57
58
  triggerType = flowSchema.triggerType;
58
59
  }
59
- let flowSchemaComplete = upperCase(flowSchema.flowTag) + "Complete"
60
+ let flowSchemaComplete = upperCase(flowSchema.flowTag)
60
61
 
61
62
  return {
62
63
  templatePath: templatePath,
@@ -61,9 +61,9 @@ const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_proj
61
61
  module.exports.<%- functionName %> = async (
62
62
  _izContext,
63
63
  requestParams,
64
- callingFlowConfig = {},
65
64
  //(<additionalParams>)
66
65
  //(</additionalParams>)
66
+ callingFlowConfig = {},
67
67
  ) => {
68
68
 
69
69
  try {
@@ -75,7 +75,7 @@ module.exports.<%- functionName %> = async (
75
75
  _izContext.correlationIds.get(consts.CONNECTION_ID);
76
76
 
77
77
  const flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
78
- flowTag: requestParams.action,
78
+ flowTag: "<%- flowTag %>",
79
79
  serviceTag: process.env.iz_serviceTag
80
80
  })
81
81
 
@@ -55,7 +55,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
55
55
  let handlerType = upperCase("hdrWbs")
56
56
  let additionalResourcePermission = defaultIamRolePerAction();
57
57
  let route = flowSchema.flowTag;
58
- let topicIn = `Process${upperCase(flowSchema.flowTag)}_In`
58
+ let topicIn = `${upperCase(flowSchema.flowTag)}_In`
59
59
 
60
60
  additionalResourcePermission.push(
61
61
  createIamRole(
@@ -50,7 +50,7 @@ function data(_izContext, flowSchema, srcPath) {
50
50
 
51
51
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
52
52
  let functionName = upperCase(flowSchema.flowTag)
53
- let topicArn = `Process${upperCase(flowSchema.flowTag)}_In`
53
+ let topicArn = `${upperCase(flowSchema.flowTag)}_In`
54
54
 
55
55
  return {
56
56
  templatePath: templatePath,
@@ -66,7 +66,7 @@ module.exports.<%- functionName %> = async (
66
66
  _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
67
67
 
68
68
  let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
69
- flowTag: requestParams.action,
69
+ flowTag: "<%- flowTag %>",
70
70
  serviceTag: process.env.iz_serviceTag
71
71
  })
72
72
 
@@ -91,7 +91,7 @@ module.exports.<%- functionName %> = async (
91
91
  callingFlowSharedLib.addParentCallingFlowConfig(
92
92
  callingFlowConfig,
93
93
  callingFlowSharedLib.createCallingFlowConfig(
94
- await lambdaSharedLib.lambdaFunctionName(_izContext, "WebSocketCompleteHdrSqs"), {}
94
+ await lambdaSharedLib.lambdaFunctionName(_izContext, "WebSocketComplete"), {}
95
95
  )
96
96
  )
97
97
  )
@@ -22,14 +22,14 @@ const path = require("path")
22
22
 
23
23
  // const {
24
24
  // HANDLER,
25
- // STORAGE_TYPES
25
+ // STORAGE_TYPES
26
26
  // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
27
27
 
28
28
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils.js");
29
- const STORAGE_TYPES = {
30
- dynamoDB: "dynamoDB",
31
- graph: "graph"
32
- }
29
+ // const STORAGE_TYPES = {
30
+ // dynamoDB: "dynamoDB",
31
+ // graph: "graph"
32
+ // }
33
33
 
34
34
  const snsTemplatePath = path.join(__dirname, '../../../resourceYaml/sns-in-sqs/snsTemplate.ejs');
35
35
  const subscriptionSqsTemplatePath = path.join(__dirname, './sqsTemplate.ejs');
@@ -64,7 +64,7 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
64
64
  if (flowSteps.includes("In")) {
65
65
  generatedSnsTopicInForFlowSchema.push(
66
66
  {
67
- queueName: "Process" + upperCase(topicIn)
67
+ queueName: upperCase(topicIn)
68
68
  }
69
69
  )
70
70
  }
@@ -75,28 +75,16 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
75
75
  if (flowSchema.outputTopic) {
76
76
  if (flowSteps.includes("Out")) {
77
77
  if (flowSchema.outputTopic) {
78
- let topicOut = `${upperCase(flowSchema.flowTag)}Complete`;
79
- defaultDsqQueueDataList.push({
80
- queueName: `WebSocketComplete` + upperCase(HANDLER.hdrSqs),
81
- subscribeTo: topicOut
82
- }
83
- )
84
- }
85
- }
86
- }
87
-
88
- if (flowSteps.includes("In") && flowSteps.includes("Out")) {
89
- if (flowSteps.length > 2) {
90
- for (let i = 2; i < flowSteps.length; i++) {
91
- generatedSnsTopicInForFlowSchema.push(
78
+ defaultDsqQueueDataList.push(
92
79
  {
93
- queueName: upperCase(flowSteps[i])
80
+ queueName: upperCase(topicIn) + "CompleteHdrSqs"
94
81
  }
95
82
  )
96
83
  }
97
84
  }
98
85
  }
99
86
 
87
+
100
88
  for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
101
89
  resultsForCreateDefaultSnsInSqs.push({
102
90
  templatePath: snsTemplatePath,
@@ -1,13 +1,3 @@
1
- <% if (subscribeTo) { %>
2
- ##===== SNS Subscription
3
- ##===== [Topic In]
4
- SubscriptionToOut<%- subscribeTo %>:
5
- Type: AWS::SNS::Subscription
6
- Properties:
7
- TopicArn: !Ref Out<%- subscribeTo %>
8
- Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>"
9
- Protocol: "sqs"
10
- <% } %>
11
1
  #------- queue ---------
12
2
  <%- queueName %>:
13
3
  Type: "AWS::SQS::Queue"
@@ -55,7 +55,7 @@ function createDataForSnsOut(_izContext, flowSchema, srcPath) {
55
55
  if (flowSchema.outputTopic) {
56
56
  generatedSnsTopicOutForFlowSchema.push(
57
57
  {
58
- queueName: upperCase(topicOut) + "Complete"
58
+ queueName: upperCase(topicOut)
59
59
  }
60
60
  )
61
61
  }
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
  const path = require('path');
20
20
 
21
21
  const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
- const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
22
+ const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils')
23
23
  const {
24
24
  SOURCE_PATH,
25
25
  defaultIamRolePerAction,
@@ -32,9 +32,10 @@ const {
32
32
  FUNCTION_NAME,
33
33
  shortNameHandler,
34
34
  externalResourceYaml,
35
- SOURCE_GENERATE_IAM_ROLE
36
- } = require('../../../../../../MainLibs/src/Consts');
37
- const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
35
+ SOURCE_GENERATE_IAM_ROLE,
36
+ SQS_RESOURCE
37
+ } = require('../../../../../MainLibs/src/Consts');
38
+ const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../GenerateCodeLibs/src/Consts');
38
39
 
39
40
  const templatePath = path.join(__dirname, "template.ejs");
40
41
  const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
@@ -48,22 +49,26 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
48
49
 
49
50
  function data(_izContext, flowSchema, srcPath) {
50
51
  let resultCreateSource = [];
51
- let flowSteps = Object.keys(flowSchema.flowSteps)
52
- let events = flowSchema.event
53
- for (const event of events) {
54
- if (event === "ownTopic") {
55
- if (flowSteps.includes("In") && flowSteps.includes("Out")) {
56
- if (flowSteps.length > 2) {
57
- for (let i = 2; i < flowSteps.length; i++) {
58
- let createSource = createSourceParams(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
59
- createSource && resultCreateSource.push(createSource);
60
- }
61
- }
62
- } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
63
- if (flowSteps.length > 1) {
64
- for (let i = 1; i < flowSteps.length; i++) {
65
- let createSource = createSourceParams(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
66
- createSource && resultCreateSource.push(createSource);
52
+ if (flowSchema.hasOwnProperty("flowSteps")) {
53
+ let flowSteps = Object.keys(flowSchema.flowSteps)
54
+ if (flowSteps.length && flowSteps.length > 0) {
55
+ let events = flowSchema.event
56
+ for (const event of events) {
57
+ if (event === "ownTopic") {
58
+ if (flowSteps.includes("In") && flowSteps.includes("Out")) {
59
+ if (flowSteps.length > 2) {
60
+ for (let i = 2; i < flowSteps.length; i++) {
61
+ let createSource = createSourceParams(_izContext, flowSteps[i], srcPath)
62
+ createSource && resultCreateSource.push(createSource);
63
+ }
64
+ }
65
+ } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
66
+ if (flowSteps.length > 1) {
67
+ for (let i = 1; i < flowSteps.length; i++) {
68
+ let createSource = createSourceParams(_izContext, flowSteps[i], srcPath)
69
+ createSource && resultCreateSource.push(createSource);
70
+ }
71
+ }
67
72
  }
68
73
  }
69
74
  }
@@ -72,8 +77,8 @@ function data(_izContext, flowSchema, srcPath) {
72
77
  return resultCreateSource
73
78
  }
74
79
 
75
- function createSourceParams(_izContext, flowTag, flowStep, srcPath) {
76
- let functionName = upperCase(flowTag);
80
+ function createSourceParams(_izContext, flowStep, srcPath) {
81
+ let functionName = upperCase(flowStep);
77
82
  let handlerType = upperCase(HANDLER.hdrSqs);
78
83
  let topicIn = upperCase(flowStep);
79
84
  let additionalResourcePermission = defaultIamRolePerAction();
@@ -87,14 +92,22 @@ function createSourceParams(_izContext, flowTag, flowStep, srcPath) {
87
92
  [
88
93
  resourceNames(RESOURCE_CLASSES.sns, topicIn + "_In")
89
94
  ]
95
+ ),
96
+ createIamRole(
97
+ {
98
+ [RESOURCE_CLASSES.sqs]: [SQS_RESOURCE.sendMessage, SQS_RESOURCE.receiveMessage, SQS_RESOURCE.deleteMessage, SQS_RESOURCE.getQueueAttributes, SQS_RESOURCE.deleteMessageBatch, SQS_RESOURCE.getQueueUrl]
99
+ },
100
+ [
101
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(flowStep) + upperCase(handlerType)),
102
+ resourceNames(RESOURCE_CLASSES.sqs, upperCase(flowStep) + upperCase(handlerType) + "DLQ")
103
+ ]
90
104
  )
91
105
  )
92
106
 
93
-
94
107
  return {
95
108
  templatePath: templatePath,
96
109
  templateData: {
97
- resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowTag) + upperCase(flowStep), "source/"),
110
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowStep), "source/"),
98
111
  functionName,
99
112
  handlerType,
100
113
  additionalResourcePermission,
@@ -0,0 +1,20 @@
1
+ <%_ const join = require('path').join; _%>
2
+ <%- firstLetterUpperCase(functionNameConfig) %>:
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
+ name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
+ events:
6
+ - sqs:
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
8
+ batchSize: 10
9
+ filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
+ - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
+ role: <%- roleName %>Role
13
+ #<#<%- functionName %><%- handlerType %>IamRole#>
14
+ #<#/<%- functionName %><%- handlerType %>IamRole#>
15
+ <%_ function firstLetterUpperCase(text){
16
+ return text.charAt(0).toUpperCase() + text.slice(1)
17
+ } _%>
18
+ <%_ function firstLetterLowerCase(str) {
19
+ return str.charAt(0).toLowerCase() + str.slice(1)
20
+ } _%>
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
  const path = require('path');
20
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")
21
+ const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../MainLibs/src/Consts');
22
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
23
23
  const templatePath = path.join(__dirname, "template.ejs")
24
24
 
25
25
  /**
@@ -33,22 +33,26 @@ const templatePath = path.join(__dirname, "template.ejs")
33
33
 
34
34
  function data(_izContext, flowSchema, srcPath) {
35
35
  let resultCreateParam = [];
36
- let flowSteps = Object.keys(flowSchema.flowSteps);
37
- let events = flowSchema.event;
38
- for (const event of events) {
39
- if (event === "ownTopic") {
40
- if (flowSteps.includes("In") && flowSteps.includes("Out")) {
41
- if (flowSteps.length > 2) {
42
- for (let i = 2; i < flowSteps.length; i++) {
43
- let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
44
- createSource && resultCreateParam.push(createSource)
45
- }
46
- }
47
- } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
48
- if (flowSteps.length > 1) {
49
- for (let i = 1; i < flowSteps.length; i++) {
50
- let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
51
- createSource && resultCreateParam.push(createSource)
36
+ if (flowSchema.hasOwnProperty("flowSteps")) {
37
+ let flowSteps = Object.keys(flowSchema.flowSteps);
38
+ if (flowSteps.length && flowSteps.length > 0) {
39
+ let events = flowSchema.event;
40
+ for (const event of events) {
41
+ if (event === "ownTopic") {
42
+ if (flowSteps.includes("In") && flowSteps.includes("Out")) {
43
+ if (flowSteps.length > 2) {
44
+ for (let i = 2; i < flowSteps.length; i++) {
45
+ let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
46
+ createSource && resultCreateParam.push(createSource)
47
+ }
48
+ }
49
+ } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
50
+ if (flowSteps.length > 1) {
51
+ for (let i = 1; i < flowSteps.length; i++) {
52
+ let createSource = createParamsForCreateSource(_izContext, upperCase(flowSchema.flowTag), upperCase(flowSteps[i]), srcPath);
53
+ createSource && resultCreateParam.push(createSource)
54
+ }
55
+ }
52
56
  }
53
57
  }
54
58
  }
@@ -70,8 +74,8 @@ function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
70
74
  queueName
71
75
  },
72
76
  setting: {
73
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowTag, "source/"),
74
- saveFileName: `${flowStep}_${handlerType}`,
77
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowStep), "source/"),
78
+ saveFileName: `${upperCase(flowStep)}_${handlerType}`,
75
79
  fileExtension: ".js",
76
80
  isAppend: false
77
81
  }
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
  const path = require('path');
20
- const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
20
+ const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils')
21
21
  const {
22
22
  SOURCE_PATH,
23
23
  defaultIamRolePerAction,
@@ -30,8 +30,9 @@ const {
30
30
  FUNCTION_NAME,
31
31
  shortNameHandler,
32
32
  externalResourceYaml,
33
- SOURCE_GENERATE_IAM_ROLE
34
- } = require('../../../../../../MainLibs/src/Consts');
33
+ SOURCE_GENERATE_IAM_ROLE,
34
+ HANDLER
35
+ } = require('../../../../../MainLibs/src/Consts');
35
36
  const templatePath = path.join(__dirname, "template.ejs");
36
37
 
37
38
 
@@ -46,22 +47,26 @@ const templatePath = path.join(__dirname, "template.ejs");
46
47
 
47
48
  function data(_izContext, flowSchema, srcPath) {
48
49
  let resultCreateSource = [];
49
- let flowSteps = Object.keys(flowSchema.flowSteps)
50
- let events = flowSchema.event
51
- for (const event of events) {
52
- if (event === "ownTopic") {
53
- if (flowSteps.includes("In") && flowSteps.includes("Out")) {
54
- if (flowSteps.length > 2) {
55
- for (let i = 2; i < flowSteps.length; i++) {
56
- let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
57
- createSource && resultCreateSource.push(createSource);
58
- }
59
- }
60
- } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
61
- if (flowSteps.length > 1) {
62
- for (let i = 1; i < flowSteps.length; i++) {
63
- let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
64
- createSource && resultCreateSource.push(createSource);
50
+ if (flowSchema.hasOwnProperty("flowSteps")) {
51
+ let flowSteps = Object.keys(flowSchema.flowSteps)
52
+ if (flowSteps.length && flowSteps.length > 0) {
53
+ let events = flowSchema.event
54
+ for (const event of events) {
55
+ if (event === "ownTopic") {
56
+ if (flowSteps.includes("In") && flowSteps.includes("Out")) {
57
+ if (flowSteps.length > 2) {
58
+ for (let i = 2; i < flowSteps.length; i++) {
59
+ let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
60
+ createSource && resultCreateSource.push(createSource);
61
+ }
62
+ }
63
+ } else if (flowSteps.includes("In") && !flowSchema.outputTopic) {
64
+ if (flowSteps.length > 1) {
65
+ for (let i = 1; i < flowSteps.length; i++) {
66
+ let createSource = createParamsForCreateSource(_izContext, flowSchema.flowTag, flowSteps[i], srcPath)
67
+ createSource && resultCreateSource.push(createSource);
68
+ }
69
+ }
65
70
  }
66
71
  }
67
72
  }
@@ -73,7 +78,7 @@ function data(_izContext, flowSchema, srcPath) {
73
78
  function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
74
79
  let functionName = upperCase(flowTag)
75
80
  let topicArn = `${upperCase(flowStep)}_In`
76
-
81
+ let handlerType = upperCase(HANDLER.hdrSqs)
77
82
  return {
78
83
  templatePath: templatePath,
79
84
  templateData: {
@@ -81,8 +86,8 @@ function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
81
86
  functionName
82
87
  },
83
88
  setting: {
84
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowTag, "source/"),
85
- saveFileName: `${upperCase(flowStep)}_Main`,
89
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowStep), "source/"),
90
+ saveFileName: `${upperCase(flowStep)}_${handlerType}`,
86
91
  fileExtension: ".js",
87
92
  isAppend: false
88
93
  }