@izara_project/izara-market-library-service-schemas 1.0.58 → 1.0.59

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.
Files changed (17) hide show
  1. package/package.json +1 -1
  2. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +23 -9
  3. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +17 -72
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +8 -32
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -2
  6. package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +2 -0
  7. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/data.js +1 -1
  8. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/template.ejs +2 -2
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +2 -2
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +31 -7
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +5 -4
  12. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +20 -2
  13. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +1 -1
  14. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/handler/template.ejs +1 -1
  15. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +29 -18
  16. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -1
  17. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +10 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.58",
3
+ "version": "1.0.59",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -198,20 +198,33 @@ module.exports.createMain = async (
198
198
  }
199
199
  };
200
200
  } else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("hashOnCreate")) {
201
+ let hashFieldName = {}
201
202
  if (objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length &&
202
203
  objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length > 0) {
203
204
  for (const fieldName of objectSchemas.fieldNames[identifier.fieldName].hashOnCreate) {
204
- Object.assign(
205
- requestParams.fieldNames, {
206
- [identifier.fieldName]: hash({
207
- [fieldName]: requestParams.fieldNames[fieldName]
208
- })
209
- }
210
- )
205
+ Object.assign(hashFieldName, { [fieldName]: requestParams.fieldNames[fieldName] })
211
206
  }
207
+
208
+ Object.assign(
209
+ requestParams.fieldNames, {
210
+ [identifier.fieldName]: hash(hashFieldName)
211
+ }
212
+ )
213
+
212
214
  } else {
213
215
  errorsFound.push("[invalid] no data to hash for create")
214
216
  }
217
+ } else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("optionalOnCreate")) {
218
+ if ((objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == true)) {
219
+ Object.assign(
220
+ requestParams.fieldNames, {
221
+ [identifier.fieldName]: hash({
222
+ //(<createIdentifiersOptionalOnCreate>)
223
+ //(</createIdentifiersOptionalOnCreate>)
224
+ })
225
+ }
226
+ )
227
+ }
215
228
  } else {
216
229
  if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate === false) &&
217
230
  (objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate === false) &&
@@ -287,7 +300,7 @@ module.exports.createMain = async (
287
300
  for (let [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
288
301
  //(<beforeCreate>)
289
302
  //(</beforeCreate>)
290
- if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB && createDataDetail.serviceTag === process.env.iz_serviceTag) {
303
+ if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
291
304
  //(<beforeCreateRecordDynamo>)
292
305
  //(</beforeCreateRecordDynamo>)
293
306
  _izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull });
@@ -308,7 +321,8 @@ module.exports.createMain = async (
308
321
  _izContext,
309
322
  await dynamodbSharedLib.tableName(
310
323
  _izContext,
311
- createDataDetail.tableName
324
+ createDataDetail.tableName,
325
+ createDataDetail.serviceTag
312
326
  ),
313
327
  {
314
328
  ...identifiersForCreateData,
@@ -154,88 +154,33 @@ module.exports.deleteMain = async (
154
154
  await sns.publishAsync(_izContext, messageParams);
155
155
 
156
156
  return deleteNodeCompleteMessage
157
- };
157
+ } else {
158
158
 
159
-
160
- for await (const [storageTag, deleteDataDetail] of Object.entries(deleteDataDetails)) {
161
- if (deleteDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
162
- _izContext.logger.debug("dynamoDb process")
163
-
164
- let identifiersForDeleteData = await dynamoDbIdentifiersByStorageResource(
165
- _izContext,
166
- objectSchema,
167
- deleteDataDetail,
168
- requestParams.identifiers
169
- )
170
-
171
- _izContext.logger.debug("identifiersForDeleteData", identifiersForDeleteData)
172
-
173
- // deleteItem in dynamo
174
- await dynamodbSharedLib.deleteItem(_izContext,
175
- await dynamodbSharedLib.tableName(_izContext, deleteDataDetail.tableName),
176
- identifiersForDeleteData
177
- );
178
-
179
- } else if (deleteDataDetail.storageType === consts.STORAGE_TYPES.graph) {
180
- _izContext.logger.debug("graph process")
181
-
182
- let deleteNodeParams = {
183
- objType: objType,
184
- identifiers: requestParams.identifiers
185
- }
186
- deleteNodeParams = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
187
- deleteNodeParams,
188
- callingFlowSharedLib.addParentCallingFlowConfig(
189
- callingFlowConfig,
190
- callingFlowSharedLib.createCallingFlowConfig(
191
- //(<callingFlowProperties>)
192
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.deleteNodeComplete), {}
193
- //(</callingFlowProperties>)
194
- )
195
- )
196
- )
197
- _izContext.logger.debug("messageObject before send message: ", deleteNodeParams);
198
-
199
- let messageAttributes;
200
-
201
- let deleteNodeMessageBody = {
202
- Message: JSON.stringify(deleteNodeParams),
203
- MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
204
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inDeleteNode, storageTag)
205
- }
206
-
207
- _izContext.logger.debug("request message params before send to IndeleteNode::", deleteNodeMessageBody);
208
-
209
- let resSns = await sns.publishAsync(_izContext, deleteNodeMessageBody)
210
- _izContext.logger.debug('reSNS send to topic InDeleteNode finish', resSns)
211
- }
212
-
213
- if (objectSchema.hasOwnProperty("extendObjType")) {
214
- if (deleteDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB && deleteDataDetail.serviceTag !== process.env.iz_serviceTag) {
159
+ for await (const [storageTag, deleteDataDetail] of Object.entries(deleteDataDetails)) {
160
+ if (deleteDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
161
+ _izContext.logger.debug("dynamoDb process")
215
162
 
216
163
  let identifiersForDeleteData = await dynamoDbIdentifiersByStorageResource(
217
164
  _izContext,
218
165
  objectSchema,
219
166
  deleteDataDetail,
220
167
  requestParams.identifiers
221
- )
222
- _izContext.logger.debug("identifiersForDeleteData", identifiersForDeleteData);
168
+ )
223
169
 
224
- await dynamodbSharedLib.deleteItem(
225
- _izContext,
226
- await dynamodbSharedLib.tableName(
227
- _izContext,
228
- deleteDataDetail.tableName,
229
- deleteDataDetail.serviceTag
230
- ),
170
+ _izContext.logger.debug("identifiersForDeleteData", identifiersForDeleteData)
171
+
172
+ // deleteItem in dynamo
173
+ await dynamodbSharedLib.deleteItem(_izContext,
174
+ await dynamodbSharedLib.tableName(_izContext, deleteDataDetail.tableName, deleteDataDetail.serviceTag),
231
175
  identifiersForDeleteData
232
- );
176
+ );
177
+
178
+ }
233
179
  }
234
- }
235
- };
180
+ };
236
181
 
237
182
 
238
- } catch (err) {
239
- throw (err)
240
- }
183
+ } catch (err) {
184
+ throw (err)
185
+ }
241
186
  }
@@ -101,9 +101,11 @@ module.exports.getMain = async (
101
101
  callingFlowConfig
102
102
  });
103
103
 
104
- const returnSystemFieldsName = requestParams.additionalRequest?.setting?.returnSystemFieldsName || false;
105
- const throwWhenNotFoundSomeRecord = requestParams.additionalRequest?.setting?.throwWhenNotFoundSomeRecord || true;
106
- const returnVersionedData = requestParams.additionalRequest?.setting?.returnVersionedData || true
104
+ const errorsFound = [];
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
107
109
 
108
110
  //(<beforeQuery>)
109
111
  //(</beforeQuery>)
@@ -151,7 +153,7 @@ module.exports.getMain = async (
151
153
  // get data from graph
152
154
  let graphServiceName = await getGraphServiceTagWithCache(_izContext, getDataDetail.graphServiceTag);
153
155
 
154
-
156
+ let versionedDataLabels = [];
155
157
  if (!returnVersionedData) {
156
158
  if (getDataDetail.versionedDatas && Object.keys(getDataDetail.versionedDatas).length) {
157
159
  // have versionedData
@@ -228,7 +230,8 @@ module.exports.getMain = async (
228
230
 
229
231
  let dataFromDynamoDb = await dynamodbSharedLib.getItem(
230
232
  _izContext,
231
- await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName),
233
+ await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName, getDataDetail.serviceTag),
234
+ await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName, getDataDetail.serviceTag),
232
235
  identifiersForGetData
233
236
  );
234
237
 
@@ -254,33 +257,6 @@ module.exports.getMain = async (
254
257
  getResults.push([dataFromDynamoDb, getDataDetail]);
255
258
 
256
259
  }
257
-
258
- if (objectSchema.hasOwnProperty("extendObjType")) {
259
- if (getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB && getDataDetail.serviceTag !== process.env.iz_serviceTag) {
260
-
261
- let identifiersForGetData = await dynamoDbIdentifiersByStorageResource(
262
- _izContext,
263
- objectSchema,
264
- getDataDetail,
265
- requestParams.identifiers
266
- )
267
- _izContext.logger.debug("identifiersForGetData", identifiersForGetData);
268
-
269
- let getParent = await dynamodbSharedLib.getItem(
270
- _izContext,
271
- await dynamodbSharedLib.tableName(
272
- _izContext,
273
- getDataDetail.tableName,
274
- getDataDetail.serviceTag
275
- ),
276
- identifiersForGetData
277
- );
278
-
279
- getResults.push([getParent, getDataDetail]);
280
- }
281
-
282
-
283
- }
284
260
  })
285
261
  );
286
262
 
@@ -308,7 +308,7 @@ module.exports.updateMain = async (
308
308
 
309
309
  let updateItem = await dynamodbSharedLib.updateItem(
310
310
  _izContext,
311
- await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName),
311
+ await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName, updateDataDetail.serviceTag),
312
312
  identifiersForUpdateData,
313
313
  fieldForUpdateTableDynamo,
314
314
  {
@@ -324,7 +324,7 @@ module.exports.updateMain = async (
324
324
  }
325
325
 
326
326
  if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOWPROPERTIES_PROPERTYNAME]) {
327
- _izContext.logger.debug("HAVE CALLINGFLOW");
327
+ _izContext.logger.debug("HAVE CALLING FLOW");
328
328
 
329
329
  messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
330
330
  let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
@@ -54,6 +54,8 @@ module.exports.generatedLambdaRole = async () => {
54
54
  ]
55
55
  },
56
56
  <%_ }) %>
57
+ //(<additionalRole>)
58
+ //(</additionalRole>)
57
59
  ]
58
60
  return externalLambdaRole
59
61
  }
@@ -120,7 +120,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
120
120
  functionNameConfig: functionName + upperCase(handlerType),
121
121
  resourceLocation: path.join(SOURCE_PATH.resourceLocationWebSocket, flowSchema.flowTag, "source/"),
122
122
  additionalResourcePermission,
123
- functionNameConfig: upperCase("ReservedLimitComp") + upperCase(shortNameHandler(handlerType)),
123
+ functionNameConfig: functionName + upperCase(shortNameHandler(handlerType)),
124
124
  roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
125
125
  },
126
126
  setting: {
@@ -83,7 +83,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
83
83
  // validate message (and MessageAttributes)
84
84
  await recordHandlerSharedLib.validateRecord(
85
85
  record, // one record will send to mainFunction
86
- "ReservedLimitCompleteHdrSqs", // queue name that need to retry or send to dlq
86
+ "CreatePresignUrlHdrSqs", // queue name that need to retry or send to dlq
87
87
  perRecordsValidatorSchema, // schema for record.Message
88
88
  // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
89
89
  );
@@ -101,7 +101,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
101
101
  let recordPromise = recordHandlerSharedLib.recordHandler(
102
102
  record, // one record will send to mainFunction
103
103
  createPresignUrl.createPresignUrl, // mainFunction that need to invoke.
104
- "ReservedLimitCompleteHdrSqs", // queue name that need to retry or send to dlq
104
+ "CreatePresignUrlHdrSqs", // queue name that need to retry or send to dlq
105
105
  passOnProperties, // all parameters that mainFunction needed.
106
106
  );
107
107
  record._izContext.logger.debug('after recordPromise in handler');
@@ -167,7 +167,7 @@ module.exports.createPresignUrl = async (
167
167
  const Key = `${fileName}.${importType}`
168
168
  //(</createKeyForUploadFile>)
169
169
 
170
- const maximumSize = fileSize * 1048576 // convert to byte unit for restrict
170
+ const maximumSize = getResult.fields.fileSize * 1048576 // convert to byte unit for restrict
171
171
  _izContext.logger.debug("maximumSize", maximumSize);
172
172
 
173
173
  // create PresignUrl
@@ -218,7 +218,7 @@ module.exports.createPresignUrl = async (
218
218
  callingFlowSharedLib.addParentCallingFlowConfig(
219
219
  returnMessage, // resive parent callingFlowConfig.
220
220
  callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
221
- await lambdaSharedLib.lambdaFunctionName(_izContext, `WebSocketTaskComplete`), {}
221
+ await lambdaSharedLib.lambdaFunctionName(_izContext, `WebSocketComplete`), {}
222
222
  )
223
223
  )
224
224
  );
@@ -37,12 +37,15 @@ const {
37
37
  externalResourceSns,
38
38
  externalResourceName,
39
39
  SOURCE_GENERATE_IAM_ROLE,
40
- FUNCTION_NAME
40
+ FUNCTION_NAME,
41
+ DYNAMO_RESOURCE
41
42
  } = require('../../../../../../../../MainLibs/src/Consts');
42
43
 
43
44
  const {
44
45
  TOPIC_NAME_GENERATE_CODE
45
46
  } = require('../../../../../../../../GenerateCodeLibs/src/Consts');
47
+ const { STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
48
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema
46
49
 
47
50
  /**
48
51
  * receive objectSchema
@@ -51,15 +54,15 @@ const {
51
54
  * @return {{ templatePath, templateData, setting } }
52
55
  */
53
56
 
54
- function data(_izContext, flowSchema, srcPath) {
55
- return [createSourceParams(_izContext, flowSchema, srcPath)]
57
+ async function data(_izContext, flowSchema, srcPath) {
58
+ return [await createSourceParams(_izContext, flowSchema, srcPath)]
56
59
  }
57
60
 
58
- function createSourceParams(_izContext, flowSchema, srcPath) {
61
+ async function createSourceParams(_izContext, flowSchema, srcPath) {
59
62
  let functionName = upperCase(FUNCTION_NAME.reservedLimit);
60
63
  let handlerType = upperCase(HANDLER.hdrSqs);
61
64
  let additionalResourcePermission = defaultIamRolePerAction();
62
-
65
+ let tableNames = [];
63
66
  additionalResourcePermission.push(
64
67
  createIamRole(
65
68
  {
@@ -72,16 +75,37 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
72
75
  [RESOURCE_CLASSES.sns]: [
73
76
  SNS_RESOURCE.publish,
74
77
  SNS_RESOURCE.subscribe
75
- ]
78
+ ],
76
79
  },
77
80
  [
78
81
  resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType),
79
82
  resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType + "DLQ"),
80
- resourceNames(RESOURCE_CLASSES.sns, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete)
83
+ resourceNames(RESOURCE_CLASSES.sns, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete),
81
84
  ]
82
85
  )
83
86
  )
84
87
 
88
+ additionalResourcePermission.push(awaitingMultipleStepsRole())
89
+
90
+ let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType)
91
+
92
+ for (const storageResource of Object.values(objectSchema.storageResources)) {
93
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
94
+ tableNames.push(storageResource.tableName)
95
+ }
96
+ }
97
+
98
+ additionalResourcePermission.push(
99
+ createIamRole(
100
+ {
101
+ [RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
102
+ },
103
+ tableNames.map(tableName =>
104
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName)
105
+ )
106
+ )
107
+ )
108
+
85
109
  return {
86
110
  templatePath: templatePath,
87
111
  templateData: {
@@ -28,6 +28,8 @@ const consts = require('@izara_project/izara-market-library-service-schemas/src/
28
28
  const coreConsts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
29
29
  const hash = require('@izara_project/izara-shared-core').objectHash;
30
30
  const importDataLibs = require('../../../../libs/source/GenerateCodeLibs');
31
+ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
32
+
31
33
  /**
32
34
  * description of function.
33
35
  * @param {Object} _izContext
@@ -66,8 +68,6 @@ module.exports.reservedLimit = async (
66
68
 
67
69
  // get static
68
70
  let payloadBeforeInvokeStaticLimit = {
69
- userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
70
- targetId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
71
71
  //(<additionalPropertiesStaticLimit>)
72
72
  //(</additionalPropertiesStaticLimit>)
73
73
  }
@@ -81,13 +81,14 @@ module.exports.reservedLimit = async (
81
81
 
82
82
  if (res.passStatus === false) {
83
83
  importDataLibs.postToConnection({ message: "static limit over" }, connectionId)
84
+ //(<afterFailReservedStaticLimit>)
85
+ return
86
+ //(</afterFailReservedStaticLimit>)
84
87
  }
85
88
 
86
89
  // reservedDynamic
87
90
 
88
91
  let sendMsgReservedDynamic = {
89
- userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
90
- targetId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
91
92
  //(<additionalPropertiesReservedDynamic>)
92
93
  //(</additionalPropertiesReservedDynamic>)
93
94
  }
@@ -24,15 +24,29 @@ const izara = require("@izara_project/izara-middleware");
24
24
  const middleware = izara.middlewareHandler;
25
25
  const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
26
26
  const Logger = require('@izara_project/izara-core-library-logger');
27
-
27
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
28
  const <%- functionName %> = require('./<%- functionName %>_Main')
29
29
 
30
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
31
+ {
32
+ type: "object",
33
+ required: ['body', 'messageAttributes'],
34
+ properties: {
35
+ body: {
36
+ type: 'object',
37
+ },
38
+ messageAttributes: {
39
+ type: 'object'
40
+ }
41
+ }
42
+ }
43
+ ));
44
+
30
45
  // validate event properties in body.Message of sqs event
31
46
  let perRecordsValidatorSchema = {
32
47
  //(<validatorSchema>)
33
48
  //(</validatorSchema>)
34
49
  }
35
- middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
36
50
 
37
51
  module.exports.main = middleware.wrap(async (event, context, callback) => {
38
52
 
@@ -43,6 +57,9 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
43
57
  // loop each record and send to mainFunction
44
58
  await Promise.all(event.Records.map(async record => { // promise.all for map() function
45
59
 
60
+ record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
61
+ record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
62
+
46
63
  let passOnProperties = []
47
64
  record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
48
65
 
@@ -58,6 +75,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
58
75
  passOnProperties.push(record.body.Message)
59
76
  //(<additionalParams>)
60
77
  //(</additionalParams>)
78
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
61
79
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
62
80
 
63
81
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -203,7 +203,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
203
203
 
204
204
  // const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
205
205
 
206
- const reservedLimitFunctionYaml = createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
206
+ const reservedLimitFunctionYaml = await createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
207
207
  const reservedLimitHandlerFunction = createReservedLimitHandler(_izContext, flowSchema, saveFilePath);
208
208
  const reservedLimitMainFunction = await createReservedLimitMainFunction(_izContext, flowSchema, saveFilePath);
209
209
  const reservedLimitQueueName = createReservedLimitQueueName(_izContext, saveFilePath);
@@ -24,7 +24,7 @@ const izara = require("@izara_project/izara-middleware");
24
24
  const middleware = izara.middlewareHandler;
25
25
  const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
26
26
  const Logger = require('@izara_project/izara-core-library-logger');
27
-
27
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
28
  const <%- functionName %> = require('./<%- functionName %>_Main')
29
29
 
30
30
  // validate event properties in body.Message of sqs event
@@ -37,6 +37,8 @@ const { v4: uuidv4 } = require('uuid')
37
37
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
38
38
  const consts = require("@izara_project/izara-middleware").consts
39
39
  const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
40
+ const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils
41
+
40
42
  //(<optionalRequire>)
41
43
  //(</optionalRequire>)
42
44
  /**
@@ -73,25 +75,34 @@ module.exports.<%- functionName %> = async (
73
75
  throw new NoRetryError('not have TopicArn for get FlowSchemas')
74
76
  }
75
77
 
76
- let topicName = topicArn.spilt(":")[5].split("_")
78
+ let topicName = topicArn.split(":")[5].split("_")
79
+ let flowTag = topicName[2]
77
80
 
78
81
  let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
79
- flowTag: topicName[2],
82
+ flowTag: flowTag,
80
83
  serviceTag: topicName[0]
81
84
  })
82
85
 
86
+ if (!flowSchema) {
87
+ if (requestParams.hasOwnProperty("flowTag")) {
88
+ flowTag = requestParams.flowTag;
89
+ flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
90
+ flowTag: flowTag,
91
+ serviceTag: process.env.iz_serviceTag
92
+ })
93
+ } else {
94
+ throw new NoRetryError("Could not find flowSchema from topicArn or requestParams.flowTag")
95
+ }
96
+ }
97
+
83
98
  //(<createIdentifiersFlow>)
84
99
  let identifiers
85
100
  //(</createIdentifiersFlow>)
86
101
 
87
- if (!flowSchema) {
88
- throw new NoRetryError("not have flowSchema in S3")
89
- }
90
-
91
102
  let wbsTasks;
92
103
  let taskKey;
93
104
  if (flowSchema.statusType === "statusField" || flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
94
- taskKey = `${createFlowTypeConcat(_izContext,{flowTag: topicName[2],serviceTag: topicName[0]})}${identifiers}`
105
+ taskKey = `${createFlowTypeConcat(_izContext,{flowTag: flowTag, serviceTag: topicName[0]})}${identifiers}`
95
106
  wbsTasks = await dynamodbSharedLib.query(
96
107
  _izContext,
97
108
  await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
@@ -100,7 +111,7 @@ module.exports.<%- functionName %> = async (
100
111
  }
101
112
  )
102
113
  } else if (flowSchema.statusType === "none") {
103
- taskKey = `${createFlowTypeConcat(_izContext,{flowTag: topicName[2],serviceTag: topicName[0]})}${correlationId}`
114
+ taskKey = `${createFlowTypeConcat(_izContext,{flowTag: flowTag, serviceTag: topicName[0]})}${correlationId}`
104
115
  wbsTasks = await dynamodbSharedLib.query(
105
116
  _izContext,
106
117
  await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
@@ -108,22 +119,22 @@ module.exports.<%- functionName %> = async (
108
119
  taskKey: taskKey
109
120
  }
110
121
  )
111
- }
122
+ }
112
123
 
113
124
  if (wbsTasks.Items.length) {
114
- await Promise.all(wbsTasks.Items.map(async ({ connectionId }) => {
115
- await postToConnection(
116
- {
117
- message: requestParams
118
- },
119
- connectionId
120
- )
125
+ await Promise.all(wbsTasks.Items.map(async (wbsTask) => {
126
+ let postMessage = { message: requestParams }
127
+
128
+ //(<beforePostMessage>)
129
+ //(</beforePostMessage>)
130
+
131
+ await postToConnection(postMessage, wbsTask.connectionId)
121
132
 
122
133
  await dynamodbSharedLib.deleteItem(_izContext,
123
134
  await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
124
135
  {
125
- taskKey: taskKey,
126
- connectionId: connectionId
136
+ taskKey: wbsTask.taskKey,
137
+ connectionId: wbsTask.connectionId
127
138
  }
128
139
  )
129
140
  }))
@@ -91,9 +91,12 @@ module.exports.updateNodeComplete = async (
91
91
  fields: returnValue.queryResult.objInstanceFull.fields
92
92
  },
93
93
  status: status,
94
- errorsFound: errorsFound
94
+ errorsFound: errorsFound,
95
95
  };
96
96
 
97
+ //(<additionalProperties>)
98
+ //(</additionalProperties>)
99
+
97
100
  updateCompleteMsg = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, updateCompleteMsg);
98
101
  _izContext.logger.debug("after addCallingFlow to SnsResponseMessageObject", updateCompleteMsg);
99
102
 
@@ -36,6 +36,8 @@ const { NoRetryError } = require("@izara_project/izara-core-library-core");
36
36
 
37
37
  async function filterCreateResourceYaml(_izContext, createSourceParams, objSchemaPath) {
38
38
  let tableNamesToFilter = new Set();
39
+ let ownServiceTag = getLocalConfig(path.join(objSchemaPath, "../../"), "iz_serviceTag")
40
+
39
41
  const allLocalFlowSchema = await getObjectSchema.getAllLocalFlowSchemas(_izContext, objSchemaPath);
40
42
  await Promise.all(allLocalFlowSchema.records.map(async (flowSchema) => {
41
43
  if (flowSchema.statusType === "storedCache") {
@@ -48,9 +50,16 @@ async function filterCreateResourceYaml(_izContext, createSourceParams, objSchem
48
50
  const allLocalObjSchema = await getObjectSchema.getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
49
51
  await Promise.all(allLocalObjSchema.records.map(async (objSchema) => {
50
52
  if (objSchema.hasOwnProperty("extendObjType")) {
51
- tableNamesToFilter.add(...await getParentTableFromObjSchema(_izContext, objSchema, objSchemaPath))
53
+ for (const storageResource of Object.values(objSchema.storageResources)) {
54
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
55
+ if (storageResource?.serviceTag !== ownServiceTag) {
56
+ tableNamesToFilter.add(storageResource.tableName)
57
+ }
58
+ }
59
+ }
52
60
  }
53
61
  }))
62
+
54
63
  let filteredCreateSourceParams = createSourceParams.filter(
55
64
  (result) => !tableNamesToFilter.has(result.templateData.tableName)
56
65
  )
@@ -75,17 +84,3 @@ async function getStoredCacheTableFromFlowSchema(_izContext, flowSchema, objSche
75
84
  }
76
85
  return tableNameStoredCache;
77
86
  }
78
-
79
- async function getParentTableFromObjSchema(_izContext, objSchema, objSchemaPath) {
80
- let parentTableNames = new Set();
81
- let ownServiceTag = getLocalConfig(path.join(objSchemaPath, "../../"), "iz_serviceTag")
82
- for (const storageResource of Object.values(objSchema.storageResources)) {
83
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
84
- if (storageResource.serviceTag && storageResource.serviceTag !== ownServiceTag) {
85
- parentTableNames.add(storageResource.tableName)
86
- }
87
- }
88
- }
89
-
90
- return parentTableNames
91
- }