@izara_project/izara-market-library-service-schemas 1.0.55 → 1.0.56

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 (52) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -0
  3. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +13 -14
  4. package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +14 -11
  5. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +9 -11
  6. package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +16 -13
  7. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +15 -4
  8. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +18 -15
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/template.ejs +2 -0
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +14 -10
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +20 -3
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +8 -14
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/template.ejs +2 -0
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +45 -55
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +5 -3
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +4 -3
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +31 -40
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/template.ejs +3 -17
  19. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +391 -0
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +9 -317
  21. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +5 -5
  22. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +1 -1
  23. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +28 -5
  24. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +11 -11
  25. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +16 -16
  26. package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +3 -0
  27. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/handler/template.ejs +4 -0
  29. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +36 -7
  30. package/src/reStructure/TemplateData/perActionEndpoint/handler/api/template.ejs +2 -2
  31. package/src/reStructure/TemplateData/perActionEndpoint/handler/dsq/template.ejs +2 -2
  32. package/src/reStructure/TemplateData/perActionEndpoint/handler/sqs/template.ejs +2 -2
  33. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +1 -2
  34. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/api/template.ejs +2 -2
  35. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/dsq/template.ejs +2 -2
  36. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/sqs/template.ejs +2 -2
  37. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +6 -0
  38. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/api/template.ejs +2 -2
  39. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs +2 -2
  40. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs +2 -2
  41. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/template.ejs +23 -23
  42. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/template.ejs +18 -16
  43. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/template.ejs +14 -12
  44. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/template.ejs +21 -19
  45. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -0
  46. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +3 -1
  47. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/api/template.ejs +24 -22
  48. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/dsq/template.ejs +21 -17
  49. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/inv/template.ejs +21 -19
  50. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/sqs/template.ejs +20 -20
  51. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +1 -1
  52. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/handler/sqs/template.ejs +1 -1
@@ -32,11 +32,11 @@ const { S3Client, GetObjectCommand, DeleteObjectCommand, PutObjectCommand, CopyO
32
32
  const s3 = new S3Client({ region: 'us-east-2' });
33
33
 
34
34
  const hash = require('@izara_project/izara-shared-core').objectHash;
35
- const Readable = require('stream');
36
- const { isValidCsv, getNestObject } = require('../../../../libs/source/GenerateCodeLibs');
37
35
  const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
36
  const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
39
37
 
38
+ //(<optionalRequired>)
39
+ //(</optionalRequired>)
40
40
 
41
41
  /**
42
42
  * description of function.
@@ -58,331 +58,23 @@ module.exports.processAfterUpload = async (
58
58
  _izContext,
59
59
  bucket,
60
60
  field,
61
- importBy = '',
62
- importBatchId = '',
63
- realImageSize = 0,
61
+ //(<additionalProperties>)
62
+ //(</additionalProperties>)
64
63
  passBackProperties = {}
65
64
  ) => {
66
65
 
67
66
  try {
68
67
 
69
- _izContext.logger.debug('----- processImageFile event params ----- ', {
68
+ _izContext.logger.debug('----- process AfterUpload event params ----- ', {
70
69
  bucket: bucket,
71
70
  field: field,
72
- importBy: importBy,
73
- importBatchId: importBatchId,
74
- realImageSize: realImageSize,
71
+ //(<loggerAdditionalParams>)
72
+ //(</loggerAdditionalParams>)
75
73
  passBackProperties: passBackProperties
76
74
  })
77
75
 
78
- let errorsFound = [];
79
-
80
- const objectS3Param = {
81
- Bucket: bucket.name,
82
- Key: field.key
83
- }
84
- _izContext.logger.debug("params before getObjectParam::", objectS3Param)
85
-
86
- const fileObjectS3 = await s3.send(new GetObjectCommand(objectS3Param));
87
- _izContext.logger.debug("get fileObjectS3", fileObjectS3);
88
-
89
- importBatchId = fileObjectS3.Metadata.importbatchid
90
-
91
- let getImportBatchMain = await lambda.invokeSync(_izContext,
92
- await lambdaSharedLib.lambdaFunctionName(_izContext, "ImportBatchMainGetHdrInv"),
93
- {
94
- identifiers: {
95
- importBatchId: importBatchId
96
- }
97
- }
98
- )
99
-
100
- _izContext.logger.debug("getImportBatchMain", getImportBatchMain)
101
- _izContext.correlationIds.set(coreConsts.BASE_USER_ID, getImportBatchMain.fields.userId);
102
- _izContext.correlationIds.set(coreConsts.TARGET_ID, getImportBatchMain.fields.submittedByUserId);
103
-
104
- let userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
105
- let targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
106
-
107
- if (Date.now() > getImportBatchMain.fields.expiryTimestamp) {
108
- errorsFound.push("url expired can't upload")
109
- let sendMessageUpdateUrlExpired = {
110
- objInstanceFull: {
111
- identifiers: {
112
- importBatchId: importBatchId
113
- },
114
- fields: {
115
- importBatchStatus: "urlExpired",
116
- errorsFound: "url expired can't upload",
117
- processingError: true
118
- }
119
- }
120
- }
121
-
122
- let sendMessageToInImportBatchUpdate = {
123
- Message: JSON.stringify(sendMessageUpdateUrlExpired),
124
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, "InImportBatchMainUpdate")
125
- };
126
-
127
- _izContext.logger.debug("message param before send to updateImportBatchMain", sendMessageToInImportBatchUpdate);
128
- await sns.publishAsync(_izContext, sendMessageToInImportBatchUpdate);
129
-
130
- let deleteFileObjectS3 = await s3.send(new DeleteObjectCommand(objectS3Param));
131
- _izContext.logger.debug("Delete object response: ", deleteFileObjectS3)
132
-
133
- return
134
- }
135
-
136
- if (fileObjectS3) {
137
- if (!importBatchId) {
138
- errorsFound.push("cant't get importBatchId from S3 uploaded file");
139
- }
140
- } else {
141
- errorsFound.push("cant't get fileObjectS3 from S3 uploaded file");
142
- };
143
-
144
- let fileS3Body = fileObjectS3.Body;
145
- _izContext.logger.debug("fileS3Body", fileS3Body);
146
-
147
- let fileS3Buffer = null;
148
-
149
- if (fileS3Body instanceof Readable) {
150
- fileS3Buffer = Buffer.concat(await fileS3Body.toArray());
151
- _izContext.logger.debug("fileS3Buffer", fileS3Buffer)
152
- } else {
153
- errorsFound.push('unknown object stream type');
154
- }
155
-
156
- // check file type
157
- // can be strict in function.yml that only trigger if it specific type of file
158
- const srcKey = field.key;
159
- const importFieldType = srcKey.match(/\.([^.]*)$/);
160
- _izContext.logger.debug("importFieldType", importFieldType);
161
- if (!importFieldType) {
162
- throw new NoRetryError("error fileType")
163
- };
164
-
165
- const importKeyType = utils.firstLetterLowerCase(importFieldType[1]);
166
- _izContext.logger.debug("importKeyType", importKeyType);
167
-
168
- if (importKeyType === "csv") {
169
- // check valid CSV file
170
- let [validCsv, errorCheckCsv] = await isValidCsv(_izContext, fileObjectS3)
171
- _izContext.logger.debug("validCsv check::", { validCsv, errorsFound })
172
- if (errorCheckCsv.length) {
173
- errorsFound.push(errorCheckCsv[0])
174
- }
175
-
176
- // check file size
177
- let reservedFileSize = getImportBatchMain.fields.fileSize;
178
- _izContext.logger.debug("initialFileSize::", reservedFileSize)
179
- let s3FileSize = fileObjectS3.ContentLength / 1048576 // convert back to byte unit
180
- _izContext.logger.debug("s3FileSize in MiB::", s3FileSize)
181
-
182
- if (s3FileSize < 0.5) { // round up to 1
183
- s3FileSize = 1
184
- }
185
-
186
- let reservedData = await dynamodbSharedLib.getItem(_izContext,
187
- await dynamodbSharedLib.tableName(_izContext, "ReservedDataMain"),
188
- {
189
- servicePendingId: importBatchId,
190
- reservedDataId: `${consts.ACCOUNTLIMIT_TAG.reservedDynamic}_${getImportBatchMain.fields.userId}_${consts.LIMIT_TAG.uploadData}`
191
- }
192
- )
193
- _izContext.logger.debug("reservedData::", reservedData);
194
-
195
- let sizeDiff;
196
-
197
- if (s3FileSize > reservedFileSize) {
198
- sizeDiff = s3FileSize - reservedFileSize;
199
-
200
-
201
- if (sizeDiff < 1) {
202
-
203
- // send message to confirmUsage
204
- let confirmUsageMessage = {
205
- userId: userId,
206
- limitTag: consts.LIMIT_TAG.uploadData,
207
- uniqueIdentify: reservedData.uniqueIdentify,
208
- }
209
-
210
- let sendMessageToConfirmUsage = {
211
- Message: JSON.stringify(confirmUsageMessage),
212
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'InConfirmUsage', consts.EXTERNAL_SERVICE_NAME.accountLimits)
213
- };
214
- _izContext.logger.debug("sendMessageToConfirmUsage", sendMessageToConfirmUsage);
215
- await sns.publishAsync(_izContext, sendMessageToConfirmUsage);
216
-
217
- let sendMessageToUpdateImportBatchStatus = {
218
- objInstanceFull: {
219
- identifiers: {
220
- importBatchId: servicePendingId
221
- },
222
- fields: {
223
- importBatchStatus: 'uploadComplete'
224
- }
225
- }
226
- }
227
-
228
- let sendMessageToUpdateImportBatch = {
229
- Message: JSON.stringify(sendMessageToUpdateImportBatchStatus),
230
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, `InImportBatchMainUpdate`)
231
- };
232
- _izContext.logger.debug("sendMessageToUpdateImportBatch", sendMessageToUpdateImportBatch);
233
- await sns.publishAsync(_izContext, sendMessageToUpdateImportBatch);
234
-
235
- }
236
- } else if (s3FileSize < reservedFileSize) {
237
- sizeDiff = reservedFileSize - s3FileSize;
238
-
239
- if (sizeDiff < 1) {
240
- let confirmUsageMessage = {
241
- userId: userId,
242
- limitTag: consts.LIMIT_TAG.uploadData,
243
- uniqueIdentify: reservedData.uniqueIdentify,
244
- }
245
-
246
- let sendMessageToConfirmUsage = {
247
- Message: JSON.stringify(confirmUsageMessage),
248
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'InConfirmUsage', consts.EXTERNAL_SERVICE_NAME.accountLimits)
249
- };
250
- _izContext.logger.debug("sendMessageToConfirmUsage", sendMessageToConfirmUsage);
251
- await sns.publishAsync(_izContext, sendMessageToConfirmUsage);
252
-
253
- let sendMessageToUpdateImportBatchStatus = {
254
- objInstanceFull: {
255
- identifiers: {
256
- importBatchId: servicePendingId
257
- },
258
- fields: {
259
- importBatchStatus: 'uploadComplete'
260
- }
261
- }
262
- }
263
-
264
- let sendMessageToUpdateImportBatch = {
265
- Message: JSON.stringify(sendMessageToUpdateImportBatchStatus),
266
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, `InImportBatchMainUpdate`)
267
- };
268
- _izContext.logger.debug("sendMessageToUpdateImportBatch", sendMessageToUpdateImportBatch);
269
- await sns.publishAsync(_izContext, sendMessageToUpdateImportBatch);
270
-
271
- } else {
272
- let realFileSize = Math.round(s3FileSize);
273
- // cancel reserved -> new reserved -> confirm
274
- // cancel
275
- let sendMessageToCancelReserved = {
276
- Message: JSON.stringify({
277
- userId: userId,
278
- limitTag: consts.LIMIT_TAG.uploadData,
279
- uniqueIdentify: reservedData.uniqueIdentify
280
- }),
281
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'InCancelUsage', consts.EXTERNAL_SERVICE_NAME.accountLimits)
282
- };
283
- _izContext.logger.debug("sendMessageToCancelReserved", sendMessageToCancelReserved);
284
- await sns.publishAsync(_izContext, sendMessageToCancelReserved);
285
-
286
- // new reserved
287
- let originTimestamp = Date.now();
288
- let messageObjReserved = {
289
- userId: userId,
290
- limitTag: consts.LIMIT_TAG.uploadData,
291
- value: realFileSize,
292
- rbacType: consts.RBAC_TYPE.appLevel,
293
- usedTimestamp: originTimestamp,
294
- targetUserId: targetId
295
- }
296
-
297
- let callingFlowProperties = {
298
- identifier: {
299
- servicePendingId: importBatchId,
300
- reservedDataId: `${consts.ACCOUNTLIMIT_TAG.reservedDynamic}_${getImportBatchMain.fields.userId}_${consts.LIMIT_TAG.uploadData}`,
301
- userId: getImportBatchMain.fields.userId,
302
- realSize: realFileSize
303
- }
304
- }
305
-
306
- messageObjReserved = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
307
- messageObjReserved,
308
- callingFlowSharedLib.createCallingFlowConfig(
309
- await lambdaSharedLib.lambdaFunctionName(_izContext, "ConfirmNewReservedHdrSqs"),
310
- callingFlowProperties
311
- )
312
- )
313
- _izContext.logger.debug('after add callingFlow: ', messageObjReserved)
314
-
315
- let sendMessageToReservedDynamic = {
316
- Message: JSON.stringify(messageObjReserved),
317
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'InReservedDynamicUsage', consts.EXTERNAL_SERVICE_NAME.accountLimits)
318
- };
319
-
320
- _izContext.logger.debug("sendMessageToReservedDynamic", sendMessageToReservedDynamic);
321
- await sns.publishAsync(_izContext, sendMessageToReservedDynamic);
322
- };
323
- } else if (s3FileSize === reservedFileSize) {
324
- let confirmUsageMessage = {
325
- userId: getImportBatchMain.fields.userId,
326
- limitTag: consts.LIMIT_TAG.uploadData,
327
- uniqueIdentify: reservedData.uniqueIdentify,
328
- }
329
-
330
- let sendMessageToConfirmUsage = {
331
- Message: JSON.stringify(confirmUsageMessage),
332
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'InConfirmUsage', consts.EXTERNAL_SERVICE_NAME.accountLimits)
333
- };
334
- _izContext.logger.debug("sendMessageToConfirmUsage", sendMessageToConfirmUsage);
335
- await sns.publishAsync(_izContext, sendMessageToConfirmUsage);
336
-
337
- let sendMessageToUpdateImportBatchStatus = {
338
- objInstanceFull: {
339
- identifiers: {
340
- importBatchId: servicePendingId
341
- },
342
- fields: {
343
- importBatchStatus: 'uploadComplete'
344
- }
345
- }
346
- }
347
-
348
- let sendMessageToUpdateImportBatch = {
349
- Message: JSON.stringify(sendMessageToUpdateImportBatchStatus),
350
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, `InImportBatchMainUpdate`)
351
- };
352
- _izContext.logger.debug("sendMessageToUpdateImportBatch", sendMessageToUpdateImportBatch);
353
- await sns.publishAsync(_izContext, sendMessageToUpdateImportBatch);
354
-
355
- }
356
-
357
- } else {
358
- errorsFound.push("error importKeyType")
359
- }
360
-
361
- if (errorsFound.length) { // if error send message to update error in importBatchMain
362
- let updateImportBatchMainError = {
363
- objInstanceFull: {
364
- identifiers: {
365
- importBatchId: importBatchId
366
- },
367
- fields: {
368
- importBatchStatus: "errorToUpload",
369
- errorsFound: errorsFound,
370
- processingError: true
371
- }
372
- }
373
- }
374
-
375
- let sendMessageToUpdateImportBatchMain = {
376
- Message: JSON.stringify(updateImportBatchMainError),
377
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, "InImportBatchMainUpdate")
378
- };
379
- _izContext.logger.debug('sendMessageToUpdateImportBatchMain::', sendMessageToUpdateImportBatchMain);
380
- await sns.publishAsync(_izContext, sendMessageToUpdateImportBatchMain);
381
-
382
- let deleteFileObjectS3 = await s3.send(new DeleteObjectCommand(objectS3Param));
383
- _izContext.logger.debug("Delete object response: ", deleteFileObjectS3)
384
-
385
- }
76
+ //(<endpointHook>)
77
+ //(</endpointHook>)
386
78
 
387
79
  } catch (err) {
388
80
  _izContext.logger.error('error ProcessImageAfterUploadMain: ', err)
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  const externalRequest = require('@izara_project/izara-core-library-external-request');
21
21
  const lambda = externalRequest.lambda;
22
-
22
+ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda')
23
23
  const { ApiGatewayManagementApiClient, PostToConnectionCommand } = require("@aws-sdk/client-apigatewaymanagementapi");
24
24
  const hash = require('@izara_project/izara-shared-core').objectHash;
25
25
  <% if (uploadS3) { %>
@@ -57,17 +57,17 @@ async function postToConnection(message, connectionId) {
57
57
  * @param {string} functionName
58
58
  * @param {Object} payload
59
59
  */
60
- async function getDataFromInvokeFunction(_izContext, functionName, payload) {
60
+ async function processStaticLimit(_izContext, functionName, payload) {
61
61
  return await lambda.invokeSync(_izContext, functionName, payload)
62
62
  }
63
63
 
64
- const getDataFromInvokeFunctionWithCache = inMemoryCacheLib(
65
- getDataFromInvokeFunction,
64
+ const processStaticLimitWithCache = inMemoryCacheLib(
65
+ processStaticLimit,
66
66
  {
67
67
  max: 100,
68
68
  maxAge: 86400000,
69
69
  promise: true,
70
- profileName: "getDataFromInvokeFunction",
70
+ profileName: "processStaticLimit",
71
71
  normalizer: function (args) {
72
72
  return hash(args[1], args[2])
73
73
  }
@@ -111,7 +111,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
111
111
  return {
112
112
  templatePath: templatePath,
113
113
  templateData: {
114
- resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
114
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowSchema.flowTag), "source/"),
115
115
  functionName,
116
116
  handlerType,
117
117
  additionalResourcePermission,
@@ -39,6 +39,10 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
39
39
  const connectionId = event.requestContext.connectionId;
40
40
  let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
41
41
 
42
+ //(<createIdentifiersFlow>)
43
+ let identifiers
44
+ //(</createIdentifiersFlow>)
45
+
42
46
  switch (route) {
43
47
 
44
48
  case '$default':
@@ -47,16 +51,35 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
47
51
  case '<%- route %>':
48
52
  console.log("event in route webSocket", event);
49
53
  let eventParams = JSON.parse(event.body)
50
-
51
- await dynamodbSharedLib.putItem(
54
+ let flowSchema = getObjectSchema.getFlowSchemaS3WithCache(
52
55
  event._izContext,
53
- await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
54
56
  {
55
- taskKey: correlationId,
56
- connectionId: connectionId,
57
+ flowTag: "<%- route %>",
58
+ serviceTag: process.env.iz_serviceTag
57
59
  }
58
60
  )
59
61
 
62
+ if (flowSchema.statusType === "statusField" || flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
63
+ await dynamodbSharedLib.putItem(event._izContext,
64
+ await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
65
+ {
66
+ taskKey: `${utils.createFlowTypeConcat(event._izContext, { flowTag: "<%- route %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
67
+ connectionId: connectionId,
68
+ }
69
+ )
70
+
71
+ } else if (flowSchema.statusType === "none") {
72
+ await dynamodbSharedLib.putItem(
73
+ event._izContext,
74
+ await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
75
+ {
76
+ taskKey: `${utils.createFlowTypeConcat(event._izContext, { flowTag: "<%- route %>", serviceTag: process.env.iz_serviceTag })}${correlationId}`,
77
+ connectionId: connectionId,
78
+ }
79
+ )
80
+ }
81
+
82
+
60
83
  let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
61
84
  await <%- functionName %>.<%- functionName %>(
62
85
  event._izContext,
@@ -72,17 +72,17 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
72
72
 
73
73
  let defaultDsqQueueDataList = [];
74
74
 
75
- if (flowSchema.outputTopic) {
76
- if (flowSteps.includes("Out")) {
77
- if (flowSchema.outputTopic) {
78
- defaultDsqQueueDataList.push(
79
- {
80
- queueName: upperCase(topicIn) + "CompleteHdrSqs"
81
- }
82
- )
83
- }
84
- }
85
- }
75
+ // if (flowSchema.outputTopic) {
76
+ // if (flowSteps.includes("Out")) {
77
+ // if (flowSchema.outputTopic) {
78
+ // defaultDsqQueueDataList.push(
79
+ // {
80
+ // queueName: upperCase(topicIn) + "CompleteHdrSqs"
81
+ // }
82
+ // )
83
+ // }
84
+ // }
85
+ // }
86
86
 
87
87
 
88
88
  for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
@@ -199,15 +199,15 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
199
199
 
200
200
  // const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
201
201
 
202
- const getPreSignUrlFunctionYaml = createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
203
- const getPreSignUrlHandler = createReservedLimitHandler(_izContext, flowSchema, saveFilePath);
204
- const getPreSignUrlMainFunction = createReservedLimitMainFunction(_izContext, flowSchema, saveFilePath);
205
- const getPreSignUrlQueue = createReservedLimitQueueName(_izContext, saveFilePath);
202
+ const reservedLimitFunctionYaml = createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
203
+ const reservedLimitHandlerFunction = createReservedLimitHandler(_izContext, flowSchema, saveFilePath);
204
+ const reservedLimitMainFunction = await createReservedLimitMainFunction(_izContext, flowSchema, saveFilePath);
205
+ const reservedLimitQueueName = createReservedLimitQueueName(_izContext, saveFilePath);
206
206
 
207
- const reservedLimitCompleteFunctionYaml = createPresignUrlFunctionYaml(_izContext, flowSchema, saveFilePath);
208
- const reservedLimitCompleteMainFunction = createPresignUrlMainFunction(_izContext, flowSchema, saveFilePath);
209
- const reservedLimitCompleteHandler = createPresignUrlHandler(_izContext, flowSchema, saveFilePath);
210
- const reservedLimitCompleteQueue = createPresignUrlQueueName(_izContext, saveFilePath);
207
+ const presignUrlFunctionYaml = createPresignUrlFunctionYaml(_izContext, flowSchema, saveFilePath);
208
+ const presignUrlMainFunction = createPresignUrlMainFunction(_izContext, flowSchema, saveFilePath);
209
+ const presignUrlHandlerFunction = createPresignUrlHandler(_izContext, flowSchema, saveFilePath);
210
+ const presignUrlQueueName = createPresignUrlQueueName(_izContext, saveFilePath);
211
211
 
212
212
  const processAfterUploadFunctionYmlS3 = createProcessAfterUploadS3FunctionYmlS3(_izContext, flowSchema, saveFilePath);
213
213
  // const processAfterUploadFunctionYamlHdrDsq = createProcessAfterUploadS3FunctionYmlDsq(_izContext, saveFilePath);
@@ -232,17 +232,17 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
232
232
  ];
233
233
 
234
234
  const getPreSignUrlResources = [
235
- ...getPreSignUrlFunctionYaml,
236
- ...getPreSignUrlHandler,
237
- ...getPreSignUrlMainFunction,
238
- ...getPreSignUrlQueue
235
+ ...reservedLimitFunctionYaml,
236
+ ...reservedLimitHandlerFunction,
237
+ ...reservedLimitMainFunction,
238
+ ...reservedLimitQueueName
239
239
  ];
240
240
 
241
241
  const reservedLimitResources = [
242
- ...reservedLimitCompleteFunctionYaml,
243
- ...reservedLimitCompleteHandler,
244
- ...reservedLimitCompleteMainFunction,
245
- ...reservedLimitCompleteQueue
242
+ ...presignUrlFunctionYaml,
243
+ ...presignUrlHandlerFunction,
244
+ ...presignUrlMainFunction,
245
+ ...presignUrlQueueName
246
246
  ];
247
247
 
248
248
  const processAfterUploadResources = [
@@ -52,6 +52,9 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
52
52
  // add argument (to invoke lambda) to passOnProperties[]
53
53
  passOnProperties.push(record.body.TopicArn)
54
54
  passOnProperties.push(record.body.Message)
55
+ //(<additionalParams>)
56
+ //(</additionalParams>)
57
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
55
58
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
56
59
 
57
60
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -53,9 +53,9 @@ module.exports.registerCompleteMain = async (
53
53
  _izContext,
54
54
  topicArn,
55
55
  requestParams,
56
- callingFlowConfig = {},
57
56
  //(<additionalParams>)
58
57
  //(</additionalParams>)
58
+ callingFlowConfig = {},
59
59
  ) => {
60
60
  try {
61
61
  _izContext.logger.debug("WebSocketInvoke _izContext", _izContext)
@@ -51,7 +51,11 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
51
51
  );
52
52
 
53
53
  // add argument (to invoke lambda) to passOnProperties[]
54
+ passOnProperties.push(record.body.TopicArn)
54
55
  passOnProperties.push(record.body.Message)
56
+ //(<additionalParams>)
57
+ //(</additionalParams>)
58
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
55
59
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
56
60
 
57
61
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -56,10 +56,11 @@ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-librar
56
56
 
57
57
  module.exports.<%- functionName %> = async (
58
58
  _izContext,
59
+ topicArn,
59
60
  requestParams,
60
- callingFlowConfig = {},
61
61
  //(<additionalParams>)
62
62
  //(</additionalParams>)
63
+ callingFlowConfig = {},
63
64
  ) => {
64
65
 
65
66
  try {
@@ -68,15 +69,43 @@ module.exports.<%- functionName %> = async (
68
69
  _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
69
70
 
70
71
  let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID);
72
+ if (!topicArn) {
73
+ throw new NoRetryError('not have TopicArn for get FlowSchemas')
74
+ }
75
+
76
+ let topicName = topicArn.spilt(":")[5].split("_")
71
77
 
78
+ let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
79
+ flowTag: topicName[2],
80
+ serviceTag: topicName[0]
81
+ })
82
+
83
+ //(<createIdentifiersFlow>)
84
+ let identifiers
85
+ //(</createIdentifiersFlow>)
86
+
87
+ if (!flowSchema) {
88
+ throw new NoRetryError("not have flowSchema in S3")
89
+ }
72
90
 
73
- let wbsTasks = await dynamodbSharedLib.query(
74
- _izContext,
75
- await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
76
- {
77
- taskKey: correlationId,
91
+ let wbsTasks;
92
+ if (flowSchema.statusType === "statusField" || flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
93
+ wbsTasks = await dynamodbSharedLib.query(
94
+ _izContext,
95
+ await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
96
+ {
97
+ taskKey: `${createFlowTypeConcat(_izContext,{flowTag: topicName[2],serviceTag: topicName[0]})}${identifiers}`
98
+ }
99
+ )
100
+ } else if (flowSchema.statusType === "none") {
101
+ wbsTasks = await dynamodbSharedLib.query(
102
+ _izContext,
103
+ await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
104
+ {
105
+ taskKey: correlationId,
106
+ }
107
+ )
78
108
  }
79
- )
80
109
 
81
110
  if (wbsTasks.Items.length) {
82
111
  await Promise.all(wbsTasks.Items.map(async ({ connectionId }) => {
@@ -29,8 +29,8 @@ const {
29
29
  const <%- functionName %> =require('./<%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(action) %>_Main')
30
30
  <%_ } _%>
31
31
 
32
- //(<globalVarible>
33
- //</globalVarible>)
32
+ //(<globalVariable>
33
+ //</globalVariable>)
34
34
 
35
35
  //validate event params in middleware before into main function
36
36
  validateSchemaMiddleware(
@@ -29,8 +29,8 @@ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record
29
29
  const <%- functionName %> =require('./<%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(action) %>_Main')
30
30
  <%_ } _%>
31
31
 
32
- //(<globalVarible>
33
- //</globalVarible>)
32
+ //(<globalVariable>
33
+ //</globalVariable>)
34
34
 
35
35
  //validate event params in middleware before into main function
36
36
  middleware.setValidatorSchema(
@@ -29,8 +29,8 @@ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record
29
29
  const <%- functionName %> =require('./<%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(action) %>_Main')
30
30
  <%_ } _%>
31
31
 
32
- //(<globalVarible>
33
- //</globalVarible>)
32
+ //(<globalVariable>
33
+ //</globalVariable>)
34
34
 
35
35
  //validate event params in middleware before into main function
36
36
  middleware.setValidatorSchema(
@@ -88,8 +88,7 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
88
88
  // const objectType = objectSchema.objectType; // main objectType
89
89
  let propertyValue = settings.propertyValueTag
90
90
  const storageResources = objectSchema.storageResources // storageResource from main objectType
91
- const serviceTag = getLocalConfig(srcPath, "iz_serviceTag")
92
-
91
+ const serviceTag = getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag")
93
92
  attributeRelationships.push(
94
93
  { // has{objectType}propertyValue
95
94
  relationshipTag: PREFIX_RELATIONSHIP.has + upperCase(propertyValue) + PROPERTY_VALUE_TAG.property,