blend-kit 1.0.1

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.
Files changed (210) hide show
  1. package/dist/helper/ApiHelper.js +0 -0
  2. package/dist/helper/BasicHelper.js +28 -0
  3. package/dist/helper/CommonHelper.js +10 -0
  4. package/dist/helper/DataHelper.js +241 -0
  5. package/dist/helper/ExpressHelper.js +728 -0
  6. package/dist/helper/FrontEndApiHelper.js +485 -0
  7. package/dist/helper/FrontEndReactApiHelper.js +483 -0
  8. package/dist/helper/MongoHelper.js +143 -0
  9. package/dist/helper/RNHelper.js +560 -0
  10. package/dist/helper/ReactHelper.js +524 -0
  11. package/dist/helper/SectionHelper.js +152 -0
  12. package/dist/helper/fileHelper.js +127 -0
  13. package/dist/helper/grammarHelper/BlendApiGrammarHelper.js +48 -0
  14. package/dist/helper/grammarHelper/BlendBasicGrammarHelper.js +98 -0
  15. package/dist/helper/grammarHelper/BlendDataGrammarHelper.js +47 -0
  16. package/dist/helper/grammarHelper/BlendMDPGrammarHelper.js +29 -0
  17. package/dist/helper/grammarHelper/BlendMongoGrammarHelper.js +51 -0
  18. package/dist/helper/grammarHelper/BlendRNGrammarHelper.js +56 -0
  19. package/dist/helper/grammarHelper/BlendReactGrammarHelper.js +55 -0
  20. package/dist/helper/grammarHelper/GrammarErrorHelper.js +16 -0
  21. package/dist/index.js +159 -0
  22. package/dist/parser/blendApi/src/grammar/BlendApiLexer.js +201 -0
  23. package/dist/parser/blendApi/src/grammar/BlendApiListener.js +3 -0
  24. package/dist/parser/blendApi/src/grammar/BlendApiParser.js +961 -0
  25. package/dist/parser/blendData/src/grammar/BlendDataLexer.js +154 -0
  26. package/dist/parser/blendData/src/grammar/BlendDataListener.js +3 -0
  27. package/dist/parser/blendData/src/grammar/BlendDataParser.js +641 -0
  28. package/dist/parser/blendMDP/src/grammar/BlendMDPLexer.js +151 -0
  29. package/dist/parser/blendMDP/src/grammar/BlendMDPListener.js +3 -0
  30. package/dist/parser/blendMDP/src/grammar/BlendMDPParser.js +490 -0
  31. package/dist/parser/blendMongo/src/grammar/BlendMongoLexer.js +187 -0
  32. package/dist/parser/blendMongo/src/grammar/BlendMongoListener.js +3 -0
  33. package/dist/parser/blendMongo/src/grammar/BlendMongoParser.js +848 -0
  34. package/dist/parser/blendRN/src/grammar/BlendRNLexer.js +172 -0
  35. package/dist/parser/blendRN/src/grammar/BlendRNListener.js +3 -0
  36. package/dist/parser/blendRN/src/grammar/BlendRNParser.js +657 -0
  37. package/dist/parser/blendReact/src/grammar/BlendReactLexer.js +159 -0
  38. package/dist/parser/blendReact/src/grammar/BlendReactListener.js +3 -0
  39. package/dist/parser/blendReact/src/grammar/BlendReactParser.js +644 -0
  40. package/dist/parser/blendbasic/src/grammar/BlendBasicLexer.js +147 -0
  41. package/dist/parser/blendbasic/src/grammar/BlendBasicListener.js +3 -0
  42. package/dist/parser/blendbasic/src/grammar/BlendBasicParser.js +747 -0
  43. package/dist/src/app.js +76 -0
  44. package/dist/src/app.ts +54 -0
  45. package/dist/types/apiOperationTypes.js +13 -0
  46. package/dist/types/basicOperationTypes.js +2 -0
  47. package/dist/types/dataOperationTypes.js +2 -0
  48. package/dist/types/frontendOperationTypes.js +4 -0
  49. package/dist/types/generalTypes.js +0 -0
  50. package/dist/types/mongoOperationTypes.js +12 -0
  51. package/package.json +29 -0
  52. package/src/grammar/.antlr/ApiModuleLexer.interp +71 -0
  53. package/src/grammar/.antlr/ApiModuleLexer.java +194 -0
  54. package/src/grammar/.antlr/ApiModuleLexer.tokens +32 -0
  55. package/src/grammar/.antlr/BlendApi.interp +70 -0
  56. package/src/grammar/.antlr/BlendApi.tokens +44 -0
  57. package/src/grammar/.antlr/BlendApiLexer.interp +89 -0
  58. package/src/grammar/.antlr/BlendApiLexer.java +237 -0
  59. package/src/grammar/.antlr/BlendApiLexer.tokens +44 -0
  60. package/src/grammar/.antlr/BlendApiParser.java +767 -0
  61. package/src/grammar/.antlr/BlendBasic.interp +41 -0
  62. package/src/grammar/.antlr/BlendBasic.tokens +20 -0
  63. package/src/grammar/.antlr/BlendBasicLexer.interp +50 -0
  64. package/src/grammar/.antlr/BlendBasicLexer.java +179 -0
  65. package/src/grammar/.antlr/BlendBasicLexer.tokens +20 -0
  66. package/src/grammar/.antlr/BlendBasicParser.java +599 -0
  67. package/src/grammar/.antlr/BlendData.interp +50 -0
  68. package/src/grammar/.antlr/BlendData.tokens +29 -0
  69. package/src/grammar/.antlr/BlendDataLexer.interp +65 -0
  70. package/src/grammar/.antlr/BlendDataLexer.java +181 -0
  71. package/src/grammar/.antlr/BlendDataLexer.tokens +29 -0
  72. package/src/grammar/.antlr/BlendDataParser.java +520 -0
  73. package/src/grammar/.antlr/BlendMDP.interp +45 -0
  74. package/src/grammar/.antlr/BlendMDP.tokens +25 -0
  75. package/src/grammar/.antlr/BlendMDPLexer.interp +59 -0
  76. package/src/grammar/.antlr/BlendMDPLexer.java +178 -0
  77. package/src/grammar/.antlr/BlendMDPLexer.tokens +25 -0
  78. package/src/grammar/.antlr/BlendMDPParser.java +386 -0
  79. package/src/grammar/.antlr/BlendMongo.interp +65 -0
  80. package/src/grammar/.antlr/BlendMongo.tokens +41 -0
  81. package/src/grammar/.antlr/BlendMongoLexer.interp +83 -0
  82. package/src/grammar/.antlr/BlendMongoLexer.java +219 -0
  83. package/src/grammar/.antlr/BlendMongoLexer.tokens +41 -0
  84. package/src/grammar/.antlr/BlendMongoParser.java +669 -0
  85. package/src/grammar/.antlr/BlendRN.interp +53 -0
  86. package/src/grammar/.antlr/BlendRN.tokens +31 -0
  87. package/src/grammar/.antlr/BlendRNLexer.interp +71 -0
  88. package/src/grammar/.antlr/BlendRNLexer.java +202 -0
  89. package/src/grammar/.antlr/BlendRNLexer.tokens +31 -0
  90. package/src/grammar/.antlr/BlendRNParser.java +542 -0
  91. package/src/grammar/.antlr/BlendReact.interp +49 -0
  92. package/src/grammar/.antlr/BlendReact.tokens +28 -0
  93. package/src/grammar/.antlr/BlendReactLexer.interp +65 -0
  94. package/src/grammar/.antlr/BlendReactLexer.java +188 -0
  95. package/src/grammar/.antlr/BlendReactLexer.tokens +28 -0
  96. package/src/grammar/.antlr/BlendReactParser.java +530 -0
  97. package/src/grammar/BlendApi.g4 +26 -0
  98. package/src/grammar/BlendBasic.g4 +16 -0
  99. package/src/grammar/BlendData.g4 +24 -0
  100. package/src/grammar/BlendMDP.g4 +12 -0
  101. package/src/grammar/BlendMongo.g4 +24 -0
  102. package/src/grammar/BlendRN.g4 +18 -0
  103. package/src/grammar/BlendReact.g4 +16 -0
  104. package/src/helper/BasicHelper.ts +35 -0
  105. package/src/helper/CommonHelper.ts +5 -0
  106. package/src/helper/DataHelper.ts +268 -0
  107. package/src/helper/ExpressHelper.ts +807 -0
  108. package/src/helper/FrontEndApiHelper.ts +526 -0
  109. package/src/helper/FrontEndReactApiHelper.ts +532 -0
  110. package/src/helper/MongoHelper.ts +165 -0
  111. package/src/helper/RNHelper.ts +651 -0
  112. package/src/helper/ReactHelper.ts +597 -0
  113. package/src/helper/SectionHelper.ts +154 -0
  114. package/src/helper/fileHelper.ts +111 -0
  115. package/src/helper/grammarHelper/BlendApiGrammarHelper.ts +45 -0
  116. package/src/helper/grammarHelper/BlendBasicGrammarHelper.ts +101 -0
  117. package/src/helper/grammarHelper/BlendDataGrammarHelper.ts +49 -0
  118. package/src/helper/grammarHelper/BlendMDPGrammarHelper.ts +33 -0
  119. package/src/helper/grammarHelper/BlendMongoGrammarHelper.ts +50 -0
  120. package/src/helper/grammarHelper/BlendRNGrammarHelper.ts +65 -0
  121. package/src/helper/grammarHelper/BlendReactGrammarHelper.ts +65 -0
  122. package/src/helper/grammarHelper/GrammarErrorHelper.ts +13 -0
  123. package/src/index.ts +168 -0
  124. package/src/parser/blendApi/src/grammar/BlendApi.interp +70 -0
  125. package/src/parser/blendApi/src/grammar/BlendApi.tokens +44 -0
  126. package/src/parser/blendApi/src/grammar/BlendApiLexer.interp +89 -0
  127. package/src/parser/blendApi/src/grammar/BlendApiLexer.tokens +44 -0
  128. package/src/parser/blendApi/src/grammar/BlendApiLexer.ts +193 -0
  129. package/src/parser/blendApi/src/grammar/BlendApiListener.ts +145 -0
  130. package/src/parser/blendApi/src/grammar/BlendApiParser.ts +968 -0
  131. package/src/parser/blendData/src/grammar/BlendData.interp +50 -0
  132. package/src/parser/blendData/src/grammar/BlendData.tokens +29 -0
  133. package/src/parser/blendData/src/grammar/BlendDataLexer.interp +65 -0
  134. package/src/parser/blendData/src/grammar/BlendDataLexer.tokens +29 -0
  135. package/src/parser/blendData/src/grammar/BlendDataLexer.ts +146 -0
  136. package/src/parser/blendData/src/grammar/BlendDataListener.ts +97 -0
  137. package/src/parser/blendData/src/grammar/BlendDataParser.ts +641 -0
  138. package/src/parser/blendMDP/src/grammar/BlendMDP.interp +45 -0
  139. package/src/parser/blendMDP/src/grammar/BlendMDP.tokens +25 -0
  140. package/src/parser/blendMDP/src/grammar/BlendMDPLexer.interp +59 -0
  141. package/src/parser/blendMDP/src/grammar/BlendMDPLexer.tokens +25 -0
  142. package/src/parser/blendMDP/src/grammar/BlendMDPLexer.ts +143 -0
  143. package/src/parser/blendMDP/src/grammar/BlendMDPListener.ts +85 -0
  144. package/src/parser/blendMDP/src/grammar/BlendMDPParser.ts +483 -0
  145. package/src/parser/blendMongo/src/grammar/BlendMongo.interp +65 -0
  146. package/src/parser/blendMongo/src/grammar/BlendMongo.tokens +41 -0
  147. package/src/parser/blendMongo/src/grammar/BlendMongoLexer.interp +83 -0
  148. package/src/parser/blendMongo/src/grammar/BlendMongoLexer.tokens +41 -0
  149. package/src/parser/blendMongo/src/grammar/BlendMongoLexer.ts +179 -0
  150. package/src/parser/blendMongo/src/grammar/BlendMongoListener.ts +133 -0
  151. package/src/parser/blendMongo/src/grammar/BlendMongoParser.ts +849 -0
  152. package/src/parser/blendRN/src/grammar/BlendRN.interp +53 -0
  153. package/src/parser/blendRN/src/grammar/BlendRN.tokens +31 -0
  154. package/src/parser/blendRN/src/grammar/BlendRNLexer.interp +71 -0
  155. package/src/parser/blendRN/src/grammar/BlendRNLexer.tokens +31 -0
  156. package/src/parser/blendRN/src/grammar/BlendRNLexer.ts +164 -0
  157. package/src/parser/blendRN/src/grammar/BlendRNListener.ts +85 -0
  158. package/src/parser/blendRN/src/grammar/BlendRNParser.ts +659 -0
  159. package/src/parser/blendReact/src/grammar/BlendReact.interp +49 -0
  160. package/src/parser/blendReact/src/grammar/BlendReact.tokens +28 -0
  161. package/src/parser/blendReact/src/grammar/BlendReactLexer.interp +65 -0
  162. package/src/parser/blendReact/src/grammar/BlendReactLexer.tokens +28 -0
  163. package/src/parser/blendReact/src/grammar/BlendReactLexer.ts +151 -0
  164. package/src/parser/blendReact/src/grammar/BlendReactListener.ts +85 -0
  165. package/src/parser/blendReact/src/grammar/BlendReactParser.ts +646 -0
  166. package/src/parser/blendbasic/src/grammar/BlendBasic.interp +41 -0
  167. package/src/parser/blendbasic/src/grammar/BlendBasic.tokens +20 -0
  168. package/src/parser/blendbasic/src/grammar/BlendBasicLexer.interp +50 -0
  169. package/src/parser/blendbasic/src/grammar/BlendBasicLexer.tokens +20 -0
  170. package/src/parser/blendbasic/src/grammar/BlendBasicLexer.ts +139 -0
  171. package/src/parser/blendbasic/src/grammar/BlendBasicListener.ts +109 -0
  172. package/src/parser/blendbasic/src/grammar/BlendBasicParser.ts +747 -0
  173. package/src/types/apiOperationTypes.ts +43 -0
  174. package/src/types/basicOperationTypes.ts +15 -0
  175. package/src/types/dataOperationTypes.ts +20 -0
  176. package/src/types/frontendOperationTypes.ts +92 -0
  177. package/src/types/generalTypes.ts +0 -0
  178. package/src/types/mongoOperationTypes.ts +36 -0
  179. package/template/.env.dev +1 -0
  180. package/template/package.json +36 -0
  181. package/template/src/app.js +76 -0
  182. package/template/src/app.ts +54 -0
  183. package/template/src/config/app.config.js +0 -0
  184. package/template/src/config/app.config.ts +0 -0
  185. package/template/src/config/database.config.js +6 -0
  186. package/template/src/config/database.config.ts +4 -0
  187. package/template/src/data/interfaces.js +2 -0
  188. package/template/src/data/interfaces.ts +23 -0
  189. package/template/src/middlewares/auth.js +22 -0
  190. package/template/src/middlewares/auth.ts +21 -0
  191. package/template/src/models/Database.js +10 -0
  192. package/template/src/models/Database.ts +8 -0
  193. package/template/src/models/User/Permission.model.js +13 -0
  194. package/template/src/models/User/Permission.model.ts +14 -0
  195. package/template/src/models/User/Role.model.js +13 -0
  196. package/template/src/models/User/Role.model.ts +14 -0
  197. package/template/src/models/User/User.model.js +17 -0
  198. package/template/src/models/User/User.model.ts +18 -0
  199. package/template/src/routes/User.routes.js +47 -0
  200. package/template/src/routes/User.routes.ts +41 -0
  201. package/template/src/routes/common/common.routes.config.js +14 -0
  202. package/template/src/routes/common/common.routes.config.ts +15 -0
  203. package/template/src/services/User/User.service.js +75 -0
  204. package/template/src/services/User/User.service.ts +68 -0
  205. package/template/src/services/User/api.data.js +72 -0
  206. package/template/src/services/User/api.data.ts +79 -0
  207. package/template/src/services/User/api.interface.js +3 -0
  208. package/template/src/services/User/api.interface.ts +10 -0
  209. package/template/tsconfig.json +10 -0
  210. package/tsconfig.json +13 -0
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FileHelper = void 0;
16
+ // fileHelper.ts
17
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
+ const path_1 = __importDefault(require("path"));
19
+ class FileHelper {
20
+ // Ensure a directory exists, create it if it doesn't
21
+ static ensureDir(folderPath) {
22
+ try {
23
+ fs_extra_1.default.ensureDirSync(folderPath);
24
+ }
25
+ catch (error) {
26
+ console.error(`Error ensuring directory: ${error.message}`);
27
+ throw error;
28
+ }
29
+ }
30
+ static writeFile(filePath, content) {
31
+ try {
32
+ // Ensure the folder exists
33
+ const folderPath = path_1.default.dirname(filePath);
34
+ this.ensureDir(folderPath);
35
+ // Write the file
36
+ fs_extra_1.default.writeFileSync(filePath, content);
37
+ }
38
+ catch (error) {
39
+ console.error(`Error writing file at ${filePath}: ${error.message}`);
40
+ throw error;
41
+ }
42
+ }
43
+ static createFile(filePath, content) {
44
+ try {
45
+ // Ensure the folder exists
46
+ const folderPath = path_1.default.dirname(filePath);
47
+ this.ensureDir(folderPath);
48
+ if (!fs_extra_1.default.existsSync(filePath)) {
49
+ fs_extra_1.default.writeFileSync(filePath, content);
50
+ }
51
+ // Write the file
52
+ }
53
+ catch (error) {
54
+ console.error(`Error writing file at ${filePath}: ${error.message}`);
55
+ throw error;
56
+ }
57
+ }
58
+ // Read content from a file
59
+ static readFile(filePath) {
60
+ try {
61
+ return fs_extra_1.default.readFileSync(filePath, 'utf-8');
62
+ }
63
+ catch (error) {
64
+ console.error(`Error reading file at ${filePath}: ${error.message}`);
65
+ throw error;
66
+ }
67
+ }
68
+ // Write a JSON object to a file, ensuring the folder exists
69
+ static writeJson(filePath, jsonContent) {
70
+ try {
71
+ // Ensure the folder exists
72
+ const folderPath = path_1.default.dirname(filePath);
73
+ this.ensureDir(folderPath);
74
+ // Write the JSON file
75
+ fs_extra_1.default.writeJsonSync(filePath, jsonContent, { spaces: 2 });
76
+ }
77
+ catch (error) {
78
+ console.error(`Error writing JSON to ${filePath}: ${error.message}`);
79
+ throw error;
80
+ }
81
+ }
82
+ // Check if a file or directory exists
83
+ static exists(filePath) {
84
+ try {
85
+ return fs_extra_1.default.existsSync(filePath);
86
+ }
87
+ catch (error) {
88
+ console.error(`Error checking existence of ${filePath}: ${error.message}`);
89
+ throw error;
90
+ }
91
+ }
92
+ // Copy a file from source to destination, ensuring the destination folder exists
93
+ static copyFile(srcPath, destPath) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ try {
96
+ // Ensure the destination folder exists
97
+ yield fs_extra_1.default.ensureDir(path_1.default.dirname(destPath));
98
+ // Copy the file
99
+ yield fs_extra_1.default.copyFile(srcPath, destPath);
100
+ console.log(`File copied from ${srcPath} to ${destPath}`);
101
+ }
102
+ catch (error) {
103
+ console.error(`Error copying file from ${srcPath} to ${destPath}: ${error.message}`);
104
+ throw error;
105
+ }
106
+ });
107
+ }
108
+ /**
109
+ * Copies an entire folder from source to destination, including its contents.
110
+ * @param srcFolder The path to the source folder.
111
+ * @param destFolder The path to the destination folder.
112
+ */
113
+ static copyFolder(srcFolder, destFolder) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ try {
116
+ // Copy the folder recursively
117
+ yield fs_extra_1.default.copy(srcFolder, destFolder, { overwrite: true });
118
+ console.log(`Folder copied from ${srcFolder} to ${destFolder}`);
119
+ }
120
+ catch (error) {
121
+ console.error(`Error copying folder from ${srcFolder} to ${destFolder}: ${error.message}`);
122
+ throw error;
123
+ }
124
+ });
125
+ }
126
+ }
127
+ exports.FileHelper = FileHelper;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const antlr4ts_1 = require("antlr4ts");
4
+ const BlendApiLexer_1 = require("../../parser/blendApi/src/grammar/BlendApiLexer");
5
+ const BlendApiParser_1 = require("../../parser/blendApi/src/grammar/BlendApiParser");
6
+ class BlendApiGrammarHelper {
7
+ parseBlendApi(code) {
8
+ const inputStream = antlr4ts_1.CharStreams.fromString(code);
9
+ const lexer = new BlendApiLexer_1.BlendApiLexer(inputStream);
10
+ const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
11
+ const parser = new BlendApiParser_1.BlendApiParser(tokenStream);
12
+ const mainModule = parser.program();
13
+ const json = {
14
+ name: mainModule.moduleDefinition().CAPITAL_IDENTIFIER().text,
15
+ apiSectionList: mainModule.sectionDefinition().map(item => {
16
+ const apiSection = {
17
+ name: item.CAPITAL_IDENTIFIER().text, apiList: item.apiDefinition().map(api => {
18
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
19
+ const apiSpec = {
20
+ input: {},
21
+ output: {},
22
+ name: api.IDENTIFIER().text,
23
+ type: api.HTTP_METHOD().text,
24
+ directOutput: ((_b = (_a = api.outputDefinition()) === null || _a === void 0 ? void 0 : _a.directOutputDefenition()) === null || _b === void 0 ? void 0 : _b.type()) ? {
25
+ required: !((_d = (_c = api.outputDefinition()) === null || _c === void 0 ? void 0 : _c.directOutputDefenition()) === null || _d === void 0 ? void 0 : _d.type().text.includes("?")),
26
+ name: (_g = (_f = (_e = api.outputDefinition()) === null || _e === void 0 ? void 0 : _e.directOutputDefenition()) === null || _f === void 0 ? void 0 : _f.type().text) === null || _g === void 0 ? void 0 : _g.replace("?", ""),
27
+ } : {},
28
+ authenticated: ((_h = api === null || api === void 0 ? void 0 : api.authenticated()) === null || _h === void 0 ? void 0 : _h.text) == "authenticated"
29
+ };
30
+ (_k = (_j = api.inputDefinition()) === null || _j === void 0 ? void 0 : _j.field()) === null || _k === void 0 ? void 0 : _k.forEach(field => {
31
+ var _a;
32
+ 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
+ });
34
+ (_m = (_l = api.outputDefinition()) === null || _l === void 0 ? void 0 : _l.field()) === null || _m === void 0 ? void 0 : _m.forEach(field => {
35
+ var _a;
36
+ 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
+ });
38
+ return apiSpec;
39
+ })
40
+ };
41
+ return apiSection;
42
+ }),
43
+ includedDataModuleList: []
44
+ };
45
+ return { isValid: parser.numberOfSyntaxErrors === 0, json };
46
+ }
47
+ }
48
+ exports.default = BlendApiGrammarHelper;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const antlr4ts_1 = require("antlr4ts");
4
+ const BlendBasicLexer_1 = require("../../parser/blendbasic/src/grammar/BlendBasicLexer");
5
+ const BlendBasicParser_1 = require("../../parser/blendbasic/src/grammar/BlendBasicParser");
6
+ const AbstractParseTreeVisitor_1 = require("antlr4ts/tree/AbstractParseTreeVisitor");
7
+ class BlendBasicGrammarHelper extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
8
+ defaultResult() {
9
+ return {}; // Avoid errors if visitChildren returns nothing
10
+ }
11
+ parseBlendBasic(code) {
12
+ const inputStream = antlr4ts_1.CharStreams.fromString(code);
13
+ const lexer = new BlendBasicLexer_1.BlendBasicLexer(inputStream);
14
+ const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
15
+ const parser = new BlendBasicParser_1.BlendBasicParser(tokenStream);
16
+ const sectionsList = parser.sections(); // Assuming the root rule is "program" that contains multiple sections
17
+ const sections = sectionsList.section().map(section => this.visitSection(section));
18
+ const basicJson = {
19
+ name: "BlendBasicConfig",
20
+ description: "Basic config for swing",
21
+ createdAt: new Date().toISOString(),
22
+ sectionList: sections
23
+ };
24
+ return { valid: parser.numberOfSyntaxErrors === 0, basicJson };
25
+ }
26
+ visitSection(ctx) {
27
+ const sectionName = ctx.IDENTIFIER().text;
28
+ // Lists for categorized modules
29
+ const dataModuleList = [];
30
+ const expressModuleList = [];
31
+ const rnModuleList = [];
32
+ const mongoModuleList = [];
33
+ const reactModuleList = [];
34
+ ctx.module().forEach(mod => {
35
+ const resultList = this.visitModule(mod);
36
+ console.log(resultList, "resultList");
37
+ if (!resultList)
38
+ return;
39
+ resultList.map(result => {
40
+ if (result.type === "data-module") {
41
+ dataModuleList.push(result.name);
42
+ }
43
+ else if (result.type === "express-module") {
44
+ expressModuleList.push({ name: result.name });
45
+ }
46
+ else if (result.type === "rn-module") {
47
+ rnModuleList.push({ name: result.name });
48
+ }
49
+ else if (result.type === "mongo-module") {
50
+ mongoModuleList.push({ name: result.name });
51
+ }
52
+ else if (result.type === "react-module") {
53
+ reactModuleList.push({ name: result.name });
54
+ }
55
+ });
56
+ });
57
+ return {
58
+ name: sectionName,
59
+ dataModuleList,
60
+ expressModuleList,
61
+ rnModuleList,
62
+ mongoModuleList,
63
+ reactModuleList
64
+ };
65
+ }
66
+ visitModule(ctx) {
67
+ var _a;
68
+ // Handle multiple identifiers
69
+ const moduleType = (_a = ctx.children) === null || _a === void 0 ? void 0 : _a[0].text; // First token is the type (e.g., data-module)
70
+ console.log(moduleType, "moduleType");
71
+ if (ctx.dataModule())
72
+ return this.visitDataModule(ctx.dataModule());
73
+ if (ctx.expressModule())
74
+ return this.visitExpressModule(ctx.expressModule());
75
+ if (ctx.rnModule())
76
+ return this.visitRnModule(ctx.rnModule());
77
+ if (ctx.mongoModule())
78
+ return this.visitMongoModule(ctx.mongoModule());
79
+ if (ctx.reactModule())
80
+ return this.visitReactModule(ctx.reactModule());
81
+ }
82
+ visitDataModule(ctx) {
83
+ return ctx.IDENTIFIER().map(id => ({ type: "data-module", name: id.text }));
84
+ }
85
+ visitExpressModule(ctx) {
86
+ return ctx.IDENTIFIER().map(id => ({ type: "express-module", name: id.text }));
87
+ }
88
+ visitRnModule(ctx) {
89
+ return ctx.IDENTIFIER().map(id => ({ type: "rn-module", name: id.text }));
90
+ }
91
+ visitMongoModule(ctx) {
92
+ return ctx.IDENTIFIER().map(id => ({ type: "mongo-module", name: id.text }));
93
+ }
94
+ visitReactModule(ctx) {
95
+ return ctx.IDENTIFIER().map(id => ({ type: "react-module", name: id.text }));
96
+ }
97
+ }
98
+ exports.default = BlendBasicGrammarHelper;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const antlr4ts_1 = require("antlr4ts");
4
+ const BlendDataLexer_1 = require("../../parser/blendData/src/grammar/BlendDataLexer");
5
+ const BlendDataParser_1 = require("../../parser/blendData/src/grammar/BlendDataParser");
6
+ class BlendDataGrammarHelper {
7
+ parseBlendData(code) {
8
+ const inputStream = antlr4ts_1.CharStreams.fromString(code);
9
+ const lexer = new BlendDataLexer_1.BlendDataLexer(inputStream);
10
+ const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
11
+ const parser = new BlendDataParser_1.BlendDataParser(tokenStream);
12
+ const mainSection = parser.program(); // Assuming the root rule is "program" that contains multiple sections
13
+ const dataDefenitionList = mainSection.dataDefinition();
14
+ let hasError = false;
15
+ const dataSet = new Set();
16
+ const moduleDataObject = {
17
+ name: mainSection.moduleDefinition().CAPITAL_IDENTIFIER().text,
18
+ dataList: dataDefenitionList.map((dataDefinition) => {
19
+ const dataName = dataDefinition.CAPITAL_IDENTIFIER().text;
20
+ if (dataSet.has(dataName)) {
21
+ hasError = true;
22
+ console.log(`Duplicate Data ${dataName} found`);
23
+ }
24
+ dataSet.add(dataDefinition.CAPITAL_IDENTIFIER().text);
25
+ const fieldSet = new Set();
26
+ return {
27
+ name: dataDefinition.CAPITAL_IDENTIFIER().text,
28
+ fields: dataDefinition.field().map((field) => {
29
+ const fieldName = field.IDENTIFIER().text;
30
+ if (fieldSet.has(fieldName)) {
31
+ hasError = true;
32
+ console.log(`Field Data ${fieldName} found in ${dataName}`);
33
+ }
34
+ fieldSet.add(fieldName);
35
+ return {
36
+ name: fieldName,
37
+ requred: !field.type().text.includes("?"),
38
+ type: field.type().text.replace("?", ""),
39
+ };
40
+ })
41
+ };
42
+ })
43
+ };
44
+ return { valid: parser.numberOfSyntaxErrors === 0 && !hasError, moduleDataObject };
45
+ }
46
+ }
47
+ exports.default = BlendDataGrammarHelper;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const antlr4ts_1 = require("antlr4ts");
4
+ const AbstractParseTreeVisitor_1 = require("antlr4ts/tree/AbstractParseTreeVisitor");
5
+ const BlendMDPLexer_1 = require("../../parser/blendMDP/src/grammar/BlendMDPLexer");
6
+ const BlendMDPParser_1 = require("../../parser/blendMDP/src/grammar/BlendMDPParser");
7
+ class BlendMDPGrammarHelper extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
8
+ defaultResult() {
9
+ return {}; // Avoid errors if visitChildren returns nothing
10
+ }
11
+ parseBlendMDP(code) {
12
+ const inputStream = antlr4ts_1.CharStreams.fromString(code);
13
+ const lexer = new BlendMDPLexer_1.BlendMDPLexer(inputStream);
14
+ const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
15
+ const parser = new BlendMDPParser_1.BlendMDPParser(tokenStream);
16
+ const program = parser.program();
17
+ const mdpJson = {
18
+ name: program.moduleDefinition().CAPITAL_IDENTIFIER().text,
19
+ propsList: program.propsDefinition().propsBodyDefinition().map(propsBody => {
20
+ return {
21
+ name: propsBody.IDENTIFIER().text,
22
+ type: propsBody.CAPITAL_IDENTIFIER().text
23
+ };
24
+ })
25
+ };
26
+ return { valid: parser.numberOfSyntaxErrors === 0, mdpJson };
27
+ }
28
+ }
29
+ exports.default = BlendMDPGrammarHelper;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const antlr4ts_1 = require("antlr4ts");
4
+ const BlendMongoLexer_1 = require("../../parser/blendMongo/src/grammar/BlendMongoLexer");
5
+ const BlendMongoParser_1 = require("../../parser/blendMongo/src/grammar/BlendMongoParser");
6
+ class BlendMongoGrammarHelper {
7
+ parseBlendMongo(code) {
8
+ const inputStream = antlr4ts_1.CharStreams.fromString(code);
9
+ const lexer = new BlendMongoLexer_1.BlendMongoLexer(inputStream);
10
+ const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
11
+ const parser = new BlendMongoParser_1.BlendMongoParser(tokenStream);
12
+ const program = parser.program();
13
+ const moduleDefinition = program.moduleDefinition();
14
+ const collectionDefinitionList = program.collectionDefinition();
15
+ const json = {
16
+ dbName: moduleDefinition.CAPITAL_IDENTIFIER().text,
17
+ collectionList: collectionDefinitionList.map(collectionDefinition => {
18
+ var _a;
19
+ const propertyFields = collectionDefinition.property().map(property => {
20
+ var _a, _b, _c, _d, _e, _f;
21
+ return {
22
+ name: property.IDENTIFIER().text,
23
+ type: property.type().text,
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
+ 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
+ // ref: collectionDefinition.reference()?collectionDefinition.reference()?.CAPITAL_IDENTIFIER().text:undefined,
27
+ };
28
+ });
29
+ const referenceFields = (_a = collectionDefinition.reference()) === null || _a === void 0 ? void 0 : _a.map(reference => {
30
+ var _a, _b, _c, _d, _e, _f;
31
+ return {
32
+ name: reference.IDENTIFIER().text,
33
+ type: 'Types.ObjectId',
34
+ unique: ((_a = reference.propertyChars()) === null || _a === void 0 ? void 0 : _a.mongoChars()) ? ((_c = (_b = reference.propertyChars()) === null || _b === void 0 ? void 0 : _b.mongoChars()) === null || _c === void 0 ? void 0 : _c.findIndex(item => item.text === "unique")) != -1 : undefined,
35
+ index: ((_d = reference.propertyChars()) === null || _d === void 0 ? void 0 : _d.mongoChars()) ? ((_f = (_e = reference.propertyChars()) === null || _e === void 0 ? void 0 : _e.mongoChars()) === null || _f === void 0 ? void 0 : _f.findIndex(item => item.text === "index")) != -1 : undefined,
36
+ ref: reference === null || reference === void 0 ? void 0 : reference.CAPITAL_IDENTIFIER().text,
37
+ };
38
+ });
39
+ return {
40
+ name: collectionDefinition.CAPITAL_IDENTIFIER().text,
41
+ fields: [...propertyFields, ...referenceFields]
42
+ };
43
+ })
44
+ };
45
+ return {
46
+ isValid: parser.numberOfSyntaxErrors > 0,
47
+ json: json
48
+ };
49
+ }
50
+ }
51
+ exports.default = BlendMongoGrammarHelper;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const antlr4ts_1 = require("antlr4ts");
4
+ const BlendRNLexer_1 = require("../../parser/blendRN/src/grammar/BlendRNLexer");
5
+ const BlendRNParser_1 = require("../../parser/blendRN/src/grammar/BlendRNParser");
6
+ class BlendRNGrammarHelper {
7
+ parseBlendRN(code) {
8
+ const inputStream = antlr4ts_1.CharStreams.fromString(code);
9
+ const lexer = new BlendRNLexer_1.BlendRNLexer(inputStream);
10
+ const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
11
+ const parser = new BlendRNParser_1.BlendRNParser(tokenStream);
12
+ const program = parser.program();
13
+ let screenList = [];
14
+ let componentList = [];
15
+ program.screenDefenition().forEach(screen => {
16
+ screen.CAPITAL_IDENTIFIER().forEach(screenName => {
17
+ screenList.push({ name: screenName.text, path: screen.PATH_IDENTIFIER().text.replace(/"/g, '') });
18
+ });
19
+ });
20
+ program.componentDefenition().forEach(component => {
21
+ component.CAPITAL_IDENTIFIER().forEach(componentName => {
22
+ componentList.push({ name: componentName.text, path: component.PATH_IDENTIFIER().text.replace(/"/g, '') });
23
+ });
24
+ });
25
+ const layout = parseAndCreateLayoutAndScreen(program);
26
+ function parseAndCreateLayoutAndScreen(prgrm) {
27
+ return prgrm.layoutDefinition().map(layout => {
28
+ const layoutList = parseAndCreateLayoutAndScreen(layout);
29
+ const pageList = layout.pageDefinition().map(page => {
30
+ return {
31
+ name: page.CAPITAL_IDENTIFIER()[0].text,
32
+ route: page.PATH_IDENTIFIER().text.replace(/"/g, ''),
33
+ element: page.CAPITAL_IDENTIFIER()[1].text
34
+ };
35
+ });
36
+ return {
37
+ name: layout.CAPITAL_IDENTIFIER().text,
38
+ route: layout.PATH_IDENTIFIER().text.replace(/"/g, ''),
39
+ children: [...layoutList, ...pageList],
40
+ type: layout.LAYOUT_TYPE().text
41
+ };
42
+ });
43
+ }
44
+ const json = {
45
+ componentList,
46
+ screenList,
47
+ layout,
48
+ name: program.moduleDefinition().CAPITAL_IDENTIFIER().text
49
+ };
50
+ return {
51
+ valid: parser.numberOfSyntaxErrors == 0,
52
+ json
53
+ };
54
+ }
55
+ }
56
+ exports.default = BlendRNGrammarHelper;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const antlr4ts_1 = require("antlr4ts");
4
+ const BlendReactLexer_1 = require("../../parser/blendReact/src/grammar/BlendReactLexer");
5
+ const BlendReactParser_1 = require("../../parser/blendReact/src/grammar/BlendReactParser");
6
+ class BlendReactGrammarHelper {
7
+ parseBlendReact(code) {
8
+ const inputStream = antlr4ts_1.CharStreams.fromString(code);
9
+ const lexer = new BlendReactLexer_1.BlendReactLexer(inputStream);
10
+ const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
11
+ const parser = new BlendReactParser_1.BlendReactParser(tokenStream);
12
+ const program = parser.program();
13
+ let screenList = [];
14
+ let componentList = [];
15
+ program.screenDefenition().forEach(screen => {
16
+ screen.CAPITAL_IDENTIFIER().forEach(screenName => {
17
+ screenList.push({ name: screenName.text, path: screen.PATH_IDENTIFIER().text.replace(/"/g, '') });
18
+ });
19
+ });
20
+ program.componentDefenition().forEach(screen => {
21
+ screen.CAPITAL_IDENTIFIER().forEach(screenName => {
22
+ componentList.push({ name: screenName.text, path: screen.PATH_IDENTIFIER().text.replace(/"/g, '') });
23
+ });
24
+ });
25
+ const layout = parseAndCreateLayoutAndScreen(program);
26
+ function parseAndCreateLayoutAndScreen(prgrm) {
27
+ return prgrm.layoutDefinition().map(layout => {
28
+ const layoutList = parseAndCreateLayoutAndScreen(layout);
29
+ const pageList = layout.pageDefinition().map(page => {
30
+ return {
31
+ name: page.CAPITAL_IDENTIFIER()[0].text,
32
+ route: page.PATH_IDENTIFIER().text.replace(/"/g, ''),
33
+ element: page.CAPITAL_IDENTIFIER()[1].text
34
+ };
35
+ });
36
+ return {
37
+ name: layout.CAPITAL_IDENTIFIER().text,
38
+ route: layout.PATH_IDENTIFIER().text.replace(/"/g, ''),
39
+ children: [...layoutList, ...pageList],
40
+ };
41
+ });
42
+ }
43
+ const json = {
44
+ componentList,
45
+ screenList,
46
+ layout,
47
+ name: program.moduleDefinition().CAPITAL_IDENTIFIER().text.toLocaleLowerCase()
48
+ };
49
+ return {
50
+ valid: parser.numberOfSyntaxErrors == 0,
51
+ json
52
+ };
53
+ }
54
+ }
55
+ exports.default = BlendReactGrammarHelper;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class GrammarErrorHelper {
4
+ static validateSyntax(parser) {
5
+ const syntaxErrors = [];
6
+ parser.removeErrorListeners();
7
+ parser.addErrorListener({
8
+ syntaxError: (recognizer, offendingSymbol, line, charPositionInLine, msg, e) => {
9
+ syntaxErrors.push(`Line ${line}:${charPositionInLine} - ${msg}`);
10
+ }
11
+ });
12
+ console.log(syntaxErrors, "syntaxErrors");
13
+ return syntaxErrors;
14
+ }
15
+ }
16
+ exports.default = GrammarErrorHelper;