@izara_project/izara-market-library-service-schemas 1.0.26 → 1.0.28
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 +2 -1
- package/package.json +9 -4
- package/src/GenerateCodeLibs/src/Consts.js +5 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +6 -6
- package/src/MainLibs/src/Consts.js +45 -2
- package/src/TemplateManager/src/libs/Consts.js +0 -1
- package/src/reStructure/GenerateCode.js +23 -4
- package/src/reStructure/GenerateSchema.js +153 -0
- package/src/reStructure/SchemaConfig.js +29 -0
- package/src/reStructure/TemplateConfig.js +20 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +104 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/attributeLinkTemplate.ejs +21 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +188 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/request.json +11 -0
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +3 -4
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +1 -1
- package/src/reStructure/TemplateData/findData/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/findData/mainFunction/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/template.ejs +2 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +4 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +2 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +5 -6
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/handler/template.ejs +1 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +3 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/functionYaml/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/handler/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/mainFunction/template.ejs +3 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +2 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +5 -6
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +4 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/template.ejs +1 -14
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +4 -5
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +4 -2
- package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ReservedTableData.js +2 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/WebSocketTaskData.js +2 -1
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +10 -0
- package/src/reStructure/TemplateData/perActionComplete/create/handler/template.ejs +2 -3
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +4 -5
- package/src/reStructure/TemplateData/perActionComplete/delete/handler/template.ejs +2 -2
- package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +4 -6
- package/src/reStructure/TemplateData/perActionComplete/generateTemplateData.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/get/handler/template.ejs +2 -3
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +4 -6
- package/src/reStructure/TemplateData/perActionComplete/update/handler/template.ejs +2 -3
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -6
- package/src/reStructure/TemplateData/perActionComplete/update/sns-in-sqs/data.js +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/handler/api/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/perActionEndpoint/handler/inv/template.ejs +1 -3
- package/src/reStructure/TemplateData/perActionEndpoint/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/perActionEndpoint/handler/webSocket/template.ejs +3 -3
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/create/template.ejs +6 -7
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/delete/template.ejs +5 -4
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/get/template.ejs +5 -6
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/update/template.ejs +5 -6
- package/src/reStructure/TemplateData/processLogical/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +5 -6
- package/src/reStructure/TemplateData/processLogicalPagination/handler/dsq/template.ejs +1 -1
- package/src/reStructure/TemplateData/processLogicalPagination/handler/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/processLogicalPagination/mainFunction/template.ejs +6 -5
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +27 -6
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +25 -4
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +26 -4
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +26 -4
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/api/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/inv/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +66 -18
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -3
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +5 -6
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +25 -4
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +25 -4
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +25 -4
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +26 -4
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/api/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/inv/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +55 -5
- package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +62 -6
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +119 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +131 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/template.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +119 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/template.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +131 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/template.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/data.js +57 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/template.ejs +138 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/data.js +58 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/template.ejs +183 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/template.ejs +125 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/template.ejs +163 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +322 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/data.js +77 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/snsTemplate.ejs +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/sqsTemplate.ejs +43 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +110 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/data.js +60 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +125 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +141 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/template.ejs +47 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/template.ejs +10 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +25 -22
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +25 -5
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +26 -5
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +25 -4
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/api/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/dsq/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/inv/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +55 -7
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/defaultDynamoDbTable.js +50 -42
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +98 -0
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +4 -5
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +11 -2
- package/src/reStructure/TemplateData/testTemplate/data.js +27 -0
- package/src/reStructure/TemplateData/testTemplate/template.ejs +5 -0
- package/src/reStructure/libs/GenerateCodeLibs.js +38 -0
package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs
CHANGED
|
@@ -20,12 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20
20
|
const izara = require("@izara_project/izara-middleware");
|
|
21
21
|
const middleware = izara.middlewareHandler;
|
|
22
22
|
|
|
23
|
-
const callingFlowSharedLib = require('@izara_project/izara-
|
|
23
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
24
24
|
|
|
25
25
|
// const CorrelationIds = require('@izara_project/izara-core-library-correlation-ids')
|
|
26
26
|
// const IntegrationTestDetail = require('@izara_project/izara-core-library-integration-tests')
|
|
27
27
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
28
|
-
const recordHandlerSharedLib = require('@izara_project/izara-
|
|
28
|
+
const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
|
package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/inv/template.ejs
CHANGED
|
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20
20
|
const izara = require("@izara_project/izara-middleware");
|
|
21
21
|
const middleware = izara.middlewareHandler;
|
|
22
22
|
|
|
23
|
-
const callingFlowSharedLib = require('@izara_project/izara-
|
|
23
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
24
24
|
|
|
25
25
|
// const CorrelationIds = require('@izara_project/izara-core-library-correlation-ids')
|
|
26
26
|
// const Logger = require('@izara_project/izara-core-library-logger');
|
package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs
CHANGED
|
@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
'use strict';
|
|
19
19
|
const izara = require("@izara_project/izara-middleware");
|
|
20
20
|
const middleware = izara.middlewareHandler;
|
|
21
|
-
const callingFlowSharedLib = require('@izara_project/izara-
|
|
21
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
22
22
|
const {
|
|
23
23
|
validateSchemaMiddleware
|
|
24
24
|
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
25
25
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
26
|
-
const recordHandlerSharedLib = require('@izara_project/izara-
|
|
26
|
+
const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
|
|
27
27
|
|
|
28
28
|
const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
|
|
29
29
|
|
package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs
CHANGED
|
@@ -19,13 +19,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
|
|
20
20
|
const hash = require("object-hash");
|
|
21
21
|
|
|
22
|
-
const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
|
|
23
|
-
const lambdaSharedLib = require('@izara_project/izara-shared/src/LambdaSharedLib');
|
|
24
22
|
|
|
25
|
-
const
|
|
23
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
24
|
+
const lambdaSharedLib = require("@izara_project/izara-core-library-lambda");
|
|
25
|
+
const snsSharedLib = require("@izara_project/izara-core-library-sns");
|
|
26
|
+
const dynamodbSharedLib = require("@izara_project/izara-core-library-dynamodb");
|
|
27
|
+
const asyncFlowSharedLib = require("@izara_project/izara-core-library-asynchronous-flow");
|
|
28
|
+
|
|
26
29
|
const sns = require("@izara_project/izara-core-library-external-request/src/resources/Sns");
|
|
27
30
|
|
|
28
|
-
const
|
|
31
|
+
const identifiersObject = require('@izara_project/izara-core-library-service-schemas/src/IdentifiersObject');
|
|
29
32
|
|
|
30
33
|
// const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
31
34
|
|
|
@@ -265,6 +268,31 @@ module.exports.deleteRelationship = async (
|
|
|
265
268
|
PREFIX.deleteRel // prefix, use constant further
|
|
266
269
|
)
|
|
267
270
|
);
|
|
271
|
+
} else if (targetStorageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
272
|
+
let tableNameFrom = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__${relType.relationshipTag}__${secondObject.objType.serviceTag}_${secondObject.objType.objectType}`;
|
|
273
|
+
let tableNameTo = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__${relType.relationshipTag}__${firstObject.objType.serviceTag}_${firstObject.objType.objectType}`;
|
|
274
|
+
|
|
275
|
+
let identifiersConcatFirstObject = await identifiersObject.identifiersConcatFromIdentifiers(_izContext, firstObject.objType, firstObject.identifiers);
|
|
276
|
+
let identifiersConcatSecondObject = await identifiersObject.identifiersConcatFromIdentifiers(_izContext, secondObject.objType, secondObject.identifiers);
|
|
277
|
+
const firstObjectIdentifiersConcat = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__identifiersConcat`;
|
|
278
|
+
const secondObjectIdentifiersConcat = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__identifiersConcat`;
|
|
279
|
+
// putItem first Object DynamoDb
|
|
280
|
+
await dynamodbSharedLib.deleteItem(_izContext,
|
|
281
|
+
await dynamodbSharedLib.tableName(_izContext, tableNameFrom),
|
|
282
|
+
{
|
|
283
|
+
[firstObjectIdentifiersConcat]: identifiersConcatFirstObject,
|
|
284
|
+
[secondObjectIdentifiersConcat]: identifiersConcatSecondObject
|
|
285
|
+
}
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
// putitem second Object DynamoDb
|
|
289
|
+
await dynamodbSharedLib.deleteItem(_izContext,
|
|
290
|
+
await dynamodbSharedLib.tableName(_izContext, tableNameTo),
|
|
291
|
+
{
|
|
292
|
+
[secondObjectIdentifiersConcat]: identifiersConcatSecondObject,
|
|
293
|
+
[firstObjectIdentifiersConcat]: identifiersConcatFirstObject
|
|
294
|
+
}
|
|
295
|
+
)
|
|
268
296
|
}
|
|
269
297
|
}
|
|
270
298
|
|
|
@@ -316,8 +344,30 @@ module.exports.deleteRelationship = async (
|
|
|
316
344
|
})
|
|
317
345
|
)
|
|
318
346
|
|
|
319
|
-
} else {
|
|
347
|
+
} else if (!awaitingStepIds.length) {
|
|
348
|
+
_izContext.logger.debug("dynamoDb storageResourceTag")
|
|
320
349
|
// if relationshipSchema stored in dynamoDB only will send message to outComplete
|
|
350
|
+
let messageObject = {
|
|
351
|
+
firstObject: firstObject,
|
|
352
|
+
secondObject: secondObject,
|
|
353
|
+
relType: relType,
|
|
354
|
+
relationshipDirection,
|
|
355
|
+
relationshipProperties
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
|
|
359
|
+
_izContext.logger.debug("have callingFlow");
|
|
360
|
+
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
|
|
361
|
+
|
|
362
|
+
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
363
|
+
let sendMessageToOutDeleteRelComplete = {
|
|
364
|
+
Message: JSON.stringify(messageObject),
|
|
365
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
366
|
+
TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete)
|
|
367
|
+
}
|
|
368
|
+
_izContext.logger.debug("send Message to outCreateRelationshipComplete :::", sendMessageToOutDeleteRelComplete);
|
|
369
|
+
await sns.publishAsync(_izContext, sendMessageToOutDeleteRelComplete);
|
|
370
|
+
}
|
|
321
371
|
}
|
|
322
372
|
|
|
323
373
|
return {
|
|
@@ -111,6 +111,33 @@ const deleteCompleteImports = {
|
|
|
111
111
|
snsOut: require('./delete/complete/sns-out/data')
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
+
const getActionImports = {
|
|
115
|
+
mainFunction: require('./get/action/mainFunction/data'),
|
|
116
|
+
functionYaml: {
|
|
117
|
+
api: require('./get/action/functionYaml/api/data'),
|
|
118
|
+
dsq: require('./get/action/functionYaml/dsq/data'),
|
|
119
|
+
inv: require('./get/action/functionYaml/inv/data'),
|
|
120
|
+
sqs: require('./get/action/functionYaml/sqs/data')
|
|
121
|
+
},
|
|
122
|
+
handler: {
|
|
123
|
+
api: require('./get/action/handler/api/data'),
|
|
124
|
+
inv: require('./get/action/handler/inv/data'),
|
|
125
|
+
dsq: require('./get/action/handler/dsq/data'),
|
|
126
|
+
sqs: require('./get/action/handler/sqs/data')
|
|
127
|
+
},
|
|
128
|
+
snsInSqs: require('./get/action/sns-in-sqs/data')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const getCompleteImports = {
|
|
132
|
+
mainFunction: require('./get/complete/mainFunction/data'),
|
|
133
|
+
functionYaml: require('./get/complete/functionYaml/data'),
|
|
134
|
+
handler: {
|
|
135
|
+
sqs: require('./get/complete/handler/sqs/data')
|
|
136
|
+
},
|
|
137
|
+
snsInSqs: require('./get/complete/sns-in-sqs/data'),
|
|
138
|
+
snsOut: require('./get/complete/sns-out/data')
|
|
139
|
+
}
|
|
140
|
+
|
|
114
141
|
/**
|
|
115
142
|
* Generates code from templates based on object schemas
|
|
116
143
|
* @param {Object} _izContext - Context object
|
|
@@ -121,9 +148,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
121
148
|
try {
|
|
122
149
|
const saveFilePath = join(objSchemaPath, '../');
|
|
123
150
|
let createSourceParams = [];
|
|
124
|
-
console.log('objSchemaPath', objSchemaPath);
|
|
151
|
+
// console.log('objSchemaPath', objSchemaPath);
|
|
125
152
|
const allObjectRelationships = getAllLocalRelationshipSchema(_izContext, objSchemaPath);
|
|
126
|
-
console.log('allObjectRelationships', allObjectRelationships);
|
|
153
|
+
// console.log('allObjectRelationships', JSON.stringify(allObjectRelationships));
|
|
127
154
|
|
|
128
155
|
// Check if the table yaml is valid
|
|
129
156
|
if (!allObjectRelationships.length) {
|
|
@@ -134,7 +161,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
134
161
|
const updateMainFunction = updateActionImports.mainFunction(_izContext, saveFilePath);
|
|
135
162
|
const updateCompleteMainFunction = updateCompleteImports.mainFunction(_izContext, saveFilePath);
|
|
136
163
|
|
|
137
|
-
const updateFunctionYaml = Object.values(updateActionImports.functionYaml).map(fn => fn(_izContext, saveFilePath)).flat();
|
|
164
|
+
const updateFunctionYaml = Object.values(updateActionImports.functionYaml).map(fn => fn(_izContext, allObjectRelationships, saveFilePath)).flat();
|
|
138
165
|
const updateCompleteYaml = updateCompleteImports.functionYaml(_izContext, saveFilePath);
|
|
139
166
|
|
|
140
167
|
const updateHandlers = Object.values(updateActionImports.handler).map(fn => fn(_izContext, saveFilePath)).flat();
|
|
@@ -148,7 +175,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
148
175
|
const createMainFunction = createActionImports.mainFunction(_izContext, saveFilePath);
|
|
149
176
|
const createCompleteMainFunction = createCompleteImports.mainFunction(_izContext, saveFilePath);
|
|
150
177
|
|
|
151
|
-
const createFunctionYaml = Object.values(createActionImports.functionYaml).map(fn => fn(_izContext, saveFilePath)).flat();
|
|
178
|
+
const createFunctionYaml = Object.values(createActionImports.functionYaml).map(fn => fn(_izContext, allObjectRelationships, saveFilePath)).flat();
|
|
152
179
|
const createCompleteYaml = createCompleteImports.functionYaml(_izContext, saveFilePath);
|
|
153
180
|
|
|
154
181
|
const createHandlers = Object.values(createActionImports.handler).map(fn => fn(_izContext, saveFilePath)).flat();
|
|
@@ -162,7 +189,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
162
189
|
const deleteMainFunction = deleteActionImports.mainFunction(_izContext, saveFilePath);
|
|
163
190
|
const deleteCompleteMainFunction = deleteCompleteImports.mainFunction(_izContext, saveFilePath);
|
|
164
191
|
|
|
165
|
-
const deleteFunctionYaml = Object.values(deleteActionImports.functionYaml).map(fn => fn(_izContext, saveFilePath)).flat();
|
|
192
|
+
const deleteFunctionYaml = Object.values(deleteActionImports.functionYaml).map(fn => fn(_izContext, allObjectRelationships, saveFilePath)).flat();
|
|
166
193
|
const deleteCompleteYaml = deleteCompleteImports.functionYaml(_izContext, saveFilePath);
|
|
167
194
|
|
|
168
195
|
const deleteHandlers = Object.values(deleteActionImports.handler).map(fn => fn(_izContext, saveFilePath)).flat();
|
|
@@ -172,6 +199,19 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
172
199
|
const deleteCompleteSnsInSqs = deleteCompleteImports.snsInSqs(_izContext, saveFilePath);
|
|
173
200
|
const deleteCompleteSnsOut = deleteCompleteImports.snsOut(_izContext, saveFilePath);
|
|
174
201
|
|
|
202
|
+
// Generate get relationship data
|
|
203
|
+
const getMainFunction = getActionImports.mainFunction(_izContext, saveFilePath);
|
|
204
|
+
const getCompleteMainFunction = getCompleteImports.mainFunction(_izContext, saveFilePath);
|
|
205
|
+
|
|
206
|
+
const getFunctionYaml = Object.values(getActionImports.functionYaml).map(fn => fn(_izContext, allObjectRelationships, saveFilePath)).flat();
|
|
207
|
+
const getCompleteYaml = getCompleteImports.handler.sqs(_izContext, saveFilePath);
|
|
208
|
+
|
|
209
|
+
const getHandlers = Object.values(getActionImports.handler).map(fn => fn(_izContext, saveFilePath)).flat();
|
|
210
|
+
const getCompleteHandler = getCompleteImports.handler.sqs(_izContext, saveFilePath);
|
|
211
|
+
|
|
212
|
+
const getSnsInSqs = getActionImports.snsInSqs(_izContext, saveFilePath);
|
|
213
|
+
const getCompleteSnsInSqs = getCompleteImports.snsInSqs(_izContext, saveFilePath);
|
|
214
|
+
const getCompleteSnsOut = getCompleteImports.snsOut(_izContext, saveFilePath);
|
|
175
215
|
// Combine all generated data
|
|
176
216
|
const updateRelationshipData = [
|
|
177
217
|
...updateHandlers,
|
|
@@ -218,6 +258,20 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
218
258
|
...deleteCompleteSnsOut
|
|
219
259
|
];
|
|
220
260
|
|
|
261
|
+
const getRelationshipData = [
|
|
262
|
+
...getMainFunction,
|
|
263
|
+
...getHandlers,
|
|
264
|
+
...getFunctionYaml,
|
|
265
|
+
...getSnsInSqs
|
|
266
|
+
];
|
|
267
|
+
|
|
268
|
+
const getRelationshipCompleteData = [
|
|
269
|
+
...getCompleteYaml,
|
|
270
|
+
...getCompleteHandler,
|
|
271
|
+
...getCompleteMainFunction,
|
|
272
|
+
...getCompleteSnsInSqs,
|
|
273
|
+
...getCompleteSnsOut
|
|
274
|
+
];
|
|
221
275
|
// Combine all data sets
|
|
222
276
|
createSourceParams.push(
|
|
223
277
|
...updateRelationshipData,
|
|
@@ -225,7 +279,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
225
279
|
...createRelationshipData,
|
|
226
280
|
...createRelationshipCompleteData,
|
|
227
281
|
...deleteRelationshipData,
|
|
228
|
-
...deleteRelationshipCompleteData
|
|
282
|
+
...deleteRelationshipCompleteData,
|
|
283
|
+
...getRelationshipData,
|
|
284
|
+
...getRelationshipCompleteData
|
|
229
285
|
);
|
|
230
286
|
|
|
231
287
|
return createSourceParams;
|
package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
|
|
21
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
22
|
+
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
|
|
24
|
+
const {
|
|
25
|
+
createIamRole,
|
|
26
|
+
resourceNames,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SOURCE_PATH,
|
|
29
|
+
SAVE_FILE_NAME,
|
|
30
|
+
FUNCTION_NAME,
|
|
31
|
+
SNS_RESOURCE,
|
|
32
|
+
defaultIamRolePerAction,
|
|
33
|
+
awaitingMultipleStepsRole,
|
|
34
|
+
shortNameHandler,
|
|
35
|
+
SHORT_FUNCTION_NAME,
|
|
36
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
37
|
+
checkDynamoTypeRelationship,
|
|
38
|
+
createDynamoDbComponentByLinks,
|
|
39
|
+
DYNAMO_RESOURCE
|
|
40
|
+
} = require("../../../../../../../MainLibs").consts;
|
|
41
|
+
|
|
42
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* receive objectSchema
|
|
46
|
+
* create data for updateRelationshipSchema
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} objectSchema
|
|
49
|
+
* @return {{ templatePath, templateData, setting } }
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
function data(_izContext, allObjectRelationships, srcPath) {
|
|
53
|
+
let createSourceArray = [];
|
|
54
|
+
|
|
55
|
+
const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
|
|
56
|
+
createSourceArray.push(createSourceParam);
|
|
57
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
58
|
+
return createSourceArray
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
63
|
+
|
|
64
|
+
let handlerType = HANDLER.hdrApi
|
|
65
|
+
let functionName = FUNCTION_NAME.getRel
|
|
66
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
67
|
+
|
|
68
|
+
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
69
|
+
|
|
70
|
+
additionalResourcePermission.push(
|
|
71
|
+
createIamRole(
|
|
72
|
+
{
|
|
73
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
74
|
+
},
|
|
75
|
+
[
|
|
76
|
+
resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.getRelComplete))
|
|
77
|
+
]
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
for (const relationship of allObjectRelationships) {
|
|
82
|
+
let [relationshipTag, links] = checkDynamoTypeRelationship(relationship)
|
|
83
|
+
for (const link of links) {
|
|
84
|
+
let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
|
|
85
|
+
additionalResourcePermission.push(
|
|
86
|
+
createIamRole(
|
|
87
|
+
{
|
|
88
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.updateItem]
|
|
89
|
+
},
|
|
90
|
+
[
|
|
91
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameFrom)),
|
|
92
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameTo))
|
|
93
|
+
]
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
templatePath: templatePath,
|
|
101
|
+
templateData: {
|
|
102
|
+
functionName,
|
|
103
|
+
handlerType,
|
|
104
|
+
additionalResourcePermission,
|
|
105
|
+
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
106
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.getRel) + upperCase(shortNameHandler(handlerType)),
|
|
107
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
108
|
+
},
|
|
109
|
+
setting: {
|
|
110
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
111
|
+
saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
|
|
112
|
+
fileExtension: '.yml',
|
|
113
|
+
isAppend: true
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = data;
|
package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/template.ejs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- http:
|
|
7
|
+
path: <%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
method: put
|
|
9
|
+
cors: true
|
|
10
|
+
#<#Authorizer#>
|
|
11
|
+
#<#/Authorizer#>
|
|
12
|
+
role: <%- roleName %>Role
|
|
13
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
14
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
15
|
+
<%_ function firstLetterUpperCase(text){
|
|
16
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
17
|
+
} _%>
|
|
18
|
+
<%_ function firstLetterLowerCase(str) {
|
|
19
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
20
|
+
} _%>
|
package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
|
|
21
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
|
|
24
|
+
const {
|
|
25
|
+
createIamRole,
|
|
26
|
+
resourceNames,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SQS_RESOURCE,
|
|
29
|
+
SOURCE_PATH,
|
|
30
|
+
SAVE_FILE_NAME,
|
|
31
|
+
FUNCTION_NAME,
|
|
32
|
+
SNS_RESOURCE,
|
|
33
|
+
defaultIamRolePerAction,
|
|
34
|
+
awaitingMultipleStepsRole,
|
|
35
|
+
shortNameHandler,
|
|
36
|
+
SHORT_FUNCTION_NAME,
|
|
37
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
38
|
+
checkDynamoTypeRelationship,
|
|
39
|
+
createDynamoDbComponentByLinks,
|
|
40
|
+
DYNAMO_RESOURCE
|
|
41
|
+
} = require("../../../../../../../MainLibs/index.js").consts;
|
|
42
|
+
|
|
43
|
+
const templatePath = path.join(__dirname, './template.ejs')
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* receive objectSchema
|
|
47
|
+
* create data for updateRelationshipSchema
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} objectSchema
|
|
50
|
+
* @return {{ templatePath, templateData, setting } }
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
function data(_izContext, allObjectRelationships, srcPath) {
|
|
54
|
+
let createSourceArray = [];
|
|
55
|
+
|
|
56
|
+
const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
|
|
57
|
+
createSourceArray.push(createSourceParam);
|
|
58
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
59
|
+
return createSourceArray
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
64
|
+
|
|
65
|
+
let handlerType = HANDLER.hdrDsq
|
|
66
|
+
let functionName = FUNCTION_NAME.getRel
|
|
67
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
68
|
+
|
|
69
|
+
additionalResourcePermission.push(
|
|
70
|
+
// createIamRole(
|
|
71
|
+
// { [RESOURCE_CLASSES.lambda]: ["InvokeFunction"] },
|
|
72
|
+
// [resourceNames(RESOURCE_CLASSES.lambda, "*GetNodeHdrInv")]),
|
|
73
|
+
createIamRole(
|
|
74
|
+
{
|
|
75
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
76
|
+
SQS_RESOURCE.deleteMessage,
|
|
77
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
78
|
+
SQS_RESOURCE.receiveMessage,
|
|
79
|
+
SQS_RESOURCE.sendMessage,
|
|
80
|
+
SQS_RESOURCE.deleteMessageBatch,
|
|
81
|
+
SQS_RESOURCE.getQueueUrl
|
|
82
|
+
],
|
|
83
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
84
|
+
},
|
|
85
|
+
[
|
|
86
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq)),
|
|
87
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq) + "DLQ"),
|
|
88
|
+
resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.getRelComplete)),
|
|
89
|
+
]
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
94
|
+
|
|
95
|
+
for (const relationship of allObjectRelationships) {
|
|
96
|
+
let [relationshipTag, links] = checkDynamoTypeRelationship(relationship)
|
|
97
|
+
for (const link of links) {
|
|
98
|
+
let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
|
|
99
|
+
additionalResourcePermission.push(
|
|
100
|
+
createIamRole(
|
|
101
|
+
{
|
|
102
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.updateItem]
|
|
103
|
+
},
|
|
104
|
+
[
|
|
105
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameFrom)),
|
|
106
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameTo))
|
|
107
|
+
]
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
templatePath: templatePath,
|
|
114
|
+
templateData: {
|
|
115
|
+
functionName,
|
|
116
|
+
handlerType,
|
|
117
|
+
additionalResourcePermission,
|
|
118
|
+
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
119
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.getRel) + upperCase(shortNameHandler(handlerType)),
|
|
120
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
121
|
+
},
|
|
122
|
+
setting: {
|
|
123
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
124
|
+
saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
|
|
125
|
+
fileExtension: '.yml',
|
|
126
|
+
isAppend: true
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = data;
|
package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/template.ejs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
role: <%- roleName %>Role
|
|
10
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
11
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
12
|
+
<%_ function firstLetterUpperCase(text){
|
|
13
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
14
|
+
} _%>
|
|
15
|
+
<%_ function firstLetterLowerCase(str) {
|
|
16
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
17
|
+
} _%>
|
package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
|
|
21
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
|
|
24
|
+
const {
|
|
25
|
+
createIamRole,
|
|
26
|
+
resourceNames,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SOURCE_PATH,
|
|
29
|
+
SAVE_FILE_NAME,
|
|
30
|
+
FUNCTION_NAME,
|
|
31
|
+
SNS_RESOURCE,
|
|
32
|
+
defaultIamRolePerAction,
|
|
33
|
+
awaitingMultipleStepsRole,
|
|
34
|
+
shortNameHandler,
|
|
35
|
+
SHORT_FUNCTION_NAME,
|
|
36
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
37
|
+
checkDynamoTypeRelationship,
|
|
38
|
+
createDynamoDbComponentByLinks,
|
|
39
|
+
DYNAMO_RESOURCE
|
|
40
|
+
} = require("../../../../../../../MainLibs/index.js").consts;
|
|
41
|
+
|
|
42
|
+
const templatePath = path.join(__dirname, './template.ejs')
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* receive objectSchema
|
|
46
|
+
* create data for updateRelationshipSchema
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} objectSchema
|
|
49
|
+
* @return {{ templatePath, templateData, setting } }
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
function data(_izContext, allObjectRelationships, srcPath) {
|
|
53
|
+
let createSourceArray = [];
|
|
54
|
+
|
|
55
|
+
const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
|
|
56
|
+
createSourceArray.push(createSourceParam);
|
|
57
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
58
|
+
return createSourceArray
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
63
|
+
|
|
64
|
+
let handlerType = HANDLER.hdrInv
|
|
65
|
+
let functionName = FUNCTION_NAME.getRel
|
|
66
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
67
|
+
|
|
68
|
+
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
69
|
+
|
|
70
|
+
additionalResourcePermission.push(
|
|
71
|
+
createIamRole({
|
|
72
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
73
|
+
},
|
|
74
|
+
[
|
|
75
|
+
resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.getRelComplete)),
|
|
76
|
+
]
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
for (const relationship of allObjectRelationships) {
|
|
81
|
+
let [relationshipTag, links] = checkDynamoTypeRelationship(relationship)
|
|
82
|
+
for (const link of links) {
|
|
83
|
+
let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
|
|
84
|
+
additionalResourcePermission.push(
|
|
85
|
+
createIamRole(
|
|
86
|
+
{
|
|
87
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.updateItem]
|
|
88
|
+
},
|
|
89
|
+
[
|
|
90
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameFrom)),
|
|
91
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameTo))
|
|
92
|
+
]
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
templatePath: templatePath,
|
|
100
|
+
templateData: {
|
|
101
|
+
functionName,
|
|
102
|
+
handlerType,
|
|
103
|
+
additionalResourcePermission,
|
|
104
|
+
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
105
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.getRel) + upperCase(shortNameHandler(handlerType)),
|
|
106
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
107
|
+
},
|
|
108
|
+
setting: {
|
|
109
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
110
|
+
saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
|
|
111
|
+
fileExtension: '.yml',
|
|
112
|
+
isAppend: true
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
module.exports = data;
|
package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/template.ejs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
role: <%- roleName %>Role
|
|
6
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
7
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
8
|
+
<%_ function firstLetterUpperCase(text){
|
|
9
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
10
|
+
} _%>
|
|
11
|
+
<%_ function firstLetterLowerCase(str) {
|
|
12
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
13
|
+
} _%>
|