@izara_project/izara-market-library-service-schemas 1.0.36 → 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.
- package/package.json +8 -7
- package/src/GenerateCodeLibs/src/Consts.js +2 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -1
- package/src/MainLibs/src/GenerateCodeUtils.js +1 -1
- package/src/TemplateManager/src/flowSchema/DefaultWebSocketResource/webSocketConnect/handler/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/handler/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/libs/template.ejs +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +1 -1
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +7 -7
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +1 -1
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +4 -2
- package/src/reStructure/TemplateData/findData/GetByStorage/getByGraph.ejs +4 -3
- package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -1
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +4 -10
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +3 -12
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +18 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +9 -6
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +0 -27
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +71 -18
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +5 -5
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +29 -19
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +28 -50
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +10 -22
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +5 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +72 -43
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +85 -40
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +8 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +5 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +7 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +4 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +3 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +4 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +13 -4
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +11 -9
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +2 -5
- package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +0 -29
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/createObjectComplete_main.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/perActionEndpoint/libs/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/create/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/delete/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/update/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +1 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/testTemplate/data.js +0 -27
- package/src/reStructure/TemplateData/testTemplate/template.ejs +0 -0
|
@@ -18,7 +18,7 @@ along with this program. If not, see
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
-
const hash = require(
|
|
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');
|
|
@@ -49,7 +49,7 @@ const { generateCodeLibs: { consts: TOPIC_NAME_GENERATE_CODE } } = require('@iza
|
|
|
49
49
|
*
|
|
50
50
|
* @returns {object} description of return value
|
|
51
51
|
*/
|
|
52
|
-
module.exports
|
|
52
|
+
module.exports.registerCompleteMain = async (
|
|
53
53
|
_izContext,
|
|
54
54
|
requestParams,
|
|
55
55
|
callingFlowConfig = {},
|
|
@@ -68,7 +68,7 @@ module.exports.<%- functionMain%> = async (
|
|
|
68
68
|
_izContext,
|
|
69
69
|
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
70
70
|
{
|
|
71
|
-
|
|
71
|
+
identifierTask: correlationId,
|
|
72
72
|
connectionId: connectionId,
|
|
73
73
|
}
|
|
74
74
|
);
|
|
@@ -88,40 +88,93 @@ module.exports.<%- functionMain%> = async (
|
|
|
88
88
|
throw new NoRetryError(`flowTag not found ${flowTag}`)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
// get data from dynamoDB of objectType of flowSchema
|
|
92
|
+
const getStoredCache = async (objectType) => {
|
|
93
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
94
|
+
_izContext,
|
|
95
|
+
{
|
|
96
|
+
objectType: objectType,
|
|
97
|
+
serviceTag: process.env.iz_serviceTag,
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
_izContext.logger.debug("==> objectSchema", objectSchema)
|
|
101
|
+
|
|
102
|
+
// this returns the table name of the first storage resource with storageType "dynamoDB"
|
|
103
|
+
const tableName = Object.values(objectSchema.storageResources).find(
|
|
104
|
+
(storageResource) => storageResource.storageType === "dynamoDB"
|
|
105
|
+
)?.tableName
|
|
106
|
+
_izContext.logger.debug("==> tableName", tableName)
|
|
107
|
+
|
|
108
|
+
let identifierPK = null
|
|
109
|
+
let identifierSK = null
|
|
110
|
+
objectSchema.identifiers.map((identifier) => {
|
|
111
|
+
if (identifier.type === "partitionKey") {
|
|
112
|
+
identifierPK = identifier.fieldName
|
|
113
|
+
} else if (identifier.type === "sortKey") {
|
|
114
|
+
identifierSK = identifier.fieldName
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
_izContext.logger.debug("==> identifierPK", identifierPK)
|
|
119
|
+
_izContext.logger.debug("==> identifierSK", identifierSK)
|
|
120
|
+
|
|
121
|
+
const payloadGetStoredCache = {
|
|
122
|
+
[identifierPK]: requestParams.identifiers[identifierPK],
|
|
123
|
+
}
|
|
124
|
+
if (identifierSK) {
|
|
125
|
+
payloadGetStoredCache[identifierSK] = requestParams.identifiers[identifierSK]
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
_izContext.logger.debug("==> payloadGetStoredCache", payloadGetStoredCache)
|
|
129
|
+
|
|
130
|
+
// const getStoredCache = await dynamodbSharedLib.getItem(
|
|
131
|
+
// _izContext,
|
|
132
|
+
// await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
133
|
+
// payloadGetStoredCache
|
|
134
|
+
// )
|
|
135
|
+
|
|
136
|
+
const getStoredCache = await dynamodbSharedLib.query(
|
|
137
|
+
_izContext,
|
|
138
|
+
await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
139
|
+
payloadGetStoredCache
|
|
140
|
+
)
|
|
141
|
+
_izContext.logger.debug("==> getStoredCache:::", getStoredCache)
|
|
142
|
+
return ({
|
|
143
|
+
data: getStoredCache.Items[0],
|
|
144
|
+
identifierPK: identifierPK,
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
switch (getFlowSchema.statusType) {
|
|
92
149
|
case "statusField":
|
|
93
150
|
let payload = {
|
|
94
151
|
identifiers: requestParams.identifiers,
|
|
95
|
-
objectType:
|
|
152
|
+
objectType: getFlowSchema.objType.objectType
|
|
96
153
|
}
|
|
97
154
|
let result = await externalRequest.lambda.invokeSync(
|
|
98
155
|
_izContext,
|
|
99
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv",
|
|
156
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv", getFlowSchema.objType.serviceTag),
|
|
100
157
|
payload
|
|
101
158
|
)
|
|
102
159
|
if (!result) {
|
|
103
160
|
throw new NoRetryError(`statusField not found ${requestParams.identifiers}`)
|
|
104
161
|
}
|
|
162
|
+
await postToConnection({message:result}, connectionId)
|
|
105
163
|
return result
|
|
106
|
-
|
|
164
|
+
case "storedCache":
|
|
107
165
|
// if statusType=storedCache then query storedCache > post message to client -> remove connectionId if status = error || complete
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
{
|
|
112
|
-
taskKey: requestParams.identifiers,
|
|
113
|
-
connectionId: requestParams.connectionId
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
if (!getStoredCache) {
|
|
166
|
+
const resultStoredCache = resultStoredCache(getFlowSchema.objType.objectType)
|
|
167
|
+
|
|
168
|
+
if (!resultStoredCache) {
|
|
117
169
|
throw new NoRetryError(`storedCache not found ${requestParams.identifiers}`)
|
|
118
170
|
}
|
|
119
|
-
|
|
171
|
+
await postToConnection({message:resultStoredCache }, connectionId)
|
|
172
|
+
return resultStoredCache
|
|
120
173
|
case "none":
|
|
121
174
|
// if statusType=none -> post message to client ---- not remove connectionId when post message, can remove connectionId when cannot use connectionId only(user disconnect)
|
|
122
175
|
break
|
|
123
176
|
default:
|
|
124
|
-
throw new NoRetryError(`statusType not found ${
|
|
177
|
+
throw new NoRetryError(`statusType not found ${getFlowSchema.statusType}`)
|
|
125
178
|
}
|
|
126
179
|
|
|
127
180
|
} catch (err) {
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js
CHANGED
|
@@ -31,7 +31,7 @@ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, defaultIamRolePerAction, DYN
|
|
|
31
31
|
*/
|
|
32
32
|
const createRegisterTable = (_izContext, srcPath) => {
|
|
33
33
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
34
|
-
const tableName = "
|
|
34
|
+
const tableName = "RegisterRecords";
|
|
35
35
|
additionalResourcePermission.push(
|
|
36
36
|
createIamRole(
|
|
37
37
|
{
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
let expiryTime = storedCacheSharedLib.createExpiryTime(_izContext, 31536000);
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})
|
|
3
|
+
//(<createKeyValuesStoredCacheTable>)
|
|
4
|
+
//(</createKeyValuesStoredCacheTable>)
|
|
5
|
+
|
|
7
6
|
let [ cacheMainStauts, cacheId, cacheMain ] = await storedCacheSharedLib.checkStoredCacheStatus(
|
|
8
7
|
_izContext,
|
|
9
8
|
"<%- tableName %>",
|
|
10
|
-
|
|
9
|
+
//(<keyValueStoredCacheTable>)
|
|
10
|
+
//(</keyValueStoredCacheTable>)
|
|
11
11
|
)
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js
CHANGED
|
@@ -49,25 +49,35 @@ function createDataForSubscriptionOutAll(_izContext, allLocalFlowSchemas, srcPat
|
|
|
49
49
|
const result = []
|
|
50
50
|
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
51
51
|
let event = flowSchema.event;
|
|
52
|
-
if (!event.includes("eventBridge")) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
if (!event.includes("eventBridge") || !event.includes("s3")) {
|
|
53
|
+
let flowSteps = flowSchema.flowSteps;
|
|
54
|
+
if (!flowSteps) {
|
|
55
|
+
return result
|
|
56
|
+
}
|
|
57
|
+
let queueName;
|
|
58
|
+
if (flowSchema.outputTopic) {
|
|
59
|
+
let flowStepOut = Object.keys(flowSchema.flowSteps)[1].split("_")
|
|
60
|
+
queueName = flowStepOut[3] + flowStepOut[2]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (queueName) {
|
|
64
|
+
result.push({
|
|
65
|
+
templatePath: templatePath,
|
|
66
|
+
templateData: {
|
|
67
|
+
queueName: queueName,
|
|
68
|
+
endpoint: "Register",
|
|
69
|
+
firstLetterUpperCase: upperCase,
|
|
70
|
+
},
|
|
71
|
+
setting: {
|
|
72
|
+
initialData: "Resources:\n",
|
|
73
|
+
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
74
|
+
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
75
|
+
fileExtension: ".yml",
|
|
76
|
+
isAppend: true
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
}
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
return result
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js
CHANGED
|
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
|
|
20
20
|
const path = require('path');
|
|
21
21
|
|
|
22
|
-
const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
const { FLOW_SCHEMA_HOOK_STATE, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
23
|
|
|
24
24
|
const { firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
|
|
25
25
|
const {
|
|
@@ -37,6 +37,7 @@ const {
|
|
|
37
37
|
SOURCE_GENERATE_IAM_ROLE,
|
|
38
38
|
LAMBDA_RESOURCE
|
|
39
39
|
} = require("../../../../../../MainLibs/src/Consts");
|
|
40
|
+
const { getLocalObjectSchemas } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
40
41
|
|
|
41
42
|
const templatePath = path.join(__dirname, "template.ejs");
|
|
42
43
|
const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
|
|
@@ -47,7 +48,7 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
|
|
|
47
48
|
* @param {Object} objectSchema
|
|
48
49
|
* @return {{templatePath, templateData,setting}}
|
|
49
50
|
*/
|
|
50
|
-
function data(_izContext, allLocalFlowSchemas, srcPath) {
|
|
51
|
+
async function data(_izContext, allLocalFlowSchemas, srcPath) {
|
|
51
52
|
const handlerType = upperCase("hdrWbs");
|
|
52
53
|
const functionName = FUNCTION_NAME.flowSchemaRegister;
|
|
53
54
|
let functionNameConfig = upperCase(functionName) + upperCase(shortNameHandler(handlerType));
|
|
@@ -90,58 +91,35 @@ function data(_izContext, allLocalFlowSchemas, srcPath) {
|
|
|
90
91
|
)
|
|
91
92
|
)
|
|
92
93
|
|
|
93
|
-
let tableStoredCacheList =
|
|
94
|
-
|
|
94
|
+
let tableStoredCacheList = new Set();
|
|
95
|
+
await Promise.all(allLocalFlowSchemas.records.map(async (flowSchema) => {
|
|
95
96
|
if (flowSchema.statusType === "storedCache") {
|
|
96
|
-
|
|
97
|
+
let objectSchema = await getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
|
|
98
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
99
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
100
|
+
tableStoredCacheList.add(storageResource.tableName);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
97
103
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
}))
|
|
105
|
+
if (tableStoredCacheList.size > 0) {
|
|
106
|
+
let tableNames = [...tableStoredCacheList]
|
|
107
|
+
additionalResourcePermission.push(
|
|
108
|
+
createIamRole(
|
|
109
|
+
{
|
|
110
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
111
|
+
DYNAMO_RESOURCE.getItem,
|
|
112
|
+
// DYNAMO_RESOURCE.putItem,
|
|
113
|
+
// DYNAMO_RESOURCE.query,
|
|
114
|
+
// DYNAMO_RESOURCE.deleteItem,
|
|
115
|
+
// DYNAMO_RESOURCE.updateItem
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
tableNames.map(tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
|
|
119
|
+
)
|
|
114
120
|
)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// if (flowSchema?.hook) {
|
|
118
|
-
// for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
|
|
119
|
-
// if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
|
|
120
|
-
// for (const hookFunction of hookProperties.functionList) {
|
|
121
|
-
// if ((hookFunction.event.hasOwnProperty("initialEvent") && (hookFunction.event.initialEvent === true))) {
|
|
122
|
-
// if (hookFunction?.permission) {
|
|
123
|
-
// for (const permission of hookFunction.permission) {
|
|
124
|
-
// additionalResourcePermission.push(
|
|
125
|
-
// createIamRole(
|
|
126
|
-
// permission.action,
|
|
127
|
-
// permission.resource.map(resource =>
|
|
128
|
-
// externalResourceYaml(
|
|
129
|
-
// resource.resource,
|
|
130
|
-
// resource.resourceName,
|
|
131
|
-
// resource.serviceTag),
|
|
132
|
-
// permission.effect
|
|
133
|
-
// )
|
|
134
|
-
// )
|
|
135
|
-
// )
|
|
136
|
-
// }
|
|
137
|
-
// }
|
|
138
|
-
// }
|
|
139
|
-
// }
|
|
140
|
-
// }
|
|
141
|
-
// }
|
|
142
|
-
// }
|
|
121
|
+
}
|
|
143
122
|
|
|
144
|
-
// console.log("additionalResourcePermission in createObjectS3", JSON.stringify(additionalResourcePermission))
|
|
145
123
|
return [{
|
|
146
124
|
templatePath: templatePath,
|
|
147
125
|
templateData: {
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs
CHANGED
|
@@ -22,7 +22,7 @@ const { middlewareHandler, consts } = require("@izara_project/izara-middleware")
|
|
|
22
22
|
// const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
23
23
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
24
24
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
25
|
-
const hash = require('
|
|
25
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
26
26
|
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
27
27
|
const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
|
|
28
28
|
const { <%- functionName%>Main } = require("./<%- firstLetterUpperCase(functionName) %>_Main");
|
|
@@ -18,7 +18,7 @@ along with this program. If not, see
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
-
const hash = require(
|
|
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');
|
|
@@ -35,6 +35,7 @@ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryEr
|
|
|
35
35
|
const { v4: uuidv4 } = require('uuid')
|
|
36
36
|
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
37
37
|
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
38
|
+
const generatedCodeLibs = require('../../../libs/source/GenerateCodeLibs')
|
|
38
39
|
/**
|
|
39
40
|
*
|
|
40
41
|
*
|
|
@@ -50,7 +51,7 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
|
|
|
50
51
|
* @returns {object} description of return value
|
|
51
52
|
*/
|
|
52
53
|
|
|
53
|
-
module.exports
|
|
54
|
+
module.exports.registerMain = async (
|
|
54
55
|
_izContext,
|
|
55
56
|
requestParams,
|
|
56
57
|
callingFlowConfig = {},
|
|
@@ -58,13 +59,7 @@ module.exports.<%- functionMain%> = async (
|
|
|
58
59
|
//(</additionalParams>)
|
|
59
60
|
) => {
|
|
60
61
|
try {
|
|
61
|
-
|
|
62
|
-
// "action":register
|
|
63
|
-
// flowTag:"xxx"
|
|
64
|
-
// identifierTask:"xxxx",
|
|
65
|
-
// ...something
|
|
66
|
-
//}
|
|
67
|
-
|
|
62
|
+
let connecttionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
|
|
68
63
|
// receive flowTag and identifiers
|
|
69
64
|
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
70
65
|
flowTag: requestParams.flowTag,
|
|
@@ -157,9 +152,10 @@ module.exports.<%- functionMain%> = async (
|
|
|
157
152
|
if (!result) {
|
|
158
153
|
throw new NoRetryError(`statusField not found ${requestParams.identifiers}`)
|
|
159
154
|
}
|
|
155
|
+
await generatedCodeLibs.postToConnection({ message: result }, connecttionId)
|
|
160
156
|
return result
|
|
161
157
|
|
|
162
|
-
|
|
158
|
+
break;
|
|
163
159
|
case "storedCache":
|
|
164
160
|
// if statusType=storedCache then query storedCache > post message to client -> remove connectionId if status = error || complete
|
|
165
161
|
|
|
@@ -182,7 +178,7 @@ module.exports.<%- functionMain%> = async (
|
|
|
182
178
|
if (storedCacheData.data.cacheStatus !== "error" && storedCacheData.data.cacheStatus != "complete") {
|
|
183
179
|
await dynamodbSharedLib.putItem(
|
|
184
180
|
_izContext,
|
|
185
|
-
await dynamodbSharedLib.tableName(_izContext, "
|
|
181
|
+
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
186
182
|
payloadPostMessage
|
|
187
183
|
)
|
|
188
184
|
|
|
@@ -190,26 +186,18 @@ module.exports.<%- functionMain%> = async (
|
|
|
190
186
|
} else {
|
|
191
187
|
await dynamodbSharedLib.deleteItem(
|
|
192
188
|
_izContext,
|
|
193
|
-
await dynamodbSharedLib.tableName(_izContext, "
|
|
189
|
+
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
194
190
|
{
|
|
195
191
|
identifierTask: requestParams.identifiers[storedCacheData.identifierPK],
|
|
196
192
|
connectionId: _izContext.correlationIds.get(consts.CONNECTION_ID)
|
|
197
193
|
}
|
|
198
194
|
)
|
|
199
195
|
}
|
|
200
|
-
|
|
196
|
+
await generatedCodeLibs.postToConnection({ message: result }, connecttionId)
|
|
201
197
|
return storedCacheData;
|
|
202
198
|
|
|
203
199
|
case "none":
|
|
204
|
-
|
|
205
|
-
storedCacheData = await getStoredCache(flowSchema.objType.objectType)
|
|
206
|
-
|
|
207
|
-
_izContext.logger.debug("==> objectSchema", storedCacheData)
|
|
208
|
-
if (!storedCacheData) {
|
|
209
|
-
throw new NoRetryError(`none not found ${requestParams.identifiers}`)
|
|
210
|
-
}
|
|
211
|
-
return storedCacheData
|
|
212
|
-
|
|
200
|
+
break;
|
|
213
201
|
default:
|
|
214
202
|
throw new NoRetryError(`statusType not found ${flowSchema.statusType}`)
|
|
215
203
|
}
|
|
@@ -52,13 +52,16 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
55
|
-
|
|
55
|
+
//TranslateIds_Test_TranslateIdsComplete_Out
|
|
56
|
+
let flowSteps = Object.keys(flowSchema.flowSteps)
|
|
57
|
+
let flowStepTopicOut = flowSteps[1];
|
|
58
|
+
let topicComponent = flowStepTopicOut.split("_");
|
|
59
|
+
const queueName = `${upperCase(topicComponent[2])}_${upperCase(topicComponent[3])}`
|
|
56
60
|
return [
|
|
57
61
|
{
|
|
58
62
|
templatePath: templatePath,
|
|
59
63
|
templateData: {
|
|
60
64
|
queueName: upperCase(queueName),
|
|
61
|
-
roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
|
|
62
65
|
},
|
|
63
66
|
setting: {
|
|
64
67
|
initialData: 'Resources:\n',
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
Type: AWS::SNS::Topic
|
|
4
4
|
Properties:
|
|
5
5
|
DisplayName: "SNS Message out"
|
|
6
|
-
TopicName: ${self:custom.
|
|
6
|
+
TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- firstLetterUpperCase(queueName) %>
|
|
7
7
|
|
|
8
8
|
<%_ function firstLetterUpperCase(text) { return text.charAt(0).toUpperCase() + text.slice(1) } _%>
|
|
@@ -1,45 +1,74 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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');
|
|
12
20
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
13
|
-
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
14
|
-
asyncFlowSharedLib =
|
|
15
|
-
require('@izara_project/izara-core-library-
|
|
16
|
-
|
|
17
|
-
require('@izara_project/izara-core-library-
|
|
18
|
-
= require('@izara_project/izara-
|
|
19
|
-
= require('@izara_project/izara-core-library-
|
|
20
|
-
=
|
|
21
|
-
require('@izara_project/izara-market-library-service-schemas/src/
|
|
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')
|
|
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');
|
|
26
30
|
const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(
|
|
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
|
+
};
|
package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js
CHANGED
|
@@ -89,7 +89,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
89
89
|
return {
|
|
90
90
|
templatePath: templatePath,
|
|
91
91
|
templateData: {
|
|
92
|
-
resourceLocation: path.join(SOURCE_PATH.
|
|
92
|
+
resourceLocation: path.join(SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
93
93
|
functionName,
|
|
94
94
|
handlerType,
|
|
95
95
|
functionNameConfig: functionConfig,
|