@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
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  const path = require('path');
21
21
  const fs = require('fs');
22
22
  const yaml = require('yaml');
23
+
23
24
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
24
25
  const {
25
26
  DEFAULT_HANDLER_PER_ACTION,
@@ -56,6 +57,7 @@ const templatePath = path.join(__dirname, "./template.ejs")
56
57
  */
57
58
  async function data(_izContext, allObjSchemas, srcPath) {
58
59
  let createSourceSet = new Set();
60
+ console.debug('templatePath:::', templatePath)
59
61
  for (const action of Object.values(ACTIONS)) {
60
62
  const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
61
63
  for (const defaultHandler of defaultHandlers) {
@@ -157,31 +159,34 @@ async function createParamForCreateSource(_izContext, allObjSchemas, action, han
157
159
  const configPath = path.join(srcPath, '../../config/serverless.config.yml');
158
160
  const serverlessConfig = fs.readFileSync(configPath, 'utf8');
159
161
  const config = yaml.parse(serverlessConfig);
160
- const serviceTag = config.main_config.iz_serviceTag;
162
+ const ownServiceTag = config.main_config.iz_serviceTag;
163
+ let parentTables = [];
161
164
  // create lambdaRole for parent dynamo table if able
162
165
  for (const objectSchema of allObjSchemas.records) {
163
166
  if (objectSchema.hasOwnProperty("extendObjType")) {
164
167
  for (const storageResource of Object.values(objectSchema.storageResources)) {
165
168
  if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
166
- if (storageResource.serviceTag) {
167
- if (storageResource.serviceTag !== serviceTag) {
168
- additionalResourcePermission.push(
169
- createIamRole(
170
- {
171
- [RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
172
- },
173
- [
174
- externalResourceYaml(RESOURCE_CLASSES.dynamoDbAcrossService, upperCase(storageResource.tableName), storageResource.serviceTag)
175
- ]
176
- )
177
- )
178
- }
169
+ if (storageResource.serviceTag && storageResource.serviceTag !== ownServiceTag) {
170
+ parentTables.push({ tableName: storageResource.tableName, serviceTag: storageResource.serviceTag })
179
171
  }
180
172
  }
181
173
  }
182
174
  }
183
175
  }
184
176
 
177
+ if (parentTables) {
178
+ additionalResourcePermission.push(
179
+ createIamRole(
180
+ {
181
+ [RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
182
+ },
183
+ parentTables.map(parentTable =>
184
+ externalResourceYaml(RESOURCE_CLASSES.dynamoDbAcrossService, upperCase(parentTable.tableName), parentTable.serviceTag)
185
+ )
186
+ )
187
+ )
188
+ }
189
+
185
190
  let resourceApis = [];
186
191
  if (handler === HANDLER.hdrApi) {
187
192
  for (const objectSchema of allObjSchemas.records) {
@@ -202,7 +207,8 @@ async function createParamForCreateSource(_izContext, allObjSchemas, action, han
202
207
  roleName: groupBy,
203
208
  action: action,
204
209
  functionNameConfig,
205
- resourceApis
210
+ resourceApis,
211
+ serviceTag: ownServiceTag
206
212
  },
207
213
  setting: {
208
214
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -10,13 +10,13 @@
10
10
  <%_ } else if (handlerType === "hdrApi") { _%>
11
11
  <%_ resourceApis.forEach(resourceApi => { _%>
12
12
  - httpApi:
13
- path: /<%- resourceApi.event %>/<%- action %>
13
+ path: /<%- serviceTag %>/<%- resourceApi.event %>/<%- action %>
14
14
  method: <%- resourceApi.method %>
15
15
  authorizer: authorizerServiceSchema
16
16
  #<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
17
17
  #<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
18
18
  - httpApi:
19
- path: /<%- resourceApi.event %>/<%- action %>/{targetUserId}
19
+ path: /<%- serviceTag %>/<%- resourceApi.event %>/<%- action %>/{targetUserId}
20
20
  method: <%- resourceApi.method %>
21
21
  authorizer: authorizerIdentifiers
22
22
  #<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
@@ -92,6 +92,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
92
92
  passOnProperties.push(record.body.Message.returnMessage)
93
93
  passOnProperties.push(record.body.Message.errorsFound)
94
94
  passOnProperties.push(record.body.Message.passStatus)
95
+ //(<additionalProperties>)
96
+ //(</additionalProperties>)
95
97
  passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message))
96
98
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
97
99
 
@@ -22,6 +22,7 @@ const snsSharedLib = require('@izara_project/izara-core-library-sns')
22
22
  const sns = require('@izara_project/izara-core-library-external-request').sns
23
23
  const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
24
24
  const { getNestObject } = require('../../../../libs/source/GenerateCodeLibs');
25
+
25
26
  //(<optionalRequired>)
26
27
  //(</optionalRequired>)
27
28
  /**
@@ -44,7 +45,9 @@ module.exports.confirmNewReserved = async (
44
45
  returnMessage,
45
46
  errorsFound,
46
47
  passStatus,
47
- passBackProperties
48
+ //(<additionalProperties>)
49
+ //(</additionalProperties>)
50
+ passBackProperties = {}
48
51
 
49
52
  ) => {
50
53
  try {
@@ -76,7 +79,7 @@ module.exports.confirmNewReserved = async (
76
79
 
77
80
  let sendMessageToConfirmUsage = {
78
81
  Message: JSON.stringify(confirmUsageMessage),
79
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'InConfirmUsage', consts.EXTERNAL_SERVICE_NAME.accountLimits)
82
+ TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'ConfirmUsage_In', consts.EXTERNAL_SERVICE_NAME.accountLimits)
80
83
  };
81
84
  _izContext.logger.debug("sendMessageToConfirmUsage", sendMessageToConfirmUsage);
82
85
  await sns.publishAsync(_izContext, sendMessageToConfirmUsage);
@@ -94,24 +97,25 @@ module.exports.confirmNewReserved = async (
94
97
  }
95
98
  )
96
99
 
97
- // update importBatchMainTable
98
- let sendMessageToUpdateImportBatchStatus = {
100
+ let sendMessageToUpdateStatus = {
99
101
  objInstanceFull: {
100
102
  identifiers: {
101
- importBatchId: servicePendingId
103
+ //(<identifiers>)
104
+ //(</identifiers>)
102
105
  },
103
106
  fields: {
104
- importBatchStatus: 'uploadComplete'
107
+ //(<fields>)
108
+ //(</fields>)
105
109
  }
106
110
  }
107
111
  }
108
112
 
109
- let sendMessageToUpdateImportBatch = {
113
+ let sendMessageToUpdateEndpoint = {
110
114
  Message: JSON.stringify(sendMessageToUpdateImportBatchStatus),
111
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, `InImportBatchMainUpdate`)
115
+ TopicArn: await snsSharedLib.snsTopicArn(_izContext, "Update_In")
112
116
  };
113
- _izContext.logger.debug("sendMessageToUpdateImportBatch", sendMessageToUpdateImportBatch);
114
- await sns.publishAsync(_izContext, sendMessageToUpdateImportBatch);
117
+ _izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
118
+ await sns.publishAsync(_izContext, sendMessageToUpdateEndpoint);
115
119
 
116
120
  return { returnResponse: 'success' }
117
121
 
@@ -25,7 +25,7 @@ const getObjectSchema = require('@izara_project/izara-core-library-service-schem
25
25
 
26
26
  /**
27
27
  * receive objectSchema
28
- * create data for WebScoket handler template
28
+ * create data for WebSocket handler template
29
29
  *
30
30
  * @param {Object} objectSchema
31
31
  * @return {{templatePath, templateData,setting}}
@@ -38,11 +38,28 @@ async function data(_izContext, flowSchema, srcPath) {
38
38
 
39
39
  async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
40
40
  let functionName = upperCase(FUNCTION_NAME.createObjectS3)
41
- // let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
42
- // let fieldNames = Object.keys(objectSchema.fieldNames)
41
+ let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
42
+ let objectType = flowSchema.objType.objectType
43
+ let createdFieldNames = [];
44
+ let statusFieldNames = [];
45
+ for (const [fieldNames, fieldSettings] of Object.entries(objectSchema.fieldNames)) {
46
+ if (fieldSettings.hasOwnProperty("requiredOnCreate") && fieldSettings.requiredOnCreate === true) {
47
+ createdFieldNames.push(fieldNames);
48
+ }
49
+
50
+ if (fieldSettings.hasOwnProperty("statusField") && fieldSettings.statusField === true) {
51
+ statusFieldNames.push(fieldNames)
52
+ }
53
+ }
54
+
43
55
  return {
44
56
  templatePath: templatePath,
45
- templateData: {},
57
+ templateData: {
58
+ flowTag: flowSchema.flowTag,
59
+ createdFieldNames: createdFieldNames,
60
+ statusFieldNames: statusFieldNames,
61
+ objectType
62
+ },
46
63
  setting: {
47
64
  savePath: path.join(srcPath, SOURCE_PATH.webSocket, flowSchema.flowTag, "source/"),
48
65
  saveFileName: `${functionName}_Main`,
@@ -35,8 +35,10 @@ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryEr
35
35
  const { v4: uuidv4 } = require('uuid')
36
36
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
37
  const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
+
38
39
  //(<optionalRequired>)
39
40
  //(</optionalRequired>)
41
+
40
42
  /**
41
43
  *
42
44
  *
@@ -65,9 +67,6 @@ module.exports.createObject = async (
65
67
  _izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
66
68
  _izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
67
69
 
68
- _izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev");
69
- _izContext.correlationIds.set(coreConsts.TARGET_ID, "BasDevTarget");
70
-
71
70
  let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
72
71
  flowTag: "<%- flowTag %>",
73
72
  serviceTag: process.env.iz_serviceTag
@@ -75,6 +74,8 @@ module.exports.createObject = async (
75
74
 
76
75
  _izContext.logger.debug("getFlowSchema", flowSchema)
77
76
 
77
+ let userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID)
78
+ let submittedByUserId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
78
79
 
79
80
  if (!flowSchema) {
80
81
  throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`)
@@ -96,17 +97,10 @@ module.exports.createObject = async (
96
97
  //(</beforeCreateHook>)
97
98
  // create message Object to create Endpoint
98
99
  let messageObject = {
100
+ objectType: <%- objectType %>
99
101
  fieldNames: {
100
- userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
101
- // userId: "mockUserId",
102
- submittedByUserId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
103
- // submittedByUserId: "mockSubmittedByUserId",
104
- startTime: Date.now(),
105
- importConfigId: requestParams.importConfigId,
106
- importBatchStatus: "processing",
107
- importType: requestParams.importType,
108
- fileName: requestParams.fileName,
109
- fileSize: requestParams.fileSize
102
+ //(<fieldNamesHook>)
103
+ //(</fieldNamesHook>)
110
104
  }
111
105
  }
112
106
  // create callingFlow
@@ -120,7 +114,7 @@ module.exports.createObject = async (
120
114
  )
121
115
  )
122
116
 
123
- // send message to ImportBatchCreateHdrSqs
117
+ // send message to Create endpoint
124
118
  let sendMessageToCreateEndpoint = {
125
119
  Message: JSON.stringify(messageObject),
126
120
  TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "Create_In")
@@ -92,6 +92,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
92
92
  passOnProperties.push(record.body.Message.returnMessage)
93
93
  passOnProperties.push(record.body.Message.errorsFound)
94
94
  passOnProperties.push(record.body.Message.passStatus)
95
+ //(<additionalProperties>)
96
+ //(</additionalProperties>)
95
97
  passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message))
96
98
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
97
99
 
@@ -56,7 +56,9 @@ module.exports.createPresignUrl = async (
56
56
  returnMessage,
57
57
  errorsFound,
58
58
  passStatus,
59
- passBackProperties
59
+ //(<additionalProperties>)
60
+ //(</additionalProperties>)
61
+ passBackProperties = {}
60
62
  ) => {
61
63
 
62
64
  try {
@@ -75,32 +77,18 @@ module.exports.createPresignUrl = async (
75
77
  const correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID)
76
78
  const connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
77
79
 
78
- // getImportBatchMain from table
79
- let importBatchMain = await lambda.invokeSync(_izContext,
80
+ let getResult = await lambda.invokeSync(_izContext,
80
81
  await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
81
82
  {
82
- identifiers: {
83
- importBatchId: servicePendingId
84
- },
85
83
  objectType: objType.objectType
84
+ //(<identifiers>)
85
+ //(</identifiers>)
86
86
  }
87
87
  )
88
- _izContext.logger.debug("importBatchMain", importBatchMain);
89
-
90
- const {
91
- importBatchId
92
- } = importBatchMain.identifiers
93
-
94
- const {
95
- importBatchStatus,
96
- importConfigId,
97
- fileName,
98
- fileSize,
99
- importType,
100
- startTime,
101
- submittedByUserId,
102
- userId
103
- } = importBatchMain.fields
88
+ _izContext.logger.debug("getResult", getResult);
89
+
90
+ //(<afterGetResult>)
91
+ //(</afterGetResult>)
104
92
 
105
93
  let uniqueIdentify = getNestObject(
106
94
  _izContext,
@@ -112,10 +100,8 @@ module.exports.createPresignUrl = async (
112
100
  await dynamodbSharedLib.putItem(_izContext,
113
101
  await dynamodbSharedLib.tableName(_izContext, "ReservedDataMain"),
114
102
  {
115
- servicePendingId: importBatchId, // importBatchId
116
- reservedDataId: reservedDataId,
117
- reservedValue: fileSize,
118
- uniqueIdentify: uniqueIdentify
103
+ //(<createReservedDataMain>)
104
+ //(</createReservedDataMain>)
119
105
  }
120
106
  );
121
107
 
@@ -125,38 +111,38 @@ module.exports.createPresignUrl = async (
125
111
  _izContext.logger.debug("reserved has reach limit");
126
112
 
127
113
  errorsFound.push("reserved has reach limit")
128
- // update importBatchMainTable
129
- let updateImportBatchMainMsg = {
114
+ // update status
115
+ let updateStatusField = {
130
116
  objInstanceFull: {
131
117
  identifiers: {
132
- importBatchId: importBatchId
118
+ //(<identifiers>)
119
+ //(</identifiers>)
133
120
  },
134
121
  fields: {
135
- importBatchStatus: "error",
136
- errorsFound: errorsFound
122
+ //(<fields>)
123
+ //(</fields>)
137
124
  }
138
125
  },
139
126
  objType: objType.objectType
140
127
  }
141
128
 
142
- let sendMessageToUpdateImportBatch = {
143
- Message: JSON.stringify(updateImportBatchMainMsg),
129
+ let sendMessageToUpdateEndpoint = {
130
+ Message: JSON.stringify(updateStatusField),
144
131
  TopicArn: await snsSharedLib.snsTopicArn(_izContext, `Update_In`)
145
132
  }
146
- _izContext.logger.debug("sendMessageToUpdateImportBatch", sendMessageToUpdateImportBatch);
133
+ _izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
147
134
 
148
135
  // cancel reserved
149
136
 
150
-
151
137
  let cancelReservedMsg = {
152
- userId: userId,
138
+ userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
153
139
  limitTag: returnMessage.limitTag,
154
140
  uniqueIdentify: uniqueIdentify
155
141
  };
156
142
 
157
143
  let sendMessageToCancelReserved = {
158
144
  Message: JSON.stringify(cancelReservedMsg),
159
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'InCancelUsage', EXTERNAL_SERVICE_NAME.accountLimits)
145
+ TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'CancelUsage_In', EXTERNAL_SERVICE_NAME.accountLimits)
160
146
  };
161
147
 
162
148
  _izContext.logger.debug("sendMessageToCancelReserved", sendMessageToCancelReserved);
@@ -173,22 +159,23 @@ module.exports.createPresignUrl = async (
173
159
  )
174
160
  }
175
161
 
176
- // store reservedDataId and servicePendingId in ReservedDataMain
177
-
178
-
179
- const Key = `${fileName}.${importType}`
162
+ //(<createKeyForUploadFile>)
163
+ const Key = `${fileName}.${importType}`
164
+ //(</createKeyForUploadFile>)
180
165
 
181
166
  const maximumSize = fileSize * 1048576 // convert to byte unit for restrict
182
167
  _izContext.logger.debug("maximumSize", maximumSize);
183
168
 
184
169
  // create PresignUrl
185
170
  let createPresignUrlParam = {
186
- Bucket: "generatecodetemplatebas-integration-test",
171
+ Bucket: "<%- bucketName %>",
187
172
  Key: Key,
188
173
  Conditions: [
174
+ //(<conditionCreateUrlLink>)
189
175
  ["content-length-range", 0, maximumSize],
190
176
  ["starts-with", "$Content-Type", "file/csv"],
191
177
  ["eq", "$x-amz-meta-importBatchId", importBatchId]
178
+ //(</conditionCreateUrlLink>)
192
179
  ],
193
180
  fields: {},
194
181
  expires: 86400
@@ -197,15 +184,18 @@ module.exports.createPresignUrl = async (
197
184
 
198
185
  const uploadUrl = await createPresignedPost(client, createPresignUrlParam);
199
186
 
200
- uploadUrl.fields['x-amz-meta-importBatchId'] = importBatchId;
201
- uploadUrl.fields['Content-Type'] = `file/${importType}`;
187
+ //(<modifyUploadLinkField>)
188
+ uploadUrl.fields['x-amz-meta-importBatchId'] = importBatchId;
189
+ uploadUrl.fields['Content-Type'] = `file/${importType}`;
190
+ //(</modifyUploadLinkField>)
202
191
 
203
192
  _izContext.logger.debug('uploadUrlLimitSize: ', uploadUrl) // return as object type = {url, fields}
204
193
 
205
194
  // update to waiting to upload
206
- if (importBatchStatus === "processing") {
207
-
208
- let updateImportBatchMainMsg = {
195
+ //(<checkStatusField>)
196
+ if (status === "processing") {
197
+ //(</checkStatusField>)
198
+ let messageObject = {
209
199
  objInstanceFull: {
210
200
  identifiers: {
211
201
  importBatchId: importBatchId
@@ -218,8 +208,8 @@ module.exports.createPresignUrl = async (
218
208
  objectType: objType,objectType
219
209
  }
220
210
 
221
- updateImportBatchMainMsg = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
222
- updateImportBatchMainMsg,
211
+ messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
212
+ messageObject,
223
213
  callingFlowSharedLib.addParentCallingFlowConfig(
224
214
  returnMessage, // resive parent callingFlowConfig.
225
215
  callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
@@ -228,14 +218,14 @@ module.exports.createPresignUrl = async (
228
218
  )
229
219
  );
230
220
 
231
- _izContext.logger.debug("after add callingFlow", updateImportBatchMainMsg)
221
+ _izContext.logger.debug("after add callingFlow", messageObject)
232
222
 
233
- let sendMessageToUpdateImportBatch = {
234
- Message: JSON.stringify(updateImportBatchMainMsg),
235
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, `In${objType.objectType}Update`)
223
+ let sendMessageToUpdateEndpoint = {
224
+ Message: JSON.stringify(messageObject),
225
+ TopicArn: await snsSharedLib.snsTopicArn(_izContext, "Update_In")
236
226
  }
237
- _izContext.logger.debug("sendMessageToUpdateImportBatch", sendMessageToUpdateImportBatch);
238
- await sns.publishAsync(_izContext, sendMessageToUpdateImportBatch);
227
+ _izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
228
+ await sns.publishAsync(_izContext, sendMessageToUpdateEndpoint);
239
229
 
240
230
  await dynamodbSharedLib.updateItem(_izContext,
241
231
  await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
@@ -78,7 +78,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
78
78
  //validate message (and MessageAttributes)
79
79
  await recordHandlerSharedLib.validateRecord(
80
80
  record, // one record will send to mainFunction
81
- "GetPresignUrlHdrSqs", // queue name that need to retry or send to dlq
81
+ "ReservedLimitHdrSqs", // queue name that need to retry or send to dlq
82
82
  perRecordsValidatorSchema, // schema for record.Message
83
83
  // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
84
84
  );
@@ -86,6 +86,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
86
86
  // add argument (to invoke lambda) to passOnProperties[]
87
87
  passOnProperties.push(record.body.Message.objType)
88
88
  passOnProperties.push(record.body.Message.objInstanceFull)
89
+ //(<additionalProperties>)
90
+ //(</additionalProperties>)
89
91
  passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message)) // is Ok PassBackProperties
90
92
  // passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)) // is Ok callinfFlow
91
93
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
@@ -94,7 +96,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
94
96
  let recordPromise = recordHandlerSharedLib.recordHandler(
95
97
  record, // one record will send to mainFunction
96
98
  reservedLimit.reservedLimit, // mainFunction that need to invoke.
97
- "GetPresignUrlHdrSqs", // queue name that need to retry or send to dlq
99
+ "ReservedLimitHdrSqs", // queue name that need to retry or send to dlq
98
100
  passOnProperties, // all parameters that mainFunction needed.
99
101
  );
100
102
  record._izContext.logger.debug('after recordPromise in handler');
@@ -114,7 +116,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
114
116
  Logger.debug('after Promise.all(recordPromises) in handler');
115
117
 
116
118
  } catch (err) {
117
- Logger.error('Unhandled Error, updateNodeCompleteHdrSqs: ', err);
119
+ Logger.error('Unhandled Error, ReservedLimitHdrSqs: ', err);
118
120
  throw (err);
119
121
  }
120
122
  });
@@ -22,6 +22,7 @@ const path = require('path');
22
22
  const templatePath = path.join(__dirname, "./template.ejs")
23
23
  const { firstLetterUpperCase: upperCase } = require('../../../../../../../../MainLibs/src/Utils')
24
24
  const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../../../MainLibs/src/Consts');
25
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema;
25
26
 
26
27
  /**
27
28
  * receive objectSchema
@@ -30,11 +31,11 @@ const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../../../MainLibs
30
31
  * @return {{ templatePath, templateData, setting } }
31
32
  */
32
33
 
33
- function data(_izContext, flowSchema, srcPath) {
34
- return [createSourceParams(_izContext, flowSchema, srcPath)]
34
+ async function data(_izContext, flowSchema, srcPath) {
35
+ return [await createSourceParams(_izContext, flowSchema, srcPath)]
35
36
  }
36
37
 
37
- function createSourceParams(_izContext, flowSchema, srcPath) {
38
+ async function createSourceParams(_izContext, flowSchema, srcPath) {
38
39
  let functionName = upperCase(FUNCTION_NAME.reservedLimit)
39
40
  return {
40
41
  templatePath: templatePath,