@nestia/editor 14.0.1 → 14.0.3
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/dist/assets/{index-5lpEeH1X.js → index-DIkEkcTz.js} +132 -132
- package/dist/index.html +1 -1
- package/lib/NestiaEditorApplication.d.ts +10 -0
- package/lib/NestiaEditorApplication.js +20 -4
- package/lib/NestiaEditorApplication.js.map +1 -1
- package/lib/NestiaEditorApplication.mjs +17 -1
- package/lib/NestiaEditorIframe.d.ts +31 -0
- package/lib/NestiaEditorIframe.js +22 -4
- package/lib/NestiaEditorIframe.js.map +1 -1
- package/lib/NestiaEditorIframe.mjs +49 -10
- package/lib/NestiaEditorModule.d.ts +46 -0
- package/lib/NestiaEditorModule.js +96 -24
- package/lib/NestiaEditorModule.js.map +1 -1
- package/lib/NestiaEditorModule.mjs +27 -13
- package/lib/NestiaEditorUploader.d.ts +19 -0
- package/lib/NestiaEditorUploader.js +10 -0
- package/lib/NestiaEditorUploader.js.map +1 -1
- package/lib/NestiaEditorUploader.mjs +11 -1
- package/lib/internal/NestiaEditorArchiver.d.ts +35 -3
- package/lib/internal/NestiaEditorArchiver.js +60 -8
- package/lib/internal/NestiaEditorArchiver.js.map +1 -1
- package/lib/internal/NestiaEditorArchiver.mjs +25 -5
- package/lib/internal/NestiaEditorComposer.d.ts +68 -0
- package/lib/internal/NestiaEditorComposer.js +27 -0
- package/lib/internal/NestiaEditorComposer.js.map +1 -1
- package/lib/internal/NestiaEditorFileUploader.d.ts +21 -0
- package/lib/internal/NestiaEditorFileUploader.js +12 -0
- package/lib/internal/NestiaEditorFileUploader.js.map +1 -1
- package/lib/internal/NestiaEditorFileUploader.mjs +12 -0
- package/package.json +9 -8
- package/src/NestiaEditorApplication.tsx +19 -3
- package/src/NestiaEditorIframe.tsx +61 -6
- package/src/NestiaEditorModule.ts +111 -35
- package/src/NestiaEditorUploader.tsx +19 -0
- package/src/internal/NestiaEditorArchiver.ts +65 -10
- package/src/internal/NestiaEditorComposer.ts +78 -0
- package/src/internal/NestiaEditorFileUploader.tsx +21 -0
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-DIkEkcTz.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>
|
|
@@ -1 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The static editor page: converts an OpenAPI document into a downloadable project.
|
|
3
|
+
*
|
|
4
|
+
* The page reads its settings from the query string (`url`, `mode`, `package`, `keyword`, `simulate`, `e2e`) and from `window` globals the served `index.html` sets. It renders the iframe flow when a document location is given, or when `swagger.json` or `swagger.yaml` is served beside the page, and the uploader otherwise. The `uploader` query key forces the uploader.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/common.md#principled-implementation An explicit query URL is forwarded to the iframe, which loads it and reports a fetch error. Without one, swagger.json and then swagger.yaml are probed for HTTP 200; absent or failed lookup falls back to the uploader. Parsed generation options, including keyword, are passed to the iframe rather than replaced by its direct-component defaults.
|
|
7
|
+
* @evidence contracts/common.md#clear-and-simple-design One component chooses between two existing components; the query and probing logic stays in the private `getAsset` and `findSwagger`, and option parsing lives in one place.
|
|
8
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The package name default comes from the shared constant, and no document name, host, or fixture is special-cased; booleans accept only `true` and `1`, as the query contract states.
|
|
9
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the page does, where each setting comes from, the lookup order, and the `uploader` override.
|
|
10
|
+
*/
|
|
1
11
|
export declare function NestiaEditorApplication(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,7 +17,18 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
17
17
|
const material_1 = require("@mui/material");
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
19
|
const NestiaEditorIframe_1 = require("./NestiaEditorIframe");
|
|
20
|
+
const NestiaEditorDefaultPackage_1 = require("./internal/NestiaEditorDefaultPackage");
|
|
20
21
|
const NestiaEditorUploader_1 = require("./NestiaEditorUploader");
|
|
22
|
+
/**
|
|
23
|
+
* The static editor page: converts an OpenAPI document into a downloadable project.
|
|
24
|
+
*
|
|
25
|
+
* The page reads its settings from the query string (`url`, `mode`, `package`, `keyword`, `simulate`, `e2e`) and from `window` globals the served `index.html` sets. It renders the iframe flow when a document location is given, or when `swagger.json` or `swagger.yaml` is served beside the page, and the uploader otherwise. The `uploader` query key forces the uploader.
|
|
26
|
+
*
|
|
27
|
+
* @evidence contracts/common.md#principled-implementation An explicit query URL is forwarded to the iframe, which loads it and reports a fetch error. Without one, swagger.json and then swagger.yaml are probed for HTTP 200; absent or failed lookup falls back to the uploader. Parsed generation options, including keyword, are passed to the iframe rather than replaced by its direct-component defaults.
|
|
28
|
+
* @evidence contracts/common.md#clear-and-simple-design One component chooses between two existing components; the query and probing logic stays in the private `getAsset` and `findSwagger`, and option parsing lives in one place.
|
|
29
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The package name default comes from the shared constant, and no document name, host, or fixture is special-cased; booleans accept only `true` and `1`, as the query contract states.
|
|
30
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the page does, where each setting comes from, the lookup order, and the `uploader` override.
|
|
31
|
+
*/
|
|
21
32
|
function NestiaEditorApplication() {
|
|
22
33
|
const [ready, setReady] = react_1.default.useState(false);
|
|
23
34
|
const [asset, setAsset] = react_1.default.useState(null);
|
|
@@ -34,7 +45,7 @@ function NestiaEditorApplication() {
|
|
|
34
45
|
}, []);
|
|
35
46
|
if (ready === false)
|
|
36
47
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
37
|
-
return asset !== null ? ((0, jsx_runtime_1.jsx)(NestiaEditorIframe_1.NestiaEditorIframe, { swagger: asset.url, package: asset.package, simulate: asset.simulate, e2e: asset.e2e, mode: asset.mode })) : ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
48
|
+
return asset !== null ? ((0, jsx_runtime_1.jsx)(NestiaEditorIframe_1.NestiaEditorIframe, { swagger: asset.url, package: asset.package, keyword: asset.keyword, simulate: asset.simulate, e2e: asset.e2e, mode: asset.mode })) : ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
38
49
|
padding: 25,
|
|
39
50
|
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", children: "Nestia Editor" }), (0, jsx_runtime_1.jsx)("hr", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(NestiaEditorUploader_1.NestiaEditorUploader, {})] }));
|
|
40
51
|
}
|
|
@@ -55,7 +66,7 @@ function getAsset() {
|
|
|
55
66
|
const e2e = (_f = query.get("e2e")) !== null && _f !== void 0 ? _f : window.e2e;
|
|
56
67
|
return {
|
|
57
68
|
mode: mode === "nest" ? "nest" : "sdk",
|
|
58
|
-
package: packageName !== null && packageName !== void 0 ? packageName :
|
|
69
|
+
package: packageName !== null && packageName !== void 0 ? packageName : NestiaEditorDefaultPackage_1.NESTIA_EDITOR_DEFAULT_PACKAGE,
|
|
59
70
|
url,
|
|
60
71
|
keyword: keyword !== null
|
|
61
72
|
? keyword === true || keyword === "true" || keyword === "1"
|
|
@@ -69,8 +80,13 @@ function getAsset() {
|
|
|
69
80
|
}
|
|
70
81
|
function findSwagger(file) {
|
|
71
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
try {
|
|
84
|
+
const response = yield fetch(file);
|
|
85
|
+
return response.status === 200 ? file : null;
|
|
86
|
+
}
|
|
87
|
+
catch (_a) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
74
90
|
});
|
|
75
91
|
}
|
|
76
92
|
//# sourceMappingURL=NestiaEditorApplication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaEditorApplication.js","sourceRoot":"","sources":["../src/NestiaEditorApplication.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA2C;AAC3C,kDAA0B;AAE1B,6DAA0D;AAC1D,iEAA8D;AAE9D;IACE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAE9D,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,CAAC,GAAS,EAAE;YACV,IAAI,CAAC;gBACH,QAAQ,CAAC,MAAM,QAAQ,EAAE,CAAC,CAAC;YAC7B,CAAC;uBAAO,CAAC;gBACP,QAAQ,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAA,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,kDAAK,CAAC;IAElC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CACtB,uBAAC,uCAAkB,IACjB,OAAO,EAAE,KAAK,CAAC,GAAG,EAClB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,IAAI,EAAE,KAAK,CAAC,IAAI,GAChB,CACH,CAAC,CAAC,CAAC,CACF,iCACE,KAAK,EAAE;YACL,OAAO,EAAE,EAAE;SACZ,aAED,uBAAC,qBAAU,IAAC,OAAO,EAAC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AC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;YACtC,OAAO,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,0DAA6B;YACrD,GAAG;YACH,OAAO,EACL,OAAO,KAAK,IAAI;gBACd,CAAC,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,GAAG;gBAC3D,CAAC,CAAC,KAAK;YACX,QAAQ,EACN,QAAQ,KAAK,IAAI;gBACf,CAAC,CAAC,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,GAAG;gBAC9D,CAAC,CAAC,KAAK;YACX,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK;SAC1E,CAAC;IACJ,CAAC;CAAA;AAED,SAAe,WAAW,CAAC,IAAY;;QACrC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAa,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;YAC7C,OAAO,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/C,CAAC;mBAAO,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import "./internal/NestiaEditorDefaultPackage.mjs";
|
|
1
2
|
import { NestiaEditorIframe } from "./NestiaEditorIframe.mjs";
|
|
2
3
|
import { NestiaEditorUploader } from "./NestiaEditorUploader.mjs";
|
|
3
4
|
import { Typography } from "@mui/material";
|
|
4
5
|
import React from "react";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
//#region src/NestiaEditorApplication.tsx
|
|
8
|
+
/**
|
|
9
|
+
* The static editor page: converts an OpenAPI document into a downloadable project.
|
|
10
|
+
*
|
|
11
|
+
* The page reads its settings from the query string (`url`, `mode`, `package`, `keyword`, `simulate`, `e2e`) and from `window` globals the served `index.html` sets. It renders the iframe flow when a document location is given, or when `swagger.json` or `swagger.yaml` is served beside the page, and the uploader otherwise. The `uploader` query key forces the uploader.
|
|
12
|
+
*
|
|
13
|
+
* @evidence contracts/common.md#principled-implementation An explicit query URL is forwarded to the iframe, which loads it and reports a fetch error. Without one, swagger.json and then swagger.yaml are probed for HTTP 200; absent or failed lookup falls back to the uploader. Parsed generation options, including keyword, are passed to the iframe rather than replaced by its direct-component defaults.
|
|
14
|
+
* @evidence contracts/common.md#clear-and-simple-design One component chooses between two existing components; the query and probing logic stays in the private `getAsset` and `findSwagger`, and option parsing lives in one place.
|
|
15
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The package name default comes from the shared constant, and no document name, host, or fixture is special-cased; booleans accept only `true` and `1`, as the query contract states.
|
|
16
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the page does, where each setting comes from, the lookup order, and the `uploader` override.
|
|
17
|
+
*/
|
|
7
18
|
function NestiaEditorApplication() {
|
|
8
19
|
const [ready, setReady] = React.useState(false);
|
|
9
20
|
const [asset, setAsset] = React.useState(null);
|
|
@@ -21,6 +32,7 @@ function NestiaEditorApplication() {
|
|
|
21
32
|
return asset !== null ? /* @__PURE__ */ jsx(NestiaEditorIframe, {
|
|
22
33
|
swagger: asset.url,
|
|
23
34
|
package: asset.package,
|
|
35
|
+
keyword: asset.keyword,
|
|
24
36
|
simulate: asset.simulate,
|
|
25
37
|
e2e: asset.e2e,
|
|
26
38
|
mode: asset.mode
|
|
@@ -58,7 +70,11 @@ async function getAsset() {
|
|
|
58
70
|
};
|
|
59
71
|
}
|
|
60
72
|
async function findSwagger(file) {
|
|
61
|
-
|
|
73
|
+
try {
|
|
74
|
+
return (await fetch(file)).status === 200 ? file : null;
|
|
75
|
+
} catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
62
78
|
}
|
|
63
79
|
//#endregion
|
|
64
80
|
export { NestiaEditorApplication };
|
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@typia/interface";
|
|
2
|
+
/**
|
|
3
|
+
* Composes a project from an OpenAPI document and offers it as a zip download.
|
|
4
|
+
*
|
|
5
|
+
* The component loads the document, from a URL or from the object given,
|
|
6
|
+
* generates the project in the browser, and shows the three stages as a
|
|
7
|
+
* stepper. A fetch failure or a composition failure is reported in place of the
|
|
8
|
+
* stage's progress, and the operations the composer could not convert are
|
|
9
|
+
* listed beside the download, so an incomplete project never passes for a
|
|
10
|
+
* complete one.
|
|
11
|
+
*
|
|
12
|
+
* @evidence contracts/common.md#principled-implementation The three stages run once, in order, from an effect: load the document, compose it with NestiaEditorComposer, and expose the files for download. Document-loading and composer failure results set their stage error states. Operations the composer skipped are listed with the download. Unexpected errors outside these operations are logged by the outer catch without setting an error state; only completed stages advance the stepper.
|
|
13
|
+
* @evidence contracts/common.md#clear-and-simple-design One component owns the stepper state; document loading and operation counting stay in the private `getDocument` and `aggregateOperation`, and archiving and composition are delegated to their own namespaces.
|
|
14
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The option defaults (keyword, simulate, e2e enabled) are the documented product defaults, and the archive name comes from the shared default package constant, not from a fixture name.
|
|
15
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the stages and how failures appear.
|
|
16
|
+
*/
|
|
2
17
|
export declare function NestiaEditorIframe(props: NestiaEditorIframe.IProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Properties of {@link NestiaEditorIframe}.
|
|
20
|
+
*
|
|
21
|
+
* `swagger` is an OpenAPI document or the URL to fetch it from. The options
|
|
22
|
+
* mirror the generator options; `mode` is internal.
|
|
23
|
+
*
|
|
24
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds the property type of the component with the same name, so the component and its inputs are one public identity.
|
|
25
|
+
* @evidence contracts/common.md#clear-and-simple-design It contains one interface and nothing else.
|
|
26
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It adds no behavior; the option defaults live in the component that reads them.
|
|
27
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what `swagger` accepts and which members are internal.
|
|
28
|
+
*/
|
|
3
29
|
export declare namespace NestiaEditorIframe {
|
|
4
30
|
interface IProps {
|
|
31
|
+
/** Source document or URL loaded once when this component mounts. */
|
|
5
32
|
swagger: string | SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument;
|
|
33
|
+
/** Generated package identity; defaults to @ORGANIZATION/PROJECT. */
|
|
6
34
|
package?: string;
|
|
35
|
+
/** Enable keyword parameter objects; enabled when omitted. */
|
|
7
36
|
keyword?: boolean;
|
|
37
|
+
/** Include SDK simulators; enabled when omitted. */
|
|
8
38
|
simulate?: boolean;
|
|
39
|
+
/** Include generated E2E functions; enabled when omitted. */
|
|
9
40
|
e2e?: boolean;
|
|
10
41
|
}
|
|
11
42
|
}
|
|
@@ -19,6 +19,22 @@ const js_yaml_1 = require("js-yaml");
|
|
|
19
19
|
const react_1 = __importDefault(require("react"));
|
|
20
20
|
const NestiaEditorArchiver_1 = require("./internal/NestiaEditorArchiver");
|
|
21
21
|
const NestiaEditorComposer_1 = require("./internal/NestiaEditorComposer");
|
|
22
|
+
const NestiaEditorDefaultPackage_1 = require("./internal/NestiaEditorDefaultPackage");
|
|
23
|
+
/**
|
|
24
|
+
* Composes a project from an OpenAPI document and offers it as a zip download.
|
|
25
|
+
*
|
|
26
|
+
* The component loads the document, from a URL or from the object given,
|
|
27
|
+
* generates the project in the browser, and shows the three stages as a
|
|
28
|
+
* stepper. A fetch failure or a composition failure is reported in place of the
|
|
29
|
+
* stage's progress, and the operations the composer could not convert are
|
|
30
|
+
* listed beside the download, so an incomplete project never passes for a
|
|
31
|
+
* complete one.
|
|
32
|
+
*
|
|
33
|
+
* @evidence contracts/common.md#principled-implementation The three stages run once, in order, from an effect: load the document, compose it with NestiaEditorComposer, and expose the files for download. Document-loading and composer failure results set their stage error states. Operations the composer skipped are listed with the download. Unexpected errors outside these operations are logged by the outer catch without setting an error state; only completed stages advance the stepper.
|
|
34
|
+
* @evidence contracts/common.md#clear-and-simple-design One component owns the stepper state; document loading and operation counting stay in the private `getDocument` and `aggregateOperation`, and archiving and composition are delegated to their own namespaces.
|
|
35
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The option defaults (keyword, simulate, e2e enabled) are the documented product defaults, and the archive name comes from the shared default package constant, not from a fixture name.
|
|
36
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the stages and how failures appear.
|
|
37
|
+
*/
|
|
22
38
|
function NestiaEditorIframe(props) {
|
|
23
39
|
var _a;
|
|
24
40
|
const [step, setStep] = react_1.default.useState(0);
|
|
@@ -26,7 +42,8 @@ function NestiaEditorIframe(props) {
|
|
|
26
42
|
const [operations, setOperationCount] = react_1.default.useState({});
|
|
27
43
|
const [composerError, setComposerError] = react_1.default.useState(null);
|
|
28
44
|
const [files, setFiles] = react_1.default.useState(null);
|
|
29
|
-
const
|
|
45
|
+
const [skipped, setSkipped] = react_1.default.useState([]);
|
|
46
|
+
const archive = NestiaEditorArchiver_1.NestiaEditorArchiver.name((_a = props.package) !== null && _a !== void 0 ? _a : NestiaEditorDefaultPackage_1.NESTIA_EDITOR_DEFAULT_PACKAGE);
|
|
30
47
|
react_1.default.useEffect(() => {
|
|
31
48
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
32
49
|
// LOADING OPENAPI DOCUMENTS
|
|
@@ -50,7 +67,7 @@ function NestiaEditorIframe(props) {
|
|
|
50
67
|
keyword: (_b = props.keyword) !== null && _b !== void 0 ? _b : true,
|
|
51
68
|
simulate: (_c = props.simulate) !== null && _c !== void 0 ? _c : true,
|
|
52
69
|
e2e: (_d = props.e2e) !== null && _d !== void 0 ? _d : true,
|
|
53
|
-
package: (_e = props.package) !== null && _e !== void 0 ? _e :
|
|
70
|
+
package: (_e = props.package) !== null && _e !== void 0 ? _e : NestiaEditorDefaultPackage_1.NESTIA_EDITOR_DEFAULT_PACKAGE,
|
|
54
71
|
});
|
|
55
72
|
}
|
|
56
73
|
catch (exp) {
|
|
@@ -67,6 +84,7 @@ function NestiaEditorIframe(props) {
|
|
|
67
84
|
}
|
|
68
85
|
// READY TO DOWNLOAD
|
|
69
86
|
setStep(2);
|
|
87
|
+
setSkipped(result.data.skipped);
|
|
70
88
|
setFiles(result.data.files);
|
|
71
89
|
}))().catch((exp) => {
|
|
72
90
|
console.error("unknown error", exp);
|
|
@@ -81,10 +99,10 @@ function NestiaEditorIframe(props) {
|
|
|
81
99
|
overflow: "auto",
|
|
82
100
|
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", children: "Nestia Editor" }), (0, jsx_runtime_1.jsx)("hr", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)(material_1.Stepper, { activeStep: step, orientation: "vertical", nonLinear: true, children: [(0, jsx_runtime_1.jsxs)(material_1.Step, { children: [(0, jsx_runtime_1.jsx)(material_1.StepLabel, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", children: "Loading OpenAPI Document" }) }), (0, jsx_runtime_1.jsxs)(material_1.StepContent, { children: [(0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 100, color: "success" }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), typeof props.swagger === "string" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { children: "Fetching OpenAPI Document from" }), (0, jsx_runtime_1.jsx)("p", { children: (0, jsx_runtime_1.jsx)("a", { href: props.swagger, target: "_blank", children: props.swagger }) })] })) : ("Delivering OpenAPI Document to the composer"), fetchError !== null ? ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "error", children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: "Fetch Error" }), fetchError] })) : null] })] }, 0), (0, jsx_runtime_1.jsxs)(material_1.Step, { children: [(0, jsx_runtime_1.jsx)(material_1.StepLabel, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", children: "Generating Software Development Kit" }) }), (0, jsx_runtime_1.jsxs)(material_1.StepContent, { children: [(0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 100, color: "success" }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), "Generating SDK functions...", (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["total operations: #", Object.values(operations)
|
|
83
101
|
.reduce((a, b) => a + b, 0)
|
|
84
|
-
.toLocaleString()] }), Object.entries(operations).map(([method, count]) => ((0, jsx_runtime_1.jsxs)("li", { children: [method, ": #", count.toLocaleString()] })))] }), composerError !== null ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "error", children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: "Composition Error" }), (0, jsx_runtime_1.jsx)("pre", { children: JSON.stringify(composerError, null, 2) })] })] })) : null] })] }, 1), (0, jsx_runtime_1.jsxs)(material_1.Step, { children: [(0, jsx_runtime_1.jsx)(material_1.StepLabel, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", children: "Downloading TypeScript Project" }) }), (0, jsx_runtime_1.jsxs)(material_1.StepContent, { children: [(0, jsx_runtime_1.jsx)("br", {}), files !== null ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("p", { children: [Object.keys(files).length.toLocaleString(), " files are ready."] }), (0, jsx_runtime_1.jsxs)(material_1.Button, { variant: "contained", color: "success", size: "large", onClick: () => NestiaEditorArchiver_1.NestiaEditorArchiver.download({
|
|
102
|
+
.toLocaleString()] }), Object.entries(operations).map(([method, count]) => ((0, jsx_runtime_1.jsxs)("li", { children: [method, ": #", count.toLocaleString()] }, method)))] }), composerError !== null ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "error", children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: "Composition Error" }), (0, jsx_runtime_1.jsx)("pre", { children: JSON.stringify(composerError, null, 2) })] })] })) : null] })] }, 1), (0, jsx_runtime_1.jsxs)(material_1.Step, { children: [(0, jsx_runtime_1.jsx)(material_1.StepLabel, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", children: "Downloading TypeScript Project" }) }), (0, jsx_runtime_1.jsxs)(material_1.StepContent, { children: [(0, jsx_runtime_1.jsx)("br", {}), files !== null ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("p", { children: [Object.keys(files).length.toLocaleString(), " files are ready."] }), (0, jsx_runtime_1.jsxs)(material_1.Button, { variant: "contained", color: "success", size: "large", onClick: () => NestiaEditorArchiver_1.NestiaEditorArchiver.download({
|
|
85
103
|
name: archive,
|
|
86
104
|
files,
|
|
87
|
-
}), children: ["Download ", archive] })] })) : null] })] }, 2)] })] }) }));
|
|
105
|
+
}), children: ["Download ", archive] }), skipped.length !== 0 ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "warning", children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: "Skipped Operations" }), "The project leaves out operations that could not be converted:", (0, jsx_runtime_1.jsx)("ul", { children: skipped.map((s) => ((0, jsx_runtime_1.jsxs)("li", { children: [s.method, " ", s.path, ": ", s.messages.join(" ")] }, `${s.method} ${s.path}`))) })] })] })) : null] })) : null] })] }, 2)] })] }) }));
|
|
88
106
|
}
|
|
89
107
|
const getDocument = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
108
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaEditorIframe.js","sourceRoot":"","sources":["../src/NestiaEditorIframe.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAUuB;AAEvB,qCAA+B;AAC/B,kDAA0B;AAG1B,0EAAuE;AACvE,0EAAuE;
|
|
1
|
+
{"version":3,"file":"NestiaEditorIframe.js","sourceRoot":"","sources":["../src/NestiaEditorIframe.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAUuB;AAEvB,qCAA+B;AAC/B,kDAA0B;AAG1B,0EAAuE;AACvE,0EAAuE;AACvE,sFAAsF;AAEtF;;;;;;;;;;;;;;GAcG;AACH,4BAAmC,KAAgC;;IACjE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACxE,MAAM,CAAC,UAAU,EAAE,iBAAiB,CAAC,GAAG,eAAK,CAAC,QAAQ,CAEpD,EAAE,CAAC,CAAC;IACN,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAa,IAAI,CAAC,CAAC;IAC3E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAgC,IAAI,CAAC,CAAC;IAC9E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAK,CAAC,QAAQ,CAC1C,EAAE,CACH,CAAC;IACF,MAAM,OAAO,GAAW,2CAAoB,CAAC,IA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YAC3C,OAAO,IAAA,cAAI,EAAC,IAAI,CAAwB,CAAC;QAC3C,CAAC;QACD,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK;YAAE,OAAO,KAAK,CAAC,OAAO,CAAC;QACjD,OAAO,eAAe,CAAC;IACzB,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,QAA2E,EACnD,EAAE;;IAC1B,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,IAAI,CAAC,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC;IACrE,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,MAAM,OAAC,QAAQ,CAAC,KAAK,mCAAI,EAAE,CAAC;QAC1D,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI;YACvD,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;gBAC/C,IACE,MAAM,KAAK,MAAM;oBACjB,MAAM,KAAK,KAAK;oBAChB,MAAM,KAAK,MAAM;oBACjB,MAAM,KAAK,OAAO;oBAClB,MAAM,KAAK,KAAK;oBAChB,MAAM,KAAK,QAAQ;oBAEnB,GAAG,CAAC,MAAM,CAAC,GAAG,OAAC,GAAG,CAAC,MAAM,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./internal/NestiaEditorDefaultPackage.mjs";
|
|
1
2
|
import { NestiaEditorArchiver } from "./internal/NestiaEditorArchiver.mjs";
|
|
2
3
|
import { NestiaEditorComposer } from "./internal/NestiaEditorComposer.mjs";
|
|
3
4
|
import { Alert, AlertTitle, Button, CircularProgress, Step, StepContent, StepLabel, Stepper, Typography } from "@mui/material";
|
|
@@ -5,12 +6,28 @@ import React from "react";
|
|
|
5
6
|
import { load } from "js-yaml";
|
|
6
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
//#region src/NestiaEditorIframe.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Composes a project from an OpenAPI document and offers it as a zip download.
|
|
11
|
+
*
|
|
12
|
+
* The component loads the document, from a URL or from the object given,
|
|
13
|
+
* generates the project in the browser, and shows the three stages as a
|
|
14
|
+
* stepper. A fetch failure or a composition failure is reported in place of the
|
|
15
|
+
* stage's progress, and the operations the composer could not convert are
|
|
16
|
+
* listed beside the download, so an incomplete project never passes for a
|
|
17
|
+
* complete one.
|
|
18
|
+
*
|
|
19
|
+
* @evidence contracts/common.md#principled-implementation The three stages run once, in order, from an effect: load the document, compose it with NestiaEditorComposer, and expose the files for download. Document-loading and composer failure results set their stage error states. Operations the composer skipped are listed with the download. Unexpected errors outside these operations are logged by the outer catch without setting an error state; only completed stages advance the stepper.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design One component owns the stepper state; document loading and operation counting stay in the private `getDocument` and `aggregateOperation`, and archiving and composition are delegated to their own namespaces.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The option defaults (keyword, simulate, e2e enabled) are the documented product defaults, and the archive name comes from the shared default package constant, not from a fixture name.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the stages and how failures appear.
|
|
23
|
+
*/
|
|
8
24
|
function NestiaEditorIframe(props) {
|
|
9
25
|
const [step, setStep] = React.useState(0);
|
|
10
26
|
const [fetchError, setFetchError] = React.useState(null);
|
|
11
27
|
const [operations, setOperationCount] = React.useState({});
|
|
12
28
|
const [composerError, setComposerError] = React.useState(null);
|
|
13
29
|
const [files, setFiles] = React.useState(null);
|
|
30
|
+
const [skipped, setSkipped] = React.useState([]);
|
|
14
31
|
const archive = NestiaEditorArchiver.name(props.package ?? "@ORGANIZATION/PROJECT");
|
|
15
32
|
React.useEffect(() => {
|
|
16
33
|
(async () => {
|
|
@@ -43,6 +60,7 @@ function NestiaEditorIframe(props) {
|
|
|
43
60
|
return;
|
|
44
61
|
}
|
|
45
62
|
setStep(2);
|
|
63
|
+
setSkipped(result.data.skipped);
|
|
46
64
|
setFiles(result.data.files);
|
|
47
65
|
})().catch((exp) => {
|
|
48
66
|
console.error("unknown error", exp);
|
|
@@ -109,7 +127,7 @@ function NestiaEditorIframe(props) {
|
|
|
109
127
|
method,
|
|
110
128
|
": #",
|
|
111
129
|
count.toLocaleString()
|
|
112
|
-
] }))] }),
|
|
130
|
+
] }, method))] }),
|
|
113
131
|
composerError !== null ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsxs(Alert, {
|
|
114
132
|
severity: "error",
|
|
115
133
|
children: [/* @__PURE__ */ jsx(AlertTitle, { children: "Composition Error" }), /* @__PURE__ */ jsx("pre", { children: JSON.stringify(composerError, null, 2) })]
|
|
@@ -118,16 +136,37 @@ function NestiaEditorIframe(props) {
|
|
|
118
136
|
/* @__PURE__ */ jsxs(Step, { children: [/* @__PURE__ */ jsx(StepLabel, { children: /* @__PURE__ */ jsx(Typography, {
|
|
119
137
|
variant: "h5",
|
|
120
138
|
children: "Downloading TypeScript Project"
|
|
121
|
-
}) }), /* @__PURE__ */ jsxs(StepContent, { children: [/* @__PURE__ */ jsx("br", {}), files !== null ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
139
|
+
}) }), /* @__PURE__ */ jsxs(StepContent, { children: [/* @__PURE__ */ jsx("br", {}), files !== null ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
140
|
+
/* @__PURE__ */ jsxs("p", { children: [Object.keys(files).length.toLocaleString(), " files are ready."] }),
|
|
141
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
142
|
+
variant: "contained",
|
|
143
|
+
color: "success",
|
|
144
|
+
size: "large",
|
|
145
|
+
onClick: () => NestiaEditorArchiver.download({
|
|
146
|
+
name: archive,
|
|
147
|
+
files
|
|
148
|
+
}),
|
|
149
|
+
children: ["Download ", archive]
|
|
128
150
|
}),
|
|
129
|
-
children: [
|
|
130
|
-
|
|
151
|
+
skipped.length !== 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
152
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
153
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
154
|
+
/* @__PURE__ */ jsxs(Alert, {
|
|
155
|
+
severity: "warning",
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: "Skipped Operations" }),
|
|
158
|
+
"The project leaves out operations that could not be converted:",
|
|
159
|
+
/* @__PURE__ */ jsx("ul", { children: skipped.map((s) => /* @__PURE__ */ jsxs("li", { children: [
|
|
160
|
+
s.method,
|
|
161
|
+
" ",
|
|
162
|
+
s.path,
|
|
163
|
+
": ",
|
|
164
|
+
s.messages.join(" ")
|
|
165
|
+
] }, `${s.method} ${s.path}`)) })
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
] }) : null
|
|
169
|
+
] }) : null] })] }, 2)
|
|
131
170
|
]
|
|
132
171
|
})
|
|
133
172
|
]
|
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
import type { OpenApiV3, OpenApiV3_1, OpenApiV3_2, SwaggerV2 } from "@typia/interface";
|
|
2
|
+
/**
|
|
3
|
+
* Serves the editor from a NestJS application.
|
|
4
|
+
*
|
|
5
|
+
* Call {@link setup} before `listen()` to expose the editor page, its bundle,
|
|
6
|
+
* and the OpenAPI document under a path of the application.
|
|
7
|
+
*
|
|
8
|
+
* @evidence contracts/common.md#principled-implementation The module registers static routes on the application's own HTTP adapter, so the editor needs no second server.
|
|
9
|
+
* @evidence contracts/common.md#clear-and-simple-design One namespace with one entry point; asset reading and location resolution stay in module-private helpers.
|
|
10
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The routes use the adapter's public `get` method, and the one read of NestJS internals is the global prefix, described at `setup`.
|
|
11
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the entry point and that it must run before `listen()`.
|
|
12
|
+
*/
|
|
2
13
|
export declare namespace NestiaEditorModule {
|
|
14
|
+
/**
|
|
15
|
+
* Registers the editor routes on a NestJS application.
|
|
16
|
+
*
|
|
17
|
+
* The routes are `<prefix>/index.html`, the bundle under `<prefix>/assets/`,
|
|
18
|
+
* `<prefix>/swagger.json`, and redirects from `<prefix>` and `<prefix>/` to
|
|
19
|
+
* the page, where the prefix joins the application's global prefix and
|
|
20
|
+
* `path`. A document given as an object is served as is. A document given by
|
|
21
|
+
* location is fetched on the first request, after `listen()`, because a path
|
|
22
|
+
* is resolved against the address the application listens on, and the fetched
|
|
23
|
+
* document is cached; a failed fetch answers 502 and is not cached.
|
|
24
|
+
*
|
|
25
|
+
* Setup reads each page-referenced JavaScript asset once. Static setup work
|
|
26
|
+
* scales with page and asset bytes; later requests reuse the registered
|
|
27
|
+
* strings. A location-based document is fetched and serialized on demand.
|
|
28
|
+
*
|
|
29
|
+
* Each Swagger route shares one successful serialized document and one
|
|
30
|
+
* in-flight fetch. A failed fetch clears the pending promise so later
|
|
31
|
+
* requests can try again. The location and document remain fixed for that
|
|
32
|
+
* registration.
|
|
33
|
+
*
|
|
34
|
+
* The application adapter owns the registered closures and their strings for
|
|
35
|
+
* the route lifetime. Setup creates no process-global history. This API
|
|
36
|
+
* supplies no fetch cancellation or timeout, so an unresolved request remains
|
|
37
|
+
* pending until its transport settles.
|
|
38
|
+
*
|
|
39
|
+
* Built assets use Node filesystem APIs and native path joining from the
|
|
40
|
+
* installed module directory. Page script URLs are validated independently
|
|
41
|
+
* from filesystem paths. Swagger locations use URL resolution against
|
|
42
|
+
* application.getUrl.
|
|
43
|
+
*
|
|
44
|
+
* @evidence contracts/common.md#principled-implementation The prefix is built by joining the global prefix and the path and dropping empty segments, so slashes never double; the static files are read once at setup, and the swagger route is lazy for a location because the listening address, which relative locations need, does not exist before `listen()`.
|
|
45
|
+
* @evidence contracts/common.md#clear-and-simple-design One function performs the registration; reading the built page and bundle, reading the global prefix, and resolving a location are separate module-private helpers.
|
|
46
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts NestJS exposes no public getter for the global prefix, so `getGlobalPrefix` reads the internal `config.globalPrefix` and falls back to an empty prefix when it is absent; this is the single foreign-internal read, kept as a stated limitation rather than replaced by a shadow copy of the prefix.
|
|
47
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the routes and prefix rule, explains setup versus request-time work and cached-document ownership, and states the absent timeout/cancellation limitation.
|
|
48
|
+
*/
|
|
3
49
|
const setup: (props: {
|
|
4
50
|
path: string;
|
|
5
51
|
application: INestApplication;
|
|
@@ -41,26 +41,78 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
41
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
44
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
48
|
exports.NestiaEditorModule = void 0;
|
|
46
49
|
const fs = __importStar(require("fs"));
|
|
50
|
+
const path_1 = __importDefault(require("path"));
|
|
51
|
+
const NestiaEditorDefaultPackage_1 = require("./internal/NestiaEditorDefaultPackage");
|
|
52
|
+
/**
|
|
53
|
+
* Serves the editor from a NestJS application.
|
|
54
|
+
*
|
|
55
|
+
* Call {@link setup} before `listen()` to expose the editor page, its bundle,
|
|
56
|
+
* and the OpenAPI document under a path of the application.
|
|
57
|
+
*
|
|
58
|
+
* @evidence contracts/common.md#principled-implementation The module registers static routes on the application's own HTTP adapter, so the editor needs no second server.
|
|
59
|
+
* @evidence contracts/common.md#clear-and-simple-design One namespace with one entry point; asset reading and location resolution stay in module-private helpers.
|
|
60
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The routes use the adapter's public `get` method, and the one read of NestJS internals is the global prefix, described at `setup`.
|
|
61
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the entry point and that it must run before `listen()`.
|
|
62
|
+
*/
|
|
47
63
|
var NestiaEditorModule;
|
|
48
64
|
(function (NestiaEditorModule) {
|
|
65
|
+
/**
|
|
66
|
+
* Registers the editor routes on a NestJS application.
|
|
67
|
+
*
|
|
68
|
+
* The routes are `<prefix>/index.html`, the bundle under `<prefix>/assets/`,
|
|
69
|
+
* `<prefix>/swagger.json`, and redirects from `<prefix>` and `<prefix>/` to
|
|
70
|
+
* the page, where the prefix joins the application's global prefix and
|
|
71
|
+
* `path`. A document given as an object is served as is. A document given by
|
|
72
|
+
* location is fetched on the first request, after `listen()`, because a path
|
|
73
|
+
* is resolved against the address the application listens on, and the fetched
|
|
74
|
+
* document is cached; a failed fetch answers 502 and is not cached.
|
|
75
|
+
*
|
|
76
|
+
* Setup reads each page-referenced JavaScript asset once. Static setup work
|
|
77
|
+
* scales with page and asset bytes; later requests reuse the registered
|
|
78
|
+
* strings. A location-based document is fetched and serialized on demand.
|
|
79
|
+
*
|
|
80
|
+
* Each Swagger route shares one successful serialized document and one
|
|
81
|
+
* in-flight fetch. A failed fetch clears the pending promise so later
|
|
82
|
+
* requests can try again. The location and document remain fixed for that
|
|
83
|
+
* registration.
|
|
84
|
+
*
|
|
85
|
+
* The application adapter owns the registered closures and their strings for
|
|
86
|
+
* the route lifetime. Setup creates no process-global history. This API
|
|
87
|
+
* supplies no fetch cancellation or timeout, so an unresolved request remains
|
|
88
|
+
* pending until its transport settles.
|
|
89
|
+
*
|
|
90
|
+
* Built assets use Node filesystem APIs and native path joining from the
|
|
91
|
+
* installed module directory. Page script URLs are validated independently
|
|
92
|
+
* from filesystem paths. Swagger locations use URL resolution against
|
|
93
|
+
* application.getUrl.
|
|
94
|
+
*
|
|
95
|
+
* @evidence contracts/common.md#principled-implementation The prefix is built by joining the global prefix and the path and dropping empty segments, so slashes never double; the static files are read once at setup, and the swagger route is lazy for a location because the listening address, which relative locations need, does not exist before `listen()`.
|
|
96
|
+
* @evidence contracts/common.md#clear-and-simple-design One function performs the registration; reading the built page and bundle, reading the global prefix, and resolving a location are separate module-private helpers.
|
|
97
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts NestJS exposes no public getter for the global prefix, so `getGlobalPrefix` reads the internal `config.globalPrefix` and falls back to an empty prefix when it is absent; this is the single foreign-internal read, kept as a stated limitation rather than replaced by a shadow copy of the prefix.
|
|
98
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the routes and prefix rule, explains setup versus request-time work and cached-document ownership, and states the absent timeout/cancellation limitation.
|
|
99
|
+
*/
|
|
49
100
|
NestiaEditorModule.setup = (props) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const prefix =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
101
|
+
const prefix = [getGlobalPrefix(props.application), props.path]
|
|
102
|
+
.join("/")
|
|
103
|
+
.split("/")
|
|
104
|
+
.filter((str) => str.length !== 0)
|
|
105
|
+
.map((str) => "/" + str)
|
|
106
|
+
.join("");
|
|
56
107
|
const adaptor = props.application.getHttpAdapter();
|
|
108
|
+
const index = yield getIndex(props);
|
|
57
109
|
const staticFiles = [
|
|
58
110
|
{
|
|
59
111
|
path: "/index.html",
|
|
60
112
|
type: "text/html",
|
|
61
|
-
content:
|
|
113
|
+
content: index,
|
|
62
114
|
},
|
|
63
|
-
yield
|
|
115
|
+
...(yield getJavaScripts(index)),
|
|
64
116
|
];
|
|
65
117
|
for (const f of staticFiles) {
|
|
66
118
|
adaptor.get(prefix + f.path, (_, res) => {
|
|
@@ -75,9 +127,17 @@ var NestiaEditorModule;
|
|
|
75
127
|
let document = typeof props.swagger === "string"
|
|
76
128
|
? null
|
|
77
129
|
: JSON.stringify(props.swagger, null, 2);
|
|
130
|
+
let pending = null;
|
|
78
131
|
adaptor.get(prefix + "/swagger.json", (_, res) => __awaiter(this, void 0, void 0, function* () {
|
|
79
132
|
try {
|
|
80
|
-
|
|
133
|
+
if (document === null) {
|
|
134
|
+
pending !== null && pending !== void 0 ? pending : (pending = (() => __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
return JSON.stringify(yield getSwagger(yield resolveLocation(props.application, props.swagger)), null, 2);
|
|
136
|
+
}))().finally(() => {
|
|
137
|
+
pending = null;
|
|
138
|
+
}));
|
|
139
|
+
document = yield pending;
|
|
140
|
+
}
|
|
81
141
|
}
|
|
82
142
|
catch (error) {
|
|
83
143
|
res.status(502);
|
|
@@ -87,7 +147,7 @@ var NestiaEditorModule;
|
|
|
87
147
|
res.type("application/json");
|
|
88
148
|
return res.send(document);
|
|
89
149
|
}));
|
|
90
|
-
for (const p of ["", "/"])
|
|
150
|
+
for (const p of prefix.length === 0 ? ["/"] : ["", "/"])
|
|
91
151
|
adaptor.get(prefix + p, (_, res) => {
|
|
92
152
|
return res.redirect(prefix + "/index.html");
|
|
93
153
|
});
|
|
@@ -97,23 +157,35 @@ var NestiaEditorModule;
|
|
|
97
157
|
: ""; };
|
|
98
158
|
})(NestiaEditorModule || (exports.NestiaEditorModule = NestiaEditorModule = {}));
|
|
99
159
|
const getIndex = (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
-
var _a;
|
|
101
160
|
const content = yield fs.promises.readFile(`${__dirname}/../dist/index.html`, "utf8");
|
|
161
|
+
// Replacement functions, because a replacement string would read its dollar
|
|
162
|
+
// patterns, which a package name may legitimately contain.
|
|
102
163
|
return content
|
|
103
|
-
.replace(
|
|
104
|
-
.replace("window.simulate = false", `window.simulate = ${!!props.simulate}`)
|
|
105
|
-
.replace("window.e2e = false", `window.e2e = ${!!props.e2e}`);
|
|
164
|
+
.replace(JSON.stringify(NestiaEditorDefaultPackage_1.NESTIA_EDITOR_DEFAULT_PACKAGE), () => { var _a; return JSON.stringify((_a = props.package) !== null && _a !== void 0 ? _a : NestiaEditorDefaultPackage_1.NESTIA_EDITOR_DEFAULT_PACKAGE); })
|
|
165
|
+
.replace("window.simulate = false", () => `window.simulate = ${!!props.simulate}`)
|
|
166
|
+
.replace("window.e2e = false", () => `window.e2e = ${!!props.e2e}`);
|
|
106
167
|
});
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
168
|
+
const getJavaScripts = (index) => __awaiter(void 0, void 0, void 0, function* () {
|
|
169
|
+
const scripts = new Set();
|
|
170
|
+
for (const match of index.matchAll(/<script\b[^>]*\bsrc\s*=\s*(["'])(.*?)\1[^>]*>/gi)) {
|
|
171
|
+
const url = new URL(match[2], "https://nestia.invalid/");
|
|
172
|
+
if (url.origin !== "https://nestia.invalid" ||
|
|
173
|
+
url.pathname.startsWith("/assets/") === false ||
|
|
174
|
+
url.pathname.endsWith(".js") === false ||
|
|
175
|
+
url.search.length !== 0 ||
|
|
176
|
+
url.hash.length !== 0)
|
|
177
|
+
throw new Error(`Unsupported editor script asset: ${match[2]}`);
|
|
178
|
+
scripts.add(url.pathname);
|
|
179
|
+
}
|
|
180
|
+
if (scripts.size === 0)
|
|
181
|
+
throw new Error("The editor page references no JavaScript asset.");
|
|
182
|
+
return Promise.all([...scripts].map((asset) => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
+
return ({
|
|
184
|
+
path: asset,
|
|
185
|
+
type: "application/javascript",
|
|
186
|
+
content: yield fs.promises.readFile(path_1.default.join(__dirname, "../dist", asset.slice(1)), "utf8"),
|
|
187
|
+
});
|
|
188
|
+
})));
|
|
117
189
|
});
|
|
118
190
|
/** An absolute URL as is; a path of the application at its own address. */
|
|
119
191
|
const resolveLocation = (application, location) => __awaiter(void 0, void 0, void 0, function* () {
|