blend-kit 1.0.1 → 1.0.2
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/antlr.readme +1 -0
- package/dist/ai-models/api-label/APILabelHelper.js +76 -0
- package/dist/ai-models/api-label/APILabelHelper.ts +34 -0
- package/dist/ai-models/api-label/labels.json +1 -0
- package/dist/ai-models/api-label/model.json +1 -0
- package/dist/ai-models/api-label/weights.bin +0 -0
- package/dist/ai-models/api-label/wordIndex.json +1 -0
- package/dist/ai-models/tokenizer.js +18 -0
- package/dist/ai-models/tokenizer.ts +16 -0
- package/dist/commands/ui.js +15 -0
- package/dist/helper/ExpressHelper.js +18 -12
- package/dist/helper/FrontEndApiHelper.js +12 -14
- package/dist/helper/FrontEndReactApiHelper.js +6 -6
- package/dist/helper/MongoHelper.js +9 -2
- package/dist/helper/RNHelper.js +7 -0
- package/dist/helper/ReactHelper.js +10 -2
- package/dist/helper/grammarHelper/BlendApiGrammarHelper.js +44 -5
- package/dist/helper/grammarHelper/BlendMongoGrammarHelper.js +2 -1
- package/dist/index.js +2 -2
- package/dist/parser/blendExpress/src/grammar/BlendExpressLexer.js +201 -0
- package/dist/parser/blendExpress/src/grammar/BlendExpressListener.js +3 -0
- package/dist/parser/blendExpress/src/grammar/BlendExpressParser.js +961 -0
- package/dist/parser/blendReact/src/grammar/BlendReactLexer.js +1 -1
- package/dist/server.js +31 -0
- package/dist/types/apiOperationTypes.js +8 -1
- package/package.json +6 -3
- package/src/ai-models/api-label/APILabelHelper.ts +34 -0
- package/src/ai-models/api-label/labels.json +1 -0
- package/src/ai-models/api-label/model.json +1 -0
- package/src/ai-models/api-label/weights.bin +0 -0
- package/src/ai-models/api-label/wordIndex.json +1 -0
- package/src/ai-models/tokenizer.ts +16 -0
- package/src/grammar/.antlr/BlendApiLexer.java +2 -2
- package/src/grammar/.antlr/BlendExpress.interp +70 -0
- package/src/grammar/.antlr/BlendExpress.tokens +44 -0
- package/src/grammar/.antlr/BlendExpressLexer.interp +89 -0
- package/src/grammar/.antlr/BlendExpressLexer.java +237 -0
- package/src/grammar/.antlr/BlendExpressLexer.tokens +44 -0
- package/src/grammar/.antlr/BlendExpressParser.java +767 -0
- package/src/grammar/.antlr/BlendMongo.interp +3 -1
- package/src/grammar/.antlr/BlendMongo.tokens +5 -3
- package/src/grammar/.antlr/BlendMongoLexer.interp +4 -1
- package/src/grammar/.antlr/BlendMongoLexer.java +99 -95
- package/src/grammar/.antlr/BlendMongoLexer.tokens +5 -3
- package/src/grammar/.antlr/BlendMongoParser.java +11 -11
- package/src/grammar/.antlr/BlendReactLexer.interp +1 -1
- package/src/grammar/.antlr/BlendReactLexer.java +1 -1
- package/src/grammar/BlendExpress.g4 +26 -0
- package/src/grammar/BlendMongo.g4 +1 -1
- package/src/grammar/BlendReact.g4 +1 -1
- package/src/helper/ExpressHelper.ts +153 -141
- package/src/helper/FrontEndApiHelper.ts +13 -14
- package/src/helper/FrontEndReactApiHelper.ts +6 -6
- package/src/helper/MongoHelper.ts +9 -2
- package/src/helper/RNHelper.ts +76 -70
- package/src/helper/ReactHelper.ts +10 -2
- package/src/helper/grammarHelper/BlendApiGrammarHelper.ts +46 -6
- package/src/helper/grammarHelper/BlendMongoGrammarHelper.ts +4 -3
- package/src/index.ts +3 -2
- package/src/parser/blendExpress/src/grammar/BlendExpress.interp +70 -0
- package/src/parser/blendExpress/src/grammar/BlendExpress.tokens +44 -0
- package/src/parser/blendExpress/src/grammar/BlendExpressLexer.interp +89 -0
- package/src/parser/blendExpress/src/grammar/BlendExpressLexer.tokens +44 -0
- package/src/parser/blendExpress/src/grammar/BlendExpressLexer.ts +193 -0
- package/src/parser/blendExpress/src/grammar/BlendExpressListener.ts +145 -0
- package/src/parser/blendExpress/src/grammar/BlendExpressParser.ts +968 -0
- package/src/parser/blendReact/src/grammar/BlendReactLexer.interp +1 -1
- package/src/parser/blendReact/src/grammar/BlendReactLexer.ts +1 -1
- package/src/types/apiOperationTypes.ts +12 -0
- package/tsconfig.json +1 -0
package/antlr.readme
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx antlr4ts -o src/parser/blendRnBasic src/grammar/BlendRnBasic.g4
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
const tokenizer_1 = require("../tokenizer");
|
|
49
|
+
const tf = __importStar(require("@tensorflow/tfjs-node"));
|
|
50
|
+
const wordIndex_json_1 = __importDefault(require("./wordIndex.json"));
|
|
51
|
+
const labels_json_1 = __importDefault(require("./labels.json"));
|
|
52
|
+
const node_path_1 = require("node:path");
|
|
53
|
+
class APILabelAIHelper {
|
|
54
|
+
static predict(apiName) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
// const wordIndex: Record<string, number> = JSON.parse(readFileSync('./wordIndex.json', 'utf-8'));
|
|
57
|
+
const vocabLength = Object.keys(wordIndex_json_1.default).length;
|
|
58
|
+
// const labels: string[] = JSON.parse(readFileSync('./models/labels.json', 'utf-8'));
|
|
59
|
+
const modelPath = `file://${(0, node_path_1.join)(__dirname, '/model.json')}`;
|
|
60
|
+
const model = yield tf.loadLayersModel(modelPath);
|
|
61
|
+
const tokens = (0, tokenizer_1.tokenize)(apiName);
|
|
62
|
+
const indices = tokens.map(tok => wordIndex_json_1.default[tok] || 0);
|
|
63
|
+
const padded = new Array(vocabLength).fill(0);
|
|
64
|
+
// indices.forEach((val, idx) => { padded[idx] = val; });
|
|
65
|
+
for (let i = 0; i < Math.min(vocabLength, indices.length); i++) {
|
|
66
|
+
padded[i] = indices[i];
|
|
67
|
+
}
|
|
68
|
+
const input = tf.tensor2d([padded], [1, vocabLength], 'float32');
|
|
69
|
+
const prediction = model.predict(input);
|
|
70
|
+
const probs = prediction.arraySync();
|
|
71
|
+
const predictedLabel = labels_json_1.default[probs[0].indexOf(Math.max(...probs[0]))];
|
|
72
|
+
return predictedLabel;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.default = APILabelAIHelper;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { tokenize } from "../tokenizer";
|
|
4
|
+
import * as tf from '@tensorflow/tfjs-node';
|
|
5
|
+
import wordIndex from './wordIndex.json';
|
|
6
|
+
import labels from './labels.json';
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
|
|
9
|
+
export default class APILabelAIHelper {
|
|
10
|
+
static async predict(apiName: string) {
|
|
11
|
+
// const wordIndex: Record<string, number> = JSON.parse(readFileSync('./wordIndex.json', 'utf-8'));
|
|
12
|
+
const vocabLength = Object.keys(wordIndex).length;
|
|
13
|
+
// const labels: string[] = JSON.parse(readFileSync('./models/labels.json', 'utf-8'));
|
|
14
|
+
const modelPath = `file://${join(__dirname, '/model.json')}`;
|
|
15
|
+
const model = await tf.loadLayersModel(modelPath);
|
|
16
|
+
|
|
17
|
+
const tokens = tokenize(apiName);
|
|
18
|
+
const indices = tokens.map(tok => wordIndex[tok] || 0);
|
|
19
|
+
|
|
20
|
+
const padded = new Array(vocabLength).fill(0);
|
|
21
|
+
// indices.forEach((val, idx) => { padded[idx] = val; });
|
|
22
|
+
for (let i = 0; i < Math.min(vocabLength, indices.length); i++) {
|
|
23
|
+
padded[i] = indices[i];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const input = tf.tensor2d([padded], [1, vocabLength], 'float32');
|
|
27
|
+
|
|
28
|
+
const prediction = model.predict(input) as tf.Tensor;
|
|
29
|
+
const probs = prediction.arraySync() as number[][];
|
|
30
|
+
|
|
31
|
+
const predictedLabel = labels[probs[0].indexOf(Math.max(...probs[0]))];
|
|
32
|
+
return predictedLabel;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["Customer","Order","Product","User"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"modelTopology":{"class_name":"Sequential","config":{"name":"sequential_1","layers":[{"class_name":"Embedding","config":{"input_dim":67,"output_dim":16,"embeddings_initializer":{"class_name":"RandomUniform","config":{"minval":-0.05,"maxval":0.05,"seed":null}},"embeddings_regularizer":null,"activity_regularizer":null,"embeddings_constraint":null,"mask_zero":null,"input_length":66,"name":"embedding_Embedding1","trainable":true,"batch_input_shape":[null,66]}},{"class_name":"LSTM","config":{"name":"lstm_LSTM1","trainable":true,"units":32,"activation":"tanh","recurrent_activation":"hard_sigmoid","use_bias":true,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_avg","distribution":"normal","seed":null}},"recurrent_initializer":{"class_name":"Orthogonal","config":{"gain":1,"seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"unit_forget_bias":null,"kernel_regularizer":null,"recurrent_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"recurrent_constraint":null,"bias_constraint":null,"dropout":0,"recurrent_dropout":0,"implementation":null,"return_sequences":false,"return_state":false,"go_backwards":false,"stateful":false,"unroll":false}},{"class_name":"Dense","config":{"units":4,"activation":"softmax","use_bias":true,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_avg","distribution":"normal","seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"bias_constraint":null,"name":"dense_Dense1","trainable":true}}]},"keras_version":"tfjs-layers 4.22.0","backend":"tensor_flow.js"},"weightsManifest":[{"paths":["weights.bin"],"weights":[{"name":"embedding_Embedding1/embeddings","shape":[67,16],"dtype":"float32"},{"name":"lstm_LSTM1/kernel","shape":[16,128],"dtype":"float32"},{"name":"lstm_LSTM1/recurrent_kernel","shape":[32,128],"dtype":"float32"},{"name":"lstm_LSTM1/bias","shape":[128],"dtype":"float32"},{"name":"dense_Dense1/kernel","shape":[32,4],"dtype":"float32"},{"name":"dense_Dense1/bias","shape":[4],"dtype":"float32"}]}],"format":"layers-model","generatedBy":"TensorFlow.js tfjs-layers v4.22.0","convertedBy":null}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"get":1,"customer":2,"details":3,"fetch":4,"user":5,"orders":6,"product":7,"stock":8,"create":9,"new":10,"add":11,"account":12,"item":13,"to":14,"cart":15,"update":16,"place":17,"order":18,"now":19,"profile":20,"modify":21,"settings":22,"status":23,"info":24,"available":25,"products":26,"history":27,"items":28,"listing":29,"password":30,"list":31,"availability":32,"address":33,"summary":34,"session":35,"quantity":36,"preferences":37,"reviews":38,"invoice":39,"tracking":40,"wishlist":41,"contact":42,"feedback":43,"image":44,"priority":45,"category":46,"categories":47,"preference":48,"reward":49,"specs":50,"data":51,"request":52,"transactions":53,"warranty":54,"comment":55,"notification":56,"bundle":57,"invoices":58,"sessions":59,"transaction":60,"gallery":61,"coupons":62,"shipment":63,"credentials":64,"review":65,"invitation":66}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tokenize = tokenize;
|
|
4
|
+
exports.buildVocab = buildVocab;
|
|
5
|
+
function tokenize(text) {
|
|
6
|
+
return text
|
|
7
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2') // Split camelCase
|
|
8
|
+
.toLowerCase()
|
|
9
|
+
.split(/[^a-z]+/) // Split on non-letters
|
|
10
|
+
.filter(Boolean);
|
|
11
|
+
}
|
|
12
|
+
function buildVocab(data) {
|
|
13
|
+
const vocabSet = new Set();
|
|
14
|
+
data.forEach(({ apiName }) => {
|
|
15
|
+
tokenize(apiName).forEach(word => { vocabSet.add(word); });
|
|
16
|
+
});
|
|
17
|
+
return Array.from(vocabSet);
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function tokenize(text: string): string[] {
|
|
2
|
+
return text
|
|
3
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2') // Split camelCase
|
|
4
|
+
.toLowerCase()
|
|
5
|
+
.split(/[^a-z]+/) // Split on non-letters
|
|
6
|
+
.filter(Boolean);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export function buildVocab(data: { apiName: string }[]): string[] {
|
|
11
|
+
const vocabSet = new Set<string>();
|
|
12
|
+
data.forEach(({ apiName }) => {
|
|
13
|
+
tokenize(apiName).forEach(word => {vocabSet.add(word)});
|
|
14
|
+
});
|
|
15
|
+
return Array.from(vocabSet);
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runUI = runUI;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
function runUI() {
|
|
10
|
+
const serverPath = path_1.default.resolve(__dirname, '../server.ts');
|
|
11
|
+
(0, child_process_1.fork)(serverPath, [], {
|
|
12
|
+
stdio: 'inherit',
|
|
13
|
+
execArgv: ['-r', 'ts-node/register'],
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -56,7 +56,8 @@ class ExpressHelper {
|
|
|
56
56
|
section.expressModuleList.forEach(module => {
|
|
57
57
|
const filePath = path_1.default.join(apiFolderPath, `${module.name}.express`);
|
|
58
58
|
const specCode = fileHelper_1.FileHelper.readFile(filePath);
|
|
59
|
-
|
|
59
|
+
let currentSection = this.basicProjectContent.sectionList.find(item => item.name === sectionName);
|
|
60
|
+
const json = new BlendApiGrammarHelper_1.default().parseBlendApi(specCode, currentSection.dataModuleList || []);
|
|
60
61
|
if (!json.isValid) {
|
|
61
62
|
throw new Error("Error while parsing the syntax");
|
|
62
63
|
}
|
|
@@ -73,29 +74,30 @@ class ExpressHelper {
|
|
|
73
74
|
parseJSONAndGenerateFiles() {
|
|
74
75
|
const apiMainSectionList = JSON.parse(fileHelper_1.FileHelper.readFile(`${this.configPath}/apiConfig.json`));
|
|
75
76
|
apiMainSectionList.forEach(sectionApi => {
|
|
77
|
+
// console.log(sectionApi.name,"sectionApisectionApisectionApisectionApisectionApisectionApisectionApisectionApi")
|
|
76
78
|
const mainSectionPath = path_1.default.join(this.folderPath, `module/${sectionApi.name}`);
|
|
77
79
|
sectionApi.expressSectionList.forEach(expressSection => {
|
|
78
80
|
const expressPath = path_1.default.join(mainSectionPath, `express/${sectionApi.name}-api`);
|
|
79
81
|
expressSection.apiSectionList.forEach(apiSection => {
|
|
80
82
|
// const apiPath = ``
|
|
81
|
-
this.writeApi(apiSection, expressPath, expressSection);
|
|
82
|
-
this.writeInterfaceCode(apiSection, expressPath, expressSection);
|
|
83
|
+
this.writeApi(apiSection, expressPath, expressSection, sectionApi.name);
|
|
84
|
+
this.writeInterfaceCode(apiSection, expressPath, expressSection, sectionApi.name);
|
|
83
85
|
this.writeApiDatacode(apiSection, expressPath, expressSection);
|
|
84
86
|
this.writeRouteCode(apiSection, expressPath, expressSection);
|
|
85
87
|
});
|
|
86
88
|
});
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
|
-
writeApi(apiSection, expressPath, expressSection) {
|
|
90
|
-
const apiCode = this.generateApiCode(apiSection, expressSection);
|
|
91
|
+
writeApi(apiSection, expressPath, expressSection, mainSectionName) {
|
|
92
|
+
const apiCode = this.generateApiCode(apiSection, expressSection, mainSectionName);
|
|
91
93
|
const apiPath = `${expressPath}/src/services/${expressSection.name}`;
|
|
92
94
|
const fileName = `${apiSection.name}/${apiSection.name}.service.ts`;
|
|
93
95
|
fileHelper_1.FileHelper.createFile(`${apiPath}/${fileName}`, apiCode);
|
|
94
96
|
}
|
|
95
|
-
writeInterfaceCode(apiSection, expressPath, expressSection) {
|
|
97
|
+
writeInterfaceCode(apiSection, expressPath, expressSection, mainSectionName) {
|
|
96
98
|
const interfacePath = `${expressPath}/src-gen/api-interfaces/${expressSection.name}`;
|
|
97
99
|
const fileName = `${apiSection.name}.interface.ts`;
|
|
98
|
-
const code = this.generateApiInterfaceCode(apiSection, expressSection);
|
|
100
|
+
const code = this.generateApiInterfaceCode(apiSection, expressSection, mainSectionName);
|
|
99
101
|
fileHelper_1.FileHelper.writeFile(`${interfacePath}/${fileName}`, code);
|
|
100
102
|
}
|
|
101
103
|
writeApiDatacode(apiSection, expressPath, expressSection) {
|
|
@@ -138,7 +140,7 @@ class ExpressHelper {
|
|
|
138
140
|
fileHelper_1.FileHelper.createFile(authPath, authCode);
|
|
139
141
|
fileHelper_1.FileHelper.createFile(swaggerConfigPath, swaggerConfigCode);
|
|
140
142
|
}
|
|
141
|
-
generateApiInterfaceCode(apiSection, expressSection) {
|
|
143
|
+
generateApiInterfaceCode(apiSection, expressSection, mainSectionName) {
|
|
142
144
|
const interfaceName = `I${apiSection.name}Api`;
|
|
143
145
|
const sectionName = `${apiSection.name}Service`;
|
|
144
146
|
const apiCode = this.generateApiFunctionCodes(apiSection);
|
|
@@ -286,15 +288,19 @@ constructor(
|
|
|
286
288
|
`;
|
|
287
289
|
return code;
|
|
288
290
|
}
|
|
289
|
-
generateApiCode(apiSection, expressSection) {
|
|
291
|
+
generateApiCode(apiSection, expressSection, mainSectionName) {
|
|
290
292
|
const serviceName = `${apiSection.name}Service`;
|
|
291
293
|
const interfaceName = `I${apiSection.name}Api`;
|
|
294
|
+
const totalInputs = apiSection.apiList.reduce((acc, currVal) => {
|
|
295
|
+
acc = acc + Object.keys(currVal.input).length;
|
|
296
|
+
return acc;
|
|
297
|
+
}, 0);
|
|
292
298
|
const code = `
|
|
293
299
|
import express from 'express';\n
|
|
294
300
|
import { ${interfaceName} } from '../../../../src-gen/api-interfaces/${expressSection.name}/${apiSection.name}.interface';\n
|
|
295
|
-
${apiSection.apiList.length > 0 ? `import {${apiSection.apiList.reduce((acc, currVal) => {
|
|
301
|
+
${apiSection.apiList.length > 0 && totalInputs > 0 ? `import {${apiSection.apiList.reduce((acc, currVal) => {
|
|
296
302
|
const inputName = (`${apiSection.name}_${currVal.name}_Input`).toUpperCase();
|
|
297
|
-
acc = acc + inputName + ','
|
|
303
|
+
acc = acc + `${Object.keys(currVal.input).length > 0 ? `${inputName + ','}` : ``}`;
|
|
298
304
|
return acc;
|
|
299
305
|
}, '')}} from '../../../../src-gen/api-data/${expressSection.name}/${apiSection.name}.data';` : ''}
|
|
300
306
|
|
|
@@ -401,7 +407,7 @@ export default class ${serviceName} implements ${interfaceName} {
|
|
|
401
407
|
* - BearerAuth: []
|
|
402
408
|
* tags:
|
|
403
409
|
* - ${apiSection.name}
|
|
404
|
-
* parameters:
|
|
410
|
+
* parameters: ${inputKeyList.length == 0 ? '[]' : ''}
|
|
405
411
|
${inputKeyList
|
|
406
412
|
.map((item) => {
|
|
407
413
|
const apiObj = api.input[item];
|
|
@@ -90,6 +90,7 @@ headers: {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
generateSliceCode(apiSection) {
|
|
93
|
+
let includedModuleList = [];
|
|
93
94
|
const filteredApiListForData = apiSection.apiList.filter(api => {
|
|
94
95
|
const inputKeyList = Object.keys(api.input);
|
|
95
96
|
const outputKeyList = Object.keys(api.output);
|
|
@@ -109,21 +110,16 @@ ${filteredApiListForData.length > 0 ? `import { ${apiSection.apiList.reduce((acc
|
|
|
109
110
|
return acc;
|
|
110
111
|
}, '')} } from "./data";
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
var _a, _b, _c;
|
|
114
|
-
if ((_a = curVal === null || curVal === void 0 ? void 0 : curVal.directOutput) === null || _a === void 0 ? void 0 : _a.name) {
|
|
115
|
-
const [moduleName, dataName] = (_c = (_b = curVal === null || curVal === void 0 ? void 0 : curVal.directOutput) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.split("->");
|
|
116
|
-
acc = acc + `import {${dataName === null || dataName === void 0 ? void 0 : dataName.replace("[]", "")}} from "../../../data/${moduleName}";`;
|
|
117
|
-
}
|
|
118
|
-
return acc;
|
|
119
|
-
}, '')} ` : ''}
|
|
113
|
+
` : ''}
|
|
120
114
|
|
|
121
115
|
${apiSection.apiList.reduce((acc, curVal) => {
|
|
122
116
|
var _a, _b, _c;
|
|
123
117
|
if ((_a = curVal === null || curVal === void 0 ? void 0 : curVal.directOutput) === null || _a === void 0 ? void 0 : _a.name) {
|
|
124
118
|
const [moduleName, dataName] = (_c = (_b = curVal === null || curVal === void 0 ? void 0 : curVal.directOutput) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.split("->");
|
|
125
|
-
acc = acc +
|
|
119
|
+
acc = acc + !includedModuleList.includes(moduleName) ? `import * as ${moduleName} from "../../../data/${moduleName}";` : '';
|
|
120
|
+
includedModuleList.push(moduleName);
|
|
126
121
|
}
|
|
122
|
+
console.log(includedModuleList, "includedModuleListincludedModuleListincludedModuleListincludedModuleList");
|
|
127
123
|
return acc;
|
|
128
124
|
}, '')}
|
|
129
125
|
|
|
@@ -135,7 +131,7 @@ interface ${apiSection.name}State {
|
|
|
135
131
|
var _a, _b;
|
|
136
132
|
const [moduleName, dataName] = ((_b = (_a = curVal === null || curVal === void 0 ? void 0 : curVal.directOutput) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.split("->")) || [];
|
|
137
133
|
acc = acc + `${curVal.name}: {
|
|
138
|
-
data: ${Object.keys(curVal.output).length > 0 ? `${apiSection.name.toUpperCase()}_${curVal.name.toUpperCase()}_OUTPUT` : dataName ? dataName : "any"},\n
|
|
134
|
+
data: ${Object.keys(curVal.output).length > 0 ? `${apiSection.name.toUpperCase()}_${curVal.name.toUpperCase()}_OUTPUT` : dataName ? `${moduleName}.${dataName}` : "any"},\n
|
|
139
135
|
status: ApiStatus,
|
|
140
136
|
error:string|null
|
|
141
137
|
}
|
|
@@ -252,6 +248,7 @@ export const GeneratedReducers = {
|
|
|
252
248
|
return code;
|
|
253
249
|
}
|
|
254
250
|
generateApiActioncode(apiSection, expressSection) {
|
|
251
|
+
let includedModuleList = [];
|
|
255
252
|
const filteredApiListForData = apiSection.apiList.filter(api => {
|
|
256
253
|
const inputKeyList = Object.keys(api.input);
|
|
257
254
|
const outputKeyList = Object.keys(api.output);
|
|
@@ -278,7 +275,8 @@ export const GeneratedReducers = {
|
|
|
278
275
|
var _a, _b, _c;
|
|
279
276
|
if ((_a = curVal === null || curVal === void 0 ? void 0 : curVal.directOutput) === null || _a === void 0 ? void 0 : _a.name) {
|
|
280
277
|
const [moduleName, dataName] = (_c = (_b = curVal === null || curVal === void 0 ? void 0 : curVal.directOutput) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.split("->");
|
|
281
|
-
acc = acc + `import {${dataName === null || dataName === void 0 ? void 0 : dataName.replace("[]", "")}} from "../../../data/${moduleName}"
|
|
278
|
+
acc = acc + !includedModuleList.includes(moduleName) ? `import {${dataName === null || dataName === void 0 ? void 0 : dataName.replace("[]", "")}} from "../../../data/${moduleName}";` : '';
|
|
279
|
+
includedModuleList.push(moduleName);
|
|
282
280
|
}
|
|
283
281
|
return acc;
|
|
284
282
|
}, '')}
|
|
@@ -315,13 +313,13 @@ export const GeneratedReducers = {
|
|
|
315
313
|
|
|
316
314
|
|
|
317
315
|
export const ${curVal.name}Api = async (${inputKeyList.length > 0 ? `input: ${inputDataTypeName},` : ``} ) => {
|
|
318
|
-
return ${expressSection.name}Api.${curVal.type.toLowerCase()}('${this.getApiName(expressSection.name)}/${this.getApiName(apiSection.name)}/${this.getApiName(curVal.name)}',${inputKeyList.length > 0 ? `${curVal.type == '
|
|
316
|
+
return ${expressSection.name}Api.${curVal.type.toLowerCase()}('${this.getApiName(expressSection.name)}/${this.getApiName(apiSection.name)}/${this.getApiName(curVal.name)}',${inputKeyList.length > 0 ? `${curVal.type == 'POST' ? 'input' : '{params: input.toJSON()}'}` : ''});
|
|
319
317
|
}
|
|
320
318
|
|
|
321
319
|
export const call${this.capitalizeFirstLetter(curVal.name)}Api = async (${inputKeyList.length > 0 ? `input: ${inputDataTypeName},` : ``} output: (output: ${outputKeyList.length > 0 ? outputDataTypeName : dataName ? dataName : 'any'}) => any,error: (errMsg: any) => void) => {
|
|
322
320
|
try {
|
|
323
|
-
//const { data } = await ${expressSection.name}Api.${curVal.type.toLowerCase()}('${this.getApiName(apiSection.name)}/${this.getApiName(curVal.name)}',${inputKeyList.length > 0 ? `${curVal.type == '
|
|
324
|
-
const { data } = await ${curVal.name}Api(${inputKeyList.length > 0 ? `${curVal.type == '
|
|
321
|
+
//const { data } = await ${expressSection.name}Api.${curVal.type.toLowerCase()}('${this.getApiName(apiSection.name)}/${this.getApiName(curVal.name)}',${inputKeyList.length > 0 ? `${curVal.type == 'POST' ? 'input' : '{params: input.toJSON()}'}` : ''});
|
|
322
|
+
const { data } = await ${curVal.name}Api(${inputKeyList.length > 0 ? `${curVal.type == 'POST' ? 'input' : 'input'}` : ''});
|
|
325
323
|
return output(data);
|
|
326
324
|
} catch (err: any) {
|
|
327
325
|
return error(showError(err));
|
|
@@ -272,9 +272,9 @@ export const GeneratedReducers = {
|
|
|
272
272
|
var _a, _b, _c;
|
|
273
273
|
if ((_a = curVal === null || curVal === void 0 ? void 0 : curVal.directOutput) === null || _a === void 0 ? void 0 : _a.name) {
|
|
274
274
|
const [moduleName, dataName] = (_c = (_b = curVal === null || curVal === void 0 ? void 0 : curVal.directOutput) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.split("->");
|
|
275
|
-
console.log(dataName,
|
|
275
|
+
// console.log(dataName,moduleName,"DataName...........")
|
|
276
276
|
if (dataName) {
|
|
277
|
-
acc = acc + `import
|
|
277
|
+
acc = acc + `import * as ${moduleName} from "../../../data/${moduleName}";`;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
return acc;
|
|
@@ -313,13 +313,13 @@ export const GeneratedReducers = {
|
|
|
313
313
|
|
|
314
314
|
|
|
315
315
|
export const ${curVal.name}Api = async (${inputKeyList.length > 0 ? `input: ${inputDataTypeName},` : ``} ) => {
|
|
316
|
-
return ${expressSection.name}Api.${curVal.type.toLowerCase()}('${this.getApiName(expressSection.name)}/${this.getApiName(apiSection.name)}/${this.getApiName(curVal.name)}',${inputKeyList.length > 0 ? `${curVal.type == '
|
|
316
|
+
return ${expressSection.name}Api.${curVal.type.toLowerCase()}('${this.getApiName(expressSection.name)}/${this.getApiName(apiSection.name)}/${this.getApiName(curVal.name)}',${inputKeyList.length > 0 ? `${curVal.type == 'POST' ? 'input' : '{params: input.toJSON()}'}` : ''});
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
export const call${this.capitalizeFirstLetter(curVal.name)}Api = async (${inputKeyList.length > 0 ? `input: ${inputDataTypeName},` : ``} output: (output: ${outputKeyList.length > 0 ? outputDataTypeName : dataName ? dataName : 'any'}) => any,error: (errMsg: any) => void) => {
|
|
319
|
+
export const call${this.capitalizeFirstLetter(curVal.name)}Api = async (${inputKeyList.length > 0 ? `input: ${inputDataTypeName},` : ``} output: (output: ${outputKeyList.length > 0 ? outputDataTypeName : dataName ? `${moduleName}.${dataName}` : 'any'}) => any,error: (errMsg: any) => void) => {
|
|
320
320
|
try {
|
|
321
|
-
//const { data } = await ${expressSection.name}Api.${curVal.type.toLowerCase()}('${this.getApiName(apiSection.name)}/${this.getApiName(curVal.name)}',${inputKeyList.length > 0 ? `${curVal.type == '
|
|
322
|
-
const { data } = await ${curVal.name}Api(${inputKeyList.length > 0 ? `${curVal.type == '
|
|
321
|
+
//const { data } = await ${expressSection.name}Api.${curVal.type.toLowerCase()}('${this.getApiName(apiSection.name)}/${this.getApiName(curVal.name)}',${inputKeyList.length > 0 ? `${curVal.type == 'POST' ? 'input' : '{params: input.toJSON()}'}` : ''});
|
|
322
|
+
const { data } = await ${curVal.name}Api(${inputKeyList.length > 0 ? `${curVal.type == 'POST' ? 'input' : 'input'}` : ''});
|
|
323
323
|
return output(data);
|
|
324
324
|
} catch (err: any) {
|
|
325
325
|
return error(showError(err));
|
|
@@ -100,17 +100,24 @@ import { Schema, model, connect, Types } from 'mongoose';\n
|
|
|
100
100
|
import {${interfaceName}} from './interfaces';
|
|
101
101
|
const ${collection.name}Schema = new Schema<${interfaceName}>({
|
|
102
102
|
${collection.fields.reduce((acc, currVal) => {
|
|
103
|
-
|
|
103
|
+
const type = this.getCollectionType(currVal.type);
|
|
104
|
+
acc = acc + `${currVal.name}: {type: ${type} ${currVal.required ? ',required:true' : ''} ${currVal.index ? ",index:true" : ""}${currVal.unique ? ',unique:true' : ''}${currVal.ref ? `,ref:"${currVal.ref}"` : ''}},\n\t`;
|
|
104
105
|
return acc;
|
|
105
106
|
}, "")}
|
|
106
107
|
});
|
|
107
108
|
|
|
108
|
-
const ${collection.name} = Database.${dbName}Db.model<${interfaceName}>('${collection.name}', ${collection.name}Schema);
|
|
109
|
+
const ${collection.name} = Database.${dbName}Db.model<${interfaceName}>('${collection.name}', ${collection.name}Schema,'${CommonHelper_1.CommonHelper.hyphenSepratedString(collection.name)}');
|
|
109
110
|
|
|
110
111
|
export default ${collection.name};
|
|
111
112
|
`;
|
|
112
113
|
return code;
|
|
113
114
|
}
|
|
115
|
+
getCollectionType(type) {
|
|
116
|
+
if (type.endsWith("[]")) {
|
|
117
|
+
return `[${type.slice(0, -2)}]`;
|
|
118
|
+
}
|
|
119
|
+
return type;
|
|
120
|
+
}
|
|
114
121
|
generateCollectionInterfaceCode(collectionList, dbName) {
|
|
115
122
|
const code = 'import { ObjectId } from "mongoose";\n' + collectionList.reduce((acc, collection) => {
|
|
116
123
|
acc = acc +
|
package/dist/helper/RNHelper.js
CHANGED
|
@@ -241,6 +241,13 @@ class RNHelper {
|
|
|
241
241
|
...extraProps
|
|
242
242
|
})
|
|
243
243
|
}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
export const MetaDataContainer = (props: {mdp: MDP,value?: any, onInput?: (val: any)=>void,extraProps?:object}) => {
|
|
247
|
+
const componentClassMetaData = props.mdp.getMetaData();
|
|
248
|
+
return generateElementFromMetaData({...props,componentClassMetaData})
|
|
249
|
+
}
|
|
250
|
+
|
|
244
251
|
|
|
245
252
|
|
|
246
253
|
const ComponentNameMap: any = {
|
|
@@ -183,6 +183,13 @@ export const generateElementFromMetaData = ({ componentClassMetaData, value, onI
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
|
|
186
|
+
export const MetaDataContainerWithObject = (props: {metadata: object,value?: any, onInput?: (val: any)=>void,extraProps?:object}) => {
|
|
187
|
+
const componentClassMetaData = props.metadata;
|
|
188
|
+
return generateElementFromMetaData({...props,componentClassMetaData})
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
186
193
|
|
|
187
194
|
const ComponentNameMap: any = {
|
|
188
195
|
${componentList.reduce((acc, component) => {
|
|
@@ -301,6 +308,7 @@ ${this.generateLayoutCode(lo, reactModule)}
|
|
|
301
308
|
`;
|
|
302
309
|
console.log([mainLayout], JSON.stringify([mainLayout]), "Main layout///////////////");
|
|
303
310
|
const routerJsonCode = `const router = createBrowserRouter([${this.generateLayoutRouterJSONCode([mainLayout])}])\nexport default router;`;
|
|
311
|
+
const routerConstant = this.generateRouterConstant(frontEnd.layout);
|
|
304
312
|
console.log(this.generateFlattenedArray(mainLayout.children), "this.generateFlattenedArray(mainLayout.children)");
|
|
305
313
|
const importCode = `${this.generateFlattenedArray(mainLayout.children).reduce((acc, item) => {
|
|
306
314
|
const importCode = ` ${item.children ? `
|
|
@@ -311,7 +319,7 @@ ${this.generateLayoutCode(lo, reactModule)}
|
|
|
311
319
|
acc = acc + importCode;
|
|
312
320
|
return acc;
|
|
313
321
|
}, "")}`;
|
|
314
|
-
return importCode + defaultImportCode + routerJsonCode;
|
|
322
|
+
return importCode + defaultImportCode + routerJsonCode + '\n' + routerConstant;
|
|
315
323
|
}
|
|
316
324
|
generateLayoutRouterJSONCode(layoutList) {
|
|
317
325
|
return layoutList.reduce((acc, layout) => {
|
|
@@ -354,7 +362,7 @@ ${this.generateLayoutCode(lo, reactModule)}
|
|
|
354
362
|
return acc;
|
|
355
363
|
}, {});
|
|
356
364
|
}
|
|
357
|
-
return JSON.stringify(routeObj)
|
|
365
|
+
return `export const RouterConstant = ${JSON.stringify(routeObj)}`;
|
|
358
366
|
}
|
|
359
367
|
generateLayoutCode(lo, frontEnd) {
|
|
360
368
|
return (`
|
|
@@ -1,25 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const antlr4ts_1 = require("antlr4ts");
|
|
4
7
|
const BlendApiLexer_1 = require("../../parser/blendApi/src/grammar/BlendApiLexer");
|
|
5
8
|
const BlendApiParser_1 = require("../../parser/blendApi/src/grammar/BlendApiParser");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
6
10
|
class BlendApiGrammarHelper {
|
|
7
|
-
parseBlendApi(code) {
|
|
11
|
+
parseBlendApi(code, dataModuleList) {
|
|
8
12
|
const inputStream = antlr4ts_1.CharStreams.fromString(code);
|
|
9
13
|
const lexer = new BlendApiLexer_1.BlendApiLexer(inputStream);
|
|
10
14
|
const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
|
|
11
15
|
const parser = new BlendApiParser_1.BlendApiParser(tokenStream);
|
|
12
16
|
const mainModule = parser.program();
|
|
17
|
+
let haveDuplicateSection = false;
|
|
18
|
+
let duplicateApis = {};
|
|
19
|
+
let haveNoDataFoundError = false;
|
|
20
|
+
const sectionNameList = new Set();
|
|
13
21
|
const json = {
|
|
14
22
|
name: mainModule.moduleDefinition().CAPITAL_IDENTIFIER().text,
|
|
15
23
|
apiSectionList: mainModule.sectionDefinition().map(item => {
|
|
24
|
+
if (sectionNameList.has(item.CAPITAL_IDENTIFIER().text)) {
|
|
25
|
+
console.error(`❌ Duplicate Section '${item.CAPITAL_IDENTIFIER().text}' at line ${item.start.line}`);
|
|
26
|
+
haveDuplicateSection = true;
|
|
27
|
+
}
|
|
28
|
+
const apiNameList = new Set();
|
|
16
29
|
const apiSection = {
|
|
17
30
|
name: item.CAPITAL_IDENTIFIER().text, apiList: item.apiDefinition().map(api => {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
32
|
+
const apiName = api.IDENTIFIER().text;
|
|
33
|
+
if (apiNameList.has(apiName)) {
|
|
34
|
+
duplicateApis[apiName] = true;
|
|
35
|
+
console.error(`❌ Duplicate API '${apiName}' in section '${item.CAPITAL_IDENTIFIER().text}' at line ${api.start.line}`);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
apiNameList.add(apiName);
|
|
39
|
+
}
|
|
19
40
|
const apiSpec = {
|
|
20
41
|
input: {},
|
|
21
42
|
output: {},
|
|
22
|
-
name:
|
|
43
|
+
name: apiName,
|
|
23
44
|
type: api.HTTP_METHOD().text,
|
|
24
45
|
directOutput: ((_b = (_a = api.outputDefinition()) === null || _a === void 0 ? void 0 : _a.directOutputDefenition()) === null || _b === void 0 ? void 0 : _b.type()) ? {
|
|
25
46
|
required: !((_d = (_c = api.outputDefinition()) === null || _c === void 0 ? void 0 : _c.directOutputDefenition()) === null || _d === void 0 ? void 0 : _d.type().text.includes("?")),
|
|
@@ -31,8 +52,22 @@ class BlendApiGrammarHelper {
|
|
|
31
52
|
var _a;
|
|
32
53
|
apiSpec.input[field.IDENTIFIER().text] = { type: (_a = field.type().text) === null || _a === void 0 ? void 0 : _a.replace("?", ""), required: !(field === null || field === void 0 ? void 0 : field.type().text.includes("?")) };
|
|
33
54
|
});
|
|
34
|
-
|
|
55
|
+
// console.log(JSON.stringify(api.outputDefinition()?.field()||[]),"api.outputDefinition()")
|
|
56
|
+
const customData = (_m = (_l = api.outputDefinition()) === null || _l === void 0 ? void 0 : _l.directOutputDefenition()) === null || _m === void 0 ? void 0 : _m.type().text;
|
|
57
|
+
if (customData && !dataModuleList.includes(customData === null || customData === void 0 ? void 0 : customData.split("->")[0])) {
|
|
58
|
+
console.error(`❌ No Data Module '${customData.split("->")[0]}' Found in section '${item.CAPITAL_IDENTIFIER().text}' at line ${api.start.line}`);
|
|
59
|
+
haveNoDataFoundError = true;
|
|
60
|
+
}
|
|
61
|
+
(_p = (_o = api.outputDefinition()) === null || _o === void 0 ? void 0 : _o.field()) === null || _p === void 0 ? void 0 : _p.forEach(field => {
|
|
35
62
|
var _a;
|
|
63
|
+
if (field.type().text.includes("->")) {
|
|
64
|
+
const customDataSplit = field.type().text.split("->");
|
|
65
|
+
console.log(dataModuleList, "dataModuleList....");
|
|
66
|
+
if (!dataModuleList.includes(customDataSplit[0])) {
|
|
67
|
+
console.error(`❌ No Data Module '${customDataSplit[0]}' Found in section '${item.CAPITAL_IDENTIFIER().text}' at line ${api.start.line}`);
|
|
68
|
+
haveNoDataFoundError = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
36
71
|
apiSpec.output[field.IDENTIFIER().text] = { type: (_a = field.type().text) === null || _a === void 0 ? void 0 : _a.replace("?", ""), required: !(field === null || field === void 0 ? void 0 : field.type().text.includes("?")) };
|
|
37
72
|
});
|
|
38
73
|
return apiSpec;
|
|
@@ -42,7 +77,11 @@ class BlendApiGrammarHelper {
|
|
|
42
77
|
}),
|
|
43
78
|
includedDataModuleList: []
|
|
44
79
|
};
|
|
45
|
-
return { isValid: parser.numberOfSyntaxErrors === 0, json };
|
|
80
|
+
return { isValid: parser.numberOfSyntaxErrors === 0 && Object.keys(duplicateApis).length === 0 && !haveDuplicateSection && !haveNoDataFoundError, json };
|
|
81
|
+
}
|
|
82
|
+
static getDatasInDataSection(dataSectionName, folderPath) {
|
|
83
|
+
const sectionPath = node_path_1.default.join(folderPath, `module/${dataSectionName}`);
|
|
84
|
+
// sectionData.sectionDataList.forEach(async (moduleData) => {
|
|
46
85
|
}
|
|
47
86
|
}
|
|
48
87
|
exports.default = BlendApiGrammarHelper;
|
|
@@ -20,9 +20,10 @@ class BlendMongoGrammarHelper {
|
|
|
20
20
|
var _a, _b, _c, _d, _e, _f;
|
|
21
21
|
return {
|
|
22
22
|
name: property.IDENTIFIER().text,
|
|
23
|
-
type: property.type().text,
|
|
23
|
+
type: property.type().text.replace("?", ""),
|
|
24
24
|
unique: ((_a = property.propertyChars()) === null || _a === void 0 ? void 0 : _a.mongoChars()) ? ((_c = (_b = property.propertyChars()) === null || _b === void 0 ? void 0 : _b.mongoChars()) === null || _c === void 0 ? void 0 : _c.findIndex(item => item.text === "unique")) != -1 : undefined,
|
|
25
25
|
index: ((_d = property.propertyChars()) === null || _d === void 0 ? void 0 : _d.mongoChars()) ? ((_f = (_e = property.propertyChars()) === null || _e === void 0 ? void 0 : _e.mongoChars()) === null || _f === void 0 ? void 0 : _f.findIndex(item => item.text === "index")) != -1 : undefined,
|
|
26
|
+
required: property.type().text.includes("?") ? false : true,
|
|
26
27
|
// ref: collectionDefinition.reference()?collectionDefinition.reference()?.CAPITAL_IDENTIFIER().text:undefined,
|
|
27
28
|
};
|
|
28
29
|
});
|
package/dist/index.js
CHANGED
|
@@ -114,7 +114,7 @@ program.command('prepare')
|
|
|
114
114
|
console.log(`Environment preparation complete.`);
|
|
115
115
|
});
|
|
116
116
|
// Command 3: blend-generate (add your logic here)
|
|
117
|
-
program.command('
|
|
117
|
+
program.command('serve')
|
|
118
118
|
.description('Generate files or configurations based on existing ones')
|
|
119
119
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
120
|
const folderPath = path_1.default.join(process.cwd());
|
|
@@ -142,7 +142,7 @@ program.command('generate')
|
|
|
142
142
|
// SectionHelper.createProject(basicFileContent);
|
|
143
143
|
// Add your custom logic here
|
|
144
144
|
}));
|
|
145
|
-
program.command('
|
|
145
|
+
program.command('chop')
|
|
146
146
|
.description('Generate files or configurations based on existing ones')
|
|
147
147
|
.action(() => {
|
|
148
148
|
const folderPath = path_1.default.join(process.cwd());
|