@izara_project/izara-market-library-service-schemas 1.0.57 → 1.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +23 -9
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +17 -72
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +8 -32
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +3 -21
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +2 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +0 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +13 -8
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +12 -10
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +31 -7
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +10 -9
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/template.ejs +0 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/data.js +4 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +2 -45
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/sns-out/data.js +75 -0
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +16 -16
- package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ttlDynamoTemplate.ejs +32 -0
- package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/userUploadRecords.js +58 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +20 -2
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +24 -16
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +33 -21
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -1
- package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +10 -15
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrDsq/data.js +0 -87
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrDsq/template.ejs +0 -30
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerDsq/data.js +0 -45
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerDsq/template.ejs +0 -151
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/request.json +0 -7
package/package.json
CHANGED
|
@@ -198,20 +198,33 @@ module.exports.createMain = async (
|
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
} else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("hashOnCreate")) {
|
|
201
|
+
let hashFieldName = {}
|
|
201
202
|
if (objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length &&
|
|
202
203
|
objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length > 0) {
|
|
203
204
|
for (const fieldName of objectSchemas.fieldNames[identifier.fieldName].hashOnCreate) {
|
|
204
|
-
Object.assign(
|
|
205
|
-
requestParams.fieldNames, {
|
|
206
|
-
[identifier.fieldName]: hash({
|
|
207
|
-
[fieldName]: requestParams.fieldNames[fieldName]
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
)
|
|
205
|
+
Object.assign(hashFieldName, { [fieldName]: requestParams.fieldNames[fieldName] })
|
|
211
206
|
}
|
|
207
|
+
|
|
208
|
+
Object.assign(
|
|
209
|
+
requestParams.fieldNames, {
|
|
210
|
+
[identifier.fieldName]: hash(hashFieldName)
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
|
|
212
214
|
} else {
|
|
213
215
|
errorsFound.push("[invalid] no data to hash for create")
|
|
214
216
|
}
|
|
217
|
+
} else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("optionalOnCreate")) {
|
|
218
|
+
if ((objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == true)) {
|
|
219
|
+
Object.assign(
|
|
220
|
+
requestParams.fieldNames, {
|
|
221
|
+
[identifier.fieldName]: hash({
|
|
222
|
+
//(<createIdentifiersOptionalOnCreate>)
|
|
223
|
+
//(</createIdentifiersOptionalOnCreate>)
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
}
|
|
215
228
|
} else {
|
|
216
229
|
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate === false) &&
|
|
217
230
|
(objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate === false) &&
|
|
@@ -287,7 +300,7 @@ module.exports.createMain = async (
|
|
|
287
300
|
for (let [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
|
|
288
301
|
//(<beforeCreate>)
|
|
289
302
|
//(</beforeCreate>)
|
|
290
|
-
if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB
|
|
303
|
+
if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
|
|
291
304
|
//(<beforeCreateRecordDynamo>)
|
|
292
305
|
//(</beforeCreateRecordDynamo>)
|
|
293
306
|
_izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull });
|
|
@@ -308,7 +321,8 @@ module.exports.createMain = async (
|
|
|
308
321
|
_izContext,
|
|
309
322
|
await dynamodbSharedLib.tableName(
|
|
310
323
|
_izContext,
|
|
311
|
-
createDataDetail.tableName
|
|
324
|
+
createDataDetail.tableName,
|
|
325
|
+
createDataDetail.serviceTag
|
|
312
326
|
),
|
|
313
327
|
{
|
|
314
328
|
...identifiersForCreateData,
|
|
@@ -154,88 +154,33 @@ module.exports.deleteMain = async (
|
|
|
154
154
|
await sns.publishAsync(_izContext, messageParams);
|
|
155
155
|
|
|
156
156
|
return deleteNodeCompleteMessage
|
|
157
|
-
}
|
|
157
|
+
} else {
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
_izContext.logger.debug("dynamoDb process")
|
|
163
|
-
|
|
164
|
-
let identifiersForDeleteData = await dynamoDbIdentifiersByStorageResource(
|
|
165
|
-
_izContext,
|
|
166
|
-
objectSchema,
|
|
167
|
-
deleteDataDetail,
|
|
168
|
-
requestParams.identifiers
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
_izContext.logger.debug("identifiersForDeleteData", identifiersForDeleteData)
|
|
172
|
-
|
|
173
|
-
// deleteItem in dynamo
|
|
174
|
-
await dynamodbSharedLib.deleteItem(_izContext,
|
|
175
|
-
await dynamodbSharedLib.tableName(_izContext, deleteDataDetail.tableName),
|
|
176
|
-
identifiersForDeleteData
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
} else if (deleteDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
180
|
-
_izContext.logger.debug("graph process")
|
|
181
|
-
|
|
182
|
-
let deleteNodeParams = {
|
|
183
|
-
objType: objType,
|
|
184
|
-
identifiers: requestParams.identifiers
|
|
185
|
-
}
|
|
186
|
-
deleteNodeParams = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
187
|
-
deleteNodeParams,
|
|
188
|
-
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
189
|
-
callingFlowConfig,
|
|
190
|
-
callingFlowSharedLib.createCallingFlowConfig(
|
|
191
|
-
//(<callingFlowProperties>)
|
|
192
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.deleteNodeComplete), {}
|
|
193
|
-
//(</callingFlowProperties>)
|
|
194
|
-
)
|
|
195
|
-
)
|
|
196
|
-
)
|
|
197
|
-
_izContext.logger.debug("messageObject before send message: ", deleteNodeParams);
|
|
198
|
-
|
|
199
|
-
let messageAttributes;
|
|
200
|
-
|
|
201
|
-
let deleteNodeMessageBody = {
|
|
202
|
-
Message: JSON.stringify(deleteNodeParams),
|
|
203
|
-
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
204
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inDeleteNode, storageTag)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
_izContext.logger.debug("request message params before send to IndeleteNode::", deleteNodeMessageBody);
|
|
208
|
-
|
|
209
|
-
let resSns = await sns.publishAsync(_izContext, deleteNodeMessageBody)
|
|
210
|
-
_izContext.logger.debug('reSNS send to topic InDeleteNode finish', resSns)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (objectSchema.hasOwnProperty("extendObjType")) {
|
|
214
|
-
if (deleteDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB && deleteDataDetail.serviceTag !== process.env.iz_serviceTag) {
|
|
159
|
+
for await (const [storageTag, deleteDataDetail] of Object.entries(deleteDataDetails)) {
|
|
160
|
+
if (deleteDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
161
|
+
_izContext.logger.debug("dynamoDb process")
|
|
215
162
|
|
|
216
163
|
let identifiersForDeleteData = await dynamoDbIdentifiersByStorageResource(
|
|
217
164
|
_izContext,
|
|
218
165
|
objectSchema,
|
|
219
166
|
deleteDataDetail,
|
|
220
167
|
requestParams.identifiers
|
|
221
|
-
|
|
222
|
-
_izContext.logger.debug("identifiersForDeleteData", identifiersForDeleteData);
|
|
168
|
+
)
|
|
223
169
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
deleteDataDetail.serviceTag
|
|
230
|
-
),
|
|
170
|
+
_izContext.logger.debug("identifiersForDeleteData", identifiersForDeleteData)
|
|
171
|
+
|
|
172
|
+
// deleteItem in dynamo
|
|
173
|
+
await dynamodbSharedLib.deleteItem(_izContext,
|
|
174
|
+
await dynamodbSharedLib.tableName(_izContext, deleteDataDetail.tableName, deleteDataDetail.serviceTag),
|
|
231
175
|
identifiersForDeleteData
|
|
232
|
-
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
}
|
|
233
179
|
}
|
|
234
|
-
}
|
|
235
|
-
};
|
|
180
|
+
};
|
|
236
181
|
|
|
237
182
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
183
|
+
} catch (err) {
|
|
184
|
+
throw (err)
|
|
185
|
+
}
|
|
241
186
|
}
|
|
@@ -101,9 +101,11 @@ module.exports.getMain = async (
|
|
|
101
101
|
callingFlowConfig
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const
|
|
104
|
+
const errorsFound = [];
|
|
105
|
+
|
|
106
|
+
const returnSystemFieldsName = requestParams.additionalRequest?.setting?.returnSystemFieldsName ?? false;
|
|
107
|
+
const throwWhenNotFoundSomeRecord = requestParams.additionalRequest?.setting?.throwWhenNotFoundSomeRecord ?? true;
|
|
108
|
+
const returnVersionedData = requestParams.additionalRequest?.setting?.returnVersionedData ?? true
|
|
107
109
|
|
|
108
110
|
//(<beforeQuery>)
|
|
109
111
|
//(</beforeQuery>)
|
|
@@ -151,7 +153,7 @@ module.exports.getMain = async (
|
|
|
151
153
|
// get data from graph
|
|
152
154
|
let graphServiceName = await getGraphServiceTagWithCache(_izContext, getDataDetail.graphServiceTag);
|
|
153
155
|
|
|
154
|
-
|
|
156
|
+
let versionedDataLabels = [];
|
|
155
157
|
if (!returnVersionedData) {
|
|
156
158
|
if (getDataDetail.versionedDatas && Object.keys(getDataDetail.versionedDatas).length) {
|
|
157
159
|
// have versionedData
|
|
@@ -228,7 +230,8 @@ module.exports.getMain = async (
|
|
|
228
230
|
|
|
229
231
|
let dataFromDynamoDb = await dynamodbSharedLib.getItem(
|
|
230
232
|
_izContext,
|
|
231
|
-
await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName),
|
|
233
|
+
await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName, getDataDetail.serviceTag),
|
|
234
|
+
await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName, getDataDetail.serviceTag),
|
|
232
235
|
identifiersForGetData
|
|
233
236
|
);
|
|
234
237
|
|
|
@@ -254,33 +257,6 @@ module.exports.getMain = async (
|
|
|
254
257
|
getResults.push([dataFromDynamoDb, getDataDetail]);
|
|
255
258
|
|
|
256
259
|
}
|
|
257
|
-
|
|
258
|
-
if (objectSchema.hasOwnProperty("extendObjType")) {
|
|
259
|
-
if (getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB && getDataDetail.serviceTag !== process.env.iz_serviceTag) {
|
|
260
|
-
|
|
261
|
-
let identifiersForGetData = await dynamoDbIdentifiersByStorageResource(
|
|
262
|
-
_izContext,
|
|
263
|
-
objectSchema,
|
|
264
|
-
getDataDetail,
|
|
265
|
-
requestParams.identifiers
|
|
266
|
-
)
|
|
267
|
-
_izContext.logger.debug("identifiersForGetData", identifiersForGetData);
|
|
268
|
-
|
|
269
|
-
let getParent = await dynamodbSharedLib.getItem(
|
|
270
|
-
_izContext,
|
|
271
|
-
await dynamodbSharedLib.tableName(
|
|
272
|
-
_izContext,
|
|
273
|
-
getDataDetail.tableName,
|
|
274
|
-
getDataDetail.serviceTag
|
|
275
|
-
),
|
|
276
|
-
identifiersForGetData
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
getResults.push([getParent, getDataDetail]);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
260
|
})
|
|
285
261
|
);
|
|
286
262
|
|
|
@@ -308,7 +308,7 @@ module.exports.updateMain = async (
|
|
|
308
308
|
|
|
309
309
|
let updateItem = await dynamodbSharedLib.updateItem(
|
|
310
310
|
_izContext,
|
|
311
|
-
await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName),
|
|
311
|
+
await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName, updateDataDetail.serviceTag),
|
|
312
312
|
identifiersForUpdateData,
|
|
313
313
|
fieldForUpdateTableDynamo,
|
|
314
314
|
{
|
|
@@ -324,7 +324,7 @@ module.exports.updateMain = async (
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOWPROPERTIES_PROPERTYNAME]) {
|
|
327
|
-
_izContext.logger.debug("HAVE
|
|
327
|
+
_izContext.logger.debug("HAVE CALLING FLOW");
|
|
328
328
|
|
|
329
329
|
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
|
|
330
330
|
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
@@ -117,27 +117,9 @@ async function createParamForCreateSource(_izContext, allObjSchemas, action, han
|
|
|
117
117
|
createIamRole(
|
|
118
118
|
{ [RESOURCE_CLASSES.sns]: SNS_RESOURCE.publish },
|
|
119
119
|
[
|
|
120
|
-
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.createObjectComplete) + "_Out")
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
createIamRole(
|
|
125
|
-
{ [RESOURCE_CLASSES.sns]: SNS_RESOURCE.publish },
|
|
126
|
-
[
|
|
127
|
-
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.updateNodeComplete) + "_Out")
|
|
128
|
-
]
|
|
129
|
-
),
|
|
130
|
-
createIamRole(
|
|
131
|
-
{ [RESOURCE_CLASSES.sns]: SNS_RESOURCE.publish },
|
|
132
|
-
[
|
|
133
|
-
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.deleteNodeComplete) + "_Out")
|
|
134
|
-
]
|
|
135
|
-
),
|
|
136
|
-
createIamRole(
|
|
137
|
-
{
|
|
138
|
-
[RESOURCE_CLASSES.sns]: SNS_RESOURCE.publish
|
|
139
|
-
},
|
|
140
|
-
[
|
|
120
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.createObjectComplete) + "_Out"),
|
|
121
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.updateNodeComplete) + "_Out"),
|
|
122
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.deleteNodeComplete) + "_Out"),
|
|
141
123
|
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.getNodeComplete) + "_Out")
|
|
142
124
|
]
|
|
143
125
|
)
|
package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js
CHANGED
|
@@ -77,7 +77,8 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
77
77
|
]
|
|
78
78
|
},
|
|
79
79
|
[
|
|
80
|
-
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
80
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask"),
|
|
81
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "UserUploadRecords")
|
|
81
82
|
]
|
|
82
83
|
),
|
|
83
84
|
createIamRole(
|
package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js
CHANGED
|
@@ -38,26 +38,12 @@ 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
41
|
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
42
|
|
|
55
43
|
return {
|
|
56
44
|
templatePath: templatePath,
|
|
57
45
|
templateData: {
|
|
58
46
|
flowTag: flowSchema.flowTag,
|
|
59
|
-
createdFieldNames: createdFieldNames,
|
|
60
|
-
statusFieldNames: statusFieldNames,
|
|
61
47
|
objectType
|
|
62
48
|
},
|
|
63
49
|
setting: {
|
|
@@ -33,8 +33,8 @@ const sns = externalRequest.sns
|
|
|
33
33
|
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
34
34
|
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
35
35
|
const { v4: uuidv4 } = require('uuid')
|
|
36
|
-
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
37
36
|
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
37
|
+
const { consts } = require('@izara_project/izara-middleware');
|
|
38
38
|
|
|
39
39
|
//(<optionalRequired>)
|
|
40
40
|
//(</optionalRequired>)
|
|
@@ -67,7 +67,7 @@ module.exports.createObject = async (
|
|
|
67
67
|
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
68
68
|
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
69
69
|
|
|
70
|
-
let
|
|
70
|
+
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
|
|
71
71
|
|
|
72
72
|
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
73
73
|
flowTag: "<%- flowTag %>",
|
|
@@ -76,16 +76,18 @@ module.exports.createObject = async (
|
|
|
76
76
|
|
|
77
77
|
_izContext.logger.debug("getFlowSchema", flowSchema)
|
|
78
78
|
|
|
79
|
-
let
|
|
80
|
-
await dynamodbSharedLib.tableName(_izContext, "
|
|
79
|
+
let getUserFromTableUserUploadRecord = await dynamodbSharedLib.getItem(_izContext,
|
|
80
|
+
await dynamodbSharedLib.tableName(_izContext, "UserUploadRecords"),
|
|
81
81
|
{
|
|
82
|
-
|
|
82
|
+
connectionId: connectionId
|
|
83
83
|
}
|
|
84
84
|
)
|
|
85
85
|
|
|
86
|
-
const { userId,
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
const { userId, submittedByUserId } = getUserFromTableUserUploadRecord
|
|
87
|
+
_izContext.correlationIds.set(consts.BASE_USER_ID, userId)
|
|
88
|
+
_izContext.correlationIds.set(consts.TARGET_ID, submittedByUserId)
|
|
89
|
+
|
|
90
|
+
if (!flowSchema) {
|
|
89
91
|
throw new NoRetryError(`flowTag not found ${requestParams.action}`)
|
|
90
92
|
}
|
|
91
93
|
|
|
@@ -93,6 +95,9 @@ module.exports.createObject = async (
|
|
|
93
95
|
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType)
|
|
94
96
|
_izContext.logger.debug("objectSchema in flowSchema mainFunction", objectSchema)
|
|
95
97
|
|
|
98
|
+
if (!objectSchema) {
|
|
99
|
+
throw new NoRetryError(`${flowSchema.objType.objectType} not found`)
|
|
100
|
+
}
|
|
96
101
|
|
|
97
102
|
//(<beforeCreateHook>)
|
|
98
103
|
//(</beforeCreateHook>)
|
|
@@ -120,7 +120,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
120
120
|
functionNameConfig: functionName + upperCase(handlerType),
|
|
121
121
|
resourceLocation: path.join(SOURCE_PATH.resourceLocationWebSocket, flowSchema.flowTag, "source/"),
|
|
122
122
|
additionalResourcePermission,
|
|
123
|
-
functionNameConfig:
|
|
123
|
+
functionNameConfig: functionName + upperCase(shortNameHandler(handlerType)),
|
|
124
124
|
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
125
125
|
},
|
|
126
126
|
setting: {
|
|
@@ -83,7 +83,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
83
83
|
// validate message (and MessageAttributes)
|
|
84
84
|
await recordHandlerSharedLib.validateRecord(
|
|
85
85
|
record, // one record will send to mainFunction
|
|
86
|
-
"
|
|
86
|
+
"CreatePresignUrlHdrSqs", // queue name that need to retry or send to dlq
|
|
87
87
|
perRecordsValidatorSchema, // schema for record.Message
|
|
88
88
|
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
89
89
|
);
|
|
@@ -101,7 +101,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
101
101
|
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
102
102
|
record, // one record will send to mainFunction
|
|
103
103
|
createPresignUrl.createPresignUrl, // mainFunction that need to invoke.
|
|
104
|
-
"
|
|
104
|
+
"CreatePresignUrlHdrSqs", // queue name that need to retry or send to dlq
|
|
105
105
|
passOnProperties, // all parameters that mainFunction needed.
|
|
106
106
|
);
|
|
107
107
|
record._izContext.logger.debug('after recordPromise in handler');
|
|
@@ -38,6 +38,8 @@ const utils = require('@izara_project/izara-market-library-service-schemas/src/M
|
|
|
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
40
|
const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils
|
|
41
|
+
//(<optionalRequired>)
|
|
42
|
+
//(</optionalRequired>)
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* description of function.
|
|
@@ -83,8 +85,8 @@ module.exports.createPresignUrl = async (
|
|
|
83
85
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
|
|
84
86
|
{
|
|
85
87
|
objectType: objType.objectType,
|
|
86
|
-
//(<
|
|
87
|
-
//(</
|
|
88
|
+
//(<identifiersForGetData>)
|
|
89
|
+
//(</identifiersForGetData>)
|
|
88
90
|
}
|
|
89
91
|
)
|
|
90
92
|
_izContext.logger.debug("getResult", getResult);
|
|
@@ -116,8 +118,8 @@ module.exports.createPresignUrl = async (
|
|
|
116
118
|
let updateStatusField = {
|
|
117
119
|
objInstanceFull: {
|
|
118
120
|
identifiers: {
|
|
119
|
-
//(<
|
|
120
|
-
//(</
|
|
121
|
+
//(<identifiersForUpdateStatus>)
|
|
122
|
+
//(</identifiersForUpdateStatus>)
|
|
121
123
|
},
|
|
122
124
|
fields: {
|
|
123
125
|
//(<fields>)
|
|
@@ -129,7 +131,7 @@ module.exports.createPresignUrl = async (
|
|
|
129
131
|
|
|
130
132
|
let sendMessageToUpdateEndpoint = {
|
|
131
133
|
Message: JSON.stringify(updateStatusField),
|
|
132
|
-
TopicArn: await snsSharedLib.
|
|
134
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, `Update_In`)
|
|
133
135
|
}
|
|
134
136
|
_izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
|
|
135
137
|
|
|
@@ -143,7 +145,7 @@ module.exports.createPresignUrl = async (
|
|
|
143
145
|
|
|
144
146
|
let sendMessageToCancelReserved = {
|
|
145
147
|
Message: JSON.stringify(cancelReservedMsg),
|
|
146
|
-
TopicArn: await snsSharedLib.
|
|
148
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, 'CancelUsage_In', EXTERNAL_SERVICE_NAME.accountLimits)
|
|
147
149
|
};
|
|
148
150
|
|
|
149
151
|
_izContext.logger.debug("sendMessageToCancelReserved", sendMessageToCancelReserved);
|
|
@@ -165,7 +167,7 @@ module.exports.createPresignUrl = async (
|
|
|
165
167
|
const Key = `${fileName}.${importType}`
|
|
166
168
|
//(</createKeyForUploadFile>)
|
|
167
169
|
|
|
168
|
-
const maximumSize = fileSize * 1048576 // convert to byte unit for restrict
|
|
170
|
+
const maximumSize = getResult.fields.fileSize * 1048576 // convert to byte unit for restrict
|
|
169
171
|
_izContext.logger.debug("maximumSize", maximumSize);
|
|
170
172
|
|
|
171
173
|
// create PresignUrl
|
|
@@ -216,7 +218,7 @@ module.exports.createPresignUrl = async (
|
|
|
216
218
|
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
217
219
|
returnMessage, // resive parent callingFlowConfig.
|
|
218
220
|
callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
|
|
219
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, `
|
|
221
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, `WebSocketComplete`), {}
|
|
220
222
|
)
|
|
221
223
|
)
|
|
222
224
|
);
|
|
@@ -225,7 +227,7 @@ module.exports.createPresignUrl = async (
|
|
|
225
227
|
|
|
226
228
|
let sendMessageToUpdateEndpoint = {
|
|
227
229
|
Message: JSON.stringify(messageObject),
|
|
228
|
-
TopicArn: await snsSharedLib.
|
|
230
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "Update_In")
|
|
229
231
|
}
|
|
230
232
|
_izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
|
|
231
233
|
await sns.publishAsync(_izContext, sendMessageToUpdateEndpoint);
|
|
@@ -238,7 +240,7 @@ module.exports.createPresignUrl = async (
|
|
|
238
240
|
await dynamodbSharedLib.updateItem(_izContext,
|
|
239
241
|
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
240
242
|
{
|
|
241
|
-
taskKey: `${createFlowTypeConcat(
|
|
243
|
+
taskKey: `${createFlowTypeConcat(_izContext, { flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
|
|
242
244
|
connectionId: connectionId
|
|
243
245
|
},
|
|
244
246
|
{
|
|
@@ -37,12 +37,15 @@ const {
|
|
|
37
37
|
externalResourceSns,
|
|
38
38
|
externalResourceName,
|
|
39
39
|
SOURCE_GENERATE_IAM_ROLE,
|
|
40
|
-
FUNCTION_NAME
|
|
40
|
+
FUNCTION_NAME,
|
|
41
|
+
DYNAMO_RESOURCE
|
|
41
42
|
} = require('../../../../../../../../MainLibs/src/Consts');
|
|
42
43
|
|
|
43
44
|
const {
|
|
44
45
|
TOPIC_NAME_GENERATE_CODE
|
|
45
46
|
} = require('../../../../../../../../GenerateCodeLibs/src/Consts');
|
|
47
|
+
const { STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
48
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema
|
|
46
49
|
|
|
47
50
|
/**
|
|
48
51
|
* receive objectSchema
|
|
@@ -51,15 +54,15 @@ const {
|
|
|
51
54
|
* @return {{ templatePath, templateData, setting } }
|
|
52
55
|
*/
|
|
53
56
|
|
|
54
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
55
|
-
return [createSourceParams(_izContext, flowSchema, srcPath)]
|
|
57
|
+
async function data(_izContext, flowSchema, srcPath) {
|
|
58
|
+
return [await createSourceParams(_izContext, flowSchema, srcPath)]
|
|
56
59
|
}
|
|
57
60
|
|
|
58
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
61
|
+
async function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
59
62
|
let functionName = upperCase(FUNCTION_NAME.reservedLimit);
|
|
60
63
|
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
61
64
|
let additionalResourcePermission = defaultIamRolePerAction();
|
|
62
|
-
|
|
65
|
+
let tableNames = [];
|
|
63
66
|
additionalResourcePermission.push(
|
|
64
67
|
createIamRole(
|
|
65
68
|
{
|
|
@@ -72,16 +75,37 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
|
72
75
|
[RESOURCE_CLASSES.sns]: [
|
|
73
76
|
SNS_RESOURCE.publish,
|
|
74
77
|
SNS_RESOURCE.subscribe
|
|
75
|
-
]
|
|
78
|
+
],
|
|
76
79
|
},
|
|
77
80
|
[
|
|
78
81
|
resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType),
|
|
79
82
|
resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType + "DLQ"),
|
|
80
|
-
resourceNames(RESOURCE_CLASSES.sns, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete)
|
|
83
|
+
resourceNames(RESOURCE_CLASSES.sns, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete),
|
|
81
84
|
]
|
|
82
85
|
)
|
|
83
86
|
)
|
|
84
87
|
|
|
88
|
+
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
89
|
+
|
|
90
|
+
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType)
|
|
91
|
+
|
|
92
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
93
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
94
|
+
tableNames.push(storageResource.tableName)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
additionalResourcePermission.push(
|
|
99
|
+
createIamRole(
|
|
100
|
+
{
|
|
101
|
+
[RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
|
|
102
|
+
},
|
|
103
|
+
tableNames.map(tableName =>
|
|
104
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName)
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
|
|
85
109
|
return {
|
|
86
110
|
templatePath: templatePath,
|
|
87
111
|
templateData: {
|
|
@@ -28,6 +28,8 @@ const consts = require('@izara_project/izara-market-library-service-schemas/src/
|
|
|
28
28
|
const coreConsts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
29
29
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
30
30
|
const importDataLibs = require('../../../../libs/source/GenerateCodeLibs');
|
|
31
|
+
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
32
|
+
|
|
31
33
|
/**
|
|
32
34
|
* description of function.
|
|
33
35
|
* @param {Object} _izContext
|
|
@@ -66,8 +68,6 @@ module.exports.reservedLimit = async (
|
|
|
66
68
|
|
|
67
69
|
// get static
|
|
68
70
|
let payloadBeforeInvokeStaticLimit = {
|
|
69
|
-
userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
|
|
70
|
-
targetId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
|
|
71
71
|
//(<additionalPropertiesStaticLimit>)
|
|
72
72
|
//(</additionalPropertiesStaticLimit>)
|
|
73
73
|
}
|
|
@@ -81,13 +81,14 @@ module.exports.reservedLimit = async (
|
|
|
81
81
|
|
|
82
82
|
if (res.passStatus === false) {
|
|
83
83
|
importDataLibs.postToConnection({ message: "static limit over" }, connectionId)
|
|
84
|
+
//(<afterFailReservedStaticLimit>)
|
|
85
|
+
return
|
|
86
|
+
//(</afterFailReservedStaticLimit>)
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
// reservedDynamic
|
|
87
90
|
|
|
88
91
|
let sendMsgReservedDynamic = {
|
|
89
|
-
userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
|
|
90
|
-
targetUserId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
|
|
91
92
|
//(<additionalPropertiesReservedDynamic>)
|
|
92
93
|
//(</additionalPropertiesReservedDynamic>)
|
|
93
94
|
}
|
|
@@ -105,9 +106,9 @@ module.exports.reservedLimit = async (
|
|
|
105
106
|
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
106
107
|
callingFlowConfig,
|
|
107
108
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
108
|
-
//(<
|
|
109
|
+
//(<callingFlowPropertiesIfHaveCallingFlowConfig>)
|
|
109
110
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
|
|
110
|
-
//(</
|
|
111
|
+
//(</callingFlowPropertiesIfHaveCallingFlowConfig>)
|
|
111
112
|
callingFlowProperties
|
|
112
113
|
)
|
|
113
114
|
)
|
|
@@ -116,9 +117,9 @@ module.exports.reservedLimit = async (
|
|
|
116
117
|
sendMsgReservedDynamic = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
117
118
|
sendMsgReservedDynamic,
|
|
118
119
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
119
|
-
//(<
|
|
120
|
+
//(<callingFlowPropertiesIfNotHaveCallingFlowConfig>)
|
|
120
121
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
|
|
121
|
-
//(</
|
|
122
|
+
//(</callingFlowPropertiesIfNotHaveCallingFlowConfig>)
|
|
122
123
|
callingFlowProperties
|
|
123
124
|
)
|
|
124
125
|
);
|
|
@@ -139,7 +140,7 @@ module.exports.reservedLimit = async (
|
|
|
139
140
|
|
|
140
141
|
let sendMessageToReservedDynamic = {
|
|
141
142
|
Message: JSON.stringify(sendMsgReservedDynamic),
|
|
142
|
-
TopicArn: await snsSharedLib.
|
|
143
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "ReservedDynamicUsage_In", consts.EXTERNAL_SERVICE_NAME.accountLimits)
|
|
143
144
|
};
|
|
144
145
|
_izContext.logger.debug("sendMessageToReservedDynamic", sendMessageToReservedDynamic);
|
|
145
146
|
await sns.publishAsync(_izContext, sendMessageToReservedDynamic);
|