@izara_project/izara-market-library-service-schemas 1.0.56 → 1.0.58
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 -28
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +5 -6
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +6 -4
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +4 -22
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +2 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +12 -8
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +0 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +19 -13
- 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 +26 -16
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +9 -12
- 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 +4 -47
- 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 +18 -0
- 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/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +3 -2
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +23 -15
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +7 -6
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -4
- 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 +22 -2
- 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
|
@@ -762,7 +762,7 @@ function collectGetData(_izContext, getResults, objectSchema, returnSystemFields
|
|
|
762
762
|
}
|
|
763
763
|
|
|
764
764
|
|
|
765
|
-
async function createUpdateDataDetail(_izContext, objectSchema, settings = { bucketName:
|
|
765
|
+
async function createUpdateDataDetail(_izContext, objectSchema, settings = { bucketName: process.env.iz_serviceSchemaBucketName }) {
|
|
766
766
|
let getGraphDataDetails = {};
|
|
767
767
|
let getDynamoDbDataDetails = {};
|
|
768
768
|
let allUpdateDataDetail = {};
|
|
@@ -826,7 +826,7 @@ async function createUpdateDataDetail(_izContext, objectSchema, settings = { buc
|
|
|
826
826
|
return allUpdateDataDetail
|
|
827
827
|
}
|
|
828
828
|
|
|
829
|
-
async function createDataDetailsLib(_izContext, objectSchemas, settings = { bucketName:
|
|
829
|
+
async function createDataDetailsLib(_izContext, objectSchemas, settings = { bucketName: process.env.iz_serviceSchemaBucketName }) {
|
|
830
830
|
_izContext.logger.debug("Lib: createDataDetailsLib:", { objectSchemas: objectSchemas });
|
|
831
831
|
/**
|
|
832
832
|
* TODO: crate DataDetail now will get parent objectSchema if have extendObjType
|
|
@@ -857,7 +857,7 @@ async function createDataDetailsLib(_izContext, objectSchemas, settings = { buck
|
|
|
857
857
|
[eachStorageResourceTag]: {
|
|
858
858
|
storageType: consts.STORAGE_TYPES.dynamoDB,
|
|
859
859
|
tableName: storageResources[eachStorageResourceTag].tableName,
|
|
860
|
-
serviceTag: process.env.iz_serviceTag,
|
|
860
|
+
serviceTag: storageResources[eachStorageResourceTag].serviceTag || process.env.iz_serviceTag,
|
|
861
861
|
fieldNames: [keyFieldName]
|
|
862
862
|
}
|
|
863
863
|
});
|
|
@@ -894,34 +894,10 @@ async function createDataDetailsLib(_izContext, objectSchemas, settings = { buck
|
|
|
894
894
|
}; // end loop storageResourceTags
|
|
895
895
|
}; // end loop
|
|
896
896
|
|
|
897
|
-
if (objectSchemas.hasOwnProperty("extendObjType")) {
|
|
898
|
-
if (objectSchemas.extendObjType.serviceTag !== process.env.iz_serviceTag) {
|
|
899
|
-
let parentObjectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objectSchemas.extendObjType, settings.bucketName);
|
|
900
|
-
_izContext.logger.debug("parentObjectSchema", parentObjectSchema);
|
|
901
|
-
for (const [fieldName, fieldNameSetting] of Object.entries(parentObjectSchema.fieldNames)) {
|
|
902
|
-
for (let eachParentStorageResourceTag of fieldNameSetting.storageResourceTags) {
|
|
903
|
-
let parentStorageResourceTag = objectSchemas.extendObjType.serviceTag + eachParentStorageResourceTag
|
|
904
|
-
if (storageResources[eachParentStorageResourceTag].storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
905
|
-
if (!createDataDetails.hasOwnProperty(parentStorageResourceTag)) {
|
|
906
|
-
createDataDetails[parentStorageResourceTag] = {
|
|
907
|
-
storageType: consts.STORAGE_TYPES.dynamoDB,
|
|
908
|
-
tableName: storageResources[eachParentStorageResourceTag].tableName,
|
|
909
|
-
serviceTag: objectSchemas.extendObjType.serviceTag,
|
|
910
|
-
fieldNames: [fieldName]
|
|
911
|
-
}
|
|
912
|
-
} else {
|
|
913
|
-
createDataDetails[parentStorageResourceTag].fieldNames.push(fieldName)
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
|
|
921
897
|
return createDataDetails;
|
|
922
898
|
};
|
|
923
899
|
|
|
924
|
-
async function createDeleteDataDetail(_izContext, objectSchema, settings = { bucketName:
|
|
900
|
+
async function createDeleteDataDetail(_izContext, objectSchema, settings = { bucketName: process.env.iz_serviceSchemaBucketName }) {
|
|
925
901
|
let deleteDynamoDataDetail = {};
|
|
926
902
|
let deleteGraphDataDetail = {};
|
|
927
903
|
let allDeleteDataDetail = {};
|
|
@@ -180,8 +180,8 @@ module.exports.createMain = async (
|
|
|
180
180
|
});
|
|
181
181
|
_izContext.logger.debug("Assign requestParams", requestParams)
|
|
182
182
|
|
|
183
|
-
} else if (
|
|
184
|
-
|
|
183
|
+
} else if (objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false ||
|
|
184
|
+
objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == null) {
|
|
185
185
|
|
|
186
186
|
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
|
|
187
187
|
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
|
|
@@ -197,8 +197,7 @@ module.exports.createMain = async (
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
|
-
}
|
|
201
|
-
if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("hashOnCreate")) {
|
|
200
|
+
} else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("hashOnCreate")) {
|
|
202
201
|
if (objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length &&
|
|
203
202
|
objectSchemas.fieldNames[identifier.fieldName].hashOnCreate.length > 0) {
|
|
204
203
|
for (const fieldName of objectSchemas.fieldNames[identifier.fieldName].hashOnCreate) {
|
|
@@ -226,7 +225,7 @@ module.exports.createMain = async (
|
|
|
226
225
|
_izContext.logger.debug("requestParams is:", requestParams);
|
|
227
226
|
|
|
228
227
|
// check settingObjSchemas
|
|
229
|
-
for (
|
|
228
|
+
for (const [keyFieldNames, valueFieldNames] of Object.entries(objectSchemas.fieldNames)) {
|
|
230
229
|
|
|
231
230
|
if (valueFieldNames.hasOwnProperty("randomOnCreate") && valueFieldNames.randomOnCreate === true) {
|
|
232
231
|
listOfRequiredOnCreate.push(keyFieldNames)
|
|
@@ -288,7 +287,7 @@ module.exports.createMain = async (
|
|
|
288
287
|
for (let [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
|
|
289
288
|
//(<beforeCreate>)
|
|
290
289
|
//(</beforeCreate>)
|
|
291
|
-
if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
|
|
290
|
+
if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB && createDataDetail.serviceTag === process.env.iz_serviceTag) {
|
|
292
291
|
//(<beforeCreateRecordDynamo>)
|
|
293
292
|
//(</beforeCreateRecordDynamo>)
|
|
294
293
|
_izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull });
|
|
@@ -103,6 +103,7 @@ module.exports.getMain = async (
|
|
|
103
103
|
|
|
104
104
|
const returnSystemFieldsName = requestParams.additionalRequest?.setting?.returnSystemFieldsName || false;
|
|
105
105
|
const throwWhenNotFoundSomeRecord = requestParams.additionalRequest?.setting?.throwWhenNotFoundSomeRecord || true;
|
|
106
|
+
const returnVersionedData = requestParams.additionalRequest?.setting?.returnVersionedData || true
|
|
106
107
|
|
|
107
108
|
//(<beforeQuery>)
|
|
108
109
|
//(</beforeQuery>)
|
|
@@ -151,10 +152,11 @@ module.exports.getMain = async (
|
|
|
151
152
|
let graphServiceName = await getGraphServiceTagWithCache(_izContext, getDataDetail.graphServiceTag);
|
|
152
153
|
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
if (!returnVersionedData) {
|
|
156
|
+
if (getDataDetail.versionedDatas && Object.keys(getDataDetail.versionedDatas).length) {
|
|
157
|
+
// have versionedData
|
|
158
|
+
versionedDataLabels = Object.keys(getDataDetail.versionedDatas);
|
|
159
|
+
}
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
|
|
@@ -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
|
)
|
|
@@ -174,7 +156,7 @@ async function createParamForCreateSource(_izContext, allObjSchemas, action, han
|
|
|
174
156
|
}
|
|
175
157
|
}
|
|
176
158
|
|
|
177
|
-
if (parentTables) {
|
|
159
|
+
if (parentTables.length > 0) {
|
|
178
160
|
additionalResourcePermission.push(
|
|
179
161
|
createIamRole(
|
|
180
162
|
{
|
|
@@ -73,7 +73,9 @@ module.exports.confirmNewReserved = async (
|
|
|
73
73
|
// confirmUsage
|
|
74
74
|
let confirmUsageMessage = {
|
|
75
75
|
userId: userId,
|
|
76
|
+
//(<optionalLimitTag>)
|
|
76
77
|
limitTag: consts.LIMIT_TAG.uploadData,
|
|
78
|
+
//(</optionalLimitTag>)
|
|
77
79
|
uniqueIdentify: uniqueIdentify,
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -111,7 +113,7 @@ module.exports.confirmNewReserved = async (
|
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
let sendMessageToUpdateEndpoint = {
|
|
114
|
-
Message: JSON.stringify(
|
|
116
|
+
Message: JSON.stringify(sendMessageToUpdateStatus),
|
|
115
117
|
TopicArn: await snsSharedLib.snsTopicArn(_izContext, "Update_In")
|
|
116
118
|
};
|
|
117
119
|
_izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
|
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/handler/template.ejs
CHANGED
|
@@ -28,6 +28,7 @@ const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
|
28
28
|
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
29
29
|
const { postToConnection } = require('../../../../libs/source/GenerateCodeLibs');
|
|
30
30
|
const createObject = require('./CreateObjectS3_Main');
|
|
31
|
+
const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils
|
|
31
32
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
32
33
|
|
|
33
34
|
event._izContext.logger.debug('Event:', event);
|
|
@@ -44,14 +45,17 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
44
45
|
console.log("event in route webSocket", event);
|
|
45
46
|
let eventParams = JSON.parse(event.body)
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
//(<createIdentifiersFlow>)
|
|
49
|
+
let identifiers
|
|
50
|
+
//(</createIdentifiersFlow>)
|
|
51
|
+
|
|
52
|
+
await dynamodbSharedLib.putItem(event._izContext,
|
|
53
|
+
await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
|
|
54
|
+
{
|
|
55
|
+
taskKey: `${createFlowTypeConcat(event._izContext, { flowTag: "<%- route %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
|
|
56
|
+
connectionId: connectionId,
|
|
57
|
+
}
|
|
58
|
+
)
|
|
55
59
|
|
|
56
60
|
let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
|
|
57
61
|
await createObject.createObject(
|
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,6 +67,8 @@ module.exports.createObject = async (
|
|
|
67
67
|
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
68
68
|
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
69
69
|
|
|
70
|
+
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
|
|
71
|
+
|
|
70
72
|
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
71
73
|
flowTag: "<%- flowTag %>",
|
|
72
74
|
serviceTag: process.env.iz_serviceTag
|
|
@@ -74,30 +76,34 @@ module.exports.createObject = async (
|
|
|
74
76
|
|
|
75
77
|
_izContext.logger.debug("getFlowSchema", flowSchema)
|
|
76
78
|
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`)
|
|
79
|
+
let getUserFromTableUserUploadRecord = await dynamodbSharedLib.getItem(_izContext,
|
|
80
|
+
await dynamodbSharedLib.tableName(_izContext, "UserUploadRecords"),
|
|
81
|
+
{
|
|
82
|
+
connectionId: connectionId
|
|
82
83
|
}
|
|
84
|
+
)
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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) {
|
|
91
|
+
throw new NoRetryError(`flowTag not found ${requestParams.action}`)
|
|
92
|
+
}
|
|
89
93
|
|
|
90
94
|
// get objectType
|
|
91
95
|
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType)
|
|
92
96
|
_izContext.logger.debug("objectSchema in flowSchema mainFunction", objectSchema)
|
|
93
97
|
|
|
94
|
-
|
|
98
|
+
if (!objectSchema) {
|
|
99
|
+
throw new NoRetryError(`${flowSchema.objType.objectType} not found`)
|
|
100
|
+
}
|
|
95
101
|
|
|
96
102
|
//(<beforeCreateHook>)
|
|
97
103
|
//(</beforeCreateHook>)
|
|
98
104
|
// create message Object to create Endpoint
|
|
99
105
|
let messageObject = {
|
|
100
|
-
objectType: <%- objectType %>
|
|
106
|
+
objectType: "<%- objectType %>",
|
|
101
107
|
fieldNames: {
|
|
102
108
|
//(<fieldNamesHook>)
|
|
103
109
|
//(</fieldNamesHook>)
|
|
@@ -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,10 @@ 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
|
+
//(<optionalRequired>)
|
|
42
|
+
//(</optionalRequired>)
|
|
43
|
+
|
|
40
44
|
/**
|
|
41
45
|
* description of function.
|
|
42
46
|
* @param {Object} _izContext
|
|
@@ -80,9 +84,9 @@ module.exports.createPresignUrl = async (
|
|
|
80
84
|
let getResult = await lambda.invokeSync(_izContext,
|
|
81
85
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
|
|
82
86
|
{
|
|
83
|
-
objectType: objType.objectType
|
|
84
|
-
//(<
|
|
85
|
-
//(</
|
|
87
|
+
objectType: objType.objectType,
|
|
88
|
+
//(<identifiersForGetData>)
|
|
89
|
+
//(</identifiersForGetData>)
|
|
86
90
|
}
|
|
87
91
|
)
|
|
88
92
|
_izContext.logger.debug("getResult", getResult);
|
|
@@ -99,10 +103,9 @@ module.exports.createPresignUrl = async (
|
|
|
99
103
|
|
|
100
104
|
await dynamodbSharedLib.putItem(_izContext,
|
|
101
105
|
await dynamodbSharedLib.tableName(_izContext, "ReservedDataMain"),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
+
//(<createReservedDataMain>)
|
|
107
|
+
{}
|
|
108
|
+
//(</createReservedDataMain>)
|
|
106
109
|
);
|
|
107
110
|
|
|
108
111
|
if (passStatus === false) { // if passStatus false post message to client
|
|
@@ -115,8 +118,8 @@ module.exports.createPresignUrl = async (
|
|
|
115
118
|
let updateStatusField = {
|
|
116
119
|
objInstanceFull: {
|
|
117
120
|
identifiers: {
|
|
118
|
-
//(<
|
|
119
|
-
//(</
|
|
121
|
+
//(<identifiersForUpdateStatus>)
|
|
122
|
+
//(</identifiersForUpdateStatus>)
|
|
120
123
|
},
|
|
121
124
|
fields: {
|
|
122
125
|
//(<fields>)
|
|
@@ -128,7 +131,7 @@ module.exports.createPresignUrl = async (
|
|
|
128
131
|
|
|
129
132
|
let sendMessageToUpdateEndpoint = {
|
|
130
133
|
Message: JSON.stringify(updateStatusField),
|
|
131
|
-
TopicArn: await snsSharedLib.
|
|
134
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, `Update_In`)
|
|
132
135
|
}
|
|
133
136
|
_izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
|
|
134
137
|
|
|
@@ -142,7 +145,7 @@ module.exports.createPresignUrl = async (
|
|
|
142
145
|
|
|
143
146
|
let sendMessageToCancelReserved = {
|
|
144
147
|
Message: JSON.stringify(cancelReservedMsg),
|
|
145
|
-
TopicArn: await snsSharedLib.
|
|
148
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, 'CancelUsage_In', EXTERNAL_SERVICE_NAME.accountLimits)
|
|
146
149
|
};
|
|
147
150
|
|
|
148
151
|
_izContext.logger.debug("sendMessageToCancelReserved", sendMessageToCancelReserved);
|
|
@@ -157,6 +160,7 @@ module.exports.createPresignUrl = async (
|
|
|
157
160
|
connectionId: connectionId
|
|
158
161
|
}
|
|
159
162
|
)
|
|
163
|
+
return "reserved not pass"
|
|
160
164
|
}
|
|
161
165
|
|
|
162
166
|
//(<createKeyForUploadFile>)
|
|
@@ -198,14 +202,15 @@ module.exports.createPresignUrl = async (
|
|
|
198
202
|
let messageObject = {
|
|
199
203
|
objInstanceFull: {
|
|
200
204
|
identifiers: {
|
|
201
|
-
|
|
205
|
+
//(<identifiersForUpdateTable>)
|
|
206
|
+
//(</identifiersForUpdateTable>)
|
|
202
207
|
},
|
|
203
208
|
fields: {
|
|
204
209
|
importBatchStatus: "waitingToUpload",
|
|
205
|
-
expiryTimestamp: (startTime + (createPresignUrlParam.expires * 1000))
|
|
210
|
+
expiryTimestamp: (getResult.startTime + (createPresignUrlParam.expires * 1000))
|
|
206
211
|
}
|
|
207
212
|
},
|
|
208
|
-
objectType: objType
|
|
213
|
+
objectType: objType.objectType
|
|
209
214
|
}
|
|
210
215
|
|
|
211
216
|
messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
@@ -222,15 +227,20 @@ module.exports.createPresignUrl = async (
|
|
|
222
227
|
|
|
223
228
|
let sendMessageToUpdateEndpoint = {
|
|
224
229
|
Message: JSON.stringify(messageObject),
|
|
225
|
-
TopicArn: await snsSharedLib.
|
|
230
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "Update_In")
|
|
226
231
|
}
|
|
227
232
|
_izContext.logger.debug("sendMessageToUpdateEndpoint", sendMessageToUpdateEndpoint);
|
|
228
233
|
await sns.publishAsync(_izContext, sendMessageToUpdateEndpoint);
|
|
229
234
|
|
|
235
|
+
|
|
236
|
+
//(<createIdentifiersFlow>)
|
|
237
|
+
let identifiers
|
|
238
|
+
//(</createIdentifiersFlow>)
|
|
239
|
+
|
|
230
240
|
await dynamodbSharedLib.updateItem(_izContext,
|
|
231
241
|
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
232
242
|
{
|
|
233
|
-
taskKey:
|
|
243
|
+
taskKey: `${createFlowTypeConcat(_izContext, { flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
|
|
234
244
|
connectionId: connectionId
|
|
235
245
|
},
|
|
236
246
|
{
|
|
@@ -58,17 +58,16 @@ module.exports.reservedLimit = async (
|
|
|
58
58
|
callingFlowConfig
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
+
let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID)
|
|
62
|
+
|
|
61
63
|
//(<beforeReserved>)
|
|
62
64
|
//(</beforeReserved>)
|
|
63
65
|
|
|
64
|
-
let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID)
|
|
65
|
-
//* hard code
|
|
66
|
-
// _izContext['userId'] = 'this-is-uuid-for-user-superUserA'
|
|
67
66
|
|
|
68
67
|
// get static
|
|
69
68
|
let payloadBeforeInvokeStaticLimit = {
|
|
70
69
|
userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
|
|
71
|
-
|
|
70
|
+
targetId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
|
|
72
71
|
//(<additionalPropertiesStaticLimit>)
|
|
73
72
|
//(</additionalPropertiesStaticLimit>)
|
|
74
73
|
}
|
|
@@ -88,13 +87,11 @@ module.exports.reservedLimit = async (
|
|
|
88
87
|
|
|
89
88
|
let sendMsgReservedDynamic = {
|
|
90
89
|
userId: _izContext.correlationIds.get(coreConsts.BASE_USER_ID),
|
|
91
|
-
|
|
90
|
+
targetId: _izContext.correlationIds.get(coreConsts.TARGET_ID),
|
|
92
91
|
//(<additionalPropertiesReservedDynamic>)
|
|
93
92
|
//(</additionalPropertiesReservedDynamic>)
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
const reservedDataId = `${consts.ACCOUNTLIMIT_TAG.reservedDynamic}_${userId}_${consts.LIMIT_TAG.uploadData}`
|
|
97
|
-
|
|
98
95
|
let callingFlowProperties = {
|
|
99
96
|
//(<baseCallingFlowProperties>)
|
|
100
97
|
//(</baseCallingFlowProperties>)
|
|
@@ -108,9 +105,9 @@ module.exports.reservedLimit = async (
|
|
|
108
105
|
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
109
106
|
callingFlowConfig,
|
|
110
107
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
111
|
-
//(<
|
|
108
|
+
//(<callingFlowPropertiesIfHaveCallingFlowConfig>)
|
|
112
109
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
|
|
113
|
-
//(</
|
|
110
|
+
//(</callingFlowPropertiesIfHaveCallingFlowConfig>)
|
|
114
111
|
callingFlowProperties
|
|
115
112
|
)
|
|
116
113
|
)
|
|
@@ -119,9 +116,9 @@ module.exports.reservedLimit = async (
|
|
|
119
116
|
sendMsgReservedDynamic = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
120
117
|
sendMsgReservedDynamic,
|
|
121
118
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
122
|
-
//(<
|
|
119
|
+
//(<callingFlowPropertiesIfNotHaveCallingFlowConfig>)
|
|
123
120
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
|
|
124
|
-
//(</
|
|
121
|
+
//(</callingFlowPropertiesIfNotHaveCallingFlowConfig>)
|
|
125
122
|
callingFlowProperties
|
|
126
123
|
)
|
|
127
124
|
);
|
|
@@ -142,7 +139,7 @@ module.exports.reservedLimit = async (
|
|
|
142
139
|
|
|
143
140
|
let sendMessageToReservedDynamic = {
|
|
144
141
|
Message: JSON.stringify(sendMsgReservedDynamic),
|
|
145
|
-
TopicArn: await snsSharedLib.
|
|
142
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "ReservedDynamicUsage_In", consts.EXTERNAL_SERVICE_NAME.accountLimits)
|
|
146
143
|
};
|
|
147
144
|
_izContext.logger.debug("sendMessageToReservedDynamic", sendMessageToReservedDynamic);
|
|
148
145
|
await sns.publishAsync(_izContext, sendMessageToReservedDynamic);
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
4
|
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
5
|
events:
|
|
6
|
-
- sqs:
|
|
7
|
-
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %>
|
|
8
|
-
batchSize: 10
|
|
9
6
|
- s3:
|
|
10
7
|
bucket: <%- bucketName %>
|
|
11
8
|
event: s3:ObjectCreated:*
|
|
@@ -36,10 +36,13 @@ function data(_izContext, flowSchema, srcPath) {
|
|
|
36
36
|
|
|
37
37
|
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
38
38
|
let bucketName = flowSchema.bucketName
|
|
39
|
+
let resourceName = bucketName.split("-").join("")
|
|
40
|
+
|
|
39
41
|
return {
|
|
40
42
|
templatePath: templatePath,
|
|
41
43
|
templateData: {
|
|
42
|
-
bucketName
|
|
44
|
+
bucketName,
|
|
45
|
+
resourceName
|
|
43
46
|
},
|
|
44
47
|
setting: {
|
|
45
48
|
initialData: 'Resources:\n',
|
|
@@ -22,10 +22,7 @@ const lambda = externalRequest.lambda;
|
|
|
22
22
|
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda')
|
|
23
23
|
const { ApiGatewayManagementApiClient, PostToConnectionCommand } = require("@aws-sdk/client-apigatewaymanagementapi");
|
|
24
24
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
25
|
-
|
|
26
|
-
const csv = require('csv-parser');
|
|
27
|
-
const streamifier = require('streamifier');
|
|
28
|
-
<% } %>
|
|
25
|
+
|
|
29
26
|
const { NoRetryError,inMemoryCacheLib } = require('@izara_project/izara-core-library-core');
|
|
30
27
|
|
|
31
28
|
const client = new ApiGatewayManagementApiClient({
|
|
@@ -74,43 +71,6 @@ const processStaticLimitWithCache = inMemoryCacheLib(
|
|
|
74
71
|
}
|
|
75
72
|
)
|
|
76
73
|
|
|
77
|
-
<% if (uploadS3) { %>
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
* @param {Object} _izContext
|
|
81
|
-
* @param {Object} data - S3 data
|
|
82
|
-
* @returns
|
|
83
|
-
*/
|
|
84
|
-
async function isValidCsv(_izContext, data) {
|
|
85
|
-
_izContext.logger.debug("function checkValidCsv", { data })
|
|
86
|
-
let errorCheckCsv = [];
|
|
87
|
-
let validCsv = true;
|
|
88
|
-
let rowCount = 0;
|
|
89
|
-
let columnCount = null;
|
|
90
|
-
|
|
91
|
-
streamifier.createReadStream(data.Body).pipe(csv()).on('data', (row) => {
|
|
92
|
-
rowCount++;
|
|
93
|
-
if (columnCount === null) {
|
|
94
|
-
columnCount = Object.keys(row).length
|
|
95
|
-
} else if (Object.keys(row).length !== columnCount) {
|
|
96
|
-
validCsv = false
|
|
97
|
-
errorCheckCsv.push(`Row ${rowCount} has inconsistent columns: ${JSON.stringify(row)}`)
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
.on('end', () => {
|
|
101
|
-
if (rowCount === 0) {
|
|
102
|
-
errorCheckCsv.push("csv file not have data row")
|
|
103
|
-
} else {
|
|
104
|
-
_izContext.logger.debug("validCsv")
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
.on('error', (error) => {
|
|
108
|
-
errorCheckCsv.push(`error:: ${error}`)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
return [validCsv, errorCheckCsv]
|
|
112
|
-
}
|
|
113
|
-
<% } %>
|
|
114
74
|
|
|
115
75
|
/**
|
|
116
76
|
*
|
|
@@ -133,10 +93,7 @@ function getNestObject(_izContext, nestedObj, paths) {
|
|
|
133
93
|
|
|
134
94
|
module.exports = {
|
|
135
95
|
postToConnection,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
getNestObject
|
|
139
|
-
<% if (uploadS3) { %>
|
|
140
|
-
isValidCsv,
|
|
141
|
-
<% } %>
|
|
96
|
+
processStaticLimit,
|
|
97
|
+
processStaticLimitWithCache,
|
|
98
|
+
getNestObject
|
|
142
99
|
}
|