@nestia/editor 12.0.0-dev.20260601.1 → 12.0.0-dev.20260619.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/LICENSE +21 -21
- package/README.md +93 -93
- package/dist/assets/index-CogvJX1Y.js +4318 -0
- package/dist/index.html +19 -19
- package/lib/NestiaEditorApplication.mjs +3 -0
- package/lib/NestiaEditorApplication.mjs.map +1 -0
- package/lib/NestiaEditorApplication2.mjs +86 -0
- package/lib/NestiaEditorApplication2.mjs.map +1 -0
- package/lib/NestiaEditorIframe.mjs +3 -0
- package/lib/NestiaEditorIframe.mjs.map +1 -0
- package/lib/NestiaEditorIframe2.mjs +139 -0
- package/lib/NestiaEditorIframe2.mjs.map +1 -0
- package/lib/NestiaEditorModule.mjs +3 -0
- package/lib/NestiaEditorModule.mjs.map +1 -0
- package/lib/NestiaEditorModule2.mjs +124 -0
- package/lib/NestiaEditorModule2.mjs.map +1 -0
- package/lib/NestiaEditorUploader.mjs +3 -0
- package/lib/NestiaEditorUploader.mjs.map +1 -0
- package/lib/NestiaEditorUploader2.mjs +90 -0
- package/lib/NestiaEditorUploader2.mjs.map +1 -0
- package/lib/_virtual/NestiaEditorApplication.mjs +4 -0
- package/lib/_virtual/NestiaEditorApplication.mjs.map +1 -0
- package/lib/_virtual/NestiaEditorComposer.mjs +4 -0
- package/lib/_virtual/NestiaEditorComposer.mjs.map +1 -0
- package/lib/_virtual/NestiaEditorFileUploader.mjs +4 -0
- package/lib/_virtual/NestiaEditorFileUploader.mjs.map +1 -0
- package/lib/_virtual/NestiaEditorIframe.mjs +4 -0
- package/lib/_virtual/NestiaEditorIframe.mjs.map +1 -0
- package/lib/_virtual/NestiaEditorModule.mjs +4 -0
- package/lib/_virtual/NestiaEditorModule.mjs.map +1 -0
- package/lib/_virtual/NestiaEditorUploader.mjs +4 -0
- package/lib/_virtual/NestiaEditorUploader.mjs.map +1 -0
- package/lib/_virtual/_commonjsHelpers.mjs +35 -0
- package/lib/_virtual/_commonjsHelpers.mjs.map +1 -0
- package/lib/_virtual/_js-yaml.mjs +7 -0
- package/lib/_virtual/_js-yaml.mjs.map +1 -0
- package/lib/_virtual/_node_fs.mjs +7 -0
- package/lib/_virtual/_node_fs.mjs.map +1 -0
- package/lib/_virtual/_react-mui-fileuploader.mjs +7 -0
- package/lib/_virtual/_react-mui-fileuploader.mjs.map +1 -0
- package/lib/_virtual/_react.mjs +7 -0
- package/lib/_virtual/_react.mjs.map +1 -0
- package/lib/_virtual/client.mjs +7 -0
- package/lib/_virtual/client.mjs.map +1 -0
- package/lib/_virtual/estree.mjs +7 -0
- package/lib/_virtual/estree.mjs.map +1 -0
- package/lib/_virtual/index.mjs +4 -0
- package/lib/_virtual/index.mjs.map +1 -0
- package/lib/_virtual/jsx-runtime.mjs +7 -0
- package/lib/_virtual/jsx-runtime.mjs.map +1 -0
- package/lib/_virtual/main.mjs +4 -0
- package/lib/_virtual/main.mjs.map +1 -0
- package/lib/_virtual/material.mjs +7 -0
- package/lib/_virtual/material.mjs.map +1 -0
- package/lib/_virtual/migrate.mjs +7 -0
- package/lib/_virtual/migrate.mjs.map +1 -0
- package/lib/_virtual/sdk.mjs +7 -0
- package/lib/_virtual/sdk.mjs.map +1 -0
- package/lib/_virtual/standalone.mjs +7 -0
- package/lib/_virtual/standalone.mjs.map +1 -0
- package/lib/_virtual/typescript.mjs +7 -0
- package/lib/_virtual/typescript.mjs.map +1 -0
- package/lib/index.mjs +1 -444
- package/lib/index.mjs.map +1 -1
- package/lib/index2.mjs +35 -0
- package/lib/index2.mjs.map +1 -0
- package/lib/internal/NestiaEditorComposer.js +5 -2
- package/lib/internal/NestiaEditorComposer.js.map +1 -1
- package/lib/internal/NestiaEditorComposer.mjs +3 -0
- package/lib/internal/NestiaEditorComposer.mjs.map +1 -0
- package/lib/internal/NestiaEditorComposer2.mjs +111 -0
- package/lib/internal/NestiaEditorComposer2.mjs.map +1 -0
- package/lib/internal/NestiaEditorFileUploader.mjs +3 -0
- package/lib/internal/NestiaEditorFileUploader.mjs.map +1 -0
- package/lib/internal/NestiaEditorFileUploader2.mjs +52 -0
- package/lib/internal/NestiaEditorFileUploader2.mjs.map +1 -0
- package/lib/main.mjs +3 -0
- package/lib/main.mjs.map +1 -0
- package/lib/main2.mjs +16 -0
- package/lib/main2.mjs.map +1 -0
- package/package.json +10 -7
- package/src/NestiaEditorApplication.tsx +94 -94
- package/src/NestiaEditorIframe.tsx +245 -245
- package/src/NestiaEditorModule.ts +136 -136
- package/src/NestiaEditorUploader.tsx +154 -154
- package/src/index.ts +3 -3
- package/src/internal/NestiaEditorComposer.ts +91 -90
- package/src/internal/NestiaEditorFileUploader.tsx +68 -68
- package/src/main.tsx +10 -10
- package/src/vite-env.d.ts +1 -1
- package/dist/assets/index-CRivKjA9.js +0 -4342
|
@@ -1,90 +1,91 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import * as
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
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
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
1
|
+
import migrate from "@nestia/migrate";
|
|
2
|
+
import type { NestiaMigrateApplication } from "@nestia/migrate";
|
|
3
|
+
import {
|
|
4
|
+
OpenApiV3,
|
|
5
|
+
OpenApiV3_1,
|
|
6
|
+
OpenApiV3_2,
|
|
7
|
+
SwaggerV2,
|
|
8
|
+
} from "@typia/interface";
|
|
9
|
+
import * as prettierEsTreePlugin from "prettier/plugins/estree";
|
|
10
|
+
import * as prettierTsPlugin from "prettier/plugins/typescript";
|
|
11
|
+
import { format } from "prettier/standalone";
|
|
12
|
+
import { IValidation } from "typia";
|
|
13
|
+
|
|
14
|
+
export namespace NestiaEditorComposer {
|
|
15
|
+
export interface IProps {
|
|
16
|
+
document:
|
|
17
|
+
| SwaggerV2.IDocument
|
|
18
|
+
| OpenApiV3.IDocument
|
|
19
|
+
| OpenApiV3_1.IDocument
|
|
20
|
+
| OpenApiV3_2.IDocument;
|
|
21
|
+
e2e: boolean;
|
|
22
|
+
keyword: boolean;
|
|
23
|
+
simulate: boolean;
|
|
24
|
+
package?: string;
|
|
25
|
+
/** @internal */
|
|
26
|
+
files?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface IOutput {
|
|
29
|
+
files: Record<string, string>;
|
|
30
|
+
openFile: string;
|
|
31
|
+
startScript: string[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const nest = (props: IProps): Promise<IValidation<IOutput>> =>
|
|
35
|
+
compose({
|
|
36
|
+
openFile: "README.md,test/start.ts",
|
|
37
|
+
startScript: ["build:test,test", ""],
|
|
38
|
+
migrate: (app) => app.nest(props),
|
|
39
|
+
})(props);
|
|
40
|
+
|
|
41
|
+
export const sdk = async (props: IProps): Promise<IValidation<IOutput>> => {
|
|
42
|
+
console.log("NestiaEditorComposer.sdk()", props);
|
|
43
|
+
return compose({
|
|
44
|
+
openFile: "README.md,test/start.ts",
|
|
45
|
+
startScript: ["swagger", "hello"],
|
|
46
|
+
migrate: (app) => app.sdk(props),
|
|
47
|
+
})(props);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const compose =
|
|
51
|
+
(config: {
|
|
52
|
+
openFile: string;
|
|
53
|
+
startScript: string[];
|
|
54
|
+
migrate: (app: NestiaMigrateApplication) => Record<string, string>;
|
|
55
|
+
}) =>
|
|
56
|
+
async (props: IProps): Promise<IValidation<IOutput>> => {
|
|
57
|
+
if (props.files !== undefined)
|
|
58
|
+
return {
|
|
59
|
+
success: true,
|
|
60
|
+
data: {
|
|
61
|
+
files: props.files,
|
|
62
|
+
openFile: config.openFile,
|
|
63
|
+
startScript: config.startScript,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const result: IValidation<NestiaMigrateApplication> =
|
|
67
|
+
await migrate.NestiaMigrateApplication.validate(props.document);
|
|
68
|
+
if (result.success === false) return result;
|
|
69
|
+
|
|
70
|
+
const app: NestiaMigrateApplication = result.data;
|
|
71
|
+
const files: Record<string, string> = config.migrate(app);
|
|
72
|
+
for (const [key, value] of Object.entries(files))
|
|
73
|
+
if (key.substring(key.length - 3) === ".ts")
|
|
74
|
+
try {
|
|
75
|
+
files[key] = await format(value, {
|
|
76
|
+
parser: "typescript",
|
|
77
|
+
plugins: [prettierEsTreePlugin, prettierTsPlugin],
|
|
78
|
+
});
|
|
79
|
+
} catch (exp) {
|
|
80
|
+
console.log(exp);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
success: true,
|
|
84
|
+
data: {
|
|
85
|
+
files,
|
|
86
|
+
openFile: config.openFile,
|
|
87
|
+
startScript: config.startScript,
|
|
88
|
+
},
|
|
89
|
+
} satisfies IValidation<IOutput>;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@typia/interface";
|
|
2
|
-
import { load } from "js-yaml";
|
|
3
|
-
import React from "react";
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import FileUpload from "react-mui-fileuploader";
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
import { ExtendedFileProps } from "react-mui-fileuploader/dist/types/index.types";
|
|
8
|
-
|
|
9
|
-
export function NestiaEditorFileUploader(
|
|
10
|
-
props: NestiaEditorFileUploader.IProps,
|
|
11
|
-
) {
|
|
12
|
-
const [elements, setElements] = React.useState<ExtendedFileProps[]>([]);
|
|
13
|
-
const onChange = async (array: ExtendedFileProps[]) => {
|
|
14
|
-
if (array.length === 0) {
|
|
15
|
-
props.onChange(null, null);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const file: ExtendedFileProps = array[array.length - 1]!;
|
|
19
|
-
const buffer: ArrayBuffer = await file.arrayBuffer();
|
|
20
|
-
const content: string = new TextDecoder().decode(buffer);
|
|
21
|
-
const extension: "json" | "yaml" = file.name.split(".").pop()! as
|
|
22
|
-
| "json"
|
|
23
|
-
| "yaml";
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const json:
|
|
27
|
-
| SwaggerV2.IDocument
|
|
28
|
-
| OpenApiV3.IDocument
|
|
29
|
-
| OpenApiV3_1.IDocument =
|
|
30
|
-
extension === "json" ? JSON.parse(content) : load(content);
|
|
31
|
-
props.onChange(json, null);
|
|
32
|
-
} catch {
|
|
33
|
-
props.onChange(
|
|
34
|
-
null,
|
|
35
|
-
extension === "json" ? "Invalid JSON file" : "Invalid YAML file",
|
|
36
|
-
);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (array.length > 1) setElements([file]);
|
|
40
|
-
};
|
|
41
|
-
return (
|
|
42
|
-
<FileUpload
|
|
43
|
-
defaultFiles={elements}
|
|
44
|
-
onFilesChange={onChange}
|
|
45
|
-
acceptedType=".json, .yaml"
|
|
46
|
-
getBase64={false}
|
|
47
|
-
multiFile={false}
|
|
48
|
-
maxUploadFiles={1}
|
|
49
|
-
title="Swagger file uploader"
|
|
50
|
-
header="Drag and drop a Swagger file here"
|
|
51
|
-
buttonLabel="Click Here"
|
|
52
|
-
rightLabel="to select swagger.json/yaml file"
|
|
53
|
-
buttonRemoveLabel="Clear"
|
|
54
|
-
/>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
export namespace NestiaEditorFileUploader {
|
|
58
|
-
export interface IProps {
|
|
59
|
-
onChange: (
|
|
60
|
-
swagger:
|
|
61
|
-
| SwaggerV2.IDocument
|
|
62
|
-
| OpenApiV3.IDocument
|
|
63
|
-
| OpenApiV3_1.IDocument
|
|
64
|
-
| null,
|
|
65
|
-
error: string | null,
|
|
66
|
-
) => void;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
1
|
+
import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@typia/interface";
|
|
2
|
+
import { load } from "js-yaml";
|
|
3
|
+
import React from "react";
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import FileUpload from "react-mui-fileuploader";
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import { ExtendedFileProps } from "react-mui-fileuploader/dist/types/index.types";
|
|
8
|
+
|
|
9
|
+
export function NestiaEditorFileUploader(
|
|
10
|
+
props: NestiaEditorFileUploader.IProps,
|
|
11
|
+
) {
|
|
12
|
+
const [elements, setElements] = React.useState<ExtendedFileProps[]>([]);
|
|
13
|
+
const onChange = async (array: ExtendedFileProps[]) => {
|
|
14
|
+
if (array.length === 0) {
|
|
15
|
+
props.onChange(null, null);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const file: ExtendedFileProps = array[array.length - 1]!;
|
|
19
|
+
const buffer: ArrayBuffer = await file.arrayBuffer();
|
|
20
|
+
const content: string = new TextDecoder().decode(buffer);
|
|
21
|
+
const extension: "json" | "yaml" = file.name.split(".").pop()! as
|
|
22
|
+
| "json"
|
|
23
|
+
| "yaml";
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const json:
|
|
27
|
+
| SwaggerV2.IDocument
|
|
28
|
+
| OpenApiV3.IDocument
|
|
29
|
+
| OpenApiV3_1.IDocument =
|
|
30
|
+
extension === "json" ? JSON.parse(content) : load(content);
|
|
31
|
+
props.onChange(json, null);
|
|
32
|
+
} catch {
|
|
33
|
+
props.onChange(
|
|
34
|
+
null,
|
|
35
|
+
extension === "json" ? "Invalid JSON file" : "Invalid YAML file",
|
|
36
|
+
);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (array.length > 1) setElements([file]);
|
|
40
|
+
};
|
|
41
|
+
return (
|
|
42
|
+
<FileUpload
|
|
43
|
+
defaultFiles={elements}
|
|
44
|
+
onFilesChange={onChange}
|
|
45
|
+
acceptedType=".json, .yaml"
|
|
46
|
+
getBase64={false}
|
|
47
|
+
multiFile={false}
|
|
48
|
+
maxUploadFiles={1}
|
|
49
|
+
title="Swagger file uploader"
|
|
50
|
+
header="Drag and drop a Swagger file here"
|
|
51
|
+
buttonLabel="Click Here"
|
|
52
|
+
rightLabel="to select swagger.json/yaml file"
|
|
53
|
+
buttonRemoveLabel="Clear"
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
export namespace NestiaEditorFileUploader {
|
|
58
|
+
export interface IProps {
|
|
59
|
+
onChange: (
|
|
60
|
+
swagger:
|
|
61
|
+
| SwaggerV2.IDocument
|
|
62
|
+
| OpenApiV3.IDocument
|
|
63
|
+
| OpenApiV3_1.IDocument
|
|
64
|
+
| null,
|
|
65
|
+
error: string | null,
|
|
66
|
+
) => void;
|
|
67
|
+
}
|
|
68
|
+
}
|
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
|
+
);
|
package/src/vite-env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
1
|
+
/// <reference types="vite/client" />
|