@izara_project/izara-market-library-service-schemas 1.0.14 → 1.0.16
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 +5 -5
- package/src/GenerateCodeLibs/src/Consts.js +3 -1
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +122 -98
- package/src/MainLibs/src/Utils.js +10 -9
- package/src/TemplateManager/src/FindData/GetByStorage/getByGraph.ejs +2 -1
- package/src/TemplateManager/src/GenerateCode.js +55 -12
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/data.js +86 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/data.js +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/template.ejs +130 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/template.ejs +47 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +15 -7
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +14 -6
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +14 -4
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +14 -4
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/data.js +171 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/request.json +19 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/template.ejs +29 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/data.js +60 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/template.ejs +10 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +15 -12
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +14 -13
- package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocket/data.js +76 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocket/template.ejs +141 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocketConnect/data.js +56 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocketConnect/template.ejs +55 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +40 -36
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Delete/template.ejs +0 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +54 -22
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +23 -27
- package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +2 -2
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/template.ejs +4 -0
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +2 -1
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +1 -5
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +1 -5
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +11 -7
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/template.ejs +4 -0
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrApi/template.ejs +5 -4
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrInv/template.ejs +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/mainFunction/template.ejs +16 -13
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +9 -6
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/template.ejs +4 -0
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +8 -5
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +10 -8
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/{awaitingMultipleStepData.js → defaultDynamoDbTable.js} +39 -3
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +6 -3
- package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +1 -1
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +5 -10
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +14 -0
- package/src/TemplateManager/src/flowTag/resources/dynamoDb/data.js +65 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/data.js +56 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/template.ejs +10 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/data.js +55 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/template.ejs +63 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/data.js +75 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/data.js +57 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/template.ejs +131 -0
- package/src/TemplateManager/src/libs/Consts.js +7 -2
- package/src/TemplateManager/src/libs/GenerateCodeUtils.js +3 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +0 -99
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const izara = require("@izara_project/izara-middleware");
|
|
21
|
+
const middleware = izara.middlewareHandler;
|
|
22
|
+
const AWS = require('aws-sdk');
|
|
23
|
+
const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
24
|
+
const izaraShared = require('@izara_project/izara-shared');
|
|
25
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
26
|
+
const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
|
|
27
|
+
|
|
28
|
+
const { validateSchemaPerWebSocket } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
|
|
29
|
+
<%_ if (isCreateMainFunction == true) { _%>
|
|
30
|
+
// user generate main function
|
|
31
|
+
<%_ } else { %>
|
|
32
|
+
const <%- functionName %> =require('./<%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(action) %>_Main')
|
|
33
|
+
<%_ } _%>
|
|
34
|
+
|
|
35
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
36
|
+
|
|
37
|
+
event._izContext.logger.debug('Event:', event);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
|
|
43
|
+
let requestParams = JSON.parse(event.body);
|
|
44
|
+
await validateSchemaPerWebSocket(
|
|
45
|
+
event._izContext,
|
|
46
|
+
requestParams,
|
|
47
|
+
"<%- objectType -%>",
|
|
48
|
+
"<%- action -%>",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
if (event.requestContext) {
|
|
52
|
+
const route = event.requestContext.routeKey;
|
|
53
|
+
const connectionId = event.requestContext.connectionId;
|
|
54
|
+
const attribute = event.body;
|
|
55
|
+
event._izContext.logger.debug('body:', attribute);
|
|
56
|
+
event._izContext.logger.debug('route:', route);
|
|
57
|
+
event.body = JSON.parse(attribute)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
switch (route) {
|
|
62
|
+
case '$default':
|
|
63
|
+
console.log('Received unknown route:', route)
|
|
64
|
+
break
|
|
65
|
+
case '<%- objectType -%><%- firstLetterUpperCase(action) %>':
|
|
66
|
+
|
|
67
|
+
// create Web socket task for respond
|
|
68
|
+
await dynamodbSharedLib.putItem(
|
|
69
|
+
event._izContext,
|
|
70
|
+
await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
|
|
71
|
+
{
|
|
72
|
+
taskKey: "<%- objectType -%>" + "<%- firstLetterUpperCase(action) %>", // objType + action
|
|
73
|
+
connectionid: connectionId,
|
|
74
|
+
// connectionid: event.body.connectionid,
|
|
75
|
+
//(<additionalParams>)
|
|
76
|
+
//(</additionalParams>)
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
let payloadBeforeInvokeFunction = requestParams
|
|
81
|
+
// delete action before send to main function
|
|
82
|
+
delete payloadBeforeInvokeFunction.action
|
|
83
|
+
console.log("payloadBeforeInvokeFunction", payloadBeforeInvokeFunction)
|
|
84
|
+
event._izContext.logger.debug("event before send to <%- functionName %>Main", requestParams)
|
|
85
|
+
//(<beforeInvokeMain>)
|
|
86
|
+
//(</beforeInvokeMain>)
|
|
87
|
+
// invoke main
|
|
88
|
+
let invokeUpdateMainFunction = await <%- functionName %>.<%- functionName %>Main(
|
|
89
|
+
event._izContext,
|
|
90
|
+
payloadBeforeInvokeFunction,
|
|
91
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(attribute)
|
|
92
|
+
);
|
|
93
|
+
//(<afterInvokeMain>)
|
|
94
|
+
//(</afterInvokeMain>)
|
|
95
|
+
|
|
96
|
+
await postMessage(invokeUpdateMainFunction, connectionId);
|
|
97
|
+
|
|
98
|
+
break
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
console.log("not have event.requestContext")
|
|
104
|
+
const connId = event.connId;
|
|
105
|
+
await postMessage({ message: event.message }, connId);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
} catch (err) {
|
|
110
|
+
console.log("event", event)
|
|
111
|
+
const connId = event.requestContext.connectionId
|
|
112
|
+
event._izContext.logger.error('Error, WebSocket: ', err);
|
|
113
|
+
await sendErrorMessage({ message: err.message }, connId);
|
|
114
|
+
return (izara.response.failure(err));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
async function postMessage(data, connectionId) {
|
|
120
|
+
const params = {
|
|
121
|
+
ConnectionId: connectionId,
|
|
122
|
+
Data: JSON.stringify(data),
|
|
123
|
+
// Data: Buffer.from(JSON.stringify(data)),
|
|
124
|
+
}
|
|
125
|
+
return api.postToConnection(params).promise();
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
async function sendErrorMessage(errorMessage, connectionId) {
|
|
129
|
+
const params = {
|
|
130
|
+
ConnectionId: connectionId,
|
|
131
|
+
Data: JSON.stringify(errorMessage)
|
|
132
|
+
}
|
|
133
|
+
return api.postToConnection(params).promise();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
<%_ function firstLetterUpperCase(text){
|
|
137
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
138
|
+
} _%>
|
|
139
|
+
<%_ function firstLetterLowerCase(str) {
|
|
140
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
141
|
+
} _%>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { SOURCE_PATH, SAVE_FILE_NAME, ACTIONS, HANDLER } = require("../../../libs/Consts");
|
|
23
|
+
|
|
24
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* receive objectSchema
|
|
28
|
+
* create data for websocket connect function yaml template
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} objectSchema
|
|
31
|
+
* @return {{ templatePath, templateData, setting } }
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function data(_izContext, webSocketStatus, srcPath) {
|
|
35
|
+
let createSourceParam;
|
|
36
|
+
if (webSocketStatus) {
|
|
37
|
+
createSourceParam = [createWebSocketConnectYaml(_izContext, srcPath)]
|
|
38
|
+
} else {
|
|
39
|
+
createSourceParam = []
|
|
40
|
+
}
|
|
41
|
+
return createSourceParam
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function createWebSocketConnectYaml(_izContext, srcPath) {
|
|
45
|
+
return {
|
|
46
|
+
templatePath: templatePath,
|
|
47
|
+
templateData: {},
|
|
48
|
+
setting: {
|
|
49
|
+
savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
|
|
50
|
+
saveFileName: "WebSocketConnect",
|
|
51
|
+
fileExtension: ".js",
|
|
52
|
+
isAppend: true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
module.exports = data
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const izara = require("@izara_project/izara-middleware");
|
|
21
|
+
const middleware = izara.middlewareHandler;
|
|
22
|
+
const AWS = require('aws-sdk');
|
|
23
|
+
const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
24
|
+
|
|
25
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
26
|
+
|
|
27
|
+
event._izContext.logger.debug('Event:', event);
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
|
|
31
|
+
if (event.requestContext) {
|
|
32
|
+
const route = event.requestContext.routeKey;
|
|
33
|
+
const connectionId = event.requestContext.connectionId;
|
|
34
|
+
|
|
35
|
+
switch (route) {
|
|
36
|
+
case '$connect':
|
|
37
|
+
console.log('Connect websocket')
|
|
38
|
+
break
|
|
39
|
+
case '$disconnect':
|
|
40
|
+
console.log('Websocket are Disconnection')
|
|
41
|
+
break
|
|
42
|
+
case '$default':
|
|
43
|
+
console.log('Received unknown route:', route)
|
|
44
|
+
break
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
return (izara.response.webSocketSuccess());
|
|
50
|
+
|
|
51
|
+
} catch (err) {
|
|
52
|
+
event._izContext.logger.error('Error, WebSocketConnect: ', err);
|
|
53
|
+
return (izara.response.failure(err));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
@@ -59,6 +59,7 @@ const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER, GRAPH_HANDLER_SERVIC
|
|
|
59
59
|
const { createDataDetailsLib } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
|
|
60
60
|
const { createLinkTypeId } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
|
|
61
61
|
const { findLinksByObjTypes } = require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib")
|
|
62
|
+
const lodash = require("lodash")
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
65
|
- all storageType( DB and Graph) use objInstance({identifiers,fields})
|
|
@@ -95,7 +96,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
95
96
|
|
|
96
97
|
let errorsFound = [];
|
|
97
98
|
|
|
98
|
-
// _izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev");
|
|
99
99
|
const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
|
|
100
100
|
if (!userId) {
|
|
101
101
|
errorsFound.push("Not have userId")
|
|
@@ -110,7 +110,7 @@ module.exports.<%- functionName %>Main = async (
|
|
|
110
110
|
objectType: OBJECT_TYPE,
|
|
111
111
|
serviceTag: SERVICE_TAG
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
//test npm install from local
|
|
114
114
|
let objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
115
115
|
_izContext,
|
|
116
116
|
MAIN_OBJTYPE
|
|
@@ -162,12 +162,12 @@ module.exports.<%- functionName %>Main = async (
|
|
|
162
162
|
const { serviceTag: secondServiceTag, objectType: secondObjectType } = link.to.objType
|
|
163
163
|
|
|
164
164
|
const matchesFromTo =
|
|
165
|
-
fromServiceTag === firstServiceTag && fromObjectType === firstObjectType
|
|
166
|
-
|
|
165
|
+
fromServiceTag === firstServiceTag && fromObjectType === firstObjectType &&
|
|
166
|
+
toServiceTag === secondServiceTag && toObjectType === secondObjectType;
|
|
167
167
|
|
|
168
168
|
const matchesToFrom =
|
|
169
|
-
fromServiceTag === secondServiceTag && fromObjectType === secondObjectType
|
|
170
|
-
|
|
169
|
+
fromServiceTag === secondServiceTag && fromObjectType === secondObjectType &&
|
|
170
|
+
toServiceTag === firstServiceTag && toObjectType === firstObjectType
|
|
171
171
|
|
|
172
172
|
if ((relationshipProperties.relationshipDirection === "from" && matchesFromTo) ||
|
|
173
173
|
(relationshipProperties.relationshipDirection === "to" && matchesToFrom)) {
|
|
@@ -385,36 +385,19 @@ module.exports.<%- functionName %>Main = async (
|
|
|
385
385
|
|
|
386
386
|
for (let [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
|
|
387
387
|
|
|
388
|
-
for (let fieldName of Object.keys(requestParams.fieldNames)) {
|
|
389
|
-
|
|
390
|
-
if (createDataDetail.fieldNames.includes(fieldName) &&
|
|
391
|
-
listOfOptionalOnCreate.includes(fieldName) || listOfRequiredOnCreate.includes(fieldName)
|
|
392
|
-
) {
|
|
393
|
-
_izContext.logger.debug("fieldNames match in detail is:", fieldName);
|
|
394
|
-
|
|
395
|
-
if (!objInstanceFull.identifiers.hasOwnProperty(fieldName))
|
|
396
|
-
if (objInstanceFull.hasOwnProperty("fields")) {
|
|
397
|
-
Object.assign(objInstanceFull.fields, {
|
|
398
|
-
[fieldName]: requestParams.fieldNames[fieldName]
|
|
399
|
-
})
|
|
400
|
-
} else {
|
|
401
|
-
Object.assign(objInstanceFull, {
|
|
402
|
-
fields: {
|
|
403
|
-
[fieldName]: requestParams.fieldNames[fieldName]
|
|
404
|
-
}
|
|
405
|
-
})
|
|
406
|
-
};
|
|
407
|
-
};
|
|
408
|
-
};
|
|
409
|
-
|
|
410
388
|
if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
|
|
411
389
|
_izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull });
|
|
412
390
|
|
|
391
|
+
let objInstanceFullForDynamoDb = lodash.cloneDeep(objInstanceFull)
|
|
392
|
+
|
|
393
|
+
Object.assign(objInstanceFullForDynamoDb.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
|
|
394
|
+
_izContext.logger.debug("objInstanceFull before create item in dynamoDB", objInstanceFullForDynamoDb)
|
|
395
|
+
|
|
413
396
|
let identifiersForCreateData = await dynamoDbIdentifiersByStorageResource(
|
|
414
397
|
_izContext,
|
|
415
398
|
objectSchema,
|
|
416
399
|
createDataDetails,
|
|
417
|
-
|
|
400
|
+
objInstanceFullForDynamoDb.identifiers
|
|
418
401
|
)
|
|
419
402
|
_izContext.logger.debug("identifiersForCreateData", identifiersForCreateData);
|
|
420
403
|
|
|
@@ -426,27 +409,32 @@ module.exports.<%- functionName %>Main = async (
|
|
|
426
409
|
),
|
|
427
410
|
{
|
|
428
411
|
...identifiersForCreateData,
|
|
429
|
-
...
|
|
412
|
+
...objInstanceFullForDynamoDb.fields
|
|
430
413
|
}
|
|
431
414
|
);
|
|
432
415
|
|
|
433
416
|
} else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
|
|
434
|
-
_izContext.logger.debug("::::::
|
|
417
|
+
_izContext.logger.debug("::::::Graph::::::", { storageTag, objInstanceFull });
|
|
418
|
+
|
|
419
|
+
let objInstanceFullForGraph = lodash.cloneDeep(objInstanceFull)
|
|
420
|
+
|
|
421
|
+
Object.assign(objInstanceFullForGraph.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
|
|
422
|
+
_izContext.logger.debug("objInstanceFull before send to Graph", objInstanceFullForGraph)
|
|
435
423
|
|
|
436
424
|
// allStorageTagComplete = false;
|
|
437
425
|
allAwaitingStepsId.push(await asyncFlowSharedLib.createAwaitingStepId(
|
|
438
426
|
(hash({
|
|
439
427
|
objType: MAIN_OBJTYPE,
|
|
440
428
|
graphServerTag: storageTag,
|
|
441
|
-
identifiers:
|
|
429
|
+
identifiers: objInstanceFullForGraph.identifiers
|
|
442
430
|
})),
|
|
443
431
|
PREFIX.CREATE_OBJECT_ASYNC
|
|
444
432
|
));
|
|
445
433
|
listOfObjectForCreates.push({
|
|
446
434
|
[storageTag]: {
|
|
447
435
|
objInstanceFull: {
|
|
448
|
-
identifiers:
|
|
449
|
-
fields:
|
|
436
|
+
identifiers: objInstanceFullForGraph.identifiers,
|
|
437
|
+
fields: objInstanceFullForGraph.fields
|
|
450
438
|
},
|
|
451
439
|
allStorageTagComplete: false
|
|
452
440
|
}
|
|
@@ -456,11 +444,27 @@ module.exports.<%- functionName %>Main = async (
|
|
|
456
444
|
|
|
457
445
|
};
|
|
458
446
|
_izContext.logger.debug("[1]listOfObjectForCreates:::", listOfObjectForCreates);
|
|
459
|
-
|
|
460
|
-
delete objInstanceFull.fields
|
|
461
447
|
};
|
|
462
448
|
};
|
|
463
449
|
|
|
450
|
+
function createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail) {
|
|
451
|
+
_izContext.logger.debug("createObjInstanceFullFieldsByStorageTag : ", { storageTag, createDataDetail })
|
|
452
|
+
let fields = {};
|
|
453
|
+
for (let fieldName of Object.keys(requestParams.fieldNames)) {
|
|
454
|
+
if ((createDataDetails[storageTag].fieldNames.includes(fieldName)) &&
|
|
455
|
+
(createDataDetail.fieldNames.includes(fieldName))) {
|
|
456
|
+
if (!objInstanceFull.identifiers.hasOwnProperty(fieldName)) {
|
|
457
|
+
if (!fields.hasOwnProperty(fieldName)) {
|
|
458
|
+
Object.assign(fields, {
|
|
459
|
+
[fieldName]: requestParams.fieldNames[fieldName]
|
|
460
|
+
})
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
_izContext.logger.debug({ fields })
|
|
466
|
+
return fields
|
|
467
|
+
}
|
|
464
468
|
/// step save awiatingMultipleStep of storageType graph ...........................................................
|
|
465
469
|
|
|
466
470
|
await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
@@ -69,7 +69,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
let errorsFound = []
|
|
72
|
-
_izContext.correlationIds.set(coreConsts.BASE_USER_ID,"BasDev");
|
|
73
72
|
const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
|
|
74
73
|
if (!userId){
|
|
75
74
|
errorsFound.push("not have userId");
|
|
@@ -39,28 +39,32 @@ const {
|
|
|
39
39
|
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
42
|
+
const izaraShared = require('@izara_project/izara-shared');
|
|
43
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
44
|
+
const graphSharedLib = izaraShared.graphSharedLib;
|
|
45
|
+
const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
|
|
46
|
+
const snsSharedLib = izaraShared.snsSharedLib;
|
|
47
47
|
|
|
48
|
+
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
49
|
+
const sns = externalRequest.sns
|
|
48
50
|
|
|
51
|
+
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
52
|
+
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
|
|
49
53
|
|
|
50
54
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* description of function.
|
|
54
|
-
* @param {Object} _izContext
|
|
55
|
-
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
56
|
-
* @param {Logger} _izContext.logger - property of _izContext
|
|
57
|
-
* @param {Object} requestParams - request params
|
|
58
|
-
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
59
|
-
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @returns {object} description of return value
|
|
63
|
-
*/
|
|
55
|
+
*
|
|
56
|
+
*
|
|
57
|
+
* description of function.
|
|
58
|
+
* @param {Object} _izContext
|
|
59
|
+
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
60
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
61
|
+
* @param {Object} requestParams - request params
|
|
62
|
+
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
63
|
+
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
64
|
+
*
|
|
65
|
+
*
|
|
66
|
+
* @returns {object} description of return value
|
|
67
|
+
*/
|
|
64
68
|
module.exports.<%- functionName %>Main = async (
|
|
65
69
|
_izContext,
|
|
66
70
|
requestParams,
|
|
@@ -75,7 +79,7 @@ module.exports.<%- functionName %>Main = async (
|
|
|
75
79
|
_izContext.logger.debug('<%- functionName %> requestParams: ', requestParams);
|
|
76
80
|
_izContext.logger.debug('<%- functionName %> callingFlowConfig: ', callingFlowConfig);
|
|
77
81
|
|
|
78
|
-
const
|
|
82
|
+
const returnSystemFieldsName = requestParams.additionalRequest?.setting?.returnSystemFieldsName || false;
|
|
79
83
|
const throwWhenNotFoundSomeRecord = requestParams.additionalRequest?.setting?.throwWhenNotFoundSomeRecord || true;
|
|
80
84
|
|
|
81
85
|
|
|
@@ -133,7 +137,10 @@ module.exports.<%- functionName %>Main = async (
|
|
|
133
137
|
{
|
|
134
138
|
identifiers: requestParams.identifiers
|
|
135
139
|
},
|
|
136
|
-
versionedDataLabels
|
|
140
|
+
versionedDataLabels,
|
|
141
|
+
{
|
|
142
|
+
returnSystemFieldsName: returnSystemFieldsName
|
|
143
|
+
}
|
|
137
144
|
)
|
|
138
145
|
|
|
139
146
|
_izContext.logger.debug("dataFromGraphV2: ", dataFromGraph);
|
|
@@ -143,12 +150,37 @@ module.exports.<%- functionName %>Main = async (
|
|
|
143
150
|
} else {
|
|
144
151
|
getRecordStatus.notFoundSomeRecord = true
|
|
145
152
|
}
|
|
146
|
-
|
|
147
153
|
//(<afterGetGraph>)
|
|
148
154
|
//(</afterGetGraph>)
|
|
149
155
|
|
|
150
156
|
getResults.push([dataFromGraph, getDataDetail]);
|
|
151
157
|
|
|
158
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
|
|
159
|
+
|
|
160
|
+
let messageObject = {
|
|
161
|
+
objType: {
|
|
162
|
+
objectType: OBJECT_TYPE,
|
|
163
|
+
serviceTag: SERVICE_TAG
|
|
164
|
+
},
|
|
165
|
+
objInstanceFull: dataFromGraph.objInstanceFull
|
|
166
|
+
}
|
|
167
|
+
// send message to SNS ProcessFindRequiredData
|
|
168
|
+
_izContext.logger.debug("HAVE CallingFlow");
|
|
169
|
+
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
|
|
170
|
+
|
|
171
|
+
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
172
|
+
let outGetNodeCompleteTopic = await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outGetNodeComplete)
|
|
173
|
+
let messageParams = {
|
|
174
|
+
Message: JSON.stringify(messageObject),
|
|
175
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
176
|
+
TopicArn: outGetNodeCompleteTopic,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
_izContext.logger.debug("messageParams OutUpdateNode ::::::: ", messageParams);
|
|
180
|
+
await sns.publishAsync(_izContext, messageParams);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
152
184
|
} else {
|
|
153
185
|
|
|
154
186
|
let identifiersForGetData = await dynamoDbIdentifiersByStorageResource(
|
|
@@ -204,7 +236,7 @@ module.exports.<%- functionName %>Main = async (
|
|
|
204
236
|
throw Error("Not found some record while get data");
|
|
205
237
|
}
|
|
206
238
|
|
|
207
|
-
let getResult = collectGetData(_izContext, getResults, objectSchema,
|
|
239
|
+
let getResult = collectGetData(_izContext, getResults, objectSchema, returnSystemFieldsName);
|
|
208
240
|
|
|
209
241
|
return getResult;
|
|
210
242
|
} catch (err) {
|