@izara_project/izara-market-library-service-schemas 1.0.55 → 1.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +4 -27
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +13 -14
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +14 -11
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +9 -11
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +16 -13
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -10
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +6 -4
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +18 -15
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +15 -11
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +12 -8
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +20 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +16 -21
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +60 -62
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +5 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +4 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +32 -44
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/template.ejs +3 -17
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +391 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +9 -317
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +7 -7
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +18 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +29 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +11 -11
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +16 -16
- package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +3 -0
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/handler/template.ejs +4 -0
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +36 -7
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -4
- package/src/reStructure/TemplateData/perActionEndpoint/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/perActionEndpoint/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/perActionEndpoint/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +1 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +6 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/template.ejs +23 -23
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/template.ejs +18 -16
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/template.ejs +14 -12
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/template.ejs +21 -19
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +3 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/api/template.ejs +24 -22
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/dsq/template.ejs +21 -17
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/inv/template.ejs +21 -19
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/sqs/template.ejs +20 -20
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/handler/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +22 -2
|
@@ -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,8 +67,7 @@ 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.
|
|
69
|
-
_izContext.correlationIds.set(coreConsts.TARGET_ID, "BasDevTarget");
|
|
70
|
+
let correlationIds = _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID)
|
|
70
71
|
|
|
71
72
|
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
72
73
|
flowTag: "<%- flowTag %>",
|
|
@@ -75,38 +76,32 @@ module.exports.createObject = async (
|
|
|
75
76
|
|
|
76
77
|
_izContext.logger.debug("getFlowSchema", flowSchema)
|
|
77
78
|
|
|
79
|
+
let getUserFromTableTask = await dynamodbSharedLib.getItem(_izContext,
|
|
80
|
+
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
81
|
+
{
|
|
82
|
+
taskKey: correlationIds
|
|
83
|
+
}
|
|
84
|
+
)
|
|
78
85
|
|
|
86
|
+
const { userId, submitByUserId } = getUserFromTableTask
|
|
87
|
+
|
|
79
88
|
if (!flowSchema) {
|
|
80
|
-
throw new NoRetryError(`flowTag not found ${requestParams.
|
|
89
|
+
throw new NoRetryError(`flowTag not found ${requestParams.action}`)
|
|
81
90
|
}
|
|
82
91
|
|
|
83
|
-
if (flowSchema.uploadS3 === true) {
|
|
84
|
-
if (!flowSchema.hasOwnProperty("objType")) {
|
|
85
|
-
throw new NoRetryError(`flowTag has uploadS3 setting should have objType in flowSchema`)
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
92
|
// get objectType
|
|
90
93
|
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType)
|
|
91
94
|
_izContext.logger.debug("objectSchema in flowSchema mainFunction", objectSchema)
|
|
92
95
|
|
|
93
|
-
_izContext.correlationIds.get(coreConsts.X_CORRELATION_ID)
|
|
94
96
|
|
|
95
97
|
//(<beforeCreateHook>)
|
|
96
98
|
//(</beforeCreateHook>)
|
|
97
99
|
// create message Object to create Endpoint
|
|
98
100
|
let messageObject = {
|
|
101
|
+
objectType: "<%- objectType %>",
|
|
99
102
|
fieldNames: {
|
|
100
|
-
|
|
101
|
-
//
|
|
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
|
|
103
|
+
//(<fieldNamesHook>)
|
|
104
|
+
//(</fieldNamesHook>)
|
|
110
105
|
}
|
|
111
106
|
}
|
|
112
107
|
// create callingFlow
|
|
@@ -120,7 +115,7 @@ module.exports.createObject = async (
|
|
|
120
115
|
)
|
|
121
116
|
)
|
|
122
117
|
|
|
123
|
-
// send message to
|
|
118
|
+
// send message to Create endpoint
|
|
124
119
|
let sendMessageToCreateEndpoint = {
|
|
125
120
|
Message: JSON.stringify(messageObject),
|
|
126
121
|
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
|
|
|
@@ -37,10 +37,12 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
37
37
|
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
38
38
|
let functionName = upperCase(FUNCTION_NAME.createPresignUrl)
|
|
39
39
|
let bucketName = flowSchema.bucketName
|
|
40
|
+
let flowTag = flowSchema.flowTag
|
|
40
41
|
return {
|
|
41
42
|
templatePath: templatePath,
|
|
42
43
|
templateData: {
|
|
43
|
-
bucketName
|
|
44
|
+
bucketName,
|
|
45
|
+
flowTag
|
|
44
46
|
},
|
|
45
47
|
setting: {
|
|
46
48
|
saveFileName: `${functionName}_Main`,
|
|
@@ -37,6 +37,8 @@ const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
|
37
37
|
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils');
|
|
38
38
|
const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
|
|
39
39
|
const { EXTERNAL_SERVICE_NAME } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
|
|
40
|
+
const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils
|
|
41
|
+
|
|
40
42
|
/**
|
|
41
43
|
* description of function.
|
|
42
44
|
* @param {Object} _izContext
|
|
@@ -56,7 +58,9 @@ module.exports.createPresignUrl = async (
|
|
|
56
58
|
returnMessage,
|
|
57
59
|
errorsFound,
|
|
58
60
|
passStatus,
|
|
59
|
-
|
|
61
|
+
//(<additionalProperties>)
|
|
62
|
+
//(</additionalProperties>)
|
|
63
|
+
passBackProperties = {}
|
|
60
64
|
) => {
|
|
61
65
|
|
|
62
66
|
try {
|
|
@@ -75,32 +79,18 @@ module.exports.createPresignUrl = async (
|
|
|
75
79
|
const correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID)
|
|
76
80
|
const connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
let importBatchMain = await lambda.invokeSync(_izContext,
|
|
82
|
+
let getResult = await lambda.invokeSync(_izContext,
|
|
80
83
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
|
|
81
84
|
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
objectType: objType.objectType
|
|
85
|
+
objectType: objType.objectType,
|
|
86
|
+
//(<identifiers>)
|
|
87
|
+
//(</identifiers>)
|
|
86
88
|
}
|
|
87
89
|
)
|
|
88
|
-
_izContext.logger.debug("
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
|
90
|
+
_izContext.logger.debug("getResult", getResult);
|
|
91
|
+
|
|
92
|
+
//(<afterGetResult>)
|
|
93
|
+
//(</afterGetResult>)
|
|
104
94
|
|
|
105
95
|
let uniqueIdentify = getNestObject(
|
|
106
96
|
_izContext,
|
|
@@ -111,12 +101,9 @@ module.exports.createPresignUrl = async (
|
|
|
111
101
|
|
|
112
102
|
await dynamodbSharedLib.putItem(_izContext,
|
|
113
103
|
await dynamodbSharedLib.tableName(_izContext, "ReservedDataMain"),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
reservedValue: fileSize,
|
|
118
|
-
uniqueIdentify: uniqueIdentify
|
|
119
|
-
}
|
|
104
|
+
//(<createReservedDataMain>)
|
|
105
|
+
{}
|
|
106
|
+
//(</createReservedDataMain>)
|
|
120
107
|
);
|
|
121
108
|
|
|
122
109
|
if (passStatus === false) { // if passStatus false post message to client
|
|
@@ -125,38 +112,38 @@ module.exports.createPresignUrl = async (
|
|
|
125
112
|
_izContext.logger.debug("reserved has reach limit");
|
|
126
113
|
|
|
127
114
|
errorsFound.push("reserved has reach limit")
|
|
128
|
-
// update
|
|
129
|
-
let
|
|
115
|
+
// update status
|
|
116
|
+
let updateStatusField = {
|
|
130
117
|
objInstanceFull: {
|
|
131
118
|
identifiers: {
|
|
132
|
-
|
|
119
|
+
//(<identifiers>)
|
|
120
|
+
//(</identifiers>)
|
|
133
121
|
},
|
|
134
122
|
fields: {
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
//(<fields>)
|
|
124
|
+
//(</fields>)
|
|
137
125
|
}
|
|
138
126
|
},
|
|
139
127
|
objType: objType.objectType
|
|
140
128
|
}
|
|
141
129
|
|
|
142
|
-
let
|
|
143
|
-
Message: JSON.stringify(
|
|
130
|
+
let sendMessageToUpdateEndpoint = {
|
|
131
|
+
Message: JSON.stringify(updateStatusField),
|
|
144
132
|
TopicArn: await snsSharedLib.snsTopicArn(_izContext, `Update_In`)
|
|
145
133
|
}
|
|
146
|
-
_izContext.logger.debug("
|
|
134
|
+
_izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
|
|
147
135
|
|
|
148
136
|
// cancel reserved
|
|
149
137
|
|
|
150
|
-
|
|
151
138
|
let cancelReservedMsg = {
|
|
152
|
-
userId:
|
|
139
|
+
userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
|
|
153
140
|
limitTag: returnMessage.limitTag,
|
|
154
141
|
uniqueIdentify: uniqueIdentify
|
|
155
142
|
};
|
|
156
143
|
|
|
157
144
|
let sendMessageToCancelReserved = {
|
|
158
145
|
Message: JSON.stringify(cancelReservedMsg),
|
|
159
|
-
TopicArn: await snsSharedLib.snsTopicArn(_izContext, '
|
|
146
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, 'CancelUsage_In', EXTERNAL_SERVICE_NAME.accountLimits)
|
|
160
147
|
};
|
|
161
148
|
|
|
162
149
|
_izContext.logger.debug("sendMessageToCancelReserved", sendMessageToCancelReserved);
|
|
@@ -171,24 +158,26 @@ module.exports.createPresignUrl = async (
|
|
|
171
158
|
connectionId: connectionId
|
|
172
159
|
}
|
|
173
160
|
)
|
|
161
|
+
return "reserved not pass"
|
|
174
162
|
}
|
|
175
163
|
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const Key = `${fileName}.${importType}`
|
|
164
|
+
//(<createKeyForUploadFile>)
|
|
165
|
+
const Key = `${fileName}.${importType}`
|
|
166
|
+
//(</createKeyForUploadFile>)
|
|
180
167
|
|
|
181
168
|
const maximumSize = fileSize * 1048576 // convert to byte unit for restrict
|
|
182
169
|
_izContext.logger.debug("maximumSize", maximumSize);
|
|
183
170
|
|
|
184
171
|
// create PresignUrl
|
|
185
172
|
let createPresignUrlParam = {
|
|
186
|
-
Bucket: "
|
|
173
|
+
Bucket: "<%- bucketName %>",
|
|
187
174
|
Key: Key,
|
|
188
175
|
Conditions: [
|
|
176
|
+
//(<conditionCreateUrlLink>)
|
|
189
177
|
["content-length-range", 0, maximumSize],
|
|
190
178
|
["starts-with", "$Content-Type", "file/csv"],
|
|
191
179
|
["eq", "$x-amz-meta-importBatchId", importBatchId]
|
|
180
|
+
//(</conditionCreateUrlLink>)
|
|
192
181
|
],
|
|
193
182
|
fields: {},
|
|
194
183
|
expires: 86400
|
|
@@ -197,29 +186,33 @@ module.exports.createPresignUrl = async (
|
|
|
197
186
|
|
|
198
187
|
const uploadUrl = await createPresignedPost(client, createPresignUrlParam);
|
|
199
188
|
|
|
200
|
-
|
|
201
|
-
|
|
189
|
+
//(<modifyUploadLinkField>)
|
|
190
|
+
uploadUrl.fields['x-amz-meta-importBatchId'] = importBatchId;
|
|
191
|
+
uploadUrl.fields['Content-Type'] = `file/${importType}`;
|
|
192
|
+
//(</modifyUploadLinkField>)
|
|
202
193
|
|
|
203
194
|
_izContext.logger.debug('uploadUrlLimitSize: ', uploadUrl) // return as object type = {url, fields}
|
|
204
195
|
|
|
205
196
|
// update to waiting to upload
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
197
|
+
//(<checkStatusField>)
|
|
198
|
+
if (status === "processing") {
|
|
199
|
+
//(</checkStatusField>)
|
|
200
|
+
let messageObject = {
|
|
209
201
|
objInstanceFull: {
|
|
210
202
|
identifiers: {
|
|
211
|
-
|
|
203
|
+
//(<identifiersForUpdateTable>)
|
|
204
|
+
//(</identifiersForUpdateTable>)
|
|
212
205
|
},
|
|
213
206
|
fields: {
|
|
214
207
|
importBatchStatus: "waitingToUpload",
|
|
215
|
-
expiryTimestamp: (startTime + (createPresignUrlParam.expires * 1000))
|
|
208
|
+
expiryTimestamp: (getResult.startTime + (createPresignUrlParam.expires * 1000))
|
|
216
209
|
}
|
|
217
210
|
},
|
|
218
|
-
objectType: objType
|
|
211
|
+
objectType: objType.objectType
|
|
219
212
|
}
|
|
220
213
|
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
215
|
+
messageObject,
|
|
223
216
|
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
224
217
|
returnMessage, // resive parent callingFlowConfig.
|
|
225
218
|
callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
|
|
@@ -228,19 +221,24 @@ module.exports.createPresignUrl = async (
|
|
|
228
221
|
)
|
|
229
222
|
);
|
|
230
223
|
|
|
231
|
-
_izContext.logger.debug("after add callingFlow",
|
|
224
|
+
_izContext.logger.debug("after add callingFlow", messageObject)
|
|
232
225
|
|
|
233
|
-
let
|
|
234
|
-
Message: JSON.stringify(
|
|
235
|
-
TopicArn: await snsSharedLib.snsTopicArn(_izContext,
|
|
226
|
+
let sendMessageToUpdateEndpoint = {
|
|
227
|
+
Message: JSON.stringify(messageObject),
|
|
228
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "Update_In")
|
|
236
229
|
}
|
|
237
|
-
_izContext.logger.debug("
|
|
238
|
-
await sns.publishAsync(_izContext,
|
|
230
|
+
_izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
|
|
231
|
+
await sns.publishAsync(_izContext, sendMessageToUpdateEndpoint);
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
//(<createIdentifiersFlow>)
|
|
235
|
+
let identifiers
|
|
236
|
+
//(</createIdentifiersFlow>)
|
|
239
237
|
|
|
240
238
|
await dynamodbSharedLib.updateItem(_izContext,
|
|
241
239
|
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
242
240
|
{
|
|
243
|
-
taskKey:
|
|
241
|
+
taskKey: `${createFlowTypeConcat(event._izContext, { flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
|
|
244
242
|
connectionId: connectionId
|
|
245
243
|
},
|
|
246
244
|
{
|
|
@@ -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
|
-
"
|
|
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
|
-
"
|
|
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,
|
|
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,
|
|
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20
20
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
21
21
|
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
22
22
|
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
23
|
-
|
|
23
|
+
const asyncFlowSharedLib = require("@izara_project/izara-core-library-asynchronous-flow")
|
|
24
24
|
const externalRequest = require('@izara_project/izara-core-library-external-request')
|
|
25
25
|
const sns = externalRequest.sns;
|
|
26
26
|
const lambda = externalRequest.lambda
|
|
@@ -45,6 +45,8 @@ module.exports.reservedLimit = async (
|
|
|
45
45
|
_izContext,
|
|
46
46
|
objType,
|
|
47
47
|
objInstanceFull,
|
|
48
|
+
//(<additionalProperties>)
|
|
49
|
+
//(</additionalProperties>)
|
|
48
50
|
callingFlowConfig = {}
|
|
49
51
|
) => {
|
|
50
52
|
|
|
@@ -55,43 +57,25 @@ module.exports.reservedLimit = async (
|
|
|
55
57
|
objInstanceFull,
|
|
56
58
|
callingFlowConfig
|
|
57
59
|
});
|
|
58
|
-
const {
|
|
59
|
-
userId,
|
|
60
|
-
submittedByUserId,
|
|
61
|
-
importConfigId,
|
|
62
|
-
importBatchStatus,
|
|
63
|
-
importType,
|
|
64
|
-
fileName,
|
|
65
|
-
fileSize,
|
|
66
|
-
startTime
|
|
67
|
-
} = objInstanceFull.fields
|
|
68
|
-
const {
|
|
69
|
-
importBatchId
|
|
70
|
-
} = objInstanceFull.identifiers
|
|
71
60
|
|
|
72
61
|
let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID)
|
|
73
|
-
|
|
74
|
-
//
|
|
62
|
+
|
|
63
|
+
//(<beforeReserved>)
|
|
64
|
+
//(</beforeReserved>)
|
|
65
|
+
|
|
75
66
|
|
|
76
67
|
// get static
|
|
77
68
|
let payloadBeforeInvokeStaticLimit = {
|
|
78
|
-
userId:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
targetUserId: submittedByUserId,
|
|
83
|
-
callingFlow: "BasDev",
|
|
84
|
-
callingFlowProperties: {}
|
|
69
|
+
userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
|
|
70
|
+
targetId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
|
|
71
|
+
//(<additionalPropertiesStaticLimit>)
|
|
72
|
+
//(</additionalPropertiesStaticLimit>)
|
|
85
73
|
}
|
|
86
74
|
|
|
87
|
-
let res = await importDataLibs.
|
|
75
|
+
let res = await importDataLibs.processStaticLimit(_izContext,
|
|
88
76
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "StaticLimitProcessHdrInv", consts.EXTERNAL_SERVICE_NAME.accountLimits),
|
|
89
77
|
payloadBeforeInvokeStaticLimit
|
|
90
78
|
)
|
|
91
|
-
// let res = await lambda.invokeSync(_izContext,
|
|
92
|
-
// await lambdaSharedLib.lambdaFunctionName(_izContext, "StaticLimitProcessHdrInv", consts.EXTERNAL_SERVICE_NAME.accountLimits),
|
|
93
|
-
// payloadBeforeInvokeStaticLimit
|
|
94
|
-
// )
|
|
95
79
|
|
|
96
80
|
_izContext.logger.debug("res::", res);
|
|
97
81
|
|
|
@@ -99,27 +83,18 @@ module.exports.reservedLimit = async (
|
|
|
99
83
|
importDataLibs.postToConnection({ message: "static limit over" }, connectionId)
|
|
100
84
|
}
|
|
101
85
|
|
|
102
|
-
|
|
103
86
|
// reservedDynamic
|
|
104
87
|
|
|
105
88
|
let sendMsgReservedDynamic = {
|
|
106
|
-
userId:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
usedTimestamp: startTime,
|
|
111
|
-
targetUserId: submittedByUserId
|
|
89
|
+
userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
|
|
90
|
+
targetUserId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
|
|
91
|
+
//(<additionalPropertiesReservedDynamic>)
|
|
92
|
+
//(</additionalPropertiesReservedDynamic>)
|
|
112
93
|
}
|
|
113
94
|
|
|
114
|
-
const reservedDataId = `${consts.ACCOUNTLIMIT_TAG.reservedDynamic}_${userId}_${consts.LIMIT_TAG.uploadData}`
|
|
115
|
-
|
|
116
95
|
let callingFlowProperties = {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
reservedDataId: reservedDataId
|
|
120
|
-
},
|
|
121
|
-
importConfigId: importConfigId,
|
|
122
|
-
objType: objType
|
|
96
|
+
//(<baseCallingFlowProperties>)
|
|
97
|
+
//(</baseCallingFlowProperties>)
|
|
123
98
|
}
|
|
124
99
|
|
|
125
100
|
_izContext.logger.debug("callingFlowProperties", callingFlowProperties);
|
|
@@ -149,9 +124,22 @@ module.exports.reservedLimit = async (
|
|
|
149
124
|
);
|
|
150
125
|
}
|
|
151
126
|
|
|
127
|
+
// create awaitingSteps
|
|
128
|
+
await asyncFlowSharedLib.createAwaitingStep(_izContext,
|
|
129
|
+
asyncFlowSharedLib.createAwaitingStepId(
|
|
130
|
+
//(<createAwaitStepId>)
|
|
131
|
+
//(</createAwaitStepId>)
|
|
132
|
+
),
|
|
133
|
+
asyncFlowSharedLib.createPendingStepId(
|
|
134
|
+
//(<createPendingStepId>)
|
|
135
|
+
//(</createPendingStepId>)
|
|
136
|
+
)
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
152
140
|
let sendMessageToReservedDynamic = {
|
|
153
141
|
Message: JSON.stringify(sendMsgReservedDynamic),
|
|
154
|
-
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "
|
|
142
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "ReservedDynamicUsage_In", consts.EXTERNAL_SERVICE_NAME.accountLimits)
|
|
155
143
|
};
|
|
156
144
|
_izContext.logger.debug("sendMessageToReservedDynamic", sendMessageToReservedDynamic);
|
|
157
145
|
await sns.publishAsync(_izContext, sendMessageToReservedDynamic);
|
|
@@ -37,6 +37,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
37
37
|
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
|
|
38
38
|
event.Records[0].s3.bucket,
|
|
39
39
|
event.Records[0].s3.object,
|
|
40
|
+
//(<additionalProperties>)
|
|
41
|
+
//(</additionalProperties>)
|
|
40
42
|
);
|
|
41
43
|
|
|
42
44
|
if (processImageResponse instanceof Error) {
|
|
@@ -49,20 +51,4 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
49
51
|
event._izContext.logger.error('Error, processAfterUploadHdrS3: ', err);
|
|
50
52
|
return (izara.response.failure(err));
|
|
51
53
|
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
// s3: {
|
|
56
|
-
// s3SchemaVersion: '1.0',
|
|
57
|
-
// configurationId: 'ImageStandardTestProcessImageFileHdrS3-68a737133cefb25bff959852b8f04754',
|
|
58
|
-
// bucket: {
|
|
59
|
-
// name: 'image-test-importdata',
|
|
60
|
-
// ownerIdentity: { principalId: 'A3CDE97VJKTOJ0' },
|
|
61
|
-
// arn: 'arn:aws:s3:::image-test-importdata'
|
|
62
|
-
// },
|
|
63
|
-
// object: {
|
|
64
|
-
// key: 'image_8733685.png',
|
|
65
|
-
// size: 2974746,
|
|
66
|
-
// eTag: '93e940d895c26ef90b7542da54d61898',
|
|
67
|
-
// sequencer: '00650D4EEAD0F63EB5'
|
|
68
|
-
// }
|
|
54
|
+
});
|