@izara_project/izara-market-library-service-schemas 1.0.35 → 1.0.37
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 +8 -7
- package/src/GenerateCodeLibs/src/Consts.js +2 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +3 -2
- package/src/MainLibs/src/Consts.js +8 -8
- package/src/MainLibs/src/GenerateCodeUtils.js +3 -1
- package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/generateTemplateData.js +35 -20
- package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/data.js +84 -0
- package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/tempReferenceRelationshipSchema.ejs +9 -0
- package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/data.js +1 -1
- package/src/TemplateManager/src/flowSchema/DefaultWebSocketResource/webSocketConnect/handler/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/FlowSchemaEndpoint/InProcessFlowSchema/handler/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/handler/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createObject/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/getsignUrlsAcc/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/createPresignUrl/reservedLimitComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/processFileS3AfterUpload/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/flowSchema/UploadS3Case/relate/libs/template.ejs +1 -1
- package/src/reStructure/SchemaConfig.js +1 -4
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +701 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +35 -163
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +3 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -4
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +3 -1
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +45 -19
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +5 -2
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +24 -14
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +4 -1
- package/src/reStructure/TemplateData/findData/GetByStorage/getByGraph.ejs +4 -3
- package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -1
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +4 -10
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +69 -34
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +3 -12
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +18 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +10 -7
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +12 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +14 -9
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +16 -40
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +9 -9
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +78 -27
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js +82 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +34 -1
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +9 -32
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +30 -20
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +6 -6
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +32 -32
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +5 -5
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +8 -9
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +116 -26
- package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +83 -44
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +4 -5
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -7
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +6 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +2 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +31 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +7 -8
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +13 -13
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +43 -39
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +5 -7
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -9
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +46 -48
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +5 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +3 -11
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +17 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +6 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +49 -84
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +60 -10
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +7 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +22 -7
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +27 -34
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +21 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +1 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +5 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data.js +5 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +10 -6
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +6 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +8 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +21 -14
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +23 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +11 -6
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +50 -45
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +3 -2
- package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +2 -28
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/createObjectComplete_main.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +10 -9
- package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +6 -2
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/perActionEndpoint/libs/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/create/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/delete/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/update/template.ejs +1 -1
- package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -0
- package/src/reStructure/TemplateData/{propertyNodeSchema → propertyValueSchema}/generateTemplateData.js +4 -4
- package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +131 -0
- package/src/reStructure/TemplateData/{propertyNodeSchema/relationshipPropertyNodeSchema → propertyValueSchema/relationshipPropertyValueSchema}/data.js +32 -55
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/tempRelationship.ejs +13 -0
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/templateRelationshipPropertyValueSchema.ejs +7 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +5 -5
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +6 -5
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +3 -3
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +4 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +5 -4
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +3 -2
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -3
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +61 -0
- package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +13 -4
- package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +0 -151
- package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +0 -7
- package/src/reStructure/TemplateData/testTemplate/data.js +0 -27
- package/src/reStructure/TemplateData/testTemplate/template.ejs +0 -0
- /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/attributeLinkTemplate.ejs +0 -0
- /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/data.js +0 -0
- /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/mainAttributeTree/request.json +0 -0
- /package/src/{reStructure/TemplateData → TemplateManager/src}/attributeTreeSchema/relationshipSchema/template.ejs +0 -0
- /package/src/reStructure/TemplateData/{propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs → propertyValueSchema/objectPropertyValueSchema/templateObjectPropertyValueSchema.ejs} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
|
|
23
|
+
// const {
|
|
24
|
+
// HANDLER,
|
|
25
|
+
// STORAGE_TYPES
|
|
26
|
+
// } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
27
|
+
|
|
28
|
+
const STORAGE_TYPES = {
|
|
29
|
+
dynamoDB: "dynamoDB",
|
|
30
|
+
graph: "graph"
|
|
31
|
+
}
|
|
32
|
+
const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../MainLibs/src/Consts')
|
|
33
|
+
const { firstUpperCase: upperCase } = require('../../../../MainLibs/src/Utils')
|
|
34
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
35
|
+
const { NoRetryError } = require("@izara_project/izara-core-library-core");
|
|
36
|
+
|
|
37
|
+
async function filterCreateResourceYaml(_izContext, createSourceParams, objSchemaPath) {
|
|
38
|
+
let tableNamesToFilter = new Set();
|
|
39
|
+
const allLocalFlowSchema = await getObjectSchema.getAllLocalFlowSchemas(_izContext, objSchemaPath);
|
|
40
|
+
for (const flowSchema of allLocalFlowSchema.records) {
|
|
41
|
+
if (flowSchema.statusType === "storedCache") {
|
|
42
|
+
const objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], objSchemaPath).then(res => res.records[0])
|
|
43
|
+
if (objectSchema) {
|
|
44
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
45
|
+
tableNamesToFilter.add(storageResource.tableName);
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
throw new NoRetryError('not have objectSchema in service to get')
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const filteredCreateSourceParams = createSourceParams.filter(
|
|
54
|
+
(result) => !tableNamesToFilter.has(result.templateData.tableName)
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
// console.log("filteredCreateSourceParams", filteredCreateSourceParams)
|
|
58
|
+
return filteredCreateSourceParams
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = filterCreateResourceYaml;
|
|
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20
20
|
const { join } = require('path');
|
|
21
21
|
|
|
22
22
|
// lib of generateCode
|
|
23
|
-
const { checkValidTableYaml } = require('../../../MainLibs/
|
|
23
|
+
const { checkValidTableYaml } = require('../../../MainLibs/src/GenerateCodeUtils.js');
|
|
24
24
|
|
|
25
25
|
const {
|
|
26
26
|
getAllLocalObjectSchemasWithHierarchy,
|
|
@@ -37,6 +37,8 @@ const createDefaultSnsOutForFindDataAndProcessLogical = require('./sns-out/defau
|
|
|
37
37
|
const createDataForCreateSourceSnsOut = require('./sns-out/data');
|
|
38
38
|
const createFindDataAndProcessLogicalDefaultSnsInSqs = require('./sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical');
|
|
39
39
|
const createDynamoPerRelationshipLink = require('./dynamodb/generateDynamoPerLink.js')
|
|
40
|
+
const filterCreateResourceYaml = require('./filterGenerateResource/data.js');
|
|
41
|
+
|
|
40
42
|
/**
|
|
41
43
|
* Generates code from templates based on object schemas
|
|
42
44
|
* @param {Object} _izContext - Context object
|
|
@@ -48,7 +50,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
48
50
|
const saveFilePath = join(objSchemaPath, '../');
|
|
49
51
|
const allObjSchemas = await getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
|
|
50
52
|
const allLocalRelationshipSchema = getAllLocalRelationshipSchema(_izContext, objSchemaPath);
|
|
51
|
-
|
|
53
|
+
const allLocalFlowSchema = await getAllLocalFlowSchemas(_izContext, objSchemaPath);
|
|
54
|
+
|
|
52
55
|
let createSourceParams = [];
|
|
53
56
|
let createdTableYaml = {}; // Declare createdTableYaml
|
|
54
57
|
|
|
@@ -56,9 +59,12 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
56
59
|
if (allObjSchemas && allObjSchemas.records) {
|
|
57
60
|
for (const objectSchema of allObjSchemas.records) {
|
|
58
61
|
try {
|
|
62
|
+
|
|
63
|
+
let createSourceDynamoDb = createSourceDataDynamoDB(_izContext, objectSchema, saveFilePath)
|
|
64
|
+
|
|
59
65
|
const [dynamoResources, updatedTableYaml] = checkValidTableYaml(
|
|
60
66
|
_izContext,
|
|
61
|
-
|
|
67
|
+
createSourceDynamoDb,
|
|
62
68
|
createdTableYaml
|
|
63
69
|
);
|
|
64
70
|
|
|
@@ -91,8 +97,11 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
91
97
|
...dynamoDbResourcePerRelationshipLink
|
|
92
98
|
)
|
|
93
99
|
}
|
|
100
|
+
const filteredCreateSourceParams = await filterCreateResourceYaml(_izContext, createSourceParams, objSchemaPath);
|
|
101
|
+
|
|
102
|
+
// console.log("filteredCreateSourceParams", filteredCreateSourceParams);
|
|
94
103
|
|
|
95
|
-
return
|
|
104
|
+
return filteredCreateSourceParams;
|
|
96
105
|
} catch (error) {
|
|
97
106
|
_izContext.logger.error('Error generating code with template resourceYaml: ', error);
|
|
98
107
|
return [];
|
|
@@ -1,151 +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
|
-
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
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const { join } = require('path');
|
|
2
|
-
|
|
3
|
-
const templatePath = join(__dirname, "template.ejs");
|
|
4
|
-
|
|
5
|
-
module.exports = async (_izContext, objSchemaPath, settings) => {
|
|
6
|
-
const srcPath = join(objSchemaPath, '../');
|
|
7
|
-
let createSourceData = [];
|
|
8
|
-
|
|
9
|
-
createSourceData.push(
|
|
10
|
-
{
|
|
11
|
-
templatePath: templatePath,
|
|
12
|
-
templateData: {
|
|
13
|
-
objectType: settings.objectType
|
|
14
|
-
},
|
|
15
|
-
setting: {
|
|
16
|
-
savePath: join(srcPath, "test" + "/"),
|
|
17
|
-
// hookPath: path.join(srcPath, "schemaHook", attributeTreeObjSchema.objectType, "/"),
|
|
18
|
-
saveFileName: "testAttributeTree",
|
|
19
|
-
fileExtension: ".js",
|
|
20
|
-
isAppend: false
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return createSourceData;
|
|
27
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|