@izara_project/izara-market-library-service-schemas 1.0.39 → 1.0.41

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 (66) hide show
  1. package/package.json +1 -1
  2. package/src/MainLibs/src/Consts.js +2 -2
  3. package/src/TemplateManager/src/libs/Consts.js +2 -1
  4. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +2 -2
  5. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +0 -1
  6. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/template.ejs +0 -1
  7. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/template.ejs +0 -1
  8. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/template.ejs +0 -1
  9. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
  10. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +1 -1
  11. package/src/reStructure/TemplateData/flowSchema/externalTopic/functionYaml/template.ejs +0 -1
  12. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +1 -14
  13. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +82 -0
  14. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +9 -8
  15. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +1 -2
  16. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +9 -4
  17. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +11 -10
  18. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +90 -49
  19. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +0 -1
  20. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -1
  21. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/data.js +1 -1
  22. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/template.ejs +0 -1
  23. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/data.js +2 -2
  24. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/mainFunction/data.js +5 -4
  25. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +1 -1
  26. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +2 -1
  27. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +21 -16
  28. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/data.js +2 -1
  29. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/template.ejs +0 -1
  30. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +28 -23
  31. package/src/reStructure/TemplateData/flowSchema/register/dynamoDB/register.js +1 -1
  32. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/data.js +2 -1
  33. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/template.ejs +4 -1
  34. package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +23 -21
  35. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/functionYaml/data.js +13 -7
  36. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/functionYaml/template.ejs +1 -2
  37. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/handler/data.js +6 -6
  38. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/mainFunction/data.js +5 -5
  39. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +4 -4
  40. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +1 -0
  41. package/src/reStructure/TemplateData/perActionComplete/create/yaml/template.ejs +0 -1
  42. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/template.ejs +0 -1
  43. package/src/reStructure/TemplateData/perActionComplete/get/yaml/template.ejs +0 -1
  44. package/src/reStructure/TemplateData/perActionComplete/update/yaml/template.ejs +0 -1
  45. package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +1 -0
  46. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +14 -14
  47. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +27 -17
  48. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +2 -1
  49. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +3 -1
  50. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +2 -0
  51. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +4 -0
  52. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/template.ejs +0 -1
  53. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +5 -1
  54. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +5 -2
  55. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +5 -1
  56. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +5 -1
  57. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/template.ejs +0 -1
  58. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +5 -2
  59. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/template.ejs +0 -1
  60. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +5 -1
  61. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/template.ejs +0 -1
  62. package/src/reStructure/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +1 -2
  63. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +4 -3
  64. package/src/reStructure/libs/ValidateAddOnDataStructure.js +0 -1
  65. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/handler/template.ejs +0 -0
  66. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/mainFunction/template.ejs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -520,8 +520,8 @@ function createDynamoDbComponentByLinks(link, relationshipTag) {
520
520
  let identifiersConcatFrom = `${link.from.objType.serviceTag}_${link.from.objType.objectType}__identifiersConcat`
521
521
  let identifiersConcatTo = `${link.to.objType.serviceTag}_${link.to.objType.objectType}__identifiersConcat`
522
522
 
523
- let resourceNameFrom = `${upperCase(link.from.objType.objectType) + upperCase(link.to.objType.objectType)}Relationship`
524
- let resourceNameTo = `${upperCase(link.to.objType.objectType) + upperCase(link.from.objType.objectType)}Relationship`
523
+ let resourceNameFrom = `${upperCase(link.from.objType.objectType) + upperCase(link.to.objType.objectType)}${upperCase(relationshipTag)}`
524
+ let resourceNameTo = `${upperCase(link.to.objType.objectType) + upperCase(link.from.objType.objectType)}${upperCase(relationshipTag)}`
525
525
  return {
526
526
  tableNameFrom,
527
527
  tableNameTo,
@@ -370,7 +370,8 @@ const SOURCE_GENERATE_IAM_ROLE = {
370
370
 
371
371
  const ADD_ON_DATA_STRUCTURE_TYPE = {
372
372
  versionedData: "versionedData",
373
- attributeTree: "attributeTree"
373
+ attributeTree: "attributeTree",
374
+ propertyValue: "propertyValue"
374
375
  };
375
376
 
376
377
  const ATTRIBUTE_TAG = {
@@ -76,8 +76,8 @@ const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas
76
76
  const externalLambdaIamRoleGetPresignUrl = await externalLambdaIamRoleUploadS3(_izContext);
77
77
  externalLambdaIamRoleGetPresignUrl && externalLambdaIamRoleArray.push(externalLambdaIamRoleGetPresignUrl);
78
78
  } else if (event.includes("extTopic")) {
79
- const externalSnsPublish = await externalRoleSnsPublish(_izContext, localFlowSchema);
80
- externalSnsPublish && externalLambdaIamRoleArray.push(externalSnsPublish);
79
+ // const externalSnsPublish = await externalRoleSnsPublish(_izContext, localFlowSchema);
80
+ // externalSnsPublish && externalLambdaIamRoleArray.push(externalSnsPublish);
81
81
  }
82
82
  }
83
83
  }
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -71,7 +71,7 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
71
71
  functionName,
72
72
  resourceLocation: SOURCE_PATH.resourceLocationWebSocketMain,
73
73
  additionalResourcePermission,
74
- roleName: "WebsocketConnect"
74
+ roleName: "WebsocketMain"
75
75
 
76
76
  },
77
77
  setting: {
@@ -9,7 +9,7 @@
9
9
  route: $disconnect
10
10
  - websocket:
11
11
  route: $default
12
- role: WebsocketConnectRole
12
+ role: <%- roleName %>Role
13
13
  #<#<WebSocketConnectIamRole#>
14
14
  #<#/<WebSocketConnectIamRole#>
15
15
 
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -63,25 +63,12 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
63
63
  if (flowSteps.includes("In")) {
64
64
  generatedSnsTopicInForFlowSchema.push(
65
65
  {
66
- queueName: "Process" + upperCase(topicIn) + upperCase(HANDLER.hdrSqs)
66
+ queueName: upperCase(topicIn) + "Complete" + upperCase(HANDLER.hdrSqs)
67
67
 
68
68
  }
69
69
  )
70
70
  }
71
71
 
72
-
73
-
74
- if (flowSchema.outputTopic) {
75
- if (flowSteps.includes("Out")) {
76
- let topicOut = `${upperCase(flowSchema.flowTag)}`;
77
- defaultDsqQueueDataList.push({
78
- queueName: `WebSocketComplete` + upperCase(HANDLER.hdrSqs),
79
- subscribeTo: topicOut
80
- }
81
- )
82
- }
83
- }
84
-
85
72
  for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
86
73
  resultsForCreateDefaultSnsInSqs.push({
87
74
  templatePath: snsTemplatePath,
@@ -0,0 +1,82 @@
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 templatePath = path.join(__dirname, '../../../resourceYaml/sns-out/template.ejs');
35
+
36
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js');
37
+
38
+ /**
39
+ * create data for dynamoDbYaml tempalte from objectSchema
40
+ * return array of dynamoDb data
41
+ * because one objectSchema can create multiple dynamoDb table
42
+ *
43
+ * @param {Object} _izContext
44
+ * @param {String} saveFilePath
45
+ * @returns {Object[]} - data of multiple dynamoDb template
46
+ */
47
+
48
+ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
49
+ let resultsForCreateDefaultSnsInSqs = [];
50
+ let flowSteps = Object.keys(flowSchema.flowSteps);
51
+ const setting = {
52
+ initialData: "Resources:\n",
53
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
54
+ saveFileName: SAVE_FILE_NAME.snsOutYaml,
55
+ fileExtension: ".yml",
56
+ isAppend: true
57
+ }
58
+
59
+ let topicOut = `${upperCase(flowSchema.flowTag)}`;
60
+
61
+ const generatedSnsTopicInForFlowSchema = [];
62
+ if (flowSteps.includes("Out")) {
63
+ generatedSnsTopicInForFlowSchema.push(
64
+ {
65
+ queueName: upperCase(topicOut) + "Complete"
66
+
67
+ }
68
+ )
69
+ }
70
+
71
+ for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
72
+ resultsForCreateDefaultSnsInSqs.push({
73
+ templatePath: templatePath,
74
+ templateData: defaultSnsInSqsData,
75
+ setting: setting
76
+ })
77
+ }
78
+
79
+ return resultsForCreateDefaultSnsInSqs;
80
+ }
81
+
82
+ module.exports = createDataForDefaultSnsInSqs;
@@ -38,7 +38,6 @@ const {
38
38
  const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
39
39
 
40
40
  const templatePath = path.join(__dirname, "template.ejs");
41
- const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
42
41
  /**
43
42
  * receive objectSchema
44
43
  * create data for WebScoket handler template
@@ -48,17 +47,19 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
48
47
  */
49
48
 
50
49
  function data(_izContext, flowSchema, srcPath) {
51
- return [createSourceParams(_izContext, flowSchema, srcPath)]
50
+ let flowSteps = Object.keys(flowSchema.flowSteps)
51
+ if (flowSteps.includes("Out") && flowSchema.outputTopic === false) {
52
+ return []
53
+ } else {
54
+ return [createSourceParams(_izContext, flowSchema, srcPath)]
55
+ }
52
56
  }
53
57
 
54
58
  function createSourceParams(_izContext, flowSchema, srcPath) {
55
- let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpointComplete)
59
+ let functionName = upperCase(flowSchema.flowTag) + "Complete"
56
60
  let handlerType = upperCase(HANDLER.hdrSqs)
57
61
  let additionalResourcePermission = defaultIamRolePerAction();
58
- let flowSteps = Object.keys(flowSchema.flowSteps)
59
- let flowStepsOut = flowSteps[1];
60
- let splitFlowStepsOut = flowStepsOut.split("_");
61
- let topicOut = `${splitFlowStepsOut[3]}_${splitFlowStepsOut[4]}`
62
+ let topicOut = flowSchema.flowTag + "Complete_Out"
62
63
  let queueName = functionName + handlerType
63
64
  additionalResourcePermission.push(
64
65
  createIamRole(
@@ -83,7 +84,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
83
84
  return {
84
85
  templatePath: templatePath,
85
86
  templateData: {
86
- resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaOwnTopic, flowSchema.flowTag, "source/"),
87
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
87
88
  functionName,
88
89
  handlerType,
89
90
  additionalResourcePermission,
@@ -3,12 +3,11 @@
3
3
  handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
- - sqs:
6
+ - sqs:
7
7
  arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -32,11 +32,16 @@ const templatePath = path.join(__dirname, "template.ejs")
32
32
 
33
33
 
34
34
  function data(_izContext, flowSchema, srcPath) {
35
- return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
35
+ let flowSteps = Object.keys(flowSchema.flowSteps)
36
+ if (flowSteps.includes("Out") && flowSchema.outputTopic === false) {
37
+ return []
38
+ } else {
39
+ return [createSourceParams(_izContext, flowSchema, srcPath)]
40
+ }
36
41
  }
37
42
 
38
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
- let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpointComplete)
43
+ function createSourceParams(_izContext, flowSchema, srcPath) {
44
+ let functionName = upperCase(flowSchema.flowTag) + "Complete"
40
45
  let handlerType = upperCase(HANDLER.hdrSqs)
41
46
  let queueName = upperCase(functionName) + upperCase(handlerType)
42
47
  return {
@@ -47,7 +52,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
47
52
  queueName
48
53
  },
49
54
  setting: {
50
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
55
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
51
56
  saveFileName: `${functionName}_${handlerType}`,
52
57
  fileExtension: ".js",
53
58
  isAppend: false
@@ -18,7 +18,7 @@ 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 { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../MainLibs/src/Consts');
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");
24
24
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
@@ -34,24 +34,25 @@ const getObjectSchema = require('@izara_project/izara-core-library-service-schem
34
34
 
35
35
 
36
36
  function data(_izContext, flowSchema, srcPath) {
37
- return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
37
+ let flowSteps = Object.keys(flowSchema.flowSteps)
38
+ if (flowSteps.includes("Out") && flowSchema.outputTopic === false) {
39
+ return []
40
+ } else {
41
+ return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
42
+ }
38
43
  }
39
44
 
40
45
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
41
- let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpointComplete)
42
- // let topicArn = Object.keys(flowSchema.flowSteps)[1]
43
- let flowSteps = Object.keys(flowSchema.flowSteps)
44
- let flowStepsOut = flowSteps[1];
45
- let splitFlowStepsOut = flowStepsOut.split("_");
46
- let topicOut = `${splitFlowStepsOut[3]}+_${splitFlowStepsOut[4]}`
46
+ let functionName = upperCase(flowSchema.flowTag) + "Complete" + upperCase(HANDLER.hdrSqs)
47
+ let topicOut = flowSchema.flowTag + "Complete_Out"
47
48
  return {
48
49
  templatePath: templatePath,
49
50
  templateData: {
51
+ functionName,
50
52
  topicOut,
51
-
52
53
  },
53
54
  setting: {
54
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
55
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
55
56
  saveFileName: `${functionName}_Main`,
56
57
  fileExtension: ".js",
57
58
  isAppend: false
@@ -1,50 +1,91 @@
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
+ const flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
78
+ flowTag: requestParams.action,
79
+ serviceTag: process.env.iz_serviceTag
80
+ })
81
+
82
+
83
+ return {
84
+ //(<endpointReturn>)
85
+ //(</endpointReturn>)
86
+ }
87
+ } catch (err) {
88
+ _izContext.logger.error('error WebSocketInvoke: ', err)
89
+ throw (err)
90
+ }
91
+ }
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -91,7 +91,7 @@ module.exports.<%- functionName %> = async (
91
91
  callingFlowSharedLib.addParentCallingFlowConfig(
92
92
  callingFlowConfig,
93
93
  callingFlowSharedLib.createCallingFlowConfig(
94
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.flowSchemaOwnTopicComplete), {}
94
+ await lambdaSharedLib.lambdaFunctionName(_izContext, "WebSocketCompleteHdrSqs"), {}
95
95
  )
96
96
  )
97
97
  )
@@ -94,7 +94,7 @@ function createSourceParams(_izContext, flowTag, flowStep, srcPath) {
94
94
  return {
95
95
  templatePath: templatePath,
96
96
  templateData: {
97
- resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowTag) + upperCase(flowStep), "source/"),
97
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowStep), "source/"),
98
98
  functionName,
99
99
  handlerType,
100
100
  additionalResourcePermission,
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -70,8 +70,8 @@ function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
70
70
  queueName
71
71
  },
72
72
  setting: {
73
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowTag, "source/"),
74
- saveFileName: `${flowStep}_${handlerType}`,
73
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowStep), "source/"),
74
+ saveFileName: `${upperCase(flowStep)}_${handlerType}`,
75
75
  fileExtension: ".js",
76
76
  isAppend: false
77
77
  }
@@ -30,7 +30,8 @@ const {
30
30
  FUNCTION_NAME,
31
31
  shortNameHandler,
32
32
  externalResourceYaml,
33
- SOURCE_GENERATE_IAM_ROLE
33
+ SOURCE_GENERATE_IAM_ROLE,
34
+ HANDLER
34
35
  } = require('../../../../../../MainLibs/src/Consts');
35
36
  const templatePath = path.join(__dirname, "template.ejs");
36
37
 
@@ -73,7 +74,7 @@ function data(_izContext, flowSchema, srcPath) {
73
74
  function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
74
75
  let functionName = upperCase(flowTag)
75
76
  let topicArn = `${upperCase(flowStep)}_In`
76
-
77
+ let handlerType = upperCase(HANDLER.hdrSqs)
77
78
  return {
78
79
  templatePath: templatePath,
79
80
  templateData: {
@@ -81,8 +82,8 @@ function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
81
82
  functionName
82
83
  },
83
84
  setting: {
84
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowTag, "source/"),
85
- saveFileName: `${upperCase(flowStep)}_Main`,
85
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowStep), "source/"),
86
+ saveFileName: `${upperCase(flowStep)}_${handlerType}`,
86
87
  fileExtension: ".js",
87
88
  isAppend: false
88
89
  }
@@ -75,7 +75,7 @@ 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)}`;
78
+ let topicOut = `${upperCase(flowSchema.flowTag)}Complete`;
79
79
  defaultDsqQueueDataList.push({
80
80
  queueName: `WebSocketComplete` + upperCase(HANDLER.hdrSqs),
81
81
  subscribeTo: topicOut
@@ -50,11 +50,12 @@ function createDataForSnsOut(_izContext, flowSchema, srcPath) {
50
50
  let generatedSnsTopicOutForFlowSchema = []
51
51
  let flowSteps = Object.keys(flowSchema.flowSteps);
52
52
  let topicOut = `${upperCase(flowSchema.flowTag)}`
53
+
53
54
  if (flowSteps.includes("Out")) {
54
55
  if (flowSchema.outputTopic) {
55
56
  generatedSnsTopicOutForFlowSchema.push(
56
57
  {
57
- queueName: upperCase(topicOut)
58
+ queueName: upperCase(topicOut) + "Complete"
58
59
  }
59
60
  )
60
61
  }