@nestia/editor 0.1.3 → 0.2.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/lib/NestiaEditorApplication.js +141 -44
- package/lib/NestiaEditorApplication.js.map +1 -1
- package/lib/NestiaEditorIframe.js +199 -76
- package/lib/NestiaEditorIframe.js.map +1 -1
- package/lib/NestiaEditorUploader.js +117 -44
- package/lib/NestiaEditorUploader.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +18 -2
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +344 -0
- package/lib/index.mjs.map +1 -0
- package/lib/internal/NestiaEditorComposer.js +146 -50
- package/lib/internal/NestiaEditorComposer.js.map +1 -1
- package/lib/internal/NestiaEditorFileUploader.js +93 -25
- package/lib/internal/NestiaEditorFileUploader.js.map +1 -1
- package/lib/main.js +7 -5
- package/lib/main.js.map +1 -1
- package/package.json +69 -68
- package/src/NestiaEditorApplication.tsx +77 -75
- package/src/NestiaEditorIframe.tsx +11 -10
- package/src/NestiaEditorUploader.tsx +8 -8
- package/src/index.ts +2 -2
- package/src/main.tsx +10 -10
|
@@ -1,75 +1,77 @@
|
|
|
1
|
-
import { Typography } from "@mui/material";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { NestiaEditorIframe } from "./NestiaEditorIframe
|
|
5
|
-
import { NestiaEditorUploader } from "./NestiaEditorUploader
|
|
6
|
-
|
|
7
|
-
export function NestiaEditorApplication() {
|
|
8
|
-
const [ready, setReady] = useState(false);
|
|
9
|
-
const [asset, setAsset] = useState<IAsset | null>(null);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
import { Typography } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
import { NestiaEditorIframe } from "./NestiaEditorIframe";
|
|
5
|
+
import { NestiaEditorUploader } from "./NestiaEditorUploader";
|
|
6
|
+
|
|
7
|
+
export function NestiaEditorApplication() {
|
|
8
|
+
const [ready, setReady] = React.useState(false);
|
|
9
|
+
const [asset, setAsset] = React.useState<IAsset | null>(null);
|
|
10
|
+
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
(async () => {
|
|
13
|
+
try {
|
|
14
|
+
setAsset(await getAsset());
|
|
15
|
+
} catch {
|
|
16
|
+
setAsset(null);
|
|
17
|
+
}
|
|
18
|
+
setReady(true);
|
|
19
|
+
})().catch(() => {});
|
|
20
|
+
}, []);
|
|
21
|
+
if (ready === false) return <></>;
|
|
22
|
+
|
|
23
|
+
return asset !== null ? (
|
|
24
|
+
<NestiaEditorIframe
|
|
25
|
+
swagger={asset.url}
|
|
26
|
+
simulate={asset.simulate}
|
|
27
|
+
e2e={asset.e2e}
|
|
28
|
+
/>
|
|
29
|
+
) : (
|
|
30
|
+
<div
|
|
31
|
+
style={{
|
|
32
|
+
padding: 25,
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<Typography variant="h4">Nestia Editor</Typography>
|
|
36
|
+
<hr />
|
|
37
|
+
<br />
|
|
38
|
+
<NestiaEditorUploader />
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function getAsset(): Promise<IAsset | null> {
|
|
44
|
+
const index: number = window.location.href.indexOf("?");
|
|
45
|
+
if (index === -1) return null;
|
|
46
|
+
|
|
47
|
+
const query: URLSearchParams = new URLSearchParams(
|
|
48
|
+
window.location.href.substring(index + 1),
|
|
49
|
+
);
|
|
50
|
+
const url: string | null = query.get("url") ?? (await findSwagger());
|
|
51
|
+
if (url === null) return null;
|
|
52
|
+
try {
|
|
53
|
+
new URL(url);
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const simulate: string | null = query.get("simulate");
|
|
59
|
+
const e2e: string | null = query.get("e2e");
|
|
60
|
+
return {
|
|
61
|
+
url,
|
|
62
|
+
simulate:
|
|
63
|
+
simulate !== null ? simulate === "true" || simulate === "1" : true,
|
|
64
|
+
e2e: e2e !== null ? e2e === "true" || e2e === "1" : true,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function findSwagger(): Promise<string | null> {
|
|
69
|
+
const response: Response = await fetch("./swagger.json");
|
|
70
|
+
return response.status === 200 ? "./swagger.json" : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface IAsset {
|
|
74
|
+
url: string;
|
|
75
|
+
simulate: boolean;
|
|
76
|
+
e2e: boolean;
|
|
77
|
+
}
|
|
@@ -10,22 +10,23 @@ import {
|
|
|
10
10
|
} from "@mui/material";
|
|
11
11
|
import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@samchon/openapi";
|
|
12
12
|
import StackBlitzSDK from "@stackblitz/sdk";
|
|
13
|
-
import
|
|
14
|
-
import { JSONTree } from "react-json-tree";
|
|
13
|
+
import React from "react";
|
|
15
14
|
import { IValidation } from "typia";
|
|
16
15
|
|
|
17
|
-
import { NestiaEditorComposer } from "./internal/NestiaEditorComposer
|
|
16
|
+
import { NestiaEditorComposer } from "./internal/NestiaEditorComposer";
|
|
18
17
|
|
|
19
18
|
export function NestiaEditorIframe(props: NestiaEditorIframe.IProps) {
|
|
20
|
-
const [id] = useState(
|
|
19
|
+
const [id] = React.useState(
|
|
21
20
|
`reactia-editor-div-${Math.random().toString().substring(2)}`,
|
|
22
21
|
);
|
|
23
|
-
const [step, setStep] = useState(0);
|
|
24
|
-
const [fetchError, setFetchError] = useState<string | null>(null);
|
|
25
|
-
const [operations, setOperationCount] = useState<
|
|
26
|
-
|
|
22
|
+
const [step, setStep] = React.useState(0);
|
|
23
|
+
const [fetchError, setFetchError] = React.useState<string | null>(null);
|
|
24
|
+
const [operations, setOperationCount] = React.useState<
|
|
25
|
+
Record<string, number>
|
|
26
|
+
>({});
|
|
27
|
+
const [composerError, setComposerError] = React.useState<any | null>(null);
|
|
27
28
|
|
|
28
|
-
useEffect(() => {
|
|
29
|
+
React.useEffect(() => {
|
|
29
30
|
(async () => {
|
|
30
31
|
// LOADING OPENAPI DOCUMENTS
|
|
31
32
|
setStep(0);
|
|
@@ -152,7 +153,7 @@ export function NestiaEditorIframe(props: NestiaEditorIframe.IProps) {
|
|
|
152
153
|
<br />
|
|
153
154
|
<Alert severity="error">
|
|
154
155
|
<AlertTitle>Composition Error</AlertTitle>
|
|
155
|
-
<
|
|
156
|
+
<pre>{JSON.stringify(composerError, null, 2)}</pre>
|
|
156
157
|
</Alert>
|
|
157
158
|
</>
|
|
158
159
|
) : null}
|
|
@@ -9,22 +9,22 @@ import {
|
|
|
9
9
|
} from "@mui/material";
|
|
10
10
|
import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@samchon/openapi";
|
|
11
11
|
import StackBlitzSDK from "@stackblitz/sdk";
|
|
12
|
-
import
|
|
12
|
+
import React from "react";
|
|
13
13
|
|
|
14
|
-
import { NestiaEditorComposer } from "./internal/NestiaEditorComposer
|
|
15
|
-
import { NestiaEditorFileUploader } from "./internal/NestiaEditorFileUploader
|
|
14
|
+
import { NestiaEditorComposer } from "./internal/NestiaEditorComposer";
|
|
15
|
+
import { NestiaEditorFileUploader } from "./internal/NestiaEditorFileUploader";
|
|
16
16
|
|
|
17
17
|
export function NestiaEditorUploader(props: NestiaEditorUploader.IProps) {
|
|
18
18
|
// PARAMETERS
|
|
19
|
-
const [mode, setMode] = useState<"nest" | "sdk">("sdk");
|
|
20
|
-
const [simulate, setSimulate] = useState(true);
|
|
21
|
-
const [e2e, setE2e] = useState(true);
|
|
19
|
+
const [mode, setMode] = React.useState<"nest" | "sdk">("sdk");
|
|
20
|
+
const [simulate, setSimulate] = React.useState(true);
|
|
21
|
+
const [e2e, setE2e] = React.useState(true);
|
|
22
22
|
|
|
23
23
|
// RESULT
|
|
24
|
-
const [document, setDocument] = useState<
|
|
24
|
+
const [document, setDocument] = React.useState<
|
|
25
25
|
SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | null
|
|
26
26
|
>(null);
|
|
27
|
-
const [progress, setProgress] = useState(false);
|
|
27
|
+
const [progress, setProgress] = React.useState(false);
|
|
28
28
|
|
|
29
29
|
const handleError = (error: string) => {
|
|
30
30
|
if (props.onError) props.onError(error);
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./NestiaEditorIframe
|
|
2
|
-
export * from "./NestiaEditorUploader
|
|
1
|
+
export * from "./NestiaEditorIframe";
|
|
2
|
+
export * from "./NestiaEditorUploader";
|
package/src/main.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { StrictMode } from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
|
|
4
|
-
import { NestiaEditorApplication } from "./NestiaEditorApplication
|
|
5
|
-
|
|
6
|
-
createRoot(document.getElementById("root")!).render(
|
|
7
|
-
<StrictMode>
|
|
8
|
-
<NestiaEditorApplication />
|
|
9
|
-
</StrictMode>,
|
|
10
|
-
);
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
|
|
4
|
+
import { NestiaEditorApplication } from "./NestiaEditorApplication";
|
|
5
|
+
|
|
6
|
+
createRoot(document.getElementById("root")!).render(
|
|
7
|
+
<StrictMode>
|
|
8
|
+
<NestiaEditorApplication />
|
|
9
|
+
</StrictMode>,
|
|
10
|
+
);
|