@izara_project/izara-market-library-service-schemas 1.0.35 → 1.0.36

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 (111) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +2 -1
  3. package/src/MainLibs/src/Consts.js +8 -8
  4. package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
  5. package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/generateTemplateData.js +35 -20
  6. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/data.js +84 -0
  7. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/tempReferenceRelationshipSchema.ejs +9 -0
  8. package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/data.js +1 -1
  9. package/src/reStructure/SchemaConfig.js +1 -4
  10. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +701 -0
  11. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +34 -162
  12. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +2 -0
  13. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -4
  14. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -0
  15. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +38 -12
  16. package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +5 -2
  17. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +22 -14
  18. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +4 -1
  19. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +68 -33
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +1 -1
  21. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +1 -1
  22. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +1 -1
  23. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +12 -4
  24. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +13 -8
  25. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +16 -13
  26. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +9 -9
  27. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +7 -9
  29. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js +82 -0
  30. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +1 -1
  31. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +34 -1
  32. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +10 -33
  33. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +5 -5
  34. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +6 -6
  35. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +26 -4
  36. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +5 -5
  37. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +7 -8
  38. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +118 -16
  39. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +83 -44
  40. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +4 -5
  41. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -7
  42. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +2 -3
  43. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +2 -4
  44. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +31 -3
  45. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +4 -4
  46. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +7 -8
  47. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +13 -13
  48. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +4 -4
  49. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +44 -69
  50. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +4 -6
  51. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +2 -2
  52. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -9
  53. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +40 -87
  54. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +5 -4
  55. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +2 -10
  56. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +17 -3
  57. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +2 -2
  58. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +6 -2
  59. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +49 -84
  60. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +55 -10
  61. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -1
  62. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -2
  63. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
  64. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +20 -7
  65. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +24 -33
  66. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +20 -5
  67. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +1 -3
  68. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +2 -2
  69. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +5 -5
  70. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data.js +5 -3
  71. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +7 -5
  72. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +6 -3
  73. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -2
  74. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +2 -2
  75. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +3 -3
  76. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +8 -3
  77. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +17 -11
  78. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +14 -8
  79. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +4 -1
  80. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +50 -42
  81. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +3 -2
  82. package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +3 -0
  83. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +9 -8
  84. package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +5 -1
  85. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +2 -1
  86. package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -0
  87. package/src/reStructure/TemplateData/{propertyNodeSchema → propertyValueSchema}/generateTemplateData.js +4 -4
  88. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +131 -0
  89. package/src/reStructure/TemplateData/{propertyNodeSchema/relationshipPropertyNodeSchema → propertyValueSchema/relationshipPropertyValueSchema}/data.js +32 -55
  90. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/tempRelationship.ejs +13 -0
  91. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/templateRelationshipPropertyValueSchema.ejs +7 -0
  92. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +2 -1
  93. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +2 -1
  94. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +2 -1
  95. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +5 -5
  96. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +5 -4
  97. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -1
  98. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +4 -4
  99. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +4 -3
  100. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +2 -1
  101. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +2 -1
  102. package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -3
  103. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +61 -0
  104. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +13 -4
  105. package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +0 -151
  106. package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +0 -7
  107. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/attributeLinkTemplate.ejs +0 -0
  108. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/data.js +0 -0
  109. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/request.json +0 -0
  110. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/template.ejs +0 -0
  111. /package/src/reStructure/TemplateData/{propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs → propertyValueSchema/objectPropertyValueSchema/templateObjectPropertyValueSchema.ejs} +0 -0
@@ -1,70 +1,45 @@
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
-
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');
24
12
  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.<%- externalTopicOutMain%>Main = async (
54
- _izContext,
55
- requestParams,
56
- callingFlowConfig = {},
57
- //(<additionalParams>)
58
- //(</additionalParams>)
59
- ) => {
60
-
61
- try {
62
-
63
- //(<additionalParams>)
64
- //(</additionalParams>)
65
-
66
- } catch (err) {
67
- _izContext.logger.error('error WebSocketInvoke: ', err)
68
- throw (err)
69
- }
70
- }
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 externalRequestSns
19
+ = require('@izara_project/izara-core-library-external-request').sns; const utils
20
+ =
21
+ require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
22
+ const { NoRetryError, consts } =
23
+ require('@izara_project/izara-core-library-core') const { v4: uuidv4 } =
24
+ require('uuid') const { TOPIC_NAME_GENERATE_CODE } =
25
+ require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
26
+ const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
27
+ /** * * * description of function. * @param {Object} _izContext * @param
28
+ {CorrelationIds} _izContext.correlationIds - property of _izContext * @param
29
+ {Logger} _izContext.logger - property of _izContext * @param {Object}
30
+ requestParams - request params * @param {Object} requestParams.identifiers -
31
+ identifiers for get data * @param {Object} requestParams.additionalRequest -
32
+ additionalRequest * * * @returns {object} description of return value */
33
+ module.exports.<%- externalTopicOutMain %>Main = async ( _izContext,
34
+ requestParams, callingFlowConfig = {}, //(<additionalParams
35
+ >) //(</additionalParams
36
+ >) ) => { try { let connectionId =
37
+ _izContext.correlationIds.get(coreConsts.CONNECTION_ID); let correlationId =
38
+ _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID); await
39
+ postToConnection( { message: requestParams }, connectionId ) await
40
+ dynamodbSharedLib.deleteItem(_izContext, await
41
+ dynamodbSharedLib.tableName(_izContext, "WebSocketTask"), { taskKey:
42
+ correlationId, connectionId: connectionId } ) //(<additionalParams
43
+ >) //(</additionalParams
44
+ >) } catch (err) { _izContext.logger.error('error WebSocketInvoke: ', err) throw
45
+ (err) } }
@@ -51,12 +51,9 @@ function data(_izContext, flowSchema, srcPath) {
51
51
  }
52
52
 
53
53
  function createSourceParams(_izContext, flowSchema, srcPath) {
54
- // let functionName = upperCase(flowSchema.flowTag);
54
+ let functionName = upperCase(flowSchema.flowTag);
55
55
  let handlerType = upperCase("hdrWbs");
56
- // let externalTopicName = FUNCTION_NAME.flowSchemaExternalTopic;
57
- let functionName = FUNCTION_NAME.flowSchemaExternalTopic;
58
- let externalTopicShortName = 'ExtTopic';
59
- let functionConfig = externalTopicShortName + upperCase(shortNameHandler(handlerType));
56
+ let functionConfig = functionName + "ExternalTopicIn" + upperCase(shortNameHandler(handlerType));
60
57
  let additionalResourcePermission = defaultIamRolePerAction();
61
58
  let route = flowSchema.flowTag;
62
59
 
@@ -84,10 +81,11 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
84
81
  [
85
82
  resourceNames(RESOURCE_CLASSES.webSocket)
86
83
  ]
87
- )
84
+ ),
88
85
  )
89
86
 
90
87
 
88
+
91
89
  return {
92
90
  templatePath: templatePath,
93
91
  templateData: {
@@ -8,8 +8,8 @@
8
8
  # authorizer: ${self:custom.iz_authorizerAppLevel}
9
9
  # identifierResource: 'route.request.header.Auth'
10
10
  role: <%- roleName %>Role
11
- #<#<%- functionName %><%- handlerType %>IamRole#>
12
- #<#/<%- functionName %><%- handlerType %>IamRole#>
11
+ #<#<%- functionName %><%- handlerType %>IamRole#>
12
+ #<#/<%- functionName %><%- handlerType %>IamRole#>
13
13
  <%_ function firstLetterUpperCase(text){
14
14
  return text.charAt(0).toUpperCase() + text.slice(1)
15
15
  } _%>
@@ -36,25 +36,18 @@ function data(_izContext, flowSchema, srcPath) {
36
36
  }
37
37
 
38
38
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
- // let functionName = upperCase(FUNCTION_NAME.createObjectS3)
40
- let functionName = FUNCTION_NAME.flowSchemaExternalTopic
39
+ let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicIn"
41
40
  let handlerType = "HdrWbs"
42
- let hook = false;
43
- let hookFunctionName;
44
- let isAsync = false;
45
41
  const flowTag = flowSchema.flowTag
46
42
  return {
47
43
  templatePath: templatePath,
48
44
  templateData: {
49
- hook: hook,
50
- hookFunctionName: hookFunctionName,
51
- isAsync,
52
45
  functionName: functionName,
53
46
  fileName: upperCase(functionName),
54
47
  flowTag,
55
48
  },
56
49
  setting: {
57
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag, 'source/'),
50
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
58
51
  saveFileName: `${upperCase(functionName)}_${handlerType}`,
59
52
  fileExtension: ".js",
60
53
  isAppend: false
@@ -1,87 +1,40 @@
1
- /*
2
- Copyright (C) 2021 Sven Mason <http://izara.io>
3
-
4
- This program is free software: you can redistribute it and/or modify
5
- it under the terms of the GNU Affero General Public License as
6
- published by the Free Software Foundation, either version 3 of the
7
- License, or (at your option) any later version.
8
-
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU Affero General Public License for more details.
13
-
14
- You should have received a copy of the GNU Affero General Public License
15
- along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
-
18
- 'use strict';
19
-
20
- const { middlewareHandler, consts } = require("@izara_project/izara-middleware");
21
- // const AWS = require('aws-sdk');
22
- // const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
23
- const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
24
- const callingFlowSharedLib = require('@izara_project/izara-core-calling-flow');
25
- const hash = require('object-hash');
26
- // const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
27
- const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts');
28
- const { postToConnection } = require("../../libs/source/ImportDataLib");
29
- const { <%- functionName%>Main } = require("./<%- fileName%>_Main");
30
-
31
- module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
32
-
33
- event._izContext.logger.debug('Event:', event);
34
-
35
- try {
36
-
37
- if (event.requestContext) {
38
- const route = event.requestContext.routeKey;
39
- const connectionId = event.requestContext.connectionId;
40
- let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
41
-
42
- switch (route) {
43
- case '<%- flowTag%>':
44
- console.log("event in route <%- flowTag%>", event);
45
- let eventParams = JSON.parse(event.body)
46
-
47
- await dynamodbSharedLib.putItem(
48
- event._izContext,
49
- await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
50
- {
51
- taskKey: correlationId,
52
- connectionId: connectionId,
53
- originTimestamp: new Date.now()
54
- }
55
- )
56
-
57
- let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
58
-
59
- await <%- functionName%>Main(
60
- event._izContext,
61
- eventParams,
62
- callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
63
- //(<additionalParams>)
64
- //(</additionalParams>)
65
- )
66
- break
67
- }
68
- } else {
69
- const connId = event.connId;
70
- // await postMessage({ message: event.message }, connId);
71
- await postToConnection({ message: event.message }, connId);
72
- }
73
-
74
- return (izara.response.webSocketSuccess());
75
-
76
- } catch (err) {
77
- const connId = event.requestContext.connectionId
78
- event._izContext.logger.error('Error, WebSocket: ', err);
79
- // await sendErrorMessage({ message: err.message }, connId);
80
- await postToConnection({ message: err.message }, connId);
81
- return (izara.response.failure(err));
82
- }
83
- });
84
- <%_ const join = require('path').join _%>
85
- <%_ function upperCase (text) {
86
- return text.charAt(0).toUpperCase() + text.slice(1)
87
- } _%>
1
+ /* Copyright (C) 2021 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 strict';
10
+ const { middlewareHandler, consts } =
11
+ require("@izara_project/izara-middleware"); // const AWS = require('aws-sdk');
12
+ // const api = new AWS.ApiGatewayManagementApi({ endpoint:
13
+ process.env.iz_webSocketEndpoint }); const dynamodbSharedLib =
14
+ require('@izara_project/izara-core-library-dynamodb'); const
15
+ callingFlowSharedLib =
16
+ require('@izara_project/izara-core-library-calling-flow'); const hash =
17
+ require('object-hash'); // const coreConsts =
18
+ require("@izara_project/izara-core-library-core/src/Consts"); const {
19
+ postToConnection } = require("../../../libs/source/GenerateCodeLibs"); const {
20
+ <%- functionName%>Main } = require("./<%- fileName%>_Main"); module.exports.main
21
+ = middlewareHandler.wrap(async (event, context, callback) => {
22
+ event._izContext.logger.debug('Event:', event); try { if (event.requestContext)
23
+ { const route = event.requestContext.routeKey; const connectionId =
24
+ event.requestContext.connectionId; let correlationId =
25
+ event._izContext.correlationIds.get(consts.X_CORRELATION_ID) switch (route) {
26
+ case '<%- flowTag%>': console.log("event in route <%- flowTag%>", event); let
27
+ eventParams = JSON.parse(event.body) await dynamodbSharedLib.putItem(
28
+ event._izContext, await dynamodbSharedLib.tableName(event._izContext,
29
+ "WebSocketTask"), { taskKey: correlationId, connectionId: connectionId,
30
+ originTimestamp: Date.now() } ) let callingFlow = eventParams?.callingFlow ?
31
+ eventParams.callingFlow : {}; await <%- functionName%>Main( event._izContext,
32
+ eventParams, callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
33
+ //(<additionalParams>) //(</additionalParams>) ) break } } else { const connId =
34
+ event.connId; // await postMessage({ message: event.message }, connId); await
35
+ postToConnection({ message: event.message }, connId); } } catch (err) { const
36
+ connId = event.requestContext.connectionId event._izContext.logger.error('Error,
37
+ WebSocket: ', err); // await sendErrorMessage({ message: err.message }, connId);
38
+ await postToConnection({ message: err.message }, connId); } }); <%_ const join =
39
+ require('path').join _%> <%_ function upperCase (text) { return
40
+ text.charAt(0).toUpperCase() + text.slice(1) } _%>
@@ -40,7 +40,7 @@ function data(_izContext, flowSchema, srcPath) {
40
40
  }
41
41
 
42
42
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
43
- const functionName = upperCase(FUNCTION_NAME.flowSchemaExternalTopic)
43
+ let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicIn"
44
44
  const splitKey = Object.keys(flowSchema.flowSteps)[0].split('_')
45
45
  // stockLocation_Test_flowStep_TopicName_In
46
46
  // let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
@@ -49,14 +49,15 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
49
49
  templatePath: templatePath,
50
50
  templateData: {
51
51
  serviceTag: splitKey[0],
52
- topicName: splitKey[3] + '_' + splitKey[4],
53
- externalTopicMain: FUNCTION_NAME.flowSchemaExternalTopic + 'Main',
52
+ topicName: splitKey[2] + '_' + splitKey[3],
53
+ externalTopicMain: functionName + 'Main',
54
54
  storedCacheTemplate,
55
55
  statusFieldTemplate,
56
56
  statusType: flowSchema.statusType,
57
+ flowTag: flowSchema.flowTag,
57
58
  },
58
59
  setting: {
59
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag, 'source/'),
60
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
60
61
  saveFileName: `${functionName}_Main`,
61
62
  fileExtension: ".js",
62
63
  isAppend: false
@@ -53,7 +53,7 @@ const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_proj
53
53
  * @returns {object} description of return value
54
54
  */
55
55
 
56
- module.exports.<%- externalTopicMain%> = async (
56
+ module.exports.<%- externalTopicMain %> = async (
57
57
  _izContext,
58
58
  requestParams,
59
59
  callingFlowConfig = {},
@@ -62,16 +62,8 @@ module.exports.<%- externalTopicMain%> = async (
62
62
  ) => {
63
63
 
64
64
  try {
65
-
66
- <% if (statusType === "statusField") { %>
67
- <%- include(statusFieldTemplate) %>
68
- <% } else if (statusType === "storedCache") { %>
69
- <%- include(storedCacheTemplate) %>
70
-
71
- <% } %>
72
-
73
65
  let sendMessageToCreateEndpoint = {
74
- Message: JSON.stringify(messageObject),
66
+ Message: JSON.stringify(requestParams),
75
67
  TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, '<%- topicName %>', '<%- serviceTag%>')
76
68
  }
77
69
  _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
@@ -32,7 +32,8 @@ const {
32
32
  FUNCTION_NAME,
33
33
  shortNameHandler,
34
34
  externalResourceYaml,
35
- SOURCE_GENERATE_IAM_ROLE
35
+ SOURCE_GENERATE_IAM_ROLE,
36
+ SQS_RESOURCE
36
37
  } = require('../../../../../../MainLibs/src/Consts');
37
38
  const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
38
39
 
@@ -55,13 +56,25 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
55
56
  let handlerType = upperCase(HANDLER.hdrSqs)
56
57
  let additionalResourcePermission = defaultIamRolePerAction();
57
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 queueName = functionName + handlerType
58
63
  additionalResourcePermission.push(
59
64
  createIamRole(
60
65
  {
61
66
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
62
67
  },
63
68
  [
64
- resourceNames(RESOURCE_CLASSES.sns, flowSteps[1])
69
+ resourceNames(RESOURCE_CLASSES.sns, topicOut)
70
+ ]
71
+ ),
72
+ createIamRole(
73
+ {
74
+ [RESOURCE_CLASSES.sqs]: [SQS_RESOURCE.sendMessage, SQS_RESOURCE.receiveMessage, SQS_RESOURCE.deleteMessage, SQS_RESOURCE.getQueueAttributes]
75
+ },
76
+ [
77
+ resourceNames(RESOURCE_CLASSES.sqs, queueName)
65
78
  ]
66
79
  )
67
80
  )
@@ -75,7 +88,8 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
75
88
  handlerType,
76
89
  additionalResourcePermission,
77
90
  functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
78
- roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic
91
+ roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic,
92
+ queueName: queueName
79
93
  },
80
94
  setting: {
81
95
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -3,8 +3,8 @@
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:
7
- arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %>
6
+ - sqs:
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
@@ -39,11 +39,15 @@ function data(_izContext, flowSchema, srcPath) {
39
39
 
40
40
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
41
41
  let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpointComplete)
42
- let topicArn = Object.keys(flowSchema.flowSteps)[1]
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]}`
43
47
  return {
44
48
  templatePath: templatePath,
45
49
  templateData: {
46
- topicArn,
50
+ topicOut,
47
51
 
48
52
  },
49
53
  setting: {
@@ -1,85 +1,50 @@
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
-
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');
24
12
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
- const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
- const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
- const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
-
30
- const externalRequest = require('@izara_project/izara-core-library-external-request');
31
- const sns = externalRequest.sns
32
- const { postToConnection } = require("../../../../libs/source/GenerateCodeLibs");
33
- const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
- const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
- const { v4: uuidv4 } = require('uuid')
36
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
- /**
39
- *
40
- *
41
- * description of function.
42
- * @param {Object} _izContext
43
- * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
44
- * @param {Logger} _izContext.logger - property of _izContext
45
- * @param {Object} requestParams - request params
46
- * @param {Object} requestParams.identifiers - identifiers for get data
47
- * @param {Object} requestParams.additionalRequest - additionalRequest
48
- *
49
- *
50
- * @returns {object} description of return value
51
- */
52
-
53
- module.exports.FlowSchemaOwnTopicEndpointComplete = async (
54
- _izContext,
55
- requestParams,
56
- callingFlowConfig = {},
57
- //(<additionalParams>)
58
- //(</additionalParams>)
59
- ) => {
60
-
61
- try {
62
- _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete _izContext", _izContext)
63
- _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete requestParams", requestParams)
64
- _izContext.logger.debug("FlowSchemaOwnTopicEndpointComplete callingFlowConfig", callingFlowConfig)
65
-
66
- //(<endpointCompleteHookMainFunction>)
67
- //(</endpointCompleteHookMainFunction>)
68
-
69
- let messageObject = {
70
- //(<messageObjectHook>)
71
- //(</messageObjectHook>)
72
- }
73
-
74
- let sendMessageToOutFlowSchema = {
75
- Message: JSON.stringify(messageObject),
76
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "<%- topicArn %>")
77
- };
78
- _izContext.logger.debug("before sendMessageToOutFlowSchema::", sendMessageToOutFlowSchema);
79
- await sns.publishAsync(_izContext, sendMessageToOutFlowSchema)
80
-
81
- } catch (err) {
82
- _izContext.logger.error('error FlowSchemaOwnTopicEndpointComplete: ', err)
83
- throw (err)
84
- }
85
- }
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) } }