@izara_project/izara-market-library-service-schemas 1.0.5 → 1.0.7
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 +2 -2
- package/src/GenerateCodeLibs/index.js +2 -1
- package/src/GenerateCodeLibs/src/Consts.js +12 -3
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +232 -7
- package/src/GenerateCodeLibs/src/TranslateIdsLibs.js +89 -0
- package/src/MainLibs/src/Utils.js +10 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +10 -2
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +5 -4
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +11 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +4 -3
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/template.ejs +24 -22
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +0 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +1 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationship/sns-in-sqs/data.js +0 -2
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/data.js +2 -2
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +0 -1
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/data.js +1 -1
- package/src/TemplateManager/src/FindData/FindDataYaml/data.js +188 -0
- package/src/TemplateManager/src/FindData/FindDataYaml/template.ejs +27 -0
- package/src/TemplateManager/src/FindData/GetByStorage/getByDynamo.ejs +53 -0
- package/src/TemplateManager/src/FindData/GetByStorage/getByGraph.ejs +99 -0
- package/src/TemplateManager/src/FindData/Handler/data.js +48 -0
- package/src/TemplateManager/src/FindData/Handler/template.ejs +140 -0
- package/src/TemplateManager/src/FindData/mainFunction/data.js +279 -0
- package/src/TemplateManager/src/FindData/mainFunction/template.ejs +158 -0
- package/src/TemplateManager/src/GenerateCode(Old).js +1 -1
- package/src/TemplateManager/src/GenerateCode.js +163 -42
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +98 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/data.js +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/createObjectComplete_main.js +172 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +172 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/template.ejs +47 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/template.ejs +10 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +98 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/data.js +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +126 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/template.ejs +47 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +22 -3
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +24 -1
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +53 -2
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +25 -3
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +5 -8
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/getTemplate.ejs +76 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/updateTemplate.ejs +67 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +47 -23
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/getTemplate.ejs +105 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/updateTemplate.ejs +109 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/createTemplate.ejs +75 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +69 -21
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/getTemplate.ejs +82 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/updateTemplate.ejs +75 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +46 -17
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/getTemplate.ejs +124 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/updateTemplate.ejs +133 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/CreateObject_main.js +760 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/data.js +67 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/request.json +0 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +575 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +0 -6
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +17 -12
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +61 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/request.json +0 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +267 -0
- package/src/TemplateManager/src/ProcessLogical/Handler/data.js +49 -0
- package/src/TemplateManager/src/ProcessLogical/Handler/template.ejs +129 -0
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +175 -0
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogical/mainFunction/data.js +47 -0
- package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +429 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/data.js +50 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/template.ejs +32 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +167 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +169 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/template.ejs +163 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/template.ejs +212 -0
- package/src/TemplateManager/src/ResourceYaml/CreateSourceData.js +2 -2
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +2 -2
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +27 -12
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +1 -1
- package/src/TemplateManager/src/ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +75 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/data.js +95 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/template.ejs +30 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/dataHdrDsq.js +52 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/template.ejs +194 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/data.js +48 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/template.ejs +330 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sns-out/data.js +47 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/data.js +58 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/template.ejs +43 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +116 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +116 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/data.js +60 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/template.ejs +157 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/data.js +59 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/template.ejs +175 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/data.js +61 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/template.ejs +155 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/dynamoDb/data.js +120 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/sns-sqs/data.js +75 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +2 -2
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +1 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +10 -3
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +6 -4
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +11 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +7 -5
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +150 -32
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +16 -15
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +35 -6
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +3 -4
- package/src/TemplateManager/src/libs/Consts.js +122 -11
- package/src/TemplateManager/src/PerActionEndpoint/Handler/testRequest.json +0 -5
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
const path = require('path');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
|
|
22
|
+
const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
|
|
24
|
+
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../libs/Consts");
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* receive objectSchema
|
|
31
|
+
* create data for hdrInv template
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} objectSchema
|
|
34
|
+
* @return {{ templatePath, templateData, setting } }
|
|
35
|
+
*/
|
|
36
|
+
async function data(_izContext, objectSchema, srcPath) {
|
|
37
|
+
if (objectSchema.overwriteGeneratedMainFunction?.length
|
|
38
|
+
&& objectSchema.overwriteGeneratedMainFunction.includes(ACTIONS.create)
|
|
39
|
+
) {
|
|
40
|
+
return [];
|
|
41
|
+
} else {
|
|
42
|
+
return [await createParamForCreateSource(_izContext, objectSchema, ACTIONS.create, srcPath)]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function createParamForCreateSource(_izContext, objectSchema, action, srcPath) {
|
|
47
|
+
let objectType = objectSchema.objectType;
|
|
48
|
+
let actionHandler = action;
|
|
49
|
+
let functionName = objectType + upperCase(action);
|
|
50
|
+
return {
|
|
51
|
+
templatePath: templatePath,
|
|
52
|
+
templateData: {
|
|
53
|
+
functionName: functionName,
|
|
54
|
+
objectType: objectType,
|
|
55
|
+
actionHandler: actionHandler,
|
|
56
|
+
},
|
|
57
|
+
setting: {
|
|
58
|
+
savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
|
|
59
|
+
saveFileName: `${upperCase(objectSchema.objectType)}${upperCase(action)}_Main`,
|
|
60
|
+
fileExtension: '.js',
|
|
61
|
+
isAppend: false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
module.exports = data;
|
|
File without changes
|
|
@@ -0,0 +1,575 @@
|
|
|
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 asyncFlowSharedLib = require('@izara_project/izara-shared/src/AsyncFlowSharedLib');
|
|
20
|
+
const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
|
|
21
|
+
const lambdaSharedLib = require('@izara_project/izara-shared/src/LambdaSharedLib')
|
|
22
|
+
const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
|
|
23
|
+
|
|
24
|
+
const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
|
|
25
|
+
const snsSharedLib = require('@izara_project/izara-shared/src/SnsSharedLib');
|
|
26
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
27
|
+
const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
28
|
+
|
|
29
|
+
const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
|
|
30
|
+
|
|
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
|
+
//-----------------------------------------------------------------------------------------------------------
|
|
51
|
+
const PREFIX = {
|
|
52
|
+
ONE: "one",
|
|
53
|
+
MANY: "many",
|
|
54
|
+
CREATE_OBJECT_ASYNC: "createObjectAsync",
|
|
55
|
+
CREATE_OBJECT_ASYNC_COMPLETE: "createObjectAsyncComplete"
|
|
56
|
+
}
|
|
57
|
+
//-----------------------------------------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
const { createCreateDataDetailsV2 } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
|
|
60
|
+
const { createLinkTypeId } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
- all storageType( DB and Graph) use objInstance({identifiers,fields})
|
|
64
|
+
- storageType[DB] async
|
|
65
|
+
- storageType[Graph] sync (should be have lambda complete)
|
|
66
|
+
-- before DB and Graph have boolend check (allStorageTagComplete = true) if storageType == graph set allStorageTagComplete = false,
|
|
67
|
+
and save awaitingMultiplastep prefix(serviceTag_CreateObject{identifierId})
|
|
68
|
+
|
|
69
|
+
>>> in lambdaComplete resive message from GrapHandler
|
|
70
|
+
1.1 check have returnValue.errorsFould.length > 0
|
|
71
|
+
-- Delete all awitingMultiplestep and senf message to callingFlow have errorFound.
|
|
72
|
+
1.2 check awaitingmultipleStepall finish
|
|
73
|
+
-- Delete awaitingStep in come if have other multiplestep(not finish)== not send message.
|
|
74
|
+
--- if check awaitingmultipleStepall finish not have record ===> sendmessage to callingFlow.
|
|
75
|
+
*/
|
|
76
|
+
//=========================================================================================
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param {*} _izContext
|
|
80
|
+
* @param {Object} requestParams = {fieldNames,relationships = []}
|
|
81
|
+
* @param {*} callingFlowConfig
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
module.exports.<%- functionName %>Main = async (
|
|
85
|
+
_izContext,
|
|
86
|
+
requestParams,
|
|
87
|
+
callingFlowConfig
|
|
88
|
+
) => {
|
|
89
|
+
try {
|
|
90
|
+
_izContext.logger.debug("function <%- functionName %>:", {
|
|
91
|
+
requestParams,
|
|
92
|
+
callingFlowConfig
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
_izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev");
|
|
96
|
+
|
|
97
|
+
const OBJECT_TYPE = "<%- objectType %>";
|
|
98
|
+
const SERVICE_TAG = process.env.iz_serviceTag;
|
|
99
|
+
//(<beforeQuery>)
|
|
100
|
+
//(</beforeQuery>)
|
|
101
|
+
|
|
102
|
+
const MAIN_OBJTYPE = {
|
|
103
|
+
objectType: OBJECT_TYPE,
|
|
104
|
+
serviceTag: SERVICE_TAG
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
108
|
+
_izContext,
|
|
109
|
+
MAIN_OBJTYPE
|
|
110
|
+
);
|
|
111
|
+
_izContext.logger.debug("objectSchema", objectSchema);
|
|
112
|
+
|
|
113
|
+
let objectSchemas = uploadUseCase.generateObjectSchemaForGraphHandler(
|
|
114
|
+
_izContext,
|
|
115
|
+
objectSchema
|
|
116
|
+
);
|
|
117
|
+
_izContext.logger.debug("objectSchemas", objectSchemas);
|
|
118
|
+
|
|
119
|
+
let createDataDetails = await createCreateDataDetailsV2(_izContext, objectSchemas);
|
|
120
|
+
_izContext.logger.debug("createDataDetails is =", createDataDetails);
|
|
121
|
+
|
|
122
|
+
let errorsFound = [];
|
|
123
|
+
|
|
124
|
+
//validate linkType
|
|
125
|
+
if ((requestParams.hasOwnProperty("relationships")) && (requestParams.relationship.length > 0)) {
|
|
126
|
+
|
|
127
|
+
for (let relationshipProperties of requestParams.relationship) {
|
|
128
|
+
_izContext.logger.debug("relType", relationshipProperties.relType)
|
|
129
|
+
let getObjectRelationship = await getObjectSchema.getRelationshipSchemaWithCache(
|
|
130
|
+
_izContext,
|
|
131
|
+
relationshipProperties.relType
|
|
132
|
+
)
|
|
133
|
+
_izContext.logger.debug("getObjectRelationship", getObjectRelationship)
|
|
134
|
+
|
|
135
|
+
for (const relationshipLink of Object.values(getObjectRelationship.links)) {
|
|
136
|
+
if (relationshipLink.from.linkType === "many" && relationshipLink.to.linkType === "many") {
|
|
137
|
+
if (relationshipLink.from.requiredOnCreate === true || relationshipLink.to.requiredOnCreate === true) {
|
|
138
|
+
errorsFound.push("error many to many linkType can't have requireOnCreate === true")
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// validate relationship link
|
|
146
|
+
let requiredOnCreateLinks = await getObjectSchema.getRequiredOnCreateLinksGraphHandlerWithCache(_izContext, MAIN_OBJTYPE);
|
|
147
|
+
_izContext.logger.debug("requiredOnCreateLinks", requiredOnCreateLinks);
|
|
148
|
+
|
|
149
|
+
let filterRequireOnCreateRels = {};
|
|
150
|
+
|
|
151
|
+
for (const [relationshipTag, relationshipProperties] of Object.entries(requiredOnCreateLinks)) {
|
|
152
|
+
let filterRequiredLinks = [];
|
|
153
|
+
|
|
154
|
+
for (const link of relationshipProperties.links) {
|
|
155
|
+
_izContext.logger.debug("linkObjectRelationship", link)
|
|
156
|
+
const serviceTags = await Promise.all(
|
|
157
|
+
link.storageResourceTags.map(async (storageTag) => {
|
|
158
|
+
let storageResource = relationshipProperties.storageResources[storageTag];
|
|
159
|
+
if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
160
|
+
return await getGraphServiceTagWithCache(_izContext, storageResource.graphServerTag)
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
)
|
|
164
|
+
_izContext.logger.debug('serviceTags: ', serviceTags);
|
|
165
|
+
|
|
166
|
+
if (serviceTags.includes("GraphHandler")) {
|
|
167
|
+
filterRequiredLinks.push(link)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (filterRequiredLinks.length) {
|
|
172
|
+
Object.assign(filterRequireOnCreateRels,
|
|
173
|
+
{
|
|
174
|
+
[relationshipTag]: {
|
|
175
|
+
...relationshipProperties,
|
|
176
|
+
links: filterRequiredLinks
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
_izContext.logger.debug("filterRequireOnCreateRels", filterRequireOnCreateRels)
|
|
182
|
+
|
|
183
|
+
if (Object.keys(filterRequireOnCreateRels).length) {
|
|
184
|
+
if (!requestParams.relationship.length) {
|
|
185
|
+
for (const relTag in filterRequireOnCreateRels) {
|
|
186
|
+
errorsFound.push(`missing required relationship of relType: serviceTag: ${filterRequireOnCreateRels[relTag].relationshipServiceTag}, relationshipTag: ${relTag} when create`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let requiredOnCreateLinks = {};
|
|
191
|
+
let createLinkTypeIds = [];
|
|
192
|
+
|
|
193
|
+
for (const [relTag, relationshipProperties] of Object.entries(filterRequireOnCreateRels)) {
|
|
194
|
+
_izContext.logger.debug("relationshipProperties", relationshipProperties);
|
|
195
|
+
|
|
196
|
+
for (const link of relationshipProperties.links) {
|
|
197
|
+
const requiredOnCreateLinkTypeId = createLinkTypeId(
|
|
198
|
+
_izContext,
|
|
199
|
+
[link.from.objType, link.to.objType],
|
|
200
|
+
{
|
|
201
|
+
relationshipTag: relTag,
|
|
202
|
+
serviceTag: relationshipProperties.relationshipServiceTag
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
Object.assign(requiredOnCreateLinks,
|
|
207
|
+
{
|
|
208
|
+
[requiredOnCreateLinkTypeId]: {
|
|
209
|
+
relType: {
|
|
210
|
+
relationshipTag: relTag,
|
|
211
|
+
serviceTag: relationshipProperties.relationshipServiceTag
|
|
212
|
+
},
|
|
213
|
+
link: link
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
_izContext.logger.debug("requiredOnCreateLinks", requiredOnCreateLinks)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
for (const createRelationship of requestParams.relationship) {
|
|
221
|
+
const onCreateLinkTypeId = createLinkTypeId(
|
|
222
|
+
_izContext,
|
|
223
|
+
[MAIN_OBJTYPE, createRelationship.targetObjType],
|
|
224
|
+
createRelationship.relType
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
if (!requiredOnCreateLinks.hasOwnProperty(onCreateLinkTypeId)) {
|
|
228
|
+
errorsFound.push(`relType:${JSON.stringify(createRelationship.relType)} are not relationshipSchema for this objType`)
|
|
229
|
+
continue;
|
|
230
|
+
} else {
|
|
231
|
+
createLinkTypeIds.push(onCreateLinkTypeId)
|
|
232
|
+
}
|
|
233
|
+
// validate missing relType that should create
|
|
234
|
+
const remainRequiredOnCreateLinkTypeIds = Object.keys(requiredOnCreateLinks)
|
|
235
|
+
.filter(requiredOnCreateLinkTypeId => !createLinkTypeIds.includes(requiredOnCreateLinkTypeId));
|
|
236
|
+
|
|
237
|
+
if (remainRequiredOnCreateLinkTypeIds.length) {
|
|
238
|
+
for (const remainRequiredOnCreateLinkTypeId of remainRequiredOnCreateLinkTypeIds) {
|
|
239
|
+
const missingLink = {
|
|
240
|
+
from: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].link.from,
|
|
241
|
+
to: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].link.to,
|
|
242
|
+
};
|
|
243
|
+
errorsFound.push(`Missing link:${JSON.stringify(missingLink)} when create`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
_izContext.logger.debug("requiredOnCreateLinks: ", requiredOnCreateLinks);
|
|
248
|
+
_izContext.logger.debug("onCreateLinkTypeIds: ", createLinkTypeIds);
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
|
|
253
|
+
if (requestParams.relationships.length) {
|
|
254
|
+
errorsFound.push(`objType:${JSON.stringify(objType)} not need relationships when create`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let objInstanceFull = {
|
|
259
|
+
identifiers: {},
|
|
260
|
+
fields: {}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
let listOfRequriedOnCreate = [];
|
|
264
|
+
let listOfOptionalOnCreate = [];
|
|
265
|
+
|
|
266
|
+
let allAwaitingStepsId = [];
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
// validate single identifiers
|
|
270
|
+
if (objectSchemas.identifiers.length === 1 && !identifier.hasOwnProperty("fieldNames")) {
|
|
271
|
+
|
|
272
|
+
const identifier = objectSchemas.identifiers[0];
|
|
273
|
+
_izContext.logger.debug(":::::case single identifer:::::", identifier);
|
|
274
|
+
|
|
275
|
+
if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate")) {
|
|
276
|
+
|
|
277
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == true)) {
|
|
278
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == false) &&
|
|
279
|
+
(objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) &&
|
|
280
|
+
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)
|
|
281
|
+
) {
|
|
282
|
+
|
|
283
|
+
Object.assign(requestParams.fieldNames, {
|
|
284
|
+
[identifier.fieldName]: hash({
|
|
285
|
+
fieldNames: identifier, //
|
|
286
|
+
uniqueRequestId: _izContext.uniqueRequestId,
|
|
287
|
+
callingFlowConfig: callingFlowConfig
|
|
288
|
+
})
|
|
289
|
+
});
|
|
290
|
+
_izContext.logger.debug("Assign requestParams", requestParams)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
} else if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false) ||
|
|
294
|
+
(objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == null)) {
|
|
295
|
+
|
|
296
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
|
|
297
|
+
((objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) || objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == true) &&
|
|
298
|
+
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
|
|
299
|
+
// check Fns have resive
|
|
300
|
+
|
|
301
|
+
if (requestParams.fieldNames.hasOwnProperty([identifier.fieldName])) {
|
|
302
|
+
_izContext.logger.debug("identifier is exist:", {
|
|
303
|
+
[identifier.fieldName]: requestParams.fieldNames[identifier.fieldName]
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
} else {
|
|
307
|
+
errorsFound.push("[invalid]requestParams not have data fieldNames of requriedOnCreate");
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
} else {
|
|
312
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == false) &&
|
|
313
|
+
(objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) &&
|
|
314
|
+
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
|
|
315
|
+
errorsFound.push("[invalid]case single identifier invalid objectSchemass");
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
_izContext.logger.debug("requestParams is:", requestParams);
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
// check settingObjSchemas
|
|
326
|
+
for (let [keyFieldNames, valueFieldNames] of Object.entries(objectSchemas.fieldNames)) {
|
|
327
|
+
|
|
328
|
+
if (valueFieldNames.hasOwnProperty("randomOnCreate") && valueFieldNames.randomOnCreate === true) {
|
|
329
|
+
listOfRequriedOnCreate.push(keyFieldNames)
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
if (valueFieldNames.hasOwnProperty("requiredOnCreate") && valueFieldNames.requiredOnCreate === true) {
|
|
333
|
+
listOfRequriedOnCreate.push(keyFieldNames)
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
if (valueFieldNames.hasOwnProperty("optionalOnCreate") && valueFieldNames.optionalOnCreate === true) {
|
|
337
|
+
if ((valueFieldNames.requiredOnCreate === false) && valueFieldNames.optionalOnCreate === true) {
|
|
338
|
+
listOfOptionalOnCreate.push(keyFieldNames)
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
}; // end iteration of fieldNames
|
|
344
|
+
|
|
345
|
+
_izContext.logger.debug("listOfRequriedOnCreate", listOfRequriedOnCreate);
|
|
346
|
+
_izContext.logger.debug("listOfOptionalOnCreate", listOfOptionalOnCreate);
|
|
347
|
+
for (let fieldName of Object.keys(requestParams.objInstanceFull.fieldNames)) {
|
|
348
|
+
|
|
349
|
+
if (!listOfRequriedOnCreate.includes(fieldName)) {
|
|
350
|
+
if (!listOfOptionalOnCreate.includes(fieldName)) {
|
|
351
|
+
errorsFound.push("[invalid] over fieldNames create object");
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
if (listOfOptionalOnCreate.length > 0 && listOfRequriedOnCreate.includes(fieldName)) {
|
|
356
|
+
// HookCode
|
|
357
|
+
// HookCode
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
/*
|
|
361
|
+
fix version if change objInstance initial
|
|
362
|
+
can delete condition if (listOfRequriedOnCreate.includes(fieldName))
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
// if (objectSchemas.identifierFieldNames.includes(fieldName)) {
|
|
366
|
+
// _izContext.logger.debug("identifiers is", fieldName);
|
|
367
|
+
// Object.assign(objInstance.identifiers, {
|
|
368
|
+
// [fieldName]: requestParams.fieldNames[fieldName]
|
|
369
|
+
// });
|
|
370
|
+
// };
|
|
371
|
+
|
|
372
|
+
if (errorsFound.length > 0) {
|
|
373
|
+
_izContext.logger.debug("HaveError::", errorsFound);
|
|
374
|
+
break
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
}; // end loop
|
|
378
|
+
|
|
379
|
+
let listOfObjectForCreates = [];
|
|
380
|
+
if (errorsFound.length == 0) {
|
|
381
|
+
|
|
382
|
+
for (let [serviceName, createDataDetail] of Object.entries(createDataDetails)) {
|
|
383
|
+
|
|
384
|
+
for (let fieldNames of Object.keys(requestParams.objInstanceFull.fieldNames)) {
|
|
385
|
+
|
|
386
|
+
if (createDataDetail.fieldNames.includes(fieldNames) && listOfRequriedOnCreate.includes(fieldNames)) {
|
|
387
|
+
_izContext.logger.debug("fieldNames match in detail is:", fieldNames);
|
|
388
|
+
|
|
389
|
+
if (objInstanceFull.hasOwnProperty("fields")) {
|
|
390
|
+
Object.assign(objInstanceFull.fields, {
|
|
391
|
+
[fieldNames]: requestParams.objInstanceFull.fieldNames[fieldNames]
|
|
392
|
+
})
|
|
393
|
+
} else {
|
|
394
|
+
Object.assign(objInstanceFull, {
|
|
395
|
+
fields: {
|
|
396
|
+
[fieldNames]: requestParams.objInstanceFull.fieldNames[fieldNames]
|
|
397
|
+
}
|
|
398
|
+
})
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
_izContext.logger.debug("objInstanceFull", objInstanceFull)
|
|
403
|
+
if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
|
|
404
|
+
_izContext.logger.debug("::::::DynamoDB::::::", { serviceName, objInstanceFull });
|
|
405
|
+
|
|
406
|
+
let identifiersForCreateData = await dynamoDbIdentifiersByStorageResource(
|
|
407
|
+
_izContext,
|
|
408
|
+
objectSchema,
|
|
409
|
+
createDataDetails,
|
|
410
|
+
requestParams.objInstanceFull.fieldNames
|
|
411
|
+
)
|
|
412
|
+
_izContext.logger.debug("identifiersForCreateData", identifiersForCreateData);
|
|
413
|
+
|
|
414
|
+
await dynamodbSharedLib.putItem(
|
|
415
|
+
_izContext,
|
|
416
|
+
await dynamodbSharedLib.tableName(
|
|
417
|
+
_izContext,
|
|
418
|
+
createDataDetail.tableName
|
|
419
|
+
),
|
|
420
|
+
identifiersForCreateData
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
} else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
|
|
425
|
+
_izContext.logger.debug("::::::Graphanler::::::", { serviceName, objInstanceFull });
|
|
426
|
+
|
|
427
|
+
// allStorageTagComplete = false;
|
|
428
|
+
allAwaitingStepsId.push(asyncFlowSharedLib.createAwaitingStepId(
|
|
429
|
+
(hash({
|
|
430
|
+
objType: MAIN_OBJTYPE,
|
|
431
|
+
graphServerTag: serviceName,
|
|
432
|
+
identifiers: objInstanceFull.identifiers
|
|
433
|
+
})),
|
|
434
|
+
PREFIX.CREATE_OBJECT_ASYNC
|
|
435
|
+
));
|
|
436
|
+
listOfObjectForCreates.push({
|
|
437
|
+
[serviceName]: {
|
|
438
|
+
objInstanceFull: {
|
|
439
|
+
identifiers: objInstanceFull.identifiers,
|
|
440
|
+
fields: objInstanceFull.fields
|
|
441
|
+
},
|
|
442
|
+
allStorageTagComplete: false
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
_izContext.logger.debug("FIRST", listOfObjectForCreates)
|
|
447
|
+
|
|
448
|
+
};
|
|
449
|
+
_izContext.logger.debug("[1]listOfObjectForCreates:::", listOfObjectForCreates);
|
|
450
|
+
|
|
451
|
+
delete objInstanceFull.fields
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
/// step save awiatingMultipleStep of storageType graph ...........................................................
|
|
456
|
+
|
|
457
|
+
await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
458
|
+
_izContext,
|
|
459
|
+
allAwaitingStepsId,
|
|
460
|
+
asyncFlowSharedLib.createPendingStepId((hash({ objType: MAIN_OBJTYPE, identifiers: objInstanceFull.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)
|
|
461
|
+
);
|
|
462
|
+
//............................................................................................................
|
|
463
|
+
|
|
464
|
+
// process storageType : graph
|
|
465
|
+
let messageObject = {};
|
|
466
|
+
for (let objectCreate of listOfObjectForCreates) {
|
|
467
|
+
|
|
468
|
+
for (let [graphServiceName, objecForCreate] of Object.entries(objectCreate)) {
|
|
469
|
+
_izContext.logger.debug("Loop each graph:", {
|
|
470
|
+
[graphServiceName]: objecForCreate
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
if (objecForCreate.allStorageTagComplete == false) { // needless check because in listOfObjectForCreates push case graph only!
|
|
474
|
+
|
|
475
|
+
messageObject = {
|
|
476
|
+
objType: MAIN_OBJTYPE,
|
|
477
|
+
objInstanceFull: objecForCreate.objInstanceFull,
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
if (errorsFound.length > 0) {
|
|
482
|
+
break;
|
|
483
|
+
} else {
|
|
484
|
+
_izContext.logger.debug("SENT MESSAGE EACH GRAPH::::", { graphServiceName, messageObject, callingFlowConfig })
|
|
485
|
+
|
|
486
|
+
Object.assign(messageObject, {
|
|
487
|
+
settings: { updatePropertiesOnMatch: false },
|
|
488
|
+
originTimestamp: Date.now()
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
// seagame: not need to check callingFlow before send to graph, Just add callingFlow and parent callingFlow before send to graph
|
|
492
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
|
|
493
|
+
_izContext.logger.debug("Have callingFlow", callingFlowConfig);
|
|
494
|
+
_izContext.logger.debug("callingFlowProperties", callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOWPROPERTIES_PROPERTYNAME])
|
|
495
|
+
|
|
496
|
+
messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
497
|
+
messageObject,
|
|
498
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
499
|
+
callingFlowConfig, // resive parent callingFlowConfig.
|
|
500
|
+
callingFlowSharedLib.createCallingFlowConfig( // callinfflow own service
|
|
501
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "CreateObjectCompleteHdrSqs"),
|
|
502
|
+
)
|
|
503
|
+
)
|
|
504
|
+
);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
let messageToCreateObject = {
|
|
508
|
+
Message: JSON.stringify(messageObject),
|
|
509
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "InCreateNodeV2", graphServiceName)
|
|
510
|
+
};
|
|
511
|
+
_izContext.logger.debug("RequestParams before send to sqs messageToCreateObject ::::::: ", messageToCreateObject);
|
|
512
|
+
await sns.publishAsync(_izContext, messageToCreateObject);
|
|
513
|
+
};
|
|
514
|
+
}; // end loop of objectCreate.
|
|
515
|
+
if (errorsFound.length > 0) {
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
}; // end loop listOfObjectForCreates
|
|
519
|
+
|
|
520
|
+
if (errorsFound.length > 0) {
|
|
521
|
+
_izContext.logger.debug("Case have errorFound:::", errorsFound);
|
|
522
|
+
|
|
523
|
+
// remove awaitngMultiplestep. [[[[[[[open when not test lolcal.]]]]]]]
|
|
524
|
+
await asyncFlowSharedLib.clearAllAwaitingSteps(
|
|
525
|
+
_izContext,
|
|
526
|
+
asyncFlowSharedLib.createPendingStepId((hash({
|
|
527
|
+
objType: MAIN_OBJTYPE,
|
|
528
|
+
identifiers: objInstanceFull.identifiers
|
|
529
|
+
})), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)); // pendingStepId
|
|
530
|
+
|
|
531
|
+
// send message to OutCreateObjectComplete.
|
|
532
|
+
//..
|
|
533
|
+
messageObject = {
|
|
534
|
+
objType: MAIN_OBJTYPE,
|
|
535
|
+
identifiers: null, // or {}
|
|
536
|
+
errorsFound: errorsFound
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// pass back property.
|
|
540
|
+
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
|
|
541
|
+
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
542
|
+
|
|
543
|
+
let sendMessageOutCreateObjectComplete = {
|
|
544
|
+
Message: JSON.stringify(messageObject),
|
|
545
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
546
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "OutCreateObjectComplete")
|
|
547
|
+
};
|
|
548
|
+
_izContext.logger.debug("Send message to OutCreateObjectComplete :::>", sendMessageOutCreateObjectComplete)
|
|
549
|
+
await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete);
|
|
550
|
+
|
|
551
|
+
return { returnValue: "function DeliveryMetodStandate have errorFounds" }
|
|
552
|
+
}
|
|
553
|
+
_izContext.logger.debug("end errorsFound is:", errorsFound);
|
|
554
|
+
|
|
555
|
+
} catch (err) {
|
|
556
|
+
throw (err)
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/*
|
|
562
|
+
example return
|
|
563
|
+
* identifierFieldNames will not includes inside fieldNames of createObjectDetails
|
|
564
|
+
{
|
|
565
|
+
dynamoDBStorageTag:{
|
|
566
|
+
storageType:"dynamoDB",
|
|
567
|
+
tableName:"xxx",
|
|
568
|
+
fieldNames:[...fieldName]
|
|
569
|
+
},
|
|
570
|
+
GraphServiceTag:{
|
|
571
|
+
storageType: 'graph',
|
|
572
|
+
fieldNames: [ 'bookId2', 'bookName' ]
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
*/
|
|
@@ -20,8 +20,6 @@ const path = require('path');
|
|
|
20
20
|
const fs = require('fs');
|
|
21
21
|
|
|
22
22
|
const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
23
|
-
const { createGetDataDetails } = require('../../../../../GenerateCodeLibs/src/GenerateCodeLibs')
|
|
24
|
-
|
|
25
23
|
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
|
|
26
24
|
const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../libs/Consts");
|
|
27
25
|
|
|
@@ -36,8 +34,6 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
36
34
|
* @return {{ templatePath, templateData, setting } }
|
|
37
35
|
*/
|
|
38
36
|
async function data(_izContext, objectSchema, srcPath) {
|
|
39
|
-
|
|
40
|
-
// let createSourceArray = [];
|
|
41
37
|
if (objectSchema.overwriteGeneratedMainFunction?.length
|
|
42
38
|
&& objectSchema.overwriteGeneratedMainFunction.includes(ACTIONS.get)
|
|
43
39
|
) {
|
|
@@ -51,14 +47,12 @@ async function createParamForCreateSource(_izContext, objectSchema, action, srcP
|
|
|
51
47
|
let objectType = objectSchema.objectType;
|
|
52
48
|
let actionHandler = action;
|
|
53
49
|
let functionName = objectType + upperCase(action);
|
|
54
|
-
let getDataDetail = await createGetDataDetails(_izContext, objectSchema);
|
|
55
50
|
return {
|
|
56
51
|
templatePath: templatePath,
|
|
57
52
|
templateData: {
|
|
58
53
|
functionName: functionName,
|
|
59
54
|
objectType: objectType,
|
|
60
55
|
actionHandler: actionHandler,
|
|
61
|
-
getDataDetail: JSON.stringify(getDataDetail)
|
|
62
56
|
},
|
|
63
57
|
setting: {
|
|
64
58
|
savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
|