@izara_project/izara-market-library-service-schemas 1.0.60 → 1.0.62
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/MainLibs/src/Consts.js +2 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +16 -53
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -3
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +36 -31
- 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/register/complete/mainFunction/template.ejs +42 -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/package.json
CHANGED
|
@@ -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
|
}
|
|
@@ -566,6 +566,7 @@ const FLOW_SCHEMA_EVENT_TYPE = {
|
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
module.exports = {
|
|
569
|
+
STORAGE_TYPES,
|
|
569
570
|
ACTIONS,
|
|
570
571
|
DEFAULT_HANDLER_PER_ACTION,
|
|
571
572
|
RESOURCE_CLASSES,
|
|
@@ -178,23 +178,6 @@ module.exports.createMain = async (
|
|
|
178
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 ...........................................................
|
|
@@ -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
|
|
|
@@ -217,6 +219,24 @@ module.exports.updateMain = async (
|
|
|
217
219
|
|
|
218
220
|
let awaitingStepIds = [];
|
|
219
221
|
|
|
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
|
+
}
|
|
239
|
+
|
|
220
240
|
// start update data
|
|
221
241
|
await Promise.all(
|
|
222
242
|
Object.entries(updateDataDetails).map(
|
|
@@ -224,6 +244,9 @@ module.exports.updateMain = async (
|
|
|
224
244
|
if (updateDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
225
245
|
// let graphServiceName = await getGraphServiceTagWithCache(_izContext, getDataDetail.graphServiceTag)
|
|
226
246
|
|
|
247
|
+
//(<beforeUpdateGraph>)
|
|
248
|
+
//(</beforeUpdateGraph>)
|
|
249
|
+
|
|
227
250
|
awaitingStepIds.push( // createAwaitingStepId if updateGraph
|
|
228
251
|
asyncFlowSharedLib.createAwaitingStepId(
|
|
229
252
|
hash({
|
|
@@ -257,10 +280,14 @@ module.exports.updateMain = async (
|
|
|
257
280
|
objType: objType,
|
|
258
281
|
objInstanceFull: {
|
|
259
282
|
identifiers: identifiers,
|
|
260
|
-
fields:
|
|
283
|
+
fields: createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, updateDataDetail),
|
|
261
284
|
},
|
|
262
285
|
versionedDataIds: versionedDataIds,
|
|
263
|
-
originTimestamp
|
|
286
|
+
originTimestamp,
|
|
287
|
+
settings: {
|
|
288
|
+
returnSystemFieldsName: returnSystemFieldsName,
|
|
289
|
+
returnOldData: returnOldData
|
|
290
|
+
}
|
|
264
291
|
}
|
|
265
292
|
|
|
266
293
|
updateNodeParams = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
@@ -281,7 +308,7 @@ module.exports.updateMain = async (
|
|
|
281
308
|
let updateNodeMessageBody = {
|
|
282
309
|
Message: JSON.stringify(updateNodeParams),
|
|
283
310
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
284
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag
|
|
311
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag)
|
|
285
312
|
}
|
|
286
313
|
|
|
287
314
|
_izContext.logger.debug('request param before send to topic InUpdateNode:::', updateNodeMessageBody);
|
|
@@ -298,10 +325,10 @@ module.exports.updateMain = async (
|
|
|
298
325
|
identifiers
|
|
299
326
|
)
|
|
300
327
|
|
|
301
|
-
let fieldForUpdateTableDynamo = createFieldForUpdateDynamoDb(_izContext, objectSchema, updateDataDetail, fields)
|
|
328
|
+
// let fieldForUpdateTableDynamo = createFieldForUpdateDynamoDb(_izContext, objectSchema, updateDataDetail, fields)
|
|
302
329
|
|
|
303
330
|
_izContext.logger.debug("identifiersForUpdateData", identifiersForUpdateData)
|
|
304
|
-
_izContext.logger.debug("fieldForUpdateTableDynamo", fieldForUpdateTableDynamo)
|
|
331
|
+
// _izContext.logger.debug("fieldForUpdateTableDynamo", fieldForUpdateTableDynamo)
|
|
305
332
|
|
|
306
333
|
//(<beforeUpdateDynamoDb>)
|
|
307
334
|
//(</beforeUpdateDynamoDb>)
|
|
@@ -310,7 +337,7 @@ module.exports.updateMain = async (
|
|
|
310
337
|
_izContext,
|
|
311
338
|
await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName, updateDataDetail.serviceTag),
|
|
312
339
|
identifiersForUpdateData,
|
|
313
|
-
|
|
340
|
+
createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, updateDataDetail),
|
|
314
341
|
{
|
|
315
342
|
returnValues: "ALL_NEW"
|
|
316
343
|
}
|
|
@@ -343,28 +370,6 @@ module.exports.updateMain = async (
|
|
|
343
370
|
}
|
|
344
371
|
}
|
|
345
372
|
}
|
|
346
|
-
if (objectSchema.hasOwnProperty("extendObjType")) {
|
|
347
|
-
if (updateDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB && updateDataDetail.serviceTag !== process.env.iz_serviceTag) {
|
|
348
|
-
|
|
349
|
-
let fieldForUpdateTableDynamo = createFieldForUpdateDynamoDb(_izContext, objectSchema, updateDataDetail, fields)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
let identifiersForUpdateData = await dynamoDbIdentifiersByStorageResource(
|
|
353
|
-
_izContext,
|
|
354
|
-
objectSchema,
|
|
355
|
-
updateDataDetail,
|
|
356
|
-
identifiers
|
|
357
|
-
)
|
|
358
|
-
_izContext.logger.debug("identifiersForUpdateData", identifiersForUpdateData);
|
|
359
|
-
|
|
360
|
-
await dynamodbSharedLib.updateItem(
|
|
361
|
-
_izContext,
|
|
362
|
-
await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName, updateDataDetail.serviceTag),
|
|
363
|
-
identifiersForUpdateData,
|
|
364
|
-
fieldForUpdateTableDynamo
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
373
|
}
|
|
369
374
|
)
|
|
370
375
|
)
|
|
@@ -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) {
|
|
@@ -57,9 +57,6 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
57
57
|
// loop each record and send to mainFunction
|
|
58
58
|
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
59
59
|
|
|
60
|
-
record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
|
|
61
|
-
record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
|
|
62
|
-
|
|
63
60
|
let passOnProperties = []
|
|
64
61
|
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
65
62
|
|
|
@@ -20,7 +20,6 @@ along with this program. If not, see
|
|
|
20
20
|
|
|
21
21
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
22
|
const { getObjectSchema, identifiersObject } = require('@izara_project/izara-core-library-service-schemas');
|
|
23
|
-
|
|
24
23
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
24
|
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
25
|
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
@@ -62,9 +61,8 @@ module.exports.registerCompleteMain = async (
|
|
|
62
61
|
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
63
62
|
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
64
63
|
|
|
65
|
-
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
|
|
66
64
|
|
|
67
|
-
if (!topicArn){
|
|
65
|
+
if (!topicArn) {
|
|
68
66
|
throw new NoRetryError("invalid not have topicArn to get flowSchema")
|
|
69
67
|
}
|
|
70
68
|
|
|
@@ -78,7 +76,24 @@ module.exports.registerCompleteMain = async (
|
|
|
78
76
|
throw new NoRetryError("not have flowSchema in S3")
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
let
|
|
79
|
+
let identifiersTask = ""
|
|
80
|
+
|
|
81
|
+
if (!requestParams.identifiersTask && flowSchema.objType) {
|
|
82
|
+
|
|
83
|
+
identifiersTask = await identifiersObject.identifiersConcatFromIdentifiers(_izContext, flowSchema.objType, requestParams)
|
|
84
|
+
_izContext.logger.debug("identifiersTask from request params", identifiersTask)
|
|
85
|
+
|
|
86
|
+
Object.assign(requestParams, {
|
|
87
|
+
identifiersTask: identifiersTask
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!requestParams.identifiersTask) {
|
|
92
|
+
_izContext.logger.warn("invalid identifiersTask")
|
|
93
|
+
return "invalid identifiersTask"
|
|
94
|
+
// throw new NoRetryError("invalid identifiersTask")
|
|
95
|
+
}
|
|
96
|
+
|
|
82
97
|
|
|
83
98
|
const getResult = async (objType) => {
|
|
84
99
|
const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
@@ -90,32 +105,29 @@ module.exports.registerCompleteMain = async (
|
|
|
90
105
|
|
|
91
106
|
_izContext.logger.debug("==> objectSchema", objectSchema)
|
|
92
107
|
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
// use object
|
|
109
|
+
let tasks = await dynamodbSharedLib.query(_izContext,
|
|
110
|
+
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
95
111
|
{
|
|
96
|
-
|
|
97
|
-
objectType: objType.objectType
|
|
112
|
+
identifiersTask: identifiersTask
|
|
98
113
|
}
|
|
99
114
|
)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
await dynamodbSharedLib.putItem(_izContext,
|
|
108
|
-
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
109
|
-
{
|
|
110
|
-
identifiersTask: requestParams.identifiersTask,
|
|
111
|
-
connectionId: connectionId
|
|
112
|
-
}
|
|
113
|
-
)
|
|
114
|
-
} else {
|
|
115
|
-
await generatedCodeLibs.postToConnection({ message: result }, connectionId)
|
|
116
|
-
}
|
|
115
|
+
|
|
116
|
+
if (tasks.Items.length > 0) {
|
|
117
|
+
const result = await externalRequest.lambda.invokeSync(_izContext,
|
|
118
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
|
|
119
|
+
{
|
|
120
|
+
identifiers: await identifiersObject.identifiersFromIdentifiersConcat(_izContext, objType, requestParams.identifiersTask),
|
|
121
|
+
objectType: objType.objectType
|
|
117
122
|
}
|
|
118
|
-
|
|
123
|
+
)
|
|
124
|
+
await Promise.all(tasks.Items.map(async (task) => {
|
|
125
|
+
if (!result) {
|
|
126
|
+
await generatedCodeLibs.postToConnection({ message: "not have record" }, task.connectionId)
|
|
127
|
+
} else {
|
|
128
|
+
await generatedCodeLibs.postToConnection({ message: result }, task.connectionId)
|
|
129
|
+
}
|
|
130
|
+
}))
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
133
|
// check statusType
|
|
@@ -126,7 +138,9 @@ module.exports.registerCompleteMain = async (
|
|
|
126
138
|
case "storedCache":
|
|
127
139
|
await getResult(flowSchema.objType);
|
|
128
140
|
break;
|
|
129
|
-
|
|
141
|
+
case "triggerCache":
|
|
142
|
+
await getResult(flowSchema.objType)
|
|
143
|
+
break;
|
|
130
144
|
case "none":
|
|
131
145
|
|
|
132
146
|
let identifier = {};
|
|
@@ -154,15 +168,8 @@ module.exports.registerCompleteMain = async (
|
|
|
154
168
|
await generatedCodeLibs.postToConnection({ message: task }, task.connectionId)
|
|
155
169
|
}))
|
|
156
170
|
await generatedCodeLibs.postToConnection({ message: tasks.Items[0] }, connectionId)
|
|
157
|
-
} else {
|
|
158
|
-
await dynamodbSharedLib.putItem(_izContext,
|
|
159
|
-
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
160
|
-
{
|
|
161
|
-
identifiersTask: hash(identifier),
|
|
162
|
-
connectionId: connectionId
|
|
163
|
-
}
|
|
164
|
-
)
|
|
165
171
|
}
|
|
172
|
+
|
|
166
173
|
break
|
|
167
174
|
default:
|
|
168
175
|
throw new NoRetryError(`statusType not found ${flowSchema.statusType}`)
|
|
@@ -20,7 +20,7 @@ along with this program. If not, see
|
|
|
20
20
|
|
|
21
21
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
22
|
const { getObjectSchema, identifiersObject } = require('@izara_project/izara-core-library-service-schemas');
|
|
23
|
-
|
|
23
|
+
const lodash = require('lodash')
|
|
24
24
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
25
|
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
26
|
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
@@ -118,6 +118,9 @@ module.exports.registerMain = async (
|
|
|
118
118
|
case "storedCache":
|
|
119
119
|
await getResult(flowSchema.objType)
|
|
120
120
|
break;
|
|
121
|
+
case "triggerCache":
|
|
122
|
+
await getResult(flowSchema.objType)
|
|
123
|
+
break;
|
|
121
124
|
case "none":
|
|
122
125
|
let identifier = {};
|
|
123
126
|
if (requestParams.hasOwnProperty("identifiersField") && Array.isArray(requestParams.identifiersField)) {
|
|
@@ -128,7 +131,9 @@ module.exports.registerMain = async (
|
|
|
128
131
|
}
|
|
129
132
|
identifier = identifier;
|
|
130
133
|
} else {
|
|
131
|
-
|
|
134
|
+
let pureRequestParams = lodash.cloneDeep(requestParams);
|
|
135
|
+
delete pureRequestParams.flowTag
|
|
136
|
+
identifier = pureRequestParams
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
// get task before putItem
|
|
@@ -21,12 +21,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
21
21
|
|
|
22
22
|
const path = require('path');
|
|
23
23
|
const fs = require('fs');
|
|
24
|
+
const lodash = require('lodash')
|
|
24
25
|
const {
|
|
25
26
|
SOURCE_PATH,
|
|
26
27
|
fieldNameSetting,
|
|
27
28
|
FIELD_NAME_TYPE,
|
|
28
29
|
PROPERTY_VALUE_TAG,
|
|
29
|
-
SAVE_FILE_NAME
|
|
30
|
+
SAVE_FILE_NAME,
|
|
31
|
+
STORAGE_TYPES
|
|
30
32
|
} = require('../../../../MainLibs/src/Consts');
|
|
31
33
|
|
|
32
34
|
const templatePath = path.join(__dirname, "./templateObjectPropertyValueSchema.ejs");
|
|
@@ -66,7 +68,13 @@ async function data(_izContext, settings, srcPath) {
|
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
const storageResources = objectSchema.storageResources; // storageResource from main objectType
|
|
69
|
-
|
|
71
|
+
let cloneDeepStorageResources = lodash.cloneDeep(storageResources)
|
|
72
|
+
for (let [storageResourceTag, storageResourceSetting] of Object.entries(cloneDeepStorageResources)) {
|
|
73
|
+
if (storageResourceSetting.storageType === STORAGE_TYPES.dynamoDB) {
|
|
74
|
+
delete cloneDeepStorageResources[storageResourceTag]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const storageResourceTags = Object.keys(cloneDeepStorageResources); // storage ResourceTag from main objectType
|
|
70
78
|
const compositeKeyDeliminator = objectSchema.compositeKeyDeliminator;
|
|
71
79
|
|
|
72
80
|
propertyValueObjectSchemas.push(
|
|
@@ -98,11 +106,11 @@ async function data(_izContext, settings, srcPath) {
|
|
|
98
106
|
|
|
99
107
|
for (let propertyValueObjectSchema of propertyValueObjectSchemas) {
|
|
100
108
|
Object.assign(propertyValueObjectSchema, {
|
|
101
|
-
storageResources:
|
|
109
|
+
storageResources: cloneDeepStorageResources, // add storageResources
|
|
102
110
|
compositeKeyDeliminator: compositeKeyDeliminator
|
|
103
111
|
})
|
|
104
112
|
for (let attributeTreeFieldName of Object.values(propertyValueObjectSchema.fieldNames)) {
|
|
105
|
-
Object.assign(attributeTreeFieldName, { storageResourceTags:
|
|
113
|
+
Object.assign(attributeTreeFieldName, { storageResourceTags: storageResourceTags }) // add storageResourceTags for each fieldName
|
|
106
114
|
}
|
|
107
115
|
};
|
|
108
116
|
for (const propertyValueObjectSchema of propertyValueObjectSchemas) {
|
package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js
CHANGED
|
@@ -19,11 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
|
|
20
20
|
const path = require('path');
|
|
21
21
|
const fs = require('fs');
|
|
22
|
+
const lodash = require('lodash')
|
|
22
23
|
const {
|
|
23
24
|
SOURCE_PATH,
|
|
24
25
|
PREFIX_RELATIONSHIP,
|
|
25
26
|
PROPERTY_VALUE_TAG,
|
|
26
|
-
SAVE_FILE_NAME
|
|
27
|
+
SAVE_FILE_NAME,
|
|
28
|
+
STORAGE_TYPES
|
|
27
29
|
} = require('../../../../MainLibs/src/Consts');
|
|
28
30
|
|
|
29
31
|
const templatePath = path.join(__dirname, "./tempRelationship.ejs");
|
|
@@ -87,7 +89,14 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
87
89
|
const attributeRelationships = [];
|
|
88
90
|
// const objectType = objectSchema.objectType; // main objectType
|
|
89
91
|
let propertyValue = settings.propertyValueTag
|
|
90
|
-
const storageResources = objectSchema.storageResources // storageResource from main objectType
|
|
92
|
+
const storageResources = objectSchema.storageResources; // storageResource from main objectType
|
|
93
|
+
let cloneDeepStorageResources = lodash.cloneDeep(storageResources)
|
|
94
|
+
for (let [storageResourceTag, storageResourceSetting] of Object.entries(cloneDeepStorageResources)) {
|
|
95
|
+
if (storageResourceSetting.storageType === STORAGE_TYPES.dynamoDB) {
|
|
96
|
+
delete cloneDeepStorageResources[storageResourceTag]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
91
100
|
const serviceTag = getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag")
|
|
92
101
|
attributeRelationships.push(
|
|
93
102
|
{ // has{objectType}propertyValue
|
|
@@ -105,7 +114,7 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
105
114
|
linkType: "many",
|
|
106
115
|
requiredOnCreate: true
|
|
107
116
|
},
|
|
108
|
-
|
|
117
|
+
cloneDeepStorageResources,
|
|
109
118
|
"from"
|
|
110
119
|
)
|
|
111
120
|
},
|
|
@@ -125,7 +134,7 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
125
134
|
linkType: "many",
|
|
126
135
|
requiredOnCreate: false
|
|
127
136
|
},
|
|
128
|
-
|
|
137
|
+
cloneDeepStorageResources,
|
|
129
138
|
"from"
|
|
130
139
|
)
|
|
131
140
|
},
|
|
@@ -145,7 +154,7 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
145
154
|
linkType: "one",
|
|
146
155
|
requiredOnCreate: false
|
|
147
156
|
},
|
|
148
|
-
|
|
157
|
+
cloneDeepStorageResources,
|
|
149
158
|
"from"
|
|
150
159
|
)
|
|
151
160
|
}
|