@izara_project/izara-market-library-service-schemas 1.0.54 → 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 (71) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -0
  3. package/src/reStructure/TemplateData/Auth/generateAuthYml/template.ejs +15 -16
  4. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +13 -14
  5. package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +14 -11
  6. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +9 -11
  7. package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +16 -13
  8. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +41 -17
  9. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +39 -21
  10. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +43 -8
  11. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +29 -9
  12. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +21 -15
  13. package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +2 -2
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/template.ejs +2 -0
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +14 -10
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +21 -4
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +8 -14
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/template.ejs +2 -0
  19. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +45 -55
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +5 -3
  21. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +4 -3
  22. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +35 -40
  23. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/template.ejs +3 -17
  24. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +391 -0
  25. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +9 -317
  26. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +5 -5
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/functionYaml/data.js +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/data.js +1 -1
  29. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +8 -8
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaMainFunction/data.js +1 -1
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaMainFunction/template.ejs +5 -3
  32. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +1 -1
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +28 -5
  34. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +11 -11
  35. package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +1 -0
  36. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +28 -26
  37. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +10 -1
  38. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/template.ejs +2 -2
  39. package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +3 -0
  40. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +1 -1
  41. package/src/reStructure/TemplateData/flowSchema/templateByStatusType/storedCacheTemplate.ejs +3 -0
  42. package/src/reStructure/TemplateData/flowSchema/templateByStatusType/triggerCacheTemplate.ejs +3 -0
  43. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/handler/template.ejs +4 -0
  44. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +36 -7
  45. package/src/reStructure/TemplateData/perActionEndpoint/handler/api/template.ejs +2 -2
  46. package/src/reStructure/TemplateData/perActionEndpoint/handler/dsq/template.ejs +2 -2
  47. package/src/reStructure/TemplateData/perActionEndpoint/handler/sqs/template.ejs +2 -2
  48. package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/data.js +10 -2
  49. package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/template.ejs +1 -1
  50. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +1 -2
  51. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/api/template.ejs +2 -2
  52. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/dsq/template.ejs +2 -2
  53. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/sqs/template.ejs +2 -2
  54. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +9 -1
  55. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -1
  56. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +6 -0
  57. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/api/template.ejs +2 -2
  58. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs +2 -2
  59. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs +2 -2
  60. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/template.ejs +23 -23
  61. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/template.ejs +18 -16
  62. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/template.ejs +14 -12
  63. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/template.ejs +21 -19
  64. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -0
  65. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +3 -1
  66. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/api/template.ejs +24 -22
  67. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/dsq/template.ejs +21 -17
  68. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/inv/template.ejs +21 -19
  69. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/sqs/template.ejs +20 -20
  70. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +1 -1
  71. 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
  }
@@ -57,7 +57,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
57
57
  let handlerType = upperCase(HANDLER.hdrSqs)
58
58
  let additionalResourcePermission = defaultIamRolePerAction();
59
59
  let route = upperCase(flowSchema.flowTag);
60
- let queueName = upperCase(flowSchema.flowTag) + handlerType;
60
+ let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
61
61
  let topicIn = route + "_In";
62
62
  additionalResourcePermission.push(
63
63
  createIamRole(
@@ -55,7 +55,7 @@ async function data(_izContext, flowSchema, srcPath) {
55
55
  async function createSourceParams(_izContext, flowSchema, srcPath) {
56
56
  let functionName = "Process" + upperCase(flowSchema.flowTag)
57
57
  let handlerType = upperCase(HANDLER.hdrSqs)
58
- let queueName = upperCase(flowSchema.flowTag) + handlerType;
58
+ let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
59
59
 
60
60
  return {
61
61
  templatePath: templatePath,
@@ -62,18 +62,18 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
62
62
  if (flowSteps.includes("In")) {
63
63
  generatedSnsTopicInForFlowSchema.push(
64
64
  {
65
- queueName: upperCase(flowSchema.flowTag),
65
+ queueName: "Process" + upperCase(flowSchema.flowTag) + upperCase(HANDLER.hdrSqs)
66
66
  }
67
67
  )
68
68
  }
69
69
 
70
- if (flowSteps.includes("Out") && flowSchema.outputTopic === true) {
71
- generatedSnsTopicInForFlowSchema.push(
72
- {
73
- queueName: upperCase(flowSchema.flowTag) + "Complete" + upperCase(HANDLER.hdrSqs)
74
- }
75
- )
76
- }
70
+ // if (flowSteps.includes("Out") && flowSchema.outputTopic === true) {
71
+ // generatedSnsTopicInForFlowSchema.push(
72
+ // {
73
+ // queueName: upperCase(flowSchema.flowTag) + "Complete" + upperCase(HANDLER.hdrSqs)
74
+ // }
75
+ // )
76
+ // }
77
77
 
78
78
  for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
79
79
  resultsForCreateDefaultSnsInSqs.push({
@@ -70,7 +70,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
70
70
  functionName,
71
71
  tableName,
72
72
  flowSchemaComplete,
73
- triggerType
73
+ triggerType,
74
74
  },
75
75
  setting: {
76
76
  savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
@@ -36,7 +36,8 @@ const triggeredCacheSharedLib = require('@izara_project/izara-core-library-trigg
36
36
  const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs.js')
37
37
  <% } else if (statusType === "storedCache") { -%>
38
38
  const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
39
- <% } %>
39
+ <% } -%>
40
+ const { createFlowTypeConcat } = require('@izara_project/izara-core-library-service-schemas').utils
40
41
  //(<optionalRequire>)
41
42
  //(</optionalRequire>)
42
43
  /**
@@ -73,13 +74,14 @@ module.exports.<%- functionName %> = async (
73
74
  <% if (statusType === "statusField") { %>
74
75
  <%- include(statusFieldTemplate) %>
75
76
  <% } else if (statusType === "storedCache") { %>
76
- <%- include(storedCacheTemplate, {tableName:tableName,flowSchemaComplete:flowSchemaComplete}) %>
77
+ <%- include(storedCacheTemplate, {tableName:tableName, flowSchemaComplete:flowSchemaComplete,flowTag}) %>
77
78
 
78
79
  <% } else if (statusType === "triggerCache") { %>
79
80
  <%- include(triggerCacheTemplate, {
80
81
  tableName: tableName,
81
82
  flowSchemaComplete: flowSchemaComplete,
82
- triggerType: triggerType
83
+ triggerType: triggerType,
84
+ flowTag
83
85
  }) %>
84
86
  <% } %>
85
87
 
@@ -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) {
@@ -24,6 +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
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
27
28
 
28
29
  const <%- functionName %> = require('./<%- functionName %>_Main')
29
30
 
@@ -178,8 +178,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
178
178
  for (const flowSchema of allLocalFlowSchemas.records) {
179
179
  // console.log("flowSchema in Generate TemplateData", flowSchema);
180
180
  const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
181
- const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
182
- createSourceParams.push(...webSocketGenerateCodeLibs, ...flowSchemaEndpointMainFunction)
181
+ if (!flowSchema.event.includes("s3")) {
182
+ const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
183
+ createSourceParams.push(...webSocketGenerateCodeLibs, ...flowSchemaEndpointMainFunction)
184
+ }
183
185
 
184
186
  // event has [s3, extTopic, ownTopic, eventBridge, lambdaSync]
185
187
  for (const event of flowSchema.event) {
@@ -190,22 +192,22 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
190
192
  const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
191
193
  const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
192
194
  const mainFunctionCreateObjectWebSocket = await createMainFunctionCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
193
- const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
194
- const webSocketCreateObjectCompleteQueue = createWebSocketCreateObjectCompleteQueue(_izContext, saveFilePath);
195
- const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath)
196
- const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, flowSchema, saveFilePath);
195
+ // const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
196
+ // const webSocketCreateObjectCompleteQueue = createWebSocketCreateObjectCompleteQueue(_izContext, saveFilePath);
197
+ // const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath)
198
+ // const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, flowSchema, saveFilePath);
197
199
 
198
200
  // const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
199
201
 
200
- const getPreSignUrlFunctionYaml = createReservedLimitFunctionYaml(_izContext, flowSchema, saveFilePath);
201
- const getPreSignUrlHandler = createReservedLimitHandler(_izContext, flowSchema, saveFilePath);
202
- const getPreSignUrlMainFunction = createReservedLimitMainFunction(_izContext, flowSchema, saveFilePath);
203
- 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);
204
206
 
205
- const reservedLimitCompleteFunctionYaml = createPresignUrlFunctionYaml(_izContext, flowSchema, saveFilePath);
206
- const reservedLimitCompleteMainFunction = createPresignUrlMainFunction(_izContext, flowSchema, saveFilePath);
207
- const reservedLimitCompleteHandler = createPresignUrlHandler(_izContext, flowSchema, saveFilePath);
208
- 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);
209
211
 
210
212
  const processAfterUploadFunctionYmlS3 = createProcessAfterUploadS3FunctionYmlS3(_izContext, flowSchema, saveFilePath);
211
213
  // const processAfterUploadFunctionYamlHdrDsq = createProcessAfterUploadS3FunctionYmlDsq(_izContext, saveFilePath);
@@ -223,24 +225,24 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
223
225
  ...functionYamlCreateObjectWebSocket,
224
226
  ...handlerCreateObjectWebSocket,
225
227
  ...mainFunctionCreateObjectWebSocket,
226
- ...webSocketCreateObjectCompleteFunctionYaml,
227
- ...webSocketCreateObjectCompleteQueue,
228
- ...webSocketCreateObjectCompleteMainFunction,
229
- ...webSocketCreateObjectCompleteHandler
228
+ // ...webSocketCreateObjectCompleteFunctionYaml,
229
+ // ...webSocketCreateObjectCompleteQueue,
230
+ // ...webSocketCreateObjectCompleteMainFunction,
231
+ // ...webSocketCreateObjectCompleteHandler
230
232
  ];
231
233
 
232
234
  const getPreSignUrlResources = [
233
- ...getPreSignUrlFunctionYaml,
234
- ...getPreSignUrlHandler,
235
- ...getPreSignUrlMainFunction,
236
- ...getPreSignUrlQueue
235
+ ...reservedLimitFunctionYaml,
236
+ ...reservedLimitHandlerFunction,
237
+ ...reservedLimitMainFunction,
238
+ ...reservedLimitQueueName
237
239
  ];
238
240
 
239
241
  const reservedLimitResources = [
240
- ...reservedLimitCompleteFunctionYaml,
241
- ...reservedLimitCompleteHandler,
242
- ...reservedLimitCompleteMainFunction,
243
- ...reservedLimitCompleteQueue
242
+ ...presignUrlFunctionYaml,
243
+ ...presignUrlHandlerFunction,
244
+ ...presignUrlMainFunction,
245
+ ...presignUrlQueueName
244
246
  ];
245
247
 
246
248
  const processAfterUploadResources = [