@izara_project/izara-market-library-service-schemas 1.0.15 → 1.0.17
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/src/Consts.js +3 -1
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +94 -73
- package/src/MainLibs/src/Utils.js +10 -9
- package/src/TemplateManager/src/GenerateCode.js +53 -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/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/Get/template.ejs +54 -22
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +59 -25
- 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/mainFunction/template.ejs +1 -1
- 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
|
@@ -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(
|
|
@@ -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) {
|
|
@@ -23,22 +23,16 @@ const {
|
|
|
23
23
|
getObjSchemaS3WithHierarchy,
|
|
24
24
|
} = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
25
25
|
|
|
26
|
-
const {
|
|
27
|
-
getGraphServiceTagWithCache,
|
|
28
|
-
getServiceNameWithCache
|
|
29
|
-
} = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
30
26
|
|
|
31
27
|
const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
32
28
|
|
|
33
29
|
|
|
34
30
|
const {
|
|
35
|
-
dynamoDbIdentifiersByStorageResource,
|
|
36
|
-
collectGetData
|
|
31
|
+
dynamoDbIdentifiersByStorageResource, createFieldForUpdateDynamoDb
|
|
37
32
|
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
38
33
|
|
|
39
34
|
const izaraShared = require('@izara_project/izara-shared');
|
|
40
35
|
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
41
|
-
const graphSharedLib = izaraShared.graphSharedLib;
|
|
42
36
|
const snsSharedLib = izaraShared.snsSharedLib;
|
|
43
37
|
const asyncFlowSharedLib = izaraShared.asyncFlowSharedLib;
|
|
44
38
|
const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
|
|
@@ -47,14 +41,10 @@ const lambdaSharedLib = izaraShared.lambdaSharedLib
|
|
|
47
41
|
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
48
42
|
const sns = externalRequest.sns
|
|
49
43
|
|
|
50
|
-
const serviceSchema = require('@izara_project/izara-core-library-service-schemas/src/Utils')
|
|
51
|
-
|
|
52
44
|
const { createUpdateDataDetail } = require("@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs")
|
|
53
|
-
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
54
45
|
const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
|
|
55
46
|
const coreConsts = require('@izara_project/izara-core-library-core/src/Consts')
|
|
56
47
|
|
|
57
|
-
|
|
58
48
|
/**
|
|
59
49
|
*
|
|
60
50
|
*
|
|
@@ -84,7 +74,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
84
74
|
_izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
|
|
85
75
|
|
|
86
76
|
let errorFounds = [];
|
|
87
|
-
|
|
88
77
|
const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID)
|
|
89
78
|
if (!userId) {
|
|
90
79
|
errorFounds.push("Not Have UserId")
|
|
@@ -96,13 +85,13 @@ module.exports.<%- functionName %>Main = async (
|
|
|
96
85
|
//(</beforeQuery>)
|
|
97
86
|
|
|
98
87
|
const identifiers = requestParams.objInstanceFull.identifiers;
|
|
99
|
-
const fields = requestParams
|
|
100
|
-
|
|
88
|
+
const fields = requestParams.objInstanceFull.fields
|
|
89
|
+
let versionedDataIds = requestParams.versionedDataIds || {}
|
|
101
90
|
|
|
102
91
|
_izContext.logger.debug("explode requestParams", {
|
|
103
92
|
identifiers: identifiers,
|
|
104
93
|
fields: fields,
|
|
105
|
-
|
|
94
|
+
versionedDataIds: versionedDataIds
|
|
106
95
|
})
|
|
107
96
|
let objectSchema = await getObjSchemaS3WithHierarchy(
|
|
108
97
|
_izContext,
|
|
@@ -119,6 +108,50 @@ module.exports.<%- functionName %>Main = async (
|
|
|
119
108
|
|
|
120
109
|
let originTimestamp = Date.now();
|
|
121
110
|
|
|
111
|
+
let haveVersionedDataIdsToUpdate = (requestParams.versionedDataIds && Object.keys(requestParams.versionedDataIds).length) ? true : false
|
|
112
|
+
if (haveVersionedDataIdsToUpdate) {
|
|
113
|
+
|
|
114
|
+
let updateMainNodeData = {};
|
|
115
|
+
let updateVersionedData = {};
|
|
116
|
+
_izContext.logger.debug("have versionedDataIds to update")
|
|
117
|
+
for (const fieldProp in requestParams.objInstanceFull.fields) {
|
|
118
|
+
const fieldSetting = objectSchema.fieldNames[fieldProp];
|
|
119
|
+
// collect updateData
|
|
120
|
+
if (fieldSetting.hasOwnProperty("versionedDataLabel")) {
|
|
121
|
+
if (!updateVersionedData.hasOwnProperty(fieldSetting.versionedDataLabel)) {
|
|
122
|
+
updateVersionedData[fieldSetting.versionedDataLabel] = {};
|
|
123
|
+
}
|
|
124
|
+
Object.assign(updateVersionedData[fieldSetting.versionedDataLabel], { [fieldProp]: requestParams.objInstanceFull.fields[fieldProp] })
|
|
125
|
+
} else {
|
|
126
|
+
Object.assign(updateMainNodeData, { [fieldProp]: requestParams.objInstanceFull.fields[fieldProp] })
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
_izContext.logger.debug("updateMainNodeData::", updateMainNodeData);
|
|
130
|
+
_izContext.logger.debug("updateVersionedData::", updateVersionedData);
|
|
131
|
+
|
|
132
|
+
const versionedDataIdLabelKeys = Object.keys(requestParams.versionedDataIds);
|
|
133
|
+
const updateVersionedDataLabelKeys = Object.keys(updateVersionedData);
|
|
134
|
+
|
|
135
|
+
_izContext.logger.debug("versionedDataIdLabelKeys:: ", versionedDataIdLabelKeys);
|
|
136
|
+
_izContext.logger.debug("updateVersionedDataLabelKeys:: ", updateVersionedDataLabelKeys);
|
|
137
|
+
//check missing versionedDataIds
|
|
138
|
+
const missingVersionedDataIdLabels = updateVersionedDataLabelKeys.filter(label => !versionedDataIdLabelKeys.includes(label));
|
|
139
|
+
_izContext.logger.debug("missingVersionedDataIdLabels:: ", missingVersionedDataIdLabels);
|
|
140
|
+
|
|
141
|
+
if (missingVersionedDataIdLabels.length) {
|
|
142
|
+
errorFounds.push(`missing versionedDataIds of versionedDataLabel '${missingVersionedDataIdLabels.join(", ")}'`)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// check missing update data of versionedDataLabels
|
|
146
|
+
const missingDataVersionedDataLabels = versionedDataIdLabelKeys.filter(label => !versionedDataIdLabelKeys.includes(label))
|
|
147
|
+
if (missingDataVersionedDataLabels.length) {
|
|
148
|
+
errorFounds.push(`missing data of versionedDataLabels '${missingDataVersionedDataLabels.join(", ")}'`);
|
|
149
|
+
}
|
|
150
|
+
// check mainNode Data should not exists
|
|
151
|
+
if (Object.keys(updateMainNodeData).length) {
|
|
152
|
+
errorsFound.push("cannot update mainNode if have versionedDataIds");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
122
155
|
|
|
123
156
|
let messageAttributes
|
|
124
157
|
|
|
@@ -131,8 +164,8 @@ module.exports.<%- functionName %>Main = async (
|
|
|
131
164
|
objInstanceFull: {
|
|
132
165
|
identifiers: identifiers,
|
|
133
166
|
fields: fields,
|
|
134
|
-
versionedDatas: versionedDatas
|
|
135
167
|
},
|
|
168
|
+
versionedDataIds: versionedDataIds,
|
|
136
169
|
status: 'error',
|
|
137
170
|
errorFounds: errorFounds
|
|
138
171
|
};
|
|
@@ -169,7 +202,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
169
202
|
serviceTag: SERVICE_TAG,
|
|
170
203
|
identifiers: identifiers,
|
|
171
204
|
fields: fields,
|
|
172
|
-
versionedDatas: versionedDatas
|
|
173
205
|
// correlationIds: _izContext.correlationIds.get("id")
|
|
174
206
|
}),
|
|
175
207
|
PREFIX.updateNode
|
|
@@ -186,7 +218,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
186
218
|
{
|
|
187
219
|
identifiers,
|
|
188
220
|
fields,
|
|
189
|
-
versionedDatas: versionedDatas
|
|
190
221
|
})
|
|
191
222
|
)
|
|
192
223
|
)
|
|
@@ -201,8 +232,8 @@ module.exports.<%- functionName %>Main = async (
|
|
|
201
232
|
objInstanceFull: {
|
|
202
233
|
identifiers: identifiers,
|
|
203
234
|
fields: fields,
|
|
204
|
-
versionedDatas: versionedDatas
|
|
205
235
|
},
|
|
236
|
+
versionedDataIds: versionedDataIds,
|
|
206
237
|
originTimestamp
|
|
207
238
|
}
|
|
208
239
|
|
|
@@ -230,7 +261,7 @@ module.exports.<%- functionName %>Main = async (
|
|
|
230
261
|
let resSNS = await sns.publishAsync(_izContext, updateNodeMessageBody)
|
|
231
262
|
_izContext.logger.debug('resSNS send to topic InUpdateNode finish!', resSNS);
|
|
232
263
|
|
|
233
|
-
} else {
|
|
264
|
+
} else if (updateDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
234
265
|
|
|
235
266
|
let identifiersForUpdateData = await dynamoDbIdentifiersByStorageResource(
|
|
236
267
|
_izContext,
|
|
@@ -238,14 +269,17 @@ module.exports.<%- functionName %>Main = async (
|
|
|
238
269
|
updateDataDetail,
|
|
239
270
|
identifiers
|
|
240
271
|
)
|
|
272
|
+
|
|
273
|
+
let fieldForUpdateTableDynamo = createFieldForUpdateDynamoDb(_izContext, objectSchema, updateDataDetail, fields)
|
|
274
|
+
|
|
241
275
|
_izContext.logger.debug("identifiersForUpdateData", identifiersForUpdateData)
|
|
242
|
-
_izContext.logger.debug("
|
|
276
|
+
_izContext.logger.debug("fieldForUpdateTableDynamo", fieldForUpdateTableDynamo)
|
|
243
277
|
|
|
244
278
|
await dynamodbSharedLib.updateItem(
|
|
245
279
|
_izContext,
|
|
246
280
|
await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName),
|
|
247
281
|
identifiersForUpdateData,
|
|
248
|
-
|
|
282
|
+
fieldForUpdateTableDynamo
|
|
249
283
|
)
|
|
250
284
|
}
|
|
251
285
|
}
|
|
@@ -260,14 +294,14 @@ module.exports.<%- functionName %>Main = async (
|
|
|
260
294
|
objInstanceFull: {
|
|
261
295
|
identifiers: identifiers,
|
|
262
296
|
fields: fields,
|
|
263
|
-
|
|
264
|
-
|
|
297
|
+
},
|
|
298
|
+
versionedDataIds: versionedDataIds
|
|
265
299
|
},
|
|
266
300
|
status: "complete",
|
|
267
301
|
errorFounds
|
|
268
302
|
}
|
|
269
303
|
} catch (err) {
|
|
270
|
-
_izContext.logger.error('error
|
|
304
|
+
_izContext.logger.error('error AddressUpdate: ', err)
|
|
271
305
|
throw (err)
|
|
272
306
|
}
|
|
273
307
|
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
3
|
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
batchSize: 10
|
|
5
9
|
iamRoleStatements:
|
|
6
10
|
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
7
11
|
- Effect: <%- resourcePermission.effect %>
|
|
@@ -113,7 +113,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
113
113
|
relType: event.relType,
|
|
114
114
|
relationshipDirection: event.relationshipDirection,
|
|
115
115
|
relationshipProperties: event.relationshipProperties,
|
|
116
|
-
}
|
|
116
|
+
},
|
|
117
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
117
118
|
);
|
|
118
119
|
|
|
119
120
|
// return error to client
|
|
@@ -146,11 +146,7 @@ let validatorSchema = {
|
|
|
146
146
|
);
|
|
147
147
|
|
|
148
148
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
149
|
-
passOnProperties.push(record.body.Message
|
|
150
|
-
passOnProperties.push(record.body.Message.secondObject)
|
|
151
|
-
passOnProperties.push(record.body.Message.relType)
|
|
152
|
-
passOnProperties.push(record.body.Message.relationshipDirection)
|
|
153
|
-
passOnProperties.push(record.body.Message.relationshipProperties)
|
|
149
|
+
passOnProperties.push(record.body.Message)
|
|
154
150
|
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
155
151
|
//(<afterPutParamIntoMainFunction>)
|
|
156
152
|
//(</afterPutParamIntoMainFunction>)
|
|
@@ -124,11 +124,7 @@ let validatorSchema = {
|
|
|
124
124
|
);
|
|
125
125
|
|
|
126
126
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
127
|
-
passOnProperties.push(record.body.Message
|
|
128
|
-
passOnProperties.push(record.body.Message.secondObject)
|
|
129
|
-
passOnProperties.push(record.body.Message.relType)
|
|
130
|
-
passOnProperties.push(record.body.Message.relationshipDirection)
|
|
131
|
-
passOnProperties.push(record.body.Message.relationshipProperties)
|
|
127
|
+
passOnProperties.push(record.body.Message)
|
|
132
128
|
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
133
129
|
//(<afterPutParamIntoMainFunction>)
|
|
134
130
|
//(</afterPutParamIntoMainFunction>)
|
|
@@ -56,11 +56,10 @@ module.exports.createRelationshipComplete = async (
|
|
|
56
56
|
// start create awaitingStepId
|
|
57
57
|
const linkTypeId = createLinkTypeId(
|
|
58
58
|
_izContext,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
returnValue.relType
|
|
59
|
+
returnValue.firstObject.objType,
|
|
60
|
+
returnValue.secondObject.objType,
|
|
61
|
+
returnValue.relType,
|
|
62
|
+
returnValue.direction
|
|
64
63
|
);
|
|
65
64
|
|
|
66
65
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
@@ -94,7 +93,8 @@ module.exports.createRelationshipComplete = async (
|
|
|
94
93
|
_izContext.logger.debug("finished all awaitingStep");
|
|
95
94
|
|
|
96
95
|
let createCompleteMsg = {
|
|
97
|
-
|
|
96
|
+
firstObject: returnValue.firstObject,
|
|
97
|
+
secondObject: returnValue.secondObject,
|
|
98
98
|
relType: returnValue.relType,
|
|
99
99
|
relationshipProperties: returnValue.relationshipProperties,
|
|
100
100
|
status: status,
|
|
@@ -128,7 +128,11 @@ module.exports.createRelationshipComplete = async (
|
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
return {
|
|
131
|
+
return {
|
|
132
|
+
returnValue,
|
|
133
|
+
status,
|
|
134
|
+
errorsFound
|
|
135
|
+
}
|
|
132
136
|
|
|
133
137
|
} catch (err) {
|
|
134
138
|
_izContext.logger.error('error createRelationshipComplete:', err)
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
3
|
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
batchSize: 10
|
|
5
9
|
iamRoleStatements:
|
|
6
10
|
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
7
11
|
- Effect: <%- resourcePermission.effect %>
|
|
@@ -245,7 +245,7 @@ module.exports.deleteRelationship = async (
|
|
|
245
245
|
|
|
246
246
|
|
|
247
247
|
// before create awaitingStepId per graph storageResource
|
|
248
|
-
const linkTypeId = createLinkTypeId(_izContext,
|
|
248
|
+
const linkTypeId = createLinkTypeId(_izContext, firstObject.objType, secondObject.objType, relType, relationshipDirection);
|
|
249
249
|
|
|
250
250
|
let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
|
|
251
251
|
let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
|
|
@@ -108,12 +108,13 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
108
108
|
let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
|
|
109
109
|
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
|
|
110
110
|
{
|
|
111
|
-
|
|
111
|
+
firstObject: event.firstObject,
|
|
112
|
+
secondObject: event.secondObject,
|
|
112
113
|
relType: event.relType,
|
|
113
|
-
|
|
114
|
+
relationshipDirection: event.relationshipDirection,
|
|
114
115
|
relationshipProperties: event.relationshipProperties,
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
},
|
|
117
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
117
118
|
);
|
|
118
119
|
|
|
119
120
|
// return error to client
|
|
@@ -104,10 +104,11 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
104
104
|
return await <%- functionName %>.<%- functionName %>(
|
|
105
105
|
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
|
|
106
106
|
{
|
|
107
|
-
|
|
107
|
+
firstObject: event.firstObject,
|
|
108
|
+
secondObject: event.secondObject,
|
|
108
109
|
relType: event.relType,
|
|
110
|
+
relationshipDirection: event.relationshipDirection,
|
|
109
111
|
relationshipProperties: event.relationshipProperties,
|
|
110
|
-
relationshipDirection: event.relationshipDirection
|
|
111
112
|
},
|
|
112
113
|
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
113
114
|
);
|