@izara_project/izara-market-library-service-schemas 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +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 +55 -12
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/data.js +86 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/data.js +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/template.ejs +130 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/template.ejs +47 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +15 -7
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +14 -6
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +14 -4
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +14 -4
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/data.js +171 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/request.json +19 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/template.ejs +29 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/data.js +60 -0
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/template.ejs +10 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/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 +16 -26
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/template.ejs +4 -0
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +2 -1
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +1 -5
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +1 -5
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +11 -7
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/template.ejs +4 -0
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrApi/template.ejs +5 -4
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrInv/template.ejs +3 -2
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/mainFunction/template.ejs +16 -13
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +9 -6
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/template.ejs +4 -0
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +8 -5
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +10 -8
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/{awaitingMultipleStepData.js → defaultDynamoDbTable.js} +39 -3
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +6 -3
- package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +1 -1
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +5 -10
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +14 -0
- package/src/TemplateManager/src/flowTag/resources/dynamoDb/data.js +65 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/data.js +56 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/template.ejs +10 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/data.js +55 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/template.ejs +63 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/data.js +75 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/data.js +57 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/template.ejs +131 -0
- package/src/TemplateManager/src/libs/Consts.js +7 -2
- package/src/TemplateManager/src/libs/GenerateCodeUtils.js +3 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +0 -99
|
@@ -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,25 +74,24 @@ 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")
|
|
91
80
|
}
|
|
92
81
|
|
|
93
|
-
const OBJECT_TYPE = "
|
|
82
|
+
const OBJECT_TYPE = "Address"
|
|
94
83
|
const SERVICE_TAG = process.env.iz_serviceTag;
|
|
95
84
|
//(<beforeQuery>)
|
|
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,
|
|
@@ -131,8 +120,8 @@ module.exports.<%- functionName %>Main = async (
|
|
|
131
120
|
objInstanceFull: {
|
|
132
121
|
identifiers: identifiers,
|
|
133
122
|
fields: fields,
|
|
134
|
-
versionedDatas: versionedDatas
|
|
135
123
|
},
|
|
124
|
+
versionedDataIds: versionedDataIds,
|
|
136
125
|
status: 'error',
|
|
137
126
|
errorFounds: errorFounds
|
|
138
127
|
};
|
|
@@ -169,7 +158,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
169
158
|
serviceTag: SERVICE_TAG,
|
|
170
159
|
identifiers: identifiers,
|
|
171
160
|
fields: fields,
|
|
172
|
-
versionedDatas: versionedDatas
|
|
173
161
|
// correlationIds: _izContext.correlationIds.get("id")
|
|
174
162
|
}),
|
|
175
163
|
PREFIX.updateNode
|
|
@@ -186,7 +174,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
186
174
|
{
|
|
187
175
|
identifiers,
|
|
188
176
|
fields,
|
|
189
|
-
versionedDatas: versionedDatas
|
|
190
177
|
})
|
|
191
178
|
)
|
|
192
179
|
)
|
|
@@ -201,8 +188,8 @@ module.exports.<%- functionName %>Main = async (
|
|
|
201
188
|
objInstanceFull: {
|
|
202
189
|
identifiers: identifiers,
|
|
203
190
|
fields: fields,
|
|
204
|
-
versionedDatas: versionedDatas
|
|
205
191
|
},
|
|
192
|
+
versionedDataIds: versionedDataIds,
|
|
206
193
|
originTimestamp
|
|
207
194
|
}
|
|
208
195
|
|
|
@@ -230,7 +217,7 @@ module.exports.<%- functionName %>Main = async (
|
|
|
230
217
|
let resSNS = await sns.publishAsync(_izContext, updateNodeMessageBody)
|
|
231
218
|
_izContext.logger.debug('resSNS send to topic InUpdateNode finish!', resSNS);
|
|
232
219
|
|
|
233
|
-
} else {
|
|
220
|
+
} else if (updateDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
234
221
|
|
|
235
222
|
let identifiersForUpdateData = await dynamoDbIdentifiersByStorageResource(
|
|
236
223
|
_izContext,
|
|
@@ -238,14 +225,17 @@ module.exports.<%- functionName %>Main = async (
|
|
|
238
225
|
updateDataDetail,
|
|
239
226
|
identifiers
|
|
240
227
|
)
|
|
228
|
+
|
|
229
|
+
let fieldForUpdateTableDynamo = createFieldForUpdateDynamoDb(_izContext, objectSchema, updateDataDetail, fields)
|
|
230
|
+
|
|
241
231
|
_izContext.logger.debug("identifiersForUpdateData", identifiersForUpdateData)
|
|
242
|
-
_izContext.logger.debug("
|
|
232
|
+
_izContext.logger.debug("fieldForUpdateTableDynamo", fieldForUpdateTableDynamo)
|
|
243
233
|
|
|
244
234
|
await dynamodbSharedLib.updateItem(
|
|
245
235
|
_izContext,
|
|
246
236
|
await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName),
|
|
247
237
|
identifiersForUpdateData,
|
|
248
|
-
|
|
238
|
+
fieldForUpdateTableDynamo
|
|
249
239
|
)
|
|
250
240
|
}
|
|
251
241
|
}
|
|
@@ -260,14 +250,14 @@ module.exports.<%- functionName %>Main = async (
|
|
|
260
250
|
objInstanceFull: {
|
|
261
251
|
identifiers: identifiers,
|
|
262
252
|
fields: fields,
|
|
263
|
-
|
|
264
|
-
|
|
253
|
+
},
|
|
254
|
+
versionedDataIds: versionedDataIds
|
|
265
255
|
},
|
|
266
256
|
status: "complete",
|
|
267
257
|
errorFounds
|
|
268
258
|
}
|
|
269
259
|
} catch (err) {
|
|
270
|
-
_izContext.logger.error('error
|
|
260
|
+
_izContext.logger.error('error AddressUpdate: ', err)
|
|
271
261
|
throw (err)
|
|
272
262
|
}
|
|
273
263
|
}
|
|
@@ -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 %>
|
|
@@ -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
|
);
|
|
@@ -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(
|
|
@@ -93,22 +92,23 @@ module.exports.createRelationshipComplete = async (
|
|
|
93
92
|
)) {
|
|
94
93
|
_izContext.logger.debug("finished all awaitingStep");
|
|
95
94
|
|
|
96
|
-
let
|
|
97
|
-
|
|
95
|
+
let deleteRelComp = {
|
|
96
|
+
firstObject: returnValue.firstObject,
|
|
97
|
+
secondObject: returnValue.secondObject,
|
|
98
98
|
relType: returnValue.relType,
|
|
99
99
|
relationshipProperties: returnValue.relationshipProperties,
|
|
100
100
|
status: status,
|
|
101
101
|
errorFounds: errorsFound
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
_izContext.logger.debug("After addCallingFlowToSnsResponseMessageObject",
|
|
104
|
+
deleteRelComp = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, deleteRelComp);
|
|
105
|
+
_izContext.logger.debug("After addCallingFlowToSnsResponseMessageObject", deleteRelComp);
|
|
106
106
|
|
|
107
107
|
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
|
|
108
|
-
_izContext.logger.debug("After addCallingFlowToSnsResponseMessageAttributes",
|
|
108
|
+
_izContext.logger.debug("After addCallingFlowToSnsResponseMessageAttributes", deleteRelComp);
|
|
109
109
|
|
|
110
110
|
let sendMessageToOutCreateRelatonshipComplete = {
|
|
111
|
-
Message: JSON.stringify(
|
|
111
|
+
Message: JSON.stringify(deleteRelComp),
|
|
112
112
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
113
113
|
TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
|
|
114
114
|
};
|
|
@@ -128,8 +128,11 @@ module.exports.createRelationshipComplete = async (
|
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
return {
|
|
132
|
-
|
|
131
|
+
return {
|
|
132
|
+
returnValue,
|
|
133
|
+
status,
|
|
134
|
+
errorsFound
|
|
135
|
+
}
|
|
133
136
|
} catch (err) {
|
|
134
137
|
_izContext.logger.error('error createRelationshipComplete:', err)
|
|
135
138
|
throw (err)
|
|
@@ -57,11 +57,10 @@ module.exports.updateRelationshipComplete = async (
|
|
|
57
57
|
// start create awaitingStepId
|
|
58
58
|
const linkTypeId = createLinkTypeId(
|
|
59
59
|
_izContext,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
returnValue.relType
|
|
60
|
+
returnValue.firstObject.objType,
|
|
61
|
+
returnValue.secondObject.objType,
|
|
62
|
+
returnValue.relType,
|
|
63
|
+
returnValue.direction
|
|
65
64
|
);
|
|
66
65
|
|
|
67
66
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
@@ -131,7 +130,11 @@ module.exports.updateRelationshipComplete = async (
|
|
|
131
130
|
);
|
|
132
131
|
|
|
133
132
|
|
|
134
|
-
return {
|
|
133
|
+
return {
|
|
134
|
+
returnValue,
|
|
135
|
+
status,
|
|
136
|
+
errorsFound
|
|
137
|
+
}
|
|
135
138
|
|
|
136
139
|
} catch (err) {
|
|
137
140
|
_izContext.logger.error('error updateRelationshipComplete:', 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 %>
|