miqro 7.2.6 → 7.2.7
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/README.md +1 -21
- package/build/esm/src/bin/compile.js +0 -1
- package/build/esm/src/bin/doc-md.js +0 -1
- package/build/esm/src/bin/generate-doc.js +0 -1
- package/build/esm/src/bin/test.js +0 -1
- package/build/esm/src/bin/types.js +0 -1
- package/build/esm/src/cluster.js +0 -1
- package/build/esm/src/common/arguments.js +0 -1
- package/build/esm/src/common/assets.js +2 -3
- package/build/esm/src/common/checksum.js +0 -1
- package/build/esm/src/common/constants.js +0 -1
- package/build/esm/src/common/content-type.js +0 -1
- package/build/esm/src/common/esbuild.js +0 -1
- package/build/esm/src/common/exit.js +0 -1
- package/build/esm/src/common/fs.js +0 -1
- package/build/esm/src/common/help.js +0 -1
- package/build/esm/src/common/jsx.js +0 -1
- package/build/esm/src/common/jwt.js +0 -1
- package/build/esm/src/common/paths.js +0 -1
- package/build/esm/src/common/watch.js +0 -1
- package/build/esm/src/inflate/inflate-sea.js +0 -1
- package/build/esm/src/inflate/inflate.js +0 -1
- package/build/esm/src/inflate/md.js +0 -1
- package/build/esm/src/inflate/setup-auth.js +0 -1
- package/build/esm/src/inflate/setup-cors.js +0 -1
- package/build/esm/src/inflate/setup-db.js +0 -1
- package/build/esm/src/inflate/setup-error.js +0 -1
- package/build/esm/src/inflate/setup-http.js +0 -1
- package/build/esm/src/inflate/setup-log.js +0 -1
- package/build/esm/src/inflate/setup-middleware.js +0 -1
- package/build/esm/src/inflate/setup-server-config.js +0 -1
- package/build/esm/src/inflate/setup-test.js +0 -1
- package/build/esm/src/inflate/setup-ws.js +0 -1
- package/build/esm/src/inflate/setup.doc.js +0 -1
- package/build/esm/src/inflate/utils/sea-utils.js +0 -1
- package/build/esm/src/lib.js +0 -1
- package/build/esm/src/main.js +0 -1
- package/build/esm/src/services/app.js +1 -1
- package/build/esm/src/services/editor.js +10 -12
- package/build/esm/src/services/hot-reload.js +0 -1
- package/build/esm/src/services/migrations.js +0 -1
- package/build/esm/src/services/utils/admin-interface.js +0 -1
- package/build/esm/src/services/utils/cache.js +0 -1
- package/build/esm/src/services/utils/cluster-cache.js +0 -1
- package/build/esm/src/services/utils/cluster-ws.js +0 -1
- package/build/esm/src/services/utils/db-manager.js +0 -1
- package/build/esm/src/services/utils/get-route.js +0 -1
- package/build/esm/src/services/utils/jwt.js +0 -1
- package/build/esm/src/services/utils/log-transport.js +0 -1
- package/build/esm/src/services/utils/log.js +0 -1
- package/build/esm/src/services/utils/middleware.js +0 -1
- package/build/esm/src/services/utils/server-interface.js +0 -1
- package/build/esm/src/services/utils/websocketmanager.d.ts +2 -0
- package/build/esm/src/services/utils/websocketmanager.js +8 -2
- package/build/esm/src/types.js +0 -1
- package/build/lib.cjs +27 -29
- package/build/style.css +3 -3
- package/package.json +2 -2
- package/build/esm/editor/auth.d.ts +0 -6
- package/build/esm/editor/auth.js +0 -43
- package/build/esm/editor/auth.js.map +0 -1
- package/build/esm/editor/common/admin-interface.d.ts +0 -36
- package/build/esm/editor/common/admin-interface.js +0 -45
- package/build/esm/editor/common/admin-interface.js.map +0 -1
- package/build/esm/editor/common/constants.d.ts +0 -4
- package/build/esm/editor/common/constants.js +0 -21
- package/build/esm/editor/common/constants.js.map +0 -1
- package/build/esm/editor/common/constants.server.d.ts +0 -2
- package/build/esm/editor/common/constants.server.js +0 -5
- package/build/esm/editor/common/constants.server.js.map +0 -1
- package/build/esm/editor/common/editor-index.d.ts +0 -2
- package/build/esm/editor/common/editor-index.js +0 -15
- package/build/esm/editor/common/editor-index.js.map +0 -1
- package/build/esm/editor/common/html-encode.d.ts +0 -1
- package/build/esm/editor/common/html-encode.js +0 -15
- package/build/esm/editor/common/html-encode.js.map +0 -1
- package/build/esm/editor/common/log-socket.d.ts +0 -15
- package/build/esm/editor/common/log-socket.js +0 -72
- package/build/esm/editor/common/log-socket.js.map +0 -1
- package/build/esm/editor/common/templates.d.ts +0 -11
- package/build/esm/editor/common/templates.js +0 -478
- package/build/esm/editor/common/templates.js.map +0 -1
- package/build/esm/editor/components/api-preview.d.ts +0 -11
- package/build/esm/editor/components/api-preview.js +0 -93
- package/build/esm/editor/components/api-preview.js.map +0 -1
- package/build/esm/editor/components/editor.d.ts +0 -16
- package/build/esm/editor/components/editor.js +0 -368
- package/build/esm/editor/components/editor.js.map +0 -1
- package/build/esm/editor/components/file-browser.d.ts +0 -37
- package/build/esm/editor/components/file-browser.js +0 -128
- package/build/esm/editor/components/file-browser.js.map +0 -1
- package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
- package/build/esm/editor/components/file-editor-toolbar.js +0 -96
- package/build/esm/editor/components/file-editor-toolbar.js.map +0 -1
- package/build/esm/editor/components/file-editor.d.ts +0 -32
- package/build/esm/editor/components/file-editor.js +0 -62
- package/build/esm/editor/components/file-editor.js.map +0 -1
- package/build/esm/editor/components/filter-query.d.ts +0 -1
- package/build/esm/editor/components/filter-query.js +0 -24
- package/build/esm/editor/components/filter-query.js.map +0 -1
- package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
- package/build/esm/editor/components/highlight-text-area.js +0 -128
- package/build/esm/editor/components/highlight-text-area.js.map +0 -1
- package/build/esm/editor/components/log-viewer.d.ts +0 -6
- package/build/esm/editor/components/log-viewer.js +0 -72
- package/build/esm/editor/components/log-viewer.js.map +0 -1
- package/build/esm/editor/components/new-file.d.ts +0 -10
- package/build/esm/editor/components/new-file.js +0 -120
- package/build/esm/editor/components/new-file.js.map +0 -1
- package/build/esm/editor/components/scroll-query.d.ts +0 -7
- package/build/esm/editor/components/scroll-query.js +0 -23
- package/build/esm/editor/components/scroll-query.js.map +0 -1
- package/build/esm/editor/components/start-page.d.ts +0 -13
- package/build/esm/editor/components/start-page.js +0 -33
- package/build/esm/editor/components/start-page.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -4
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -31
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -7
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -51
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -7
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -41
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -151
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -40
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -47
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -47
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
- package/build/esm/editor/http/admin/editor/editor.js +0 -9
- package/build/esm/editor/http/admin/editor/editor.js.map +0 -1
- package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/index.api.js +0 -23
- package/build/esm/editor/http/admin/editor/index.api.js.map +0 -1
- package/build/esm/editor/server.d.ts +0 -3
- package/build/esm/editor/server.js +0 -50
- package/build/esm/editor/server.js.map +0 -1
- package/build/esm/editor/ws.d.ts +0 -3
- package/build/esm/editor/ws.js +0 -12
- package/build/esm/editor/ws.js.map +0 -1
- package/build/esm/src/bin/compile.js.map +0 -1
- package/build/esm/src/bin/doc-md.js.map +0 -1
- package/build/esm/src/bin/generate-doc.js.map +0 -1
- package/build/esm/src/bin/test.js.map +0 -1
- package/build/esm/src/bin/types.js.map +0 -1
- package/build/esm/src/cluster.js.map +0 -1
- package/build/esm/src/common/arguments.js.map +0 -1
- package/build/esm/src/common/assets.js.map +0 -1
- package/build/esm/src/common/checksum.js.map +0 -1
- package/build/esm/src/common/constants.js.map +0 -1
- package/build/esm/src/common/content-type.js.map +0 -1
- package/build/esm/src/common/esbuild.js.map +0 -1
- package/build/esm/src/common/exit.js.map +0 -1
- package/build/esm/src/common/fs.js.map +0 -1
- package/build/esm/src/common/help.js.map +0 -1
- package/build/esm/src/common/jsx.js.map +0 -1
- package/build/esm/src/common/jwt.js.map +0 -1
- package/build/esm/src/common/paths.js.map +0 -1
- package/build/esm/src/common/watch.js.map +0 -1
- package/build/esm/src/inflate/inflate-sea.js.map +0 -1
- package/build/esm/src/inflate/inflate.js.map +0 -1
- package/build/esm/src/inflate/md.js.map +0 -1
- package/build/esm/src/inflate/setup-auth.js.map +0 -1
- package/build/esm/src/inflate/setup-cors.js.map +0 -1
- package/build/esm/src/inflate/setup-db.js.map +0 -1
- package/build/esm/src/inflate/setup-error.js.map +0 -1
- package/build/esm/src/inflate/setup-http.js.map +0 -1
- package/build/esm/src/inflate/setup-log.js.map +0 -1
- package/build/esm/src/inflate/setup-middleware.js.map +0 -1
- package/build/esm/src/inflate/setup-server-config.js.map +0 -1
- package/build/esm/src/inflate/setup-test.js.map +0 -1
- package/build/esm/src/inflate/setup-ws.js.map +0 -1
- package/build/esm/src/inflate/setup.doc.js.map +0 -1
- package/build/esm/src/inflate/utils/sea-utils.js.map +0 -1
- package/build/esm/src/lib.js.map +0 -1
- package/build/esm/src/main.js.map +0 -1
- package/build/esm/src/services/app.js.map +0 -1
- package/build/esm/src/services/editor.js.map +0 -1
- package/build/esm/src/services/hot-reload.js.map +0 -1
- package/build/esm/src/services/migrations.js.map +0 -1
- package/build/esm/src/services/utils/admin-interface.js.map +0 -1
- package/build/esm/src/services/utils/cache.js.map +0 -1
- package/build/esm/src/services/utils/cluster-cache.js.map +0 -1
- package/build/esm/src/services/utils/cluster-ws.js.map +0 -1
- package/build/esm/src/services/utils/db-manager.js.map +0 -1
- package/build/esm/src/services/utils/get-route.js.map +0 -1
- package/build/esm/src/services/utils/jwt.js.map +0 -1
- package/build/esm/src/services/utils/log-transport.js.map +0 -1
- package/build/esm/src/services/utils/log.js.map +0 -1
- package/build/esm/src/services/utils/middleware.js.map +0 -1
- package/build/esm/src/services/utils/server-interface.js.map +0 -1
- package/build/esm/src/services/utils/websocketmanager.js.map +0 -1
- package/build/esm/src/types.js.map +0 -1
- package/build/font.ttf +0 -0
- package/editor/auth.ts +0 -52
- package/editor/common/admin-interface.ts +0 -84
- package/editor/common/constants.server.ts +0 -5
- package/editor/common/constants.ts +0 -21
- package/editor/common/editor-index.tsx +0 -17
- package/editor/common/html-encode.ts +0 -14
- package/editor/common/log-socket.tsx +0 -87
- package/editor/common/templates.ts +0 -481
- package/editor/components/api-preview.tsx +0 -118
- package/editor/components/editor.tsx +0 -496
- package/editor/components/file-browser.tsx +0 -311
- package/editor/components/file-editor-toolbar.tsx +0 -194
- package/editor/components/file-editor.tsx +0 -125
- package/editor/components/filter-query.tsx +0 -26
- package/editor/components/highlight-text-area.tsx +0 -148
- package/editor/components/log-viewer.tsx +0 -113
- package/editor/components/new-file.tsx +0 -172
- package/editor/components/scroll-query.tsx +0 -25
- package/editor/components/start-page.tsx +0 -52
- package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
- package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
- package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
- package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
- package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
- package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
- package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
- package/editor/http/admin/editor/editor.tsx +0 -10
- package/editor/http/admin/editor/index.api.tsx +0 -42
- package/editor/server.ts +0 -57
- package/editor/ws.ts +0 -15
- package/src/bin/compile.ts +0 -35
- package/src/bin/doc-md.ts +0 -210
- package/src/bin/generate-doc.ts +0 -64
- package/src/bin/test.ts +0 -93
- package/src/bin/types.ts +0 -34
- package/src/cluster.ts +0 -27
- package/src/common/arguments.ts +0 -853
- package/src/common/assets.ts +0 -148
- package/src/common/checksum.ts +0 -58
- package/src/common/constants.ts +0 -19
- package/src/common/content-type.ts +0 -84
- package/src/common/esbuild.ts +0 -103
- package/src/common/exit.ts +0 -91
- package/src/common/fs.ts +0 -82
- package/src/common/help.ts +0 -65
- package/src/common/jsx.ts +0 -574
- package/src/common/jwt.ts +0 -85
- package/src/common/paths.ts +0 -107
- package/src/common/watch.ts +0 -88
- package/src/inflate/inflate-sea.ts +0 -268
- package/src/inflate/inflate.ts +0 -105
- package/src/inflate/md.ts +0 -25
- package/src/inflate/setup-auth.ts +0 -41
- package/src/inflate/setup-cors.ts +0 -42
- package/src/inflate/setup-db.ts +0 -117
- package/src/inflate/setup-error.ts +0 -44
- package/src/inflate/setup-http.ts +0 -720
- package/src/inflate/setup-log.ts +0 -45
- package/src/inflate/setup-middleware.ts +0 -47
- package/src/inflate/setup-server-config.ts +0 -48
- package/src/inflate/setup-test.ts +0 -23
- package/src/inflate/setup-ws.ts +0 -50
- package/src/inflate/setup.doc.ts +0 -92
- package/src/inflate/utils/sea-utils.ts +0 -14
- package/src/lib.ts +0 -35
- package/src/main.ts +0 -107
- package/src/services/app.ts +0 -750
- package/src/services/editor.tsx +0 -101
- package/src/services/globals.ts.ignore +0 -186
- package/src/services/hot-reload.ts +0 -55
- package/src/services/migrations.ts +0 -68
- package/src/services/utils/admin-interface.ts +0 -37
- package/src/services/utils/cache.ts +0 -88
- package/src/services/utils/cluster-cache.ts +0 -255
- package/src/services/utils/cluster-ws.ts +0 -202
- package/src/services/utils/db-manager.ts +0 -92
- package/src/services/utils/get-route.ts +0 -70
- package/src/services/utils/jwt.ts +0 -25
- package/src/services/utils/log-transport.ts +0 -81
- package/src/services/utils/log.ts +0 -92
- package/src/services/utils/middleware.ts +0 -10
- package/src/services/utils/server-interface.ts +0 -122
- package/src/services/utils/websocketmanager.ts +0 -158
- package/src/types.ts +0 -287
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
|
-
}
|
package/src/bin/generate-doc.ts
DELETED
|
@@ -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,93 +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
|
-
import { ImportJSXFileOptions } from "../common/jsx.js";
|
|
12
|
-
|
|
13
|
-
export async function testMain(app: Miqro, options: ImportJSXFileOptions) {
|
|
14
|
-
const startMS = Date.now();
|
|
15
|
-
//resetTests();
|
|
16
|
-
resetGlobals();
|
|
17
|
-
//const testLogger = getLogger("test");
|
|
18
|
-
globalThis.test = {
|
|
19
|
-
PORT: TEST_SOCKET,
|
|
20
|
-
request: (request: RequestOptions) => reqlRequest({
|
|
21
|
-
...request,
|
|
22
|
-
socketPath: TEST_SOCKET
|
|
23
|
-
}),
|
|
24
|
-
logger: app.logger,
|
|
25
|
-
sleep: async (ms: number) => new Promise(resolve => setTimeout(resolve, ms)),
|
|
26
|
-
jsx: {
|
|
27
|
-
createRuntime: createNodeRuntime,
|
|
28
|
-
test: (cb, args: {
|
|
29
|
-
runtimeOptions?: {
|
|
30
|
-
basePath?: string | null;
|
|
31
|
-
url?: RuntimeURL;
|
|
32
|
-
logger?: {
|
|
33
|
-
log: Function;
|
|
34
|
-
error: Function;
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
containerOptions?: {
|
|
38
|
-
runtimeOptions?: RuntimeOptions;
|
|
39
|
-
shadowInit?: boolean | RuntimeShadowRootInit;
|
|
40
|
-
};
|
|
41
|
-
}) => {
|
|
42
|
-
return async () => {
|
|
43
|
-
const runtime = createNodeRuntime(args.runtimeOptions);
|
|
44
|
-
const root = runtime.createElement("root");
|
|
45
|
-
const container = runtime.createContainer(root, args.containerOptions);
|
|
46
|
-
await cb(container, root, runtime);
|
|
47
|
-
container.disconnect();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
for (const service of app.options.services) {
|
|
54
|
-
const servicePath = getServicePath(service);
|
|
55
|
-
await setupTests(app.logger, servicePath, options);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
console.log("");
|
|
59
|
-
app.logger.log("===starting tests===");
|
|
60
|
-
console.log("");
|
|
61
|
-
|
|
62
|
-
const ret = await runTests(undefined, app.logger);
|
|
63
|
-
|
|
64
|
-
console.log("");
|
|
65
|
-
app.logger.log("===tests ended===");
|
|
66
|
-
if (ret.failed.length > 0) {
|
|
67
|
-
console.log("");
|
|
68
|
-
app.logger.error("===failed tests===");
|
|
69
|
-
console.log("");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const took = Date.now() - startMS;
|
|
73
|
-
ret.failed.forEach(e => {
|
|
74
|
-
app.logger.error("\x1b[31m%s\x1b[0m", e.fullName);
|
|
75
|
-
app.logger.error(e.error);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
console.log("");
|
|
80
|
-
app.logger.log(ret.passed + " tests passed");
|
|
81
|
-
if (ret.failed.length > 0) {
|
|
82
|
-
app.logger.error(ret.failed.length + " failed");
|
|
83
|
-
} else {
|
|
84
|
-
app.logger.log(ret.failed.length + " failed");
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
app.logger.log("took " + took + "ms");
|
|
88
|
-
|
|
89
|
-
if (ret.failed.length > 0) {
|
|
90
|
-
process.exit(EXIT_CODES.TEST_FAILED);
|
|
91
|
-
}
|
|
92
|
-
await app.dbManager.closeAll();
|
|
93
|
-
}
|
package/src/bin/types.ts
DELETED
|
@@ -1,34 +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
|
-
import { installAsset } from "../common/assets.js";
|
|
8
|
-
|
|
9
|
-
export async function installTypings(args: Arguments, logger: MinimalLogger) {
|
|
10
|
-
/*if (args.installTypes) {
|
|
11
|
-
logger.debug("writing types");
|
|
12
|
-
// install typing for typescript only if argument --install-types is set
|
|
13
|
-
await initTypes(logger);
|
|
14
|
-
}*/
|
|
15
|
-
if (args.install) {
|
|
16
|
-
logger.debug("writing node_modules");
|
|
17
|
-
await installAsset(logger, ["node_modules/"]);
|
|
18
|
-
}
|
|
19
|
-
if (args.installTSConfig && !existsSync("tsconfig.json")) {
|
|
20
|
-
logger.info("writing tsconfig.json");
|
|
21
|
-
writeFileSync("tsconfig.json", TEMPLATES["TSCONFIGJSON"].template("", ""));
|
|
22
|
-
} else if (args.installTSConfig) {
|
|
23
|
-
logger.error("tsconfig.json already exists!");
|
|
24
|
-
process.exit(EXIT_CODES.ABNORMAL);
|
|
25
|
-
}
|
|
26
|
-
if (args.installMiqroJSON && !existsSync("miqro.json")) {
|
|
27
|
-
logger.info("writing miqro.json");
|
|
28
|
-
writeFileSync("miqro.json", TEMPLATES["MIQROJSON"].template("", ""));
|
|
29
|
-
} else if (args.installMiqroJSON) {
|
|
30
|
-
logger.error("miqro.json already exists!");
|
|
31
|
-
process.exit(EXIT_CODES.ABNORMAL);
|
|
32
|
-
}
|
|
33
|
-
process.exit(EXIT_CODES.NORMAL_EXIT);
|
|
34
|
-
}
|
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
|
-
}
|