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

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 (108) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +35 -5
  3. package/src/MainLibs/src/Consts.js +5 -2
  4. package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
  5. package/src/MainLibs/src/Utils.js +12 -0
  6. package/src/reStructure/GenerateCode.js +2 -2
  7. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +36 -11
  8. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +24 -1
  9. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +26 -0
  10. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +22 -0
  11. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +37 -7
  12. package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -2
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -0
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +5 -1
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +3 -3
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/template.ejs +1 -1
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +1 -1
  19. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
  20. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +1 -1
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/functionYaml/data.js +127 -0
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/handler/data.js +121 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/{sqs/handler → handler}/template.ejs +16 -61
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/data.js +74 -0
  25. package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/template.ejs +131 -0
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +61 -34
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +3 -7
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -5
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +13 -4
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +16 -37
  32. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +2 -4
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +2 -5
  34. package/src/reStructure/TemplateData/flowSchema/{externalTopic/sqs → flowSchemaOwnTopic/flowStep}/functionYaml/data.js +43 -38
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/template.ejs +20 -0
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/data.js +80 -0
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/template.ejs +85 -0
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/mainFunction/data.js +92 -0
  39. package/src/reStructure/TemplateData/flowSchema/{externalTopic/websocket → flowSchemaOwnTopic/flowStep}/mainFunction/template.ejs +11 -13
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +47 -37
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +23 -26
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/functionYaml/data.js +5 -21
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/webSocketComplete/functionYaml/template.ejs +20 -0
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/data.js +2 -2
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/data.js +2 -2
  46. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/template.ejs +24 -10
  47. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +32 -34
  48. package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/template.ejs +1 -1
  49. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +172 -0
  50. package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +165 -0
  51. package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → templateBystatusType}/statusFieldTemplate.ejs +0 -5
  52. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/storedCacheTemplate.ejs +24 -0
  53. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +20 -0
  54. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +3 -0
  55. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +3 -0
  56. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +2 -7
  57. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +22 -3
  58. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +14 -9
  59. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +26 -6
  60. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +11 -7
  61. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +17 -7
  62. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +23 -4
  63. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +14 -9
  64. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +26 -6
  65. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +10 -7
  66. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +11 -7
  67. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +23 -4
  68. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +14 -9
  69. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +26 -7
  70. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +10 -7
  71. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +12 -7
  72. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +22 -3
  73. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +14 -6
  74. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +20 -3
  75. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +9 -3
  76. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +12 -6
  77. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +6 -2
  78. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +20 -11
  79. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +0 -184
  80. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +0 -11
  81. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +0 -210
  82. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +0 -77
  83. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +0 -8
  84. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +0 -17
  85. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +0 -64
  86. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +0 -61
  87. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +0 -74
  88. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +0 -110
  89. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +0 -18
  90. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +0 -57
  91. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +0 -85
  92. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +0 -67
  93. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/FlowSchemaCompleteComponent → externalTopic}/functionYaml/template.ejs +0 -0
  94. /package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/template.ejs +0 -0
  95. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/data.js +0 -0
  96. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/template.ejs +0 -0
  97. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/data.js +0 -0
  98. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/mainFunction/data.js +0 -0
  99. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/dynamoDB/register.js +0 -0
  100. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/data.js +0 -0
  101. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/template.ejs +0 -0
  102. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/data.js +0 -0
  103. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/template.ejs +0 -0
  104. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/data.js +0 -0
  105. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/template.ejs +0 -0
  106. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/data.js +0 -0
  107. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/template.ejs +0 -0
  108. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/mainFunction/data.js +0 -0
@@ -1,74 +0,0 @@
1
- /*
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
- */
15
-
16
- 'use strict';
17
-
18
- const hash = require('@izara_project/izara-shared-core').objectHash;
19
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
20
- const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
21
- const snsSharedLib = require('@izara_project/izara-core-library-sns');
22
- const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
23
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
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");
31
-
32
- /**
33
- * Description of function.
34
- *
35
- * @param {Object} _izContext
36
- * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
37
- * @param {Logger} _izContext.logger - property of _izContext
38
- * @param {Object} requestParams - request params
39
- * @param {Object} requestParams.identifiers - identifiers for get data
40
- * @param {Object} requestParams.additionalRequest - additionalRequest
41
- *
42
- * @returns {object} description of return value
43
- */
44
- module.exports.<%- externalTopicOutMain %>Main = async (
45
- _izContext,
46
- requestParams,
47
- callingFlowConfig = {},
48
- // (<additionalParams>)
49
- // (</additionalParams>)
50
- ) => {
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);
58
-
59
- await dynamodbSharedLib.deleteItem(
60
- _izContext,
61
- await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
62
- {
63
- taskKey: correlationId,
64
- connectionId: connectionId
65
- }
66
- );
67
-
68
- // (<additionalParams>)
69
- // (</additionalParams>)
70
- } catch (err) {
71
- _izContext.logger.error('error WebSocketInvoke: ', err);
72
- throw err;
73
- }
74
- };
@@ -1,110 +0,0 @@
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
- const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
-
24
- const { firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
25
- const {
26
- SOURCE_PATH,
27
- defaultIamRolePerAction,
28
- createIamRole,
29
- RESOURCE_CLASSES,
30
- SNS_RESOURCE,
31
- resourceNames,
32
- DYNAMO_RESOURCE,
33
- SAVE_FILE_NAME,
34
- FUNCTION_NAME,
35
- shortNameHandler,
36
- externalResourceYaml,
37
- SOURCE_GENERATE_IAM_ROLE
38
- } = require("../../../../../../MainLibs/src/Consts");
39
-
40
- const templatePath = path.join(__dirname, "template.ejs");
41
- const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
42
- /**
43
- * receive objectSchema
44
- * create data for WebSocket handler template
45
- *
46
- * @param {Object} objectSchema
47
- * @return {{templatePath, templateData,setting}}
48
- */
49
- function data(_izContext, flowSchema, srcPath) {
50
- return [createSourceParams(_izContext, flowSchema, srcPath)]
51
- }
52
-
53
- function createSourceParams(_izContext, flowSchema, srcPath) {
54
- let functionName = upperCase(flowSchema.flowTag);
55
- let handlerType = upperCase("hdrWbs");
56
- let functionConfig = functionName + "ExternalTopicIn" + upperCase(shortNameHandler(handlerType));
57
- let additionalResourcePermission = defaultIamRolePerAction();
58
- let route = flowSchema.flowTag;
59
-
60
- additionalResourcePermission.push(
61
- createIamRole(
62
- {
63
- [RESOURCE_CLASSES.dynamoDbTable]: [
64
- DYNAMO_RESOURCE.putItem,
65
- DYNAMO_RESOURCE.getItem,
66
- DYNAMO_RESOURCE.query,
67
- DYNAMO_RESOURCE.deleteItem,
68
- DYNAMO_RESOURCE.updateItem
69
- ]
70
- },
71
- [
72
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
73
- ]
74
- ),
75
- createIamRole(
76
- {
77
- "execute-api": [
78
- "ManageConnections"
79
- ]
80
- },
81
- [
82
- resourceNames(RESOURCE_CLASSES.webSocket)
83
- ]
84
- ),
85
- )
86
-
87
-
88
-
89
- return {
90
- templatePath: templatePath,
91
- templateData: {
92
- resourceLocation: path.join(SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
93
- functionName,
94
- handlerType,
95
- functionNameConfig: functionConfig,
96
- additionalResourcePermission,
97
- route,
98
- roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
99
- // externalTopicName
100
- },
101
- setting: {
102
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
103
- saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
104
- fileExtension: ".yml",
105
- isAppend: true
106
- }
107
- }
108
- }
109
-
110
- module.exports = data;
@@ -1,18 +0,0 @@
1
- <%_ const join = require('path').join; _%>
2
- <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
- name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionNameConfig) %>
5
- events:
6
- - websocket:
7
- route: <%- route %>
8
- # authorizer: ${self:custom.iz_authorizerAppLevel}
9
- # identifierResource: 'route.request.header.Auth'
10
- role: <%- roleName %>Role
11
- #<#<%- functionName %><%- handlerType %>IamRole#>
12
- #<#/<%- functionName %><%- handlerType %>IamRole#>
13
- <%_ function firstLetterUpperCase(text){
14
- return text.charAt(0).toUpperCase() + text.slice(1)
15
- } _%>
16
- <%_ function firstLetterLowerCase(str) {
17
- return str.charAt(0).toLowerCase() + str.slice(1)
18
- } _%>
@@ -1,57 +0,0 @@
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
- const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
-
23
- const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts");
24
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
25
- const templatePath = path.join(__dirname, "template.ejs")
26
-
27
- /**
28
- * receive objectSchema
29
- * create data for WebSocket handler template
30
- *
31
- * @param {Object} objectSchema
32
- * @return {{templatePath, templateData,setting}}
33
- */
34
- function data(_izContext, flowSchema, srcPath) {
35
- return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
36
- }
37
-
38
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
- let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicIn"
40
- let handlerType = "HdrWbs"
41
- const flowTag = flowSchema.flowTag
42
- return {
43
- templatePath: templatePath,
44
- templateData: {
45
- functionName: functionName,
46
- fileName: upperCase(functionName),
47
- flowTag,
48
- },
49
- setting: {
50
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
51
- saveFileName: `${upperCase(functionName)}_${handlerType}`,
52
- fileExtension: ".js",
53
- isAppend: false
54
- }
55
- }
56
- }
57
- module.exports = data
@@ -1,85 +0,0 @@
1
- /*
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/>.
14
- */
15
-
16
- 'use strict';
17
-
18
- const { middlewareHandler, consts } = require("@izara_project/izara-middleware");
19
- // const AWS = require('aws-sdk');
20
- // const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
21
-
22
- const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
23
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
24
- const hash = require('@izara_project/izara-shared-core').objectHash;
25
- // const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
26
-
27
- const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
28
- const { <%- functionName %>Main } = require("./<%- fileName %>_Main");
29
-
30
- module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
31
- event._izContext.logger.debug('Event:', event);
32
-
33
- try {
34
- if (event.requestContext) {
35
- const route = event.requestContext.routeKey;
36
- const connectionId = event.requestContext.connectionId;
37
- let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID);
38
-
39
- switch (route) {
40
- case '<%- flowTag %>':
41
- console.log("event in route <%- flowTag %>", event);
42
-
43
- let eventParams = JSON.parse(event.body);
44
-
45
- await dynamodbSharedLib.putItem(
46
- event._izContext,
47
- await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
48
- {
49
- taskKey: correlationId,
50
- connectionId: connectionId,
51
- originTimestamp: Date.now()
52
- }
53
- );
54
-
55
- let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
56
-
57
- await <%- functionName %>Main(
58
- event._izContext,
59
- eventParams,
60
- callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
61
- // (<additionalParams>)
62
- // (</additionalParams>)
63
- );
64
-
65
- break;
66
- }
67
- } else {
68
- const connId = event.connId;
69
- // await postMessage({ message: event.message }, connId);
70
- await postToConnection({ message: event.message }, connId);
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
- }
78
- });
79
-
80
- <%_
81
- const join = require('path').join;
82
- function upperCase(text) {
83
- return text.charAt(0).toUpperCase() + text.slice(1);
84
- }
85
- _%>
@@ -1,67 +0,0 @@
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
- const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts");
23
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
24
- const templatePath = path.join(__dirname, "template.ejs");
25
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
26
- const statusFieldTemplate = path.join(__dirname, "../../../createRecordByStatusType/statusFieldTemplate.ejs")
27
- const storedCacheTemplate = path.join(__dirname, "../../../createRecordByStatusType/storedCacheTemplate.ejs")
28
-
29
- /**
30
- * receive objectSchema
31
- * create data for WebSocket Main template
32
- *
33
- * @param {Object} objectSchema
34
- * @return {{templatePath, templateData,setting}}
35
- */
36
-
37
-
38
- function data(_izContext, flowSchema, srcPath) {
39
- return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
40
- }
41
-
42
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
43
- let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicIn"
44
- const splitKey = Object.keys(flowSchema.flowSteps)[0].split('_')
45
- // stockLocation_Test_flowStep_TopicName_In
46
- // let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
47
- // let fieldNames = Object.keys(objectSchema.fieldNames)
48
- return {
49
- templatePath: templatePath,
50
- templateData: {
51
- serviceTag: splitKey[0],
52
- topicName: splitKey[2] + '_' + splitKey[3],
53
- externalTopicMain: functionName + 'Main',
54
- storedCacheTemplate,
55
- statusFieldTemplate,
56
- statusType: flowSchema.statusType,
57
- flowTag: flowSchema.flowTag,
58
- },
59
- setting: {
60
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
61
- saveFileName: `${functionName}_Main`,
62
- fileExtension: ".js",
63
- isAppend: false
64
- }
65
- }
66
- }
67
- module.exports = data