@izara_project/izara-market-library-service-schemas 1.0.33 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/GenerateCodeLibs/src/Consts.js +2 -1
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +20 -6
- package/src/MainLibs/src/Consts.js +43 -10
- package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +1 -1
- package/src/reStructure/GenerateCode.js +1 -0
- package/src/reStructure/SchemaConfig.js +1 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +3 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +28 -44
- package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/attributeLinkTemplate.ejs +3 -7
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTree/data.js +134 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/data.js +172 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/template.ejs +7 -0
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +123 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/data.js +57 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/template.ejs +85 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +68 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +96 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/data.js +77 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/template.ejs +49 -0
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +138 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/template.ejs +83 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +133 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +64 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +12 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +27 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +34 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +76 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +13 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +142 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +18 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/data.js +64 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +89 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +120 -0
- package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +26 -59
- package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +8 -8
- package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +11 -9
- package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +3 -6
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +7 -9
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +8 -43
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +1 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +7 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +18 -7
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +7 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +52 -13
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +18 -18
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +67 -6
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +20 -0
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +3 -3
- package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +9 -3
- package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +9 -3
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +10 -4
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +9 -3
- package/src/reStructure/TemplateData/propertyNodeSchema/generateTemplateData.js +66 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +151 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs +16 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/data.js +179 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +7 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +5 -5
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +5 -5
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +1 -1
- package/src/reStructure/libs/ValidateAddOnDataStructure.js +62 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +0 -188
- /package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/request.json +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
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
|
+
console.log("=== property node schema ===");
|
|
21
|
+
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const {
|
|
25
|
+
SOURCE_PATH,
|
|
26
|
+
ADD_ON_DATA_STRUCTURE_TYPE,
|
|
27
|
+
ATTRIBUTE_TAG,
|
|
28
|
+
fieldNameSetting,
|
|
29
|
+
FIELD_NAME_TPYE,
|
|
30
|
+
PROPERTYNODE_TAG,
|
|
31
|
+
SAVE_FILE_NAME
|
|
32
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts');
|
|
33
|
+
|
|
34
|
+
const templatePath = path.join(__dirname, "./templateObjectPropertyNodeSchema.ejs");
|
|
35
|
+
|
|
36
|
+
const modules = {
|
|
37
|
+
validateAddOnDataStructure: require('../../../libs/ValidateAddOnDataStructure')
|
|
38
|
+
};
|
|
39
|
+
const yaml = require("yaml")
|
|
40
|
+
const objectschemaLocalByPath = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
41
|
+
const Consts = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts')
|
|
42
|
+
// const objectSchemasBySrc = srcPath
|
|
43
|
+
async function data(_izContext, settings, srcPath) {
|
|
44
|
+
|
|
45
|
+
const configPath = path.join(srcPath, '../../config/serverless.config.yml');
|
|
46
|
+
const serverlessConfig = fs.readFileSync(configPath, 'utf8');
|
|
47
|
+
const config = yaml.parse(serverlessConfig);
|
|
48
|
+
const serviceTag = config.main_config.iz_serviceTag;
|
|
49
|
+
const objectSchemaPath = path.join(srcPath, "schemas")
|
|
50
|
+
// /home/dogsrcute/Programming mint/BackEnd-Service/workspace_by_work/attributee/empty-education/app/src/
|
|
51
|
+
|
|
52
|
+
let allObjectSchemas = await objectschemaLocalByPath.getAllLocalObjectSchemas(
|
|
53
|
+
_izContext,
|
|
54
|
+
objectSchemaPath
|
|
55
|
+
);
|
|
56
|
+
_izContext.logger.debug("allObjectSchemas =>>", allObjectSchemas);
|
|
57
|
+
|
|
58
|
+
if (allObjectSchemas.records.length == 0) {
|
|
59
|
+
throw Error(`Invalid objType:${objTypeString(objType)}, cannot generate attribute tree schema cause objectSchema is not exists`)
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
let propertyNodeObjectSchemas = [];
|
|
64
|
+
let createSources = [];
|
|
65
|
+
|
|
66
|
+
for (const objectSchema of allObjectSchemas.records) {
|
|
67
|
+
|
|
68
|
+
let objectType = objectSchema.objectType;
|
|
69
|
+
|
|
70
|
+
// validate only addOnndataStructure is type propertyNode.
|
|
71
|
+
|
|
72
|
+
if (!objectSchema.hasOwnProperty("addOnDataStructure") || !Array.isArray(objectSchema.addOnDataStructure) || !objectSchema.addOnDataStructure.length) {
|
|
73
|
+
console.log(`Not have data in addOnDataStructure in objectType:${objectType} ,continute nextObjectSchema`);
|
|
74
|
+
continue;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
for (let eachAddOnDataStructure of objectSchema.addOnDataStructure) {
|
|
78
|
+
|
|
79
|
+
if (eachAddOnDataStructure.type !== Consts.ADD_ON_DATA_STRUCTURE_TYPE.propertyNode) {
|
|
80
|
+
console.log("continute, not type propertyNode next addOnDataStructure")
|
|
81
|
+
continue
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const storageResources = objectSchema.storageResources; // storageResource from main objectType
|
|
85
|
+
const storageResourceTag = Object.keys(storageResources); // storage ResourceTag from main objectType
|
|
86
|
+
const compositeKeyDeliminator = objectSchema.compositeKeyDeliminator;
|
|
87
|
+
|
|
88
|
+
propertyNodeObjectSchemas.push(
|
|
89
|
+
{ // {subject}property
|
|
90
|
+
objectType: objectType + PROPERTYNODE_TAG.property,
|
|
91
|
+
fieldNames: {
|
|
92
|
+
[objectType + PROPERTYNODE_TAG.property + "Id"]: fieldNameSetting(FIELD_NAME_TPYE.randomOnCreateFieldName),
|
|
93
|
+
},
|
|
94
|
+
identifiers: [
|
|
95
|
+
{
|
|
96
|
+
type: "identifier",
|
|
97
|
+
fieldName: objectType + PROPERTYNODE_TAG.property + "Id"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{ // {subject}propertyLabel
|
|
102
|
+
objectType: objectType + PROPERTYNODE_TAG.propertyLabel,
|
|
103
|
+
fieldNames: {
|
|
104
|
+
[objectType + PROPERTYNODE_TAG.propertyLabel + "Id"]: fieldNameSetting(FIELD_NAME_TPYE.randomOnCreateFieldName),
|
|
105
|
+
},
|
|
106
|
+
identifiers: [
|
|
107
|
+
{
|
|
108
|
+
type: "identifier",
|
|
109
|
+
fieldName: objectType + PROPERTYNODE_TAG.propertyLabel + "Id"
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
for (let propertyNodeObjectSchema of propertyNodeObjectSchemas) {
|
|
116
|
+
Object.assign(propertyNodeObjectSchema, {
|
|
117
|
+
storageResources: storageResources, // add storageResources
|
|
118
|
+
compositeKeyDeliminator: compositeKeyDeliminator
|
|
119
|
+
})
|
|
120
|
+
for (let attributeTreeFieldName of Object.values(propertyNodeObjectSchema.fieldNames)) {
|
|
121
|
+
Object.assign(attributeTreeFieldName, { storageResourceTags: storageResourceTag }) // add storageResourceTags for each fieldName
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
for (const propertyNodeObjectSchema of propertyNodeObjectSchemas) {
|
|
125
|
+
createSources.push({
|
|
126
|
+
templatePath: templatePath,
|
|
127
|
+
templateData: {
|
|
128
|
+
fieldNames: JSON.stringify(propertyNodeObjectSchema.fieldNames, null, 2),
|
|
129
|
+
identifiers: JSON.stringify(propertyNodeObjectSchema.identifiers, null, 2),
|
|
130
|
+
objectType: propertyNodeObjectSchema.objectType,
|
|
131
|
+
storageResources: JSON.stringify(propertyNodeObjectSchema.storageResources, null, 2),
|
|
132
|
+
compositeKeyDeliminator: propertyNodeObjectSchema.compositeKeyDeliminator
|
|
133
|
+
},
|
|
134
|
+
setting: {
|
|
135
|
+
savePath: path.join(srcPath, SOURCE_PATH.generatedPropertyNode, propertyNodeObjectSchema.objectType + "/"),
|
|
136
|
+
hookPath: path.join(srcPath, "schemaHook", "propertyNode", propertyNodeObjectSchema.objectType, "/"),
|
|
137
|
+
saveFileName: SAVE_FILE_NAME.objectSchema,
|
|
138
|
+
fileExtension: ".js",
|
|
139
|
+
isAppend: false
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
};//End loop addOn
|
|
146
|
+
}; //End loop objectSchema
|
|
147
|
+
|
|
148
|
+
return createSources;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
module.exports = data
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const izara = require("@izara_project/izara-middleware");
|
|
2
|
+
let { pattern } = izara.validatorSchema.stringNotEmpty(); // should not be empty string
|
|
3
|
+
|
|
4
|
+
module.exports = [
|
|
5
|
+
{
|
|
6
|
+
objectType: "<%- objectType %>",
|
|
7
|
+
addOnDataStructure: [ // optional, add for additional setting to objectType
|
|
8
|
+
//(<addOnDataStructure<%- objectType %>>)
|
|
9
|
+
//(</addOnDataStructure<%- objectType %>>)
|
|
10
|
+
],
|
|
11
|
+
canDelete: true,
|
|
12
|
+
storageResources: <%- storageResources %>,
|
|
13
|
+
fieldNames: <%- fieldNames %>,
|
|
14
|
+
identifiers: <%- identifiers %>
|
|
15
|
+
}
|
|
16
|
+
]
|
package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/data.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
console.log("=== relationship property node schema ===");
|
|
21
|
+
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const {
|
|
25
|
+
SOURCE_PATH,
|
|
26
|
+
PREFIX_RELATIONSHIP,
|
|
27
|
+
PROPERTYNODE_TAG,
|
|
28
|
+
SAVE_FILE_NAME
|
|
29
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts');
|
|
30
|
+
|
|
31
|
+
const templatePath = path.join(__dirname, "./templateRelationshipPropertyNodeSchema.ejs");
|
|
32
|
+
|
|
33
|
+
const yaml = require("yaml")
|
|
34
|
+
const objectschemaLocalByPath = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
35
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
36
|
+
const Consts = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts');
|
|
37
|
+
const { firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils");
|
|
38
|
+
const { createBasicRelationshipsProperties } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
39
|
+
|
|
40
|
+
async function data(_izContext, settings, srcPath) {
|
|
41
|
+
|
|
42
|
+
let objectSchemaPath = path.join(srcPath, "schemas")
|
|
43
|
+
let allObjectSchemas = await objectschemaLocalByPath.getAllLocalObjectSchemas(
|
|
44
|
+
_izContext,
|
|
45
|
+
objectSchemaPath
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
let createSourceRecords = [];
|
|
49
|
+
|
|
50
|
+
if (allObjectSchemas.records.length == 0) {
|
|
51
|
+
throw Error(`Invalid objType:${objTypeString(objType)}, cannot generate attribute tree schema cause objectSchema is not exists`)
|
|
52
|
+
};
|
|
53
|
+
nextObjectSchema:
|
|
54
|
+
for (const objectSchema of allObjectSchemas.records) {
|
|
55
|
+
|
|
56
|
+
// validate only addOnndataStructure is type propertyNode.
|
|
57
|
+
if (!objectSchema.hasOwnProperty("addOnDataStructure") || !Array.isArray(objectSchema.addOnDataStructure) || !objectSchema.addOnDataStructure.length) {
|
|
58
|
+
console.log("Not have data in addOnDataStructure ,continute nextObjectSchema")
|
|
59
|
+
continue
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
for (let eachAddOnDataStructure of objectSchema.addOnDataStructure) {
|
|
63
|
+
|
|
64
|
+
if (eachAddOnDataStructure.type !== Consts.ADD_ON_DATA_STRUCTURE_TYPE.propertyNode) {
|
|
65
|
+
console.log("continute,AddOnDataStructure not type propertyNode")
|
|
66
|
+
continue
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
let generateRelationships = createSourceParams(
|
|
70
|
+
_izContext,
|
|
71
|
+
objectSchema,
|
|
72
|
+
srcPath
|
|
73
|
+
);
|
|
74
|
+
console.log("generateRelationship", generateRelationships);
|
|
75
|
+
|
|
76
|
+
createSourceRecords.push(...generateRelationships);
|
|
77
|
+
|
|
78
|
+
};//End loop addOn
|
|
79
|
+
}; //End loop objectSchema
|
|
80
|
+
console.log("createSourceRecords: ", createSourceRecords);
|
|
81
|
+
|
|
82
|
+
if (createSourceRecords.length) {
|
|
83
|
+
return {
|
|
84
|
+
templatePath: templatePath,
|
|
85
|
+
templateData: {
|
|
86
|
+
datas: createSourceRecords
|
|
87
|
+
},
|
|
88
|
+
setting: {
|
|
89
|
+
savePath: path.join(srcPath, SOURCE_PATH.generatedPropertyNode),
|
|
90
|
+
hookPath: path.join(srcPath, "schemaHook", "propertyNode", "/"),
|
|
91
|
+
saveFileName: SAVE_FILE_NAME.objectRelationship,
|
|
92
|
+
fileExtension: ".js",
|
|
93
|
+
isAppend: false,
|
|
94
|
+
// encloseTemplate: "\n ]",
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function createSourceParams(
|
|
102
|
+
_izContext,
|
|
103
|
+
objectSchema,
|
|
104
|
+
srcPath
|
|
105
|
+
) {
|
|
106
|
+
const attributeRelationships = [];
|
|
107
|
+
const objectType = objectSchema.objectType; // main objectType
|
|
108
|
+
const storageResources = objectSchema.storageResources // storageResource from main objectType
|
|
109
|
+
const configPath = path.join(srcPath, '../../config/serverless.config.yml');
|
|
110
|
+
const serverlessConfig = fs.readFileSync(configPath, 'utf8');
|
|
111
|
+
const config = yaml.parse(serverlessConfig);
|
|
112
|
+
const serviceTag = config.main_config.iz_serviceTag;
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
attributeRelationships.push(
|
|
116
|
+
{ // has{objectType}property
|
|
117
|
+
relationshipTag: PREFIX_RELATIONSHIP.has + upperCase(objectType) + PROPERTYNODE_TAG.property,
|
|
118
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
119
|
+
{
|
|
120
|
+
serviceTag: serviceTag,
|
|
121
|
+
objectType: objectType,
|
|
122
|
+
linkType: "many",
|
|
123
|
+
requiredOnCreate: false
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
serviceTag: serviceTag,
|
|
127
|
+
objectType: upperCase(objectType) + PROPERTYNODE_TAG.property,
|
|
128
|
+
linkType: "many",
|
|
129
|
+
requiredOnCreate: false
|
|
130
|
+
},
|
|
131
|
+
storageResources,
|
|
132
|
+
"from"
|
|
133
|
+
)
|
|
134
|
+
},
|
|
135
|
+
// disabled{objectType}property
|
|
136
|
+
{
|
|
137
|
+
relationshipTag: PREFIX_RELATIONSHIP.disabled + upperCase(objectType) + PROPERTYNODE_TAG.property,
|
|
138
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
139
|
+
{
|
|
140
|
+
serviceTag: serviceTag,
|
|
141
|
+
objectType: objectType,
|
|
142
|
+
linkType: "many",
|
|
143
|
+
requiredOnCreate: false
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
serviceTag: serviceTag,
|
|
147
|
+
objectType: upperCase(objectType) + PROPERTYNODE_TAG.property,
|
|
148
|
+
linkType: "many",
|
|
149
|
+
requiredOnCreate: false
|
|
150
|
+
},
|
|
151
|
+
storageResources,
|
|
152
|
+
"from"
|
|
153
|
+
)
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
{ // is{objectType}PropertyLabel
|
|
157
|
+
relationshipTag: PREFIX_RELATIONSHIP.is + upperCase(objectType) + PROPERTYNODE_TAG.propertyLabel,
|
|
158
|
+
relationshipProperties: createBasicRelationshipsProperties(
|
|
159
|
+
{
|
|
160
|
+
serviceTag: serviceTag,
|
|
161
|
+
objectType: upperCase(objectType) + PROPERTYNODE_TAG.property,
|
|
162
|
+
linkType: "many",
|
|
163
|
+
requiredOnCreate: true
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
serviceTag: serviceTag,
|
|
167
|
+
objectType: upperCase(objectType) + PROPERTYNODE_TAG.propertyLabel,
|
|
168
|
+
linkType: "many",
|
|
169
|
+
requiredOnCreate: false
|
|
170
|
+
},
|
|
171
|
+
storageResources,
|
|
172
|
+
"from"
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
return attributeRelationships
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
module.exports = data
|
package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs
CHANGED
|
@@ -109,7 +109,7 @@ module.exports.createRelationshipComplete = async (
|
|
|
109
109
|
let sendMessageToOutCreateRelatonshipComplete = {
|
|
110
110
|
Message: JSON.stringify(createCompleteMsg),
|
|
111
111
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
112
|
-
TopicArn: await snsSharedLib.
|
|
112
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
|
|
113
113
|
};
|
|
114
114
|
_izContext.logger.debug("Send message to OutCreateRelationshipComplete :::>", sendMessageToOutCreateRelatonshipComplete);
|
|
115
115
|
await sns.publishAsync(_izContext, sendMessageToOutCreateRelatonshipComplete);
|
package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs
CHANGED
|
@@ -107,13 +107,13 @@ module.exports.createRelationshipComplete = async (
|
|
|
107
107
|
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
|
|
108
108
|
_izContext.logger.debug("After addCallingFlowToSnsResponseMessageAttributes", deleteRelComp);
|
|
109
109
|
|
|
110
|
-
let
|
|
110
|
+
let sendMessageToOutDeleteRelatonshipComplete = {
|
|
111
111
|
Message: JSON.stringify(deleteRelComp),
|
|
112
112
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
113
|
-
TopicArn: await snsSharedLib.
|
|
113
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete)
|
|
114
114
|
};
|
|
115
|
-
_izContext.logger.debug("Send message to OutCreateRelationshipComplete :::>",
|
|
116
|
-
await sns.publishAsync(_izContext,
|
|
115
|
+
_izContext.logger.debug("Send message to OutCreateRelationshipComplete :::>", sendMessageToOutDeleteRelatonshipComplete);
|
|
116
|
+
await sns.publishAsync(_izContext, sendMessageToOutDeleteRelatonshipComplete);
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
// remove awaitingMultipleStep after finished
|
|
@@ -134,7 +134,7 @@ module.exports.createRelationshipComplete = async (
|
|
|
134
134
|
errorsFound
|
|
135
135
|
}
|
|
136
136
|
} catch (err) {
|
|
137
|
-
_izContext.logger.error('error
|
|
137
|
+
_izContext.logger.error('error deleteRelationshipComplete:', err)
|
|
138
138
|
throw (err)
|
|
139
139
|
}
|
|
140
140
|
}
|
package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs
CHANGED
|
@@ -107,13 +107,13 @@ module.exports.createRelationshipComplete = async (
|
|
|
107
107
|
let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
|
|
108
108
|
_izContext.logger.debug("After addCallingFlowToSnsResponseMessageAttributes", createCompleteMsg);
|
|
109
109
|
|
|
110
|
-
let
|
|
110
|
+
let sendMessageToOutGetRelComplete = {
|
|
111
111
|
Message: JSON.stringify(createCompleteMsg),
|
|
112
112
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
113
|
-
TopicArn: await snsSharedLib.
|
|
113
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outGetRelComplete)
|
|
114
114
|
};
|
|
115
|
-
_izContext.logger.debug("Send message to
|
|
116
|
-
await sns.publishAsync(_izContext,
|
|
115
|
+
_izContext.logger.debug("Send message to outGetRelComplete :::>", sendMessageToOutGetRelComplete);
|
|
116
|
+
await sns.publishAsync(_izContext, sendMessageToOutGetRelComplete);
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
// remove awaitingMultipleStep after finished
|
|
@@ -135,7 +135,7 @@ module.exports.createRelationshipComplete = async (
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
} catch (err) {
|
|
138
|
-
_izContext.logger.error('error
|
|
138
|
+
_izContext.logger.error('error GetRelationshipComplete:', err)
|
|
139
139
|
throw (err)
|
|
140
140
|
}
|
|
141
141
|
}
|
package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs
CHANGED
|
@@ -112,7 +112,7 @@ module.exports.updateRelationshipComplete = async (
|
|
|
112
112
|
let sendMessageToOutUpdateRelatonshipComplete = {
|
|
113
113
|
Message: JSON.stringify(updateCompleteMsg),
|
|
114
114
|
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
115
|
-
TopicArn: await snsSharedLib.
|
|
115
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete)
|
|
116
116
|
};
|
|
117
117
|
_izContext.logger.debug("Send message to OutUpdateRelationshipComplete :::>", sendMessageToOutUpdateRelatonshipComplete);
|
|
118
118
|
await sns.publishAsync(_izContext, sendMessageToOutUpdateRelatonshipComplete);
|
|
@@ -0,0 +1,62 @@
|
|
|
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 Consts = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts')
|
|
20
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
21
|
+
const { ADD_ON_DATA_STRUCTURE_TYPE } = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts');
|
|
22
|
+
|
|
23
|
+
async function validateAddOnDataStructure(
|
|
24
|
+
_izContext,
|
|
25
|
+
settings
|
|
26
|
+
) {
|
|
27
|
+
|
|
28
|
+
let errorFounds = [];
|
|
29
|
+
let returnObjectValue = {}
|
|
30
|
+
|
|
31
|
+
const objTypeString = objType => `{ serviceTag: ${objType.serviceTag}, objectType: ${objType.objectType} }`;
|
|
32
|
+
|
|
33
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, settings.objType);
|
|
34
|
+
|
|
35
|
+
if (!objectSchema) {
|
|
36
|
+
errorFounds.push(`Invalid objType:${objTypeString(settings.objType)}, cannot generate attribute tree schema cause objectSchema is not exists`)
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (!objectSchema.hasOwnProperty("addOnDataStructure") || !Array.isArray(objectSchema.addOnDataStructure) || !objectSchema.addOnDataStructure.length) {
|
|
40
|
+
errorFounds.push(`objType: ${objTypeString(settings.objType)}.cause addOnDataStructure is not exists or empty`)
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if (settings.hasOwnProperty("attributeTag")) {
|
|
45
|
+
let addOnAttributeTree = objectSchema.addOnDataStructure.find(addOn => {
|
|
46
|
+
return addOn.type === ADD_ON_DATA_STRUCTURE_TYPE.attributeTree && addOn.attributeTreeTag === settings.attributeTag;
|
|
47
|
+
});
|
|
48
|
+
Object.assign(returnObjectValue, {
|
|
49
|
+
addOnAttributeTree: addOnAttributeTree,
|
|
50
|
+
});
|
|
51
|
+
if (!addOnAttributeTree) {
|
|
52
|
+
errorFounds.push(`objType: ${objTypeString(settings.objType)}. cannot generate attribute tree schema cause not found addOnDataStructure with attributeTreeTag: ${settings.attributeTag}`)
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
Object.assign(returnObjectValue, {
|
|
57
|
+
objectSchema: objectSchema
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return [returnObjectValue, errorFounds];
|
|
61
|
+
}
|
|
62
|
+
module.exports = validateAddOnDataStructure
|