@izara_project/izara-market-library-service-schemas 1.0.77 → 1.0.79
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 +10 -0
- package/package.json +3 -2
- package/src/MainLibs/src/Consts.js +14 -1
- package/src/MainLibs/src/Utils.js +4 -3
- package/src/reStructure/GenerateResources.js +127 -0
- package/src/reStructure/GenerateTests.js +23 -22
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +4 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +1 -1
- package/src/reStructure/TemplateData/IntTest/generateResources/generateResources.js +84 -41
- package/src/reStructure/TemplateData/IntTest/generateResources/templateResources.ejs +31 -0
- package/src/reStructure/TemplateData/IntTest/generateTests/events/data.js +110 -100
- package/src/reStructure/TemplateData/IntTest/generateTests/events/templateEvents.ejs +8 -7
- package/src/reStructure/TemplateData/IntTest/generateTests/generateTemplate.js +59 -61
- package/src/reStructure/TemplateData/IntTest/generateTests/tests/data.js +180 -260
- package/src/reStructure/TemplateData/IntTest/generateTests/tests/templateTests.ejs +3 -1
- package/src/reStructure/TemplateData/IntTest/libs/{generateTestsLibs.js → libs.js} +82 -84
- package/src/reStructure/TemplateData/IntTest/upload/uploadIntTest.js +60 -0
- package/src/reStructure/TemplateData/externalService/functionNameConfig/data.js +1 -1
- package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +2 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaMainFunction/template.ejs +7 -7
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/statusFieldComponent/Handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/checkTriggerCacheComplete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/functionYaml/data.js +1 -0
- package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/mainFunction/data.js +1 -0
- package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/triggerCacheComplete/functionYaml/data.js +1 -0
- package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/triggerCacheComplete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/webSocketComplete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/create/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/delete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/get/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/perActionComplete/update/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/processLogical/handler/template.ejs +1 -1
- 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/relationshipPerAction/changeRelationship/action/handler/templateByHandler/dsqTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/sqsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/dsqTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/sqsTemplate.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +4 -3
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/dsqTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/sqsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/dsqTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/sqsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/dsqTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/sqsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/dsqTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/sqsTemplate.ejs +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/handler/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +2 -2
- package/src/reStructure/TemplateData/IntTest/generateResources/resources/data.js +0 -74
- package/src/reStructure/TemplateData/IntTest/generateResources/resources/templateresources.ejs +0 -18
- package/src/reStructure/TemplateData/IntTest/generateResources.js +0 -144
- package/src/reStructure/TemplateData/IntTest/generateUpload/genetateTempleteUpload.js +0 -52
- package/src/reStructure/TemplateData/IntTest/generateUpload/upload/data.js +0 -40
- package/src/reStructure/TemplateData/IntTest/generateUpload/upload/libs/generateTestUploadLibs.js +0 -39
- package/src/reStructure/TemplateData/IntTest/generateUpload.js +0 -145
package/index.js
CHANGED
|
@@ -28,6 +28,11 @@ import mainLibUtils from './src/MainLibs/src/Utils.js';
|
|
|
28
28
|
import sourceManagerUtils from './src/SourceManager/src/Utils.js'
|
|
29
29
|
import createSource from './src/SourceManager/src/CreateSource.js'
|
|
30
30
|
|
|
31
|
+
import generateCode from './src/reStructure/GenerateCode.js';
|
|
32
|
+
import generateSchema from './src/reStructure/GenerateSchema.js';
|
|
33
|
+
import generateIntTest from './src/reStructure/GenerateTests.js';
|
|
34
|
+
import generateResourceIntTest from './src/reStructure/GenerateResources.js';
|
|
35
|
+
|
|
31
36
|
export {
|
|
32
37
|
// generatedCode Libs
|
|
33
38
|
constsGenerateCodeLibs, //generateCode Consts
|
|
@@ -44,4 +49,9 @@ export {
|
|
|
44
49
|
// Libs
|
|
45
50
|
checkPermission,
|
|
46
51
|
|
|
52
|
+
// main generateCode
|
|
53
|
+
generateCode,
|
|
54
|
+
generateSchema,
|
|
55
|
+
generateIntTest,
|
|
56
|
+
generateResourceIntTest
|
|
47
57
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-market-library-service-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.79",
|
|
4
4
|
"description": "Schemas for Izara Market project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,15 +25,16 @@
|
|
|
25
25
|
"@izara_project/izara-core-library-core": "^1.0.28",
|
|
26
26
|
"@izara_project/izara-core-library-dynamodb": "^1.0.12",
|
|
27
27
|
"@izara_project/izara-core-library-external-request": "^1.0.22",
|
|
28
|
+
"@izara_project/izara-core-library-graph-service": "1.0.16",
|
|
28
29
|
"@izara_project/izara-core-library-lambda": "^1.0.6",
|
|
29
30
|
"@izara_project/izara-core-library-logger": "^1.0.8",
|
|
31
|
+
"@izara_project/izara-core-library-s3": "^1.0.3",
|
|
30
32
|
"@izara_project/izara-core-library-service-schemas": "^1.0.102",
|
|
31
33
|
"@izara_project/izara-core-library-sns": "^1.0.7",
|
|
32
34
|
"@izara_project/izara-core-library-sqs": "^1.0.5",
|
|
33
35
|
"@izara_project/izara-shared": "^1.0.126",
|
|
34
36
|
"@izara_project/izara-shared-core": "^1.0.6",
|
|
35
37
|
"@izara_project/izara-shared-service-schemas": "^1.0.33",
|
|
36
|
-
"@izara_project/izara-core-library-graph-service": "1.0.16",
|
|
37
38
|
"ejs": "^3.1.10",
|
|
38
39
|
"js-beautify": "^1.15.4",
|
|
39
40
|
"lodash": "^4.17.21",
|
|
@@ -608,6 +608,17 @@ async function getExternalTopicComponentFromAllObjectSchemas(_izContext, allObjS
|
|
|
608
608
|
return externalTopicComponents
|
|
609
609
|
};
|
|
610
610
|
|
|
611
|
+
const GENERATE_SEED_DATA_TYPE = {
|
|
612
|
+
RANDOM_ON_CREATE_IDENTIFIERS: "randomOnCreateIdentifier",
|
|
613
|
+
NON_RANDOM_ON_CREATE_IDENTIFIERS: "notRandomOnIdentifier",
|
|
614
|
+
RELATIONSHIPS: "relationships"
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const SEED_DATA_TAG = {
|
|
618
|
+
dynamoDBSeedDataTags: "dynamoDBSeedDataTags",
|
|
619
|
+
graphSeedDataTags: "graphSeedDataTags"
|
|
620
|
+
}
|
|
621
|
+
|
|
611
622
|
export default {
|
|
612
623
|
STORAGE_TYPES,
|
|
613
624
|
ACTIONS,
|
|
@@ -644,5 +655,7 @@ export default {
|
|
|
644
655
|
createDynamoDbComponentByLinks,
|
|
645
656
|
getStorageResourceFromObjectSchemas,
|
|
646
657
|
FLOW_SCHEMA_EVENT_TYPE,
|
|
647
|
-
getExternalTopicComponentFromAllObjectSchemas
|
|
658
|
+
getExternalTopicComponentFromAllObjectSchemas,
|
|
659
|
+
GENERATE_SEED_DATA_TYPE,
|
|
660
|
+
SEED_DATA_TAG
|
|
648
661
|
}
|
|
@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
import yaml from 'yaml';
|
|
21
|
+
import fs from "fs";
|
|
22
|
+
import path from 'path';
|
|
23
23
|
|
|
24
24
|
function firstLetterUpperCase(text) {
|
|
25
25
|
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
@@ -59,6 +59,7 @@ function getLocalConfig(srcPath, params) {
|
|
|
59
59
|
// }
|
|
60
60
|
// return newObjectSchema
|
|
61
61
|
// }
|
|
62
|
+
|
|
62
63
|
export default {
|
|
63
64
|
firstLetterUpperCase,
|
|
64
65
|
firstLetterLowerCase,
|
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
import { join, dirname } from "path";
|
|
21
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = dirname(__filename);
|
|
24
|
+
import { readFileSync } from "fs";
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// SourceManager
|
|
28
|
+
const { deleteFileInDir } = utils
|
|
29
|
+
import { utils, createSource } from "../SourceManager/index.js";
|
|
30
|
+
|
|
31
|
+
import generateResource from './TemplateData/IntTest/generateResources/generateResources.js';
|
|
32
|
+
|
|
33
|
+
async function generateCodeWithTemplate(_izContext, savePath, settings) {
|
|
34
|
+
try {
|
|
35
|
+
|
|
36
|
+
// let packagePath = path.join(__dirname, "../../")
|
|
37
|
+
// let saveFilePath = join(packagePath, `../`);
|
|
38
|
+
// let localServicePath = join(saveFilePath, "../../");
|
|
39
|
+
// console.log({ packagePath });
|
|
40
|
+
// --------- Prepare path -------------
|
|
41
|
+
// point to app/src
|
|
42
|
+
|
|
43
|
+
// point to root folder of service
|
|
44
|
+
|
|
45
|
+
//------ Start Create Source ------
|
|
46
|
+
|
|
47
|
+
// collect all result of template data for execute createSource
|
|
48
|
+
let allCreateSource = []
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
let createSourceResult = await generateResource(_izContext, savePath);
|
|
52
|
+
// console.log({ createSourceResult })
|
|
53
|
+
// Filter out empty or invalid objects before adding to allCreateSource
|
|
54
|
+
if (Array.isArray(createSourceResult)) {
|
|
55
|
+
const validResults = createSourceResult.filter(item =>
|
|
56
|
+
item && item.templatePath && item.templateData && item.setting
|
|
57
|
+
);
|
|
58
|
+
allCreateSource.push(...validResults);
|
|
59
|
+
}
|
|
60
|
+
// console.log({ allCreateSource })
|
|
61
|
+
// check each allCreateSource valid
|
|
62
|
+
for (let item of allCreateSource) {
|
|
63
|
+
// throw Error('Skipping invalid source item:', item);
|
|
64
|
+
if (!item || !item.templatePath || !item.templateData || !item.setting) {
|
|
65
|
+
console.log('throw Error Skipping invalid source item:', item);
|
|
66
|
+
throw Error('Skipping invalid source item:', item);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const { templatePath, templateData, setting } = item;
|
|
71
|
+
setting.checkCreateSourcePass = true;
|
|
72
|
+
|
|
73
|
+
let [status, errors] = await createSource.createSource(
|
|
74
|
+
readFileSync(templatePath, 'utf8'),
|
|
75
|
+
templateData,
|
|
76
|
+
setting,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
if (status === false) {
|
|
80
|
+
console.log('templatePath in generateCode', templatePath)
|
|
81
|
+
throw Error(errors)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// validatePathWithRootServicePath(localServicePath, setting.savePath)
|
|
85
|
+
await deleteFileInDir(setting.savePath);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// generate all source
|
|
89
|
+
for (let item of allCreateSource) {
|
|
90
|
+
// throw error if item is invalid
|
|
91
|
+
if (!item || !item.templatePath || !item.templateData || !item.setting) {
|
|
92
|
+
console.log('Throwing invalid source item:', item);
|
|
93
|
+
throw Error('Throwing invalid source item:', item);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const { templatePath, templateData, setting } = item;
|
|
97
|
+
setting.checkCreateSourcePass = false;
|
|
98
|
+
|
|
99
|
+
await createSource.createSource(
|
|
100
|
+
readFileSync(templatePath, 'utf8'),
|
|
101
|
+
templateData,
|
|
102
|
+
setting,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
console.log('Generated all source files successfully');
|
|
107
|
+
|
|
108
|
+
// exec(`bash ${path.join(packagePath, "./frontEnd/NpmBash.bash")}`, (error, stdout, stderr) => {
|
|
109
|
+
// if (error) {
|
|
110
|
+
// console.error(`
|
|
111
|
+
// ${error.message}`);
|
|
112
|
+
// return;
|
|
113
|
+
// }
|
|
114
|
+
// if (stderr) {
|
|
115
|
+
// console.error(`${stderr}`);
|
|
116
|
+
// return;
|
|
117
|
+
// }
|
|
118
|
+
// console.log(`${stdout}`);
|
|
119
|
+
// });
|
|
120
|
+
// return 'return values';
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error('Error generating code:', error);
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default generateCodeWithTemplate;
|
|
@@ -17,24 +17,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
import { join, dirname } from "path";
|
|
21
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = dirname(__filename);
|
|
24
24
|
|
|
25
|
+
import { readFileSync } from "fs";
|
|
25
26
|
// SourceManager
|
|
26
27
|
import { utils, createSource } from "../SourceManager/index.js";
|
|
27
28
|
const { deleteFileInDir } = utils
|
|
28
|
-
|
|
29
|
+
import generateTest from './TemplateData/IntTest/generateTests/generateTemplate.js'
|
|
30
|
+
import uploadLib from './TemplateData/IntTest/upload/uploadIntTest.js'
|
|
31
|
+
import lib from '../reStructure/TemplateData/IntTest/libs/libs.js';
|
|
32
|
+
const { getLocalConfig } = lib;
|
|
29
33
|
async function generateCodeWithTemplate(_izContext, savePath, settings) {
|
|
30
34
|
_izContext.logger.debug("START", { savePath, settings })
|
|
31
35
|
try {
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
let packagePath = path.join(__dirname, "../../")
|
|
34
38
|
// console.log({ packagePath });
|
|
35
39
|
// --------- Prepare path -------------
|
|
36
40
|
// point to app/src
|
|
37
|
-
|
|
41
|
+
let saveFilePath = join(packagePath, `../`);
|
|
38
42
|
|
|
39
43
|
// point to root folder of service
|
|
40
44
|
// let localServicePath = join(saveFilePath, "../../");
|
|
@@ -45,8 +49,8 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
|
|
|
45
49
|
let allCreateSource = []
|
|
46
50
|
|
|
47
51
|
|
|
48
|
-
let generateTemplateData = (await import(join(__dirname, IntTestConfig.TemplateAndData[templateName]))).default;
|
|
49
|
-
let createSourceResult = await
|
|
52
|
+
// let generateTemplateData = (await import(join(__dirname, IntTestConfig.TemplateAndData[templateName]))).default;
|
|
53
|
+
let createSourceResult = await generateTest(_izContext, savePath);
|
|
50
54
|
// console.log({ createSourceResult })
|
|
51
55
|
// Filter out empty or invalid objects before adding to allCreateSource
|
|
52
56
|
if (Array.isArray(createSourceResult)) {
|
|
@@ -68,7 +72,7 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
|
|
|
68
72
|
const { templatePath, templateData, setting } = item;
|
|
69
73
|
setting.checkCreateSourcePass = true;
|
|
70
74
|
|
|
71
|
-
let [status, errors] = await createSource(
|
|
75
|
+
let [status, errors] = await createSource.createSource(
|
|
72
76
|
readFileSync(templatePath, 'utf8'),
|
|
73
77
|
templateData,
|
|
74
78
|
setting,
|
|
@@ -94,7 +98,7 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
|
|
|
94
98
|
const { templatePath, templateData, setting } = item;
|
|
95
99
|
setting.checkCreateSourcePass = false;
|
|
96
100
|
|
|
97
|
-
await createSource(
|
|
101
|
+
await createSource.createSource(
|
|
98
102
|
readFileSync(templatePath, 'utf8'),
|
|
99
103
|
templateData,
|
|
100
104
|
setting,
|
|
@@ -103,7 +107,14 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
|
|
|
103
107
|
|
|
104
108
|
console.log('Generated all source files successfully');
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
console.log("upload file to S3")
|
|
111
|
+
const intTestPath = join(saveFilePath, `../../src/generateIntegrationTest/${getLocalConfig("iz_serviceTag")}`)
|
|
112
|
+
console.log({ intTestPath })
|
|
113
|
+
|
|
114
|
+
// uploadLib(intTestPath, settings)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
// exec(`bash ${ path.join(packagePath, "./frontEnd/NpmBash.bash") } `, (error, stdout, stderr) => {
|
|
107
118
|
// if (error) {
|
|
108
119
|
// console.error(`
|
|
109
120
|
// ${error.message}`);
|
|
@@ -123,13 +134,3 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
|
|
|
123
134
|
}
|
|
124
135
|
|
|
125
136
|
export default generateCodeWithTemplate
|
|
126
|
-
|
|
127
|
-
/*
|
|
128
|
-
GenerateCode will iterate through templateConfig and generate each template dependOn each templateAndData\
|
|
129
|
-
|
|
130
|
-
GenerateSchema now use for generate attribute tree only
|
|
131
|
-
generateSchema can be modify use used depend on use case eg: some objectType have attribute tree inside addOn
|
|
132
|
-
when generateSchema in own service need to generate ref objectRelationship only
|
|
133
|
-
and attribute tree service can generate schema
|
|
134
|
-
|
|
135
|
-
*/
|
|
@@ -30,7 +30,8 @@ import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-f
|
|
|
30
30
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
31
31
|
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
32
32
|
import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
33
|
-
import
|
|
33
|
+
import identifierLib from '@izara_project/izara-core-library-identifiers';
|
|
34
|
+
const { createRandomIdentifier } = identifierLib
|
|
34
35
|
|
|
35
36
|
// ──────────────────────── Middleware / External ────────────────────────
|
|
36
37
|
import { consts as middlewareConsts } from '@izara_project/izara-middleware';
|
|
@@ -52,7 +53,8 @@ const {
|
|
|
52
53
|
TOPIC_NAME_GRAPH_HANDLER
|
|
53
54
|
} = constsGenerateCodeLibs;
|
|
54
55
|
|
|
55
|
-
const { dynamoDbIdentifiersByStorageResource } = generateCodeLibs
|
|
56
|
+
const { dynamoDbIdentifiersByStorageResource, createDataDetailsLib } = generateCodeLibs
|
|
57
|
+
|
|
56
58
|
//(<optionalRequire>)
|
|
57
59
|
//(</optionalRequire>)
|
|
58
60
|
|
|
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
// ==================== Shared Core Utilities ====================
|
|
20
|
-
import { consts as coreConsts } from 'izara_project/izara-core-library-core';
|
|
20
|
+
import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
21
21
|
|
|
22
22
|
// ==================== Core Service Schemas ====================
|
|
23
23
|
import { getObjectSchema, consts, createObjType } from '@izara_project/izara-core-library-service-schemas'
|
|
@@ -1,56 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
17
|
|
|
18
|
-
|
|
18
|
+
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
import path from 'path';
|
|
21
|
+
import { fileURLToPath } from 'url';
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = path.dirname(__filename);
|
|
23
24
|
|
|
25
|
+
import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas'
|
|
26
|
+
import intTestLibs from '../libs/libs.js';
|
|
27
|
+
const { getLocalConfig, directoryPath } = intTestLibs;
|
|
24
28
|
|
|
29
|
+
const templatePath = path.join(__dirname, "./templateResources.ejs")
|
|
25
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Generates code with templates for different actions
|
|
33
|
+
* @param {Object} _izContext - Context object
|
|
34
|
+
* @param {string} savePath - Path to the schema
|
|
35
|
+
* @returns {Array} Array of generated code parameters
|
|
36
|
+
*/
|
|
37
|
+
async function generateCodeWithTemplate(_izContext, savePath) {
|
|
38
|
+
try {
|
|
39
|
+
let allCreateSource = [];
|
|
26
40
|
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
let schemaPath = path.join(savePath, "../ schemas")
|
|
42
|
+
let slsYmlPath = path.join(savePath, "../../sls_yaml/generatedCode/source/")
|
|
43
|
+
let serviceTag = getLocalConfig("iz_serviceTag")
|
|
44
|
+
let functionPath = path.join(savePath, "../../sls_yaml/")
|
|
45
|
+
// console.log("serviceTag", serviceTag);
|
|
29
46
|
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
// * @param {Object} _izContext - Context object
|
|
33
|
-
// * @param {string} savePath - Path to the schema
|
|
34
|
-
// * @returns {Array} Array of generated code parameters
|
|
35
|
-
// */
|
|
36
|
-
// async function generateCodeWithTemplate(_izContext, savePath, settings) {
|
|
37
|
-
// try {
|
|
38
|
-
// // console.log("settings generateCodeWithTemplate", settings)
|
|
39
|
-
// let allCreateSource = [];
|
|
47
|
+
// let allObjectSchema = await getObjectSchemas.getAllLocalObjectSchemasWithHierarchy(_izContext, schemaPath)
|
|
48
|
+
let allObjectSchema = await getObjectSchema.getAllLocalObjectSchemas(_izContext, schemaPath) // get ObjectSchemas Local
|
|
40
49
|
|
|
41
|
-
|
|
50
|
+
let allObjectSchemas = allObjectSchema.records
|
|
42
51
|
|
|
43
|
-
|
|
52
|
+
let tableNames = [];
|
|
53
|
+
for (let objectSchema of allObjectSchemas) {
|
|
54
|
+
// console.log("objectSchema", objectSchema)
|
|
55
|
+
for (let storageResource of Object.values(objectSchema.storageResources)) {
|
|
56
|
+
// console.log("storageResource_Data", storageResource)
|
|
57
|
+
if (storageResource.storageType === "dynamoDB") {
|
|
58
|
+
// console.log("storageResource_Data_Before_Push_Dynamo", storageResource)
|
|
59
|
+
tableNames.push(storageResource.tableName)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
44
63
|
|
|
64
|
+
const generateFunctionComponent = directoryPath(slsYmlPath);
|
|
65
|
+
const mainFunctionComponent = directoryPath(functionPath);
|
|
66
|
+
// console.log({ mainFunctionComponent, generateFunctionComponent })
|
|
67
|
+
let lambdaComponent = { ...generateFunctionComponent, ...mainFunctionComponent }
|
|
68
|
+
let s3Component = {}
|
|
69
|
+
for (const lambdaFunctionName in lambdaComponent) {
|
|
70
|
+
if (lambdaFunctionName.endsWith("S3")) {
|
|
71
|
+
s3Component[lambdaFunctionName] = lambdaComponent[lambdaFunctionName]
|
|
72
|
+
delete lambdaComponent[lambdaFunctionName]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
console.log(s3Component)
|
|
45
76
|
|
|
46
|
-
// allCreateSource.push(
|
|
47
|
-
// generateResource,
|
|
48
|
-
// )
|
|
49
|
-
// return allCreateSource;
|
|
50
|
-
// } catch (error) {
|
|
51
|
-
// _izContext.logger.error('Error generating code with template propertyNode schema:', error);
|
|
52
|
-
// return [];
|
|
53
|
-
// }
|
|
54
|
-
// }
|
|
55
77
|
|
|
56
|
-
|
|
78
|
+
allCreateSource.push(
|
|
79
|
+
{
|
|
80
|
+
templatePath: templatePath,
|
|
81
|
+
templateData: { tableNames, functionComponent: lambdaComponent, s3Component },
|
|
82
|
+
setting: {
|
|
83
|
+
generateHookFile: false,
|
|
84
|
+
savePath: path.join(savePath, `${serviceTag}/sharedResources/`),
|
|
85
|
+
saveFileName: 'resources',
|
|
86
|
+
fileExtension: ".json",
|
|
87
|
+
isAppend: false
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
return allCreateSource;
|
|
92
|
+
|
|
93
|
+
} catch (error) {
|
|
94
|
+
_izContext.logger.error('Error generating code with template propertyNode schema:', error);
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default generateCodeWithTemplate;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Lambda": {
|
|
3
|
+
<% Object.entries(functionComponent).forEach(([funcName, filePath], index, array) => { -%>
|
|
4
|
+
"<%= funcName %>": {
|
|
5
|
+
"localLocation": "/<%= filePath %>.js",
|
|
6
|
+
"localHandler": "main",
|
|
7
|
+
"functionName": "<%= funcName %>"
|
|
8
|
+
}<%= index !== array.length - 1 ? ',' : '' %>
|
|
9
|
+
<% }); -%>
|
|
10
|
+
}, <% Object.keys(s3Component).length ? "," : "" %>
|
|
11
|
+
<% if (Object.keys(s3Component).length) { -%>
|
|
12
|
+
"S3": {
|
|
13
|
+
<% Object.entries(s3Component).forEach(([functionName,filePath],index) => { -%>
|
|
14
|
+
"<%- functionName %>": {
|
|
15
|
+
"localLocation": "/<%- filePath %>",
|
|
16
|
+
"localHandler": "main",
|
|
17
|
+
"functionName": "<%- functionName %>"
|
|
18
|
+
}<%= index < Object.keys(s3Component).length - 1 ? "," : "" %>
|
|
19
|
+
<% }); -%>
|
|
20
|
+
} <% Object.keys(tableNames).length ? "," : "" -%>
|
|
21
|
+
<% } -%>
|
|
22
|
+
<% if (Object.keys(tableNames).length) { -%>
|
|
23
|
+
"Dynamodb": {
|
|
24
|
+
<% tableNames.forEach(function(tableName, index) { %>
|
|
25
|
+
"<%= tableName %>": {
|
|
26
|
+
"tableName": "<%= tableName %>"
|
|
27
|
+
}<% if (index < tableNames.length - 1) { %>,<% } %>
|
|
28
|
+
<% }); %>
|
|
29
|
+
}
|
|
30
|
+
<% } %>
|
|
31
|
+
}
|