@izara_project/izara-market-library-service-schemas 1.0.48 → 1.0.50
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/index.js +3 -1
- package/package.json +3 -3
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +28 -29
- package/src/GenerateCodeLibs/src/TranslateIdsLibs.js +9 -6
- package/src/MainLibs/src/Consts.js +29 -23
- package/src/MainLibs/src/Utils.js +4 -4
- package/src/reStructure/GenerateCode.js +3 -3
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +3 -3
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +24 -8
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +8 -3
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +11 -5
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +7 -2
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +0 -1
- package/src/reStructure/TemplateData/findData/GetByStorage/getByDynamo.ejs +5 -4
- package/src/reStructure/TemplateData/findData/GetByStorage/getByGraph.ejs +12 -32
- package/src/reStructure/TemplateData/findData/findDataYaml/data.js +32 -62
- package/src/reStructure/TemplateData/findData/generateTemplateData.js +2 -2
- package/src/reStructure/TemplateData/findData/handler/template.ejs +1 -2
- package/src/reStructure/TemplateData/findData/mainFunction/data.js +19 -12
- package/src/reStructure/TemplateData/findData/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/template.ejs +0 -15
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/data.js +4 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/template.ejs +9 -42
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +0 -10
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +2 -14
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +14 -17
- package/src/reStructure/TemplateData/flowSchema/flowStep/handler/data.js +15 -18
- package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/data.js +16 -19
- package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +21 -19
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +20 -6
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +33 -12
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/functionYaml/data.js +128 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/functionYaml/templateApi.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/functionYaml/templateInv.ejs +13 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/handler/data.js +85 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/handler/templateApi.ejs +80 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/handler/templateInv.ejs +47 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/mainFunction/data.js +74 -0
- package/src/reStructure/TemplateData/flowSchema/lambdaSync/mainFunction/template.ejs +96 -0
- package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +1 -0
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +6 -7
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/storedCacheTemplate.ejs +4 -5
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +2 -6
- package/src/reStructure/TemplateData/generateRole/data.js +0 -20
- package/src/reStructure/TemplateData/generateRole/template.ejs +4 -2
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +18 -7
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +10 -10
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +10 -10
- package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +2 -2
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +5 -5
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +5 -5
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +5 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +3 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +6 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +7 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +8 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +8 -7
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/handler/sqs/template.ejs +8 -4
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +8 -7
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +2 -2
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const RBAC_TARGET_ID = process.env.iz_rbacTargetIdUser // iz_rbacTargetIdUser | iz_rbacDeliveryMethodId
|
|
21
|
+
|
|
22
|
+
const izara = require("@izara_project/izara-middleware");
|
|
23
|
+
const middleware = izara.middlewareHandler;
|
|
24
|
+
const lambdaFunction = require('./LambdaFunction_Main')
|
|
25
|
+
|
|
26
|
+
// validate event params in middlewware before into function.
|
|
27
|
+
let validatorSchema = {};
|
|
28
|
+
// NOTE: not sure about remap_when_flatten and remove_when_flatten function of api still require for validate or not? Tam(19-Nov) -- Yes
|
|
29
|
+
|
|
30
|
+
// for auth userLevel
|
|
31
|
+
if (process.env.iz_rbacTargetIdUser) {
|
|
32
|
+
validatorSchema.required.push('pathParameters');
|
|
33
|
+
validatorSchema.properties.pathParameters = {
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
type: ['object', 'boolean'],
|
|
36
|
+
required: [process.env.iz_rbacTargetIdUser],
|
|
37
|
+
properties: {
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
validatorSchema.properties.pathParameters.properties[process.env.iz_rbacTargetIdUser] = {
|
|
41
|
+
type: 'string'
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// If not have Authorizer set setMiddlewareSettings.
|
|
45
|
+
middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true })
|
|
46
|
+
|
|
47
|
+
// // default user Authorizer.
|
|
48
|
+
// middleware.setValidatorSchema(validatorSchema)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
52
|
+
event._izContext.logger.debug('Event:', event);
|
|
53
|
+
try {
|
|
54
|
+
|
|
55
|
+
// for targetUserId
|
|
56
|
+
let targetUserId = null
|
|
57
|
+
if (process.env.iz_rbacTargetIdUser) {
|
|
58
|
+
targetUserId = event.pathParameters[process.env.iz_rbacTargetIdUser]
|
|
59
|
+
}
|
|
60
|
+
// invoke LambdaFunction
|
|
61
|
+
let lambdaFunctionResponse = await lambdaFunction.lambdaFunction(
|
|
62
|
+
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
|
|
63
|
+
event.body,
|
|
64
|
+
event._izContext.userId, // send userId last element
|
|
65
|
+
targetUserId
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// return error to client
|
|
69
|
+
if (lambdaFunctionResponse instanceof Error) {
|
|
70
|
+
return (izara.response.failure(lambdaFunctionResponse));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// return success to client
|
|
74
|
+
return (izara.response.success(lambdaFunctionResponse));
|
|
75
|
+
|
|
76
|
+
} catch (err) {
|
|
77
|
+
event._izContext.logger.error('Error, LambdaFunctionHdrApi: ', err);
|
|
78
|
+
return (izara.response.failure(err));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
// const AWS = require('aws-sdk');
|
|
21
|
+
// const sqs = new AWS.SQS({ apiVersion: '2012-11-05' });
|
|
22
|
+
|
|
23
|
+
const middleware = require("@izara_project/izara-middleware").middlewareHandler;
|
|
24
|
+
|
|
25
|
+
const <%- functionName %> = require('./<%- functionName %>_Main')
|
|
26
|
+
|
|
27
|
+
// validate event params in middlewware before into function.
|
|
28
|
+
const validatorSchema = {};
|
|
29
|
+
middleware.setValidatorSchema(validatorSchema)
|
|
30
|
+
|
|
31
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
32
|
+
event._izContext.logger.debug('Event:', event);
|
|
33
|
+
event._izContext.logger.debug('context:', context);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
|
|
37
|
+
// invoke LambdaFunction
|
|
38
|
+
return await lambdaFunction.lambdaFunction(
|
|
39
|
+
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
|
|
40
|
+
event
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
} catch (err) {
|
|
44
|
+
event._izContext.logger.error('Error, LambdaFunctionHdrInv: ', err);
|
|
45
|
+
throw (err);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema
|
|
21
|
+
const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts');
|
|
22
|
+
const { STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
24
|
+
const templatePath = path.join(__dirname, "./template.ejs");
|
|
25
|
+
const statusFieldTemplate = path.join(__dirname, "../../templateBystatusType/statusFieldTemplate.ejs")
|
|
26
|
+
const storedCacheTemplate = path.join(__dirname, "../../templateBystatusType/storedCacheTemplate.ejs")
|
|
27
|
+
const triggerCacheTemplate = path.join(__dirname, "../../templateBystatusType/triggerCacheTemplate.ejs");
|
|
28
|
+
/**
|
|
29
|
+
* receive objectSchema
|
|
30
|
+
* create data for WebScoket handler template
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} objectSchema
|
|
33
|
+
* @return {{templatePath, templateData,setting}}
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
async function data(_izContext, flowSchema, srcPath) {
|
|
38
|
+
return [await createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
42
|
+
let functionName = upperCase(flowSchema.flowTag);
|
|
43
|
+
let statusType = flowSchema.statusType;
|
|
44
|
+
let triggerType = flowSchema.triggerType;
|
|
45
|
+
let tableName = null;
|
|
46
|
+
if (flowSchema.statusType === "storedCache") {
|
|
47
|
+
let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
|
|
48
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
49
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
50
|
+
tableName = storageResource.tableName
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
templatePath: templatePath,
|
|
56
|
+
templateData: {
|
|
57
|
+
flowTag: flowSchema.flowTag,
|
|
58
|
+
functionName,
|
|
59
|
+
statusFieldTemplate,
|
|
60
|
+
storedCacheTemplate,
|
|
61
|
+
triggerCacheTemplate,
|
|
62
|
+
statusType,
|
|
63
|
+
tableName,
|
|
64
|
+
triggerType
|
|
65
|
+
},
|
|
66
|
+
setting: {
|
|
67
|
+
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
|
|
68
|
+
saveFileName: `${functionName}_Main`,
|
|
69
|
+
fileExtension: ".js",
|
|
70
|
+
isAppend: false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
module.exports = data
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http: //izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see
|
|
16
|
+
<http: //www.gnu.org/licenses />.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
23
|
+
|
|
24
|
+
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
|
+
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
|
+
const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
|
|
27
|
+
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
28
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
29
|
+
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
30
|
+
const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
|
|
31
|
+
|
|
32
|
+
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
33
|
+
const sns = externalRequest.sns
|
|
34
|
+
const sqs = externalRequest.sqs
|
|
35
|
+
const lambda = externalRequest.lambda
|
|
36
|
+
const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
|
|
37
|
+
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
38
|
+
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
39
|
+
const { v4: uuidv4 } = require('uuid')
|
|
40
|
+
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
41
|
+
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
42
|
+
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
43
|
+
const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs.js')
|
|
44
|
+
//(<optionalRequire>)
|
|
45
|
+
//(</optionalRequire>)
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
*
|
|
49
|
+
* description of function.
|
|
50
|
+
* @param {Object} _izContext
|
|
51
|
+
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
52
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
53
|
+
* @param {Object} requestParams - request params
|
|
54
|
+
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
55
|
+
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
56
|
+
*
|
|
57
|
+
*
|
|
58
|
+
* @returns {object} description of return value
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
module.exports.<%- functionName %>Main = async (
|
|
62
|
+
_izContext,
|
|
63
|
+
requestParams,
|
|
64
|
+
callingFlowConfig = {},
|
|
65
|
+
//(<additionalParams>)
|
|
66
|
+
//(</additionalParams>)
|
|
67
|
+
) => {
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
_izContext.logger.debug("<%- functionName %>Main _izContext", _izContext)
|
|
71
|
+
_izContext.logger.debug("<%- functionName %>Main requestParams", requestParams)
|
|
72
|
+
_izContext.logger.debug("<%- functionName %>Main callingFlowConfig", callingFlowConfig)
|
|
73
|
+
|
|
74
|
+
//(<beforeCheckStatus>)
|
|
75
|
+
//(</beforeCheckStatus>)
|
|
76
|
+
|
|
77
|
+
<% if (statusType === "statusField") { %>
|
|
78
|
+
<%- include(statusFieldTemplate) %>
|
|
79
|
+
<% } else if (statusType === "storedCache") { %>
|
|
80
|
+
<%- include(storedCacheTemplate, {tableName:tableName}) %>
|
|
81
|
+
|
|
82
|
+
<% } else if (statusType === "triggerCache") { %>
|
|
83
|
+
<%- include(triggerCacheTemplate, {
|
|
84
|
+
tableName: tableName,
|
|
85
|
+
triggerType: triggerType
|
|
86
|
+
}) %>
|
|
87
|
+
<% } %>
|
|
88
|
+
|
|
89
|
+
//(<endpointHook>)
|
|
90
|
+
//(</endpointHook>)
|
|
91
|
+
|
|
92
|
+
} catch (err) {
|
|
93
|
+
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
94
|
+
throw (err)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -50,6 +50,7 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
|
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
53
|
+
passOnProperties.push(record.body.TopicArn)
|
|
53
54
|
passOnProperties.push(record.body.Message)
|
|
54
55
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
55
56
|
|
|
@@ -51,6 +51,7 @@ const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Const
|
|
|
51
51
|
*/
|
|
52
52
|
module.exports.registerCompleteMain = async (
|
|
53
53
|
_izContext,
|
|
54
|
+
topicArn,
|
|
54
55
|
requestParams,
|
|
55
56
|
callingFlowConfig = {},
|
|
56
57
|
//(<additionalParams>)
|
|
@@ -63,16 +64,14 @@ module.exports.registerCompleteMain = async (
|
|
|
63
64
|
|
|
64
65
|
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!requestParams.flowTag) {
|
|
70
|
-
throw new NoRetryError("not have flowTag in request")
|
|
67
|
+
if (!topicArn){
|
|
68
|
+
throw new NoRetryError("invalid not have topicArn to get flowSchema")
|
|
71
69
|
}
|
|
72
70
|
|
|
71
|
+
let topicName = topicArn.split(":")[5].split("_")
|
|
73
72
|
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
74
|
-
flowTag:
|
|
75
|
-
serviceTag:
|
|
73
|
+
flowTag: topicName[2],
|
|
74
|
+
serviceTag: topicName[0]
|
|
76
75
|
})
|
|
77
76
|
|
|
78
77
|
if (!flowSchema) {
|
package/src/reStructure/TemplateData/flowSchema/templateBystatusType/storedCacheTemplate.ejs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//(</createKeyValuesStoredCacheTable>)
|
|
3
|
-
|
|
4
|
-
let [ cacheMainStatus, cacheId, cacheMain ] = await storedCacheSharedLib.checkStoredCacheStatus(
|
|
1
|
+
let [ cacheMainStatus, cacheMain, cacheExist ] = await storedCacheSharedLib.checkStoredCacheStatus(
|
|
5
2
|
_izContext,
|
|
6
3
|
"<%- tableName %>",
|
|
7
4
|
{
|
|
@@ -20,5 +17,7 @@ if (cacheMainStatus !== "process") {
|
|
|
20
17
|
//(<afterValidateStoredCacheStatus>)
|
|
21
18
|
//(</afterValidateStoredCacheStatus>)
|
|
22
19
|
}
|
|
23
|
-
}
|
|
24
20
|
|
|
21
|
+
//(<checkStoredCacheHook>)
|
|
22
|
+
//(</checkStoredCacheHook>)
|
|
23
|
+
}
|
package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs
CHANGED
|
@@ -17,10 +17,6 @@ if (triggerCacheStatus !== "process") {
|
|
|
17
17
|
//(<afterValidateTriggerCacheStatus>)
|
|
18
18
|
//(</afterValidateTriggerCacheStatus>)
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
//(<validateTriggerCacheProcessing>)
|
|
24
|
-
//(</validateTriggerCacheProcessing>)
|
|
25
|
-
}
|
|
20
|
+
//(<checkTriggerCacheHook>)
|
|
21
|
+
//(</checkTriggerCacheHook>)
|
|
26
22
|
}
|
|
@@ -48,11 +48,7 @@ function generateRole(_izContext, createSourceParams, srcPath) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
console.log("reformCreateSourceParams", JSON.stringify(reformCreateSourceParams, null, 2))
|
|
52
|
-
// console.log("reformCreateSourceParams", reformCreateSourceParams)
|
|
53
51
|
for (const [roleName, roleData] of Object.entries(reformCreateSourceParams)) {
|
|
54
|
-
// console.log("roleName in reformCreateSourceParams", roleName)
|
|
55
|
-
// console.log('roleData', JSON.stringify(roleData, null, 2))
|
|
56
52
|
|
|
57
53
|
createSourceRole.push(
|
|
58
54
|
{
|
|
@@ -76,19 +72,3 @@ function generateRole(_izContext, createSourceParams, srcPath) {
|
|
|
76
72
|
module.exports = {
|
|
77
73
|
generateRole
|
|
78
74
|
}
|
|
79
|
-
|
|
80
|
-
/*
|
|
81
|
-
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
82
|
-
- Effect: <%- resourcePermission.effect %>
|
|
83
|
-
Action:
|
|
84
|
-
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
85
|
-
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
86
|
-
- <%- resourcePerAction %>:<%- permission %>
|
|
87
|
-
<%_ }) _%>
|
|
88
|
-
<%_ }) _%>
|
|
89
|
-
Resource:
|
|
90
|
-
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
91
|
-
- "<%- resource %>"
|
|
92
|
-
<%_ }) _%>
|
|
93
|
-
<%_}) _%>
|
|
94
|
-
*/
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
Principal:
|
|
10
10
|
Service: "lambda.amazonaws.com"
|
|
11
11
|
Action: sts:AssumeRole
|
|
12
|
+
#<#AssumeRolePolicyDocument<%- roleName %>Role#>
|
|
13
|
+
#<#/AssumeRolePolicyDocument<%- roleName %>Role#>
|
|
12
14
|
ManagedPolicyArns:
|
|
13
15
|
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
14
16
|
Policies:
|
|
@@ -29,5 +31,5 @@
|
|
|
29
31
|
- "<%- resource.trim() _%>"
|
|
30
32
|
<%_ }) _%>
|
|
31
33
|
<%_ }) _%>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
#<#<%- roleName %>Role#>
|
|
35
|
+
#<#/<%- roleName %>Role#>
|
|
@@ -38,7 +38,7 @@ const PREFIX = {
|
|
|
38
38
|
* @param {*} errorsFounds
|
|
39
39
|
* @param {*} graphServiceTag
|
|
40
40
|
* @param {*} passBackProperties
|
|
41
|
-
*/
|
|
41
|
+
*/
|
|
42
42
|
|
|
43
43
|
module.exports.createObjectComplete = async (
|
|
44
44
|
_izContext,
|
|
@@ -90,11 +90,24 @@ module.exports.createObjectComplete = async (
|
|
|
90
90
|
errorsFound = errorsFound.concat(errorsFound.join(","));
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
+
let existsNode = null;
|
|
94
|
+
|
|
95
|
+
if (Object.keys(returnValue.queryResult.returnCreateNode.existsNode).length) {
|
|
96
|
+
existsNode = {
|
|
97
|
+
objType: {
|
|
98
|
+
objectType: returnValue.requestParams.objType.objectType,
|
|
99
|
+
serviceTag: returnValue.requestParams.objType.serviceTag
|
|
100
|
+
},
|
|
101
|
+
objInstanceFull: returnValue.queryResult.returnCreateNode.existsNode.objInstanceFull
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
93
105
|
let awaitingStepId = await asyncFlowSharedLib.createAwaitingStepId(
|
|
94
106
|
(hash({
|
|
95
107
|
objType: returnValue.requestParams.objType,
|
|
96
108
|
graphServerTag: graphServiceTag,
|
|
97
|
-
identifiers: returnValue.requestParams.objInstanceFull.identifiers
|
|
109
|
+
identifiers: returnValue.requestParams.objInstanceFull.identifiers,
|
|
110
|
+
callingFlowProperties: passBackProperties.passBackProperties.parentPassBackProperties.callingFlowProperties || {}
|
|
98
111
|
})),
|
|
99
112
|
PREFIX.CREATE_OBJECT_ASYNC
|
|
100
113
|
)
|
|
@@ -124,11 +137,9 @@ module.exports.createObjectComplete = async (
|
|
|
124
137
|
objectType: returnValue.requestParams.objType.objectType,
|
|
125
138
|
serviceTag: returnValue.requestParams.objType.serviceTag
|
|
126
139
|
},
|
|
127
|
-
objInstanceFull:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
},
|
|
131
|
-
relationships: returnValue.requestParams.relationships,
|
|
140
|
+
objInstanceFull: returnValue.queryResult.returnCreateNode.objInstanceFull,
|
|
141
|
+
relationships: returnValue.queryResult.returnCreateNode.relationships,
|
|
142
|
+
existsNode: existsNode,
|
|
132
143
|
status: status,
|
|
133
144
|
errorsFound: errorsFound
|
|
134
145
|
}
|
|
@@ -54,10 +54,10 @@ module.exports.updateNodeComplete = async (
|
|
|
54
54
|
// start create AwaitingStepId
|
|
55
55
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
56
56
|
hash({
|
|
57
|
-
objectType: returnValue.
|
|
58
|
-
serviceTag: returnValue.
|
|
59
|
-
identifiers: returnValue.
|
|
60
|
-
fields: returnValue.
|
|
57
|
+
objectType: returnValue.queryResult.refactoredNodes.objType.objectType,
|
|
58
|
+
serviceTag: returnValue.queryResult.refactoredNodes.objType.serviceTag,
|
|
59
|
+
identifiers: returnValue.queryResult.refactoredNodes.objInstanceFull.identifiers,
|
|
60
|
+
fields: returnValue.queryResult.refactoredNodes.objInstanceFull.fields
|
|
61
61
|
}),
|
|
62
62
|
PREFIX.updateNode
|
|
63
63
|
)
|
|
@@ -83,12 +83,12 @@ module.exports.updateNodeComplete = async (
|
|
|
83
83
|
|
|
84
84
|
let updateCompleteMsg = {
|
|
85
85
|
objType: {
|
|
86
|
-
objectType: returnValue.
|
|
87
|
-
serviceTag: returnValue.
|
|
86
|
+
objectType: returnValue.queryResult.refactoredNodes.objType.objectType,
|
|
87
|
+
serviceTag: returnValue.queryResult.refactoredNodes.objType.serviceTag
|
|
88
88
|
},
|
|
89
89
|
objInstance: {
|
|
90
|
-
identifiers: returnValue.
|
|
91
|
-
fields: returnValue.
|
|
90
|
+
identifiers: returnValue.queryResult.refactoredNodes.objInstanceFull.identifiers,
|
|
91
|
+
fields: returnValue.queryResult.refactoredNodes.objInstanceFull.fields
|
|
92
92
|
},
|
|
93
93
|
status: status,
|
|
94
94
|
errorsFound: errorsFound
|
|
@@ -123,8 +123,8 @@ module.exports.updateNodeComplete = async (
|
|
|
123
123
|
//(</beforeReturn>)
|
|
124
124
|
|
|
125
125
|
return {
|
|
126
|
-
objType: returnValue.
|
|
127
|
-
objInstanceFull: returnValue.
|
|
126
|
+
objType: returnValue.queryResult.refactoredNodes.objType,
|
|
127
|
+
objInstanceFull: returnValue.queryResult.refactoredNodes.objInstanceFull,
|
|
128
128
|
errorsFound: errorsFound
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -54,10 +54,10 @@ module.exports.updateNodeComplete = async (
|
|
|
54
54
|
// start create AwaitingStepId
|
|
55
55
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
56
56
|
hash({
|
|
57
|
-
objectType: returnValue.
|
|
58
|
-
serviceTag: returnValue.
|
|
59
|
-
identifiers: returnValue.
|
|
60
|
-
fields: returnValue.
|
|
57
|
+
objectType: returnValue.queryResult.objType.objectType,
|
|
58
|
+
serviceTag: returnValue.queryResult.objType.serviceTag,
|
|
59
|
+
identifiers: returnValue.queryResult.objInstanceFull.identifiers,
|
|
60
|
+
fields: returnValue.queryResult.objInstanceFull.fields
|
|
61
61
|
}),
|
|
62
62
|
PREFIX.updateNode
|
|
63
63
|
)
|
|
@@ -83,12 +83,12 @@ module.exports.updateNodeComplete = async (
|
|
|
83
83
|
|
|
84
84
|
let updateCompleteMsg = {
|
|
85
85
|
objType: {
|
|
86
|
-
objectType: returnValue.
|
|
87
|
-
serviceTag: returnValue.
|
|
86
|
+
objectType: returnValue.queryResult.objType.objectType,
|
|
87
|
+
serviceTag: returnValue.queryResult.objType.serviceTag
|
|
88
88
|
},
|
|
89
89
|
objInstanceFull: {
|
|
90
|
-
identifiers: returnValue.
|
|
91
|
-
fields: returnValue.
|
|
90
|
+
identifiers: returnValue.queryResult.objInstanceFull.identifiers,
|
|
91
|
+
fields: returnValue.queryResult.objInstanceFull.fields
|
|
92
92
|
},
|
|
93
93
|
status: status,
|
|
94
94
|
errorsFound: errorsFound
|
|
@@ -123,8 +123,8 @@ module.exports.updateNodeComplete = async (
|
|
|
123
123
|
//(</beforeReturn>)
|
|
124
124
|
|
|
125
125
|
return {
|
|
126
|
-
objType: returnValue.
|
|
127
|
-
objInstanceFull: returnValue.
|
|
126
|
+
objType: returnValue.queryResult.objType,
|
|
127
|
+
objInstanceFull: returnValue.queryResult.objInstanceFull,
|
|
128
128
|
errorsFound: errorsFound
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -110,7 +110,7 @@ module.exports.processLogical = async (
|
|
|
110
110
|
errorsFound.push("type of element isn't object")
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
const objectSchemas = await getObjectSchemas.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
113
|
+
const objectSchemas = await getObjectSchemas.getObjSchemaS3WithHierarchy(_izContext, objType, process.env.iz_serviceSchemaBucketName);
|
|
114
114
|
_izContext.logger.debug("objectSchemas: ", objectSchemas)
|
|
115
115
|
|
|
116
116
|
let identifiersFieldName = null;
|
|
@@ -34,7 +34,7 @@ const templatePath = path.join(__dirname, "./templateObjectPropertyValueSchema.e
|
|
|
34
34
|
const modules = {
|
|
35
35
|
validateAddOnDataStructure: require('../../../libs/ValidateAddOnDataStructure')
|
|
36
36
|
};
|
|
37
|
-
const
|
|
37
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
38
38
|
// const objectSchemasBySrc = srcPath
|
|
39
39
|
|
|
40
40
|
|
|
@@ -43,7 +43,7 @@ async function data(_izContext, settings, srcPath) {
|
|
|
43
43
|
let createSources = [];
|
|
44
44
|
for (const settingPropertyNode of settings) {
|
|
45
45
|
if (settingPropertyNode.generateName === "propertyValue") {
|
|
46
|
-
let objectSchema = await
|
|
46
|
+
let objectSchema = await getObjectSchema.getLocalObjectSchemasWithHierarchy(
|
|
47
47
|
_izContext,
|
|
48
48
|
[settingPropertyNode.objType.objectType],
|
|
49
49
|
path.join(srcPath, "./schemas")
|
package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js
CHANGED
|
@@ -28,9 +28,9 @@ const {
|
|
|
28
28
|
|
|
29
29
|
const templatePath = path.join(__dirname, "./tempRelationship.ejs");
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
32
32
|
|
|
33
|
-
const { firstLetterUpperCase: upperCase,
|
|
33
|
+
const { firstLetterUpperCase: upperCase, getLocalConfig } = require("../../../../MainLibs/src/Utils");
|
|
34
34
|
const { createBasicRelationshipsProperties } = require('../../../../GenerateCodeLibs/src/GenerateCodeLibs');
|
|
35
35
|
const { ADD_ON_DATA_STRUCTURE_TYPE } = require('../../../../TemplateManager/src/libs/Consts');
|
|
36
36
|
|
|
@@ -38,10 +38,10 @@ async function data(_izContext, settings, srcPath) {
|
|
|
38
38
|
// console.log("create Data function ::", { settings })
|
|
39
39
|
let createSourceRecords = []
|
|
40
40
|
for (const settingPropertyValue of settings) {
|
|
41
|
-
let objectSchema = await
|
|
41
|
+
let objectSchema = await getObjectSchema.getLocalObjectSchemasWithHierarchy(
|
|
42
42
|
_izContext,
|
|
43
43
|
settingPropertyValue.objType.objectType,
|
|
44
|
-
path.join(srcPath, "./schemas")
|
|
44
|
+
path.join(srcPath, "./schemas"),
|
|
45
45
|
).then(res => res.records[0]);
|
|
46
46
|
|
|
47
47
|
if (!objectSchema) {
|
|
@@ -88,7 +88,7 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
88
88
|
// const objectType = objectSchema.objectType; // main objectType
|
|
89
89
|
let propertyValue = settings.propertyValueTag
|
|
90
90
|
const storageResources = objectSchema.storageResources // storageResource from main objectType
|
|
91
|
-
const serviceTag =
|
|
91
|
+
const serviceTag = getLocalConfig(srcPath, "iz_serviceTag")
|
|
92
92
|
|
|
93
93
|
attributeRelationships.push(
|
|
94
94
|
{ // has{objectType}propertyValue
|
package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs
CHANGED
|
@@ -100,7 +100,7 @@ module.exports.createRelationship = async (
|
|
|
100
100
|
async function validateIdentifiersExists(_izContext, objType, identifiersObject) {
|
|
101
101
|
|
|
102
102
|
const objTypeString = `objType:{ serviceTag:${objType.serviceTag}, objectType:${objType.objectType} }`;
|
|
103
|
-
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
103
|
+
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType, process.env.iz_serviceSchemaBucketName);
|
|
104
104
|
|
|
105
105
|
if (!objectSchema) {
|
|
106
106
|
errorsFound.push(`validateIdentifiers, not found schema of ${objTypeString}`);
|
|
@@ -133,7 +133,7 @@ module.exports.createRelationship = async (
|
|
|
133
133
|
//(<beforeGetRelCreateRel>)
|
|
134
134
|
//(</beforeGetRelCreateRel>)
|
|
135
135
|
|
|
136
|
-
const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType);
|
|
136
|
+
const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType, process.env.iz_serviceSchemaBucketName);
|
|
137
137
|
_izContext.logger.debug("relationshipSchema: ", relationshipSchema);
|
|
138
138
|
|
|
139
139
|
const links = await findLinksByObjTypes(_izContext, [firstObject.objType, secondObject.objType], relationshipSchema.links)
|
|
@@ -196,7 +196,7 @@ module.exports.createRelationship = async (
|
|
|
196
196
|
const usedStorageResource = relationshipSchema.storageResources[storageResourceTag];
|
|
197
197
|
|
|
198
198
|
if (usedStorageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
199
|
-
const graphServiceTag = await getGraphServiceTagWithCache(_izContext, usedStorageResource.graphServerTag);
|
|
199
|
+
const graphServiceTag = await getGraphServiceTagWithCache(_izContext, usedStorageResource.graphServerTag, process.env.iz_serviceSchemaBucketName);
|
|
200
200
|
if (!graphServiceTag) {
|
|
201
201
|
errorsFound.push(`storageResourceTag: ${storageResourceTag} invalid, not found graph serviceTag from graphServerTag: ${usedStorageResource.graphServerTag}`)
|
|
202
202
|
}
|
|
@@ -354,8 +354,8 @@ module.exports.createRelationship = async (
|
|
|
354
354
|
relationshipProperties
|
|
355
355
|
//(<inUpdateRelMessageBodyCreateRel>)
|
|
356
356
|
//(</inUpdateRelMessageBodyCreateRel>)
|
|
357
|
-
|
|
358
|
-
|
|
357
|
+
|
|
358
|
+
// assign originTimestamp if not exists in relationshipProperties
|
|
359
359
|
}
|
|
360
360
|
_izContext.logger.debug('createRelMessageBody: ', createRelMessageBody);
|
|
361
361
|
|