@nestia/editor 13.0.4 → 14.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.
- package/README.md +1 -1
- package/dist/assets/index-5lpEeH1X.js +4156 -0
- package/dist/index.html +1 -1
- package/lib/NestiaEditorModule.js +25 -7
- package/lib/NestiaEditorModule.js.map +1 -1
- package/lib/NestiaEditorModule.mjs +19 -13
- package/lib/NestiaEditorUploader.js +5 -0
- package/lib/NestiaEditorUploader.js.map +1 -1
- package/lib/NestiaEditorUploader.mjs +7 -5
- package/lib/internal/NestiaEditorComposer.d.ts +12 -0
- package/lib/internal/NestiaEditorComposer.js +6 -0
- package/lib/internal/NestiaEditorComposer.js.map +1 -1
- package/lib/internal/NestiaEditorComposer.mjs +8 -2
- package/package.json +4 -4
- package/src/NestiaEditorModule.ts +35 -11
- package/src/NestiaEditorUploader.tsx +9 -0
- package/src/internal/NestiaEditorComposer.ts +18 -0
- package/dist/assets/index-D9z0cqhh.js +0 -4155
package/dist/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1.0, maximum-scale=3.0s"
|
|
7
7
|
/>
|
|
8
8
|
<title>Nestia Editor</title>
|
|
9
|
-
<script type="module" src="./assets/index-
|
|
9
|
+
<script type="module" src="./assets/index-5lpEeH1X.js"></script>
|
|
10
10
|
</head>
|
|
11
11
|
<body style="width: 100%; height: 100%; margin: 0px; overflow: hidden;">
|
|
12
12
|
<div id="root" style="width: 100%; height: 100%"></div>
|
|
@@ -60,13 +60,6 @@ var NestiaEditorModule;
|
|
|
60
60
|
type: "text/html",
|
|
61
61
|
content: yield getIndex(props),
|
|
62
62
|
},
|
|
63
|
-
{
|
|
64
|
-
path: "/swagger.json",
|
|
65
|
-
type: "application/json",
|
|
66
|
-
content: JSON.stringify(typeof props.swagger === "string"
|
|
67
|
-
? yield getSwagger(props.swagger)
|
|
68
|
-
: props.swagger, null, 2),
|
|
69
|
-
},
|
|
70
63
|
yield getJavaScript(),
|
|
71
64
|
];
|
|
72
65
|
for (const f of staticFiles) {
|
|
@@ -75,6 +68,25 @@ var NestiaEditorModule;
|
|
|
75
68
|
return res.send(f.content);
|
|
76
69
|
});
|
|
77
70
|
}
|
|
71
|
+
// A document given by location is read when the editor asks for it, not
|
|
72
|
+
// here: `setup()` runs before `listen()`, so the application's own path,
|
|
73
|
+
// such as `@nestjs/swagger`'s "/api-json", serves nothing yet, and a path
|
|
74
|
+
// is resolved against the address the application listens on.
|
|
75
|
+
let document = typeof props.swagger === "string"
|
|
76
|
+
? null
|
|
77
|
+
: JSON.stringify(props.swagger, null, 2);
|
|
78
|
+
adaptor.get(prefix + "/swagger.json", (_, res) => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
try {
|
|
80
|
+
document !== null && document !== void 0 ? document : (document = JSON.stringify(yield getSwagger(yield resolveLocation(props.application, props.swagger)), null, 2));
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
res.status(502);
|
|
84
|
+
res.type("text/plain");
|
|
85
|
+
return res.send(error instanceof Error ? error.message : String(error));
|
|
86
|
+
}
|
|
87
|
+
res.type("application/json");
|
|
88
|
+
return res.send(document);
|
|
89
|
+
}));
|
|
78
90
|
for (const p of ["", "/"])
|
|
79
91
|
adaptor.get(prefix + p, (_, res) => {
|
|
80
92
|
return res.redirect(prefix + "/index.html");
|
|
@@ -103,6 +115,12 @@ const getJavaScript = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
103
115
|
content: yield fs.promises.readFile(`${__dirname}/../dist/assets/${path}`, "utf8"),
|
|
104
116
|
};
|
|
105
117
|
});
|
|
118
|
+
/** An absolute URL as is; a path of the application at its own address. */
|
|
119
|
+
const resolveLocation = (application, location) => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
|
+
return /^[a-z][a-z\d+\-.]*:/i.test(location)
|
|
121
|
+
? location
|
|
122
|
+
: new URL(location, yield application.getUrl()).href;
|
|
123
|
+
});
|
|
106
124
|
const getSwagger = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
125
|
const response = yield fetch(url);
|
|
108
126
|
if (response.status !== 200)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaEditorModule.js","sourceRoot":"","sources":["../src/NestiaEditorModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAY,EAAE,+BAAW;AAEzB,IAAiB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"NestiaEditorModule.js","sourceRoot":"","sources":["../src/NestiaEditorModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAY,EAAE,+BAAW;AAEzB,IAAiB,kBAAkB,CAwElC;AAxED,WAAiB,kBAAkB;IACpB,wBAAK,GAAG,CAAO,KAY3B,EAAiB,EAAE;QAClB,MAAM,MAAM,GACV,GAAG;YACH,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC;iBAC7C,IAAI,CAAC,GAAG,CAAC;iBACT,KAAK,CAAC,GAAG,CAAC;iBACV,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;iBACjC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,MAAM,OAAO,GAAqB,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;QACrE,MAAM,WAAW,GAAkB;YACjC;gBACE,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,MAAM,QAAQ,CAAC,KAAK,CAAC;aAC/B;YACD,MAAM,aAAa,EAAE;SACtB,CAAC;QACF,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,IAA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,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,OAAO;QACL,IAAI,EAAE,WAAW,IAAI,EAAE;QACvB,IAAI,EAAE,wBAAwB;QAC9B,OAAO,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CACjC,GAAG,SAAS,mBAAmB,IAAI,EAAE,EACrC,MAAM,CACP;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,2EAA2E;AAC3E,MAAM,eAAe,GAAG,CACtB,WAA6B,EAC7B,QAAgB,EACC,EAAE;IACnB,OAAA,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC;QACnC,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAA;AAAA,CAAC,CAAD,CAAC;AAEzD,MAAM,UAAU,GAAG,CACjB,GAAW,EAGX,EAAE;IACF,MAAM,QAAQ,GAAa,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG;QACzB,MAAM,IAAI,KAAK,CAAC,yCAAyC,GAAG,EAAE,CAAC,CAAC;IAClE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAA,CAAC"}
|
|
@@ -5,23 +5,27 @@ let NestiaEditorModule;
|
|
|
5
5
|
_NestiaEditorModule.setup = async (props) => {
|
|
6
6
|
const prefix = "/" + [getGlobalPrefix(props.application), props.path].join("/").split("/").filter((str) => str.length !== 0).join("/");
|
|
7
7
|
const adaptor = props.application.getHttpAdapter();
|
|
8
|
-
const staticFiles = [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
path: "/swagger.json",
|
|
16
|
-
type: "application/json",
|
|
17
|
-
content: JSON.stringify(typeof props.swagger === "string" ? await getSwagger(props.swagger) : props.swagger, null, 2)
|
|
18
|
-
},
|
|
19
|
-
await getJavaScript()
|
|
20
|
-
];
|
|
8
|
+
const staticFiles = [{
|
|
9
|
+
path: "/index.html",
|
|
10
|
+
type: "text/html",
|
|
11
|
+
content: await getIndex(props)
|
|
12
|
+
}, await getJavaScript()];
|
|
21
13
|
for (const f of staticFiles) adaptor.get(prefix + f.path, (_, res) => {
|
|
22
14
|
res.type(f.type);
|
|
23
15
|
return res.send(f.content);
|
|
24
16
|
});
|
|
17
|
+
let document = typeof props.swagger === "string" ? null : JSON.stringify(props.swagger, null, 2);
|
|
18
|
+
adaptor.get(prefix + "/swagger.json", async (_, res) => {
|
|
19
|
+
try {
|
|
20
|
+
document ??= JSON.stringify(await getSwagger(await resolveLocation(props.application, props.swagger)), null, 2);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
res.status(502);
|
|
23
|
+
res.type("text/plain");
|
|
24
|
+
return res.send(error instanceof Error ? error.message : String(error));
|
|
25
|
+
}
|
|
26
|
+
res.type("application/json");
|
|
27
|
+
return res.send(document);
|
|
28
|
+
});
|
|
25
29
|
for (const p of ["", "/"]) adaptor.get(prefix + p, (_, res) => {
|
|
26
30
|
return res.redirect(prefix + "/index.html");
|
|
27
31
|
});
|
|
@@ -40,6 +44,8 @@ const getJavaScript = async () => {
|
|
|
40
44
|
content: await fs.promises.readFile(`${__dirname}/../dist/assets/${path}`, "utf8")
|
|
41
45
|
};
|
|
42
46
|
};
|
|
47
|
+
/** An absolute URL as is; a path of the application at its own address. */
|
|
48
|
+
const resolveLocation = async (application, location) => /^[a-z][a-z\d+\-.]*:/i.test(location) ? location : new URL(location, await application.getUrl()).href;
|
|
43
49
|
const getSwagger = async (url) => {
|
|
44
50
|
const response = await fetch(url);
|
|
45
51
|
if (response.status !== 200) throw new Error(`Failed to fetch Swagger document from ${url}`);
|
|
@@ -58,6 +58,11 @@ function NestiaEditorUploader(props) {
|
|
|
58
58
|
name: NestiaEditorArchiver_1.NestiaEditorArchiver.name(name),
|
|
59
59
|
files: result.data.files,
|
|
60
60
|
});
|
|
61
|
+
if (result.data.skipped.length !== 0)
|
|
62
|
+
handleError([
|
|
63
|
+
"The project leaves out operations that could not be converted:",
|
|
64
|
+
...result.data.skipped.map((s) => ` - ${s.method} ${s.path}: ${s.messages.join(" ")}`),
|
|
65
|
+
].join("\n"));
|
|
61
66
|
}
|
|
62
67
|
else {
|
|
63
68
|
handleError(JSON.stringify(result.errors, null, 2));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaEditorUploader.js","sourceRoot":"","sources":["../src/NestiaEditorUploader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CASuB;AAEvB,kDAA0B;AAE1B,0EAAuE;AACvE,0EAAuE;AACvE,sFAAsF;AACtF,kFAA+E;AAE/E,8BAAqC,KAAkC;IACrE,aAAa;IACb,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAiB,KAAK,CAAC,CAAC;IAC9D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,0DAA6B,CAAC,CAAC;IAEtE,SAAS;IACT,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,eAAK,CAAC,QAAQ,CAE5C,IAAI,CAAC,CAAC;IACR,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEtD,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE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AM,CAAC,CAAC,GAAG,CAAC,GAAI,GAC/D,IACU,EACd,gCAAM,EACN,gCAAM,EACN,uBAAC,iBAAM,IACL,SAAS,EAAC,GAAG,EACb,SAAS,QACT,OAAO,EAAC,WAAW,EACnB,KAAK,EAAE,MAAM,EACb,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,IAAI,EAChD,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,YAExB,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,kBAAkB,GACzC,IACR,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -33,11 +33,13 @@ function NestiaEditorUploader(props) {
|
|
|
33
33
|
simulate,
|
|
34
34
|
package: name
|
|
35
35
|
});
|
|
36
|
-
if (result.success === true)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
if (result.success === true) {
|
|
37
|
+
NestiaEditorArchiver.download({
|
|
38
|
+
name: NestiaEditorArchiver.name(name),
|
|
39
|
+
files: result.data.files
|
|
40
|
+
});
|
|
41
|
+
if (result.data.skipped.length !== 0) handleError(["The project leaves out operations that could not be converted:", ...result.data.skipped.map((s) => ` - ${s.method} ${s.path}: ${s.messages.join(" ")}`)].join("\n"));
|
|
42
|
+
} else handleError(JSON.stringify(result.errors, null, 2));
|
|
41
43
|
} catch (exp) {
|
|
42
44
|
handleError(exp instanceof Error ? exp.message : "unknown error");
|
|
43
45
|
}
|
|
@@ -12,6 +12,18 @@ export declare namespace NestiaEditorComposer {
|
|
|
12
12
|
files: Record<string, string>;
|
|
13
13
|
openFile: string;
|
|
14
14
|
startScript: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Operations `@nestia/migrate` could not convert, left out of the files.
|
|
17
|
+
*
|
|
18
|
+
* The CLI prints them; the editor reports them to its user, so a project
|
|
19
|
+
* lacking an operation never passes for a complete one.
|
|
20
|
+
*/
|
|
21
|
+
skipped: ISkipped[];
|
|
22
|
+
}
|
|
23
|
+
interface ISkipped {
|
|
24
|
+
method: string;
|
|
25
|
+
path: string;
|
|
26
|
+
messages: string[];
|
|
15
27
|
}
|
|
16
28
|
const nest: (props: IProps) => Promise<IValidation<IOutput>>;
|
|
17
29
|
const sdk: (props: IProps) => Promise<IValidation<IOutput>>;
|
|
@@ -72,6 +72,7 @@ var NestiaEditorComposer;
|
|
|
72
72
|
files: props.files,
|
|
73
73
|
openFile: config.openFile,
|
|
74
74
|
startScript: config.startScript,
|
|
75
|
+
skipped: [],
|
|
75
76
|
},
|
|
76
77
|
};
|
|
77
78
|
const result = yield migrate_1.default.NestiaMigrateApplication.validate(props.document);
|
|
@@ -96,6 +97,11 @@ var NestiaEditorComposer;
|
|
|
96
97
|
files,
|
|
97
98
|
openFile: config.openFile,
|
|
98
99
|
startScript: config.startScript,
|
|
100
|
+
skipped: app.getData().errors.map((error) => ({
|
|
101
|
+
method: error.method.toUpperCase(),
|
|
102
|
+
path: error.path,
|
|
103
|
+
messages: error.messages,
|
|
104
|
+
})),
|
|
99
105
|
},
|
|
100
106
|
};
|
|
101
107
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaEditorComposer.js","sourceRoot":"","sources":["../../src/internal/NestiaEditorComposer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAsC;AAQtC,MAAY,oBAAoB,oDAAgC;AAChE,MAAY,gBAAgB,wDAAoC;AAChE,oDAA6C;AAG7C,IAAiB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"NestiaEditorComposer.js","sourceRoot":"","sources":["../../src/internal/NestiaEditorComposer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAsC;AAQtC,MAAY,oBAAoB,oDAAgC;AAChE,MAAY,gBAAgB,wDAAoC;AAChE,oDAA6C;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AAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;YAC9C,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK;gBACzC,IAAI,CAAC;oBACH,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,IAAA,mBAAM,EAAC,KAAK,EAAE;wBAC/B,MAAM,EAAE,YAAY;wBACpB,OAAO,EAAE,CAAC,oBAAoB,EAAE,gBAAgB,CAAC;qBAClD,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;QACL,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE;gBACJ,KAAK;gBACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBAC5C,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;oBAClC,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;iBACzB,CAAC,CAAC;aACJ;SAC6B,CAAC;IACnC,CAAC,CAAA,CAAC;AACN,CAAC,EA7FgB,oBAAoB,aAApB,oBAAoB,GAApB,oBAAoB,QA6FpC"}
|
|
@@ -21,7 +21,8 @@ let NestiaEditorComposer;
|
|
|
21
21
|
data: {
|
|
22
22
|
files: props.files,
|
|
23
23
|
openFile: config.openFile,
|
|
24
|
-
startScript: config.startScript
|
|
24
|
+
startScript: config.startScript,
|
|
25
|
+
skipped: []
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
28
|
const result = await migrate.NestiaMigrateApplication.validate(props.document);
|
|
@@ -41,7 +42,12 @@ let NestiaEditorComposer;
|
|
|
41
42
|
data: {
|
|
42
43
|
files,
|
|
43
44
|
openFile: config.openFile,
|
|
44
|
-
startScript: config.startScript
|
|
45
|
+
startScript: config.startScript,
|
|
46
|
+
skipped: app.getData().errors.map((error) => ({
|
|
47
|
+
method: error.method.toUpperCase(),
|
|
48
|
+
path: error.path,
|
|
49
|
+
messages: error.messages
|
|
50
|
+
}))
|
|
45
51
|
}
|
|
46
52
|
};
|
|
47
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/editor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"homepage": "https://nestia.io",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@mui/material": "^5.15.6",
|
|
41
|
-
"@typia/interface": "^
|
|
41
|
+
"@typia/interface": "^15.0.0",
|
|
42
42
|
"fflate": "^0.8.2",
|
|
43
43
|
"js-yaml": "^4.3.1",
|
|
44
44
|
"prettier": "^3.8.1",
|
|
45
45
|
"react-mui-fileuploader": "^0.5.2",
|
|
46
|
-
"typia": "
|
|
47
|
-
"@nestia/migrate": "^
|
|
46
|
+
"typia": "15.0.0",
|
|
47
|
+
"@nestia/migrate": "^14.0.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@eslint/js": "^9.13.0",
|
|
@@ -34,17 +34,6 @@ export namespace NestiaEditorModule {
|
|
|
34
34
|
type: "text/html",
|
|
35
35
|
content: await getIndex(props),
|
|
36
36
|
},
|
|
37
|
-
{
|
|
38
|
-
path: "/swagger.json",
|
|
39
|
-
type: "application/json",
|
|
40
|
-
content: JSON.stringify(
|
|
41
|
-
typeof props.swagger === "string"
|
|
42
|
-
? await getSwagger(props.swagger)
|
|
43
|
-
: props.swagger,
|
|
44
|
-
null,
|
|
45
|
-
2,
|
|
46
|
-
),
|
|
47
|
-
},
|
|
48
37
|
await getJavaScript(),
|
|
49
38
|
];
|
|
50
39
|
for (const f of staticFiles) {
|
|
@@ -53,6 +42,32 @@ export namespace NestiaEditorModule {
|
|
|
53
42
|
return res.send(f.content);
|
|
54
43
|
});
|
|
55
44
|
}
|
|
45
|
+
|
|
46
|
+
// A document given by location is read when the editor asks for it, not
|
|
47
|
+
// here: `setup()` runs before `listen()`, so the application's own path,
|
|
48
|
+
// such as `@nestjs/swagger`'s "/api-json", serves nothing yet, and a path
|
|
49
|
+
// is resolved against the address the application listens on.
|
|
50
|
+
let document: string | null =
|
|
51
|
+
typeof props.swagger === "string"
|
|
52
|
+
? null
|
|
53
|
+
: JSON.stringify(props.swagger, null, 2);
|
|
54
|
+
adaptor.get(prefix + "/swagger.json", async (_: any, res: any) => {
|
|
55
|
+
try {
|
|
56
|
+
document ??= JSON.stringify(
|
|
57
|
+
await getSwagger(
|
|
58
|
+
await resolveLocation(props.application, props.swagger as string),
|
|
59
|
+
),
|
|
60
|
+
null,
|
|
61
|
+
2,
|
|
62
|
+
);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
res.status(502);
|
|
65
|
+
res.type("text/plain");
|
|
66
|
+
return res.send(error instanceof Error ? error.message : String(error));
|
|
67
|
+
}
|
|
68
|
+
res.type("application/json");
|
|
69
|
+
return res.send(document);
|
|
70
|
+
});
|
|
56
71
|
for (const p of ["", "/"])
|
|
57
72
|
adaptor.get(prefix + p, (_: any, res: any) => {
|
|
58
73
|
return res.redirect(prefix + "/index.html");
|
|
@@ -124,6 +139,15 @@ const getJavaScript = async (): Promise<IStaticFile> => {
|
|
|
124
139
|
};
|
|
125
140
|
};
|
|
126
141
|
|
|
142
|
+
/** An absolute URL as is; a path of the application at its own address. */
|
|
143
|
+
const resolveLocation = async (
|
|
144
|
+
application: INestApplication,
|
|
145
|
+
location: string,
|
|
146
|
+
): Promise<string> =>
|
|
147
|
+
/^[a-z][a-z\d+\-.]*:/i.test(location)
|
|
148
|
+
? location
|
|
149
|
+
: new URL(location, await application.getUrl()).href;
|
|
150
|
+
|
|
127
151
|
const getSwagger = async (
|
|
128
152
|
url: string,
|
|
129
153
|
): Promise<
|
|
@@ -63,6 +63,15 @@ export function NestiaEditorUploader(props: NestiaEditorUploader.IProps) {
|
|
|
63
63
|
name: NestiaEditorArchiver.name(name),
|
|
64
64
|
files: result.data.files,
|
|
65
65
|
});
|
|
66
|
+
if (result.data.skipped.length !== 0)
|
|
67
|
+
handleError(
|
|
68
|
+
[
|
|
69
|
+
"The project leaves out operations that could not be converted:",
|
|
70
|
+
...result.data.skipped.map(
|
|
71
|
+
(s) => ` - ${s.method} ${s.path}: ${s.messages.join(" ")}`,
|
|
72
|
+
),
|
|
73
|
+
].join("\n"),
|
|
74
|
+
);
|
|
66
75
|
} else {
|
|
67
76
|
handleError(JSON.stringify(result.errors, null, 2));
|
|
68
77
|
}
|
|
@@ -29,6 +29,18 @@ export namespace NestiaEditorComposer {
|
|
|
29
29
|
files: Record<string, string>;
|
|
30
30
|
openFile: string;
|
|
31
31
|
startScript: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Operations `@nestia/migrate` could not convert, left out of the files.
|
|
34
|
+
*
|
|
35
|
+
* The CLI prints them; the editor reports them to its user, so a project
|
|
36
|
+
* lacking an operation never passes for a complete one.
|
|
37
|
+
*/
|
|
38
|
+
skipped: ISkipped[];
|
|
39
|
+
}
|
|
40
|
+
export interface ISkipped {
|
|
41
|
+
method: string;
|
|
42
|
+
path: string;
|
|
43
|
+
messages: string[];
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
export const nest = (props: IProps): Promise<IValidation<IOutput>> =>
|
|
@@ -59,6 +71,7 @@ export namespace NestiaEditorComposer {
|
|
|
59
71
|
files: props.files,
|
|
60
72
|
openFile: config.openFile,
|
|
61
73
|
startScript: config.startScript,
|
|
74
|
+
skipped: [],
|
|
62
75
|
},
|
|
63
76
|
};
|
|
64
77
|
const result: IValidation<NestiaMigrateApplication> =
|
|
@@ -83,6 +96,11 @@ export namespace NestiaEditorComposer {
|
|
|
83
96
|
files,
|
|
84
97
|
openFile: config.openFile,
|
|
85
98
|
startScript: config.startScript,
|
|
99
|
+
skipped: app.getData().errors.map((error) => ({
|
|
100
|
+
method: error.method.toUpperCase(),
|
|
101
|
+
path: error.path,
|
|
102
|
+
messages: error.messages,
|
|
103
|
+
})),
|
|
86
104
|
},
|
|
87
105
|
} satisfies IValidation<IOutput>;
|
|
88
106
|
};
|