miqro 7.0.1 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/esm/editor/auth.d.ts +6 -0
- package/build/esm/editor/auth.js +41 -0
- package/build/esm/editor/common/admin-interface.d.ts +36 -0
- package/build/esm/editor/common/admin-interface.js +44 -0
- package/build/esm/editor/common/constants.d.ts +4 -0
- package/build/esm/editor/common/constants.js +20 -0
- package/build/esm/editor/common/constants.server.d.ts +2 -0
- package/build/esm/editor/common/constants.server.js +4 -0
- package/build/esm/editor/common/editor-index.d.ts +2 -0
- package/build/esm/editor/common/editor-index.js +14 -0
- package/build/esm/editor/common/html-encode.d.ts +1 -0
- package/build/esm/editor/common/html-encode.js +14 -0
- package/build/esm/editor/common/log-socket.d.ts +15 -0
- package/build/esm/editor/common/log-socket.js +71 -0
- package/build/esm/editor/common/templates.d.ts +11 -0
- package/build/esm/editor/common/templates.js +477 -0
- package/build/esm/editor/components/api-preview.d.ts +11 -0
- package/build/esm/editor/components/api-preview.js +92 -0
- package/build/esm/editor/components/editor.d.ts +16 -0
- package/build/esm/editor/components/editor.js +367 -0
- package/build/esm/editor/components/file-browser.d.ts +37 -0
- package/build/esm/editor/components/file-browser.js +127 -0
- package/build/esm/editor/components/file-editor-toolbar.d.ts +22 -0
- package/build/esm/editor/components/file-editor-toolbar.js +95 -0
- package/build/esm/editor/components/file-editor.d.ts +32 -0
- package/build/esm/editor/components/file-editor.js +61 -0
- package/build/esm/editor/components/filter-query.d.ts +1 -0
- package/build/esm/editor/components/filter-query.js +23 -0
- package/build/esm/editor/components/highlight-text-area.d.ts +11 -0
- package/build/esm/editor/components/highlight-text-area.js +127 -0
- package/build/esm/editor/components/log-viewer.d.ts +6 -0
- package/build/esm/editor/components/log-viewer.js +71 -0
- package/build/esm/editor/components/new-file.d.ts +10 -0
- package/build/esm/editor/components/new-file.js +119 -0
- package/build/esm/editor/components/scroll-query.d.ts +7 -0
- package/build/esm/editor/components/scroll-query.js +22 -0
- package/build/esm/editor/components/start-page.d.ts +13 -0
- package/build/esm/editor/components/start-page.js +32 -0
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +3 -0
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +30 -0
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +5 -0
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +50 -0
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +4 -0
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +40 -0
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +26 -0
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +150 -0
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +3 -0
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +39 -0
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +10 -0
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +46 -0
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +10 -0
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +46 -0
- package/build/esm/editor/http/admin/editor/editor.d.ts +1 -0
- package/build/esm/editor/http/admin/editor/editor.js +8 -0
- package/build/esm/editor/http/admin/editor/index.api.d.ts +3 -0
- package/build/esm/editor/http/admin/editor/index.api.js +22 -0
- package/build/esm/editor/server.d.ts +3 -0
- package/build/esm/editor/server.js +49 -0
- package/build/esm/editor/ws.d.ts +3 -0
- package/build/esm/editor/ws.js +11 -0
- package/editor/auth.ts +51 -0
- package/editor/common/admin-interface.ts +84 -0
- package/editor/common/constants.server.ts +5 -0
- package/editor/common/constants.ts +21 -0
- package/editor/common/editor-index.tsx +17 -0
- package/editor/common/html-encode.ts +14 -0
- package/editor/common/log-socket.tsx +87 -0
- package/editor/common/templates.ts +481 -0
- package/editor/components/api-preview.tsx +118 -0
- package/editor/components/editor.tsx +496 -0
- package/editor/components/file-browser.tsx +311 -0
- package/editor/components/file-editor-toolbar.tsx +194 -0
- package/editor/components/file-editor.tsx +125 -0
- package/editor/components/filter-query.tsx +26 -0
- package/editor/components/highlight-text-area.tsx +148 -0
- package/editor/components/log-viewer.tsx +113 -0
- package/editor/components/new-file.tsx +172 -0
- package/editor/components/scroll-query.tsx +25 -0
- package/editor/components/start-page.tsx +52 -0
- package/editor/http/admin/editor/api/fs/delete.api.tsx +32 -0
- package/editor/http/admin/editor/api/fs/read.api.tsx +55 -0
- package/editor/http/admin/editor/api/fs/rename.api.tsx +41 -0
- package/editor/http/admin/editor/api/fs/scan.api.tsx +181 -0
- package/editor/http/admin/editor/api/fs/write.api.tsx +41 -0
- package/editor/http/admin/editor/api/server/reload.api.ts +53 -0
- package/editor/http/admin/editor/api/server/restart.api.tsx +52 -0
- package/editor/http/admin/editor/editor.tsx +10 -0
- package/editor/http/admin/editor/index.api.tsx +42 -0
- package/editor/server.ts +57 -0
- package/editor/ws.ts +15 -0
- package/package.json +1 -1
- package/src/bin/compile.ts +35 -0
- package/src/bin/doc-md.ts +210 -0
- package/src/bin/generate-doc.ts +64 -0
- package/src/bin/test.ts +92 -0
- package/src/bin/types.ts +34 -0
- package/src/cluster.ts +27 -0
- package/src/common/arguments.ts +762 -0
- package/src/common/assets.ts +148 -0
- package/src/common/checksum.ts +58 -0
- package/src/common/constants.ts +18 -0
- package/src/common/content-type.ts +84 -0
- package/src/common/esbuild.ts +102 -0
- package/src/common/exit.ts +91 -0
- package/src/common/fs.ts +82 -0
- package/src/common/help.ts +60 -0
- package/src/common/jsx.ts +562 -0
- package/src/common/jwt.ts +85 -0
- package/src/common/paths.ts +107 -0
- package/src/common/watch.ts +88 -0
- package/src/inflate/inflate-sea.ts +237 -0
- package/src/inflate/inflate.ts +101 -0
- package/src/inflate/md.ts +25 -0
- package/src/inflate/setup-auth.ts +41 -0
- package/src/inflate/setup-cors.ts +41 -0
- package/src/inflate/setup-db.ts +117 -0
- package/src/inflate/setup-error.ts +44 -0
- package/src/inflate/setup-http.ts +704 -0
- package/src/inflate/setup-log.ts +45 -0
- package/src/inflate/setup-middleware.ts +47 -0
- package/src/inflate/setup-server-config.ts +48 -0
- package/src/inflate/setup-test.ts +23 -0
- package/src/inflate/setup-ws.ts +50 -0
- package/src/inflate/setup.doc.ts +92 -0
- package/src/inflate/utils/sea-utils.ts +14 -0
- package/src/lib.ts +34 -0
- package/src/main.ts +101 -0
- package/src/services/app.ts +699 -0
- package/src/services/editor.tsx +101 -0
- package/src/services/globals.ts.ignore +186 -0
- package/src/services/hot-reload.ts +51 -0
- package/src/services/migrations.ts +68 -0
- package/src/services/utils/admin-interface.ts +37 -0
- package/src/services/utils/cache.ts +88 -0
- package/src/services/utils/cluster-cache.ts +230 -0
- package/src/services/utils/cluster-ws.ts +202 -0
- package/src/services/utils/db-manager.ts +92 -0
- package/src/services/utils/get-route.ts +70 -0
- package/src/services/utils/jwt.ts +25 -0
- package/src/services/utils/log-transport.ts +81 -0
- package/src/services/utils/log.ts +92 -0
- package/src/services/utils/middleware.ts +10 -0
- package/src/services/utils/server-interface.ts +122 -0
- package/src/services/utils/websocketmanager.ts +157 -0
- package/src/types.ts +307 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Logger } from "@miqro/core";
|
|
2
|
+
import { Migration, migration } from "@miqro/query";
|
|
3
|
+
import { importDBConfigModule, importMigrationModule, InflateError, inflateJSX } from "../common/jsx.js";
|
|
4
|
+
import { getDBConfigPath, getMigrationsPath, getServicePath } from "../common/paths.js";
|
|
5
|
+
import { dirname, extname, relative, resolve } from "node:path";
|
|
6
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { cwd } from "node:process";
|
|
8
|
+
import { DBConfig, NamedMigration } from "../types.js";
|
|
9
|
+
|
|
10
|
+
export interface MigrationModule extends Migration, NamedMigration {
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function inflateDBConfig(logger: Logger, service: string, dbConfigList: DBConfig[] | undefined, inflateDir: string | undefined | false, errors: InflateError[]) {
|
|
15
|
+
const servicePath = getServicePath(service);
|
|
16
|
+
const dbConfigPath = getDBConfigPath(servicePath);
|
|
17
|
+
if (dbConfigPath) {
|
|
18
|
+
try {
|
|
19
|
+
//logger.debug("loading DBConfig for service[%s]", service);
|
|
20
|
+
const config = await importDBConfigModule(dbConfigPath, logger);
|
|
21
|
+
if (config && dbConfigList && dbConfigList.filter(c => c.name === config.name).length > 0) {
|
|
22
|
+
throw new Error(`ws path [${config.name}] already defined! error from [${dbConfigPath}]`);
|
|
23
|
+
} else if (config) {
|
|
24
|
+
//logger.debug("DBConfig [%s] loaded from service [%s]", config.name, service);
|
|
25
|
+
if (dbConfigList) {
|
|
26
|
+
dbConfigList.push(config);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if (config) {
|
|
32
|
+
if (inflateDir) {
|
|
33
|
+
const inflatePath = resolve(inflateDir, service, "db.cjs");
|
|
34
|
+
mkdirSync(dirname(inflatePath), {
|
|
35
|
+
recursive: true
|
|
36
|
+
});
|
|
37
|
+
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
38
|
+
writeFileSync(inflatePath, await inflateJSX(dbConfigPath, {
|
|
39
|
+
// embemedJSX: false,
|
|
40
|
+
minify: false,
|
|
41
|
+
useExport: true,
|
|
42
|
+
platform: "node",
|
|
43
|
+
logger
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//const db = await dbManager.setupDB(service, config);
|
|
48
|
+
|
|
49
|
+
//return db;
|
|
50
|
+
return config;
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
errors.push({
|
|
54
|
+
filePath: dbConfigPath,
|
|
55
|
+
error: e
|
|
56
|
+
});
|
|
57
|
+
logger.error("error with " + dbConfigPath);
|
|
58
|
+
logger.error(e);
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function inflateDBMigrations(logger: Logger, service: string, dbName: string, inflateDir: string | undefined | false, errors: InflateError[]) {
|
|
66
|
+
const servicePath = getServicePath(service);
|
|
67
|
+
const migrationsFolderPath = getMigrationsPath(servicePath);
|
|
68
|
+
if (migrationsFolderPath) {
|
|
69
|
+
|
|
70
|
+
logger?.trace("loading migrations from service [%s]", service);
|
|
71
|
+
|
|
72
|
+
const serviceMigrations = migration.getSortedMigrations(migrationsFolderPath);
|
|
73
|
+
|
|
74
|
+
const migrationModules: MigrationModule[] = [];
|
|
75
|
+
|
|
76
|
+
for (const migrationName of serviceMigrations) {
|
|
77
|
+
const migrationPath = resolve(migrationsFolderPath, migrationName);
|
|
78
|
+
try {
|
|
79
|
+
const migrationModule = await importMigrationModule(migrationPath);
|
|
80
|
+
migrationModules.push({
|
|
81
|
+
name: migrationName,
|
|
82
|
+
service,
|
|
83
|
+
dbName,
|
|
84
|
+
...migrationModule
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (inflateDir) {
|
|
88
|
+
const inflatePath = resolve(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - extname(migrationName).length) + ".cjs");
|
|
89
|
+
mkdirSync(dirname(inflatePath), {
|
|
90
|
+
recursive: true
|
|
91
|
+
});
|
|
92
|
+
logger?.log("writing [%s]", relative(cwd(), inflatePath));
|
|
93
|
+
writeFileSync(inflatePath, await inflateJSX(resolve(migrationsFolderPath, migrationName), {
|
|
94
|
+
// embemedJSX: false,
|
|
95
|
+
minify: false,
|
|
96
|
+
useExport: true,
|
|
97
|
+
platform: "node",
|
|
98
|
+
logger
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
} catch (e) {
|
|
103
|
+
errors.push({
|
|
104
|
+
filePath: migrationPath,
|
|
105
|
+
error: e
|
|
106
|
+
});
|
|
107
|
+
logger.error("error with " + migrationPath);
|
|
108
|
+
logger.error(e);
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return migrationModules;
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Logger, Router } from "@miqro/core";
|
|
2
|
+
import { importErrorConfigModule, InflateError, inflateJSX } from "../common/jsx.js";
|
|
3
|
+
import { getErrorConfigPath } from "../common/paths.js";
|
|
4
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
5
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { cwd } from "node:process";
|
|
7
|
+
|
|
8
|
+
export async function setupError(logger: Logger, servicePath: string, service: string, mainRouter: Router, inflateDir: string | undefined | false, inflateSea: boolean, errors: InflateError[]): Promise<void> {
|
|
9
|
+
const errorPath = getErrorConfigPath(servicePath); //resolve(process.cwd(), service, "auth.ts");
|
|
10
|
+
|
|
11
|
+
if (errorPath) {
|
|
12
|
+
try {
|
|
13
|
+
const errorModule = await importErrorConfigModule(errorPath, logger);
|
|
14
|
+
logger.debug("setting up error handling from [%s]", join(service, basename(errorPath)));
|
|
15
|
+
if (errorModule && errorModule.catch) {
|
|
16
|
+
for (const m of errorModule.catch) {
|
|
17
|
+
mainRouter.catch(m);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (inflateDir && inflateSea) {
|
|
21
|
+
const inflatePath = resolve(inflateDir, service, "catch.cjs");
|
|
22
|
+
mkdirSync(dirname(inflatePath), {
|
|
23
|
+
recursive: true
|
|
24
|
+
});
|
|
25
|
+
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
26
|
+
writeFileSync(inflatePath, await inflateJSX(errorPath, {
|
|
27
|
+
// embemedJSX: false,
|
|
28
|
+
minify: false,
|
|
29
|
+
useExport: true,
|
|
30
|
+
platform: "node",
|
|
31
|
+
logger
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
} catch (e) {
|
|
36
|
+
errors.push({
|
|
37
|
+
filePath: errorPath,
|
|
38
|
+
error: e
|
|
39
|
+
});
|
|
40
|
+
logger.error("error with " + errorPath);
|
|
41
|
+
logger.error(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|