miqro 6.2.13 → 7.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 (217) hide show
  1. package/README.md +9 -17
  2. package/build/editor.bundle.js +11601 -10129
  3. package/build/esm/src/bin/types.js +10 -5
  4. package/build/esm/src/cluster.js +1 -1
  5. package/build/esm/src/common/arguments.d.ts +2 -1
  6. package/build/esm/src/common/arguments.js +42 -18
  7. package/build/esm/src/common/assets.d.ts +1 -1
  8. package/build/esm/src/common/assets.js +34 -13
  9. package/build/esm/src/common/esbuild.d.ts +4 -1
  10. package/build/esm/src/common/esbuild.js +31 -26
  11. package/build/esm/src/common/exit.js +4 -4
  12. package/build/esm/src/common/help.d.ts +1 -1
  13. package/build/esm/src/common/help.js +2 -2
  14. package/build/esm/src/common/jsx.d.ts +2 -3
  15. package/build/esm/src/common/jsx.js +70 -75
  16. package/build/esm/src/common/paths.d.ts +0 -1
  17. package/build/esm/src/common/paths.js +3 -3
  18. package/build/esm/src/common/watch.d.ts +0 -1
  19. package/build/esm/src/common/watch.js +4 -1
  20. package/build/esm/src/inflate/inflate-sea.js +35 -24
  21. package/build/esm/src/inflate/inflate.js +4 -4
  22. package/build/esm/src/inflate/setup-auth.js +1 -1
  23. package/build/esm/src/inflate/setup-cors.js +1 -1
  24. package/build/esm/src/inflate/setup-db.js +2 -2
  25. package/build/esm/src/inflate/setup-error.js +1 -1
  26. package/build/esm/src/inflate/setup-http.js +16 -16
  27. package/build/esm/src/inflate/setup-log.js +1 -1
  28. package/build/esm/src/inflate/setup-middleware.js +1 -1
  29. package/build/esm/src/inflate/setup-server-config.js +1 -1
  30. package/build/esm/src/inflate/setup-ws.js +1 -1
  31. package/build/esm/src/inflate/setup.doc.d.ts +2 -2
  32. package/build/esm/src/inflate/setup.doc.js +23 -2
  33. package/build/esm/src/inflate/utils/sea-utils.js +2 -2
  34. package/build/esm/src/lib.d.ts +10 -1
  35. package/build/esm/src/lib.js +16 -1
  36. package/build/esm/src/main.js +2 -1
  37. package/build/esm/src/services/app.d.ts +1 -0
  38. package/build/esm/src/services/app.js +4 -5
  39. package/build/esm/src/services/migrations.js +2 -2
  40. package/build/esm/src/services/utils/jwt.d.ts +2 -0
  41. package/build/esm/src/services/utils/jwt.js +23 -0
  42. package/build/esm/src/services/utils/middleware.d.ts +9 -0
  43. package/build/esm/src/services/utils/middleware.js +9 -0
  44. package/build/esm/src/services/utils/server-interface.js +33 -4
  45. package/build/esm/src/types.d.ts +50 -83
  46. package/build/lib.cjs +15694 -15619
  47. package/package.json +6 -8
  48. package/sea/basic-compile.base64.sh +1 -1
  49. package/sea/basic-compile.sh +1 -1
  50. package/sea/install-nodejs.sh +1 -1
  51. package/sea/node.version.tag +1 -1
  52. package/.eslintrc +0 -15
  53. package/build/esm/editor/auth.d.ts +0 -6
  54. package/build/esm/editor/auth.js +0 -41
  55. package/build/esm/editor/common/admin-interface.d.ts +0 -36
  56. package/build/esm/editor/common/admin-interface.js +0 -44
  57. package/build/esm/editor/common/constants.d.ts +0 -4
  58. package/build/esm/editor/common/constants.js +0 -20
  59. package/build/esm/editor/common/constants.server.d.ts +0 -2
  60. package/build/esm/editor/common/constants.server.js +0 -4
  61. package/build/esm/editor/common/editor-index.d.ts +0 -2
  62. package/build/esm/editor/common/editor-index.js +0 -14
  63. package/build/esm/editor/common/html-encode.d.ts +0 -1
  64. package/build/esm/editor/common/html-encode.js +0 -14
  65. package/build/esm/editor/common/log-socket.d.ts +0 -15
  66. package/build/esm/editor/common/log-socket.js +0 -70
  67. package/build/esm/editor/common/templates.d.ts +0 -11
  68. package/build/esm/editor/common/templates.js +0 -477
  69. package/build/esm/editor/components/api-preview.d.ts +0 -11
  70. package/build/esm/editor/components/api-preview.js +0 -90
  71. package/build/esm/editor/components/editor.d.ts +0 -16
  72. package/build/esm/editor/components/editor.js +0 -365
  73. package/build/esm/editor/components/file-browser.d.ts +0 -37
  74. package/build/esm/editor/components/file-browser.js +0 -126
  75. package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
  76. package/build/esm/editor/components/file-editor-toolbar.js +0 -93
  77. package/build/esm/editor/components/file-editor.d.ts +0 -32
  78. package/build/esm/editor/components/file-editor.js +0 -59
  79. package/build/esm/editor/components/filter-query.d.ts +0 -1
  80. package/build/esm/editor/components/filter-query.js +0 -22
  81. package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
  82. package/build/esm/editor/components/highlight-text-area.js +0 -125
  83. package/build/esm/editor/components/log-viewer.d.ts +0 -6
  84. package/build/esm/editor/components/log-viewer.js +0 -69
  85. package/build/esm/editor/components/new-file.d.ts +0 -10
  86. package/build/esm/editor/components/new-file.js +0 -117
  87. package/build/esm/editor/components/scroll-query.d.ts +0 -7
  88. package/build/esm/editor/components/scroll-query.js +0 -21
  89. package/build/esm/editor/components/start-page.d.ts +0 -13
  90. package/build/esm/editor/components/start-page.js +0 -30
  91. package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -3
  92. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -29
  93. package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -5
  94. package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -49
  95. package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -4
  96. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -39
  97. package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
  98. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -149
  99. package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
  100. package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -38
  101. package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
  102. package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -46
  103. package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
  104. package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -45
  105. package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
  106. package/build/esm/editor/http/admin/editor/editor.js +0 -7
  107. package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
  108. package/build/esm/editor/http/admin/editor/index.api.js +0 -21
  109. package/build/esm/editor/server.d.ts +0 -3
  110. package/build/esm/editor/server.js +0 -49
  111. package/build/esm/editor/ws.d.ts +0 -3
  112. package/build/esm/editor/ws.js +0 -11
  113. package/build/esm/src/services/globals.d.ts +0 -3
  114. package/build/esm/src/services/globals.js +0 -182
  115. package/build/jsx.dom.js +0 -1587
  116. package/build/postject.base64.cjs +0 -1
  117. package/editor/auth.ts +0 -51
  118. package/editor/common/admin-interface.ts +0 -84
  119. package/editor/common/constants.server.ts +0 -5
  120. package/editor/common/constants.ts +0 -21
  121. package/editor/common/editor-index.tsx +0 -17
  122. package/editor/common/html-encode.ts +0 -14
  123. package/editor/common/log-socket.tsx +0 -85
  124. package/editor/common/templates.ts +0 -481
  125. package/editor/components/api-preview.tsx +0 -116
  126. package/editor/components/editor.tsx +0 -494
  127. package/editor/components/file-browser.tsx +0 -308
  128. package/editor/components/file-editor-toolbar.tsx +0 -191
  129. package/editor/components/file-editor.tsx +0 -122
  130. package/editor/components/filter-query.tsx +0 -22
  131. package/editor/components/highlight-text-area.tsx +0 -145
  132. package/editor/components/log-viewer.tsx +0 -110
  133. package/editor/components/new-file.tsx +0 -169
  134. package/editor/components/scroll-query.tsx +0 -22
  135. package/editor/components/start-page.tsx +0 -49
  136. package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
  137. package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
  138. package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
  139. package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
  140. package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
  141. package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
  142. package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
  143. package/editor/http/admin/editor/editor.tsx +0 -8
  144. package/editor/http/admin/editor/index.api.tsx +0 -39
  145. package/editor/server.ts +0 -57
  146. package/editor/ws.ts +0 -15
  147. package/sea/types.json +0 -1
  148. package/src/bin/compile.ts +0 -35
  149. package/src/bin/doc-md.ts +0 -210
  150. package/src/bin/generate-doc.ts +0 -64
  151. package/src/bin/test.ts +0 -92
  152. package/src/bin/types.ts +0 -29
  153. package/src/cluster.ts +0 -27
  154. package/src/common/arguments.ts +0 -733
  155. package/src/common/assets.ts +0 -128
  156. package/src/common/checksum.ts +0 -58
  157. package/src/common/constants.ts +0 -18
  158. package/src/common/content-type.ts +0 -84
  159. package/src/common/esbuild.ts +0 -94
  160. package/src/common/exit.ts +0 -91
  161. package/src/common/fs.ts +0 -82
  162. package/src/common/help.ts +0 -60
  163. package/src/common/jsx.ts +0 -547
  164. package/src/common/jwt.ts +0 -85
  165. package/src/common/paths.ts +0 -107
  166. package/src/common/watch.ts +0 -85
  167. package/src/inflate/inflate-sea.ts +0 -226
  168. package/src/inflate/inflate.ts +0 -101
  169. package/src/inflate/md.ts +0 -25
  170. package/src/inflate/setup-auth.ts +0 -41
  171. package/src/inflate/setup-cors.ts +0 -41
  172. package/src/inflate/setup-db.ts +0 -117
  173. package/src/inflate/setup-error.ts +0 -44
  174. package/src/inflate/setup-http.ts +0 -704
  175. package/src/inflate/setup-log.ts +0 -45
  176. package/src/inflate/setup-middleware.ts +0 -47
  177. package/src/inflate/setup-server-config.ts +0 -48
  178. package/src/inflate/setup-test.ts +0 -23
  179. package/src/inflate/setup-ws.ts +0 -50
  180. package/src/inflate/setup.doc.ts +0 -68
  181. package/src/inflate/utils/sea-utils.ts +0 -14
  182. package/src/lib.ts +0 -19
  183. package/src/main.ts +0 -100
  184. package/src/services/app.ts +0 -698
  185. package/src/services/editor.tsx +0 -101
  186. package/src/services/globals.ts +0 -186
  187. package/src/services/hot-reload.ts +0 -51
  188. package/src/services/migrations.ts +0 -68
  189. package/src/services/utils/admin-interface.ts +0 -37
  190. package/src/services/utils/cache.ts +0 -88
  191. package/src/services/utils/cluster-cache.ts +0 -230
  192. package/src/services/utils/cluster-ws.ts +0 -202
  193. package/src/services/utils/db-manager.ts +0 -92
  194. package/src/services/utils/get-route.ts +0 -70
  195. package/src/services/utils/log-transport.ts +0 -81
  196. package/src/services/utils/log.ts +0 -92
  197. package/src/services/utils/server-interface.ts +0 -92
  198. package/src/services/utils/websocketmanager.ts +0 -157
  199. package/src/types/@esbuild.d.ts +0 -1
  200. package/src/types/@miqro/core.d.ts +0 -2
  201. package/src/types/@miqro/jsx.d.ts +0 -2
  202. package/src/types/@miqro/parser.d.ts +0 -2
  203. package/src/types/@miqro/query.d.ts +0 -2
  204. package/src/types/@miqro/request.d.ts +0 -2
  205. package/src/types/@miqro/test.d.ts +0 -2
  206. package/src/types/@miqro.d.ts +0 -1
  207. package/src/types/@types.d.ts +0 -1
  208. package/src/types/browser.globals.d.ts +0 -1
  209. package/src/types/cookie.d.ts +0 -2
  210. package/src/types/globals.d.ts +0 -2
  211. package/src/types/jose.d.ts +0 -2
  212. package/src/types/jsx.globals.d.ts +0 -38
  213. package/src/types/miqro.d.ts +0 -228
  214. package/src/types/postject.d.ts +0 -1
  215. package/src/types/server.globals.d.ts +0 -47
  216. package/src/types.ts +0 -304
  217. package/tsconfig.json +0 -35
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawn } from "node:child_process";
4
- import { Arguments } from "../common/arguments.js";
5
- import { EXIT_CODES } from "../common/constants.js";
6
-
7
- export async function compileSH(args: Arguments) {
8
- return new Promise<void>((resolve, reject) => {
9
- try {
10
- process.chdir(args.inflateDir);
11
- const proc = spawn(`sh`, ["./compile.sh"]);
12
-
13
- proc.stdout.on('data', (data) => {
14
- console.log(`${data}`);
15
- });
16
-
17
- proc.stderr.on('data', (data) => {
18
- console.log(`${data}`);
19
- });
20
-
21
- proc.on('close', (code) => {
22
- console.log(`compilation exited with code ${code}`);
23
-
24
- if (code !== 0) {
25
- process.exit(code);
26
- } else {
27
- process.exit(EXIT_CODES.NORMAL_EXIT);
28
- }
29
- resolve();
30
- });
31
- } catch (e) {
32
- reject(e);
33
- }
34
- });
35
- }
package/src/bin/doc-md.ts DELETED
@@ -1,210 +0,0 @@
1
- import { GroupPolicy, Logger, ParserMode, RouteJSONDoc, RouterJSONDoc, SchemaProperties } from "@miqro/core";
2
- import { Schema } from "@miqro/parser";
3
-
4
- /*interface SchemaProperties {
5
- [key: string]: Schema | string;
6
- }
7
-
8
- type ParserMode = "add_extra" | "no_extra" | "remove_extra"*/
9
-
10
- export async function getMDDoc(args: { ignore?: string[], showFilePath?: boolean; jsonDoc: RouterJSONDoc }, logger?: Logger) {
11
-
12
- const pathList = Object.keys(args.jsonDoc).sort();
13
-
14
- let outMD = "";
15
-
16
- const tableIndexItems = [];
17
-
18
- for (const path of pathList) {
19
- const pathData = args.jsonDoc[path];
20
- const methods = Object.keys(pathData);
21
- for (const method of methods) {
22
- if (method) {
23
- const apiDataList: RouteJSONDoc[] = pathData[method];
24
- for (const apiData of apiDataList) {
25
- tableIndexItems.push({
26
- apiData
27
- });
28
- outMD += `## ${apiData.identifier/*.replaceAll("_", "-")*/}\n\n`;
29
- outMD += `${args.showFilePath && (apiData as any).___filePath ? (apiData as any).___filePath + "\n\n" : ""}`;
30
-
31
- if (apiData.name) {
32
- outMD += `${apiData.name}\n\n`;
33
- }
34
- if (apiData.description) {
35
- outMD += `${apiData.description}\n\n`;
36
- }
37
- outMD += `[${method}] ${path}\n\n`;
38
-
39
- outMD += `[${path}](${path}) \n\n`;
40
-
41
- if (apiData.policy) {
42
- outMD += `### policy\n\n`;
43
- outMD += policyToString(apiData.policy);
44
- }
45
- if (apiData.request) {
46
- const requestOutMD = parserToString(apiData.request);
47
- outMD += requestOutMD !== "" ? `### request\n\n${requestOutMD}` : "";
48
- }
49
- if (apiData.response && typeof apiData.response !== "boolean") {
50
- const responseOutMD = parserToString(apiData.response);
51
- outMD += responseOutMD !== "" ? `### response\n\n${responseOutMD}` : "";
52
- }
53
- }
54
- }
55
- }
56
- }
57
-
58
- const indexTable = getIndexTable(tableIndexItems);
59
-
60
- return `${indexTable}\n\n${outMD}`;
61
- }
62
-
63
- function getIndexTable(data: {
64
- apiData: RouteJSONDoc;
65
- }[]): string {
66
- return `${data.map(api => `[${api.apiData.identifier/*.replaceAll("_", "-")*/}](#${api.apiData.identifier/*.replaceAll("_", "-")*/.toLocaleLowerCase()})${api.apiData.name || api.apiData.description ? `\n\n\t${api.apiData.name ? api.apiData.name + " " : ""}${api.apiData.description ? api.apiData.description : ""}` : ""}`).join("\n\n")}`;
67
- }
68
-
69
- function policyToString(policy: GroupPolicy): string {
70
- let outMD = "| groups | policy |\n";
71
- outMD += "|--------|--------|\n";
72
- outMD += `| ${(policy.groups instanceof Array ? policy.groups : [policy.groups]).join(",")} | ${policy.groupPolicy} |\n\n`;
73
- return outMD;
74
- }
75
-
76
- export function parserToString(parser: {
77
- status?: number | number[],
78
- headers?: string | SchemaProperties | SchemaProperties[];
79
- headersMode?: ParserMode;
80
- query?: string | SchemaProperties | boolean | SchemaProperties[];
81
- queryMode?: ParserMode;
82
- params?: string | SchemaProperties | boolean | SchemaProperties[];
83
- paramsMode?: ParserMode;
84
- body?: string | SchemaProperties | boolean | SchemaProperties[];
85
- bodyMode?: ParserMode;
86
- }): string {
87
- let outMD = "";
88
- if (parser.status) {
89
- outMD += `#### status\n\n${parser.status instanceof Array ? parser.status.join(",") : parser.status}\n\n`;
90
- }
91
- if (parser.params && typeof parser.params !== "boolean") {
92
- outMD += `#### path params\n\n`;
93
- outMD += parserPartToString(parser.params, parser.paramsMode);
94
- }
95
- if (parser.headers) {
96
- outMD += `#### headers\n\n`;
97
- outMD += parserPartToString(parser.headers, parser.headersMode);
98
- }
99
- if (parser.query && parser.query !== true) {
100
- outMD += `#### query\n\n`;
101
- outMD += parserPartToString(parser.query, parser.queryMode);
102
- }
103
- if (parser.body && parser.body !== true) {
104
- outMD += `#### body\n\n`;
105
- outMD += parserPartToString(parser.body, parser.bodyMode);
106
- }
107
- return outMD;
108
- }
109
-
110
- function parserPartToString(arg: string | SchemaProperties | false | SchemaProperties[], mode?: ParserMode): string {
111
- if (arg === false) {
112
- return "not allowed";
113
- }
114
- let outMD = "";
115
- let maxTabulation = 1;
116
- const parsers: Array<SchemaProperties | string> | string = arg instanceof Array ? arg : typeof arg === "string" ? [arg] : [arg];
117
- for (const parser of parsers) {
118
- const ret = internalParserToString(parser);
119
- if (ret.maxTabulation > maxTabulation) {
120
- maxTabulation = ret.maxTabulation;
121
- }
122
- outMD += `| | | | ${getTabulation(ret.maxTabulation * 2)}\n`;
123
- outMD += `|--------|-------|-------|${getTabulation(ret.maxTabulation * 2, true)}\n`;
124
- outMD += `${ret.out}\n\n`;
125
- }
126
- return outMD
127
- }
128
-
129
- function internalParserToString(parser: string | SchemaProperties, tabulation = 1): { out: string, maxTabulation: number } {
130
- let outMD = "";
131
- let maxTabulation = tabulation;
132
- if (typeof parser === "string") {
133
- outMD += `${getTabulation(tabulation)}${parser}|\n`;
134
- } else {
135
- const attrNames = Object.keys(parser);
136
- for (const name of attrNames) {
137
- const p = parser[name];
138
- const description = typeof p === "string" ? "" : p.description ? p.description : "";
139
-
140
- if (typeof p === "string") {
141
- outMD += `${getTabulation(tabulation)}${name} | ${p}|\n`;
142
- } else if (p.type.toLocaleLowerCase() === "object" || p.type.toLocaleLowerCase() === "object?") {
143
- const rString = p.required === false || p.type.toLocaleLowerCase() === "object?" ? "?" : "";
144
- outMD += `${getTabulation(tabulation)}${name} | object${rString}| ${description}|\n`;
145
- const ret = parserBaseObjectTypeToString(p, tabulation + 1);
146
- if (maxTabulation < ret.maxTabulation) {
147
- maxTabulation = ret.maxTabulation;
148
- }
149
- outMD += `${ret.out}`;
150
- } else if (p.type.toLocaleLowerCase() === "dict" || p.type.toLocaleLowerCase() === "dict?") {
151
- const rString = p.required === false || p.type.toLocaleLowerCase() === "dict?" ? "?" : "";
152
- outMD += `${getTabulation(tabulation)}${name} | Dict\\<${p.dictType}\>${rString}| ${description}|\n`;
153
- if (p.dictType === "object") {
154
- const ret = parserBaseObjectTypeToString(p, tabulation + 1);
155
- if (maxTabulation < ret.maxTabulation) {
156
- maxTabulation = ret.maxTabulation;
157
- }
158
- outMD += `${ret.out}`;
159
- }
160
- } else if (p.type.toLocaleLowerCase() === "array" || p.type.toLocaleLowerCase() === "array?") {
161
- const rString = p.required === false || p.type.toLocaleLowerCase() === "array?" ? "?" : "";
162
- outMD += `${getTabulation(tabulation)}${name} | Array\\<${p.arrayType}\>${rString}| ${description}|\n`;
163
- if (p.arrayType.toLocaleLowerCase() === "object") {
164
- const ret = parserBaseObjectTypeToString(p, tabulation + 1);
165
- if (maxTabulation < ret.maxTabulation) {
166
- maxTabulation = ret.maxTabulation;
167
- }
168
- outMD += `${ret.out}`;
169
- }
170
- } else if (p.type.toLocaleLowerCase() === "regex") {
171
- outMD += `${getTabulation(tabulation)}${name} | ${p.regex}| ${description}|\n`;
172
- } else if (p.type.toLocaleLowerCase() === "regex?") {
173
- outMD += `${getTabulation(tabulation)}${name} | ${p.regex}?| ${description}|\n`;
174
- } else if (p.type.toLocaleLowerCase() === "enum") {
175
- outMD += `${getTabulation(tabulation)}${name} | ${p.type}| ${description}|\n`;
176
- outMD += `${getTabulation(tabulation + 1)}| ${p.enumValues?.join(",")}|\n`;
177
- if (maxTabulation < tabulation + 1) {
178
- maxTabulation = tabulation + 1;
179
- }
180
- } else if (p.type.toLocaleLowerCase() === "enum?") {
181
- outMD += `${getTabulation(tabulation)}${name} | ${p.type}?| ${description}|\n`;
182
- outMD += `${getTabulation(tabulation + 1)}| ${p.enumValues?.join(",")}|\n`;
183
- if (maxTabulation < tabulation + 1) {
184
- maxTabulation = tabulation + 1;
185
- }
186
- } else {
187
- const rString = p.required === false ? "?" : "";
188
- outMD += `${getTabulation(tabulation)}${name} | ${p.type}${rString}| ${description}|\n`;
189
- }
190
- }
191
- }
192
- return {
193
- out: outMD,
194
- maxTabulation
195
- };
196
- }
197
-
198
- function parserBaseObjectTypeToString(arg: Schema, tabulation: number): { out: string; maxTabulation: number } {
199
- const options: SchemaProperties = arg.properties ? arg.properties : {};
200
- //const outMD = `${getTabulation(tabulation)}name | type |\n${getTabulation(tabulation)}--------|--------|\n`;
201
- return internalParserToString(options, tabulation + 1);
202
- }
203
-
204
- function getTabulation(n: number, header = false) {
205
- let out = "";
206
- for (let i = 0; i < n; i++) {
207
- out += header ? "-|" : "| ";
208
- }
209
- return out;
210
- }
@@ -1,64 +0,0 @@
1
- import { Logger, Router } from "@miqro/core";
2
- import { Arguments } from "../common/arguments.js";
3
- import { writeFileSync } from "node:fs";
4
- import { getMDDoc } from "./doc-md.js";
5
- import { EXIT_CODES } from "../common/constants.js";
6
- import { InflatedResult } from "../services/app.js";
7
- import { RouteFileMap } from "../inflate/setup-http.js";
8
- import { inflateMD2HTML, inflateMDString2HTML } from "../inflate/md.js";
9
-
10
- export async function generateDocs(args: Arguments, logger: Logger, result: InflatedResult) {
11
- logger.info("writing [%s]", args.generateDocOut);
12
- writeFileSync(args.generateDocOut, await getDocOutput(result.router, result.fileMap, args.generateDocAll, args.generateDocType));
13
- }
14
-
15
- export async function getDocOutput(router: Router, fileMap: RouteFileMap, generateDocAll: boolean, generateDocType: "MD" | "JSON" | "HTML") {
16
- /*
17
- ** TODO FIX THIS MESS
18
- */
19
-
20
- const fileMapAPIRouteList = Object.keys(fileMap).map(f => fileMap[f]).filter(fMap => fMap.previewMethod === "api").map(fMap => fMap.routes);
21
-
22
- const jsonDoc = router.getJSONDoc();
23
-
24
- if (!generateDocAll) {
25
- Object.keys(jsonDoc).forEach(path => {
26
- const methods = Object.keys(jsonDoc[path]);
27
- methods.forEach(method => {
28
- const data = jsonDoc[path][method];
29
- //console.log("[%s] [%s]", path, method);
30
-
31
- if (fileMapAPIRouteList.filter(f => {
32
- for (const r of f) {
33
- if (r.method === String(method).toUpperCase() && r.path === path) {
34
- return true;
35
- }
36
- }
37
- return false;
38
- }).length === 0) {
39
- //console.log("DELETE [%s] [%s]", path, method);
40
- delete jsonDoc[path][method];
41
- } else {
42
- //console.log("KEEP [%s] [%s]", path, method);
43
- }
44
-
45
- });
46
- });
47
- }
48
-
49
- switch (generateDocType) {
50
- case "JSON":
51
- return JSON.stringify(jsonDoc, undefined, 2);
52
- break;
53
- case "MD":
54
- return await getMDDoc({ showFilePath: true, jsonDoc });
55
- break;
56
- case "HTML":
57
- const md = await getMDDoc({ showFilePath: true, jsonDoc });
58
- const html = inflateMDString2HTML(md);
59
- return html;
60
- break;
61
- default:
62
- process.exit(EXIT_CODES.BAD_ARGUMENTS);
63
- }
64
- }
package/src/bin/test.ts DELETED
@@ -1,92 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { RequestOptions, request as reqlRequest } from "@miqro/request";
4
- import { resetGlobals, runTests } from "@miqro/test/dist/runner/common.js";
5
- import { getServicePath, TEST_SOCKET } from "../common/paths.js";
6
- import { createNodeRuntime } from "@miqro/jsx-node";
7
- import { RuntimeOptions, RuntimeShadowRootInit, RuntimeURL } from "@miqro/jsx";
8
- import { EXIT_CODES } from "../common/constants.js";
9
- import { Miqro } from "../services/app.js";
10
- import { setupTests } from "../inflate/setup-test.js";
11
-
12
- export async function testMain(app: Miqro) {
13
- const startMS = Date.now();
14
- //resetTests();
15
- resetGlobals();
16
- //const testLogger = getLogger("test");
17
- globalThis.test = {
18
- PORT: TEST_SOCKET,
19
- request: (request: RequestOptions) => reqlRequest({
20
- ...request,
21
- socketPath: TEST_SOCKET
22
- }),
23
- logger: app.logger,
24
- sleep: async (ms: number) => new Promise(resolve => setTimeout(resolve, ms)),
25
- jsx: {
26
- createRuntime: createNodeRuntime,
27
- test: (cb, args: {
28
- runtimeOptions?: {
29
- basePath?: string | null;
30
- url?: RuntimeURL;
31
- logger?: {
32
- log: Function;
33
- error: Function;
34
- };
35
- },
36
- containerOptions?: {
37
- runtimeOptions?: RuntimeOptions;
38
- shadowInit?: boolean | RuntimeShadowRootInit;
39
- };
40
- }) => {
41
- return async () => {
42
- const runtime = createNodeRuntime(args.runtimeOptions);
43
- const root = runtime.createElement("root");
44
- const container = runtime.createContainer(root, args.containerOptions);
45
- await cb(container, root, runtime);
46
- container.disconnect();
47
- }
48
- }
49
- }
50
- }
51
-
52
- for (const service of app.options.services) {
53
- const servicePath = getServicePath(service);
54
- await setupTests(app.logger, servicePath);
55
- }
56
-
57
- console.log("");
58
- app.logger.log("===starting tests===");
59
- console.log("");
60
-
61
- const ret = await runTests(undefined, app.logger);
62
-
63
- console.log("");
64
- app.logger.log("===tests ended===");
65
- if (ret.failed.length > 0) {
66
- console.log("");
67
- app.logger.error("===failed tests===");
68
- console.log("");
69
- }
70
-
71
- const took = Date.now() - startMS;
72
- ret.failed.forEach(e => {
73
- app.logger.error("\x1b[31m%s\x1b[0m", e.fullName);
74
- app.logger.error(e.error);
75
- });
76
-
77
-
78
- console.log("");
79
- app.logger.log(ret.passed + " tests passed");
80
- if (ret.failed.length > 0) {
81
- app.logger.error(ret.failed.length + " failed");
82
- } else {
83
- app.logger.log(ret.failed.length + " failed");
84
- }
85
-
86
- app.logger.log("took " + took + "ms");
87
-
88
- if (ret.failed.length > 0) {
89
- process.exit(EXIT_CODES.TEST_FAILED);
90
- }
91
- await app.dbManager.closeAll();
92
- }
package/src/bin/types.ts DELETED
@@ -1,29 +0,0 @@
1
- import { MinimalLogger } from "@miqro/core";
2
- import { Arguments } from "../common/arguments.js";
3
- import { initTypes } from "../common/assets.js";
4
- import { existsSync, writeFileSync } from "node:fs";
5
- import { TEMPLATES } from "../../editor/common/templates.js";
6
- import { EXIT_CODES } from "../common/constants.js";
7
-
8
- export async function installTypings(args: Arguments, logger: MinimalLogger) {
9
- if (args.installTypes) {
10
- logger.debug("writing types");
11
- // install typing for typescript only if argument --install-types is set
12
- await initTypes(logger);
13
- }
14
- if (args.installTSConfig && !existsSync("tsconfig.json")) {
15
- logger.info("writing tsconfig.json");
16
- writeFileSync("tsconfig.json", TEMPLATES["TSCONFIGJSON"].template("", ""));
17
- } else if (args.installTSConfig) {
18
- logger.error("tsconfig.json already exists!");
19
- process.exit(EXIT_CODES.ABNORMAL);
20
- }
21
- if (args.installMiqroJSON && !existsSync("miqro.json")) {
22
- logger.info("writing miqro.json");
23
- writeFileSync("miqro.json", TEMPLATES["MIQROJSON"].template("", ""));
24
- } else if (args.installMiqroJSON) {
25
- logger.error("miqro.json already exists!");
26
- process.exit(EXIT_CODES.ABNORMAL);
27
- }
28
- process.exit(EXIT_CODES.NORMAL_EXIT);
29
- }
package/src/cluster.ts DELETED
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { mainPath } from "@miqro/runner";
4
- import { dirname, resolve } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { execSync } from "node:child_process";
7
- import { parseArguments } from "./common/arguments.js";
8
- import { checkEnvVariable } from "@miqro/core";
9
- import { cpus } from "node:os";
10
-
11
- const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import.meta.url))) : null;
12
-
13
- //const usage = "CLUSTER_COUNT=os.cpus().length [CLUSTER_AUTO_BROADCAST=true|false] [CLUSTER_DISABLE_RESTART=true|false]";
14
-
15
- const CLUSTER_COUNT = checkEnvVariable("CLUSTER_COUNT", String(cpus().length));
16
-
17
- const args = parseArguments();
18
-
19
- if (args.inflate || args.test || args.compile || args.installTSConfig || args.installTypes || args.migrateDown || args.migrateUp) {
20
- await import("./main.js");
21
- } else {
22
- const CMD = `CLUSTER_COUNT=${CLUSTER_COUNT} CLUSTER_AUTO_BROADCAST=true ${process.argv[0]} ${mainPath()} ${resolve(__package_dirname, "main.js")} ${process.argv.slice(2).join(" ")}`;
23
-
24
- console.log(CMD);
25
-
26
- execSync(CMD, { stdio: 'inherit' });
27
- }