web_api_base 3.5.1 → 3.6.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.
Files changed (58) hide show
  1. package/dist/Application.d.ts +4 -1
  2. package/dist/Application.js +30 -8
  3. package/dist/Application.js.map +1 -1
  4. package/dist/ApplicationConfiguration.d.ts +3 -2
  5. package/dist/ApplicationConfiguration.js +13 -18
  6. package/dist/ApplicationConfiguration.js.map +1 -1
  7. package/dist/bin/CreateApplication.js +4 -1
  8. package/dist/bin/CreateApplication.js.map +1 -1
  9. package/dist/bin/CreateController.js +2 -1
  10. package/dist/bin/CreateController.js.map +1 -1
  11. package/dist/decorators/controllers/ControllerDecorators.d.ts +2 -3
  12. package/dist/decorators/controllers/ControllerDecorators.js +6 -6
  13. package/dist/decorators/controllers/ControllerDecorators.js.map +1 -1
  14. package/dist/decorators/documentation/DocumentationDecorators.d.ts +17 -0
  15. package/dist/decorators/documentation/DocumentationDecorators.js +39 -0
  16. package/dist/decorators/documentation/DocumentationDecorators.js.map +1 -0
  17. package/dist/dependencyInjection/DependecyService.js +6 -2
  18. package/dist/dependencyInjection/DependecyService.js.map +1 -1
  19. package/dist/documentation/CSS.d.ts +6 -0
  20. package/dist/documentation/CSS.js +293 -0
  21. package/dist/documentation/CSS.js.map +1 -0
  22. package/dist/documentation/Documentation.d.ts +7 -0
  23. package/dist/documentation/Documentation.js +81 -0
  24. package/dist/documentation/Documentation.js.map +1 -0
  25. package/dist/documentation/HTML.d.ts +4 -0
  26. package/dist/documentation/HTML.js +26 -0
  27. package/dist/documentation/HTML.js.map +1 -0
  28. package/dist/documentation/JS.d.ts +5 -0
  29. package/dist/documentation/JS.js +239 -0
  30. package/dist/documentation/JS.js.map +1 -0
  31. package/dist/exceptions/ArgumentNullException.d.ts +3 -0
  32. package/dist/exceptions/ArgumentNullException.js +10 -0
  33. package/dist/exceptions/ArgumentNullException.js.map +1 -0
  34. package/dist/exceptions/FindDependencyException.d.ts +3 -0
  35. package/dist/exceptions/FindDependencyException.js +10 -0
  36. package/dist/exceptions/FindDependencyException.js.map +1 -0
  37. package/dist/index.d.ts +4 -0
  38. package/dist/index.js +17 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/interfaces/IApplication.d.ts +1 -0
  41. package/dist/interfaces/IApplicationConfiguration.d.ts +2 -1
  42. package/dist/metadata/Type.d.ts +4 -0
  43. package/dist/metadata/Type.js +37 -0
  44. package/dist/metadata/Type.js.map +1 -0
  45. package/package.json +1 -1
  46. package/readme.md +64 -1
  47. package/dist/temp/Application.d.ts +0 -5
  48. package/dist/temp/Application.js +0 -27
  49. package/dist/temp/Application.js.map +0 -1
  50. package/dist/temp/Index.d.ts +0 -1
  51. package/dist/temp/Index.js +0 -19
  52. package/dist/temp/Index.js.map +0 -1
  53. package/dist/temp/controllers/StatusController.d.ts +0 -21
  54. package/dist/temp/controllers/StatusController.js +0 -117
  55. package/dist/temp/controllers/StatusController.js.map +0 -1
  56. package/dist/temp/service/SampleService.d.ts +0 -9
  57. package/dist/temp/service/SampleService.js +0 -19
  58. package/dist/temp/service/SampleService.js.map +0 -1
@@ -0,0 +1,293 @@
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
+ const fs_1 = __importDefault(require("fs"));
7
+ class CSS {
8
+ static Save() {
9
+ let theme = CSS._light;
10
+ if (process.argv.indexOf("--dark") > -1 || process.argv.indexOf("--DARK") > -1)
11
+ theme = CSS._dark;
12
+ fs_1.default.writeFileSync(`${__dirname}\\style.css`, theme + '\r\n' + CSS._css, 'utf-8');
13
+ }
14
+ }
15
+ exports.default = CSS;
16
+ CSS._dark = `
17
+ :root
18
+ {
19
+ --c-from : rgb(39, 39, 39);
20
+ --c-to : rgba(53, 53, 53, 0);
21
+ --g-from : rgb(24, 24, 24);
22
+ --g-to : rgb(34, 33, 33);
23
+ --b-from : rgba(78, 121, 185, 0.87);
24
+ --b-to : rgba(33, 95, 189, 0.842);
25
+ --t-from : rgb(27, 27, 27);
26
+ --t-to : rgb(10, 10, 10);
27
+ --b-from-hover : rgba(5, 42, 85, 0.733);
28
+ --b-to-hover : rgba(6, 52, 150, 0.705);
29
+ --borders : rgba(116, 116, 116, 0.384);
30
+ --h1-color : rgb(231, 231, 231);
31
+ --h2-color : rgb(211, 210, 210);
32
+ --h-from : rgb(7, 7, 7);
33
+ --h-to : rgb(26, 26, 26);
34
+ --tx-color : rgb(199, 226, 136);
35
+ --b-color : rgb(233, 233, 233);
36
+ }`;
37
+ CSS._light = `
38
+ :root
39
+ {
40
+ --c-from : rgb(245, 245, 245);
41
+ --c-to : rgba(238, 238, 238, 0);
42
+ --g-from : rgb(240, 240, 240);
43
+ --g-to : rgb(255, 255, 255);
44
+ --b-from : rgba(78, 121, 185, 0.87);
45
+ --b-to : rgba(33, 95, 189, 0.842);
46
+ --t-from : rgb(240, 240, 240);
47
+ --t-to : rgb(255, 255, 255);
48
+ --b-from-hover : rgba(5, 42, 85, 0.733);
49
+ --b-to-hover : rgba(6, 52, 150, 0.705);
50
+ --borders : rgba(116, 116, 116, 0.384);
51
+ --h1-color : rgb(94, 147, 226);
52
+ --h2-color : rgb(104, 111, 209);
53
+ --tx-color : rgb(73, 73, 73);
54
+ --b-color : rgb(233, 233, 233);
55
+ }
56
+ `;
57
+ CSS._css = `
58
+
59
+ body
60
+ {
61
+ background-image: linear-gradient(to right, var(--g-from) , var(--g-to));
62
+ }
63
+
64
+ .header
65
+ {
66
+ background-image: linear-gradient(to right, var(--h-from) , var(--h-to));
67
+ height: 40px;
68
+ display: flex;
69
+ flex-direction: row;
70
+ justify-content: center;
71
+ align-items: center;
72
+ color: var(--h1-color);
73
+ padding: 10px;
74
+ }
75
+
76
+ .DivHeader {
77
+ width: 50%;
78
+ }
79
+
80
+ .DivHeaderRight {
81
+ display: flex;
82
+ flex-direction: column;
83
+ align-items: end;
84
+ }
85
+
86
+ .DivHeaderRight p {
87
+ height: 15px;
88
+ font-size: 10px;
89
+ margin: 1px;
90
+ }
91
+
92
+ a
93
+ {
94
+ font-weight: 600;
95
+ cursor: pointer;
96
+ color: var(--h1-color);
97
+ text-decoration: none;
98
+ }
99
+
100
+
101
+ #root
102
+ {
103
+ position: absolute;
104
+ top: 0%;
105
+ left : 0%;
106
+ width: 100%;
107
+ height: 100%;
108
+ background-image: linear-gradient(to right, var(--g-from) , var(--g-to));
109
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
110
+
111
+ }
112
+
113
+ h1{
114
+ font-size: 15px;
115
+ font-style: normal;
116
+ font-weight: 400;
117
+ text-align: left;
118
+ color: var(--h1-color);
119
+
120
+ }
121
+
122
+ verb
123
+ {
124
+ font-size: 12px;
125
+ font-weight: 600;
126
+ }
127
+
128
+ h2{
129
+ font-size: 12px;
130
+ font-style: normal;
131
+ font-weight: 400;
132
+ text-align: left;
133
+ color: var(--h2-color);
134
+ cursor: pointer;
135
+ }
136
+
137
+ h3{
138
+ font-size: 11px;
139
+ font-style: normal;
140
+ font-weight: 400;
141
+ text-align: left;
142
+ color: var(--h2-color);
143
+ }
144
+
145
+ .container
146
+ {
147
+ display: none;
148
+ flex-direction: column;
149
+ justify-content: center;
150
+ }
151
+
152
+ .btn-container
153
+ {
154
+ display: flex;
155
+ flex-direction: column;
156
+ justify-content: center;
157
+ align-items: start;
158
+ padding-top: 5px;
159
+
160
+ }
161
+
162
+ .token-container
163
+ {
164
+ display: flex;
165
+ flex-direction: row;
166
+ align-items: start;
167
+ padding-top: 5px;
168
+
169
+
170
+ }
171
+
172
+ textarea, input
173
+ {
174
+ padding: 10px;
175
+ border: 1px solid var(--borders);
176
+ background-image: linear-gradient(to right, var(--t-from) , var(--t-to));
177
+ color: var(--tx-color);
178
+ outline: none;
179
+ height: 80px;
180
+ }
181
+
182
+ input
183
+ {
184
+ padding: 2px;
185
+ width: calc(30% - 5px);
186
+ height: 20px;
187
+ }
188
+
189
+ .card
190
+ {
191
+
192
+ padding: 10px;
193
+ width: calc(100% - 20px);
194
+ background-image: linear-gradient(to right, var(--c-from) , var(--c-to));
195
+ display: block;
196
+
197
+ }
198
+
199
+ .colapsed
200
+ {
201
+ overflow: auto;
202
+ display: none;
203
+ height: 30px;
204
+ }
205
+
206
+ button
207
+ {
208
+ background-image: linear-gradient(to right, var(--b-from) , var(--b-to));
209
+ width: 100px;
210
+ height: 30px;
211
+ font-weight: 400;
212
+ color: var(--b-color);
213
+ border: none;
214
+ cursor: pointer;
215
+ }
216
+
217
+ button:hover
218
+ {
219
+ background-image: linear-gradient(to right, var(--b-from-hover) , var(--b-to-hover));
220
+ }
221
+
222
+
223
+ .GET
224
+ {
225
+ color: rgb(129, 190, 38);
226
+ }
227
+
228
+ .POST
229
+ {
230
+ color: rgb(235, 187, 83);
231
+ }
232
+
233
+ .PUT
234
+ {
235
+ color: rgb(204, 196, 82);
236
+ }
237
+
238
+ .DELETE
239
+ {
240
+ color: rgb(201, 111, 89);
241
+ }
242
+
243
+ .OTHER
244
+ {
245
+ color: rgb(115, 206, 223);
246
+ }
247
+
248
+ status
249
+ {
250
+ font-size: 13px;
251
+ cursor: pointer;
252
+ font-weight: 600;
253
+ margin-bottom: 2px;
254
+ }
255
+
256
+
257
+ tx
258
+ {
259
+ font-size: 11px;
260
+ font-style: normal;
261
+ font-weight: 400;
262
+ text-align: left;
263
+ color: var(--h2-color);
264
+ }
265
+
266
+
267
+
268
+ .OK
269
+ {
270
+ color: rgb(129, 190, 38);
271
+ }
272
+
273
+ .ErrorClient
274
+ {
275
+ color: rgb(204, 196, 82);
276
+ }
277
+
278
+ .ErrorServer
279
+ {
280
+ color: rgb(201, 111, 89);
281
+ }
282
+
283
+ .Info
284
+ {
285
+ color: rgb(115, 206, 223);
286
+ }
287
+
288
+
289
+
290
+
291
+
292
+ `;
293
+ //# sourceMappingURL=CSS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CSS.js","sourceRoot":"","sources":["../../documentation/CSS.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AAGpB,MAAqB,GAAG;IA2Rb,MAAM,CAAC,IAAI;QAEd,IAAI,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC;QAEvB,IAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACzE,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;QAEtB,YAAE,CAAC,aAAa,CAAC,GAAG,SAAS,aAAa,EAAE,KAAK,GAAG,MAAM,GAAE,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnF,CAAC;;AAnSL,sBAoSC;AAjSkB,SAAK,GAAG;;;;;;;;;;;;;;;;;;;;MAoBrB,CAAC;AAEY,UAAM,GAAG;;;;;;;;;;;;;;;;;;;KAmBvB,CAAC;AAEa,QAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2OrB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import IController from "../interfaces/IController";
2
+ import { Express } from "express";
3
+ export default class Documentation {
4
+ CreateDocumentation(controllers: {
5
+ new (...args: any[]): IController;
6
+ }[], app: Express): void;
7
+ }
@@ -0,0 +1,81 @@
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
+ const ControllerDecorators_1 = __importDefault(require("../decorators/controllers/ControllerDecorators"));
7
+ const HTML_1 = __importDefault(require("./HTML"));
8
+ const JS_1 = __importDefault(require("./JS"));
9
+ const CSS_1 = __importDefault(require("./CSS"));
10
+ const Type_1 = __importDefault(require("../metadata/Type"));
11
+ const DocumentationDecorators_1 = require("../decorators/documentation/DocumentationDecorators");
12
+ const child_process_1 = __importDefault(require("child_process"));
13
+ const Application_1 = __importDefault(require("../Application"));
14
+ class Documentation {
15
+ CreateDocumentation(controllers, app) {
16
+ var _a;
17
+ let documentations = [];
18
+ for (let c of controllers) {
19
+ let empty = new c();
20
+ let methods = Reflect.ownKeys(empty.constructor.prototype).filter(m => {
21
+ return typeof empty[m] == "function";
22
+ });
23
+ let route = ControllerDecorators_1.default.GetRoute(empty);
24
+ let doc = {
25
+ Id: 'c_' + documentations.length,
26
+ Route: route !== null && route !== void 0 ? route : "",
27
+ Controller: c.name,
28
+ Resources: []
29
+ };
30
+ for (let method of methods) {
31
+ let action = ControllerDecorators_1.default.GetAction(empty, method.toString());
32
+ if (!action) {
33
+ continue;
34
+ }
35
+ let verb = ControllerDecorators_1.default.GetVerb(empty, method.toString());
36
+ let fromBody = ControllerDecorators_1.default.GetFromBodyArgs(empty.constructor, method.toString());
37
+ let fromQuery = ControllerDecorators_1.default.GetFromQueryArgs(empty.constructor, method.toString());
38
+ let template = DocumentationDecorators_1.DocumentationDecorators.GetRequestJson(empty, method.toString());
39
+ if (!template && fromBody.length > 0) {
40
+ template = JSON.stringify(Type_1.default.CreateTemplateFrom(fromBody[0].Type));
41
+ }
42
+ let description = DocumentationDecorators_1.DocumentationDecorators.GetDescription(empty, method.toString());
43
+ doc.Resources.push({
44
+ Description: description !== null && description !== void 0 ? description : "",
45
+ Id: `${doc.Id}-${doc.Resources.length}`,
46
+ Route: `${route}${action}`,
47
+ Verb: (_a = verb === null || verb === void 0 ? void 0 : verb.toString()) !== null && _a !== void 0 ? _a : "GET",
48
+ Template: template !== null && template !== void 0 ? template : "",
49
+ Response: DocumentationDecorators_1.DocumentationDecorators.GetProducesResponse(empty.constructor, method.toString()),
50
+ FromBody: fromBody.map(s => { return { Field: s.Field, Type: s.Type.name }; }),
51
+ FromQuery: fromQuery.map(s => { return { Field: s.Field, Type: s.Type.name }; })
52
+ });
53
+ }
54
+ if (doc.Resources.length > 0) {
55
+ JS_1.default.Append(`AddResource(${JSON.stringify(doc)});`);
56
+ documentations.push(doc);
57
+ }
58
+ }
59
+ if (documentations.length > 0) {
60
+ JS_1.default.Save();
61
+ HTML_1.default.Save();
62
+ CSS_1.default.Save();
63
+ app.get('/playground', (_, resp) => {
64
+ resp.sendFile(`${__dirname}\\index.html`);
65
+ });
66
+ app.get('/style.css', (_, resp) => {
67
+ resp.sendFile(`${__dirname}\\style.css`);
68
+ });
69
+ app.get('/script.js', (_, resp) => {
70
+ resp.sendFile(`${__dirname}\\script.js`);
71
+ });
72
+ console.log(Application_1.default.Configurations);
73
+ child_process_1.default.exec(`start chrome.exe "http://${Application_1.default.Configurations.Host}:${Application_1.default.Configurations.Port}/playground"`, (error, stdout, stdin) => {
74
+ if (error)
75
+ console.error(error);
76
+ });
77
+ }
78
+ }
79
+ }
80
+ exports.default = Documentation;
81
+ //# sourceMappingURL=Documentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Documentation.js","sourceRoot":"","sources":["../../documentation/Documentation.ts"],"names":[],"mappings":";;;;;AAAA,0GAAmF;AAEnF,kDAA0B;AAC1B,8CAAsB;AACtB,gDAAwB;AACxB,4DAAoC;AACpC,iGAA8F;AAE9F,kEAAgC;AAChC,iEAAyC;AAEzC,MAAqB,aAAa;IACvB,mBAAmB,CAAC,WAAoD,EAAE,GAAa;;QAE1F,IAAI,cAAc,GAAiB,EAAE,CAAC;QAEtC,KAAI,IAAI,CAAC,IAAI,WAAW,EACxB;YAEI,IAAI,KAAK,GAAG,IAAI,CAAC,EAAS,CAAC;YAE3B,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KA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,CAAC,CAAC;aAC5B;SAEJ;QAED,IAAG,cAAc,CAAC,MAAM,GAAG,CAAC,EAC5B;YACI,YAAE,CAAC,IAAI,EAAE,CAAC;YACV,cAAI,CAAC,IAAI,EAAE,CAAC;YACZ,aAAG,CAAC,IAAI,EAAE,CAAC;YAEX,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;gBAE/B,IAAI,CAAC,QAAQ,CAAC,GAAG,SAAS,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;gBAE9B,IAAI,CAAC,QAAQ,CAAC,GAAG,SAAS,aAAa,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;gBAE9B,IAAI,CAAC,QAAQ,CAAC,GAAG,SAAS,aAAa,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,GAAG,CAAC,qBAAW,CAAC,cAAc,CAAC,CAAC;YACxC,uBAAG,CAAC,IAAI,CAAC,4BAA4B,qBAAW,CAAC,cAAc,CAAC,IAAI,IAAI,qBAAW,CAAC,cAAc,CAAC,IAAI,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;gBAE5I,IAAG,KAAK;oBACJ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;SACN;IACL,CAAC;CACJ;AAjGD,gCAiGC"}
@@ -0,0 +1,4 @@
1
+ export default class HTML {
2
+ private static _html;
3
+ static Save(): void;
4
+ }
@@ -0,0 +1,26 @@
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
+ const fs_1 = __importDefault(require("fs"));
7
+ class HTML {
8
+ static Save() {
9
+ fs_1.default.writeFileSync(`${__dirname}\\index.html`, HTML._html, 'utf-8');
10
+ }
11
+ }
12
+ exports.default = HTML;
13
+ HTML._html = `<!DOCTYPE html>
14
+ <html lang="en">
15
+ <head>
16
+ <meta charset="UTF-8">
17
+ <meta name="viewport" content="width=device-width, initial-scale=1">
18
+ <title>Document</title>
19
+ <link rel="stylesheet" type="text/css" href="./style.css">
20
+ </head>
21
+ <body>
22
+ <div id="root"></div>
23
+ <script src="./script.js"> </script>
24
+ </body>
25
+ </html>`;
26
+ //# sourceMappingURL=HTML.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTML.js","sourceRoot":"","sources":["../../documentation/HTML.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AAGpB,MAAqB,IAAI;IAgBd,MAAM,CAAC,IAAI;QAEd,YAAE,CAAC,aAAa,CAAC,GAAG,SAAS,cAAc,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;;AAnBL,uBAoBC;AAlBkB,UAAK,GAAG;;;;;;;;;;;;YAYf,CAAC"}
@@ -0,0 +1,5 @@
1
+ export default class JS {
2
+ private static _js;
3
+ static Append(text: string): void;
4
+ static Save(): void;
5
+ }
@@ -0,0 +1,239 @@
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
+ const fs_1 = __importDefault(require("fs"));
7
+ const Application_1 = __importDefault(require("../Application"));
8
+ class JS {
9
+ static Append(text) {
10
+ JS._js += text;
11
+ }
12
+ static Save() {
13
+ let app = "";
14
+ let version = "";
15
+ let description = "";
16
+ try {
17
+ if (fs_1.default.existsSync(`${Application_1.default.Configurations.RootPath}\\package.json`)) {
18
+ let j = JSON.parse(fs_1.default.readFileSync(`${Application_1.default.Configurations.RootPath}\\package.json`, 'utf-8'));
19
+ app = j.name;
20
+ version = j.version;
21
+ description = j.description;
22
+ this._js = this._js.replace('??APP', `${app} ${version}`);
23
+ this._js = this._js.replace('??DESC', `${description}`);
24
+ }
25
+ }
26
+ catch (err) {
27
+ console.error(err);
28
+ }
29
+ fs_1.default.writeFileSync(`${__dirname}\\script.js`, JS._js, 'utf-8');
30
+ }
31
+ }
32
+ exports.default = JS;
33
+ JS._js = `
34
+ document.getElementById('root').innerHTML += '<div class="header" ><div class="DivHeader"><p>Made with <a href="https://www.npmjs.com/package/web_api_base" target="_blank">web_api_base</a></p></div></div>';
35
+ document.getElementsByClassName('header')[0].innerHTML += '<div class="DivHeader DivHeaderRight"><p class="pTitle" style="font-size: 14px;font-weight:600;">??APP</p><p>??DESC</p></div>';
36
+
37
+ function AddResource(route)
38
+ {
39
+ console.log(route);
40
+
41
+ document.getElementById('root').innerHTML += '<div id="'+ route.Controller.toLowerCase()+'" class="card"></div>';
42
+
43
+ let root = document.getElementById(route.Controller.toLowerCase());
44
+
45
+ root.innerHTML += '<h1 >'+route.Controller+'</h1>';
46
+
47
+ for(let r of route.Resources)
48
+ {
49
+
50
+ let expandId = { ID : 'link_' + r.Id, RID : r.Id};
51
+
52
+ try{
53
+ r.Template = JSON.stringify(JSON.parse(r.Template), null, 2);
54
+ }catch{}
55
+
56
+ let verbClass = "OTHER";
57
+
58
+ if(["GET", "POST", "PUT", "DELETE"].includes(r.Verb))
59
+ {
60
+ verbClass = r.Verb
61
+ }
62
+
63
+ root.innerHTML += '<h2 id="'+ expandId.ID +'"><verb class="'+ verbClass+'">'+r.Verb+'</verb> '+window.location.origin+r.Route+'</h2>';
64
+ root.innerHTML += '<div id="'+r.Id+'_container" class="container"></div>';
65
+ let container = document.getElementById(r.Id + '_container');
66
+
67
+ for(let c of r.FromQuery)
68
+ {
69
+ container.innerHTML += '<div class="token-container"><input type="text" id="key-'+r.Id+r.FromQuery.indexOf(c)+'" placeholder="'+c.Field+'"></div>';
70
+ }
71
+
72
+ if(r.FromBody.length > 0)
73
+ container.innerHTML += '<textarea id="body-'+r.Id+'" placeholder="{}" spellcheck="false">'+r.Template+'</textarea>';
74
+
75
+
76
+ if(r.Description)
77
+ {
78
+ container.innerHTML += '<h3>'+r.Description+'</h3>';
79
+
80
+ }else {
81
+
82
+ container.innerHTML += '<h3>Use @Description(...) to add a description to a action</h3>';
83
+ }
84
+
85
+
86
+ container.innerHTML += '<div class="btn-container" ><button id="bt-'+expandId.ID+'">Send</button></div>';
87
+
88
+ if(r.Response.length > 0 && r.Response[0].JSON?.length > 0)
89
+ {
90
+ container.innerHTML += '<h3 id="response-bar-'+r.Id+'">Response'+(r.Response.length > 1 ? 's': '')+':</h3>';
91
+
92
+ container.innerHTML += '<div id="status-bar-'+r.Id+'" class="btn-container" ></div>';
93
+
94
+
95
+ for(let s of r.Response.sort((a, b)=> a.Status - b.Status))
96
+ {
97
+ let bar = document.getElementById('status-bar-'+r.Id);
98
+
99
+ let classValue = "Info";
100
+
101
+ if(s.Status.toString().indexOf('2') == 0)
102
+ {
103
+ classValue = "OK";
104
+
105
+ }else if(s.Status.toString().indexOf('4') == 0)
106
+ {
107
+ classValue = "ErrorClient";
108
+ }
109
+ else if(s.Status.toString().indexOf('5') == 0)
110
+ {
111
+ classValue = "ErrorServer";
112
+ }
113
+
114
+
115
+ bar.innerHTML += '<div><status id="status-'+r.Id+s.Status+'" class="'+classValue+'"> '+s.Status+ '</status> <tx>' + (s.Description ?? '')+'</tx></div>';
116
+
117
+ document.addEventListener('DOMContentLoaded', function() {
118
+
119
+ document.getElementById('status-'+r.Id+s.Status).addEventListener('click', function (evt) {
120
+
121
+ let textarea = document.getElementById('response-area-'+r.Id);
122
+ textarea.value = s.JSON;
123
+
124
+ });
125
+
126
+
127
+ });
128
+
129
+
130
+ }
131
+
132
+
133
+ }else{
134
+
135
+ container.innerHTML += '<h3 id="response-bar-'+r.Id+'">Response:</h3>';
136
+ container.innerHTML += '<div id="status-bar-'+r.Id+'" class="btn-container" style="display:none;" ></div>';
137
+ }
138
+
139
+ document.addEventListener('DOMContentLoaded', function() {
140
+
141
+
142
+ document.getElementById('bt-'+expandId.ID).addEventListener('click', (evt) =>
143
+ {
144
+ let body = document.getElementById('body-'+r.Id);
145
+ let resp = document.getElementById('response-area-'+r.Id);
146
+ let bar = document.getElementById('status-bar-'+r.Id);
147
+ let h3 = document.getElementById('response-bar-'+r.Id);
148
+
149
+ let req = new XMLHttpRequest();
150
+ let args = '?';
151
+ for(let c of r.FromQuery)
152
+ {
153
+ let input = document.getElementById('key-'+r.Id+r.FromQuery.indexOf(c));
154
+
155
+ args+= c.Field + '="' + input.value + '"&';
156
+ }
157
+
158
+ if(args.length > 1){
159
+ args = args.substring(0, args.length -1);
160
+ }else
161
+ {
162
+ args = '';
163
+ }
164
+
165
+ req.open(r.Verb, window.location.origin+r.Route+args, true);
166
+ req.setRequestHeader('Content-type', 'application/json');
167
+ req.onerror = ()=>
168
+ {
169
+ h3.innerText = "Current response:";
170
+ bar.style.display = "flex";
171
+ resp.value = 'Error to send the request';
172
+ bar.innerHTML = '<div><status class="ErrorServer">-1</status> <tx>Error on request</tx></div>';
173
+ }
174
+
175
+
176
+ req.onreadystatechange = ()=>
177
+ {
178
+ if(req.readyState == 4 && req.status > 0)
179
+ {
180
+ h3.innerText = "Current response:";
181
+
182
+ bar.style.display = "flex";
183
+
184
+ let classValue = "Info";
185
+
186
+ if(req.status.toString().indexOf('2') == 0)
187
+ {
188
+ classValue = "OK";
189
+
190
+ }else if(req.status.toString().indexOf('4') == 0)
191
+ {
192
+ classValue = "ErrorClient";
193
+ }
194
+ else if(req.status.toString().indexOf('5') == 0)
195
+ {
196
+ classValue = "ErrorServer";
197
+ }
198
+
199
+ console.log(req);
200
+ bar.innerHTML = '<div><status class="'+classValue+'"> '+req.status+ '</status> <tx>New request</tx></div>';
201
+ resp.value = JSON.stringify(JSON.parse(req.responseText), null, 2);
202
+ }
203
+ }
204
+
205
+ if(body){
206
+ req.send(body.value);
207
+ }else
208
+ {
209
+ req.send();
210
+ }
211
+
212
+ });
213
+ });
214
+
215
+ container.innerHTML += '<textarea id="response-area-'+r.Id+'" style="margin-top:5px"; spellcheck="false" ></textarea>';
216
+
217
+
218
+ document.addEventListener('DOMContentLoaded', function() {
219
+ document.getElementById(expandId.ID).addEventListener('click', function (evt) {
220
+
221
+ let div = document.getElementById(expandId.RID + '_container');
222
+
223
+ if(div.style.display == "flex")
224
+ div.style.display = "none";
225
+ else
226
+ div.style.display = "flex";
227
+ });
228
+
229
+ });
230
+
231
+ }
232
+
233
+
234
+
235
+ }
236
+
237
+
238
+ `;
239
+ //# sourceMappingURL=JS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JS.js","sourceRoot":"","sources":["../../documentation/JS.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,iEAAyC;AAEzC,MAAqB,EAAE;IAiNZ,MAAM,CAAC,MAAM,CAAC,IAAa;QAE9B,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,IAAI;QAEd,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI,WAAW,GAAG,EAAE,CAAC;QAErB,IAAG;YAEC,IAAG,YAAE,CAAC,UAAU,CAAC,GAAG,qBAAW,CAAC,cAAc,CAAC,QAAQ,gBAAgB,CAAC,EACxE;gBACI,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,GAAG,qBAAW,CAAC,cAAc,CAAC,QAAQ,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC;gBACrG,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC;gBACb,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC;gBACpB,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC;gBAE5B,IAAI,CAAC,GAAG,GAAG,IAAI,CAA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