@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.
Files changed (37) hide show
  1. package/dist/assets/{index-5lpEeH1X.js → index-DIkEkcTz.js} +132 -132
  2. package/dist/index.html +1 -1
  3. package/lib/NestiaEditorApplication.d.ts +10 -0
  4. package/lib/NestiaEditorApplication.js +20 -4
  5. package/lib/NestiaEditorApplication.js.map +1 -1
  6. package/lib/NestiaEditorApplication.mjs +17 -1
  7. package/lib/NestiaEditorIframe.d.ts +31 -0
  8. package/lib/NestiaEditorIframe.js +22 -4
  9. package/lib/NestiaEditorIframe.js.map +1 -1
  10. package/lib/NestiaEditorIframe.mjs +49 -10
  11. package/lib/NestiaEditorModule.d.ts +46 -0
  12. package/lib/NestiaEditorModule.js +96 -24
  13. package/lib/NestiaEditorModule.js.map +1 -1
  14. package/lib/NestiaEditorModule.mjs +27 -13
  15. package/lib/NestiaEditorUploader.d.ts +19 -0
  16. package/lib/NestiaEditorUploader.js +10 -0
  17. package/lib/NestiaEditorUploader.js.map +1 -1
  18. package/lib/NestiaEditorUploader.mjs +11 -1
  19. package/lib/internal/NestiaEditorArchiver.d.ts +35 -3
  20. package/lib/internal/NestiaEditorArchiver.js +60 -8
  21. package/lib/internal/NestiaEditorArchiver.js.map +1 -1
  22. package/lib/internal/NestiaEditorArchiver.mjs +25 -5
  23. package/lib/internal/NestiaEditorComposer.d.ts +68 -0
  24. package/lib/internal/NestiaEditorComposer.js +27 -0
  25. package/lib/internal/NestiaEditorComposer.js.map +1 -1
  26. package/lib/internal/NestiaEditorFileUploader.d.ts +21 -0
  27. package/lib/internal/NestiaEditorFileUploader.js +12 -0
  28. package/lib/internal/NestiaEditorFileUploader.js.map +1 -1
  29. package/lib/internal/NestiaEditorFileUploader.mjs +12 -0
  30. package/package.json +9 -8
  31. package/src/NestiaEditorApplication.tsx +19 -3
  32. package/src/NestiaEditorIframe.tsx +61 -6
  33. package/src/NestiaEditorModule.ts +111 -35
  34. package/src/NestiaEditorUploader.tsx +19 -0
  35. package/src/internal/NestiaEditorArchiver.ts +65 -10
  36. package/src/internal/NestiaEditorComposer.ts +78 -0
  37. package/src/internal/NestiaEditorFileUploader.tsx +21 -0
@@ -11,24 +11,72 @@ import * as prettierTsPlugin from "prettier/plugins/typescript";
11
11
  import { format } from "prettier/standalone";
12
12
  import { IValidation } from "typia";
13
13
 
14
+ /**
15
+ * Composes the files of a project from an OpenAPI document.
16
+ *
17
+ * It validates and converts the document with `@nestia/migrate`, then formats
18
+ * the TypeScript files with Prettier's standalone build.
19
+ *
20
+ * @evidence contracts/common.md#principled-implementation The composer delegates conversion to `NestiaMigrateApplication`, which owns the OpenAPI semantics, and formats each `.ts` output with Prettier; a file that fails to format keeps its unformatted text.
21
+ * @evidence contracts/common.md#clear-and-simple-design One namespace with two public entry points that select the migration mode and retain the legacy workspace launch metadata; the shared flow is one private curried function.
22
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Conversion and formatting use the public APIs of `@nestia/migrate` and Prettier; a formatting failure is logged and the file is kept as generated.
23
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the composer produces and which libraries do the work.
24
+ */
14
25
  export namespace NestiaEditorComposer {
26
+ /**
27
+ * Input of the composer: the OpenAPI document, the generator options, and the
28
+ * package name.
29
+ *
30
+ * The internal `files` member bypasses conversion and returns the given files
31
+ * unchanged.
32
+ *
33
+ * @evidence contracts/common.md#principled-implementation The fields are the migrate options the editor exposes plus the document, and `files` lets a caller supply an already composed project.
34
+ * @evidence contracts/common.md#clear-and-simple-design A flat property record; the document type is the union of the supported OpenAPI and Swagger versions.
35
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No field is defaulted here; the callers own the defaults.
36
+ * @evidence contracts/common.md#meaningful-documentation The comment states the inputs and the internal member.
37
+ */
15
38
  export interface IProps {
39
+ /** OpenAPI or Swagger source to validate before conversion. */
16
40
  document:
17
41
  | SwaggerV2.IDocument
18
42
  | OpenApiV3.IDocument
19
43
  | OpenApiV3_1.IDocument
20
44
  | OpenApiV3_2.IDocument;
45
+
46
+ /** Include generated E2E functions. */
21
47
  e2e: boolean;
48
+
49
+ /** Group generated parameters into a keyword object. */
22
50
  keyword: boolean;
51
+
52
+ /** Include SDK mockup simulators. */
23
53
  simulate: boolean;
54
+
55
+ /** Package identity passed to the migration generator. */
24
56
  package?: string;
57
+
25
58
  /** @internal */
26
59
  files?: Record<string, string>;
27
60
  }
61
+ /**
62
+ * Output of the composer: the files, the files to open, the start script, and
63
+ * the skipped operations.
64
+ *
65
+ * @evidence contracts/common.md#principled-implementation The files carry the downloadable project and skipped exposes incomplete conversion. openFile and startScript are legacy workspace metadata with no reader in the current zip UI.
66
+ * @evidence contracts/common.md#clear-and-simple-design A flat property record without behavior.
67
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Every member is produced by the composer or the migrate application; none is a fixture value.
68
+ * @evidence contracts/common.md#meaningful-documentation The comment names the members and the `skipped` member documents itself.
69
+ */
28
70
  export interface IOutput {
71
+ /** Relative project paths mapped to UTF-8 text. */
29
72
  files: Record<string, string>;
73
+
74
+ /** Legacy comma-separated workspace editor entry paths. */
30
75
  openFile: string;
76
+
77
+ /** Legacy workspace launch commands; zip downloads do not execute them. */
31
78
  startScript: string[];
79
+
32
80
  /**
33
81
  * Operations `@nestia/migrate` could not convert, left out of the files.
34
82
  *
@@ -37,12 +85,34 @@ export namespace NestiaEditorComposer {
37
85
  */
38
86
  skipped: ISkipped[];
39
87
  }
88
+ /**
89
+ * An operation that could not be converted: its upper-case HTTP method, its
90
+ * path, and the reasons.
91
+ *
92
+ * @evidence contracts/common.md#principled-implementation The migrate application reports errors by method, path, and messages, and the composer normalizes the method to upper case for display.
93
+ * @evidence contracts/common.md#clear-and-simple-design Three fields with no behavior.
94
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The values are copied from the migrate errors.
95
+ * @evidence contracts/common.md#meaningful-documentation The comment states each field.
96
+ */
40
97
  export interface ISkipped {
98
+ /** Upper-case HTTP method identifying the omitted operation. */
41
99
  method: string;
100
+
101
+ /** OpenAPI path identifying the omitted operation. */
42
102
  path: string;
103
+
104
+ /** Conversion diagnostics supplied by the migrate application. */
43
105
  messages: string[];
44
106
  }
45
107
 
108
+ /**
109
+ * Composes a NestJS project from an OpenAPI document.
110
+ *
111
+ * @evidence contracts/common.md#principled-implementation It runs the shared flow with the migrate application's `nest` output, the `README.md,test/start.ts` files to open, and the `build:test,test` start script.
112
+ * @evidence contracts/common.md#clear-and-simple-design A one-expression binding of the shared flow.
113
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The mode selects the public migrate operation. Returned launch metadata comes from the former embedded workspace flow; zip delivery does not read or execute it.
114
+ * @evidence contracts/common.md#meaningful-documentation The comment names the project kind produced.
115
+ */
46
116
  export const nest = (props: IProps): Promise<IValidation<IOutput>> =>
47
117
  compose({
48
118
  openFile: "README.md,test/start.ts",
@@ -50,6 +120,14 @@ export namespace NestiaEditorComposer {
50
120
  migrate: (app) => app.nest(props),
51
121
  })(props);
52
122
 
123
+ /**
124
+ * Composes a software development kit project from an OpenAPI document.
125
+ *
126
+ * @evidence contracts/common.md#principled-implementation It runs the shared flow with the migrate application's `sdk` output, the `README.md,test/start.ts` files to open, and the `swagger` and `hello` start scripts.
127
+ * @evidence contracts/common.md#clear-and-simple-design A one-expression binding of the shared flow.
128
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The mode selects the public migrate operation. Returned launch metadata comes from the former embedded workspace flow; zip delivery does not read or execute it.
129
+ * @evidence contracts/common.md#meaningful-documentation The comment names the project kind produced.
130
+ */
53
131
  export const sdk = async (props: IProps): Promise<IValidation<IOutput>> =>
54
132
  compose({
55
133
  openFile: "README.md,test/start.ts",
@@ -3,6 +3,18 @@ import { load } from "js-yaml";
3
3
  import React from "react";
4
4
  import FileUpload, { type ExtendedFileProps } from "react-mui-fileuploader";
5
5
 
6
+ /**
7
+ * A file picker that reads an OpenAPI document from a JSON or YAML file.
8
+ *
9
+ * The last chosen file is read and parsed by its extension, and the result is passed to `onChange` with the parsed document, or with an error message when the content does not parse. Clearing the selection reports `null` for both.
10
+ *
11
+ * A file-reading failure rejects the uploader callback before parsing; it is not reported through `onChange`. Parsing reports content without validating its OpenAPI shape; the composer performs that validation.
12
+ *
13
+ * @evidence contracts/common.md#principled-implementation The file is decoded as UTF-8 text and parsed with `JSON.parse` for a `json` extension and with `js-yaml` otherwise; a parse failure is reported with the message for the format, and only the last chosen file is kept, matching the single-file picker.
14
+ * @evidence contracts/common.md#clear-and-simple-design One component wraps the third-party uploader and owns only reading and parsing; the form around it belongs to `NestiaEditorUploader`.
15
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The parser is chosen by the file extension alone; no document name or content is special-cased.
16
+ * @evidence contracts/common.md#meaningful-documentation The comment states which file is read, how it is parsed, and what `onChange` receives in each case.
17
+ */
6
18
  export function NestiaEditorFileUploader(
7
19
  props: NestiaEditorFileUploader.IProps,
8
20
  ) {
@@ -51,8 +63,17 @@ export function NestiaEditorFileUploader(
51
63
  />
52
64
  );
53
65
  }
66
+ /**
67
+ * Properties of {@link NestiaEditorFileUploader}.
68
+ *
69
+ * @evidence contracts/common.md#principled-implementation The namespace holds the property type of the component with the same name.
70
+ * @evidence contracts/common.md#clear-and-simple-design It contains one interface with one callback.
71
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It adds no behavior.
72
+ * @evidence contracts/common.md#meaningful-documentation The comment names the component the properties belong to.
73
+ */
54
74
  export namespace NestiaEditorFileUploader {
55
75
  export interface IProps {
76
+ /** Receives parsed file content, parse failures, or null/null when cleared. */
56
77
  onChange: (
57
78
  swagger:
58
79
  | SwaggerV2.IDocument