@izara_project/izara-market-library-service-schemas 1.0.3 → 1.0.4
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 +5 -5
- package/src/GenerateCodeLibs/src/Consts.js +40 -0
- package/src/TemplateManager/src/FunctionYaml/HdrApi/data.js +4 -4
- package/src/TemplateManager/src/FunctionYaml/HdrDsq/data.js +7 -5
- package/src/TemplateManager/src/FunctionYaml/HdrInv/data.js +3 -3
- package/src/TemplateManager/src/FunctionYaml/HdrSqs/data.js +11 -13
- package/src/TemplateManager/src/FunctionYaml/HdrSqs/template.ejs +1 -1
- package/src/TemplateManager/src/GenerateCode.js +117 -29
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +1 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/awaitingMultipleStepData.js +98 -0
- package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +7 -7
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +4 -3
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +4 -4
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +4 -4
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/sqsTemplate.ejs +1 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +89 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/request.json +3 -0
- package/src/TemplateManager/src/ResourceYaml/sns-out/template.ejs +10 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +151 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +76 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/template.ejs +127 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +55 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/request.json +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +140 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +75 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +45 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +70 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +127 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/template.ejs +33 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +148 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +125 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +148 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +80 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/request.json +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +324 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +72 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +120 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +73 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +167 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +73 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/request.json +5 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +126 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +73 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/request.json +7 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +31 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +91 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/request.json +3 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +70 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/request.json +3 -0
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +56 -10
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +6 -2
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +67 -2
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/request.json +12 -0
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +10 -14
- package/src/TemplateManager/src/libs/Consts.js +16 -25
- package/src/TemplateManager/src/MainResourcesYaml/CreateSourceData.js +0 -76
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Data/MainDynamoDbYamlData.js +0 -155
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs +0 -31
- package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.exampleData.js +0 -12
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// topicName: "OutCreateNode", // sns of external service
|
|
12
|
-
// sqsEndpoint: "AucCreateCompleteHdrSqs" // sqs inside this service
|
|
13
|
-
// },
|
|
14
|
-
]
|
|
1
|
+
module.exports.generatedSnsTopicSubscription = [ <% datas.forEach(data => { -%>
|
|
2
|
+
<% data.serviceNames.forEach(serviceName => { _%>
|
|
3
|
+
{
|
|
4
|
+
serviceName: "<%- serviceName %>",
|
|
5
|
+
topicName: "<%- data.topicName %>",
|
|
6
|
+
sqsEndpoint: "<%- data.sqsEndpoint %>"
|
|
7
|
+
},
|
|
8
|
+
<% }) _%>
|
|
9
|
+
<% }) _%>
|
|
10
|
+
]
|
|
@@ -73,11 +73,13 @@ function createIamRole(action, resource = [], effect = "Allow") {
|
|
|
73
73
|
const SOURCE_PATH = {
|
|
74
74
|
appYaml: `../sls_yaml/generatedCode/source/`,
|
|
75
75
|
resourceYaml: `../../resource/sls_yaml/generatedCode/source/`,
|
|
76
|
-
lambdaPerObjectTypePath: `/generatedCode/lambdaPerObjectType/source/`,
|
|
77
|
-
lamdaPerCombindActionPath: `/generatedCode/lamdaPerCombindAction/source/`,
|
|
76
|
+
lambdaPerObjectTypePath: `/generatedCode/lambdaPerObjectType/source/`, // test
|
|
77
|
+
lamdaPerCombindActionPath: `/generatedCode/lamdaPerCombindAction/source/`, // test
|
|
78
78
|
externalService: '../initial_setup/generatedCode/source/',
|
|
79
|
-
lambdaPerAction: '../src
|
|
80
|
-
|
|
79
|
+
lambdaPerAction: '../src/generatedCode/ObjectTypePerActionEndpoint/source/',
|
|
80
|
+
updateRelationshipSchema: '../src/generatedCode/RelationshipPerAction/source/',
|
|
81
|
+
resourceLocationPerAction: 'src/generatedCode/ObjectTypePerActionEndpoint/source/',
|
|
82
|
+
resourceLocationUpdateRelationshipSchema: 'src/generatedCode/RelationshipPerAction/source/',
|
|
81
83
|
};
|
|
82
84
|
|
|
83
85
|
|
|
@@ -102,35 +104,24 @@ const DEFAULT_LAMBDA_ROLE_PER_ACTION = {
|
|
|
102
104
|
|
|
103
105
|
const SQS_RESOURCE = {
|
|
104
106
|
sendMessage: "SendMessage",
|
|
105
|
-
|
|
107
|
+
receiveMessage: "ReceiveMessage",
|
|
106
108
|
deleteMessage: "DeleteMessage",
|
|
107
|
-
getQueueAttributes: "GetQueueAttributes"
|
|
109
|
+
getQueueAttributes: "GetQueueAttributes",
|
|
110
|
+
deleteMessageBatch: "DeleteMessageBatch",
|
|
111
|
+
getQueueUrl: "GetQueueUrl"
|
|
108
112
|
}
|
|
109
113
|
|
|
110
|
-
function externalResourceName(resourceClass, functionName,
|
|
114
|
+
function externalResourceName(resourceClass, functionName, serviceTag) {
|
|
111
115
|
return {
|
|
112
|
-
[RESOURCE_CLASSES.dynamoDbTable]: "arn:aws:dynamodb:${process.env.iz_region}:${process.env.iz_accountId}:table/${dynamoSharedLib.tableName(" + `"${functionName}" ,"${
|
|
113
|
-
[RESOURCE_CLASSES.lambda]: "arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(" + `"${functionName}" ,"${
|
|
114
|
-
[RESOURCE_CLASSES.sns]: `snsSharedLib.snsTopicArn("${functionName}" , "${serviceName}")`,
|
|
116
|
+
[RESOURCE_CLASSES.dynamoDbTable]: "arn:aws:dynamodb:${process.env.iz_region}:${process.env.iz_accountId}:table/${await dynamoSharedLib.tableName(_izContext, " + `"${functionName}" ,"${serviceTag}")}`,
|
|
117
|
+
[RESOURCE_CLASSES.lambda]: "arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${await lambdaSharedLib.lambdaFunctionName(_izContext, " + `"${functionName}" ,"${serviceTag}")}`,
|
|
115
118
|
}[resourceClass]
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
[ACTIONS.update]: "InCreateVersionedData",
|
|
121
|
-
[ACTIONS.get]: "GetNodeHdrInv",
|
|
121
|
+
function externalResourceSns(functionName, serviceTag) {
|
|
122
|
+
return "arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${await snsSharedLib.snsTopicName(_izContext, " + `"${functionName}", "${serviceTag}")}`
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
const DEFAULT_EXTERNAL_IAM_ROLE_PER_ACTION = {
|
|
125
|
-
[ACTIONS.create]: "InCreateNode",
|
|
126
|
-
[ACTIONS.update]: "InCreateVersionedData",
|
|
127
|
-
[ACTIONS.get]: {
|
|
128
|
-
[RESOURCE_CLASSES.lambda]: ["GetNodeHdrInv"],
|
|
129
|
-
},
|
|
130
|
-
[ACTIONS.delete]: "GetNodeHdrInv",
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
125
|
module.exports = {
|
|
135
126
|
ACTIONS,
|
|
136
127
|
DEFAULT_HANDLER_PER_ACTION,
|
|
@@ -142,5 +133,5 @@ module.exports = {
|
|
|
142
133
|
SQS_RESOURCE,
|
|
143
134
|
HANDLER,
|
|
144
135
|
externalResourceName,
|
|
145
|
-
|
|
136
|
+
externalResourceSns
|
|
146
137
|
}
|
|
@@ -1,76 +0,0 @@
|
|
|
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 path = require('path');
|
|
21
|
-
|
|
22
|
-
const schemaConsts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// const lambdaYaml = require("./Template/Resource/Lambda/LambdaYamlTemplateData");
|
|
27
|
-
|
|
28
|
-
const config = require('../libs/Consts')
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const dynamoDbMainYaml = require("./TemplateAndData/DynamoDbMain/Data/MainDynamoDbYamlData")
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @param {Object} _izContext
|
|
35
|
-
* @param {Object} objectSchema
|
|
36
|
-
*/
|
|
37
|
-
module.exports.createSourceDataObjectSchema = (_izContext, objectSchema, saveFilePath) => {
|
|
38
|
-
|
|
39
|
-
let resultsForCreateSource = [];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const dynamoDbMainYamlDataList = dynamoDbMainYaml.dynamoDbMainYamlFromObjectSchema.templateDataFunction(_izContext, objectSchema);
|
|
43
|
-
// console.log("dynamoDbMainYamlDataList: ", dynamoDbMainYamlDataList);
|
|
44
|
-
|
|
45
|
-
for (let dynamoDbMainYamlData of dynamoDbMainYamlDataList) {
|
|
46
|
-
// create iam role of handler here
|
|
47
|
-
resultsForCreateSource.push({
|
|
48
|
-
templatePath: dynamoDbMainYaml.dynamoDbMainYamlFromObjectSchema.templatePath,
|
|
49
|
-
templateData: dynamoDbMainYamlData,
|
|
50
|
-
setting: {
|
|
51
|
-
initialData: 'Resources:\n',
|
|
52
|
-
savePath: path.join(saveFilePath, config.SOURCE_PATH.resourceYaml),
|
|
53
|
-
saveFileName: 'generate-dynamodb-table',
|
|
54
|
-
fileExtension: '.yml',
|
|
55
|
-
isAppend: true
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// console.log("resultsForCreateSource: ", resultsForCreateSource);
|
|
61
|
-
|
|
62
|
-
return resultsForCreateSource;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
* @param {Object} _izContext
|
|
69
|
-
* @param {Object} relSchema
|
|
70
|
-
* @param {String} saveFilePath
|
|
71
|
-
* @returns
|
|
72
|
-
*/
|
|
73
|
-
module.exports.createSourceDataRelSchema = (_izContext, relSchema, saveFilePath) => {
|
|
74
|
-
|
|
75
|
-
return []
|
|
76
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
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 path = require("path")
|
|
21
|
-
|
|
22
|
-
// const {
|
|
23
|
-
// HANDLER,
|
|
24
|
-
// STORAGE_TYPES
|
|
25
|
-
// } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const STORAGE_TYPES = {
|
|
29
|
-
dynamoDB: "dynamoDB",
|
|
30
|
-
graph: "graph"
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// ---------- End Per Lambda Handler IamRole Data ----------
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* create data for dynamoDbYaml tempalte from objectSchema
|
|
40
|
-
* return array of dynamoDb data
|
|
41
|
-
* because one objectSchema can create multiple dynamoDb table
|
|
42
|
-
*
|
|
43
|
-
* @param {Object} _izContext
|
|
44
|
-
* @param {Object} objectSchema
|
|
45
|
-
* @returns {Object[]} - data of multiple dynamoDb template
|
|
46
|
-
*/
|
|
47
|
-
function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema) {
|
|
48
|
-
let dynamoDbYamlTemplateData = [];
|
|
49
|
-
|
|
50
|
-
// store detail for create dynamoDb table
|
|
51
|
-
let identifiersDetail = {};
|
|
52
|
-
|
|
53
|
-
// add identifiersDetail for dynamoDb storage
|
|
54
|
-
for (let identifier of objectSchema.identifiers) {
|
|
55
|
-
// console.log("in identifiers")
|
|
56
|
-
if (identifier.type === "partitionKey" || identifier.type === "sortKey") {
|
|
57
|
-
identifiersDetail[identifier.type] = {};
|
|
58
|
-
|
|
59
|
-
if (identifier.name) {
|
|
60
|
-
Object.assign(
|
|
61
|
-
identifiersDetail[identifier.type],
|
|
62
|
-
{
|
|
63
|
-
AttributeName: identifier.name,
|
|
64
|
-
AttributeType: "S"
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
} else {
|
|
68
|
-
let fieldNameType = objectSchema.fieldNames[identifier.fieldName].type;
|
|
69
|
-
let attributeType;
|
|
70
|
-
|
|
71
|
-
if (fieldNameType === "string") {
|
|
72
|
-
attributeType = "S"
|
|
73
|
-
} else if (fieldNameType === "number") {
|
|
74
|
-
attributeType = "N"
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
Object.assign(
|
|
78
|
-
identifiersDetail[identifier.type],
|
|
79
|
-
{
|
|
80
|
-
AttributeName: identifier.fieldName,
|
|
81
|
-
AttributeType: attributeType
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// console.log("identifiersDetail: ", identifiersDetail)
|
|
88
|
-
if (!identifiersDetail.hasOwnProperty("partitionKey")) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// start create dynamoDb template data
|
|
94
|
-
for (let storageResource of Object.values(objectSchema.storageResources)) {
|
|
95
|
-
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
96
|
-
let templateData = {
|
|
97
|
-
tableName: storageResource.tableName,
|
|
98
|
-
attributes: []
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (storageResource.hasOwnProperty("groupByPartitionKeyField")) {
|
|
103
|
-
templateData.attributes.push(
|
|
104
|
-
{
|
|
105
|
-
keyType: "partitionKey",
|
|
106
|
-
AttributeName: storageResource.groupByPartitionKeyField,
|
|
107
|
-
AttributeType: "S"
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
} else {
|
|
111
|
-
for (let identifierType in identifiersDetail) {
|
|
112
|
-
templateData.attributes.push(
|
|
113
|
-
{
|
|
114
|
-
keyType: identifierType,
|
|
115
|
-
AttributeName: identifiersDetail[identifierType].AttributeName,
|
|
116
|
-
AttributeType: identifiersDetail[identifierType].AttributeType
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
dynamoDbYamlTemplateData.push(templateData);
|
|
122
|
-
// console.log("templateData: ", templateData)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return dynamoDbYamlTemplateData
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// return array of table data
|
|
131
|
-
// because one relSchema can create multiple dynamoDb table
|
|
132
|
-
function dataForMainDynamoDbYamlFromRelSchema(_izContext, relSchema) {
|
|
133
|
-
let relTag = Object.keys(relSchema)[0];
|
|
134
|
-
let relData = relSchema[relTag];
|
|
135
|
-
|
|
136
|
-
for (let parents of relData.parents) {
|
|
137
|
-
let parentObjectType = parent.objType.objectType;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
module.exports = {
|
|
147
|
-
dynamoDbMainYamlFromObjectSchema: {
|
|
148
|
-
templatePath: path.join(__dirname, '../Template/DynamoDb.ejs'),
|
|
149
|
-
templateDataFunction: dataForMainDynamoDbYamlFromObjectSchema
|
|
150
|
-
},
|
|
151
|
-
dynamoDbMainYamlFromRelSchema: {
|
|
152
|
-
templatePath: path.join(__dirname, '../Template/DynamoDb.ejs'),
|
|
153
|
-
templateDataFunction: dataForMainDynamoDbYamlFromRelSchema
|
|
154
|
-
},
|
|
155
|
-
}
|
package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<%- tableName %>Table:
|
|
2
|
-
Type: "AWS::DynamoDB::Table"
|
|
3
|
-
Properties:
|
|
4
|
-
TableName: ${self:custom.iz_resourcePrefix}<%- tableName %>
|
|
5
|
-
AttributeDefinitions:
|
|
6
|
-
<%_ attributes.forEach((attribute) => { -%>
|
|
7
|
-
- AttributeName: <%- attribute["AttributeName"] %>
|
|
8
|
-
AttributeType: <%- attribute["AttributeType"] %>
|
|
9
|
-
<%_ }) _%>
|
|
10
|
-
KeySchema:
|
|
11
|
-
<%_ attributes.forEach((attribute) => { -%>
|
|
12
|
-
<%_ if(attribute.keyType === 'partitionKey') { -%>
|
|
13
|
-
- AttributeName: <%- attribute["AttributeName"] %>
|
|
14
|
-
KeyType: HASH
|
|
15
|
-
<%_ } -%>
|
|
16
|
-
<%_ if(attribute.keyType === 'sortKey') { -%>
|
|
17
|
-
- AttributeName: <%- attribute["AttributeName"] %>
|
|
18
|
-
KeyType: RANGE
|
|
19
|
-
<%_ } -%>
|
|
20
|
-
<%_ }) _%>
|
|
21
|
-
ProvisionedThroughput:
|
|
22
|
-
ReadCapacityUnits: 1
|
|
23
|
-
WriteCapacityUnits: 1
|
|
24
|
-
#<#<%- firstLetterUpperCase(tableName) %>DynamoDbSetting#>
|
|
25
|
-
#<#/<%- firstLetterUpperCase(tableName) %>DynamoDbSetting#>
|
|
26
|
-
<%_ function firstLetterUpperCase(text){
|
|
27
|
-
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
28
|
-
} _%>
|
|
29
|
-
<%_ function firstLetterLowerCase(str) {
|
|
30
|
-
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
31
|
-
} _%>
|