@izara_project/izara-market-library-service-schemas 1.0.28 → 1.0.30
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 +1 -1
- package/src/GenerateCodeLibs/src/Consts.js +10 -9
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +54 -21
- package/src/MainLibs/src/Consts.js +36 -18
- package/src/reStructure/GenerateCode.js +2 -1
- package/src/reStructure/TemplateConfig.js +5 -1
- package/src/reStructure/TemplateData/EndpointPerService/generateTemplateData.js +108 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/data.js +76 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +73 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/data.js +81 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +125 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/data.js +70 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +73 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/data.js +79 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/request.json +7 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +126 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/data.js +53 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +624 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/data.js +52 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +177 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/data.js +56 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +234 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/data.js +56 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +330 -0
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +175 -0
- package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +26 -0
- package/src/reStructure/TemplateData/externalService/generateTemplateData.js +1 -1
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +91 -249
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +1 -1
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +10 -8
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +1 -1
- package/src/reStructure/TemplateData/findData/findDataYaml/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +4 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +3 -29
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +3 -21
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +3 -31
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/functionYaml/data.js +41 -10
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/functionYaml/template.ejs +3 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/{hook/handler/templateAsyncHandler.ejs → preSignUrl/createPresignUrl/handler/template.ejs} +26 -11
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → createPresignUrl}/mainFunction/data.js +10 -7
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +253 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{reservedLimit → createPresignUrl}/queue/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +10 -38
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +40 -45
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +7 -10
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +100 -190
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → reservedLimit}/sqs/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{getSignUrls → reservedLimit}/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +8 -6
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/queue/s3Template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/data.js +5 -2
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +41 -38
- package/src/reStructure/TemplateData/flowSchema/legacy/hookCode-old/queue/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +11 -1
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +35 -44
- package/src/reStructure/TemplateData/perActionComplete/create/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +4 -5
- package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +5 -4
- package/src/reStructure/TemplateData/perActionComplete/generateTemplateData.js +15 -2
- package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +7 -4
- package/src/reStructure/TemplateData/perActionComplete/update/sns-out/data.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +5 -4
- package/src/reStructure/TemplateData/processLogical/yaml/data.js +3 -3
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/sqs/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +16 -15
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +18 -16
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/sns-in-sqs/template.ejs +0 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +16 -15
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +17 -14
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +18 -16
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +17 -14
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +20 -17
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +16 -14
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +19 -18
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/defaultDynamoDbTable.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +40 -38
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +6 -12
- package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/snsAndSqsPerActionData.js +22 -49
- package/src/reStructure/TemplateData/resourceYaml/sns-in-sqs/snsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/sns-out/data.js +8 -24
- package/src/reStructure/TemplateData/resourceYaml/sns-out/template.ejs +1 -1
- package/src/reStructure/TemplateData/testTemplate/template.ejs +0 -5
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/handler/data.js +0 -93
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/handler/templateSyncHandler.ejs +0 -49
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/hookLogic/data.js +0 -43
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/mainFunction/data.js +0 -65
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/mainFunction/template.ejs +0 -7
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/data.js +0 -72
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/snsTemplate.ejs +0 -59
- package/src/reStructure/TemplateData/flowSchema/components/upload/hook/queue/sqsTemplate.ejs +0 -43
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/handler/template.ejs +0 -120
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/mainFunction/template.ejs +0 -163
- /package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/{reservedLimit → createPresignUrl}/queue/template.ejs +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
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 dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
20
|
+
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
21
|
+
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
22
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
23
|
+
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
24
|
+
|
|
25
|
+
const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
|
|
26
|
+
const snsSharedLib = require('@izara_project/izara-shared/src/SnsSharedLib');
|
|
27
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
28
|
+
const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
29
|
+
|
|
30
|
+
const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
|
|
31
|
+
|
|
32
|
+
const hash = require("object-hash")
|
|
33
|
+
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
34
|
+
const path = require('path')
|
|
35
|
+
const schemasPath = path.join(__dirname, '../schemas');
|
|
36
|
+
const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
37
|
+
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
generateDynamoDbIdentifiers,
|
|
41
|
+
dynamoDbIdentifiersByStorageResource,
|
|
42
|
+
collectGetData
|
|
43
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
getGraphServiceTagWithCache,
|
|
47
|
+
getServiceNameWithCache
|
|
48
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
49
|
+
|
|
50
|
+
const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
51
|
+
const { createDeleteDataDetail } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
|
|
52
|
+
const { createObjType } = require("@izara_project/izara-core-library-service-schemas/src/Utils");
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param {*} _izContext
|
|
57
|
+
* @param {Object} requestParams = {identifiers}
|
|
58
|
+
* @param {*} callingFlowConfig
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
module.exports.deleteMain = async (
|
|
62
|
+
_izContext,
|
|
63
|
+
requestParams,
|
|
64
|
+
callingFlowConfig
|
|
65
|
+
) => {
|
|
66
|
+
try {
|
|
67
|
+
_izContext.logger.debug("function:DeleteMain::", {
|
|
68
|
+
requestParams: requestParams,
|
|
69
|
+
callingFlowConfig: callingFlowConfig
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
let errorsFound = []
|
|
73
|
+
const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
|
|
74
|
+
if (!userId) {
|
|
75
|
+
errorsFound.push("not have userId");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//(<beforeQuery>)
|
|
79
|
+
//(</beforeQuery>)
|
|
80
|
+
const objType = createObjType(requestParams.objectType);
|
|
81
|
+
let objectSchema = await getObjectSchema.getObjSchemaS3WithCache(_izContext,
|
|
82
|
+
objType)
|
|
83
|
+
_izContext.logger.debug("objectSchema", objectSchema)
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
create deleteDataDetail that decade what storage that have to access or not
|
|
87
|
+
becuase it only use identifier and dont care fieldName
|
|
88
|
+
*/
|
|
89
|
+
let deleteDataDetails = await createDeleteDataDetail(_izContext, objectSchema);
|
|
90
|
+
_izContext.logger.debug("deleteDataDetails", deleteDataDetails);
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
// validate objectSchema that canDelete or not
|
|
94
|
+
if (objectSchema.canDelete === false || objectSchema.canDelete == null) {
|
|
95
|
+
errorsFound.push("this objectSchema can't delete")
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (errorsFound.length) {
|
|
99
|
+
let deleteNodeCompleteMessage = {
|
|
100
|
+
objType: objType,
|
|
101
|
+
identifiers: requestParams.identifiers,
|
|
102
|
+
status: "error",
|
|
103
|
+
errorsFound
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
deleteNodeCompleteMessage = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, deleteNodeCompleteMessage);
|
|
107
|
+
|
|
108
|
+
let messageParams = {
|
|
109
|
+
Message: JSON.stringify(deleteNodeCompleteMessage),
|
|
110
|
+
MessageAttribute: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
111
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.deleteNodeComplete)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_izContext.logger.debug("messageParams OutDeleteNodeComplete::", messageParams);
|
|
115
|
+
await sns.publishAsync(_izContext, messageParams);
|
|
116
|
+
|
|
117
|
+
return deleteNodeCompleteMessage
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
for await (const [storageTag, deleteDataDetail] of Object.entries(deleteDataDetails)) {
|
|
122
|
+
if (deleteDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
123
|
+
_izContext.logger.debug("dynamoDb process")
|
|
124
|
+
|
|
125
|
+
let identifiersForDeleteData = await dynamoDbIdentifiersByStorageResource(
|
|
126
|
+
_izContext,
|
|
127
|
+
objectSchema,
|
|
128
|
+
deleteDataDetail,
|
|
129
|
+
requestParams.identifiers
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
_izContext.logger.debug("identifiersForDeleteData", identifiersForDeleteData)
|
|
133
|
+
|
|
134
|
+
// deleteItem in dynamo
|
|
135
|
+
await dynamodbSharedLib.deleteItem(_izContext,
|
|
136
|
+
await dynamodbSharedLib.tableName(_izContext, deleteDataDetail.tableName),
|
|
137
|
+
identifiersForDeleteData
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
} else if (deleteDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
141
|
+
_izContext.logger.debug("graph process")
|
|
142
|
+
|
|
143
|
+
let deleteNodeParams = {
|
|
144
|
+
objType: objType,
|
|
145
|
+
identifiers: requestParams.identifiers
|
|
146
|
+
}
|
|
147
|
+
deleteNodeParams = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
148
|
+
deleteNodeParams,
|
|
149
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
150
|
+
callingFlowConfig,
|
|
151
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
152
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.deleteNodeComplete), {}
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
)
|
|
156
|
+
_izContext.logger.debug("messageObject before send message: ", deleteNodeParams);
|
|
157
|
+
|
|
158
|
+
let messageAttributes;
|
|
159
|
+
|
|
160
|
+
let deleteNodeMessageBody = {
|
|
161
|
+
Message: JSON.stringify(deleteNodeParams),
|
|
162
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
163
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inDeleteNode, storageTag)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
_izContext.logger.debug("request message params before send to IndeleteNode::", deleteNodeMessageBody);
|
|
167
|
+
|
|
168
|
+
let resSns = await sns.publishAsync(_izContext, deleteNodeMessageBody)
|
|
169
|
+
_izContext.logger.debug('reSNS send to topic InDeleteNode finish', resSns)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
} catch (err) {
|
|
175
|
+
throw (err)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
// const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../#utils");
|
|
25
|
+
// const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../#const");
|
|
26
|
+
const {
|
|
27
|
+
firstLetterLowerCase: lowerCase,
|
|
28
|
+
firstLetterUpperCase: upperCase,
|
|
29
|
+
firstLetterUpperCase,
|
|
30
|
+
checkOverWriteGenerateMainFunction
|
|
31
|
+
} = require("../../../../../MainLibs/index.js").utils;
|
|
32
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../../MainLibs/src/Consts.js");
|
|
33
|
+
|
|
34
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
35
|
+
|
|
36
|
+
function data(_izContext, srcPath) {
|
|
37
|
+
return [createSource(_izContext, srcPath)]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createSource(_izContext, srcPath) {
|
|
41
|
+
let functionName = upperCase(ACTIONS.get)
|
|
42
|
+
return {
|
|
43
|
+
templatePath: templatePath,
|
|
44
|
+
templateData: {
|
|
45
|
+
functionName,
|
|
46
|
+
},
|
|
47
|
+
setting: {
|
|
48
|
+
savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
|
|
49
|
+
saveFileName: `${upperCase(functionName)}_Main`,
|
|
50
|
+
fileExtension: ".js",
|
|
51
|
+
isAppend: false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = data
|
|
@@ -0,0 +1,234 @@
|
|
|
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 {
|
|
22
|
+
getObjSchemaS3WithHierarchy,
|
|
23
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
getGraphServiceTagWithCache,
|
|
27
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
28
|
+
|
|
29
|
+
const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
objInstanceFromobjInstanceBase
|
|
33
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/IdentifiersObject');
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
dynamoDbIdentifiersByStorageResource,
|
|
37
|
+
collectGetData,
|
|
38
|
+
createGetDataDetails,
|
|
39
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
40
|
+
|
|
41
|
+
const { createObjTypeConcat, createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
|
|
42
|
+
|
|
43
|
+
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
44
|
+
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
45
|
+
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
46
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
47
|
+
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
48
|
+
const graphSharedLib = require('@izara_project/izara-core-library-graph-service');
|
|
49
|
+
|
|
50
|
+
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
51
|
+
const sns = externalRequest.sns
|
|
52
|
+
|
|
53
|
+
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
54
|
+
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
|
|
55
|
+
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
*
|
|
59
|
+
* description of function.
|
|
60
|
+
* @param {Object} _izContext
|
|
61
|
+
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
62
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
63
|
+
* @param {Object} requestParams - request params
|
|
64
|
+
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
65
|
+
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
66
|
+
*
|
|
67
|
+
*
|
|
68
|
+
* @returns {object} description of return value
|
|
69
|
+
*/
|
|
70
|
+
module.exports.getMain = async (
|
|
71
|
+
_izContext,
|
|
72
|
+
requestParams,
|
|
73
|
+
callingFlowConfig = {},
|
|
74
|
+
//(<additionalParams>)
|
|
75
|
+
//(</additionalParams>)
|
|
76
|
+
) => {
|
|
77
|
+
try {
|
|
78
|
+
_izContext.logger.debug('function GetMain: ', {
|
|
79
|
+
requestParams,
|
|
80
|
+
callingFlowConfig
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const returnSystemFieldsName = requestParams.additionalRequest?.setting?.returnSystemFieldsName || false;
|
|
84
|
+
const throwWhenNotFoundSomeRecord = requestParams.additionalRequest?.setting?.throwWhenNotFoundSomeRecord || true;
|
|
85
|
+
|
|
86
|
+
//(<beforeQuery>)
|
|
87
|
+
//(</beforeQuery>)
|
|
88
|
+
const objType = createObjType(requestParams.objectType)
|
|
89
|
+
let objectSchema = await getObjSchemaS3WithHierarchy(
|
|
90
|
+
_izContext,
|
|
91
|
+
objType
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
_izContext.logger.debug("objectSchema: ", objectSchema);
|
|
95
|
+
|
|
96
|
+
let getDataDetails = await createGetDataDetails(_izContext, objectSchema);
|
|
97
|
+
_izContext.logger.debug("getDataDetails:", getDataDetails)
|
|
98
|
+
|
|
99
|
+
// start to get data
|
|
100
|
+
let getResults = []; // for collect result data from
|
|
101
|
+
let getRecordStatus = {
|
|
102
|
+
getAtLeastOneRecord: false,
|
|
103
|
+
notFoundSomeRecord: false
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
await Promise.all(
|
|
107
|
+
Object.entries(getDataDetails).map(
|
|
108
|
+
async ([storageTag, getDataDetail]) => {
|
|
109
|
+
if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
110
|
+
// get data from graph
|
|
111
|
+
let graphServiceName = await getGraphServiceTagWithCache(_izContext, getDataDetail.graphServiceTag);
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
let versionedDataLabels = [];
|
|
115
|
+
if (getDataDetail.versionedDatas && Object.keys(getDataDetail.versionedDatas).length) {
|
|
116
|
+
// have versionedData
|
|
117
|
+
versionedDataLabels = Object.keys(getDataDetail.versionedDatas);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
//(<beforeGetGraph>)
|
|
122
|
+
//(</beforeGetGraph>)
|
|
123
|
+
|
|
124
|
+
let dataFromGraph = await graphSharedLib.getNodeV2(
|
|
125
|
+
_izContext,
|
|
126
|
+
graphServiceName,
|
|
127
|
+
objType,
|
|
128
|
+
{
|
|
129
|
+
identifiers: requestParams.identifiers
|
|
130
|
+
},
|
|
131
|
+
versionedDataLabels,
|
|
132
|
+
{
|
|
133
|
+
returnSystemFieldsName: returnSystemFieldsName
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
_izContext.logger.debug("dataFromGraphV2: ", dataFromGraph);
|
|
138
|
+
|
|
139
|
+
if (Object.keys(dataFromGraph).length) {
|
|
140
|
+
getRecordStatus.getAtLeastOneRecord = true;
|
|
141
|
+
} else {
|
|
142
|
+
getRecordStatus.notFoundSomeRecord = true
|
|
143
|
+
}
|
|
144
|
+
//(<afterGetGraph>)
|
|
145
|
+
//(</afterGetGraph>)
|
|
146
|
+
|
|
147
|
+
getResults.push([dataFromGraph, getDataDetail]);
|
|
148
|
+
|
|
149
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
|
|
150
|
+
|
|
151
|
+
let messageObject = {
|
|
152
|
+
objType: {
|
|
153
|
+
objectType: OBJECT_TYPE,
|
|
154
|
+
serviceTag: SERVICE_TAG
|
|
155
|
+
},
|
|
156
|
+
objInstanceFull: dataFromGraph.objInstanceFull
|
|
157
|
+
}
|
|
158
|
+
// send message to SNS ProcessFindRequiredData
|
|
159
|
+
_izContext.logger.debug("HAVE CallingFlow");
|
|
160
|
+
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
|
|
161
|
+
|
|
162
|
+
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
163
|
+
let outGetNodeCompleteTopic = await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outGetNodeComplete)
|
|
164
|
+
let messageParams = {
|
|
165
|
+
Message: JSON.stringify(messageObject),
|
|
166
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
167
|
+
TopicArn: outGetNodeCompleteTopic,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
_izContext.logger.debug("messageParams OutUpdateNode ::::::: ", messageParams);
|
|
171
|
+
await sns.publishAsync(_izContext, messageParams);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
} else {
|
|
176
|
+
|
|
177
|
+
let identifiersForGetData = await dynamoDbIdentifiersByStorageResource(
|
|
178
|
+
_izContext,
|
|
179
|
+
objectSchema,
|
|
180
|
+
getDataDetail,
|
|
181
|
+
requestParams.identifiers
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
_izContext.logger.debug("identifiersForGetData: ", identifiersForGetData);
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
//(<beforeGetDynamoDb>)
|
|
188
|
+
//(</beforeGetDynamoDb>)
|
|
189
|
+
|
|
190
|
+
let dataFromDynamoDb = await dynamodbSharedLib.getItem(
|
|
191
|
+
_izContext,
|
|
192
|
+
await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName),
|
|
193
|
+
identifiersForGetData
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
_izContext.logger.debug("dataFromDynamoDb: ", dataFromDynamoDb);
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
if (dataFromDynamoDb) {
|
|
200
|
+
dataFromDynamoDb = await objInstanceFromobjInstanceBase(
|
|
201
|
+
_izContext,
|
|
202
|
+
objType,
|
|
203
|
+
dataFromDynamoDb
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
getRecordStatus.getAtLeastOneRecord = true;
|
|
207
|
+
} else {
|
|
208
|
+
getRecordStatus.notFoundSomeRecord = true;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//(<afterGetDynamoDb>)
|
|
212
|
+
//(</afterGetDynamoDb>)
|
|
213
|
+
|
|
214
|
+
// collect return data depend on getDataDetail
|
|
215
|
+
getResults.push([dataFromDynamoDb, getDataDetail]);
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
_izContext.logger.debug("getRecordStatus: ", getRecordStatus);
|
|
222
|
+
|
|
223
|
+
if (throwWhenNotFoundSomeRecord && getRecordStatus.getAtLeastOneRecord === true && getRecordStatus.notFoundSomeRecord === true) {
|
|
224
|
+
throw Error("Not found some record while get data");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
let getResult = collectGetData(_izContext, getResults, objectSchema, returnSystemFieldsName);
|
|
228
|
+
|
|
229
|
+
return getResult;
|
|
230
|
+
} catch (err) {
|
|
231
|
+
_izContext.logger.error('error PersonGetMain: ', err)
|
|
232
|
+
throw (err)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
|
|
24
|
+
// const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../#utils");
|
|
25
|
+
// const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../#const");
|
|
26
|
+
const {
|
|
27
|
+
firstLetterLowerCase: lowerCase,
|
|
28
|
+
firstLetterUpperCase: upperCase,
|
|
29
|
+
firstLetterUpperCase,
|
|
30
|
+
checkOverWriteGenerateMainFunction
|
|
31
|
+
} = require("../../../../../MainLibs/index.js").utils;
|
|
32
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../../MainLibs/src/Consts.js");
|
|
33
|
+
|
|
34
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
35
|
+
|
|
36
|
+
function data(_izContext, srcPath) {
|
|
37
|
+
return [createSource(_izContext, srcPath)]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createSource(_izContext, srcPath) {
|
|
41
|
+
let functionName = upperCase(ACTIONS.update)
|
|
42
|
+
return {
|
|
43
|
+
templatePath: templatePath,
|
|
44
|
+
templateData: {
|
|
45
|
+
functionName,
|
|
46
|
+
},
|
|
47
|
+
setting: {
|
|
48
|
+
savePath: path.join(srcPath, SOURCE_PATH.endpointPerService),
|
|
49
|
+
saveFileName: `${upperCase(functionName)}_Main`,
|
|
50
|
+
fileExtension: ".js",
|
|
51
|
+
isAppend: false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = data
|