@izara_project/izara-market-library-service-schemas 1.0.60 → 1.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/GenerateCodeLibs/src/Consts.js +7 -3
- package/src/MainLibs/src/Consts.js +7 -2
- package/src/reStructure/GenerateCode.js +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +24 -61
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -3
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +141 -105
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +8 -0
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +11 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +0 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +13 -9
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +1 -0
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +44 -35
- package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +7 -2
- package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +12 -4
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +14 -5
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +123 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +122 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/template.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +123 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/template.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +123 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/template.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/data.js +57 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/template.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/data.js +58 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/template.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/template.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/template.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +382 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/data.js +77 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +121 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/data.js +60 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/template.ejs +129 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/template.ejs +154 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/template.ejs +46 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/template.ejs +10 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +55 -2
package/package.json
CHANGED
|
@@ -25,7 +25,8 @@ const PREFIX = {
|
|
|
25
25
|
deleteRel: "deleteRelationshipEndpoint",
|
|
26
26
|
updateNode: "updateNodeEndpoint",
|
|
27
27
|
createNode: "createNodeEndpoint",
|
|
28
|
-
getRel: "getRelationshipEndpoint"
|
|
28
|
+
getRel: "getRelationshipEndpoint",
|
|
29
|
+
changeRel: "changeRelationshipEndpoint"
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
// const TOPIC_NAME_GRAPH_HANDLER = {
|
|
@@ -55,7 +56,9 @@ const TOPIC_NAME_GRAPH_HANDLER = {
|
|
|
55
56
|
inCreateNode: "CreateNode_In",
|
|
56
57
|
outCreateNode: "CreateNode_Out",
|
|
57
58
|
inDeleteNode: "DeleteNode_In",
|
|
58
|
-
outDeleteNode: "DeleteNode_Out"
|
|
59
|
+
outDeleteNode: "DeleteNode_Out",
|
|
60
|
+
inChangeRelationship: "ChangeRelationshipType_In",
|
|
61
|
+
outChangeRelationship: "ChangeRelationshipType_Out"
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
const TOPIC_NAME_GENERATE_CODE = {
|
|
@@ -79,7 +82,8 @@ const TOPIC_NAME_GENERATE_CODE = {
|
|
|
79
82
|
createPresignUrl: "CreatePresignUrl",
|
|
80
83
|
flowSchemaOwnTopicComplete: "FlowSchemaOwnTopicComplete",
|
|
81
84
|
flowSchemaOwnTopicEndpointComplete: "FlowSchemaOwnTopicEndpointComplete",
|
|
82
|
-
createRecordComplete: "CreateRecordComplete"
|
|
85
|
+
createRecordComplete: "CreateRecordComplete",
|
|
86
|
+
changeRelationshipComplete: "ChangeRelationshipComplete"
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
const GRAPH_HANDLER_SERVICE_NAME = {
|
|
@@ -30,7 +30,7 @@ const { getGraphServiceNameFromGraphServerTagWithCache, getGraphServiceTagWithCa
|
|
|
30
30
|
|
|
31
31
|
const DEFAULT_HANDLER_PER_ACTION = {
|
|
32
32
|
[ACTIONS.create]: [HANDLER.hdrApi, HANDLER.hdrSqs, HANDLER.hdrInv],
|
|
33
|
-
[ACTIONS.update]: [HANDLER.hdrApi, HANDLER.hdrSqs],
|
|
33
|
+
[ACTIONS.update]: [HANDLER.hdrApi, HANDLER.hdrSqs, HANDLER.hdrInv],
|
|
34
34
|
[ACTIONS.get]: [HANDLER.hdrApi, HANDLER.hdrInv],
|
|
35
35
|
[ACTIONS.delete]: [HANDLER.hdrApi, HANDLER.hdrSqs]
|
|
36
36
|
}
|
|
@@ -285,6 +285,8 @@ const FUNCTION_NAME = {
|
|
|
285
285
|
flowSchemaEventBridge: "EventBridge",
|
|
286
286
|
createRecordComplete: "createRecordComplete",
|
|
287
287
|
flowSchemaRegister: "register",
|
|
288
|
+
changeRel: "changeRelationship",
|
|
289
|
+
changeRelComplete: "changeRelationshipComplete"
|
|
288
290
|
};
|
|
289
291
|
|
|
290
292
|
const SHORT_FUNCTION_NAME = {
|
|
@@ -307,7 +309,9 @@ const SHORT_FUNCTION_NAME = {
|
|
|
307
309
|
deleteNodeComplete: "deleteNodeComp",
|
|
308
310
|
createObjectS3Complete: "webSocketTaskComp",
|
|
309
311
|
getRel: "getRel",
|
|
310
|
-
getRelComplete: "getRelComp"
|
|
312
|
+
getRelComplete: "getRelComp",
|
|
313
|
+
changeRel: "changeRel",
|
|
314
|
+
changeRelComplete: "changeRelComp"
|
|
311
315
|
}
|
|
312
316
|
|
|
313
317
|
const getGraphServiceNameFromAllRelSchema = async (_izContext, allRelSchemas, settings = { bucketName: OBJECT_SCHEMA_BUCKET_NAME }) => {
|
|
@@ -566,6 +570,7 @@ const FLOW_SCHEMA_EVENT_TYPE = {
|
|
|
566
570
|
}
|
|
567
571
|
|
|
568
572
|
module.exports = {
|
|
573
|
+
STORAGE_TYPES,
|
|
569
574
|
ACTIONS,
|
|
570
575
|
DEFAULT_HANDLER_PER_ACTION,
|
|
571
576
|
RESOURCE_CLASSES,
|
|
@@ -67,7 +67,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath, settings = {}
|
|
|
67
67
|
for (const templateName in templateConfig.TemplateAndData) {
|
|
68
68
|
// Display log indicating which template is being loaded
|
|
69
69
|
// console.log('Loading template:', templateName);
|
|
70
|
-
|
|
70
|
+
console.log("templateName", templateName)
|
|
71
71
|
let generateTemplateData = require(join(__dirname, templateConfig.TemplateAndData[templateName]));
|
|
72
72
|
let createSourceResult = await generateTemplateData(_izContext, objSchemaPath, settings);
|
|
73
73
|
|
|
@@ -31,7 +31,7 @@ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-
|
|
|
31
31
|
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
32
32
|
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
33
33
|
const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
|
|
34
|
-
|
|
34
|
+
const { createRandomIdentifier } = require('@izara_project/izara-core-library-core').IdentifierLib
|
|
35
35
|
// ──────────────────────── Middleware / External ────────────────────────
|
|
36
36
|
const middlewareConsts = require('@izara_project/izara-middleware').consts;
|
|
37
37
|
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
@@ -170,31 +170,14 @@ module.exports.createMain = async (
|
|
|
170
170
|
_izContext.logger.debug(":::::case single identifier:::::", identifier);
|
|
171
171
|
|
|
172
172
|
if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate") && (objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == true)) {
|
|
173
|
-
Object.assign(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
Object.assign(
|
|
174
|
+
requestParams.fieldNames, {
|
|
175
|
+
[identifier.fieldName]: await createRandomIdentifier(
|
|
176
|
+
_izContext,
|
|
177
|
+
objType
|
|
178
|
+
)
|
|
179
179
|
});
|
|
180
180
|
_izContext.logger.debug("Assign requestParams", requestParams)
|
|
181
|
-
|
|
182
|
-
} else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate") && objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false ||
|
|
183
|
-
objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == null) {
|
|
184
|
-
|
|
185
|
-
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
|
|
186
|
-
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
|
|
187
|
-
// check Fns have receive
|
|
188
|
-
|
|
189
|
-
if (requestParams.fieldNames.hasOwnProperty([identifier.fieldName])) {
|
|
190
|
-
_izContext.logger.debug("identifier is exist:", {
|
|
191
|
-
[identifier.fieldName]: requestParams.fieldNames[identifier.fieldName]
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
} else {
|
|
195
|
-
errorsFound.push("[invalid]requestParams not have data fieldNames of requiredOnCreate");
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
181
|
} else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("hashOnCreate")) {
|
|
199
182
|
let hashFieldName = {}
|
|
200
183
|
if (objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length &&
|
|
@@ -225,6 +208,22 @@ module.exports.createMain = async (
|
|
|
225
208
|
}
|
|
226
209
|
)
|
|
227
210
|
}
|
|
211
|
+
} else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate") && objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false ||
|
|
212
|
+
objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == null) {
|
|
213
|
+
|
|
214
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
|
|
215
|
+
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
|
|
216
|
+
// check Fns have receive
|
|
217
|
+
|
|
218
|
+
if (requestParams.fieldNames.hasOwnProperty([identifier.fieldName])) {
|
|
219
|
+
_izContext.logger.debug("identifier is exist:", {
|
|
220
|
+
[identifier.fieldName]: requestParams.fieldNames[identifier.fieldName]
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
} else {
|
|
224
|
+
errorsFound.push("[invalid]requestParams not have data fieldNames of requiredOnCreate");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
228
227
|
} else {
|
|
229
228
|
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate === false) &&
|
|
230
229
|
(objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate === false) &&
|
|
@@ -365,46 +364,11 @@ module.exports.createMain = async (
|
|
|
365
364
|
_izContext.logger.debug("FIRST", listOfObjectForCreates)
|
|
366
365
|
|
|
367
366
|
}
|
|
368
|
-
|
|
369
|
-
if (objectSchema.hasOwnProperty("extendObjType")) {
|
|
370
|
-
if (createDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB &&
|
|
371
|
-
createDataDetail.tableName.includes(`${firstLetterUpperCase(objectSchema.extendObjType.objectType)}Records`) &&
|
|
372
|
-
createDataDetail.serviceTag !== process.env.iz_serviceTag
|
|
373
|
-
) {
|
|
374
|
-
let objInstanceFullForParentDynamoDb = lodash.cloneDeep(objInstanceFull)
|
|
375
|
-
Object.assign(objInstanceFullForParentDynamoDb.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
|
|
376
|
-
_izContext.logger.debug("objInstanceFull before create item in dynamoDB in parent", objInstanceFullForParentDynamoDb)
|
|
377
|
-
|
|
378
|
-
Object.assign(objInstanceFullForParentDynamoDb.fields, { [`${objectSchema.extendObjType.objectType}HandlerServiceTag`]: process.env.iz_serviceTag })
|
|
379
|
-
|
|
380
|
-
let identifiersForCreateData = await dynamoDbIdentifiersByStorageResource(
|
|
381
|
-
_izContext,
|
|
382
|
-
objectSchema,
|
|
383
|
-
createDataDetails,
|
|
384
|
-
objInstanceFullForParentDynamoDb.identifiers
|
|
385
|
-
)
|
|
386
|
-
_izContext.logger.debug("identifiersForCreateData", identifiersForCreateData);
|
|
387
|
-
|
|
388
|
-
await dynamodbSharedLib.putItem(
|
|
389
|
-
_izContext,
|
|
390
|
-
await dynamodbSharedLib.tableName(
|
|
391
|
-
_izContext,
|
|
392
|
-
createDataDetail.tableName,
|
|
393
|
-
createDataDetail.serviceTag
|
|
394
|
-
),
|
|
395
|
-
{
|
|
396
|
-
...identifiersForCreateData,
|
|
397
|
-
...objInstanceFullForParentDynamoDb.fields
|
|
398
|
-
}
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
367
|
};
|
|
403
368
|
_izContext.logger.debug("[1]listOfObjectForCreates:::", listOfObjectForCreates);
|
|
404
369
|
};
|
|
405
370
|
|
|
406
371
|
function createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail) {
|
|
407
|
-
_izContext.logger.debug("createObjInstanceFullFieldsByStorageTag : ", { storageTag, createDataDetail })
|
|
408
372
|
let fields = {};
|
|
409
373
|
for (let fieldName of Object.keys(requestParams.fieldNames)) {
|
|
410
374
|
if ((createDataDetails[storageTag].fieldNames.includes(fieldName)) &&
|
|
@@ -418,7 +382,6 @@ module.exports.createMain = async (
|
|
|
418
382
|
}
|
|
419
383
|
}
|
|
420
384
|
}
|
|
421
|
-
_izContext.logger.debug({ fields })
|
|
422
385
|
return fields
|
|
423
386
|
}
|
|
424
387
|
/// step save awaitingMultipleStep of storageType graph ...........................................................
|
|
@@ -469,7 +432,7 @@ module.exports.createMain = async (
|
|
|
469
432
|
objInstanceFullForGraph,
|
|
470
433
|
requestParams.relationships || [],
|
|
471
434
|
Date.now(),
|
|
472
|
-
{ updatePropertiesOnMatch: false }
|
|
435
|
+
{ updatePropertiesOnMatch: false }
|
|
473
436
|
)
|
|
474
437
|
return createNodeResult
|
|
475
438
|
|
|
@@ -103,9 +103,9 @@ module.exports.getMain = async (
|
|
|
103
103
|
|
|
104
104
|
const errorsFound = [];
|
|
105
105
|
|
|
106
|
-
const returnSystemFieldsName = requestParams.
|
|
107
|
-
const throwWhenNotFoundSomeRecord = requestParams.
|
|
108
|
-
const returnVersionedData = requestParams.
|
|
106
|
+
const returnSystemFieldsName = requestParams.additionalParams?.setting?.returnSystemFieldsName ?? false;
|
|
107
|
+
const throwWhenNotFoundSomeRecord = requestParams.additionalParams?.setting?.throwWhenNotFoundSomeRecord ?? true;
|
|
108
|
+
const returnVersionedData = requestParams.additionalParams?.setting?.returnVersionedData ?? true
|
|
109
109
|
|
|
110
110
|
//(<beforeQuery>)
|
|
111
111
|
//(</beforeQuery>)
|
|
@@ -17,12 +17,11 @@ along with this program. If not, see
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
|
-
|
|
20
|
+
const lodash = require('lodash')
|
|
21
21
|
// ==================== Shared Core Utilities ====================
|
|
22
22
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
23
23
|
const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
|
|
24
24
|
|
|
25
|
-
|
|
26
25
|
// ==================== Core Service Schemas ====================
|
|
27
26
|
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
28
27
|
const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
@@ -89,6 +88,9 @@ module.exports.updateMain = async (
|
|
|
89
88
|
callingFlowConfig
|
|
90
89
|
});
|
|
91
90
|
|
|
91
|
+
const returnSystemFieldsName = requestParams?.additionalParams?.settings?.returnSystemFieldsName ?? false;
|
|
92
|
+
const returnOldData = requestParams?.additionalParams?.settings?.returnOldData ?? false;
|
|
93
|
+
|
|
92
94
|
let errorsFound = [];
|
|
93
95
|
|
|
94
96
|
const objType = createObjType(requestParams.objectType);
|
|
@@ -130,7 +132,7 @@ module.exports.updateMain = async (
|
|
|
130
132
|
let updateDataDetails = await createUpdateDataDetail(
|
|
131
133
|
_izContext,
|
|
132
134
|
objectSchema,
|
|
133
|
-
|
|
135
|
+
);
|
|
134
136
|
|
|
135
137
|
_izContext.logger.debug("updateDataDetails", updateDataDetails);
|
|
136
138
|
|
|
@@ -216,6 +218,24 @@ module.exports.updateMain = async (
|
|
|
216
218
|
}
|
|
217
219
|
|
|
218
220
|
let awaitingStepIds = [];
|
|
221
|
+
let updateItem;
|
|
222
|
+
function createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, updateDataDetail) {
|
|
223
|
+
let fields = {};
|
|
224
|
+
for (let fieldName of Object.keys(requestParams.objInstanceFull.fields)) {
|
|
225
|
+
console.log("updateDataDetail[storageTag]", updateDataDetails[storageTag])
|
|
226
|
+
if ((updateDataDetails[storageTag].fieldNames.includes(fieldName)) &&
|
|
227
|
+
(updateDataDetail.fieldNames.includes(fieldName))) {
|
|
228
|
+
if (!identifiers.hasOwnProperty(fieldName)) {
|
|
229
|
+
if (!fields.hasOwnProperty(fieldName)) {
|
|
230
|
+
Object.assign(fields, {
|
|
231
|
+
[fieldName]: requestParams.objInstanceFull.fields[fieldName]
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return fields
|
|
238
|
+
}
|
|
219
239
|
|
|
220
240
|
// start update data
|
|
221
241
|
await Promise.all(
|
|
@@ -224,71 +244,82 @@ module.exports.updateMain = async (
|
|
|
224
244
|
if (updateDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
225
245
|
// let graphServiceName = await getGraphServiceTagWithCache(_izContext, getDataDetail.graphServiceTag)
|
|
226
246
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
hash({
|
|
230
|
-
objectType: objType.objectType,
|
|
231
|
-
serviceTag: objType.serviceTag,
|
|
232
|
-
identifiers: identifiers,
|
|
233
|
-
fields: fields,
|
|
234
|
-
// correlationIds: _izContext.correlationIds.get("id")
|
|
235
|
-
}),
|
|
236
|
-
PREFIX.updateNode
|
|
237
|
-
)
|
|
238
|
-
)
|
|
239
|
-
_izContext.logger.debug("awaitingStepIds", awaitingStepIds)
|
|
240
|
-
|
|
241
|
-
if (awaitingStepIds.length) {
|
|
242
|
-
let awaitingMultipleStep = await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
243
|
-
_izContext,
|
|
244
|
-
awaitingStepIds,
|
|
245
|
-
asyncFlowSharedLib.createPendingStepId(
|
|
246
|
-
hash(
|
|
247
|
-
{
|
|
248
|
-
identifiers,
|
|
249
|
-
fields,
|
|
250
|
-
})
|
|
251
|
-
)
|
|
252
|
-
)
|
|
253
|
-
_izContext.logger.debug("awaitingMultipleStep", awaitingMultipleStep)
|
|
254
|
-
}
|
|
247
|
+
//(<beforeUpdateGraph>)
|
|
248
|
+
//(</beforeUpdateGraph>)
|
|
255
249
|
|
|
256
250
|
let updateNodeParams = {
|
|
257
251
|
objType: objType,
|
|
258
252
|
objInstanceFull: {
|
|
259
253
|
identifiers: identifiers,
|
|
260
|
-
fields:
|
|
254
|
+
fields: createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, updateDataDetail),
|
|
261
255
|
},
|
|
262
256
|
versionedDataIds: versionedDataIds,
|
|
263
|
-
originTimestamp
|
|
257
|
+
originTimestamp,
|
|
258
|
+
settings: {
|
|
259
|
+
returnSystemFieldsName: returnSystemFieldsName,
|
|
260
|
+
returnOldData: returnOldData
|
|
261
|
+
}
|
|
264
262
|
}
|
|
265
263
|
|
|
266
|
-
updateNodeParams
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
264
|
+
if (Object.keys(updateNodeParams.objInstanceFull.fields).length === 0) {
|
|
265
|
+
return
|
|
266
|
+
} else {
|
|
267
|
+
|
|
268
|
+
awaitingStepIds.push( // createAwaitingStepId if updateGraph
|
|
269
|
+
asyncFlowSharedLib.createAwaitingStepId(
|
|
270
|
+
hash({
|
|
271
|
+
objectType: objType.objectType,
|
|
272
|
+
serviceTag: objType.serviceTag,
|
|
273
|
+
identifiers: identifiers,
|
|
274
|
+
fields: fields,
|
|
275
|
+
// correlationIds: _izContext.correlationIds.get("id")
|
|
276
|
+
}),
|
|
277
|
+
PREFIX.updateNode
|
|
274
278
|
)
|
|
275
279
|
)
|
|
276
|
-
|
|
280
|
+
_izContext.logger.debug("awaitingStepIds", awaitingStepIds)
|
|
281
|
+
|
|
282
|
+
if (awaitingStepIds.length) {
|
|
283
|
+
let awaitingMultipleStep = await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
284
|
+
_izContext,
|
|
285
|
+
awaitingStepIds,
|
|
286
|
+
asyncFlowSharedLib.createPendingStepId(
|
|
287
|
+
hash(
|
|
288
|
+
{
|
|
289
|
+
identifiers,
|
|
290
|
+
fields,
|
|
291
|
+
})
|
|
292
|
+
)
|
|
293
|
+
)
|
|
294
|
+
_izContext.logger.debug("awaitingMultipleStep", awaitingMultipleStep)
|
|
295
|
+
}
|
|
277
296
|
|
|
278
|
-
|
|
297
|
+
updateNodeParams = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
298
|
+
updateNodeParams,
|
|
299
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
300
|
+
callingFlowConfig,
|
|
301
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
302
|
+
//(<callingFlowProperties>)
|
|
303
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.updateNodeComplete), {}
|
|
304
|
+
//(</callingFlowProperties>)
|
|
305
|
+
)
|
|
306
|
+
)
|
|
307
|
+
)
|
|
279
308
|
|
|
309
|
+
_izContext.logger.debug("messageObject before send message:", updateNodeParams);
|
|
280
310
|
|
|
281
|
-
let updateNodeMessageBody = {
|
|
282
|
-
Message: JSON.stringify(updateNodeParams),
|
|
283
|
-
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
284
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag,)
|
|
285
|
-
}
|
|
286
311
|
|
|
287
|
-
|
|
312
|
+
let updateNodeMessageBody = {
|
|
313
|
+
Message: JSON.stringify(updateNodeParams),
|
|
314
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
315
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag)
|
|
316
|
+
}
|
|
288
317
|
|
|
289
|
-
|
|
290
|
-
_izContext.logger.debug('resSNS send to topic InUpdateNode finish!', resSNS);
|
|
318
|
+
_izContext.logger.debug('request param before send to topic InUpdateNode:::', updateNodeMessageBody);
|
|
291
319
|
|
|
320
|
+
let resSNS = await sns.publishAsync(_izContext, updateNodeMessageBody)
|
|
321
|
+
_izContext.logger.debug('resSNS send to topic InUpdateNode finish!', resSNS);
|
|
322
|
+
}
|
|
292
323
|
} else if (updateDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
293
324
|
|
|
294
325
|
let identifiersForUpdateData = await dynamoDbIdentifiersByStorageResource(
|
|
@@ -298,76 +329,81 @@ module.exports.updateMain = async (
|
|
|
298
329
|
identifiers
|
|
299
330
|
)
|
|
300
331
|
|
|
301
|
-
let fieldForUpdateTableDynamo = createFieldForUpdateDynamoDb(_izContext, objectSchema, updateDataDetail, fields)
|
|
332
|
+
// let fieldForUpdateTableDynamo = createFieldForUpdateDynamoDb(_izContext, objectSchema, updateDataDetail, fields)
|
|
302
333
|
|
|
303
334
|
_izContext.logger.debug("identifiersForUpdateData", identifiersForUpdateData)
|
|
304
|
-
_izContext.logger.debug("fieldForUpdateTableDynamo", fieldForUpdateTableDynamo)
|
|
335
|
+
// _izContext.logger.debug("fieldForUpdateTableDynamo", fieldForUpdateTableDynamo)
|
|
305
336
|
|
|
306
337
|
//(<beforeUpdateDynamoDb>)
|
|
307
338
|
//(</beforeUpdateDynamoDb>)
|
|
339
|
+
let fields = createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, updateDataDetail)
|
|
340
|
+
if (Object.keys(fields).length === 0) {
|
|
341
|
+
return
|
|
342
|
+
} else {
|
|
343
|
+
updateItem = await dynamodbSharedLib.updateItem(
|
|
344
|
+
_izContext,
|
|
345
|
+
await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName, updateDataDetail.serviceTag),
|
|
346
|
+
identifiersForUpdateData,
|
|
308
347
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (awaitingStepIds.length == 0) {
|
|
321
|
-
let messageObject = {
|
|
322
|
-
objType: objType,
|
|
323
|
-
updateItem
|
|
324
|
-
}
|
|
348
|
+
{
|
|
349
|
+
returnValues: "ALL_NEW"
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
_izContext.logger.debug("updateItem:", updateItem);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
)
|
|
357
|
+
)
|
|
325
358
|
|
|
326
|
-
|
|
327
|
-
|
|
359
|
+
function createObjInstanceFullFromParams(object, requestParams) {
|
|
360
|
+
let objInstanceFull = {
|
|
361
|
+
identifiers: {},
|
|
362
|
+
fields: {}
|
|
363
|
+
}
|
|
328
364
|
|
|
329
|
-
|
|
330
|
-
|
|
365
|
+
for (const field in object) {
|
|
366
|
+
if (requestParams.objInstanceFull.identifiers.hasOwnProperty(field)) {
|
|
367
|
+
Object.assign(objInstanceFull.identifiers, { [field]: requestParams.objInstanceFull.identifiers[field] })
|
|
368
|
+
}
|
|
331
369
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
337
|
-
TopicArn: outUpdateNodeCompleteTopic
|
|
338
|
-
}
|
|
370
|
+
if (requestParams.objInstanceFull.fields.hasOwnProperty(field)) {
|
|
371
|
+
Object.assign(objInstanceFull.fields, { [field]: requestParams.objInstanceFull.fields[field] })
|
|
372
|
+
}
|
|
373
|
+
}
|
|
339
374
|
|
|
340
|
-
|
|
341
|
-
|
|
375
|
+
return objInstanceFull
|
|
376
|
+
}
|
|
342
377
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
378
|
+
if (awaitingStepIds.length === 0) {
|
|
379
|
+
let messageObject = {
|
|
380
|
+
objType: objType,
|
|
381
|
+
objInstanceFull: createObjInstanceFullFromParams(updateItem, requestParams)
|
|
382
|
+
}
|
|
348
383
|
|
|
349
|
-
|
|
384
|
+
//(<additionalProperties>)
|
|
385
|
+
//(</additionalProperties>)
|
|
350
386
|
|
|
387
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOWPROPERTIES_PROPERTYNAME]) {
|
|
388
|
+
_izContext.logger.debug("HAVE CALLING FLOW");
|
|
351
389
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
objectSchema,
|
|
355
|
-
updateDataDetail,
|
|
356
|
-
identifiers
|
|
357
|
-
)
|
|
358
|
-
_izContext.logger.debug("identifiersForUpdateData", identifiersForUpdateData);
|
|
390
|
+
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
|
|
391
|
+
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
359
392
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
}
|
|
393
|
+
_izContext.logger.debug("after create callingFlow", messageObject)
|
|
394
|
+
let outUpdateNodeCompleteTopic = await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete);
|
|
395
|
+
let messageParams = {
|
|
396
|
+
Message: JSON.stringify(messageObject),
|
|
397
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
398
|
+
TopicArn: outUpdateNodeCompleteTopic
|
|
368
399
|
}
|
|
369
|
-
|
|
370
|
-
|
|
400
|
+
|
|
401
|
+
_izContext.logger.debug("message params OutUpdateNodeComplete :::", messageParams);
|
|
402
|
+
await sns.publishAsync(_izContext, messageParams);
|
|
403
|
+
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
371
407
|
return {
|
|
372
408
|
returnValues: {
|
|
373
409
|
objType: objType,
|
|
@@ -196,6 +196,14 @@ async function externalLambdaIamRoleRelationships(_izContext, allRelSchemas) {
|
|
|
196
196
|
graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
|
|
197
197
|
externalResourceName(RESOURCE_CLASSES.lambda, "GetRelationshipV2HdrInv", graphServiceName)
|
|
198
198
|
)
|
|
199
|
+
),
|
|
200
|
+
createIamRole(
|
|
201
|
+
{
|
|
202
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
203
|
+
},
|
|
204
|
+
graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
|
|
205
|
+
externalResourceName(RESOURCE_CLASSES.sns, "ChangeRelationshipType_In", graphServiceName)
|
|
206
|
+
)
|
|
199
207
|
)
|
|
200
208
|
)
|
|
201
209
|
}
|
|
@@ -115,7 +115,6 @@ async function snsSubscriptionCreateRelationshipComplete(_izContext, allRelSchem
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
// topic not create yet will return error when initialSetup
|
|
119
118
|
// create topic for OutUpdateNodeComplete
|
|
120
119
|
async function snsSubscriptionOutUpdateNodeComplete(_izContext, allObjSchemas) {
|
|
121
120
|
let serviceTag = await getGraphServiceNameFromObjectSchema(_izContext, allObjSchemas)
|
|
@@ -127,6 +126,17 @@ async function snsSubscriptionOutUpdateNodeComplete(_izContext, allObjSchemas) {
|
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
|
|
129
|
+
// change relationship
|
|
130
|
+
async function snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchemas) {
|
|
131
|
+
let serviceTag = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
serviceTag: serviceTag,
|
|
135
|
+
topicName: TOPIC_NAME_GRAPH_HANDLER.outChangeRelationship, // external service
|
|
136
|
+
sqsEndpoint: TOPIC_NAME_GENERATE_CODE.changeRelationshipComplete // in service
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
130
140
|
async function snsSubscriptionCreateNodeComplete(_izContext, allObjectSchemas) {
|
|
131
141
|
let serviceTag = await getGraphServiceNameFromObjectSchema(_izContext, allObjectSchemas)
|
|
132
142
|
|
|
@@ -126,7 +126,7 @@ module.exports.createPresignUrl = async (
|
|
|
126
126
|
//(</fields>)
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
|
-
|
|
129
|
+
objectType: objType.objectType
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
let sendMessageToUpdateEndpoint = {
|
|
@@ -189,8 +189,8 @@ module.exports.createPresignUrl = async (
|
|
|
189
189
|
["eq", "$x-amz-meta-importBatchId", importBatchId]
|
|
190
190
|
//(</conditionCreateUrlLink>)
|
|
191
191
|
],
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
Fields: {},
|
|
193
|
+
Expires: 86400
|
|
194
194
|
};
|
|
195
195
|
_izContext.logger.debug('createPresignUrlParam', createPresignUrlParam);
|
|
196
196
|
|
|
@@ -215,7 +215,7 @@ module.exports.createPresignUrl = async (
|
|
|
215
215
|
},
|
|
216
216
|
fields: {
|
|
217
217
|
importBatchStatus: "waitingToUpload",
|
|
218
|
-
expiryTimestamp: (getResult.fields.startTime + (createPresignUrlParam.
|
|
218
|
+
expiryTimestamp: (getResult.fields.startTime + (createPresignUrlParam.Expires * 1000))
|
|
219
219
|
}
|
|
220
220
|
},
|
|
221
221
|
objectType: objType.objectType
|
|
@@ -21,7 +21,7 @@ const path = require('path');
|
|
|
21
21
|
|
|
22
22
|
const templatePath = path.join(__dirname, "./template.ejs")
|
|
23
23
|
|
|
24
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../../MainLibs/src/Utils")
|
|
24
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, getLocalConfig } = require("../../../../../../../../MainLibs/src/Utils");
|
|
25
25
|
const {
|
|
26
26
|
HANDLER,
|
|
27
27
|
defaultIamRolePerAction,
|
|
@@ -59,6 +59,7 @@ async function data(_izContext, flowSchema, srcPath) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
62
|
+
let iz_serviceSchemaBucketName = getLocalConfig(path.join(srcPath, "../"), "iz_serviceSchemaBucketName")
|
|
62
63
|
let functionName = upperCase(FUNCTION_NAME.reservedLimit);
|
|
63
64
|
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
64
65
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
@@ -87,7 +88,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
87
88
|
|
|
88
89
|
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
89
90
|
|
|
90
|
-
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType)
|
|
91
|
+
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType, iz_serviceSchemaBucketName)
|
|
91
92
|
|
|
92
93
|
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
93
94
|
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|