@nestia/editor 12.0.0-rc.2 → 12.0.0-rc.4

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.
Files changed (100) hide show
  1. package/LICENSE +21 -21
  2. package/dist/assets/index-Wyu3BnMf.js +4289 -0
  3. package/dist/index.html +19 -19
  4. package/lib/NestiaEditorApplication.mjs +66 -3
  5. package/lib/NestiaEditorApplication.mjs.map +1 -1
  6. package/lib/NestiaEditorIframe.js +11 -17
  7. package/lib/NestiaEditorIframe.js.map +1 -1
  8. package/lib/NestiaEditorIframe.mjs +159 -3
  9. package/lib/NestiaEditorIframe.mjs.map +1 -1
  10. package/lib/NestiaEditorModule.mjs +51 -3
  11. package/lib/NestiaEditorModule.mjs.map +1 -1
  12. package/lib/NestiaEditorUploader.js +4 -11
  13. package/lib/NestiaEditorUploader.js.map +1 -1
  14. package/lib/NestiaEditorUploader.mjs +129 -3
  15. package/lib/NestiaEditorUploader.mjs.map +1 -1
  16. package/lib/index.mjs +4 -2
  17. package/lib/internal/NestiaEditorArchiver.d.ts +20 -0
  18. package/lib/internal/NestiaEditorArchiver.js +38 -0
  19. package/lib/internal/NestiaEditorArchiver.js.map +1 -0
  20. package/lib/internal/NestiaEditorArchiver.mjs +24 -0
  21. package/lib/internal/NestiaEditorArchiver.mjs.map +1 -0
  22. package/lib/internal/NestiaEditorComposer.mjs +52 -3
  23. package/lib/internal/NestiaEditorComposer.mjs.map +1 -1
  24. package/lib/internal/NestiaEditorFileUploader.mjs +43 -3
  25. package/lib/internal/NestiaEditorFileUploader.mjs.map +1 -1
  26. package/lib/main.mjs +9 -3
  27. package/lib/main.mjs.map +1 -1
  28. package/package.json +9 -12
  29. package/src/NestiaEditorApplication.tsx +94 -94
  30. package/src/NestiaEditorIframe.tsx +258 -245
  31. package/src/NestiaEditorModule.ts +136 -136
  32. package/src/NestiaEditorUploader.tsx +146 -154
  33. package/src/index.ts +3 -3
  34. package/src/internal/NestiaEditorArchiver.ts +43 -0
  35. package/src/internal/NestiaEditorComposer.ts +89 -89
  36. package/src/internal/NestiaEditorFileUploader.tsx +65 -65
  37. package/src/main.tsx +10 -10
  38. package/src/typings/react-mui-fileuploader.d.ts +27 -27
  39. package/src/vite-env.d.ts +1 -1
  40. package/README.md +0 -93
  41. package/dist/assets/index-tCs1FGcC.js +0 -4318
  42. package/lib/NestiaEditorApplication2.mjs +0 -86
  43. package/lib/NestiaEditorApplication2.mjs.map +0 -1
  44. package/lib/NestiaEditorIframe2.mjs +0 -139
  45. package/lib/NestiaEditorIframe2.mjs.map +0 -1
  46. package/lib/NestiaEditorModule2.mjs +0 -124
  47. package/lib/NestiaEditorModule2.mjs.map +0 -1
  48. package/lib/NestiaEditorUploader2.mjs +0 -90
  49. package/lib/NestiaEditorUploader2.mjs.map +0 -1
  50. package/lib/_virtual/NestiaEditorApplication.mjs +0 -4
  51. package/lib/_virtual/NestiaEditorApplication.mjs.map +0 -1
  52. package/lib/_virtual/NestiaEditorComposer.mjs +0 -4
  53. package/lib/_virtual/NestiaEditorComposer.mjs.map +0 -1
  54. package/lib/_virtual/NestiaEditorFileUploader.mjs +0 -4
  55. package/lib/_virtual/NestiaEditorFileUploader.mjs.map +0 -1
  56. package/lib/_virtual/NestiaEditorIframe.mjs +0 -4
  57. package/lib/_virtual/NestiaEditorIframe.mjs.map +0 -1
  58. package/lib/_virtual/NestiaEditorModule.mjs +0 -4
  59. package/lib/_virtual/NestiaEditorModule.mjs.map +0 -1
  60. package/lib/_virtual/NestiaEditorUploader.mjs +0 -4
  61. package/lib/_virtual/NestiaEditorUploader.mjs.map +0 -1
  62. package/lib/_virtual/_commonjsHelpers.mjs +0 -35
  63. package/lib/_virtual/_commonjsHelpers.mjs.map +0 -1
  64. package/lib/_virtual/_js-yaml.mjs +0 -7
  65. package/lib/_virtual/_js-yaml.mjs.map +0 -1
  66. package/lib/_virtual/_node_fs.mjs +0 -7
  67. package/lib/_virtual/_node_fs.mjs.map +0 -1
  68. package/lib/_virtual/_react-mui-fileuploader.mjs +0 -7
  69. package/lib/_virtual/_react-mui-fileuploader.mjs.map +0 -1
  70. package/lib/_virtual/_react.mjs +0 -7
  71. package/lib/_virtual/_react.mjs.map +0 -1
  72. package/lib/_virtual/client.mjs +0 -7
  73. package/lib/_virtual/client.mjs.map +0 -1
  74. package/lib/_virtual/estree.mjs +0 -7
  75. package/lib/_virtual/estree.mjs.map +0 -1
  76. package/lib/_virtual/index.mjs +0 -4
  77. package/lib/_virtual/index.mjs.map +0 -1
  78. package/lib/_virtual/jsx-runtime.mjs +0 -7
  79. package/lib/_virtual/jsx-runtime.mjs.map +0 -1
  80. package/lib/_virtual/main.mjs +0 -4
  81. package/lib/_virtual/main.mjs.map +0 -1
  82. package/lib/_virtual/material.mjs +0 -7
  83. package/lib/_virtual/material.mjs.map +0 -1
  84. package/lib/_virtual/migrate.mjs +0 -7
  85. package/lib/_virtual/migrate.mjs.map +0 -1
  86. package/lib/_virtual/sdk.mjs +0 -7
  87. package/lib/_virtual/sdk.mjs.map +0 -1
  88. package/lib/_virtual/standalone.mjs +0 -7
  89. package/lib/_virtual/standalone.mjs.map +0 -1
  90. package/lib/_virtual/typescript.mjs +0 -7
  91. package/lib/_virtual/typescript.mjs.map +0 -1
  92. package/lib/index.mjs.map +0 -1
  93. package/lib/index2.mjs +0 -35
  94. package/lib/index2.mjs.map +0 -1
  95. package/lib/internal/NestiaEditorComposer2.mjs +0 -110
  96. package/lib/internal/NestiaEditorComposer2.mjs.map +0 -1
  97. package/lib/internal/NestiaEditorFileUploader2.mjs +0 -51
  98. package/lib/internal/NestiaEditorFileUploader2.mjs.map +0 -1
  99. package/lib/main2.mjs +0 -16
  100. package/lib/main2.mjs.map +0 -1
@@ -1,245 +1,258 @@
1
- import {
2
- Alert,
3
- AlertTitle,
4
- CircularProgress,
5
- Step,
6
- StepContent,
7
- StepLabel,
8
- Stepper,
9
- Typography,
10
- } from "@mui/material";
11
- import StackBlitzSDK from "@stackblitz/sdk";
12
- import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@typia/interface";
13
- import { load } from "js-yaml";
14
- import React from "react";
15
- import { IValidation } from "typia";
16
-
17
- import { NestiaEditorComposer } from "./internal/NestiaEditorComposer";
18
-
19
- export function NestiaEditorIframe(props: NestiaEditorIframe.IProps) {
20
- const [id] = React.useState(
21
- `reactia-editor-div-${Math.random().toString().substring(2)}`,
22
- );
23
- const [step, setStep] = React.useState(0);
24
- const [fetchError, setFetchError] = React.useState<string | null>(null);
25
- const [operations, setOperationCount] = React.useState<
26
- Record<string, number>
27
- >({});
28
- const [composerError, setComposerError] = React.useState<any | null>(null);
29
-
30
- React.useEffect(() => {
31
- (async () => {
32
- // LOADING OPENAPI DOCUMENTS
33
- setStep(0);
34
- const document:
35
- | SwaggerV2.IDocument
36
- | OpenApiV3.IDocument
37
- | OpenApiV3_1.IDocument
38
- | string =
39
- typeof props.swagger === "string"
40
- ? await getDocument(props.swagger)
41
- : props.swagger;
42
- if (typeof document === "string") {
43
- setFetchError(document);
44
- return;
45
- } else setOperationCount(aggregateOperation(document));
46
-
47
- // GENERATING SOFTWARE DEVELOPMENT KIT
48
- setStep(1);
49
- const result: IValidation<NestiaEditorComposer.IOutput> =
50
- await (async () => {
51
- try {
52
- return await NestiaEditorComposer[props.mode ?? "sdk"]({
53
- document,
54
- keyword: props.keyword ?? true,
55
- simulate: props.simulate ?? true,
56
- e2e: props.e2e ?? true,
57
- package: props.package ?? "@ORGANIZATION/PROJECT",
58
- });
59
- } catch (exp) {
60
- return {
61
- success: false,
62
- errors: exp as any,
63
- data: undefined,
64
- } satisfies IValidation.IFailure;
65
- }
66
- })();
67
- if (result.success === false) {
68
- setComposerError(result.errors);
69
- return;
70
- }
71
-
72
- // COMPOSING STACKBLITZ PROJECT
73
- setStep(2);
74
- StackBlitzSDK.embedProject(
75
- id,
76
- {
77
- title: document.info?.title ?? "Nestia Editor",
78
- template: "node",
79
- files: result.data.files,
80
- },
81
- {
82
- width: "100%",
83
- height: "100%",
84
- openFile: result.data.openFile,
85
- startScript: result.data.startScript as any, // no problem
86
- },
87
- );
88
- })().catch((exp) => {
89
- console.error("unknown error", exp);
90
- });
91
- }, []);
92
- return (
93
- <div
94
- id={id}
95
- style={{
96
- width: "100%",
97
- height: "100%",
98
- overflow: "hidden",
99
- }}
100
- >
101
- <div
102
- style={{
103
- padding: 25,
104
- overflow: "auto",
105
- }}
106
- >
107
- <Typography variant="h4">Nestia Editor</Typography>
108
- <hr />
109
- <br />
110
- <Stepper activeStep={step} orientation="vertical" nonLinear={true}>
111
- <Step key={0}>
112
- <StepLabel>
113
- <Typography variant="h5">Loading OpenAPI Document</Typography>
114
- </StepLabel>
115
- <StepContent>
116
- <br />
117
- <CircularProgress size={100} color="success" />
118
- <br />
119
- <br />
120
- {typeof props.swagger === "string" ? (
121
- <>
122
- <p>Fetching OpenAPI Document from</p>
123
- <p>
124
- <a href={props.swagger} target="_blank">
125
- {props.swagger}
126
- </a>
127
- </p>
128
- </>
129
- ) : (
130
- "Delivering OpenAPI Document to the composer"
131
- )}
132
- {fetchError !== null ? (
133
- <Alert severity="error">
134
- <AlertTitle>Fetch Error</AlertTitle>
135
- {fetchError}
136
- </Alert>
137
- ) : null}
138
- </StepContent>
139
- </Step>
140
- <Step key={1}>
141
- <StepLabel>
142
- <Typography variant="h5">
143
- Generating Software Development Kit
144
- </Typography>
145
- </StepLabel>
146
- <StepContent>
147
- <br />
148
- <CircularProgress size={100} color="success" />
149
- <br />
150
- <br />
151
- Generating SDK functions...
152
- <br />
153
- <ul>
154
- <li>
155
- total operations: #
156
- {Object.values(operations)
157
- .reduce((a, b) => a + b, 0)
158
- .toLocaleString()}
159
- </li>
160
- {Object.entries(operations).map(([method, count]) => (
161
- <li>
162
- {method}: #{count.toLocaleString()}
163
- </li>
164
- ))}
165
- </ul>
166
- {composerError !== null ? (
167
- <>
168
- <br />
169
- <Alert severity="error">
170
- <AlertTitle>Composition Error</AlertTitle>
171
- <pre>{JSON.stringify(composerError, null, 2)}</pre>
172
- </Alert>
173
- </>
174
- ) : null}
175
- </StepContent>
176
- </Step>
177
- <Step key={2}>
178
- <StepLabel>
179
- <Typography variant="h5">Composing TypeScript Project</Typography>
180
- </StepLabel>
181
- <StepContent></StepContent>
182
- </Step>
183
- </Stepper>
184
- </div>
185
- </div>
186
- );
187
- }
188
- export namespace NestiaEditorIframe {
189
- export interface IProps {
190
- swagger:
191
- | string
192
- | SwaggerV2.IDocument
193
- | OpenApiV3.IDocument
194
- | OpenApiV3_1.IDocument;
195
- package?: string;
196
- keyword?: boolean;
197
- simulate?: boolean;
198
- e2e?: boolean;
199
-
200
- /** @internal */
201
- mode?: "nest" | "sdk";
202
-
203
- /** @internal */
204
- files?: Record<string, string>;
205
- }
206
- }
207
-
208
- const getDocument = async (
209
- url: string,
210
- ): Promise<
211
- SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | string
212
- > => {
213
- try {
214
- const response: Response = await fetch(url);
215
- if (response.status !== 200) return await response.text();
216
- else if (url.endsWith(".yaml")) {
217
- const text: string = await response.text();
218
- return load(text) as OpenApiV3.IDocument;
219
- }
220
- return await response.json();
221
- } catch (error) {
222
- if (error instanceof Error) return error.message;
223
- return "Unknown error";
224
- }
225
- };
226
-
227
- const aggregateOperation = (
228
- document: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument,
229
- ): Record<string, number> => {
230
- const map: Record<string, number> = {};
231
- if (!(typeof document === "object" && document !== null)) return map;
232
- for (const collection of Object.values(document.paths ?? {}))
233
- if (typeof collection === "object" && collection !== null)
234
- for (const [method] of Object.entries(collection))
235
- if (
236
- method === "head" ||
237
- method === "get" ||
238
- method === "post" ||
239
- method === "patch" ||
240
- method === "put" ||
241
- method === "delete"
242
- )
243
- map[method] = (map[method] ?? 0) + 1;
244
- return map;
245
- };
1
+ import {
2
+ Alert,
3
+ AlertTitle,
4
+ Button,
5
+ CircularProgress,
6
+ Step,
7
+ StepContent,
8
+ StepLabel,
9
+ Stepper,
10
+ Typography,
11
+ } from "@mui/material";
12
+ import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@typia/interface";
13
+ import { load } from "js-yaml";
14
+ import React from "react";
15
+ import { IValidation } from "typia";
16
+
17
+ import { NestiaEditorArchiver } from "./internal/NestiaEditorArchiver";
18
+ import { NestiaEditorComposer } from "./internal/NestiaEditorComposer";
19
+
20
+ export function NestiaEditorIframe(props: NestiaEditorIframe.IProps) {
21
+ const [step, setStep] = React.useState(0);
22
+ const [fetchError, setFetchError] = React.useState<string | null>(null);
23
+ const [operations, setOperationCount] = React.useState<
24
+ Record<string, number>
25
+ >({});
26
+ const [composerError, setComposerError] = React.useState<any | null>(null);
27
+ const [files, setFiles] = React.useState<Record<string, string> | null>(null);
28
+ const archive: string = NestiaEditorArchiver.name(
29
+ props.package ?? "@ORGANIZATION/PROJECT",
30
+ );
31
+
32
+ React.useEffect(() => {
33
+ (async () => {
34
+ // LOADING OPENAPI DOCUMENTS
35
+ setStep(0);
36
+ const document:
37
+ | SwaggerV2.IDocument
38
+ | OpenApiV3.IDocument
39
+ | OpenApiV3_1.IDocument
40
+ | string =
41
+ typeof props.swagger === "string"
42
+ ? await getDocument(props.swagger)
43
+ : props.swagger;
44
+ if (typeof document === "string") {
45
+ setFetchError(document);
46
+ return;
47
+ } else setOperationCount(aggregateOperation(document));
48
+
49
+ // GENERATING SOFTWARE DEVELOPMENT KIT
50
+ setStep(1);
51
+ const result: IValidation<NestiaEditorComposer.IOutput> =
52
+ await (async () => {
53
+ try {
54
+ return await NestiaEditorComposer[props.mode ?? "sdk"]({
55
+ document,
56
+ keyword: props.keyword ?? true,
57
+ simulate: props.simulate ?? true,
58
+ e2e: props.e2e ?? true,
59
+ package: props.package ?? "@ORGANIZATION/PROJECT",
60
+ });
61
+ } catch (exp) {
62
+ return {
63
+ success: false,
64
+ errors: exp as any,
65
+ data: undefined,
66
+ } satisfies IValidation.IFailure;
67
+ }
68
+ })();
69
+ if (result.success === false) {
70
+ setComposerError(result.errors);
71
+ return;
72
+ }
73
+
74
+ // READY TO DOWNLOAD
75
+ setStep(2);
76
+ setFiles(result.data.files);
77
+ })().catch((exp) => {
78
+ console.error("unknown error", exp);
79
+ });
80
+ }, []);
81
+ return (
82
+ <div
83
+ style={{
84
+ width: "100%",
85
+ height: "100%",
86
+ overflow: "hidden",
87
+ }}
88
+ >
89
+ <div
90
+ style={{
91
+ padding: 25,
92
+ overflow: "auto",
93
+ }}
94
+ >
95
+ <Typography variant="h4">Nestia Editor</Typography>
96
+ <hr />
97
+ <br />
98
+ <Stepper activeStep={step} orientation="vertical" nonLinear={true}>
99
+ <Step key={0}>
100
+ <StepLabel>
101
+ <Typography variant="h5">Loading OpenAPI Document</Typography>
102
+ </StepLabel>
103
+ <StepContent>
104
+ <br />
105
+ <CircularProgress size={100} color="success" />
106
+ <br />
107
+ <br />
108
+ {typeof props.swagger === "string" ? (
109
+ <>
110
+ <p>Fetching OpenAPI Document from</p>
111
+ <p>
112
+ <a href={props.swagger} target="_blank">
113
+ {props.swagger}
114
+ </a>
115
+ </p>
116
+ </>
117
+ ) : (
118
+ "Delivering OpenAPI Document to the composer"
119
+ )}
120
+ {fetchError !== null ? (
121
+ <Alert severity="error">
122
+ <AlertTitle>Fetch Error</AlertTitle>
123
+ {fetchError}
124
+ </Alert>
125
+ ) : null}
126
+ </StepContent>
127
+ </Step>
128
+ <Step key={1}>
129
+ <StepLabel>
130
+ <Typography variant="h5">
131
+ Generating Software Development Kit
132
+ </Typography>
133
+ </StepLabel>
134
+ <StepContent>
135
+ <br />
136
+ <CircularProgress size={100} color="success" />
137
+ <br />
138
+ <br />
139
+ Generating SDK functions...
140
+ <br />
141
+ <ul>
142
+ <li>
143
+ total operations: #
144
+ {Object.values(operations)
145
+ .reduce((a, b) => a + b, 0)
146
+ .toLocaleString()}
147
+ </li>
148
+ {Object.entries(operations).map(([method, count]) => (
149
+ <li>
150
+ {method}: #{count.toLocaleString()}
151
+ </li>
152
+ ))}
153
+ </ul>
154
+ {composerError !== null ? (
155
+ <>
156
+ <br />
157
+ <Alert severity="error">
158
+ <AlertTitle>Composition Error</AlertTitle>
159
+ <pre>{JSON.stringify(composerError, null, 2)}</pre>
160
+ </Alert>
161
+ </>
162
+ ) : null}
163
+ </StepContent>
164
+ </Step>
165
+ <Step key={2}>
166
+ <StepLabel>
167
+ <Typography variant="h5">
168
+ Downloading TypeScript Project
169
+ </Typography>
170
+ </StepLabel>
171
+ <StepContent>
172
+ <br />
173
+ {files !== null ? (
174
+ <>
175
+ <p>
176
+ {Object.keys(files).length.toLocaleString()} files are
177
+ ready.
178
+ </p>
179
+ <Button
180
+ variant="contained"
181
+ color="success"
182
+ size="large"
183
+ onClick={() =>
184
+ NestiaEditorArchiver.download({
185
+ name: archive,
186
+ files,
187
+ })
188
+ }
189
+ >
190
+ Download {archive}
191
+ </Button>
192
+ </>
193
+ ) : null}
194
+ </StepContent>
195
+ </Step>
196
+ </Stepper>
197
+ </div>
198
+ </div>
199
+ );
200
+ }
201
+ export namespace NestiaEditorIframe {
202
+ export interface IProps {
203
+ swagger:
204
+ | string
205
+ | SwaggerV2.IDocument
206
+ | OpenApiV3.IDocument
207
+ | OpenApiV3_1.IDocument;
208
+ package?: string;
209
+ keyword?: boolean;
210
+ simulate?: boolean;
211
+ e2e?: boolean;
212
+
213
+ /** @internal */
214
+ mode?: "nest" | "sdk";
215
+
216
+ /** @internal */
217
+ files?: Record<string, string>;
218
+ }
219
+ }
220
+
221
+ const getDocument = async (
222
+ url: string,
223
+ ): Promise<
224
+ SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | string
225
+ > => {
226
+ try {
227
+ const response: Response = await fetch(url);
228
+ if (response.status !== 200) return await response.text();
229
+ else if (url.endsWith(".yaml")) {
230
+ const text: string = await response.text();
231
+ return load(text) as OpenApiV3.IDocument;
232
+ }
233
+ return await response.json();
234
+ } catch (error) {
235
+ if (error instanceof Error) return error.message;
236
+ return "Unknown error";
237
+ }
238
+ };
239
+
240
+ const aggregateOperation = (
241
+ document: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument,
242
+ ): Record<string, number> => {
243
+ const map: Record<string, number> = {};
244
+ if (!(typeof document === "object" && document !== null)) return map;
245
+ for (const collection of Object.values(document.paths ?? {}))
246
+ if (typeof collection === "object" && collection !== null)
247
+ for (const [method] of Object.entries(collection))
248
+ if (
249
+ method === "head" ||
250
+ method === "get" ||
251
+ method === "post" ||
252
+ method === "patch" ||
253
+ method === "put" ||
254
+ method === "delete"
255
+ )
256
+ map[method] = (map[method] ?? 0) + 1;
257
+ return map;
258
+ };