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

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 (139) hide show
  1. package/package.json +8 -7
  2. package/src/GenerateCodeLibs/src/Consts.js +2 -2
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +3 -2
  4. package/src/MainLibs/src/Consts.js +8 -8
  5. package/src/MainLibs/src/GenerateCodeUtils.js +3 -1
  6. package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/generateTemplateData.js +35 -20
  7. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/data.js +84 -0
  8. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/tempReferenceRelationshipSchema.ejs +9 -0
  9. package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/data.js +1 -1
  10. package/src/TemplateManager/src/flowSchema/DefaultWebSocketResource/webSocketConnect/handler/template.ejs +1 -1
  11. package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/handler/template.ejs +1 -1
  12. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/template.ejs +1 -1
  13. package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/mainFunction/template.ejs +1 -1
  14. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/mainFunction/template.ejs +1 -1
  15. package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/mainFunction/template.ejs +1 -1
  16. package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/mainFunction/template.ejs +1 -1
  17. package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/libs/template.ejs +1 -1
  18. package/src/reStructure/SchemaConfig.js +1 -4
  19. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +701 -0
  20. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +35 -163
  21. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +3 -1
  22. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -4
  23. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +3 -1
  24. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +45 -19
  25. package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +5 -2
  26. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +24 -14
  27. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +4 -1
  28. package/src/reStructure/TemplateData/findData/GetByStorage/getByGraph.ejs +4 -3
  29. package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -1
  30. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +4 -10
  31. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +69 -34
  32. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +1 -1
  33. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +3 -2
  34. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +3 -12
  35. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +2 -2
  36. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +18 -2
  37. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +10 -7
  38. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +2 -2
  39. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +1 -1
  40. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +2 -2
  41. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +12 -4
  42. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +14 -9
  43. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +1 -1
  44. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +16 -40
  45. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +9 -9
  46. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +1 -1
  47. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +3 -3
  48. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +78 -27
  49. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js +82 -0
  50. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +1 -1
  51. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +34 -1
  52. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +9 -32
  53. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +30 -20
  54. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +6 -6
  55. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +32 -32
  56. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +5 -5
  57. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +8 -9
  58. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +116 -26
  59. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +83 -44
  60. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +4 -5
  61. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -7
  62. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +6 -4
  63. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +2 -4
  64. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +31 -3
  65. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +4 -4
  66. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +7 -8
  67. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +13 -13
  68. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +4 -4
  69. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +43 -39
  70. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +5 -7
  71. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +2 -2
  72. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -9
  73. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +46 -48
  74. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +5 -4
  75. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +3 -11
  76. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +17 -3
  77. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +2 -2
  78. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +6 -2
  79. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +49 -84
  80. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +60 -10
  81. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -1
  82. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +7 -3
  83. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
  84. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +22 -7
  85. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +27 -34
  86. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +21 -5
  87. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +1 -3
  88. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +2 -2
  89. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +5 -5
  90. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data.js +5 -3
  91. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +10 -6
  92. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +6 -3
  93. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -2
  94. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +2 -2
  95. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +4 -4
  96. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +8 -3
  97. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +21 -14
  98. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +23 -8
  99. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +11 -6
  100. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +50 -45
  101. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +3 -2
  102. package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +2 -28
  103. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/createObjectComplete_main.js +1 -1
  104. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +10 -9
  105. package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +6 -2
  106. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +3 -2
  107. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +3 -2
  108. package/src/reStructure/TemplateData/perActionEndpoint/libs/template.ejs +1 -1
  109. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/create/template.ejs +1 -1
  110. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/delete/template.ejs +1 -1
  111. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/update/template.ejs +1 -1
  112. package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -0
  113. package/src/reStructure/TemplateData/{propertyNodeSchema → propertyValueSchema}/generateTemplateData.js +4 -4
  114. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +131 -0
  115. package/src/reStructure/TemplateData/{propertyNodeSchema/relationshipPropertyNodeSchema → propertyValueSchema/relationshipPropertyValueSchema}/data.js +32 -55
  116. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/tempRelationship.ejs +13 -0
  117. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/templateRelationshipPropertyValueSchema.ejs +7 -0
  118. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +3 -2
  119. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +3 -2
  120. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +3 -2
  121. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +5 -5
  122. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +6 -5
  123. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +3 -3
  124. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +4 -4
  125. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +5 -4
  126. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +3 -2
  127. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +3 -2
  128. package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -3
  129. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +61 -0
  130. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +13 -4
  131. package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +0 -151
  132. package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +0 -7
  133. package/src/reStructure/TemplateData/testTemplate/data.js +0 -27
  134. package/src/reStructure/TemplateData/testTemplate/template.ejs +0 -0
  135. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/attributeLinkTemplate.ejs +0 -0
  136. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/data.js +0 -0
  137. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/request.json +0 -0
  138. /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/template.ejs +0 -0
  139. /package/src/reStructure/TemplateData/{propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs → propertyValueSchema/objectPropertyValueSchema/templateObjectPropertyValueSchema.ejs} +0 -0
@@ -1,44 +1,37 @@
1
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
- */
2
+ * Copyright (C) 2020 Sven Mason <http://izara.io>
3
+ *
4
+ * This program is free software: you can redistribute it and/or modify it under the terms of
5
+ * the GNU Affero General Public License as published by the Free Software Foundation, either
6
+ * version 3 of the License, or (at your option) any later version.
7
+ *
8
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ * See the GNU Affero General Public License for more details.
11
+ *
12
+ * You should have received a copy of the GNU Affero General Public License along with this program.
13
+ * If not, see <http://www.gnu.org/licenses/>.
14
+ */
18
15
 
19
16
  'use strict';
20
17
 
21
- const hash = require("object-hash");
18
+ const hash = require('@izara_project/izara-shared-core').objectHash;
22
19
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
23
-
24
20
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
21
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
22
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
23
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
24
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
25
+ const externalRequestSns = require('@izara_project/izara-core-library-external-request').sns;
26
+ const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils');
27
+ const { NoRetryError, consts: coreConsts } = require('@izara_project/izara-core-library-core');
28
+ const { v4: uuidv4 } = require('uuid');
29
+ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
30
+ const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
29
31
 
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
32
  /**
33
+ * Description of function.
39
34
  *
40
- *
41
- * description of function.
42
35
  * @param {Object} _izContext
43
36
  * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
44
37
  * @param {Logger} _izContext.logger - property of _izContext
@@ -46,25 +39,36 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
46
39
  * @param {Object} requestParams.identifiers - identifiers for get data
47
40
  * @param {Object} requestParams.additionalRequest - additionalRequest
48
41
  *
49
- *
50
42
  * @returns {object} description of return value
51
43
  */
52
-
53
- module.exports.<%- externalTopicOutMain%>Main = async (
44
+ module.exports.<%- externalTopicOutMain %>Main = async (
54
45
  _izContext,
55
46
  requestParams,
56
47
  callingFlowConfig = {},
57
- //(<additionalParams>)
58
- //(</additionalParams>)
48
+ // (<additionalParams>)
49
+ // (</additionalParams>)
59
50
  ) => {
60
-
61
51
  try {
52
+ let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID);
53
+ let correlationId = _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID);
54
+
55
+ await postToConnection({
56
+ message: requestParams
57
+ }, connectionId);
62
58
 
63
- //(<additionalParams>)
64
- //(</additionalParams>)
59
+ await dynamodbSharedLib.deleteItem(
60
+ _izContext,
61
+ await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
62
+ {
63
+ taskKey: correlationId,
64
+ connectionId: connectionId
65
+ }
66
+ );
65
67
 
68
+ // (<additionalParams>)
69
+ // (</additionalParams>)
66
70
  } catch (err) {
67
- _izContext.logger.error('error WebSocketInvoke: ', err)
68
- throw (err)
71
+ _izContext.logger.error('error WebSocketInvoke: ', err);
72
+ throw err;
69
73
  }
70
- }
74
+ };
@@ -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,14 +81,15 @@ 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: {
94
- resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaExternalTopic, flowSchema.flowTag, "source/"),
92
+ resourceLocation: path.join(SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
95
93
  functionName,
96
94
  handlerType,
97
95
  functionNameConfig: functionConfig,
@@ -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,18 +1,16 @@
1
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/>.
2
+ * Copyright (C) 2021 Sven Mason <http://izara.io>
3
+ *
4
+ * This program is free software: you can redistribute it and/or modify it under the terms
5
+ * of the GNU Affero General Public License as published by the Free Software Foundation,
6
+ * either version 3 of the License, or (at your option) any later version.
7
+ *
8
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ * See the GNU Affero General Public License for more details.
11
+ *
12
+ * You should have received a copy of the GNU Affero General Public License along with this program.
13
+ * If not, see <http://www.gnu.org/licenses/>.
16
14
  */
17
15
 
18
16
  'use strict';
@@ -20,29 +18,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
18
  const { middlewareHandler, consts } = require("@izara_project/izara-middleware");
21
19
  // const AWS = require('aws-sdk');
22
20
  // const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
21
+
23
22
  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');
23
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
24
+ const hash = require('@izara_project/izara-shared-core').objectHash;
26
25
  // 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
26
 
31
- module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
27
+ const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
28
+ const { <%- functionName %>Main } = require("./<%- fileName %>_Main");
32
29
 
30
+ module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
33
31
  event._izContext.logger.debug('Event:', event);
34
32
 
35
33
  try {
36
-
37
34
  if (event.requestContext) {
38
35
  const route = event.requestContext.routeKey;
39
36
  const connectionId = event.requestContext.connectionId;
40
- let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
37
+ let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID);
41
38
 
42
39
  switch (route) {
43
- case '<%- flowTag%>':
44
- console.log("event in route <%- flowTag%>", event);
45
- let eventParams = JSON.parse(event.body)
40
+ case '<%- flowTag %>':
41
+ console.log("event in route <%- flowTag %>", event);
42
+
43
+ let eventParams = JSON.parse(event.body);
46
44
 
47
45
  await dynamodbSharedLib.putItem(
48
46
  event._izContext,
@@ -50,38 +48,38 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
50
48
  {
51
49
  taskKey: correlationId,
52
50
  connectionId: connectionId,
53
- originTimestamp: new Date.now()
51
+ originTimestamp: Date.now()
54
52
  }
55
- )
53
+ );
56
54
 
57
55
  let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
58
56
 
59
- await <%- functionName%>Main(
57
+ await <%- functionName %>Main(
60
58
  event._izContext,
61
59
  eventParams,
62
60
  callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
63
- //(<additionalParams>)
64
- //(</additionalParams>)
65
- )
66
- break
67
- }
68
- } else {
61
+ // (<additionalParams>)
62
+ // (</additionalParams>)
63
+ );
64
+
65
+ break;
66
+ }
67
+ } else {
69
68
  const connId = event.connId;
70
69
  // await postMessage({ message: event.message }, connId);
71
70
  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
71
  }
72
+ } catch (err) {
73
+ const connId = event.requestContext?.connectionId;
74
+ event._izContext.logger.error('Error, WebSocket: ', err);
75
+ // await sendErrorMessage({ message: err.message }, connId);
76
+ await postToConnection({ message: err.message }, connId);
77
+ }
83
78
  });
84
- <%_ const join = require('path').join _%>
85
- <%_ function upperCase (text) {
86
- return text.charAt(0).toUpperCase() + text.slice(1)
87
- } _%>
79
+
80
+ <%_
81
+ const join = require('path').join;
82
+ function upperCase(text) {
83
+ return text.charAt(0).toUpperCase() + text.slice(1);
84
+ }
85
+ _%>
@@ -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
@@ -18,7 +18,7 @@ along with this program. If not, see
18
18
 
19
19
  'use strict';
20
20
 
21
- const hash = require("object-hash");
21
+ const hash = require('@izara_project/izara-shared-core').objectHash;
22
22
  const { getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
23
23
 
24
24
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
@@ -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) } }