@izara_project/izara-market-library-service-schemas 1.0.59 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.59",
3
+ "version": "1.0.62",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,11 +24,11 @@
24
24
  "@izara_project/izara-core-library-core": "^1.0.20",
25
25
  "@izara_project/izara-core-library-external-request": "^1.0.20",
26
26
  "@izara_project/izara-core-library-logger": "^1.0.7",
27
- "@izara_project/izara-core-library-service-schemas": "^1.0.84",
27
+ "@izara_project/izara-core-library-service-schemas": "^1.0.90",
28
28
  "@izara_project/izara-core-library-sns": "^1.0.6",
29
29
  "@izara_project/izara-core-library-sqs": "^1.0.4",
30
30
  "@izara_project/izara-shared": "^1.0.126",
31
- "@izara_project/izara-shared-service-schemas": "^1.0.26",
31
+ "@izara_project/izara-shared-service-schemas": "^1.0.29",
32
32
  "@izara_project/izara-shared-core": "^1.0.2",
33
33
  "ejs": "^3.1.10",
34
34
  "js-beautify": "^1.15.4",
@@ -72,7 +72,7 @@ function validateSchemaMiddleware(
72
72
  middleware,
73
73
  // objectType,
74
74
  action,
75
- bucketName = consts.OBJECT_SCHEMA_BUCKET_NAME
75
+ bucketName = process.env.iz_serviceSchemaBucketName
76
76
  // setting = {}
77
77
  ) {
78
78
 
@@ -108,7 +108,7 @@ async function validateSchemaPerRecord(
108
108
  lambdaFunctionName,
109
109
  objType,
110
110
  action,
111
- setting = { bucketName: consts.OBJECT_SCHEMA_BUCKET_NAME, specificFieldNames: [] }
111
+ setting = { bucketName: process.env.iz_serviceSchemaBucketName, specificFieldNames: [] }
112
112
  ) {
113
113
  try {
114
114
  record._izContext.logger.debug("validateSchemaPerRecord: ",
@@ -350,7 +350,7 @@ async function messageToDlq(record, messageFailError, queueUrl) {
350
350
  * @param {Object} _izContext
351
351
  * @param {Object} objectSchema
352
352
  */
353
- async function createGetDataDetails(_izContext, objectSchema, settings = { bucketName: consts.OBJECT_SCHEMA_BUCKET_NAME }) {
353
+ async function createGetDataDetails(_izContext, objectSchema, settings = { bucketName: process.env.iz_serviceSchemaBucketName }) {
354
354
 
355
355
  // group versionedData per storageTag
356
356
  // or should group versionedData per graph serviceTag
@@ -546,7 +546,7 @@ async function createGetDataDetails(_izContext, objectSchema, settings = { bucke
546
546
  * @param {Object} objectSchema
547
547
  * @param {Object} reqIdentifiers - input identifier from calling function
548
548
  */
549
- async function generateDynamoDbIdentifiers(_izContext, objectSchema, reqIdentifiers, bucketName = consts.OBJECT_SCHEMA_BUCKET_NAME) {
549
+ async function generateDynamoDbIdentifiers(_izContext, objectSchema, reqIdentifiers, bucketName = process.env.iz_serviceSchemaBucketName) {
550
550
 
551
551
  // start create identifiers for dynamo
552
552
  let dynamoIdentifiers = {};
@@ -617,7 +617,7 @@ const generateDynamoDbIdentifiersWithCache = inMemoryCacheLib(
617
617
  * @param {Object} dynamoStorageResource
618
618
  * @param {Object} reqIdentifiers
619
619
  */
620
- async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, dynamoStorageResource, reqIdentifiers, bucketName = consts.OBJECT_SCHEMA_BUCKET_NAME) {
620
+ async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, dynamoStorageResource, reqIdentifiers, bucketName = process.env.iz_serviceSchemaBucketName) {
621
621
 
622
622
  let dynamoIdentifiers = await generateDynamoDbIdentifiersWithCache(_izContext, objectSchema, reqIdentifiers, bucketName)
623
623
 
@@ -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,
@@ -169,40 +169,23 @@ module.exports.createMain = async (
169
169
  const identifier = objectSchemas.identifiers[0];
170
170
  _izContext.logger.debug(":::::case single identifier:::::", identifier);
171
171
 
172
- if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate")) {
173
- if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == true)) {
174
- Object.assign(requestParams.fieldNames, {
175
- [identifier.fieldName]: hash({
176
- fieldNames: identifier, //
177
- uniqueRequestId: _izContext.uniqueRequestId,
178
- callingFlowConfig: callingFlowConfig
179
- })
180
- });
181
- _izContext.logger.debug("Assign requestParams", requestParams)
182
-
183
- } else if (objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false ||
184
- objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == null) {
185
-
186
- if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
187
- (objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
188
- // check Fns have receive
189
-
190
- if (requestParams.fieldNames.hasOwnProperty([identifier.fieldName])) {
191
- _izContext.logger.debug("identifier is exist:", {
192
- [identifier.fieldName]: requestParams.fieldNames[identifier.fieldName]
193
- });
194
-
195
- } else {
196
- errorsFound.push("[invalid]requestParams not have data fieldNames of requiredOnCreate");
197
- }
198
- }
199
- };
172
+ if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate") && (objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == true)) {
173
+ Object.assign(requestParams.fieldNames, {
174
+ [identifier.fieldName]: hash({
175
+ fieldNames: identifier, //
176
+ uniqueRequestId: _izContext.uniqueRequestId,
177
+ callingFlowConfig: callingFlowConfig
178
+ })
179
+ });
180
+ _izContext.logger.debug("Assign requestParams", requestParams)
200
181
  } else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("hashOnCreate")) {
201
182
  let hashFieldName = {}
202
183
  if (objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length &&
203
184
  objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length > 0) {
204
185
  for (const fieldName of objectSchemas.fieldNames[identifier.fieldName].hashOnCreate) {
205
- Object.assign(hashFieldName, { [fieldName]: requestParams.fieldNames[fieldName] })
186
+ Object.assign(hashFieldName, {
187
+ [fieldName]: requestParams.fieldNames[fieldName]
188
+ })
206
189
  }
207
190
 
208
191
  Object.assign(
@@ -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.additionalRequest?.setting?.returnSystemFieldsName ?? false;
107
- const throwWhenNotFoundSomeRecord = requestParams.additionalRequest?.setting?.throwWhenNotFoundSomeRecord ?? true;
108
- const returnVersionedData = requestParams.additionalRequest?.setting?.returnVersionedData ?? true
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>)
@@ -154,7 +154,7 @@ module.exports.getMain = async (
154
154
  let graphServiceName = await getGraphServiceTagWithCache(_izContext, getDataDetail.graphServiceTag);
155
155
 
156
156
  let versionedDataLabels = [];
157
- if (!returnVersionedData) {
157
+ if (returnVersionedData) {
158
158
  if (getDataDetail.versionedDatas && Object.keys(getDataDetail.versionedDatas).length) {
159
159
  // have versionedData
160
160
  versionedDataLabels = Object.keys(getDataDetail.versionedDatas);
@@ -231,7 +231,6 @@ module.exports.getMain = async (
231
231
  let dataFromDynamoDb = await dynamodbSharedLib.getItem(
232
232
  _izContext,
233
233
  await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName, getDataDetail.serviceTag),
234
- await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName, getDataDetail.serviceTag),
235
234
  identifiersForGetData
236
235
  );
237
236
 
@@ -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: 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
- fieldForUpdateTableDynamo,
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
  )
@@ -81,7 +81,7 @@ module.exports.confirmNewReserved = async (
81
81
 
82
82
  let sendMessageToConfirmUsage = {
83
83
  Message: JSON.stringify(confirmUsageMessage),
84
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'ConfirmUsage_In', consts.EXTERNAL_SERVICE_NAME.accountLimits)
84
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, 'ConfirmUsage_In', consts.EXTERNAL_SERVICE_NAME.accountLimits)
85
85
  };
86
86
  _izContext.logger.debug("sendMessageToConfirmUsage", sendMessageToConfirmUsage);
87
87
  await sns.publishAsync(_izContext, sendMessageToConfirmUsage);
@@ -114,7 +114,7 @@ module.exports.confirmNewReserved = async (
114
114
 
115
115
  let sendMessageToUpdateEndpoint = {
116
116
  Message: JSON.stringify(sendMessageToUpdateStatus),
117
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, "Update_In")
117
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "Update_In")
118
118
  };
119
119
  _izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
120
120
  await sns.publishAsync(_izContext, sendMessageToUpdateEndpoint);
@@ -126,7 +126,7 @@ module.exports.createPresignUrl = async (
126
126
  //(</fields>)
127
127
  }
128
128
  },
129
- objType: objType.objectType
129
+ objectType: objType.objectType
130
130
  }
131
131
 
132
132
  let sendMessageToUpdateEndpoint = {
@@ -152,14 +152,22 @@ module.exports.createPresignUrl = async (
152
152
  await sns.publishAsync(_izContext, sendMessageToCancelReserved);
153
153
 
154
154
  await postToConnection({ message: "reserved has reach limit" }, connectionId)
155
+
156
+ //(<createIdentifiersForDeleteTask>)
157
+ let identifiers
158
+ //(</createIdentifiersForDeleteTask>)
155
159
  // after post message delete websocket task
156
160
  await dynamodbSharedLib.deleteItem(_izContext,
157
161
  await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
158
162
  {
159
- taskKey: correlationId,
163
+ taskKey: `${createFlowTypeConcat(_izContext, { flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
160
164
  connectionId: connectionId
161
165
  }
162
166
  )
167
+
168
+ //(<afterCancelReservedLimit>)
169
+ //(</afterCancelReservedLimit>)
170
+
163
171
  return "reserved not pass"
164
172
  }
165
173
 
@@ -181,8 +189,8 @@ module.exports.createPresignUrl = async (
181
189
  ["eq", "$x-amz-meta-importBatchId", importBatchId]
182
190
  //(</conditionCreateUrlLink>)
183
191
  ],
184
- fields: {},
185
- expires: 86400
192
+ Fields: {},
193
+ Expires: 86400
186
194
  };
187
195
  _izContext.logger.debug('createPresignUrlParam', createPresignUrlParam);
188
196
 
@@ -207,7 +215,7 @@ module.exports.createPresignUrl = async (
207
215
  },
208
216
  fields: {
209
217
  importBatchStatus: "waitingToUpload",
210
- expiryTimestamp: (getResult.startTime + (createPresignUrlParam.expires * 1000))
218
+ expiryTimestamp: (getResult.fields.startTime + (createPresignUrlParam.Expires * 1000))
211
219
  }
212
220
  },
213
221
  objectType: objType.objectType
@@ -232,11 +240,9 @@ module.exports.createPresignUrl = async (
232
240
  _izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
233
241
  await sns.publishAsync(_izContext, sendMessageToUpdateEndpoint);
234
242
 
235
-
236
- //(<createIdentifiersFlow>)
243
+ //(<createIdentifierFlow>)
237
244
  let identifiers
238
- //(</createIdentifiersFlow>)
239
-
245
+ //(</createIdentifierFlow>)
240
246
  await dynamodbSharedLib.updateItem(_izContext,
241
247
  await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
242
248
  {
@@ -248,6 +254,10 @@ module.exports.createPresignUrl = async (
248
254
  }
249
255
  )
250
256
  }
257
+
258
+ //(<mainFunctionHookCode>)
259
+ //(</mainFunctionHookCode>)
260
+
251
261
  } catch (err) {
252
262
  _izContext.logger.error('error createPresignUrl: ', err)
253
263
  throw (err)
@@ -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 correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID);
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
- const result = await externalRequest.lambda.invokeSync(_izContext,
94
- await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
108
+ // use object
109
+ let tasks = await dynamodbSharedLib.query(_izContext,
110
+ await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
95
111
  {
96
- identifiers: await identifiersObject.identifiersFromIdentifiersConcat(_izContext, objType, requestParams.identifiersTask),
97
- objectType: objType.objectType
112
+ identifiersTask: identifiersTask
98
113
  }
99
114
  )
100
- if (!result) {
101
- await generatedCodeLibs.postToConnection({ message: "not have record" }, connectionId)
102
- } else {
103
- for (const [fieldName, fieldNameSetting] of Object.entries(objectSchema.fieldNames)) {
104
- if (fieldNameSetting.hasOwnProperty("statusField") && fieldNameSetting.statusField === true) {
105
- if (result.fields[fieldName] !== "complete" && result.fields[fieldName] !== "error") {
106
- // if status is not complete or error will save data into table
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
- identifier = requestParams
134
+ let pureRequestParams = lodash.cloneDeep(requestParams);
135
+ delete pureRequestParams.flowTag
136
+ identifier = pureRequestParams
132
137
  }
133
138
 
134
139
  // get task before putItem
@@ -55,7 +55,7 @@ module.exports.updateNodeComplete = async (
55
55
  let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
56
56
  hash({
57
57
  objectType: returnValue.requestParams.objType.objectType,
58
- serviceTag: returnValue.requestParams.objType.objectType,
58
+ serviceTag: returnValue.requestParams.objType.serviceTag,
59
59
  identifiers: returnValue.requestParams.objInstanceFull.identifiers,
60
60
  fields: returnValue.requestParams.objInstanceFull.fields
61
61
  }),
@@ -83,12 +83,12 @@ module.exports.updateNodeComplete = async (
83
83
 
84
84
  let updateCompleteMsg = {
85
85
  objType: {
86
- objectType: returnValue.queryResult.objType.objectType,
87
- serviceTag: returnValue.queryResult.objType.serviceTag
86
+ objectType: returnValue.requestParams.objType.objectType,
87
+ serviceTag: returnValue.requestParams.objType.serviceTag
88
88
  },
89
89
  objInstanceFull: {
90
- identifiers: returnValue.queryResult.objInstanceFull.identifiers,
91
- fields: returnValue.queryResult.objInstanceFull.fields
90
+ identifiers: returnValue.requestParams.objInstanceFull.identifiers,
91
+ fields: returnValue.requestParams.objInstanceFull.fields
92
92
  },
93
93
  status: status,
94
94
  errorsFound: errorsFound,
@@ -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
- const storageResourceTag = Object.keys(storageResources); // storage ResourceTag from main objectType
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: storageResources, // add 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: storageResourceTag }) // add storageResourceTags for each fieldName
113
+ Object.assign(attributeTreeFieldName, { storageResourceTags: storageResourceTags }) // add storageResourceTags for each fieldName
106
114
  }
107
115
  };
108
116
  for (const propertyValueObjectSchema of propertyValueObjectSchemas) {
@@ -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
- storageResources,
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
- storageResources,
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
- storageResources,
157
+ cloneDeepStorageResources,
149
158
  "from"
150
159
  )
151
160
  }